From a084dbcb4dc2c411ef88ced74942f4131586234c Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sun, 1 Sep 2024 17:27:12 +0200 Subject: [PATCH] Fix lightning-struck villagers always becoming werewolves Closes #1052 --- .../event/EntityStruckByLightningEventHook.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java b/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java index e449d04789..2dead06e3a 100644 --- a/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java +++ b/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java @@ -46,7 +46,7 @@ private void empowerItem(EntityStruckByLightningEvent event) { } private LightningBolt lastLightningBolt; - private Set affectedVillagers; + private Set affectedVillagers; private void transformVillager(EntityStruckByLightningEvent event) { if (event.getEntity() instanceof Villager) { @@ -55,16 +55,17 @@ private void transformVillager(EntityStruckByLightningEvent event) { lastLightningBolt = event.getLightning(); affectedVillagers = new HashSet<>(); } - if(!affectedVillagers.add(entity)) { + if(!affectedVillagers.add(entity.getId())) { // The same lightning bolt will strike multiple times. Only count the first time it hits any entity event.setCanceled(true); return; } if(entity.getLevel().random.nextBoolean()) { - event.setCanceled(true); // 50% chance that they become a witch like vanilla does - return; + event.setCanceled(false); + return; // 50% chance that they become a witch like vanilla does } if(entity.getVillagerData().getProfession() != RegistryEntries.VILLAGER_PROFESSION_WEREWOLF) { + event.setCanceled(true); EntityWerewolf.initializeWerewolfVillagerData(entity); } }