mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-01 07:03:52 +01:00
Fixes #322
This commit is contained in:
parent
3c371d2eb1
commit
84f1ee19fc
@ -37,6 +37,11 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkyLight(Chunk chunk, int x, int y, int z, int value) {
|
public void setSkyLight(Chunk chunk, int x, int y, int z, int value) {
|
||||||
|
|
||||||
|
@ -80,6 +80,19 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
|
if (craftChunk != null) {
|
||||||
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
checkVersion("v1_10_R1");
|
checkVersion("v1_10_R1");
|
||||||
if (air == null) {
|
if (air == null) {
|
||||||
|
@ -86,6 +86,19 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
getImpWorld();
|
getImpWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
|
if (craftChunk != null) {
|
||||||
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChunkLoaded(int x, int z) {
|
public boolean isChunkLoaded(int x, int z) {
|
||||||
return getWorld().isChunkLoaded(x, z);
|
return getWorld().isChunkLoaded(x, z);
|
||||||
|
@ -84,6 +84,19 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
|||||||
getImpWorld();
|
getImpWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
|
if (craftChunk != null) {
|
||||||
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChunkLoaded(int x, int z) {
|
public boolean isChunkLoaded(int x, int z) {
|
||||||
return getWorld().isChunkLoaded(x, z);
|
return getWorld().isChunkLoaded(x, z);
|
||||||
|
@ -96,6 +96,19 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
|||||||
getImpWorld();
|
getImpWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
CraftChunk craftChunk = (CraftChunk) chunk.getChunk();
|
||||||
|
if (craftChunk != null) {
|
||||||
|
int[] otherMap = craftChunk.getHandle().heightMap;
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkSection[] getCachedSections(World world, int cx, int cz) {
|
public ChunkSection[] getCachedSections(World world, int cx, int cz) {
|
||||||
CraftChunk chunk = (CraftChunk) world.getChunkAt(cx, cz);
|
CraftChunk chunk = (CraftChunk) world.getChunkAt(cx, cz);
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package com.boydti.fawe.example;
|
package com.boydti.fawe.example;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -90,18 +88,11 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendChunk(final FaweChunk fc) {
|
public void sendChunk(final FaweChunk fc) {
|
||||||
if (Fawe.get().isMainThread()) {
|
refreshChunk(fc);
|
||||||
refreshChunk(fc);
|
|
||||||
} else {
|
|
||||||
SetQueue.IMP.addTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
refreshChunk(fc);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void setHeightMap(FaweChunk chunk, int[] heightMap);
|
||||||
|
|
||||||
public abstract void setFullbright(CHUNKSECTION sections);
|
public abstract void setFullbright(CHUNKSECTION sections);
|
||||||
|
|
||||||
public abstract boolean removeLighting(CHUNKSECTION sections, RelightMode mode, boolean hasSky);
|
public abstract boolean removeLighting(CHUNKSECTION sections, RelightMode mode, boolean hasSky);
|
||||||
|
@ -3,13 +3,10 @@ package com.boydti.fawe.example;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import java.util.ArrayDeque;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class NMSRelighter {
|
public class NMSRelighter {
|
||||||
@ -129,12 +126,22 @@ public class NMSRelighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendChunks() {
|
public void sendChunks() {
|
||||||
|
final Map<FaweChunk, int[]> fcs = new HashMap<>(skyToRelight.size());
|
||||||
for (Map.Entry<Long, RelightSkyEntry> entry : skyToRelight.entrySet()) {
|
for (Map.Entry<Long, RelightSkyEntry> entry : skyToRelight.entrySet()) {
|
||||||
RelightSkyEntry chunk = entry.getValue();
|
RelightSkyEntry chunk = entry.getValue();
|
||||||
CharFaweChunk fc = (CharFaweChunk) queue.getFaweChunk(chunk.x, chunk.z);
|
CharFaweChunk fc = (CharFaweChunk) queue.getFaweChunk(chunk.x, chunk.z);
|
||||||
|
fcs.put(fc, chunk.heightMap);
|
||||||
fc.setBitMask(chunk.bitmask);
|
fc.setBitMask(chunk.bitmask);
|
||||||
queue.sendChunk(fc);
|
queue.sendChunk(fc);
|
||||||
}
|
}
|
||||||
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
|
@Override
|
||||||
|
public void run(Object value) {
|
||||||
|
for (Map.Entry<FaweChunk, int[]> entry : fcs.entrySet()) {
|
||||||
|
queue.setHeightMap(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTransparent(int x, int y, int z) {
|
private boolean isTransparent(int x, int y, int z) {
|
||||||
@ -196,12 +203,6 @@ public class NMSRelighter {
|
|||||||
if (brightness > 1 && (brightness != 15 || opacity != 15)) {
|
if (brightness > 1 && (brightness != 15 || opacity != 15)) {
|
||||||
lightBlock(bx + x, y, bz + z, brightness);
|
lightBlock(bx + x, y, bz + z, brightness);
|
||||||
}
|
}
|
||||||
if (opacity > 1 && opacity >= value) {
|
|
||||||
mask[j] = 0;
|
|
||||||
queue.setBlockLight(section, x, y, z, 0);
|
|
||||||
queue.setSkyLight(section, x, y, z, 0);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0:
|
case 0:
|
||||||
if (opacity > 1) {
|
if (opacity > 1) {
|
||||||
@ -230,6 +231,12 @@ public class NMSRelighter {
|
|||||||
case 9:
|
case 9:
|
||||||
case 11:
|
case 11:
|
||||||
case 13:
|
case 13:
|
||||||
|
if (opacity >= value) {
|
||||||
|
mask[j] = 0;
|
||||||
|
queue.setBlockLight(section, x, y, z, 0);
|
||||||
|
queue.setSkyLight(section, x, y, z, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (opacity <= 1) {
|
if (opacity <= 1) {
|
||||||
mask[j] = --value;
|
mask[j] = --value;
|
||||||
} else {
|
} else {
|
||||||
@ -238,6 +245,7 @@ public class NMSRelighter {
|
|||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
if (opacity > 1) {
|
if (opacity > 1) {
|
||||||
|
chunk.heightMap[z << 4 | x] = y;
|
||||||
value -= opacity;
|
value -= opacity;
|
||||||
mask[j] = value;
|
mask[j] = value;
|
||||||
}
|
}
|
||||||
@ -336,6 +344,7 @@ public class NMSRelighter {
|
|||||||
public final int x;
|
public final int x;
|
||||||
public final int z;
|
public final int z;
|
||||||
public final byte[] mask;
|
public final byte[] mask;
|
||||||
|
public int[] heightMap = new int[256];
|
||||||
public final boolean[] fix;
|
public final boolean[] fix;
|
||||||
public int bitmask;
|
public int bitmask;
|
||||||
public boolean smooth;
|
public boolean smooth;
|
||||||
|
@ -191,6 +191,10 @@ public class MCAChunk extends FaweChunk<Void> {
|
|||||||
streamer.readFully();
|
streamer.readFully();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int[] getHeightMapArray() {
|
||||||
|
return heightMap;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDeleted(boolean deleted) {
|
public void setDeleted(boolean deleted) {
|
||||||
setModified();
|
setModified();
|
||||||
this.deleted = deleted;
|
this.deleted = deleted;
|
||||||
|
@ -162,6 +162,19 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
MCAChunk mca = (MCAChunk) chunk;
|
||||||
|
if (mca != null) {
|
||||||
|
int[] otherMap = mca.getHeightMapArray();
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFullbright(FaweChunk sections) {
|
public void setFullbright(FaweChunk sections) {
|
||||||
if (sections.getClass() == MCAChunk.class) {
|
if (sections.getClass() == MCAChunk.class) {
|
||||||
|
@ -78,6 +78,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
getImpWorld();
|
getImpWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
|
if (forgeChunk != null) {
|
||||||
|
int[] otherMap = forgeChunk.getHeightMap();
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,6 +75,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
getImpWorld();
|
getImpWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
|
if (forgeChunk != null) {
|
||||||
|
int[] otherMap = forgeChunk.heightMap;
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||||
Map<ChunkPosition, TileEntity> tiles = chunk.chunkTileEntityMap;
|
Map<ChunkPosition, TileEntity> tiles = chunk.chunkTileEntityMap;
|
||||||
|
@ -72,6 +72,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
getImpWorld();
|
getImpWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
|
if (forgeChunk != null) {
|
||||||
|
int[] otherMap = forgeChunk.getHeightMap();
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,6 +80,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
|||||||
|
|
||||||
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
protected BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
Chunk forgeChunk = (Chunk) chunk.getChunk();
|
||||||
|
if (forgeChunk != null) {
|
||||||
|
int[] otherMap = forgeChunk.getHeightMap();
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||||
Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
|
Map<BlockPos, TileEntity> tiles = chunk.getTileEntityMap();
|
||||||
|
@ -49,6 +49,19 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHeightMap(FaweChunk chunk, int[] heightMap) {
|
||||||
|
BaseFullChunk forgeChunk = (BaseFullChunk) chunk.getChunk();
|
||||||
|
if (forgeChunk != null) {
|
||||||
|
int[] otherMap = forgeChunk.getHeightMapArray();
|
||||||
|
for (int i = 0; i < heightMap.length; i++) {
|
||||||
|
if (heightMap[i] > otherMap[i]) {
|
||||||
|
otherMap[i] = heightMap[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FaweNukkit getFaweNukkit() {
|
public FaweNukkit getFaweNukkit() {
|
||||||
return faweNukkit;
|
return faweNukkit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user