mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 19:37:35 +01:00
a2ad49b22f
Note to other developers: This commit may require you to wipe your workspace as a result of the changes to BD. --- work/BuildData Submodule work/BuildData f527a8ff..d56672db: > Mappings Update --- work/Bukkit Submodule work/Bukkit 0c1d258bb..db06c80d7: > Add list of entities to EntityTransformEvent > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks ---work/CraftBukkit Submodule work/CraftBukkit 6a398ac44..068dab5be: > Enable optional source JAR shading via profile shadeSourcesJar > Use ImmutableList rather than AbstractList for CraftMetaBook > Fix setRecipes(List) not setting Knowledge Book recipes. > Mappings Update > Add list of entities to EntityTransformEvent & move die calls > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks > Add Vanilla help to default permissions --- work/Spigot Submodule work/Spigot a1f2566f6..e769fe4d9: > Mappings Update > Rebuild patches
82 lines
4.4 KiB
Diff
82 lines
4.4 KiB
Diff
From 084c88af6e4ed0452afb265baac3a816bb78f5ea 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 3854464e8..dcc6e9762 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
@@ -380,7 +380,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 de591d912..5fe4734e3 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -166,7 +166,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) {
|
|
@@ -722,7 +722,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) {
|
|
@@ -2031,7 +2032,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 d5936eb19..4b8b66352 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -217,7 +217,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);
|
|
}
|
|
@@ -236,7 +236,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.2
|
|
|