From f4ea6d5ef0a712076bdb072c2ec7c4c9ac6b664c Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 23 Jul 2024 15:01:17 +0200 Subject: [PATCH] Fix collission with other mods changing eye height/hitboxes --- .../client/mixin/MixinPlayerEntity.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinPlayerEntity.java b/src/main/java/com/minelittlepony/client/mixin/MixinPlayerEntity.java index 5bc60a6a..5e7eb444 100644 --- a/src/main/java/com/minelittlepony/client/mixin/MixinPlayerEntity.java +++ b/src/main/java/com/minelittlepony/client/mixin/MixinPlayerEntity.java @@ -7,15 +7,13 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.minelittlepony.client.render.EquineRenderManager.RegistrationHandler; import com.minelittlepony.client.render.EquineRenderManager.SyncedPony; @Mixin(PlayerEntity.class) -abstract class MixinPlayerEntity extends LivingEntity implements RegistrationHandler { - MixinPlayerEntity() { super(null, null); } - +abstract class MixinPlayerEntity implements RegistrationHandler { private final SyncedPony syncedPony = new SyncedPony(); @Override @@ -23,14 +21,11 @@ abstract class MixinPlayerEntity extends LivingEntity implements RegistrationHan return syncedPony; } - @Inject(method = "getBaseDimensions", at = @At("RETURN"), cancellable = true) - private void onGetBaseDimensions(EntityPose pose, CallbackInfoReturnable info) { + @ModifyReturnValue(method = "getBaseDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;", + at = @At("RETURN")) + private EntityDimensions modifyEyeHeight(EntityDimensions dimensions, EntityPose pose) { float factor = syncedPony.getCachedPonyData().size().eyeHeightFactor(); - - if (factor != 1) { - EntityDimensions dimensions = info.getReturnValue(); - info.setReturnValue(dimensions.withEyeHeight(dimensions.eyeHeight() * factor)); - } + return factor == 1 ? dimensions : dimensions.withEyeHeight(dimensions.eyeHeight() * factor); } @Inject(method = "tick()V", at = @At("TAIL"))