Skip to content

Commit

Permalink
fix: handle unbreakable items correctly in crafting
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Mar 12, 2023
1 parent 74ffa9a commit 06d2bf5
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected void craftShift(Player player, IStorageController storageController) {
if (this.currentRecipe == null)
break;

ItemStack newResult = this.currentRecipe.assemble(this.matrix).copy();
ItemStack newResult = this.currentRecipe.assemble(this.matrix).copy();
if (newResult.getItem() != result.getItem())
break;

Expand Down Expand Up @@ -317,12 +317,11 @@ protected void craftShift(Player player, IStorageController storageController) {
if (stackInSlot.isEmpty()) {
this.matrix.setItem(i, currentCraftingItem);
}
//handle "normal items"
else if (!stackInSlot.getItem().canBeDepleted() && ItemStack.matches(stackInSlot, currentCraftingItem) &&
ItemStack.tagMatches(stackInSlot, currentCraftingItem)) {
//hacky workaround for aquaculture unbreakable fillet knife being mis-interpreted and duped
if (!ForgeRegistries.ITEMS.getKey(stackInSlot.getItem()).toString().equals("aquaculture:neptunium_fillet_knife"))
currentCraftingItem.grow(stackInSlot.getCount());
//handle "normal items" ie non-damagable
else if (!stackInSlot.isDamageableItem() && ItemStack.tagMatches(stackInSlot, currentCraftingItem)) {
//Used to call grow here, but that causes dupes of unbreakable items
//removing it seems not to cause any harm?
// currentCraftingItem.grow(stackInSlot.getCount());
this.matrix.setItem(i, currentCraftingItem);
}
//handle items that consume durability on craft
Expand All @@ -332,6 +331,7 @@ else if (ItemStack.isSame(stackInSlot, currentCraftingItem)) {
//last resort, try to place in player inventory or if that fails, drop.
ItemHandlerHelper.giveItemToPlayer(player, newResult);
}

} else if (!stackInSlot.isEmpty()) {
//decrease the stack size in the matrix
this.matrix.removeItem(i, 1);
Expand Down

0 comments on commit 06d2bf5

Please sign in to comment.