2020-09-24 14:49:02 +02:00
|
|
|
package com.minelittlepony.unicopia.mixin;
|
|
|
|
|
2021-08-04 15:38:03 +02:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2020-09-24 14:49:02 +02:00
|
|
|
|
|
|
|
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-12-22 15:43:06 +01:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.SpellPredicate;
|
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) {
|
2021-03-06 22:11:17 +01:00
|
|
|
Equine<?> eq = Equine.of(targetEntity).orElse(null);
|
2020-09-24 14:49:02 +02:00
|
|
|
if (eq instanceof Pony) {
|
2021-12-22 15:43:06 +01:00
|
|
|
((Pony)eq).getSpellSlot().get(SpellPredicate.IS_DISGUISE, true).ifPresent(spell -> {
|
2020-09-27 13:29:19 +02:00
|
|
|
if (spell.getDisguise().getAppearance() == baseEntity) {
|
2020-09-24 14:49:02 +02:00
|
|
|
info.setReturnValue(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|