Skip to content

Commit

Permalink
Fix IllegalArgumentException: Cannot copy null stack in ItemStackMixi…
Browse files Browse the repository at this point in the history
…n_NeoForge

Fixes IllegalArgumentException: Cannot copy null stack reported in server logs.
  • Loading branch information
LabsZero authored Nov 13, 2024
1 parent 1732a9b commit ae5049e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ public abstract class ItemStackMixin_NeoForge implements ItemStackBridge, IItemS
// @formatter:on

@Decorate(method = "hurtAndBreak(ILnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;Ljava/util/function/Consumer;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;processDurabilityChange(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/item/ItemStack;I)I"))
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;processDurabilityChange(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/item/ItemStack;I)I"))
private int arclight$itemDamage(ServerLevel serverLevel, ItemStack itemStack, int i, @Local(ordinal = 0) LivingEntity damager) throws Throwable {
// Added null check for itemStack
if (itemStack == null) {
return 0;
}

int result = (int) DecorationOps.callsite().invoke(serverLevel, itemStack, i);
if (damager instanceof ServerPlayer) {
PlayerItemDamageEvent event = new PlayerItemDamageEvent(((ServerPlayerEntityBridge) damager).bridge$getBukkitEntity(), CraftItemStack.asCraftMirror((ItemStack) (Object) this), result);
Expand All @@ -64,7 +69,7 @@ public abstract class ItemStackMixin_NeoForge implements ItemStackBridge, IItemS
}

@Deprecated
public void setItem(Item item) {
public void setItem(@Nullable Item item) {
this.item = item;
}

Expand Down

0 comments on commit ae5049e

Please sign in to comment.