Paper/patches/server/0594-Configurable-door-breaking-difficulty.patch

87 lines
4.4 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 3 Jan 2021 22:27:43 -0800
Subject: [PATCH] Configurable door breaking difficulty
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-06-17 10:37:27 +02:00
index 8d7acac29d5a8586f449e32f51c1213545e4d366..4227e7fc46e22265316b42bbdb166d60e5aed94e 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2021-06-15 15:20:52 +02:00
@@ -2,7 +2,10 @@ package com.destroystokyo.paper;
import java.util.Arrays;
2021-06-11 14:02:28 +02:00
import java.util.List;
-
+import java.util.stream.Collectors;
+import net.minecraft.world.Difficulty;
+import net.minecraft.world.entity.monster.Vindicator;
+import net.minecraft.world.entity.monster.Zombie;
2021-06-15 15:20:52 +02:00
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
2021-06-11 14:02:28 +02:00
import org.bukkit.Bukkit;
2021-06-15 15:20:52 +02:00
import org.bukkit.configuration.file.YamlConfiguration;
@@ -89,6 +92,25 @@ public class PaperWorldConfig {
2021-06-11 14:02:28 +02:00
disableMobSpawnerSpawnEggTransformation = getBoolean("game-mechanics.disable-mob-spawner-spawn-egg-transformation", disableMobSpawnerSpawnEggTransformation);
}
2021-06-11 14:02:28 +02:00
+ public List<Difficulty> zombieBreakDoors;
+ public List<Difficulty> vindicatorBreakDoors;
+ private void setupEntityBreakingDoors() {
+ zombieBreakDoors = getEnumList(
+ "door-breaking-difficulty.zombie",
+ java.util.Arrays.stream(Difficulty.values())
+ .filter(Zombie.DOOR_BREAKING_PREDICATE)
2021-06-11 14:02:28 +02:00
+ .collect(Collectors.toList()),
+ Difficulty.class
+ );
+ vindicatorBreakDoors = getEnumList(
+ "door-breaking-difficulty.vindicator",
+ java.util.Arrays.stream(Difficulty.values())
+ .filter(Vindicator.DOOR_BREAKING_PREDICATE)
2021-06-11 14:02:28 +02:00
+ .collect(Collectors.toList()),
+ Difficulty.class
+ );
+ }
+
public short keepLoadedRange;
private void keepLoadedRange() {
keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16);
2021-06-17 10:37:27 +02:00
@@ -140,6 +162,11 @@ public class PaperWorldConfig {
return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
}
+ private <T extends Enum<T>> List<T> getEnumList(String path, List<T> def, Class<T> type) {
+ config.addDefault("world-settings.default." + path, def.stream().map(Enum::name).collect(Collectors.toList()));
+ return ((List<String>) (config.getList("world-settings." + worldName + "." + path, config.getList("world-settings.default." + path)))).stream().map(s -> Enum.valueOf(type, s)).collect(Collectors.toList());
+ }
+
public int cactusMaxHeight;
public int reedMaxHeight;
public int bambooMaxHeight;
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
2021-06-17 10:37:27 +02:00
index fafc4c4c7f5d6c4c03671bceec269250117ec472..51082fb81477b96c778796e8daf288b366cecf22 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
@@ -195,7 +195,7 @@ public class Vindicator extends AbstractIllager {
2021-06-11 14:02:28 +02:00
static class VindicatorBreakDoorGoal extends BreakDoorGoal {
2021-06-11 14:02:28 +02:00
public VindicatorBreakDoorGoal(Mob mob) {
- super(mob, 6, Vindicator.DOOR_BREAKING_PREDICATE);
+ super(mob, 6, com.google.common.base.Predicates.in(mob.level.paperConfig.vindicatorBreakDoors)); // Paper
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
}
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 955f733db9cd7412541e4e9c346c48bac733d07e..6408e158745c20ab449c44a28420bc9b28e1efac 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
@@ -100,7 +100,7 @@ public class Zombie extends Monster {
2021-06-11 14:02:28 +02:00
public Zombie(EntityType<? extends Zombie> type, Level world) {
super(type, world);
- this.breakDoorGoal = new BreakDoorGoal(this, Zombie.DOOR_BREAKING_PREDICATE);
+ this.breakDoorGoal = new BreakDoorGoal(this, com.google.common.base.Predicates.in(world.paperConfig.zombieBreakDoors)); // Paper
}
public Zombie(Level world) {