From 06675f3824dc01f6e559a4b62278fe76858381a8 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Mon, 25 Apr 2022 09:46:49 -0400 Subject: [PATCH] fix cleric impetuses not updating, add motion not affecting players, brainsweeping not affecting witches --- .../impetuses/BlockStoredPlayerImpetus.java | 4 ++-- .../casting/operators/spells/OpAddMotion.kt | 1 + .../hexcasting/common/misc/Brainsweeping.java | 18 +++++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java b/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java index 832b8ebc..79d57ebd 100644 --- a/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java +++ b/src/main/java/at/petrak/hexcasting/common/blocks/circles/impetuses/BlockStoredPlayerImpetus.java @@ -44,9 +44,9 @@ public class BlockStoredPlayerImpetus extends BlockAbstractImpetus { if (entity instanceof Player) { // phew, we got something tile.setPlayer(entity.getUUID()); - tile.setChanged(); + level.sendBlockUpdated(pPos, pState, pState, Block.UPDATE_CLIENTS); - pLevel.playSound(pPlayer, pPos, HexSounds.IMPETUS_STOREDPLAYER_DING.get(), SoundSource.BLOCKS, + pLevel.playSound(null, pPos, HexSounds.IMPETUS_STOREDPLAYER_DING.get(), SoundSource.BLOCKS, 1f, 1f); } } diff --git a/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt b/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt index dfd47912..e6339170 100644 --- a/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt +++ b/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/OpAddMotion.kt @@ -41,6 +41,7 @@ object OpAddMotion : SpellOperator { private data class Spell(val target: Entity, val motion: Vec3) : RenderedSpell { override fun cast(ctx: CastingContext) { target.push(motion.x, motion.y, motion.z) + target.hurtMarked = true // Whyyyyy } } } diff --git a/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java b/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java index 8988420c..b73f8174 100644 --- a/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java +++ b/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java @@ -11,6 +11,7 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.Brain; import net.minecraft.world.entity.npc.Villager; import net.minecraft.world.entity.npc.VillagerDataHolder; +import net.minecraft.world.entity.raid.Raider; import net.minecraftforge.event.entity.living.LivingConversionEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -21,12 +22,16 @@ public class Brainsweeping { public static final String TAG_BRAINSWEPT = "hexcasting:brainswept"; + private static boolean isValidTarget(LivingEntity entity) { + return entity instanceof VillagerDataHolder || entity instanceof Raider; + } + public static boolean isBrainswept(LivingEntity entity) { - return entity instanceof VillagerDataHolder && entity.getPersistentData().getBoolean(TAG_BRAINSWEPT); + return isValidTarget(entity) && entity.getPersistentData().getBoolean(TAG_BRAINSWEPT); } public static void brainsweep(LivingEntity entity) { - if (entity instanceof VillagerDataHolder) { + if (isValidTarget(entity)) { entity.getPersistentData().putBoolean(TAG_BRAINSWEPT, true); if (entity instanceof Mob mob) @@ -50,7 +55,7 @@ public class Brainsweeping { public static void startTracking(PlayerEvent.StartTracking evt) { Entity target = evt.getTarget(); if (evt.getPlayer() instanceof ServerPlayer serverPlayer && - target instanceof VillagerDataHolder && target instanceof LivingEntity living && isBrainswept(living)) { + target instanceof LivingEntity living && isBrainswept(living)) { HexMessages.getNetwork().send(PacketDistributor.PLAYER.with(() -> serverPlayer), MsgBrainsweepAck.of(living)); } } @@ -63,11 +68,10 @@ public class Brainsweeping { } @SubscribeEvent - public static void copyBrainsweepBetweenZombieAndVillager(LivingConversionEvent.Post evt) { + public static void copyBrainsweepBetweenZombieVillagerAndWitch(LivingConversionEvent.Post evt) { var outcome = evt.getOutcome(); var original = evt.getEntityLiving(); - if (outcome instanceof VillagerDataHolder && original instanceof VillagerDataHolder) { - if (isBrainswept(original)) brainsweep(outcome); - } + if (isValidTarget(outcome) && isBrainswept(original)) + brainsweep(outcome); } }