From 60df44b111e29a2cb4916810491894f7f3598fae Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 3 Jan 2021 22:28:18 -0800 Subject: [PATCH] Configurable door breaking difficulty --- ...onfigurable-door-breaking-difficulty.patch | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Spigot-Server-Patches/0646-Configurable-door-breaking-difficulty.patch diff --git a/Spigot-Server-Patches/0646-Configurable-door-breaking-difficulty.patch b/Spigot-Server-Patches/0646-Configurable-door-breaking-difficulty.patch new file mode 100644 index 000000000..c92658e5c --- /dev/null +++ b/Spigot-Server-Patches/0646-Configurable-door-breaking-difficulty.patch @@ -0,0 +1,101 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +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 +index 80409c4b52a4bb7146760070dae0e04d49bdd6b3..c46d5d6aa8246f0cecacba288ab3f51a41e112c8 100644 +--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java ++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +@@ -5,8 +5,12 @@ import java.util.EnumMap; + import java.util.HashMap; + import java.util.List; + import java.util.Map; ++import java.util.stream.Collectors; + + import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode; ++import net.minecraft.server.EntityVindicator; ++import net.minecraft.server.EntityZombie; ++import net.minecraft.server.EnumDifficulty; + import org.bukkit.Bukkit; + import org.bukkit.Material; + import org.bukkit.configuration.ConfigurationSection; +@@ -73,6 +77,11 @@ public class PaperWorldConfig { + return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path)); + } + ++ private > List getEnumList(String path, List def, Class type) { ++ config.addDefault("world-settings.default." + path, def.stream().map(Enum::name).collect(Collectors.toList())); ++ return ((List) (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; +@@ -731,4 +740,23 @@ public class PaperWorldConfig { + private void disableMobSpawnerSpawnEggTransformation() { + disableMobSpawnerSpawnEggTransformation = getBoolean("game-mechanics.disable-mob-spawner-spawn-egg-transformation", disableMobSpawnerSpawnEggTransformation); + } ++ ++ public List zombieBreakDoors; ++ public List vindicatorBreakDoors; ++ private void setupEntityBreakingDoors() { ++ zombieBreakDoors = getEnumList( ++ "door-breaking-difficulty.zombie", ++ Arrays.stream(EnumDifficulty.values()) ++ .filter(EntityZombie.getDoorBreakingPredicate()) ++ .collect(Collectors.toList()), ++ EnumDifficulty.class ++ ); ++ vindicatorBreakDoors = getEnumList( ++ "door-breaking-difficulty.vindicator", ++ Arrays.stream(EnumDifficulty.values()) ++ .filter(EntityVindicator.getDoorBreakingPredicate()) ++ .collect(Collectors.toList()), ++ EnumDifficulty.class ++ ); ++ } + } +diff --git a/src/main/java/net/minecraft/server/EntityVindicator.java b/src/main/java/net/minecraft/server/EntityVindicator.java +index c0d26aa9dcd02c44d744b10e18609857ada95889..4761ddfedeed54e79788a6f60f06a805efd60ab1 100644 +--- a/src/main/java/net/minecraft/server/EntityVindicator.java ++++ b/src/main/java/net/minecraft/server/EntityVindicator.java +@@ -8,6 +8,7 @@ import javax.annotation.Nullable; + + public class EntityVindicator extends EntityIllagerAbstract { + ++ public static final Predicate getDoorBreakingPredicate() { return b; } // Paper - OBFHELPER + private static final Predicate b = (enumdifficulty) -> { + return enumdifficulty == EnumDifficulty.NORMAL || enumdifficulty == EnumDifficulty.HARD; + }; +@@ -164,7 +165,7 @@ public class EntityVindicator extends EntityIllagerAbstract { + static class a extends PathfinderGoalBreakDoor { + + public a(EntityInsentient entityinsentient) { +- super(entityinsentient, 6, EntityVindicator.b); ++ super(entityinsentient, 6, com.google.common.base.Predicates.in(entityinsentient.world.paperConfig.vindicatorBreakDoors)); // Paper + this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); + } + +diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java +index 62d202ff871cf3f3deea69931fbee84131bdda8b..752e39ad94ea9e8254853a3fda846be2bd436918 100644 +--- a/src/main/java/net/minecraft/server/EntityZombie.java ++++ b/src/main/java/net/minecraft/server/EntityZombie.java +@@ -25,6 +25,7 @@ public class EntityZombie extends EntityMonster { + private static final DataWatcherObject d = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); + private static final DataWatcherObject bo = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.b); + public static final DataWatcherObject DROWN_CONVERTING = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); ++ public static final Predicate getDoorBreakingPredicate() { return bq; } // Paper - OBFHELPER + private static final Predicate bq = (enumdifficulty) -> { + return enumdifficulty == EnumDifficulty.HARD; + }; +@@ -37,7 +38,7 @@ public class EntityZombie extends EntityMonster { + + public EntityZombie(EntityTypes entitytypes, World world) { + super(entitytypes, world); +- this.br = new PathfinderGoalBreakDoor(this, EntityZombie.bq); ++ this.br = new PathfinderGoalBreakDoor(this, com.google.common.base.Predicates.in(world.paperConfig.zombieBreakDoors)); // Paper + } + + public EntityZombie(World world) {