diff --git a/src/main/java/com/github/alexthe666/iceandfire/event/ServerEvents.java b/src/main/java/com/github/alexthe666/iceandfire/event/ServerEvents.java index 1c8c8ce95..3cb99bed8 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/event/ServerEvents.java +++ b/src/main/java/com/github/alexthe666/iceandfire/event/ServerEvents.java @@ -673,8 +673,9 @@ public void onVillagerTrades(VillagerTradesEvent event) { @SubscribeEvent public void onLightningHit(final EntityStruckByLightningEvent event) { - // TODO :: Set owner UUID in the tags as well to prevent damage to them? - if (event.getLightning().getTags().contains(BOLT_DONT_DESTROY_LOOT) && (event.getEntity() instanceof ItemEntity || event.getEntity() instanceof ExperienceOrb)) { + if ((event.getEntity() instanceof ItemEntity || event.getEntity() instanceof ExperienceOrb) && event.getLightning().getTags().contains(BOLT_DONT_DESTROY_LOOT)) { + event.setCanceled(true); + } else if (event.getLightning().getTags().contains(event.getEntity().getStringUUID())) { event.setCanceled(true); } } diff --git a/src/main/java/com/github/alexthe666/iceandfire/item/DragonSteelOverrides.java b/src/main/java/com/github/alexthe666/iceandfire/item/DragonSteelOverrides.java index 5f928f370..b9cbbedaf 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/item/DragonSteelOverrides.java +++ b/src/main/java/com/github/alexthe666/iceandfire/item/DragonSteelOverrides.java @@ -96,6 +96,7 @@ default void hurtEnemy(T item, ItemStack stack, LivingEntity target, LivingEntit if (!attacker.level.isClientSide && flag) { LightningBolt lightningboltentity = EntityType.LIGHTNING_BOLT.create(target.level); lightningboltentity.getTags().add(ServerEvents.BOLT_DONT_DESTROY_LOOT); + lightningboltentity.getTags().add(attacker.getStringUUID()); lightningboltentity.moveTo(target.position()); if (!target.level.isClientSide) { target.level.addFreshEntity(lightningboltentity); diff --git a/src/main/java/com/github/alexthe666/iceandfire/item/ItemAlchemySword.java b/src/main/java/com/github/alexthe666/iceandfire/item/ItemAlchemySword.java index 4aa73276c..7cfcc1672 100644 --- a/src/main/java/com/github/alexthe666/iceandfire/item/ItemAlchemySword.java +++ b/src/main/java/com/github/alexthe666/iceandfire/item/ItemAlchemySword.java @@ -57,6 +57,7 @@ public boolean hurtEnemy(@NotNull ItemStack stack, @NotNull LivingEntity target, if (!attacker.level.isClientSide && flag) { LightningBolt lightningboltentity = EntityType.LIGHTNING_BOLT.create(target.level); lightningboltentity.getTags().add(ServerEvents.BOLT_DONT_DESTROY_LOOT); + lightningboltentity.getTags().add(attacker.getStringUUID()); lightningboltentity.moveTo(target.position()); if (!target.level.isClientSide) { target.level.addFreshEntity(lightningboltentity);