mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-25 03:55:35 +01:00
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
|
@Override
|
||||||
public byte getData() {
|
public byte getData() {
|
||||||
return (byte) (queue.getCombinedId4Data(x, y, z, 0) & 0xF);
|
return (byte) (queue.getCachedCombinedId4Data(x, y, z, 0) & 0xF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,12 +54,12 @@ public class AsyncBlock implements Block {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Material getType() {
|
public Material getType() {
|
||||||
return Material.getMaterial(queue.getCombinedId4Data(x, y, z, 0) >> 4);
|
return Material.getMaterial(queue.getCachedCombinedId4Data(x, y, z, 0) >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTypeId() {
|
public int getTypeId() {
|
||||||
return queue.getCombinedId4Data(x, y, z, 0) >> 4;
|
return queue.getCachedCombinedId4Data(x, y, z, 0) >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,6 +5,7 @@ import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
|||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.HasFaweQueue;
|
import com.boydti.fawe.object.HasFaweQueue;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
|
import com.boydti.fawe.util.DelegateFaweQueue;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
import com.boydti.fawe.util.SetQueue;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
@ -58,7 +59,7 @@ import org.bukkit.util.Vector;
|
|||||||
* @see #wrap(org.bukkit.World)
|
* @see #wrap(org.bukkit.World)
|
||||||
* @see #create(org.bukkit.WorldCreator)
|
* @see #create(org.bukkit.WorldCreator)
|
||||||
*/
|
*/
|
||||||
public class AsyncWorld implements World, HasFaweQueue {
|
public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue{
|
||||||
|
|
||||||
private World parent;
|
private World parent;
|
||||||
private FaweQueue queue;
|
private FaweQueue queue;
|
||||||
@ -86,6 +87,7 @@ public class AsyncWorld implements World, HasFaweQueue {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public AsyncWorld(World parent, FaweQueue queue) {
|
public AsyncWorld(World parent, FaweQueue queue) {
|
||||||
|
super(queue);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
if (queue instanceof BukkitQueue_0) {
|
if (queue instanceof BukkitQueue_0) {
|
||||||
@ -120,7 +122,7 @@ public class AsyncWorld implements World, HasFaweQueue {
|
|||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public World getParent() {
|
public World getBukkitWorld() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,10 +142,6 @@ public class AsyncWorld implements World, HasFaweQueue {
|
|||||||
return wrap(world);
|
return wrap(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enqueue() {
|
|
||||||
queue.enqueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void commit() {
|
public void commit() {
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
@ -517,6 +517,18 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
|
|||||||
return getBrightness(lastSection, x, y, z);
|
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
|
@Override
|
||||||
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||||
int cx = x >> 4;
|
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 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) {
|
public int getAdjacentLight(int x, int y, int z) {
|
||||||
int light = 0;
|
int light = 0;
|
||||||
if ((light = Math.max(light, getSkyLight(x - 1, y, z))) == 15) {
|
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) {
|
public int getCombinedId4DataDebug(int x, int y, int z, int def, EditSession session) {
|
||||||
try {
|
try {
|
||||||
return getCombinedId4Data(x, y, z);
|
return getCombinedId4Data(x, y, z);
|
||||||
|
@ -205,6 +205,11 @@ public class DelegateFaweQueue extends FaweQueue {
|
|||||||
return parent.getCombinedId4Data(x, y, z);
|
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
|
@Override
|
||||||
public boolean hasSky() {
|
public boolean hasSky() {
|
||||||
return parent.hasSky();
|
return parent.hasSky();
|
||||||
|
Loading…
Reference in New Issue
Block a user