mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 01:17:42 +01:00
mob spawning option to ignore creative players
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: granny <granny@purpurmc.org>
|
|
||||||
Date: Fri, 26 Aug 2022 22:44:41 -0700
|
|
||||||
Subject: [PATCH] mob spawning option to ignore creative players
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java
|
|
||||||
index c1b76a1ebc1eea7ab70cf61d8175a31794dd122a..dc15c15951e4ca30b8341d24f813259a77f41c77 100644
|
|
||||||
--- a/net/minecraft/world/level/NaturalSpawner.java
|
|
||||||
+++ b/net/minecraft/world/level/NaturalSpawner.java
|
|
||||||
@@ -280,7 +280,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 = world.getNearestPlayer(d0, (double) i, d1, -1.0D, false);
|
|
||||||
+ Player entityhuman = world.getNearestPlayer(d0, (double) i, d1, -1.0D, world.purpurConfig.mobSpawningIgnoreCreativePlayers); // 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 596a4d0a7c6851c31ee2c09cfc11400683336e6d..dee8860d593b126353f9f284de65b5fccbe4f530 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
@@ -380,6 +380,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);
|
|
||||||
@@ -388,6 +389,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,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/world/level/NaturalSpawner.java
|
||||||
|
+++ b/net/minecraft/world/level/NaturalSpawner.java
|
||||||
|
@@ -267,7 +_,7 @@
|
||||||
|
mutableBlockPos.set(x, y, z);
|
||||||
|
double d = x + 0.5;
|
||||||
|
double d1 = z + 0.5;
|
||||||
|
- Player nearestPlayer = level.getNearestPlayer(d, y, d1, -1.0, false);
|
||||||
|
+ Player nearestPlayer = level.getNearestPlayer(d, y, d1, -1.0, level.purpurConfig.mobSpawningIgnoreCreativePlayers); // Purpur - mob spawning option to ignore creative players
|
||||||
|
if (nearestPlayer != null) {
|
||||||
|
double d2 = nearestPlayer.distanceToSqr(d, y, d1);
|
||||||
|
if (level.isLoadedAndInBounds(mutableBlockPos) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn
|
||||||
@@ -379,6 +379,7 @@ public class PurpurWorldConfig {
|
|||||||
public boolean phantomSpawning;
|
public boolean phantomSpawning;
|
||||||
public boolean villagerTraderSpawning;
|
public boolean villagerTraderSpawning;
|
||||||
public boolean villageSiegeSpawning;
|
public boolean villageSiegeSpawning;
|
||||||
|
public boolean mobSpawningIgnoreCreativePlayers = false;
|
||||||
private void mobSpawnerSettings() {
|
private void mobSpawnerSettings() {
|
||||||
// values of "default" or null will default to true only if the world environment is normal (aka overworld)
|
// 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);
|
Predicate<Boolean> predicate = (bool) -> (bool != null && bool) || (bool == null && environment == World.Environment.NORMAL);
|
||||||
@@ -387,6 +388,7 @@ public class PurpurWorldConfig {
|
|||||||
phantomSpawning = getBoolean("gameplay-mechanics.mob-spawning.phantoms", predicate);
|
phantomSpawning = getBoolean("gameplay-mechanics.mob-spawning.phantoms", predicate);
|
||||||
villagerTraderSpawning = getBoolean("gameplay-mechanics.mob-spawning.wandering-traders", predicate);
|
villagerTraderSpawning = getBoolean("gameplay-mechanics.mob-spawning.wandering-traders", predicate);
|
||||||
villageSiegeSpawning = getBoolean("gameplay-mechanics.mob-spawning.village-sieges", predicate);
|
villageSiegeSpawning = getBoolean("gameplay-mechanics.mob-spawning.village-sieges", predicate);
|
||||||
|
mobSpawningIgnoreCreativePlayers = getBoolean("gameplay-mechanics.mob-spawning.ignore-creative-players", mobSpawningIgnoreCreativePlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disableObserverClocks = false;
|
public boolean disableObserverClocks = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user