Do not load chunks for light checks

Should only happen for blocks on the edge that uses neighbors light level
(certain blocks). In that case, there will be 3-4 other neighbors to get a light level from.
This commit is contained in:
Aikar 2016-03-31 19:29:06 -04:00
parent 0ba94906ad
commit dea2d41b86
2 changed files with 33 additions and 4 deletions

View file

@ -1,4 +1,4 @@
From d7343318730a1a96448116c422161127a8bc0600 Mon Sep 17 00:00:00 2001
From bb8dd93f486683d2a80fe0d23337f11faca44e9a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 28 Mar 2016 20:55:47 -0400
Subject: [PATCH] MC Utils
@ -7,10 +7,10 @@ Collection of utils to help reduce NMS diff
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
new file mode 100644
index 0000000..f76fd44
index 0000000..3004822
--- /dev/null
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -0,0 +1,109 @@
@@ -0,0 +1,115 @@
+package net.minecraft.server;
+
+import org.bukkit.Location;
@ -119,7 +119,13 @@ index 0000000..f76fd44
+ public static Location toLocation(Entity entity) {
+ return new Location(entity.getWorld().getWorld(), entity.locX, entity.locY, entity.locZ);
+ }
+
+ public static boolean isEdgeOfChunk(BlockPosition pos) {
+ final int absX = Math.abs(pos.getX()) % 16;
+ final int absZ = Math.abs(pos.getZ()) % 16;
+ return (absX == 0 || absX == 15 || absZ == 0 || absZ == 15);
+ }
+}
--
2.7.4
2.8.0

View file

@ -0,0 +1,23 @@
From ea50a2f4bccc3f86ce363e53f345acc3b434b8bb Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 31 Mar 2016 19:17:58 -0400
Subject: [PATCH] Do not load chunks for light checks
Should only happen for blocks on the edge that uses neighbors light level
(certain blocks). In that case, there will be 3-4 other neighbors to get a light level from.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index fa84bad..89103d6 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -723,6 +723,7 @@ public abstract class World implements IBlockAccess {
if (blockposition.getY() >= 256) {
blockposition = new BlockPosition(blockposition.getX(), 255, blockposition.getZ());
}
+ if (!this.isLoaded(blockposition)) return 0; // Paper
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
--
2.8.0