aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0386-Configurable-chance-of-villager-zombie-infection.patch
blob: 91bdbf894a565c103646f27f19826f9bbba1279e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zero <zero@cock.li>
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 b8e58219847a243516754c845732d1b1e3f56f23..955cc760f3eabe2fa2d88fe277ca923944eb9aea 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -536,6 +536,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 c3fd3b354812dd690d68b45bc5a179778e4511e0..20d8e705ea432df64917b59f8290aa5400795f4b 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
@@ -452,10 +452,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