aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0416-Configurable-chance-of-villager-zombie-infection.patch
blob: 0a2c05d50a574805ec7dd5934fa6250f1468a815 (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
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 fe1c9dd8258ec8c3fdf343d4a44de2be2ae3d35f..525d702d78a609af987ebd2c32169b873e5c05ed 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -604,4 +604,9 @@ public class PaperWorldConfig {
     private void nerfNetherPortalPigmen() {
         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);
+    }
 }
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
index f406826945dd752e6528743a0c8cad3cfdfc4a95..3d8d4a43e6cd554b6f1eeafa1c8d43cef877139a 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java
@@ -450,10 +450,14 @@ public class EntityZombie extends EntityMonster {
     @Override
     public void a(WorldServer worldserver, EntityLiving entityliving) {
         super.a(worldserver, entityliving);
-        if ((worldserver.getDifficulty() == EnumDifficulty.NORMAL || worldserver.getDifficulty() == EnumDifficulty.HARD) && entityliving instanceof EntityVillager) {
-            if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) {
+        // Paper start
+        if (world.paperConfig.zombieVillagerInfectionChance != 0.0 && (world.paperConfig.zombieVillagerInfectionChance != -1.0 || worldserver.getDifficulty() == EnumDifficulty.NORMAL || worldserver.getDifficulty() == EnumDifficulty.HARD) && entityliving instanceof EntityVillager) {
+            if (world.paperConfig.zombieVillagerInfectionChance == -1.0 && worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) {
                 return;
             }
+            if (world.paperConfig.zombieVillagerInfectionChance != -1.0 && (this.random.nextDouble() * 100.0) > world.paperConfig.zombieVillagerInfectionChance) {
+                return;
+            } // Paper end
 
             EntityVillager entityvillager = (EntityVillager) entityliving;
             // CraftBukkit start