There is a bug that lets you duplicate backpack upgrade materials (copper, iron, gold, diamond)
To Reproduce
Steps to reproduce the behavior:
- Open a crafting table
- surround a gold backpack with diamonds, (multiple per slot)
- craft the backpack
- Dupe the diamonds in the crafting grid!, it can even push a stack past 64
Version information:
- Plugin version [e.g. v1.2.0]
Additional context
I actually tracked the bug down to a snippet of BackpackCraftingListener.class starting at line 133 and fixed it, by replacing
for (int i : surrounding = new int[]{0, 1, 2, 3, 5, 6, 7, 8}) {
ItemStack slot = matrix[i];
if (slot == null || slot.getType() == Material.AIR) continue;
if (slot.getAmount() > 1) {
ItemStack reduced = slot.clone();
reduced.setAmount(slot.getAmount() - 1);
inv.setItem(i + 1, reduced);
continue;
}
inv.setItem(i + 1, null);
}
inv.setItem(5, null);
With this
surrounding = new int[]{0, 1, 2, 3, 5, 6, 7, 8};
int[] var7 = surrounding;
int var8 = surrounding.length;
for(int var9 = 0; var9 < var8; ++var9) {
int i = var7[var9];
ItemStack slot = matrix[i];
if (slot != null && slot.getType() != Material.AIR) {
int invSlot = i + 1;
if (slot.getAmount() > 1) {
ItemStack reduced = slot.clone();
reduced.setAmount(slot.getAmount() - 1);
inv.setItem(invSlot, reduced);
} else {
inv.setItem(invSlot, (ItemStack)null);
}
}
}
inv.setItem(5, (ItemStack)null);
There is a bug that lets you duplicate backpack upgrade materials (copper, iron, gold, diamond)
To Reproduce
Steps to reproduce the behavior:
Version information:
Additional context
I actually tracked the bug down to a snippet of BackpackCraftingListener.class starting at line 133 and fixed it, by replacing
for (int i : surrounding = new int[]{0, 1, 2, 3, 5, 6, 7, 8}) {
ItemStack slot = matrix[i];
if (slot == null || slot.getType() == Material.AIR) continue;
if (slot.getAmount() > 1) {
ItemStack reduced = slot.clone();
reduced.setAmount(slot.getAmount() - 1);
inv.setItem(i + 1, reduced);
continue;
}
inv.setItem(i + 1, null);
}
inv.setItem(5, null);
With this
surrounding = new int[]{0, 1, 2, 3, 5, 6, 7, 8};
int[] var7 = surrounding;
int var8 = surrounding.length;