diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinGuardianTargetPredicate.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinGuardianTargetPredicate.java new file mode 100644 index 00000000..b7beed91 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinGuardianTargetPredicate.java @@ -0,0 +1,21 @@ +package com.minelittlepony.unicopia.mixin; + +import org.jetbrains.annotations.Nullable; +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.CallbackInfoReturnable; + +import com.minelittlepony.unicopia.EquinePredicates; + +import net.minecraft.entity.LivingEntity; + +@Mixin(targets = "net.minecraft.entity.mob.GuardianEntity$GuardianTargetPredicate") +abstract class MixinGuardianTargetPredicate { + @Inject(method = "test", at = @At("HEAD"), cancellable = true) + private void test(@Nullable LivingEntity livingEntity, CallbackInfoReturnable info) { + if (EquinePredicates.PLAYER_SEAPONY.test(livingEntity)) { + info.setReturnValue(false); + } + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/minelp/MixinPonyPosture.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/minelp/MixinPonyPosture.java index 618907d7..faaa44bc 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/minelp/MixinPonyPosture.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/minelp/MixinPonyPosture.java @@ -6,16 +6,14 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.api.pony.PonyPosture; -import com.minelittlepony.unicopia.Race; -import com.minelittlepony.unicopia.entity.player.Pony; - +import com.minelittlepony.unicopia.EquinePredicates; import net.minecraft.entity.LivingEntity; @Mixin(PonyPosture.class) abstract class MixinPonyPosture { @Inject(method = "isPartiallySubmerged", at = @At("HEAD"), cancellable = true) private static void isPartiallySubmerged(LivingEntity entity, CallbackInfoReturnable info) { - if (Pony.of(entity).filter(pony -> pony.getCompositeRace().includes(Race.SEAPONY)).isPresent()) { + if (EquinePredicates.PLAYER_SEAPONY.test(entity)) { info.setReturnValue(true); } } diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index 0c6d99ef..5acbbf09 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -24,6 +24,7 @@ "MixinFallingBlock", "MixinFallingBlockEntity", "MixinFlowableFluid", + "MixinGuardianTargetPredicate", "MixinItem", "MixinItemEntity", "MixinLivingEntity",