From 35e4471f024f48b2bdb100cb911bc2f9eb2c4ce7 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sun, 1 Sep 2024 17:30:26 +0200 Subject: [PATCH] Add config option to disable villager lightning conversion Closes #1053 --- .../entity/villager/VillagerProfessionWerewolfConfig.java | 4 ++++ .../evilcraft/event/EntityStruckByLightningEventHook.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/cyclops/evilcraft/entity/villager/VillagerProfessionWerewolfConfig.java b/src/main/java/org/cyclops/evilcraft/entity/villager/VillagerProfessionWerewolfConfig.java index 4b16c3e832..605b68b4ec 100644 --- a/src/main/java/org/cyclops/evilcraft/entity/villager/VillagerProfessionWerewolfConfig.java +++ b/src/main/java/org/cyclops/evilcraft/entity/villager/VillagerProfessionWerewolfConfig.java @@ -7,6 +7,7 @@ import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.village.VillagerTradesEvent; +import org.cyclops.cyclopscore.config.ConfigurableProperty; import org.cyclops.cyclopscore.config.extendedconfig.VillagerConfig; import org.cyclops.evilcraft.EvilCraft; import org.cyclops.evilcraft.Reference; @@ -18,6 +19,9 @@ */ public class VillagerProfessionWerewolfConfig extends VillagerConfig { + @ConfigurableProperty(category = "mob", comment = "If villagers struck by lightning should have a 50% chance of becoming a werewolf villager", isCommandable = true) + public static boolean convertOnLightning = true; + public VillagerProfessionWerewolfConfig() { super( EvilCraft._instance, diff --git a/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java b/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java index 2dead06e3a..8c2c50ab66 100644 --- a/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java +++ b/src/main/java/org/cyclops/evilcraft/event/EntityStruckByLightningEventHook.java @@ -9,6 +9,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import org.cyclops.evilcraft.RegistryEntries; import org.cyclops.evilcraft.entity.monster.EntityWerewolf; +import org.cyclops.evilcraft.entity.villager.VillagerProfessionWerewolfConfig; import org.cyclops.evilcraft.item.IItemEmpowerable; import java.util.HashSet; @@ -49,7 +50,7 @@ private void empowerItem(EntityStruckByLightningEvent event) { private Set affectedVillagers; private void transformVillager(EntityStruckByLightningEvent event) { - if (event.getEntity() instanceof Villager) { + if (event.getEntity() instanceof Villager && VillagerProfessionWerewolfConfig.convertOnLightning) { Villager entity = (Villager) event.getEntity(); if(lastLightningBolt != event.getLightning()) { lastLightningBolt = event.getLightning();