From bfb3463529b96dd73e025cfb5957d832a06bcf17 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Mon, 2 May 2022 12:02:26 -0400 Subject: [PATCH] witches no longer drink potions or join raids if swept --- .../at/petrak/hexcasting/mixin/MixinRaider.java | 17 +++++++++++++++++ .../at/petrak/hexcasting/mixin/MixinWitch.java | 17 +++++++++++++++++ src/main/resources/hexcasting.mixins.json | 4 +++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/java/at/petrak/hexcasting/mixin/MixinRaider.java create mode 100644 src/main/java/at/petrak/hexcasting/mixin/MixinWitch.java diff --git a/src/main/java/at/petrak/hexcasting/mixin/MixinRaider.java b/src/main/java/at/petrak/hexcasting/mixin/MixinRaider.java new file mode 100644 index 00000000..e7a6eaf6 --- /dev/null +++ b/src/main/java/at/petrak/hexcasting/mixin/MixinRaider.java @@ -0,0 +1,17 @@ +package at.petrak.hexcasting.mixin; + +import at.petrak.hexcasting.common.misc.Brainsweeping; +import net.minecraft.world.entity.raid.Raider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +// Prevents the witch from joining a raid +@Mixin(Raider.class) +public class MixinRaider { + @Redirect(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/raid/Raider;isAlive()Z")) + private boolean isAliveForAiPurposes(Raider instance) { + var self = (Raider) (Object) this; + return self.isAlive() && !Brainsweeping.isBrainswept(self); + } +} diff --git a/src/main/java/at/petrak/hexcasting/mixin/MixinWitch.java b/src/main/java/at/petrak/hexcasting/mixin/MixinWitch.java new file mode 100644 index 00000000..17174979 --- /dev/null +++ b/src/main/java/at/petrak/hexcasting/mixin/MixinWitch.java @@ -0,0 +1,17 @@ +package at.petrak.hexcasting.mixin; + +import at.petrak.hexcasting.common.misc.Brainsweeping; +import net.minecraft.world.entity.monster.Witch; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +// Prevents the witch from drinking potions +@Mixin(Witch.class) +public class MixinWitch { + @Redirect(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/monster/Witch;isAlive()Z")) + private boolean isAliveForAiPurposes(Witch instance) { + var self = (Witch) (Object) this; + return self.isAlive() && !Brainsweeping.isBrainswept(self); + } +} diff --git a/src/main/resources/hexcasting.mixins.json b/src/main/resources/hexcasting.mixins.json index 01cce570..eb4c78e9 100644 --- a/src/main/resources/hexcasting.mixins.json +++ b/src/main/resources/hexcasting.mixins.json @@ -6,6 +6,8 @@ "package": "at.petrak.hexcasting.mixin", "mixins": [ "MixinMob", - "MixinVillager" + "MixinRaider", + "MixinVillager", + "MixinWitch" ] }