Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
480a87933a
While the previous logic was logically correct, some CB API's before would request a chunk without removing it from the unload queue. While this is logically wrong, some plugins seem to be causing unload issues. This change will make anything using that one API that use to not remove from queue, no longer remove from queue. Hopefully other activities on the server will touch the chunk if it REALLY is in use.
98 Zeilen
3.8 KiB
Diff
98 Zeilen
3.8 KiB
Diff
From 6a8a879e92e5058a3c510aa0f82596ee13c5ee29 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Fri, 18 Mar 2016 20:16:03 -0400
|
|
Subject: [PATCH] Add World Util Methods
|
|
|
|
Methods that can be used for other patches to help improve logic.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index f996c53..d8bd36c 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -156,6 +156,12 @@ public abstract class World implements IBlockAccess {
|
|
return (CraftServer) Bukkit.getServer();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public Chunk getChunkIfLoaded(BlockPosition blockposition) {
|
|
+ return this.chunkProvider.getLoadedChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public Chunk getChunkIfLoaded(int x, int z) {
|
|
return ((ChunkProviderServer) this.chunkProvider).getLoadedChunkAtWithoutMarkingActive(x, z); // Paper - This is added by CB, and will not mark as active. Simply an alias
|
|
}
|
|
@@ -634,6 +640,41 @@ public abstract class World implements IBlockAccess {
|
|
}
|
|
}
|
|
|
|
+ // Paper start - test if meets light level, return faster
|
|
+ // logic copied from below
|
|
+ public boolean isLightLevel(BlockPosition blockposition, int level) {
|
|
+ if (isValidLocation(blockposition)) {
|
|
+ if (this.getType(blockposition).f()) {
|
|
+ if (this.c(blockposition.up(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.east(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.west(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.south(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.north(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ } else {
|
|
+ if (blockposition.getY() >= 256) {
|
|
+ blockposition = new BlockPosition(blockposition.getX(), 255, blockposition.getZ());
|
|
+ }
|
|
+
|
|
+ Chunk chunk = this.getChunkAtWorldCoords(blockposition);
|
|
+ return chunk.a(blockposition, this.J) >= level;
|
|
+ }
|
|
+ } else {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public int getLightLevel(BlockPosition blockposition) {
|
|
return this.c(blockposition, true);
|
|
}
|
|
@@ -748,6 +789,27 @@ public abstract class World implements IBlockAccess {
|
|
return this.worldProvider.n()[this.getLightLevel(blockposition)];
|
|
}
|
|
|
|
+ // Paper start - reduces need to do isLoaded before getType
|
|
+ public IBlockData getTypeIfLoaded(BlockPosition blockposition) {
|
|
+ // CraftBukkit start - tree generation
|
|
+ if (captureTreeGeneration) {
|
|
+ Iterator<BlockState> it = capturedBlockStates.iterator();
|
|
+ while (it.hasNext()) {
|
|
+ BlockState previous = it.next();
|
|
+ if (previous.getX() == blockposition.getX() && previous.getY() == blockposition.getY() && previous.getZ() == blockposition.getZ()) {
|
|
+ return CraftMagicNumbers.getBlock(previous.getTypeId()).fromLegacyData(previous.getRawData());
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+ Chunk chunk = this.getChunkIfLoaded(blockposition);
|
|
+ if (chunk != null) {
|
|
+ return this.isValidLocation(blockposition) ? chunk.getBlockData(blockposition) : Blocks.AIR.getBlockData();
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public IBlockData getType(BlockPosition blockposition) {
|
|
// CraftBukkit start - tree generation
|
|
if (captureTreeGeneration) {
|
|
--
|
|
2.7.4
|
|
|