geforkt von Mirrors/Paper
0fb8bdf0e0
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 14883d6b SPIGOT-6078: Add SmithItemEvent and expand SmithingInventory API CraftBukkit Changes: 115244c7 SPIGOT-6078: Add SmithItemEvent and expand SmithingInventory API
97 Zeilen
5.6 KiB
Diff
97 Zeilen
5.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Mon, 8 Jul 2019 00:13:36 -0700
|
|
Subject: [PATCH] Use getChunkIfLoadedImmediately in places
|
|
|
|
This prevents us from hitting chunk loads for chunks at or less-than
|
|
ticket level 33 (yes getChunkIfLoaded will actually perform a chunk
|
|
load in that case).
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
index a68be9b72daca6353d51141a8771e00240375315..fe662ea8acb873aac2fc3b29addbef77854494ed 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
@@ -207,7 +207,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
}
|
|
|
|
@Override public Chunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
|
- return this.chunkProvider.getChunkAt(x, z, false);
|
|
+ return this.chunkProvider.getChunkAtIfLoadedImmediately(x, z); // Paper
|
|
}
|
|
|
|
// Paper start - Asynchronous IO
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
index fa0b7edf42243d53d9dc897903b9b9e902b33cf7..eee5b3e4645ae41f63aba8898c58f43402d31b73 100644
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
@@ -1244,7 +1244,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
|
speed = player.abilities.walkSpeed * 10f;
|
|
}
|
|
// Paper start - Prevent moving into unloaded chunks
|
|
- if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX() != toX || this.player.locZ() != toZ) && !worldserver.isChunkLoaded((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4)) {
|
|
+ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX() != toX || this.player.locZ() != toZ) && worldserver.getChunkIfLoadedImmediately((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4) == null) { // Paper - use getIfLoadedImmediately
|
|
this.internalTeleport(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.yaw, this.player.pitch, Collections.emptySet());
|
|
return;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
|
|
index 15da3511a9e57c320f4cf409852bee07109095bc..b620d7e0d824c8d0758a66a8fbe872c3e45103d2 100644
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
|
@@ -164,6 +164,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
return (CraftServer) Bukkit.getServer();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @Override
|
|
+ public boolean isChunkLoaded(int x, int z) {
|
|
+ return ((WorldServer)this).getChunkIfLoaded(x, z) != null;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public ResourceKey<DimensionManager> getTypeKey() {
|
|
return typeKey;
|
|
}
|
|
@@ -1062,14 +1069,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
}
|
|
|
|
public boolean p(BlockPosition blockposition) {
|
|
- return isOutsideWorld(blockposition) ? false : this.getChunkProvider().b(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
+ return isOutsideWorld(blockposition) ? false : isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
|
|
}
|
|
|
|
public boolean a(BlockPosition blockposition, Entity entity, EnumDirection enumdirection) {
|
|
if (isOutsideWorld(blockposition)) {
|
|
return false;
|
|
} else {
|
|
- IChunkAccess ichunkaccess = this.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4, ChunkStatus.FULL, false);
|
|
+ IChunkAccess ichunkaccess = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper
|
|
|
|
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).a((IBlockAccess) this, blockposition, entity, enumdirection);
|
|
}
|
|
@@ -1190,7 +1197,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
|
|
for (int i1 = i; i1 < j; ++i1) {
|
|
for (int j1 = k; j1 < l; ++j1) {
|
|
- Chunk chunk = ichunkprovider.a(i1, j1);
|
|
+ Chunk chunk = (Chunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper
|
|
|
|
if (chunk != null) {
|
|
chunk.a(oclass, axisalignedbb, list, predicate);
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index 58d22363124a9343188d8c19476e5a92f2f0b80b..53d0541aba207b5eaea2e49edbb56df918d30333 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -140,9 +140,10 @@ public class ActivationRange
|
|
{
|
|
for ( int j1 = k; j1 <= l; ++j1 )
|
|
{
|
|
- if ( world.getWorld().isChunkLoaded( i1, j1 ) )
|
|
+ Chunk chunk = (Chunk) world.getChunkIfLoadedImmediately( i1, j1 );
|
|
+ if ( chunk != null )
|
|
{
|
|
- activateChunkEntities( world.getChunkAt( i1, j1 ) );
|
|
+ activateChunkEntities( chunk );
|
|
}
|
|
}
|
|
}
|