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 (#1550)

* Fix IllegalArgumentException: Cannot copy null stack in ItemStackMixin_NeoForge

Fixes IllegalArgumentException: Cannot copy null stack reported in server logs.

* Update ItemStackMixin_NeoForge.java

* Update ItemStackMixin_NeoForge.java

* Update ItemStackMixin_NeoForge.java

* Update build.gradle

* Update ItemStackMixin_NeoForge.java

* Fixed build failing
  • Loading branch information
LabsZero authored Nov 16, 2024
1 parent 1732a9b commit 17f1124
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ 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 {
if (itemStack == null) {
itemStack = ItemStack.EMPTY;
}
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 +67,9 @@ public abstract class ItemStackMixin_NeoForge implements ItemStackBridge, IItemS
}

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

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ allprojects {
fabricLoaderVersion = '0.16.9'
fabricApiVersion = '0.108.0+1.21.1'
forgeVersion = '52.0.28'
neoForgeVersion = '21.1.77'
neoForgeVersion = '21.1.79'
apiVersion = '1.7.3'
toolsVersion = '1.3.0'
mixinVersion = '0.8.5'
Expand Down

0 comments on commit 17f1124

Please sign in to comment.