Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-14 20:10:05 +01:00
Another one
Dieser Commit ist enthalten in:
Ursprung
3cb16c9d91
Commit
fe7b741545
@ -6,10 +6,10 @@ Subject: [PATCH] Improve cancelling PreCreatureSpawnEvent with per player mob
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
index 56f7a63e65cce587512b77aafdb4ced18b43d024..21370ed6c7d98d3f3546f0365ac50e5c26ba3bde 100644
|
index 97a24cb410cf7d22a1a8edf8a5622d03a3d5a9c7..72fdcb65c1cc76d69369306c2c7e9a0f5dcb1f96 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
@@ -240,8 +240,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -248,8 +248,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
++(backingSet[i].mobCounts[index]);
|
++(backingSet[i].mobCounts[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,33 +37,33 @@ index 56f7a63e65cce587512b77aafdb4ced18b43d024..21370ed6c7d98d3f3546f0365ac50e5c
|
|||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
index e18c3e08f9fbfe17c797c1f96dce1b86fa41fab6..4a5dc7fd4eb1a7ab1ec371f0f107de882f88149c 100644
|
index ba989879c43cb7d614198444fd2ead85ea71eae9..b3024770b4fd140370a75afa55b966a404969428 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
@@ -456,7 +456,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
@@ -569,7 +569,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||||
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
|
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
|
||||||
// re-set mob counts
|
// re-set mob counts
|
||||||
for (ServerPlayer player : this.level.players) {
|
for (ServerPlayer player : this.level.players) {
|
||||||
- Arrays.fill(player.mobCounts, 0);
|
- Arrays.fill(player.mobCounts, 0);
|
||||||
+ // Paper start - per player mob spawning backoff
|
+ // Paper start - per player mob spawning backoff
|
||||||
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
|
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
|
||||||
+ player.mobCounts[ii] = 0;
|
+ player.mobCounts[ii] = 0;
|
||||||
+
|
+
|
||||||
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
|
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
|
||||||
+ if (newBackoff < 0) {
|
+ if (newBackoff < 0) {
|
||||||
+ newBackoff = 0;
|
+ newBackoff = 0;
|
||||||
+ }
|
+ }
|
||||||
+ player.mobBackoffCounts[ii] = newBackoff;
|
+ player.mobBackoffCounts[ii] = newBackoff;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - per player mob spawning backoff
|
+ // Paper end - per player mob spawning backoff
|
||||||
}
|
}
|
||||||
spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true);
|
spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true);
|
||||||
} else {
|
} else {
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
index cb961d9051416626f499c1ca87107f1114433c94..8dc3ba983fd4c61e463867be8d224aa90424215a 100644
|
index 8cc02ee9b1a710e35eb65a5a095681cc7dc542bb..4e4e5b7e8c387cf13cf5bc5e39d334c3222c9103 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
@@ -280,6 +280,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
@@ -307,6 +307,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||||
public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length;
|
public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length;
|
||||||
public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper
|
public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper
|
||||||
// Paper end - Optional per player mob spawns
|
// Paper end - Optional per player mob spawns
|
||||||
@ -72,10 +72,10 @@ index cb961d9051416626f499c1ca87107f1114433c94..8dc3ba983fd4c61e463867be8d224aa9
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
public CraftPlayer.TransferCookieConnection transferCookieConnection;
|
public CraftPlayer.TransferCookieConnection transferCookieConnection;
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||||
index 364510c0d0667e67aa3b25099a021f5f856fc113..e524b27d185da3e88668f8ef107517272860bd66 100644
|
index f3b52e61ddde25a60c1d178a7607b220ca01f770..848bfa93ebbdf78b0c3bae50e1726377fb78c862 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||||
@@ -272,6 +272,11 @@ public final class NaturalSpawner {
|
@@ -301,6 +301,11 @@ public final class NaturalSpawner {
|
||||||
|
|
||||||
// Paper start - PreCreatureSpawnEvent
|
// Paper start - PreCreatureSpawnEvent
|
||||||
PreSpawnStatus doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2);
|
PreSpawnStatus doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2);
|
||||||
@ -85,5 +85,5 @@ index 364510c0d0667e67aa3b25099a021f5f856fc113..e524b27d185da3e88668f8ef10751727
|
|||||||
+ }
|
+ }
|
||||||
+ // Paper end - per player mob count backoff
|
+ // Paper end - per player mob count backoff
|
||||||
if (doSpawning == PreSpawnStatus.ABORT) {
|
if (doSpawning == PreSpawnStatus.ABORT) {
|
||||||
return j; // Paper - Optional per player mob spawns
|
return;
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren