mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-18 12:48:53 +01:00
Properly handle large values of spawnChunkRadius
The chunk system does not allow ticket levels below 0, so we need to add tickets for each individual chunk instead.
This commit is contained in:
parent
4bc80b8a44
commit
ae80a251fc
4 changed files with 34 additions and 6 deletions
|
@ -5,6 +5,34 @@ Subject: [PATCH] Add startup flag to disable gamerule limits
|
||||||
|
|
||||||
-DPaper.DisableGameRuleLimits=true will disable gamerule limits
|
-DPaper.DisableGameRuleLimits=true will disable gamerule limits
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index 9928e14a5a42a2f0deba86e9dcb1f6f9f59412ef..c5eed86a8982466fd8302c678f0f041db1b24029 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -2071,13 +2071,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.lastSpawnChunkRadius > 1) {
|
||||||
|
- this.getChunkSource().removeRegionTicket(TicketType.START, new ChunkPos(blockposition1), this.lastSpawnChunkRadius, Unit.INSTANCE);
|
||||||
|
+ // Paper start - allow disabling gamerule limits
|
||||||
|
+ for (ChunkPos chunkPos : io.papermc.paper.util.MCUtil.getSpiralOutChunks(blockposition1, this.lastSpawnChunkRadius - 2)) {
|
||||||
|
+ this.getChunkSource().removeTicketAtLevel(TicketType.START, chunkPos, net.minecraft.server.level.ChunkLevel.ENTITY_TICKING_LEVEL, Unit.INSTANCE);
|
||||||
|
+ }
|
||||||
|
+ // Paper end - allow disabling gamerule limits
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = this.getGameRules().getInt(GameRules.RULE_SPAWN_CHUNK_RADIUS) + 1;
|
||||||
|
|
||||||
|
if (i > 1) {
|
||||||
|
- this.getChunkSource().addRegionTicket(TicketType.START, new ChunkPos(pos), i, Unit.INSTANCE);
|
||||||
|
+ // Paper start - allow disabling gamerule limits
|
||||||
|
+ for (ChunkPos chunkPos : io.papermc.paper.util.MCUtil.getSpiralOutChunks(pos, i - 2)) {
|
||||||
|
+ this.getChunkSource().addTicketAtLevel(TicketType.START, chunkPos, net.minecraft.server.level.ChunkLevel.ENTITY_TICKING_LEVEL, Unit.INSTANCE);
|
||||||
|
+ }
|
||||||
|
+ // Paper end - allow disabling gamerule limits
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastSpawnChunkRadius = i;
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||||
index 4ae47c2c5a6bcfbf932d000a80974463e2d3818d..7c363d59c6567cae8e6caf213be51804efa5a96d 100644
|
index 4ae47c2c5a6bcfbf932d000a80974463e2d3818d..7c363d59c6567cae8e6caf213be51804efa5a96d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
||||||
|
|
|
@ -19,10 +19,10 @@ fully prevent enderpearl travel exploits.
|
||||||
public net.minecraft.world.entity.projectile.Projectile ownerUUID
|
public net.minecraft.world.entity.projectile.Projectile ownerUUID
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
index 5979e8d25eaddf990ded79bcf6485cc0612faa63..0a46bf03f9a55c7453f042cba6f448d4d0bcd1e6 100644
|
index 06ae6347d2c9666cb64aea2bea9ff946324015d9..7db77a36701e766c148e91d8313838d307855d8a 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -2664,6 +2664,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -2672,6 +2672,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
|
|
||||||
public void onTickingEnd(Entity entity) {
|
public void onTickingEnd(Entity entity) {
|
||||||
ServerLevel.this.entityTickList.remove(entity);
|
ServerLevel.this.entityTickList.remove(entity);
|
||||||
|
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Call CraftPlayer#onEntityRemove for all online players
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
index 0a46bf03f9a55c7453f042cba6f448d4d0bcd1e6..3d09c0c9ca3541c2b3b6feeb426eeffbdaeef69c 100644
|
index 7db77a36701e766c148e91d8313838d307855d8a..657d8af7cc104962ee46ad1a7dc88b13c24262db 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -2786,7 +2786,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -2794,7 +2794,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
entity.valid = false;
|
entity.valid = false;
|
||||||
if (!(entity instanceof ServerPlayer)) {
|
if (!(entity instanceof ServerPlayer)) {
|
||||||
|
|
|
@ -2328,7 +2328,7 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
index 3d09c0c9ca3541c2b3b6feeb426eeffbdaeef69c..b4027f5cf90935a1fe3ab2c28b0bcbb55a7b541b 100644
|
index 657d8af7cc104962ee46ad1a7dc88b13c24262db..585e2b43a0326f0b81597fa1234d3c67c76af550 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -230,6 +230,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -230,6 +230,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
|
@ -2339,7 +2339,7 @@ index 3d09c0c9ca3541c2b3b6feeb426eeffbdaeef69c..b4027f5cf90935a1fe3ab2c28b0bcbb5
|
||||||
|
|
||||||
public LevelChunk getChunkIfLoaded(int x, int z) {
|
public LevelChunk getChunkIfLoaded(int x, int z) {
|
||||||
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
|
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately
|
||||||
@@ -2647,6 +2648,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -2655,6 +2656,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
return this.chunkSource.getGenerator().getSeaLevel();
|
return this.chunkSource.getGenerator().getSeaLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue