Skip to content

Commit b329c17

Browse files
authored
Fix tool head replace recipe (#1403)
1 parent 425c57b commit b329c17

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/main/java/gregtech/common/crafting/ToolHeadReplaceRecipe.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,34 @@ public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World world) {
3333
List<ItemStack> list = new ArrayList<>();
3434

3535
for (int i = 0; i < inv.getSizeInventory(); i++) {
36-
ItemStack itemstack = inv.getStackInSlot(i);
37-
38-
if (!itemstack.isEmpty()) {
39-
list.add(itemstack);
40-
41-
if (list.size() > 1) {
42-
ItemStack stack = list.get(0);
43-
44-
IGTTool tool;
45-
UnificationEntry toolHead;
46-
if (itemstack.getItem() instanceof IGTTool) {
47-
tool = (IGTTool) itemstack.getItem();
48-
toolHead = OreDictUnifier.getUnificationEntry(stack);
49-
} else if (stack.getItem() instanceof IGTTool) {
50-
tool = (IGTTool) stack.getItem();
51-
toolHead = OreDictUnifier.getUnificationEntry(itemstack);
52-
} else return false;
53-
54-
if (!tool.isElectric()) return false;
55-
if (toolHead == null) return false;
56-
IGTTool[] output = TOOL_HEAD_TO_TOOL_MAP.get(toolHead.orePrefix);
57-
return output != null && output[tool.getElectricTier()] != null;
36+
ItemStack stack = inv.getStackInSlot(i);
37+
if (!stack.isEmpty()) {
38+
list.add(stack);
39+
if (list.size() > 2) {
40+
return false;
5841
}
5942
}
6043
}
44+
45+
if (list.size() == 2) {
46+
ItemStack stack1 = list.get(0);
47+
ItemStack stack2 = list.get(1);
48+
49+
IGTTool tool;
50+
UnificationEntry toolHead;
51+
if (stack1.getItem() instanceof IGTTool) {
52+
tool = (IGTTool) stack1.getItem();
53+
toolHead = OreDictUnifier.getUnificationEntry(stack2);
54+
} else if (stack2.getItem() instanceof IGTTool) {
55+
tool = (IGTTool) stack2.getItem();
56+
toolHead = OreDictUnifier.getUnificationEntry(stack1);
57+
} else return false;
58+
59+
if (!tool.isElectric()) return false;
60+
if (toolHead == null) return false;
61+
IGTTool[] output = TOOL_HEAD_TO_TOOL_MAP.get(toolHead.orePrefix);
62+
return output != null && output[tool.getElectricTier()] != null;
63+
}
6164
return false;
6265
}
6366

0 commit comments

Comments
 (0)