From 487a067d69be0ab82e7ee51fee63d2be438a5531 Mon Sep 17 00:00:00 2001 From: Len Bucchino Date: Sat, 29 Apr 2023 19:59:24 -0500 Subject: [PATCH] Fixing bug where you respawn and are still casting if keepinventory is set to true --- .../player/ServerPlayerEvents.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/redspace/ironsspellbooks/player/ServerPlayerEvents.java b/src/main/java/io/redspace/ironsspellbooks/player/ServerPlayerEvents.java index 090ab73eb..02227e159 100644 --- a/src/main/java/io/redspace/ironsspellbooks/player/ServerPlayerEvents.java +++ b/src/main/java/io/redspace/ironsspellbooks/player/ServerPlayerEvents.java @@ -19,10 +19,7 @@ import net.minecraft.world.item.SwordItem; import net.minecraftforge.event.ItemAttributeModifierEvent; import net.minecraftforge.event.entity.EntityMountEvent; -import net.minecraftforge.event.entity.living.LivingAttackEvent; -import net.minecraftforge.event.entity.living.LivingDamageEvent; -import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent; -import net.minecraftforge.event.entity.living.LivingExperienceDropEvent; +import net.minecraftforge.event.entity.living.*; import net.minecraftforge.event.entity.player.PlayerContainerEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -130,6 +127,17 @@ public static void onPlayerCloned(PlayerEvent.Clone event) { event.getEntity().setTicksFrozen(0); } + @SubscribeEvent + public static void onLivingDeathEvent(LivingDeathEvent event) { + //IronsSpellbooks.LOGGER.debug("onLivingDeathEvent: {} {}", event.getEntity().getName().getString(), event.getEntity().isDeadOrDying()); + event.getEntity().clearFire(); + event.getEntity().setTicksFrozen(0); + if (event.getEntity() instanceof ServerPlayer serverPlayer) { + //IronsSpellbooks.LOGGER.debug("onLivingDeathEvent: {}", serverPlayer.getName().getString()); + Utils.serverSideCancelCast(serverPlayer); + } + } + @SubscribeEvent public static void onPlayerChangedDimension(PlayerEvent.PlayerChangedDimensionEvent event) { //Ironsspellbooks.logger.debug("PlayerChangedDimension: {}", event.getEntity().getName().getString());