Skip to content

Commit

Permalink
Fix quartz knives being immediately consumed on use (AppliedEnergisti…
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored Jul 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7756c19 commit c9729c5
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -69,16 +69,18 @@ public InteractionResultHolder<ItemStack> use(Level level, Player p, Interaction

@Override
public ItemStack getCraftingRemainingItem(ItemStack itemStack) {
var result = itemStack.copy();

var broken = new MutableBoolean(false);
if (CommonHooks.getCraftingPlayer() instanceof ServerPlayer serverPlayer) {
itemStack.hurtAndBreak(1, serverPlayer.serverLevel(), serverPlayer, ignored -> broken.setTrue());
result.hurtAndBreak(1, serverPlayer.serverLevel(), serverPlayer, ignored -> broken.setTrue());
} else {
var currentServer = ServerLifecycleHooks.getCurrentServer();
if (currentServer != null) {
itemStack.hurtAndBreak(1, currentServer.overworld(), null, ignored -> broken.setTrue());
result.hurtAndBreak(1, currentServer.overworld(), null, ignored -> broken.setTrue());
}
}
return broken.getValue() ? ItemStack.EMPTY : itemStack;
return broken.getValue() ? ItemStack.EMPTY : result;
}

@Override

0 comments on commit c9729c5

Please sign in to comment.