diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/BlockChangeTracker.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/BlockChangeTracker.java index 0942437f..98b3ee29 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/BlockChangeTracker.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/BlockChangeTracker.java @@ -45,7 +45,7 @@ import fr.neatmonster.nocheatplus.utilities.TickTask; import fr.neatmonster.nocheatplus.utilities.ds.map.LinkedCoordHashMap; import fr.neatmonster.nocheatplus.utilities.ds.map.LinkedCoordHashMap.MoveOrder; import fr.neatmonster.nocheatplus.utilities.map.BlockCache; -import fr.neatmonster.nocheatplus.utilities.map.BlockCache.BlockCacheNode; +import fr.neatmonster.nocheatplus.utilities.map.BlockCache.IBlockCacheNode; import fr.neatmonster.nocheatplus.utilities.map.BlockProperties; /** @@ -151,7 +151,7 @@ public class BlockChangeTracker { public final long id; public final int tick, x, y, z; public final Direction direction; - public final BlockCacheNode previousState; + public final IBlockCacheNode previousState; /** * A push entry. @@ -163,7 +163,7 @@ public class BlockChangeTracker { * @param direction */ public BlockChangeEntry(long id, int tick, int x, int y, int z, - Direction direction, BlockCacheNode previousState) { + Direction direction, IBlockCacheNode previousState) { this.id = id; this.tick = tick; this.x = x; @@ -453,7 +453,7 @@ public class BlockChangeTracker { * If not NONE, pushing into that direction is assumed. */ private void addBlockChange(final long changeId, final int tick, final WorldNode worldNode, - final int x, final int y, final int z, final Direction direction, final BlockCacheNode previousState) { + final int x, final int y, final int z, final Direction direction, final IBlockCacheNode previousState) { worldNode.lastChangeTick = tick; final BlockChangeEntry entry = new BlockChangeEntry(changeId, tick, x, y, z, direction, previousState); LinkedList entries = worldNode.blocks.get(x, y, z, MoveOrder.END); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/map/BlockCache.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/map/BlockCache.java index bb7d50ed..cb7084b9 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/map/BlockCache.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/map/BlockCache.java @@ -35,37 +35,64 @@ public abstract class BlockCache { /** The Constant ID_AIR. */ private static final int ID_AIR = 0; - public static class BlockCacheNode { + /** + * Read access to a BlockCacheNode. + * @author asofold + * + */ + public static interface IBlockCacheNode { - public static final short FETCHED_ID = 0x01; - public static final short FETCHED_DATA = 0x02; - public static final short FETCHED_BOUNDS = 0x04; + public boolean isIdFetched(); + + public boolean isDataFetched(); + + public boolean isBoundsFetched(); + + public int getId(); + + public int getData(); + + public double[] getBounds(); + + } + + public static class BlockCacheNode implements IBlockCacheNode { + + private static final short FETCHED_ID = 0x01; + private static final short FETCHED_DATA = 0x02; + private static final short FETCHED_BOUNDS = 0x04; private short fetched = 0; private int id = 0; private int data = 0; private double[] bounds = null; + @Override public boolean isIdFetched() { return (fetched & FETCHED_ID) != 0; } + @Override public boolean isDataFetched() { return (fetched & FETCHED_DATA) != 0; } + @Override public boolean isBoundsFetched() { return (fetched & FETCHED_BOUNDS) != 0; } + @Override public int getId() { return id; } + @Override public int getData() { return data; } + @Override public double[] getBounds() { return bounds; } @@ -332,7 +359,7 @@ public abstract class BlockCache { * properties set. If forceSetAll is false, null might be returned, * if no node is present for the given coordinates. */ - public BlockCacheNode getBlockCacheNode(int x, int y, int z, boolean forceSetAll) { + public IBlockCacheNode getBlockCacheNode(int x, int y, int z, boolean forceSetAll) { if (forceSetAll) { final BlockCacheNode node = getOrCreateNode(x, y, z); if (!node.isDataFetched()) {