Skip to content

Commit

Permalink
Fix stack size 1 container items not returning their container when c…
Browse files Browse the repository at this point in the history
…onsumed (#5034)
  • Loading branch information
KnightMiner committed Dec 26, 2022
1 parent 697fb0d commit c0a2061
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Compo

@Override
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity living) {
ItemStack container = stack.getContainerItem();
ItemStack result = super.finishUsingItem(stack, level, living);
Player player = living instanceof Player p ? p : null;
if (player == null || !player.getAbilities().instabuild) {
ItemStack container = stack.getContainerItem().copy();
if (result.isEmpty()) {
return container;
return container.copy();
}
if (player != null) {
if (!player.getInventory().add(container)) {
if (!player.getInventory().add(container.copy())) {
player.drop(stack, false);
}
}
Expand Down

0 comments on commit c0a2061

Please sign in to comment.