This commit is contained in:
Jesse Boyd 2016-10-24 23:43:11 +11:00
parent 3c371d2eb1
commit 84f1ee19fc
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
14 changed files with 163 additions and 24 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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();

View File

@ -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;
}