testserver/patches/server/0371-Configurable-chance-of...

47 lines
2.8 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
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 82d8299d949ee26eefba2952b625650c1aca0e6a..6e7699e5a725eac05de3e809ae9a45a45891892b 100644
2021-06-11 12:02:28 +00:00
--- 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 {
2021-06-11 12:02:28 +00:00
nerfNetherPortalPigmen = getBoolean("game-mechanics.nerf-pigmen-from-nether-portals", nerfNetherPortalPigmen);
}
2021-06-13 22:05:18 +00:00
2021-06-11 12:02:28 +00:00
+ public double zombieVillagerInfectionChance = -1.0;
+ private void zombieVillagerInfectionChance() {
+ zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
+ }
2021-06-13 22:05:18 +00:00
+
public int lightQueueSize = 20;
private void lightQueueSize() {
lightQueueSize = getInt("light-queue-size", lightQueueSize);
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
2022-06-08 04:06:41 +00:00
index 374fccfec47769d2df51056fb6d1948f472a6802..6efce73f5233927104ec772e16a370926317d80d 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
2022-06-08 04:06:41 +00:00
@@ -450,10 +450,14 @@ public class Zombie extends Monster {
public boolean wasKilled(ServerLevel world, LivingEntity other) {
boolean flag = super.wasKilled(world, other);
2021-06-13 22:05:18 +00:00
- if ((world.getDifficulty() == Difficulty.NORMAL || world.getDifficulty() == Difficulty.HARD) && other instanceof Villager) {
- if (world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) {
2022-06-08 04:06:41 +00:00
+ // Paper start
2021-06-13 22:05:18 +00:00
+ 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()) {
2022-06-08 04:06:41 +00:00
return flag;
2021-06-11 12:02:28 +00:00
}
+ if (level.paperConfig.zombieVillagerInfectionChance != -1.0 && (this.random.nextDouble() * 100.0) > level.paperConfig.zombieVillagerInfectionChance) {
2022-06-08 04:06:41 +00:00
+ return flag;
2021-06-11 12:02:28 +00:00
+ } // Paper end
2021-06-13 22:05:18 +00:00
Villager entityvillager = (Villager) other;
2021-06-11 12:02:28 +00:00
// CraftBukkit start