From f93f37deeaa2216b402150eb6a1aed5cc420337f Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Wed, 28 Mar 2012 11:39:39 -0500 Subject: [PATCH] Handle 1.2.x world height in chunks with Spout plus custom blocks --- .../org/dynmap/bukkit/NewMapChunkCache.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java b/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java index 86104b9e..e6f8e4ef 100644 --- a/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java +++ b/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java @@ -590,11 +590,22 @@ public class NewMapChunkCache implements MapChunkCache { private static class SpoutChunkSnapshot implements ChunkSnapshot { private ChunkSnapshot chunk; - private short[] customids; /* (X << 11) | (Z << 7) | Y */ + private short[] customids; + private final int shiftx; + private final int shiftz; - SpoutChunkSnapshot(ChunkSnapshot chunk, short[] customids) { + SpoutChunkSnapshot(ChunkSnapshot chunk, short[] customids, int height) { this.chunk = chunk; this.customids = customids.clone(); + int sx = 11; + int sz = 7; /* 128 high values */ + while(height > 128) { + sx++; + sz++; + height = (height >> 1); + } + shiftx = sx; + shiftz = sz; } /* Need these for interface, but not used */ public final int getX() { return chunk.getX(); } @@ -606,7 +617,7 @@ public class NewMapChunkCache implements MapChunkCache { public final long getCaptureFullTime() { return chunk.getCaptureFullTime(); } public final int getBlockTypeId(int x, int y, int z) { - int id = customids[(x << 11) | (z << 7) | y]; + int id = customids[(x << shiftx) | (z << shiftz) | y]; if(id != 0) return id; return chunk.getBlockTypeId(x, y, z); } @@ -716,7 +727,7 @@ public class NewMapChunkCache implements MapChunkCache { SpoutChunk sc = (SpoutChunk)c; short[] custids = sc.getCustomBlockIds(); if(custids != null) { - return new SpoutChunkSnapshot(ss, custids); + return new SpoutChunkSnapshot(ss, custids, c.getWorld().getMaxHeight()); } } return ss;