mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
85 lines
4.6 KiB
Diff
85 lines
4.6 KiB
Diff
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
|
|
index 4b28347ac5850a878b55d2a815c2c9346dab0568..2c67111621937d9649ac79d133c955d25bc50485 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -6,6 +6,10 @@ import java.util.List;
|
|
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
|
|
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
|
import net.minecraft.world.entity.MobCategory;
|
|
+import java.util.stream.Collectors;
|
|
+import net.minecraft.world.Difficulty;
|
|
+import net.minecraft.world.entity.monster.Vindicator;
|
|
+import net.minecraft.world.entity.monster.Zombie;
|
|
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
@@ -108,6 +112,25 @@ public class PaperWorldConfig {
|
|
disableMobSpawnerSpawnEggTransformation = getBoolean("game-mechanics.disable-mob-spawner-spawn-egg-transformation", disableMobSpawnerSpawnEggTransformation);
|
|
}
|
|
|
|
+ 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)
|
|
+ .collect(Collectors.toList()),
|
|
+ Difficulty.class
|
|
+ );
|
|
+ vindicatorBreakDoors = getEnumList(
|
|
+ "door-breaking-difficulty.vindicator",
|
|
+ java.util.Arrays.stream(Difficulty.values())
|
|
+ .filter(Vindicator.DOOR_BREAKING_PREDICATE)
|
|
+ .collect(Collectors.toList()),
|
|
+ Difficulty.class
|
|
+ );
|
|
+ }
|
|
+
|
|
public short keepLoadedRange;
|
|
private void keepLoadedRange() {
|
|
keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16);
|
|
@@ -170,6 +193,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;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
|
|
index 48593ad8dd80054f89a672a648cb1608a6c5eb8d..f7bcd6b8e1fb2e97db7da9bf218be0e9c99d245b 100644
|
|
--- 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 {
|
|
|
|
static class VindicatorBreakDoorGoal extends BreakDoorGoal {
|
|
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 3a6c9c06e8cc6ec5937059c8a5953af6ee0bb0e9..8da494792786fd80be50efc4cbb56caeae18d004 100644
|
|
--- 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 {
|
|
|
|
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) {
|