From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 21 Sep 2016 22:54:28 -0400
Subject: [PATCH] Chunk registration fixes

World checks and the Chunk Add logic are inconsistent on how Y > 256, < 0, is treated

Keep them consistent

diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 3508fd7084db5dc908c5cddc790bb37f44a50e25..7417725363a09500215d5e5e3be1d3a4458dd5e4 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -696,7 +696,7 @@ public class WorldServer extends World {
     public void chunkCheck(Entity entity) {
         this.getMethodProfiler().enter("chunkCheck");
         int i = MathHelper.floor(entity.locX() / 16.0D);
-        int j = MathHelper.floor(entity.locY() / 16.0D);
+        int j =  Math.min(15, Math.max(0, MathHelper.floor(entity.locY() / 16.0D))); // Paper - stay consistent with chunk add/remove behavior;
         int k = MathHelper.floor(entity.locZ() / 16.0D);
 
         if (!entity.inChunk || entity.chunkX != i || entity.chunkY != j || entity.chunkZ != k) {
