Skip to content

Commit

Permalink
Fixed a bug where enchantments on chestplate would get removed when u…
Browse files Browse the repository at this point in the history
…sing a piggy backpack

Fixed a bug when inventory is full, no chestplate is on but the piggy backpack doesn't work
Now giving back the chestplate where the piggy backpack item was
  • Loading branch information
K0LALA committed Jul 5, 2024
1 parent 8ffc469 commit 9987cc3
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,20 @@ public InteractionResult interactLivingEntity(ItemStack stack, Player playerIn,
// is the chest slot empty?
ItemStack chestArmor = playerIn.getItemBySlot(EquipmentSlot.CHEST);

// need enough space to exchange the chest armor
if (chestArmor.getItem() != this && playerIn.getInventory().getFreeSlot() == -1) {
// not enough inventory space
return InteractionResult.PASS;
if(chestArmor != ItemStack.EMPTY) {
// need enough space to exchange the chest armor
if (chestArmor.getItem() != this && playerIn.getInventory().getFreeSlot() == -1) {
// not enough inventory space
return InteractionResult.PASS;
}
}

// try carrying the entity
if (this.pickupEntity(playerIn, target)) {
// unequip old armor
if (chestArmor.getItem() != this) {
ItemHandlerHelper.giveItemToPlayer(playerIn, chestArmor);
int piggyBackpackSlot = playerIn.getInventory().findSlotMatchingItem(stack);
playerIn.getInventory().add(piggyBackpackSlot, chestArmor);
chestArmor = ItemStack.EMPTY;
}

Expand Down

0 comments on commit 9987cc3

Please sign in to comment.