mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-04 06:02:12 -07:00
Improve configurable door difficulty (#6985)
This commit is contained in:
@@ -3,6 +3,7 @@ From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|||||||
Date: Sun, 3 Jan 2021 22:27:43 -0800
|
Date: Sun, 3 Jan 2021 22:27:43 -0800
|
||||||
Subject: [PATCH] Configurable door breaking difficulty
|
Subject: [PATCH] Configurable door breaking difficulty
|
||||||
|
|
||||||
|
Co-authored-by: Doc <nachito94@msn.com>
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
@@ -14,22 +15,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
+ public List<net.minecraft.world.Difficulty> zombieBreakDoors;
|
+ public List<net.minecraft.world.Difficulty> zombieBreakDoors;
|
||||||
+ public List<net.minecraft.world.Difficulty> vindicatorBreakDoors;
|
+ public List<net.minecraft.world.Difficulty> vindicatorBreakDoors;
|
||||||
|
+ 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<>();
|
||||||
+ private void setupEntityBreakingDoors() {
|
+ private void setupEntityBreakingDoors() {
|
||||||
+ zombieBreakDoors = getEnumList(
|
+ for (net.minecraft.world.entity.EntityType<?> entityType : entitiesValidForBreakDoors) {
|
||||||
+ "door-breaking-difficulty.zombie",
|
+ java.util.function.Predicate<net.minecraft.world.Difficulty> difficultyPredicate = net.minecraft.world.entity.monster.Zombie.DOOR_BREAKING_PREDICATE;
|
||||||
|
+ if (entityType.getBaseClass() == net.minecraft.world.entity.monster.Vindicator.class) {
|
||||||
|
+ 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())
|
+ java.util.Arrays.stream(net.minecraft.world.Difficulty.values())
|
||||||
+ .filter(net.minecraft.world.entity.monster.Zombie.DOOR_BREAKING_PREDICATE)
|
+ .filter(difficultyPredicate)
|
||||||
+ .collect(Collectors.toList()),
|
|
||||||
+ net.minecraft.world.Difficulty.class
|
|
||||||
+ );
|
|
||||||
+ vindicatorBreakDoors = getEnumList(
|
|
||||||
+ "door-breaking-difficulty.vindicator",
|
|
||||||
+ java.util.Arrays.stream(net.minecraft.world.Difficulty.values())
|
|
||||||
+ .filter(net.minecraft.world.entity.monster.Vindicator.DOOR_BREAKING_PREDICATE)
|
|
||||||
+ .collect(Collectors.toList()),
|
+ .collect(Collectors.toList()),
|
||||||
+ net.minecraft.world.Difficulty.class
|
+ net.minecraft.world.Difficulty.class
|
||||||
|
+ )
|
||||||
+ );
|
+ );
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
public short keepLoadedRange;
|
public short keepLoadedRange;
|
||||||
private void keepLoadedRange() {
|
private void keepLoadedRange() {
|
||||||
@@ -43,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
public VindicatorBreakDoorGoal(Mob mob) {
|
public VindicatorBreakDoorGoal(Mob mob) {
|
||||||
- super(mob, 6, Vindicator.DOOR_BREAKING_PREDICATE);
|
- super(mob, 6, Vindicator.DOOR_BREAKING_PREDICATE);
|
||||||
+ super(mob, 6, com.google.common.base.Predicates.in(mob.level.paperConfig.vindicatorBreakDoors)); // Paper
|
+ super(mob, 6, com.google.common.base.Predicates.in(mob.level.paperConfig.entitiesDifficultyBreakDoors.getOrDefault(mob.getType(), mob.level.paperConfig.entitiesDifficultyBreakDoors.get(EntityType.VINDICATOR)))); // Paper
|
||||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
public Zombie(EntityType<? extends Zombie> type, Level world) {
|
public Zombie(EntityType<? extends Zombie> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
- this.breakDoorGoal = new BreakDoorGoal(this, Zombie.DOOR_BREAKING_PREDICATE);
|
- this.breakDoorGoal = new BreakDoorGoal(this, Zombie.DOOR_BREAKING_PREDICATE);
|
||||||
+ this.breakDoorGoal = new BreakDoorGoal(this, com.google.common.base.Predicates.in(world.paperConfig.zombieBreakDoors)); // Paper
|
+ this.breakDoorGoal = new BreakDoorGoal(this, com.google.common.base.Predicates.in(world.paperConfig.entitiesDifficultyBreakDoors.getOrDefault(type, world.paperConfig.entitiesDifficultyBreakDoors.get(EntityType.ZOMBIE)))); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
public Zombie(Level world) {
|
public Zombie(Level world) {
|
||||||
|
@@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.spigotmc.SpigotWorldConfig;
|
import org.spigotmc.SpigotWorldConfig;
|
||||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ public Map<net.minecraft.world.entity.EntityType<?>, Integer> entityPerChunkSaveLimits = new HashMap<>();
|
+ public Map<net.minecraft.world.entity.EntityType<?>, Integer> entityPerChunkSaveLimits = new HashMap<>();
|
||||||
|
Reference in New Issue
Block a user