From 3ec4cc1fbdab03896e7e818177383e2b107e372e Mon Sep 17 00:00:00 2001 From: Poweruser_rs Date: Wed, 4 Nov 2015 02:47:50 +0100 Subject: [PATCH] Prevent village doors from loading chunks diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java index 89f1b74e7..47b87b4bf 100644 --- a/src/main/java/net/minecraft/server/Village.java +++ b/src/main/java/net/minecraft/server/Village.java @@ -20,6 +20,28 @@ public class Village { private List aggressors = new ArrayList(); private int ironGolemCount; + // Poweruser start + private int[][] positions = null; + + private void calculateNewCheckPositions() { + this.positions = new int[][] { {(this.center.x - this.size) >> 4, (this.center.z - this.size) >> 4}, + {(this.center.x - this.size) >> 4, (this.center.z + this.size) >> 4}, + {(this.center.x + this.size) >> 4, (this.center.z - this.size) >> 4}, + {(this.center.x + this.size) >> 4, (this.center.z + this.size) >> 4}, + {this.center.x >> 4, this.center.z >> 4} }; + } + + public boolean isVillageAreaLoaded() { + for(int i = 0; this.positions != null && i < this.positions.length; i++) { + int[] pos = this.positions[i]; + if(this.world.isChunkLoaded(pos[0], pos[1])) { + return true; + } + } + return false; + } + // Poweruser end + public Village() {} public Village(World world) { @@ -31,6 +53,7 @@ public class Village { } public void tick(int i) { + if(!this.isVillageAreaLoaded()) { return; } // Poweruser this.time = i; this.m(); this.l(); @@ -330,6 +353,7 @@ public class Village { this.size = Math.max(32, (int) Math.sqrt((double) j) + 1); } + this.calculateNewCheckPositions(); // Poweruser } public int a(String s) { @@ -379,6 +403,7 @@ public class Village { this.playerStandings.put(nbttagcompound2.getString("Name"), Integer.valueOf(nbttagcompound2.getInt("S"))); } + this.calculateNewCheckPositions(); // Poweruser } public void b(NBTTagCompound nbttagcompound) { -- 2.13.3