Skip to content

Commit

Permalink
Fix tool head replace recipe (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Jan 9, 2023
1 parent 425c57b commit b329c17
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/main/java/gregtech/common/crafting/ToolHeadReplaceRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,34 @@ public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World world) {
List<ItemStack> list = new ArrayList<>();

for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack itemstack = inv.getStackInSlot(i);

if (!itemstack.isEmpty()) {
list.add(itemstack);

if (list.size() > 1) {
ItemStack stack = list.get(0);

IGTTool tool;
UnificationEntry toolHead;
if (itemstack.getItem() instanceof IGTTool) {
tool = (IGTTool) itemstack.getItem();
toolHead = OreDictUnifier.getUnificationEntry(stack);
} else if (stack.getItem() instanceof IGTTool) {
tool = (IGTTool) stack.getItem();
toolHead = OreDictUnifier.getUnificationEntry(itemstack);
} else return false;

if (!tool.isElectric()) return false;
if (toolHead == null) return false;
IGTTool[] output = TOOL_HEAD_TO_TOOL_MAP.get(toolHead.orePrefix);
return output != null && output[tool.getElectricTier()] != null;
ItemStack stack = inv.getStackInSlot(i);
if (!stack.isEmpty()) {
list.add(stack);
if (list.size() > 2) {
return false;
}
}
}

if (list.size() == 2) {
ItemStack stack1 = list.get(0);
ItemStack stack2 = list.get(1);

IGTTool tool;
UnificationEntry toolHead;
if (stack1.getItem() instanceof IGTTool) {
tool = (IGTTool) stack1.getItem();
toolHead = OreDictUnifier.getUnificationEntry(stack2);
} else if (stack2.getItem() instanceof IGTTool) {
tool = (IGTTool) stack2.getItem();
toolHead = OreDictUnifier.getUnificationEntry(stack1);
} else return false;

if (!tool.isElectric()) return false;
if (toolHead == null) return false;
IGTTool[] output = TOOL_HEAD_TO_TOOL_MAP.get(toolHead.orePrefix);
return output != null && output[tool.getElectricTier()] != null;
}
return false;
}

Expand Down

0 comments on commit b329c17

Please sign in to comment.