Skip to content

Commit

Permalink
Try to fix incompatibility with bumblezone (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
2No2Name committed Jan 17, 2025
1 parent f10a886 commit 459de76
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down Expand Up @@ -75,6 +72,25 @@ private void initFields(Entity entity, CallbackInfo ci) {
at = @At("HEAD")
)
public void isHolding(Item item, CallbackInfoReturnable<Boolean> cir) {
this.initHeldItem();
}

@Intrinsic
public ItemStack getHeldItem() {
return this.heldItem;
}

@SuppressWarnings({"UnresolvedMixinReference", "MixinAnnotationTarget"})
@Inject(
method = "getHeldItem",
at = @At("HEAD")
)
private void initHeldItem(CallbackInfoReturnable<ItemStack> callbackInfoReturnable) {
this.initHeldItem();
}

@Unique
private void initHeldItem() {
if (this.heldItem == null) {
this.heldItem = this.entity instanceof LivingEntity ? ((LivingEntity) this.entity).getMainHandStack() : ItemStack.EMPTY;
}
Expand Down

0 comments on commit 459de76

Please sign in to comment.