Skip to content

Commit

Permalink
chore(events): preprocess MixinEntityPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Aug 9, 2024
1 parent 053d4fd commit 18ba4b0
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,29 @@

@Mixin(EntityPlayer.class)
public class MixinEntityPlayer {
private static final String skytils$entityInteractTarget =
//#if MC>12000
//$$ "Lnet/minecraft/entity/player/PlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;";
//#else
"Lnet/minecraft/entity/player/EntityPlayer;getCurrentEquippedItem()Lnet/minecraft/item/ItemStack;";
//#endif

@Inject(method = "attackTargetEntityWithCurrentItem", at = @At("HEAD"), cancellable = true)
private void onAttack(Entity targetEntity, CallbackInfo ci) {
if (EventsKt.postCancellableSync(new EntityAttackEvent((Entity) (Object) this, targetEntity))) {
ci.cancel();
}
}

@Inject(method = "interactWith", at = @At(value = "INVOKE", target = skytils$entityInteractTarget), cancellable = true)
@Inject(
method =
//#if MC>12000
//$$ "interact",
//#else
"interactWith",
//#endif
at = @At(value = "INVOKE",
target =
//#if MC>12000
//$$ "Lnet/minecraft/entity/player/PlayerEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;",
//#else
"Lnet/minecraft/entity/player/EntityPlayer;getCurrentEquippedItem()Lnet/minecraft/item/ItemStack;",
//#endif
ordinal = 0
), cancellable = true)
private void onEntityInteract(Entity targetEntity,
//#if MC>12000
//$$ Hand hand,
Expand Down

0 comments on commit 18ba4b0

Please sign in to comment.