mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
2365b308c8
Upstream has released updates that appears to apply and compile correctly. This update has been tested to ensure that World Conversion still occurs correctly. Bukkit Changes: 0812ce2c SPIGOT-4397: isChunkGenerated API CraftBukkit Changes:4824655c
SPIGOT-4398: Upgrade to ASM 6.2.1 for better Java 11 supporteea43870
MC-134115: Fix issues converting tile entities1a7f2d10
SPIGOT-4397: isChunkGenerated API40aed54d
SPIGOT-4396: Improve vehicle movement Spigot Changes: f6a273b1 Rebuild patches
82 lines
4.4 KiB
Diff
82 lines
4.4 KiB
Diff
From f9d9e18d4f417f736a1db5a26add8ccd0498dfae Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 29 Aug 2018 21:59:22 -0400
|
|
Subject: [PATCH] Optimize getChunkIfLoaded type calls
|
|
|
|
Uses optimized check to avoid major locks and large method.
|
|
|
|
Will improve inlining across many hot methods.
|
|
|
|
Improve getBrightness to not do double chunk map lookups.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
index c0d48c33fc..5b57ea93c8 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
@@ -378,7 +378,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
|
continue;
|
|
}
|
|
|
|
- Chunk neighbor = this.getChunkAt(chunk.locX + x, chunk.locZ + z, false, false);
|
|
+ Chunk neighbor = this.chunks.get(chunk.chunkKey); // Paper
|
|
if (neighbor != null) {
|
|
neighbor.setNeighborUnloaded(-x, -z);
|
|
chunk.setNeighborUnloaded(x, z);
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 2ff8536d59..0c42d042b1 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -165,7 +165,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
}
|
|
|
|
public Chunk getChunkIfLoaded(int x, int z) {
|
|
- return ((ChunkProviderServer) this.chunkProvider).getChunkAt(x, z, false, false);
|
|
+ return ((ChunkProviderServer) this.chunkProvider).chunks.get(ChunkCoordIntPair.a(x, z)); // Paper - optimize getChunkIfLoaded
|
|
}
|
|
|
|
protected World(IDataManager idatamanager, @Nullable PersistentCollection persistentcollection, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag, ChunkGenerator gen, org.bukkit.World.Environment env) {
|
|
@@ -721,7 +721,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ());
|
|
}
|
|
|
|
- return !blockposition.isValidLocation() ? enumskyblock.c : (!this.isLoaded(blockposition) ? enumskyblock.c : this.getChunkAtWorldCoords(blockposition).getBrightness(enumskyblock, blockposition)); // Paper
|
|
+ Chunk chunk; // Paper
|
|
+ return !blockposition.isValidLocation() ? enumskyblock.c : ((chunk = this.getChunkIfLoaded(blockposition)) == null ? enumskyblock.c : chunk.getBrightness(enumskyblock, blockposition)); // Paper - optimize ifChunkLoaded
|
|
}
|
|
|
|
public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) {
|
|
@@ -2030,7 +2031,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
if (blockposition.isInvalidYLocation()) { // Paper
|
|
return false;
|
|
} else {
|
|
- Chunk chunk = this.chunkProvider.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4, false, false);
|
|
+ Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper - optimize ifLoaded
|
|
|
|
return chunk != null && !chunk.isEmpty();
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 08fd8850c6..2422251c72 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -212,7 +212,7 @@ public class CraftWorld implements World {
|
|
return false;
|
|
}
|
|
|
|
- net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkAt(x, z, false, false);
|
|
+ net.minecraft.server.Chunk chunk = world.getChunkIfLoaded(x, z); // Paper - optimize ifLaoded
|
|
if (chunk != null) {
|
|
world.getChunkProviderServer().unload(chunk);
|
|
}
|
|
@@ -231,7 +231,7 @@ public class CraftWorld implements World {
|
|
|
|
private boolean unloadChunk0(int x, int z, boolean save) {
|
|
Boolean result = MCUtil.ensureMain("Unload Chunk", () -> { // Paper - Ensure never async
|
|
- net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkAt(x, z, false, false);
|
|
+ net.minecraft.server.Chunk chunk = world.getChunkIfLoaded(x, z); // Paper - optimize ifLoaded
|
|
if (chunk == null) {
|
|
return true;
|
|
}
|
|
--
|
|
2.19.0
|
|
|