mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-01 07:03:52 +01:00
Don't use relighter for non nms placer
This commit is contained in:
parent
92bf3f702b
commit
f0066bbd26
@ -2,6 +2,8 @@ package com.boydti.fawe.bukkit.v0;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.example.NullRelighter;
|
||||
import com.boydti.fawe.example.Relighter;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
@ -9,6 +11,7 @@ import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import java.io.File;
|
||||
@ -17,6 +20,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Location;
|
||||
@ -27,6 +31,9 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
|
||||
public static int ALLOCATE;
|
||||
private static int LIGHT_MASK = 0x739C0;
|
||||
private ConcurrentMap<Long, ChunkSnapshot> chunkCache = new MapMaker()
|
||||
.weakValues()
|
||||
.makeMap();
|
||||
|
||||
public BukkitQueue_All(com.sk89q.worldedit.world.World world) {
|
||||
super(world);
|
||||
@ -46,6 +53,11 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Relighter getRelighter() {
|
||||
return NullRelighter.INSTANCE;
|
||||
}
|
||||
|
||||
private static Class<?> classRegionFileCache;
|
||||
private static Class<?> classRegionFile;
|
||||
private static Class<?> classCraftChunk;
|
||||
@ -220,13 +232,15 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
|
||||
@Override
|
||||
public ChunkSnapshot getCachedChunk(World world, int cx, int cz) {
|
||||
long pair = MathMan.pairInt(cx, cz);
|
||||
ChunkSnapshot cached = chunkCache.get(pair);
|
||||
if (cached != null) return cached;
|
||||
if (world.isChunkLoaded(cx, cz)) {
|
||||
long pair = MathMan.pairInt(cx, cz);
|
||||
Long originalKeep = keepLoaded.get(pair);
|
||||
keepLoaded.put(pair, Long.MAX_VALUE);
|
||||
if (world.isChunkLoaded(cx, cz)) {
|
||||
Chunk chunk = world.getChunkAt(cx, cz);
|
||||
ChunkSnapshot snapshot = chunk.getChunkSnapshot(false, true, false);
|
||||
ChunkSnapshot snapshot = getAndCacheChunk(chunk);
|
||||
if (originalKeep != null) {
|
||||
keepLoaded.put(pair, originalKeep);
|
||||
} else {
|
||||
@ -263,7 +277,13 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
public ChunkSnapshot loadChunk(World world, int x, int z, boolean generate) {
|
||||
Chunk chunk = world.getChunkAt(x, z);
|
||||
chunk.load(generate);
|
||||
return chunk.isLoaded() ? chunk.getChunkSnapshot(false, true, false) : null;
|
||||
return chunk.isLoaded() ? getAndCacheChunk(chunk) : null;
|
||||
}
|
||||
|
||||
private ChunkSnapshot getAndCacheChunk(Chunk chunk) {
|
||||
ChunkSnapshot snapshot = chunk.getChunkSnapshot(false, true, false);
|
||||
chunkCache.put(MathMan.pairInt(chunk.getX(), chunk.getZ()), snapshot);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,11 +38,11 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
@Override
|
||||
public void runTasks() {
|
||||
super.runTasks();
|
||||
if (!relighter.isEmpty()) {
|
||||
if (!getRelighter().isEmpty()) {
|
||||
TaskManager.IMP.taskNowAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
relighter.fixLightingSafe(hasSky());
|
||||
getRelighter().fixLightingSafe(hasSky());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -66,7 +66,7 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
sendChunk(chunk);
|
||||
}
|
||||
if (Settings.IMP.LIGHTING.MODE == 2) {
|
||||
relighter.addChunk(chunk.getX(), chunk.getZ(), null, chunk.getBitMask());
|
||||
getRelighter().addChunk(chunk.getX(), chunk.getZ(), null, chunk.getBitMask());
|
||||
return;
|
||||
}
|
||||
CharFaweChunk cfc = (CharFaweChunk) chunk;
|
||||
@ -90,7 +90,7 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
}
|
||||
}
|
||||
if (relight) {
|
||||
relighter.addChunk(chunk.getX(), chunk.getZ(), fix, chunk.getBitMask());
|
||||
getRelighter().addChunk(chunk.getX(), chunk.getZ(), fix, chunk.getBitMask());
|
||||
} else if (Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) {
|
||||
sendChunk(chunk);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user