Skip to content

Commit

Permalink
Fix Upgrade Core recipe (Fixes #104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Oct 3, 2024
1 parent eb068ca commit 5fbdd91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21.1 2024-09-27T23:05:17.3373723 Recipes
// 1.21.1 2024-10-03T21:15:00.664536 Recipes
3e6d620f7add54f0a4894209d84ba72c8bebe1ca data/forcecraft/advancement/recipes/building_blocks/force_black_torch.json
9c1f7e54da6ecd6a41cec7802d0c30a0c915b7c1 data/forcecraft/advancement/recipes/building_blocks/force_blue_torch.json
d82ae03117d94de897534994565aceca4eafb713 data/forcecraft/advancement/recipes/building_blocks/force_brick.json
Expand Down Expand Up @@ -630,7 +630,7 @@ c33a3ca56210bbe9f112551d612e3a365fd391be data/forcecraft/recipe/transmutation/st
8e8ad90aa1dd22b531e26eb610da20d2e5d1bd8c data/forcecraft/recipe/transmutation/stick_from_wooden_sword.json
e29e842cc19006d27f61ec181abd1c73f98e3f8e data/forcecraft/recipe/transmutation/string_from_bow.json
6ea4032498758de24d685a9ad0afcead6fbb762a data/forcecraft/recipe/transmutation/tripwire_hook_from_crossbow.json
73e50e1fd1ce94f55236bc21a06a71b65516eae9 data/forcecraft/recipe/transmutation/upgrade_core.json
b2ac238f265edc5d2d7a4dc9ebb29c154abbff45 data/forcecraft/recipe/transmutation/upgrade_core.json
49d7fe867a7c70e5ff289e7220f74a67bd81d3d7 data/forcecraft/recipe/transmutation/upgrade_tome.json
e0dfc55d30600af7fe71289e372f2cf255025e4d data/forcecraft/recipe/treasure_core.json
2f986aa5a44c0cde4b444444f28c194879ab9068 data/forcecraft/recipe/white_force_furnace_from_dye.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
},
{
"type": "neoforge:components",
"components": {
"forcecraft:tome_experience": 100
},
"components": {},
"items": "forcecraft:experience_tome"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1773,8 +1773,8 @@ private void addTransmutationRecipes(RecipeOutput output) {
.save(output, Reference.modLoc("transmutation/upgrade_tome"));

TransmutationRecipeBuilder.transmutation(ForceRegistry.UPGRADE_CORE.get())
.requires(DataComponentIngredient.of(false, DataComponentPredicate.builder()
.expect(ForceComponents.TOME_EXPERIENCE.get(), 100).build(), ForceRegistry.EXPERIENCE_TOME.get()))
.requires(DataComponentIngredient.of(false, DataComponentPredicate.builder().build(),
ForceRegistry.EXPERIENCE_TOME.get()))
.unlockedBy("has_experience_tome", has(ForceRegistry.EXPERIENCE_TOME.get()))
.save(output, Reference.modLoc("transmutation/upgrade_core"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ public boolean matches(CraftingInput inv, Level level) {
else inputs.add(itemstack);
} else {
if (itemstack.getItem() instanceof ExperienceTomeItem) {
if (itemstack.has(ForceComponents.TOME_EXPERIENCE) && itemstack.getOrDefault(ForceComponents.TOME_EXPERIENCE, 0) < 100) {
int experience = itemstack.getOrDefault(ForceComponents.TOME_EXPERIENCE, 0);

if (itemstack.has(ForceComponents.TOME_EXPERIENCE) && experience < 100) {
return false;
} else {
ItemStack experienceTome = new ItemStack(ForceRegistry.EXPERIENCE_TOME.get());
itemstack.set(ForceComponents.TOME_EXPERIENCE, 100);
itemstack.set(ForceComponents.TOME_EXPERIENCE, experience);
if (isSimple)
stackedContents.accountStack(experienceTome, 1);
else inputs.add(experienceTome);
else inputs.add(itemstack);
}
} else {
if (!itemstack.isDamaged()) {
Expand All @@ -107,7 +109,10 @@ public boolean matches(CraftingInput inv, Level level) {
}
}

return stacks == this.ingredients.size() && (isSimple ? stackedContents.canCraft(this, (IntList) null) : RecipeMatcher.findMatches(inputs, this.ingredients) != null);
return stacks == this.ingredients.size() && (isSimple ?
stackedContents.canCraft(this, (IntList) null) :
RecipeMatcher.findMatches(inputs, this.ingredients) != null
);
}

@Override
Expand Down

0 comments on commit 5fbdd91

Please sign in to comment.