Fix fuckups from previous commit

This commit is contained in:
Nassim Jahnke 2021-11-25 12:08:44 +01:00 committed by MiniDigger | Martin
parent dabbf5b193
commit e85e1f4e49
5 changed files with 51 additions and 24 deletions

View File

@ -272,10 +272,48 @@ index 8868ffcda194e8c2300181a2cdda9337dbde6284..95f195980e28bb59f43e5ca1d5e79ebe
public String getDebugStatus() { public String getDebugStatus() {
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 a66d9d6df1fc0ad68f51ea96d4e1a2d725c73b05..00305a06885b2457615b6bd35bb1a84721ca1d77 100644 index a66d9d6df1fc0ad68f51ea96d4e1a2d725c73b05..c3875acfad91c50a7fec4b1f8e06e8a32e2ea037 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
@@ -928,15 +928,7 @@ public class ServerChunkCache extends ChunkSource { @@ -881,6 +881,37 @@ public class ServerChunkCache extends ChunkSource {
if (flag) {
this.chunkMap.tick();
} else {
+ // Paper start - optimize isOutisdeRange
+ ChunkMap playerChunkMap = this.chunkMap;
+ for (ServerPlayer player : this.level.players) {
+ if (!player.affectsSpawning || player.isSpectator()) {
+ playerChunkMap.playerMobSpawnMap.remove(player);
+ continue;
+ }
+
+ int viewDistance = this.chunkMap.getEffectiveViewDistance();
+
+ // copied and modified from isOutisdeRange
+ int chunkRange = level.spigotConfig.mobSpawnRange;
+ chunkRange = (chunkRange > viewDistance) ? (byte)viewDistance : chunkRange;
+ chunkRange = (chunkRange > DistanceManager.MOB_SPAWN_RANGE) ? DistanceManager.MOB_SPAWN_RANGE : chunkRange;
+
+ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange);
+ event.callEvent();
+ if (event.isCancelled() || event.getSpawnRadius() < 0 || playerChunkMap.playerChunkTickRangeMap.getLastViewDistance(player) == -1) {
+ playerChunkMap.playerMobSpawnMap.remove(player);
+ continue;
+ }
+
+ int range = Math.min(event.getSpawnRadius(), 32); // limit to max view distance
+ int chunkX = net.minecraft.server.MCUtil.getChunkCoordinate(player.getX());
+ int chunkZ = net.minecraft.server.MCUtil.getChunkCoordinate(player.getZ());
+
+ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
+ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in isOutsideRange
+ player.playerNaturallySpawnedEvent = event;
+ }
+ // Paper end - optimize isOutisdeRange
LevelData worlddata = this.level.getLevelData();
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
@@ -928,15 +959,7 @@ public class ServerChunkCache extends ChunkSource {
boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
//Collections.shuffle(list); // Paper - no... just no... //Collections.shuffle(list); // Paper - no... just no...
@ -292,7 +330,7 @@ index a66d9d6df1fc0ad68f51ea96d4e1a2d725c73b05..00305a06885b2457615b6bd35bb1a847
Iterator iterator1 = list.iterator(); Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
@@ -944,9 +936,9 @@ public class ServerChunkCache extends ChunkSource { @@ -944,9 +967,9 @@ public class ServerChunkCache extends ChunkSource {
LevelChunk chunk1 = chunkproviderserver_a.chunk; LevelChunk chunk1 = chunkproviderserver_a.chunk;
ChunkPos chunkcoordintpair = chunk1.getPos(); ChunkPos chunkcoordintpair = chunk1.getPos();

View File

@ -332,18 +332,10 @@ index 95fcf31b0ea68312f6c3475c1b4a01ca2b269536..9d4dc7d8d8b6633a3e88a8fc43d3d798
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
this.passengers = ImmutableList.of(); this.passengers = ImmutableList.of();
diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java
index 55ce69b5fe097841d00ef5c241459dce9bb0d4db..daaf057380a55e6841831f56657cafb5ac97fb27 100644 index 55ce69b5fe097841d00ef5c241459dce9bb0d4db..e5bcbfe175a697e04886d04543e1278b7e83a184 100644
--- a/src/main/java/org/spigotmc/TrackingRange.java --- a/src/main/java/org/spigotmc/TrackingRange.java
+++ b/src/main/java/org/spigotmc/TrackingRange.java +++ b/src/main/java/org/spigotmc/TrackingRange.java
@@ -6,6 +6,7 @@ import net.minecraft.world.entity.ExperienceOrb; @@ -24,6 +24,7 @@ public class TrackingRange
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.entity.decoration.Painting;
import net.minecraft.world.entity.item.ItemEntity;
+import net.minecraft.world.entity.monster.Ghast;
public class TrackingRange
{
@@ -24,6 +25,7 @@ public class TrackingRange
{ {
return defaultRange; return defaultRange;
} }
@ -351,7 +343,7 @@ index 55ce69b5fe097841d00ef5c241459dce9bb0d4db..daaf057380a55e6841831f56657cafb5
SpigotWorldConfig config = entity.level.spigotConfig; SpigotWorldConfig config = entity.level.spigotConfig;
if ( entity instanceof ServerPlayer ) if ( entity instanceof ServerPlayer )
{ {
@@ -47,8 +49,48 @@ public class TrackingRange @@ -47,8 +48,48 @@ public class TrackingRange
return config.miscTrackingRange; return config.miscTrackingRange;
} else } else
{ {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Skip distance map update when spawning disabled.
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 93b8c5c21a6a6c2475f4589014852a5178dfc13f..6f4c2d4eb5f42cd661ec6dd6c354060811e59dad 100644 index ca3ccf2631587a896f6b909d63889708e6f72f27..930291a0844acbd0491e641008727223b0010a60 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
@@ -926,7 +926,7 @@ public class ServerChunkCache extends ChunkSource { @@ -957,7 +957,7 @@ public class ServerChunkCache extends ChunkSource {
int l = this.distanceManager.getNaturalSpawnChunkCount(); int l = this.distanceManager.getNaturalSpawnChunkCount();
// Paper start - per player mob spawning // Paper start - per player mob spawning
NaturalSpawner.SpawnState spawnercreature_d; // moved down NaturalSpawner.SpawnState spawnercreature_d; // moved down

View File

@ -22,10 +22,10 @@ With this change I could get all 200 on at 0ms ping.
So in general this patch should reduce Netty I/O thread load. So in general this patch should reduce Netty I/O thread load.
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 7e9a5499bec4eb33c25f610465c6bbfb4ccd18df..6efac4257ea167b73e68b491d050b777f0f71b35 100644 index 204fc634fdbcff8ff9f4b570c50a76401dcc8bd6..573a7fc1543f4dbdbc6d83d1dc123ab952840c88 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
@@ -1000,7 +1000,24 @@ public class ServerChunkCache extends ChunkSource { @@ -1031,7 +1031,24 @@ public class ServerChunkCache extends ChunkSource {
}); });
gameprofilerfiller.pop(); gameprofilerfiller.pop();
gameprofilerfiller.pop(); gameprofilerfiller.pop();

View File

@ -26,7 +26,7 @@ index 4e3d4195db3660edd2b9ee850b774be91455fb84..4e3d14ed8a9651a327c8a5fbb53e69e6
// Paper end - optimise isOutsideOfRange // Paper end - optimise isOutsideOfRange
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 1a2687056c3264b74d992a554ab610ea744192c5..aa2671323c776a943d2e0c8a89d872933779703f 100644 index 1a2687056c3264b74d992a554ab610ea744192c5..e7bc9621a4cb81ac4661eaa86162fbad7d4e018b 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
@@ -157,6 +157,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -157,6 +157,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@ -59,12 +59,9 @@ index 1a2687056c3264b74d992a554ab610ea744192c5..aa2671323c776a943d2e0c8a89d87293
} }
void updateMaps(ServerPlayer player) { void updateMaps(ServerPlayer player) {
@@ -262,8 +271,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -264,6 +273,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, this.getEffectiveViewDistance()));
} }
- // Paper end - use distance map to optimise entity tracker // Paper end - use distance map to optimise entity tracker
+ // Paper end - use distance map to optimise entity trackerD
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise PlayerChunkMap#isOutsideRange this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise PlayerChunkMap#isOutsideRange
+ this.playerGeneralAreaMap.update(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn + this.playerGeneralAreaMap.update(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
} }