Allow queue to use cached block value
This commit is contained in:
parent
84f1ee19fc
commit
c3af25ddf7
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -517,6 +517,18 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> 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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user