diff --git a/pom.xml b/pom.xml
index 321317c..67b2b19 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
org.bukkit
bukkit
- [1.0.0-R1-SNAPSHOT,)
+ [1.1-R3-SNAPSHOT,)
compile
diff --git a/src/main/java/org/dynmap/mobs/BlockLightLevel.java b/src/main/java/org/dynmap/mobs/BlockLightLevel.java
deleted file mode 100644
index bb4bb08..0000000
--- a/src/main/java/org/dynmap/mobs/BlockLightLevel.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.dynmap.mobs;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.bukkit.block.Block;
-
-/**
- * Wrapper for accessing raw light levels for given block
- */
-public class BlockLightLevel {
- private Method gethandle;
- private Method getrawlight;
- private Object enum_sky;
- private Object enum_block;
- private boolean ready;
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public BlockLightLevel() {
- /* Get CraftChunk.getChunkSnapshot(boolean,boolean,boolean) and CraftChunk.getHandle() */
- try {
- Class c = Class.forName("org.bukkit.craftbukkit.CraftChunk");
- gethandle = c.getDeclaredMethod("getHandle", new Class[0]);
- Class enumskyblock = Class.forName("net.minecraft.server.EnumSkyBlock");
- Object[] enumvals = enumskyblock.getEnumConstants();
- for(int i = 0; i < enumvals.length; i++) {
- String ev = enumvals[i].toString();
- if(ev.equals("Sky")) {
- enum_sky = enumvals[i];
- }
- else if(ev.equals("Block")) {
- enum_block = enumvals[i];
- }
- }
- Class cc = Class.forName("net.minecraft.server.Chunk");
- getrawlight = cc.getDeclaredMethod("a", new Class[] { enumskyblock, int.class, int.class, int.class });
- } catch (ClassNotFoundException cnfx) {
- } catch (NoSuchMethodException nsmx) {
- }
- if((gethandle != null) && (enum_sky != null) && (enum_block != null) && (getrawlight != null)) {
- ready = true;
- }
- else {
- DynmapMobsPlugin.info("Block raw light level API not available");
- }
- }
-
- public boolean isReady() {
- return ready;
- }
-
- public int getSkyLightLevel(Block b) {
- try {
- Object hand = gethandle.invoke(b.getChunk());
- if(hand != null) {
- Integer v = (Integer)getrawlight.invoke(hand, enum_sky, b.getX() & 0xF, b.getY() & 0x7F, b.getZ() & 0xF);
- return v;
- }
- } catch (InvocationTargetException itx) {
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- }
- return -1;
- }
-
- public int getBlockLightLevel(Block b) {
- try {
- Object hand = gethandle.invoke(b.getChunk());
- if(hand != null) {
- Integer v = (Integer)getrawlight.invoke(hand, enum_block, b.getX() & 0xF, b.getY() & 0x7F, b.getZ() & 0xF);
- return v;
- }
- } catch (InvocationTargetException itx) {
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- }
- return -1;
- }
-}
diff --git a/src/main/java/org/dynmap/mobs/DynmapMobsPlugin.java b/src/main/java/org/dynmap/mobs/DynmapMobsPlugin.java
index 7151431..558a20e 100644
--- a/src/main/java/org/dynmap/mobs/DynmapMobsPlugin.java
+++ b/src/main/java/org/dynmap/mobs/DynmapMobsPlugin.java
@@ -8,6 +8,7 @@
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
+import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.LivingEntity;
@@ -41,7 +42,6 @@ public class DynmapMobsPlugin extends JavaPlugin {
boolean tinyicons;
boolean nolabels;
boolean stop;
- BlockLightLevel bll = new BlockLightLevel();
/* Mapping of mobs to icons */
private static class MobMapping {
@@ -140,22 +140,17 @@ else if(mobs[i].mobid.equals("wolf")) { /* Check for tamed wolf */
continue;
Location loc = le.getLocation();
-
+ Block blk = null;
if(hideifshadow < 15) {
- if(loc.getBlock().getLightLevel() <= hideifshadow) {
+ blk = loc.getBlock();
+ if(blk.getLightLevel() <= hideifshadow) {
continue;
}
}
if(hideifundercover < 15) {
- if(bll.isReady()) {
- if(bll.getSkyLightLevel(loc.getBlock()) <= hideifundercover) {
- continue;
- }
- }
- else {
- if(loc.getWorld().getHighestBlockYAt(loc) > loc.getBlockY()) {
- continue;
- }
+ if(blk == null) blk = loc.getBlock();
+ if(blk.getLightFromSky() <= hideifundercover) {
+ continue;
}
}