Guardians no longer attack seaponies

This commit is contained in:
Sollace 2023-11-25 21:42:58 +00:00
parent ea78257ffd
commit fb7a85c5d8
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 24 additions and 4 deletions

View file

@ -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<Boolean> info) {
if (EquinePredicates.PLAYER_SEAPONY.test(livingEntity)) {
info.setReturnValue(false);
}
}
}

View file

@ -6,16 +6,14 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.api.pony.PonyPosture; import com.minelittlepony.api.pony.PonyPosture;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
@Mixin(PonyPosture.class) @Mixin(PonyPosture.class)
abstract class MixinPonyPosture { abstract class MixinPonyPosture {
@Inject(method = "isPartiallySubmerged", at = @At("HEAD"), cancellable = true) @Inject(method = "isPartiallySubmerged", at = @At("HEAD"), cancellable = true)
private static void isPartiallySubmerged(LivingEntity entity, CallbackInfoReturnable<Boolean> info) { private static void isPartiallySubmerged(LivingEntity entity, CallbackInfoReturnable<Boolean> info) {
if (Pony.of(entity).filter(pony -> pony.getCompositeRace().includes(Race.SEAPONY)).isPresent()) { if (EquinePredicates.PLAYER_SEAPONY.test(entity)) {
info.setReturnValue(true); info.setReturnValue(true);
} }
} }

View file

@ -24,6 +24,7 @@
"MixinFallingBlock", "MixinFallingBlock",
"MixinFallingBlockEntity", "MixinFallingBlockEntity",
"MixinFlowableFluid", "MixinFlowableFluid",
"MixinGuardianTargetPredicate",
"MixinItem", "MixinItem",
"MixinItemEntity", "MixinItemEntity",
"MixinLivingEntity", "MixinLivingEntity",