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
|
||||
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();
|
||||
}
|
||||
|
||||
@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() {
|
||||
checkVersion("v1_10_R1");
|
||||
if (air == null) {
|
||||
|
@ -86,6 +86,19 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
||||
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
|
||||
public boolean isChunkLoaded(int x, int z) {
|
||||
return getWorld().isChunkLoaded(x, z);
|
||||
|
@ -84,6 +84,19 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
||||
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
|
||||
public boolean isChunkLoaded(int x, int z) {
|
||||
return getWorld().isChunkLoaded(x, z);
|
||||
|
@ -96,6 +96,19 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
||||
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
|
||||
public ChunkSection[] getCachedSections(World world, int cx, int cz) {
|
||||
CraftChunk chunk = (CraftChunk) world.getChunkAt(cx, cz);
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.boydti.fawe.example;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -90,17 +88,10 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
|
||||
@Override
|
||||
public void sendChunk(final FaweChunk fc) {
|
||||
if (Fawe.get().isMainThread()) {
|
||||
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);
|
||||
|
||||
|
@ -3,13 +3,10 @@ package com.boydti.fawe.example;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class NMSRelighter {
|
||||
@ -129,12 +126,22 @@ public class NMSRelighter {
|
||||
}
|
||||
|
||||
public void sendChunks() {
|
||||
final Map<FaweChunk, int[]> fcs = new HashMap<>(skyToRelight.size());
|
||||
for (Map.Entry<Long, RelightSkyEntry> entry : skyToRelight.entrySet()) {
|
||||
RelightSkyEntry chunk = entry.getValue();
|
||||
CharFaweChunk fc = (CharFaweChunk) queue.getFaweChunk(chunk.x, chunk.z);
|
||||
fcs.put(fc, chunk.heightMap);
|
||||
fc.setBitMask(chunk.bitmask);
|
||||
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) {
|
||||
@ -196,12 +203,6 @@ public class NMSRelighter {
|
||||
if (brightness > 1 && (brightness != 15 || opacity != 15)) {
|
||||
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) {
|
||||
case 0:
|
||||
if (opacity > 1) {
|
||||
@ -230,6 +231,12 @@ public class NMSRelighter {
|
||||
case 9:
|
||||
case 11:
|
||||
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) {
|
||||
mask[j] = --value;
|
||||
} else {
|
||||
@ -238,6 +245,7 @@ public class NMSRelighter {
|
||||
break;
|
||||
case 15:
|
||||
if (opacity > 1) {
|
||||
chunk.heightMap[z << 4 | x] = y;
|
||||
value -= opacity;
|
||||
mask[j] = value;
|
||||
}
|
||||
@ -336,6 +344,7 @@ public class NMSRelighter {
|
||||
public final int x;
|
||||
public final int z;
|
||||
public final byte[] mask;
|
||||
public int[] heightMap = new int[256];
|
||||
public final boolean[] fix;
|
||||
public int bitmask;
|
||||
public boolean smooth;
|
||||
|
@ -191,6 +191,10 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
streamer.readFully();
|
||||
}
|
||||
|
||||
public int[] getHeightMapArray() {
|
||||
return heightMap;
|
||||
}
|
||||
|
||||
public void setDeleted(boolean deleted) {
|
||||
setModified();
|
||||
this.deleted = deleted;
|
||||
|
@ -162,6 +162,19 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
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
|
||||
public void setFullbright(FaweChunk sections) {
|
||||
if (sections.getClass() == MCAChunk.class) {
|
||||
|
@ -78,6 +78,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
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);
|
||||
|
||||
@Override
|
||||
|
@ -75,6 +75,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
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
|
||||
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||
Map<ChunkPosition, TileEntity> tiles = chunk.chunkTileEntityMap;
|
||||
|
@ -72,6 +72,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
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);
|
||||
|
||||
@Override
|
||||
|
@ -80,6 +80,19 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
|
||||
|
||||
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
|
||||
public CompoundTag getTileEntity(Chunk chunk, int x, int y, int z) {
|
||||
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() {
|
||||
return faweNukkit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user