From 7f22bccf87e7eaca00a13d3510c0e39771a9e02a Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Sat, 9 Nov 2024 15:41:12 +0100 Subject: [PATCH] Inline CommonHooks call --- .../java/net/neoforged/neoforge/common/CommonHooks.java | 9 --------- .../neoforge/common/extensions/IItemStackExtension.java | 7 ++++++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/neoforged/neoforge/common/CommonHooks.java b/src/main/java/net/neoforged/neoforge/common/CommonHooks.java index d774909204..34b843d737 100644 --- a/src/main/java/net/neoforged/neoforge/common/CommonHooks.java +++ b/src/main/java/net/neoforged/neoforge/common/CommonHooks.java @@ -738,15 +738,6 @@ public static Player getCraftingPlayer() { return craftingPlayer.get(); } - public static ItemStack getCraftingRemainder(ItemStack stack) { - stack = stack.getItem().getCraftingRemainder(stack); - if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage()) { - EventHooks.onPlayerDestroyItem(craftingPlayer.get(), stack, null); - return ItemStack.EMPTY; - } - return stack; - } - public static boolean onPlayerAttackTarget(Player player, Entity target) { if (NeoForge.EVENT_BUS.post(new AttackEntityEvent(player, target)).isCanceled()) return false; diff --git a/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java b/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java index 3f66b32211..4237f37617 100644 --- a/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java +++ b/src/main/java/net/neoforged/neoforge/common/extensions/IItemStackExtension.java @@ -61,7 +61,12 @@ private ItemStack self() { * @return The resulting ItemStack */ default ItemStack getCraftingRemainder() { - return CommonHooks.getCraftingRemainder(self()); + ItemStack stack = self().getItem().getCraftingRemainder(self()); + if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage()) { + EventHooks.onPlayerDestroyItem(craftingPlayer.get(), stack, null); + return ItemStack.EMPTY; + } + return stack; } /**