Unicopia/src/main/java/com/minelittlepony/unicopia/mixin/MixinTargetPredicate.java

31 lines
1.1 KiB
Java
Raw Normal View History

2020-09-24 14:49:02 +02:00
package com.minelittlepony.unicopia.mixin;
import javax.annotation.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;
2021-03-03 10:33:23 +01:00
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
2020-09-24 14:49:02 +02:00
import com.minelittlepony.unicopia.entity.Equine;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.TargetPredicate;
@Mixin(TargetPredicate.class)
abstract class MixinTargetPredicate {
@Inject(method = "test", at = @At("HEAD"), cancellable = true)
public void onTest(@Nullable LivingEntity baseEntity, LivingEntity targetEntity, CallbackInfoReturnable<Boolean> info) {
Equine<?> eq = Equine.of(targetEntity);
if (eq instanceof Pony) {
2021-03-03 10:33:23 +01:00
((Pony)eq).getSpellSlot().get(SpellType.DISGUISE, true).ifPresent(spell -> {
if (spell.getDisguise().getAppearance() == baseEntity) {
2020-09-24 14:49:02 +02:00
info.setReturnValue(false);
}
});
}
}
}