From 5b1c2b1cf433ce02d3a81ff90c34df4371815d38 Mon Sep 17 00:00:00 2001 From: granny Date: Fri, 26 Aug 2022 22:48:17 -0700 Subject: [PATCH] mob spawning option to ignore creative players --- ...ng-option-to-ignore-creative-players.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 patches/server/0294-mob-spawning-option-to-ignore-creative-players.patch diff --git a/patches/server/0294-mob-spawning-option-to-ignore-creative-players.patch b/patches/server/0294-mob-spawning-option-to-ignore-creative-players.patch new file mode 100644 index 0000000000..c3d1e55475 --- /dev/null +++ b/patches/server/0294-mob-spawning-option-to-ignore-creative-players.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: granny +Date: Fri, 26 Aug 2022 22:44:41 -0700 +Subject: [PATCH] mob spawning option to ignore creative players + + +diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java +index 4a8998a98987985e259b0a2a29ee7c94c1f3a4b1..17a93a11a3b69128defc392816858d9528714c26 100644 +--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java ++++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java +@@ -259,7 +259,7 @@ public final class NaturalSpawner { + blockposition_mutableblockposition.set(l, i, i1); + double d0 = (double) l + 0.5D; + double d1 = (double) i1 + 0.5D; +- Player entityhuman = (chunk instanceof LevelChunk) ? ((LevelChunk)chunk).findNearestPlayer(d0, i, d1, 576.0D, net.minecraft.world.entity.EntitySelector.NO_SPECTATORS) : world.getNearestPlayer(d0, (double) i, d1, -1.0D, false); // Paper - use chunk's player cache to optimize search in range ++ Player entityhuman = (chunk instanceof LevelChunk) ? ((LevelChunk)chunk).findNearestPlayer(d0, i, d1, 576.0D, world.purpurConfig.mobSpawningIgnoreCreativePlayers ? net.minecraft.world.entity.EntitySelector.NO_CREATIVE_OR_SPECTATOR : net.minecraft.world.entity.EntitySelector.NO_SPECTATORS) : world.getNearestPlayer(d0, (double) i, d1, -1.0D, world.purpurConfig.mobSpawningIgnoreCreativePlayers); // Paper - use chunk's player cache to optimize search in range // Purpur + + if (entityhuman != null) { + double d2 = entityhuman.distanceToSqr(d0, (double) i, d1); +diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +index 2a3ae8ba73a547d02e7a635321e4534de7daafdc..45eebbc1993b53b4d01317c6089b619f026d53ed 100644 +--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java ++++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +@@ -375,6 +375,7 @@ public class PurpurWorldConfig { + public boolean phantomSpawning; + public boolean villagerTraderSpawning; + public boolean villageSiegeSpawning; ++ public boolean mobSpawningIgnoreCreativePlayers = false; + private void mobSpawnerSettings() { + // values of "default" or null will default to true only if the world environment is normal (aka overworld) + Predicate predicate = (bool) -> (bool != null && bool) || (bool == null && environment == World.Environment.NORMAL); +@@ -383,6 +384,7 @@ public class PurpurWorldConfig { + phantomSpawning = getBoolean("gameplay-mechanics.mob-spawning.phantoms", predicate); + villagerTraderSpawning = getBoolean("gameplay-mechanics.mob-spawning.wandering-traders", predicate); + villageSiegeSpawning = getBoolean("gameplay-mechanics.mob-spawning.village-sieges", predicate); ++ mobSpawningIgnoreCreativePlayers = getBoolean("gameplay-mechanics.mob-spawning.ignore-creative-players", mobSpawningIgnoreCreativePlayers); + } + + public boolean disableObserverClocks = false;