Skip to content

Commit

Permalink
mob spawning option to ignore creative players
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Aug 27, 2022
1 parent bc88bab commit 5b1c2b1
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: granny <[email protected]>
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<Boolean> 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;

0 comments on commit 5b1c2b1

Please sign in to comment.