2021-06-11 12:02:28 +00: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
2022-05-06 15:52:14 +00:00
Co-authored-by: Doc <nachito94@msn.com>
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
2022-05-07 18:38:15 +00:00
index bd28bbab098441bdede682c6b269c1d19a2dd062..13fc7c21283f09fd135a12649776bb1355da4154 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
2022-05-07 17:52:32 +00:00
@@ -137,6 +137,27 @@ public class PaperWorldConfig {
2022-05-07 05:57:41 +00:00
private void disableMobSpawnerSpawnEggTransformation() {
2021-06-11 12:02:28 +00:00
disableMobSpawnerSpawnEggTransformation = getBoolean("game-mechanics.disable-mob-spawner-spawn-egg-transformation", disableMobSpawnerSpawnEggTransformation);
}
2022-05-07 05:57:41 +00:00
+
2022-05-06 15:52:14 +00:00
+ private final List<net.minecraft.world.entity.EntityType<?>> entitiesValidForBreakDoors = Arrays.asList(net.minecraft.world.entity.EntityType.ZOMBIE, net.minecraft.world.entity.EntityType.ZOMBIE_VILLAGER, net.minecraft.world.entity.EntityType.HUSK, net.minecraft.world.entity.EntityType.ZOMBIFIED_PIGLIN, net.minecraft.world.entity.EntityType.VINDICATOR);
+ public java.util.Map<net.minecraft.world.entity.EntityType<?>, java.util.List<net.minecraft.world.Difficulty>> entitiesDifficultyBreakDoors = new it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap<>();
2021-06-11 12:02:28 +00:00
+ private void setupEntityBreakingDoors() {
2022-05-06 15:52:14 +00:00
+ for (net.minecraft.world.entity.EntityType<?> entityType : entitiesValidForBreakDoors) {
+ java.util.function.Predicate<net.minecraft.world.Difficulty> difficultyPredicate = net.minecraft.world.entity.monster.Zombie.DOOR_BREAKING_PREDICATE;
2022-05-07 18:38:15 +00:00
+ if (entityType == net.minecraft.world.entity.EntityType.VINDICATOR) {
2022-05-06 15:52:14 +00:00
+ difficultyPredicate = net.minecraft.world.entity.monster.Vindicator.DOOR_BREAKING_PREDICATE;
+ }
+ entitiesDifficultyBreakDoors.put(
+ entityType,
+ getEnumList(
+ "door-breaking-difficulty." + entityType.id,
+ java.util.Arrays.stream(net.minecraft.world.Difficulty.values())
+ .filter(difficultyPredicate)
+ .collect(Collectors.toList()),
+ net.minecraft.world.Difficulty.class
+ )
+ );
+ }
2021-06-11 12:02:28 +00:00
+ }
2022-05-07 05:57:41 +00:00
2021-06-14 19:17:47 +00:00
public short keepLoadedRange;
private void keepLoadedRange() {
2021-06-11 12:02:28 +00: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
2022-05-06 15:52:14 +00:00
index 920c2101ebbdc07c7fd15903a3d641aa55f8336d..430492facbaa80471875da07bf4b9b601777d1fd 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
2022-01-01 03:05:42 +00:00
@@ -192,7 +192,7 @@ public class Vindicator extends AbstractIllager {
private static class VindicatorBreakDoorGoal extends BreakDoorGoal {
2021-06-11 12:02:28 +00:00
public VindicatorBreakDoorGoal(Mob mob) {
- super(mob, 6, Vindicator.DOOR_BREAKING_PREDICATE);
2022-05-06 15:52:14 +00:00
+ super(mob, 6, com.google.common.base.Predicates.in(mob.level.paperConfig.entitiesDifficultyBreakDoors.getOrDefault(mob.getType(), mob.level.paperConfig.entitiesDifficultyBreakDoors.get(EntityType.VINDICATOR)))); // Paper
2021-06-11 12:02:28 +00:00
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
2022-05-06 15:52:14 +00:00
index 92145b35cf9f04afd388dfea8215097a9da7c5a7..f9b7877ce5f66cc58ff1111d0fa72081a03c4f4e 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
2021-11-24 17:58:26 +00:00
@@ -97,7 +97,7 @@ public class Zombie extends Monster {
2021-06-11 12:02:28 +00:00
public Zombie(EntityType<? extends Zombie> type, Level world) {
super(type, world);
- this.breakDoorGoal = new BreakDoorGoal(this, Zombie.DOOR_BREAKING_PREDICATE);
2022-05-06 15:52:14 +00:00
+ this.breakDoorGoal = new BreakDoorGoal(this, com.google.common.base.Predicates.in(world.paperConfig.entitiesDifficultyBreakDoors.getOrDefault(type, world.paperConfig.entitiesDifficultyBreakDoors.get(EntityType.ZOMBIE)))); // Paper
2021-06-11 12:02:28 +00:00
}
public Zombie(Level world) {