From ecdb50920e03f0dc2e9d1f123c86fc4deac8252f Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 9 Mar 2012 14:33:51 -0600 Subject: [PATCH] Try fix for getHighestBlockY() not working as advertised --- .../org/dynmap/bukkit/NewMapChunkCache.java | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java b/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java index 6924f844..a5297eb1 100644 --- a/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java +++ b/src/main/java/org/dynmap/bukkit/NewMapChunkCache.java @@ -4,6 +4,7 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.ListIterator; @@ -31,8 +32,8 @@ public class NewMapChunkCache implements MapChunkCache { private static Method gethandle = null; private static Method removeentities = null; private static Method getworldhandle = null; - private static Field chunkbiome = null; private static boolean use_spout = false; + private static boolean use_sections = false; private World w; private DynmapWorld dw; @@ -532,15 +533,13 @@ public class NewMapChunkCache implements MapChunkCache { } catch (ClassNotFoundException cnfx) { } catch (NoSuchMethodException nsmx) { } - - /* Get CraftChunkSnapshot.biome field */ + /* Check for ChunkSnapshot.isSectionEmpty(int) method */ try { - Class c = Class.forName("org.bukkit.craftbukkit.CraftChunkSnapshot"); - chunkbiome = c.getDeclaredField("biome"); - chunkbiome.setAccessible(true); - } catch (ClassNotFoundException cnfx) { - } catch (NoSuchFieldException nsmx) { + ChunkSnapshot.class.getDeclaredMethod("isSectionEmpty", new Class[] { int.class }); + use_sections = true; + } catch (NoSuchMethodException nsmx) { } + use_spout = DynmapPlugin.plugin.hasSpout(); init = true; @@ -799,23 +798,16 @@ public class NewMapChunkCache implements MapChunkCache { isSectionNotEmpty[idx] = new boolean[nsect + 1]; int maxy = 0; if(snaparray[idx] != EMPTY) { - /* Get max height */ - if(dw.isNether()) { - maxy = 128; + if(!use_sections) { + Arrays.fill(isSectionNotEmpty[idx], true); } else { - for(int i = 0; i < 16; i++) { - for(int j = 0; j < 16; j++) { - maxy = Math.max(maxy, snaparray[idx].getHighestBlockYAt(i, j)); + for(int i = 0; i < nsect; i++) { + if(snaparray[idx].isSectionEmpty(i) == false) { + isSectionNotEmpty[idx][i] = true; } } } - maxy = (maxy-1) >> 4; - for(int i = 0; i <= nsect; i++) { - if(i <= maxy) { /* Below top? */ - isSectionNotEmpty[idx][i] = true; - } - } } } public boolean isEmptySection(int sx, int sy, int sz) { @@ -901,8 +893,7 @@ public class NewMapChunkCache implements MapChunkCache { public boolean setChunkDataTypes(boolean blockdata, boolean biome, boolean highestblocky, boolean rawbiome) { this.biome = biome; this.biomeraw = rawbiome; - //this.highesty = highestblocky; - this.highesty = true; + this.highesty = highestblocky; this.blockdata = blockdata; return true; }