diff --git a/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java b/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java index dc5f856d..92f1ec37 100644 --- a/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java +++ b/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncBlock.java @@ -34,7 +34,7 @@ public class AsyncBlock implements Block { @Override public byte getData() { - return (byte) (queue.getCombinedId4Data(x, y, z, 0) & 0xF); + return (byte) (queue.getCachedCombinedId4Data(x, y, z, 0) & 0xF); } @Override @@ -54,12 +54,12 @@ public class AsyncBlock implements Block { @Override public Material getType() { - return Material.getMaterial(queue.getCombinedId4Data(x, y, z, 0) >> 4); + return Material.getMaterial(queue.getCachedCombinedId4Data(x, y, z, 0) >> 4); } @Override public int getTypeId() { - return queue.getCombinedId4Data(x, y, z, 0) >> 4; + return queue.getCachedCombinedId4Data(x, y, z, 0) >> 4; } @Override diff --git a/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index 0dcb7987..72c85699 100644 --- a/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/bukkit0/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -5,6 +5,7 @@ import com.boydti.fawe.bukkit.v0.BukkitQueue_0; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.HasFaweQueue; import com.boydti.fawe.object.RunnableVal; +import com.boydti.fawe.util.DelegateFaweQueue; import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.TaskManager; @@ -58,7 +59,7 @@ import org.bukkit.util.Vector; * @see #wrap(org.bukkit.World) * @see #create(org.bukkit.WorldCreator) */ -public class AsyncWorld implements World, HasFaweQueue { +public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue{ private World parent; private FaweQueue queue; @@ -86,6 +87,7 @@ public class AsyncWorld implements World, HasFaweQueue { */ @Deprecated public AsyncWorld(World parent, FaweQueue queue) { + super(queue); this.parent = parent; this.queue = queue; if (queue instanceof BukkitQueue_0) { @@ -120,7 +122,7 @@ public class AsyncWorld implements World, HasFaweQueue { this.queue = queue; } - public World getParent() { + public World getBukkitWorld() { return parent; } @@ -140,10 +142,6 @@ public class AsyncWorld implements World, HasFaweQueue { return wrap(world); } - public void enqueue() { - queue.enqueue(); - } - public void commit() { flush(); } diff --git a/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java b/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java index fd0bfd31..96b5338f 100644 --- a/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java @@ -517,6 +517,18 @@ public abstract class MappedFaweQueue extends FaweQueue { return getBrightness(lastSection, x, y, z); } + @Override + public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException { + FaweChunk fc = map.getCachedFaweChunk(x >> 4, z >> 4); + if (fc != null) { + int combined = fc.getBlockCombinedId(x & 15, y, z & 15); + if (combined != 0) { + return combined; + } + } + return getCombinedId4Data(x, y, z); + } + @Override public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException { int cx = x >> 4; diff --git a/core/src/main/java/com/boydti/fawe/object/FaweQueue.java b/core/src/main/java/com/boydti/fawe/object/FaweQueue.java index a52c444f..a19d2bba 100644 --- a/core/src/main/java/com/boydti/fawe/object/FaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/object/FaweQueue.java @@ -273,6 +273,8 @@ public abstract class FaweQueue { public abstract int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException; + public abstract int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException; + public int getAdjacentLight(int x, int y, int z) { int light = 0; if ((light = Math.max(light, getSkyLight(x - 1, y, z))) == 15) { @@ -310,6 +312,14 @@ public abstract class FaweQueue { } } + public int getCachedCombinedId4Data(int x, int y, int z, int def) { + try { + return getCachedCombinedId4Data(x, y, z); + } catch (FaweException ignore) { + return def; + } + } + public int getCombinedId4DataDebug(int x, int y, int z, int def, EditSession session) { try { return getCombinedId4Data(x, y, z); diff --git a/core/src/main/java/com/boydti/fawe/util/DelegateFaweQueue.java b/core/src/main/java/com/boydti/fawe/util/DelegateFaweQueue.java index 70e96649..71f5bfa6 100644 --- a/core/src/main/java/com/boydti/fawe/util/DelegateFaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/util/DelegateFaweQueue.java @@ -205,6 +205,11 @@ public class DelegateFaweQueue extends FaweQueue { return parent.getCombinedId4Data(x, y, z); } + @Override + public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException { + return parent.getCachedCombinedId4Data(x, y, z); + } + @Override public boolean hasSky() { return parent.hasSky();