aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0992-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2023-09-24 12:35:16 +1000
committerNassim Jahnke <[email protected]>2023-09-24 12:35:16 +1000
commit2ec643a53ceae5960a1b128aad9f177f6ae81ed7 (patch)
tree2a62189af40a2f5ad36e5f0d3641bff81578a94b /patches/server/0992-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch
parent6be43952eb6088a3f0c9a04ede96707e720203e3 (diff)
downloadPaper-2ec643a53ceae5960a1b128aad9f177f6ae81ed7.tar.gz
Paper-2ec643a53ceae5960a1b128aad9f177f6ae81ed7.zip
Readd anti xray and oversized block entity patches
Diffstat (limited to 'patches/server/0992-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch')
-rw-r--r--patches/server/0992-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch91
1 files changed, 0 insertions, 91 deletions
diff --git a/patches/server/0992-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/patches/server/0992-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch
deleted file mode 100644
index 3acfa0c78f..0000000000
--- a/patches/server/0992-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: kickash32 <[email protected]>
-Date: Mon, 5 Apr 2021 01:42:35 -0400
-Subject: [PATCH] Improve cancelling PreCreatureSpawnEvent with per player mob
- spawns
-
-
-diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
-index 3d5f992c2f4a8df1cf0db1c209e2cce19e214b8a..91549ce95c4829f2262ccddf51372b1c858da15c 100644
---- a/src/main/java/net/minecraft/server/level/ChunkMap.java
-+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
-@@ -313,8 +313,27 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
- }
- }
-
-+ // Paper start - per player mob count backoff
-+ public void updateFailurePlayerMobTypeMap(int chunkX, int chunkZ, net.minecraft.world.entity.MobCategory mobCategory) {
-+ if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
-+ return;
-+ }
-+ int idx = mobCategory.ordinal();
-+ final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> inRange = this.playerMobDistanceMap.getObjectsInRange(chunkX, chunkZ);
-+ if (inRange != null) {
-+ final Object[] set = inRange.getBackingSet();
-+ for (int i = 0; i < set.length; i++) {
-+ if (!(set[i] instanceof ServerPlayer serverPlayer)) {
-+ continue;
-+ }
-+ ++serverPlayer.mobBackoffCounts[idx];
-+ }
-+ }
-+ }
-+ // Paper end - per player mob count backoff
-+
- public int getMobCountNear(ServerPlayer entityPlayer, net.minecraft.world.entity.MobCategory mobCategory) {
-- return entityPlayer.mobCounts[mobCategory.ordinal()];
-+ return entityPlayer.mobCounts[mobCategory.ordinal()] + entityPlayer.mobBackoffCounts[mobCategory.ordinal()]; // Paper - per player mob count backoff
- }
- // Paper end
-
-diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
-index 50da1f746edeff63f723776b8e30b041c8de0138..2ab16e10323982e193e647246bd116e31f17bad2 100644
---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
-+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
-@@ -532,7 +532,17 @@ public class ServerChunkCache extends ChunkSource {
- if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't count mobs when animals and monsters are disabled
- // re-set mob counts
- for (ServerPlayer player : this.level.players) {
-- Arrays.fill(player.mobCounts, 0);
-+ // Paper start - per player mob spawning backoff
-+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
-+ player.mobCounts[ii] = 0;
-+
-+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
-+ if (newBackoff < 0) {
-+ newBackoff = 0;
-+ }
-+ player.mobBackoffCounts[ii] = newBackoff;
-+ }
-+ // Paper end - per player mob spawning backoff
- }
- spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true);
- } else {
-diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
-index 215786e3991942ad5773306a68519946372e94d4..50dcbace6fea4669af904000df08ee6d13df77f8 100644
---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
-+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
-@@ -252,6 +252,7 @@ public class ServerPlayer extends Player {
- // Paper start - mob spawning rework
- 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[] mobBackoffCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper - per player mob count backoff
- public final com.destroystokyo.paper.util.PooledHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleMobDistanceMap;
- // Paper end
-
-diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
-index e1c4cf4b60b810837526c888ec82acbfc8fe540c..64656c384863a6430e933e506d965ee628f08669 100644
---- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
-+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
-@@ -279,6 +279,11 @@ public final class NaturalSpawner {
-
- // Paper start
- PreSpawnStatus doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2);
-+ // Paper start - mob count backoff
-+ if (doSpawning == PreSpawnStatus.ABORT || doSpawning == PreSpawnStatus.CANCELLED) {
-+ world.getChunkSource().chunkMap.updateFailurePlayerMobTypeMap(blockposition_mutableblockposition.getX() >> 4, blockposition_mutableblockposition.getZ() >> 4, group);
-+ }
-+ // Paper end - mob count backoff
- if (doSpawning == PreSpawnStatus.ABORT) {
- return j; // Paper
- }