fix cleric impetuses not updating, add motion not affecting players, brainsweeping not affecting witches

This commit is contained in:
yrsegal@gmail.com 2022-04-25 09:46:49 -04:00
parent 19c10d8f47
commit 06675f3824
3 changed files with 14 additions and 9 deletions

View file

@ -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);
}
}

View file

@ -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
}
}
}

View file

@ -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);
}
}