From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 22 Feb 2020 16:10:31 -0500 Subject: [PATCH] Configurable chance of villager zombie infection This allows you to solve an issue in vanilla behavior where: * On easy difficulty your villagers will NEVER get infected, meaning they will always die. * On normal difficulty they will have a 50% of getting infected or dying. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java index 82d8299d949ee26eefba2952b625650c1aca0e6a..6e7699e5a725eac05de3e809ae9a45a45891892b 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -557,6 +557,11 @@ public class PaperWorldConfig { nerfNetherPortalPigmen = getBoolean("game-mechanics.nerf-pigmen-from-nether-portals", nerfNetherPortalPigmen); } + public double zombieVillagerInfectionChance = -1.0; + private void zombieVillagerInfectionChance() { + zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance); + } + public int lightQueueSize = 20; private void lightQueueSize() { lightQueueSize = getInt("light-queue-size", lightQueueSize); diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java index 0760fcc3bde6b819ae526e2c66486b09a948d98b..f09e9ae8e976b0150c00995cd22e64feaefd27be 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java @@ -449,10 +449,13 @@ public class Zombie extends Monster { @Override public void killed(ServerLevel world, LivingEntity other) { super.killed(world, other); - if ((world.getDifficulty() == Difficulty.NORMAL || world.getDifficulty() == Difficulty.HARD) && other instanceof Villager) { - if (world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { + if (level.paperConfig.zombieVillagerInfectionChance != 0.0 && (level.paperConfig.zombieVillagerInfectionChance != -1.0 || world.getDifficulty() == Difficulty.NORMAL || world.getDifficulty() == Difficulty.HARD) && other instanceof Villager) { + if (level.paperConfig.zombieVillagerInfectionChance == -1.0 && world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { return; } + if (level.paperConfig.zombieVillagerInfectionChance != -1.0 && (this.random.nextDouble() * 100.0) > level.paperConfig.zombieVillagerInfectionChance) { + return; + } // Paper end Villager entityvillager = (Villager) other; // CraftBukkit start