Skip to content

Commit

Permalink
Fixed build failing
Browse files Browse the repository at this point in the history
  • Loading branch information
LabsZero authored Nov 16, 2024
1 parent d869dc7 commit 7a0f570
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ public abstract class ItemStackMixin_NeoForge implements ItemStackBridge, IItemS
@Shadow private int count;
// @formatter:on

@Decorate(method = "hurtAndBreak",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;processDurabilityChange(Lnet/minecraft/world/item/ItemStack;I)I"))
private int arclight$itemDamage(ServerLevel serverLevel, ItemStack itemStack, int damage, @Local(ordinal = 0) LivingEntity damager) {
// Ensure the itemStack is not null
@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"))
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, damage);
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);
event.getPlayer().getServer().getPluginManager().callEvent(event);
Expand All @@ -61,16 +59,17 @@ public abstract class ItemStackMixin_NeoForge implements ItemStackBridge, IItemS
return result;
}

@Inject(method = "hurtAndBreak(ILnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;Ljava/util/function/Consumer;)V",
at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"))
@Inject(method = "hurtAndBreak(ILnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;Ljava/util/function/Consumer;)V", at = @At(value = "INVOKE", target = "Ljava/util/function/Consumer;accept(Ljava/lang/Object;)V"))
private void arclight$itemBreak(int amount, ServerLevel level, @org.jetbrains.annotations.Nullable LivingEntity livingEntity, Consumer<Item> onBroken, CallbackInfo ci) {
if (this.count == 1 && livingEntity instanceof ServerPlayer serverPlayer) {
CraftEventFactory.callPlayerItemBreakEvent(serverPlayer, (ItemStack) (Object) this);
}
}

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

Expand Down

0 comments on commit 7a0f570

Please sign in to comment.