Skip to content

Commit

Permalink
fix: items no longer duplicated when player dies
Browse files Browse the repository at this point in the history
closes #53
  • Loading branch information
Jamalam360 committed Jul 29, 2024
1 parent eba4f94 commit 358b0cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Fix (#31).
- Fix duplication when player dies (#53).
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public abstract class InventoryMixin {
target = "Lnet/minecraft/core/NonNullList;get(I)Ljava/lang/Object;"
)
)
private ItemStack utilitybelt$useBeltStackForDestroySpeed(ItemStack original) {
private Object utilitybelt$useBeltStackForDestroySpeed(Object original) {
StateManager stateManager = StateManager.getStateManager(player);
if (stateManager.isInBelt(this.player)) {
ItemStack belt = UtilityBeltItem.getBelt(this.player);
Expand All @@ -61,6 +61,7 @@ public abstract class InventoryMixin {
return inv.getItem(stateManager.getSelectedBeltSlot(this.player));
}
}

return original;
}

Expand Down Expand Up @@ -184,25 +185,7 @@ public abstract class InventoryMixin {
}
}
}

@Inject(method = "dropAll", at = @At("HEAD"))
private void utilitybelt$dropAllFromUtilityBelt(CallbackInfo ci) {
ItemStack belt = UtilityBeltItem.getBelt(this.player);
if (belt != null) {
UtilityBeltInventory.Mutable inv = StateManager.getStateManager(this.player).getMutableInventory(this.player);

for (int i = 0; i < inv.getContainerSize(); i++) {
ItemStack itemStack = inv.getItem(i);
if (!itemStack.isEmpty()) {
this.player.drop(itemStack, true, false);
inv.setItem(i, ItemStack.EMPTY);
}
}

StateManager.getStateManager(this.player).setInventory(this.player, inv);
}
}


@Inject(
method = "isEmpty",
at = @At("HEAD"),
Expand Down

0 comments on commit 358b0cd

Please sign in to comment.