Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-27 03:12:37 +01:00
Remove heightmap code from NMSRelighter
Dieser Commit ist enthalten in:
Ursprung
9ec9c56377
Commit
3c19944300
@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class NMSRelighterFactory implements RelighterFactory {
|
||||
@Override
|
||||
public @NotNull Relighter createRelighter(RelightMode relightMode, World world, IQueueExtent<IQueueChunk> queue) {
|
||||
return new NMSRelighter(queue, Settings.IMP.LIGHTING.DO_HEIGHTMAPS,
|
||||
return new NMSRelighter(queue,
|
||||
relightMode != null ? relightMode : RelightMode.valueOf(Settings.IMP.LIGHTING.MODE));
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||
import com.sk89q.worldedit.registry.state.EnumProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
@ -37,7 +36,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class NMSRelighter implements Relighter {
|
||||
|
||||
@ -47,14 +45,12 @@ public class NMSRelighter implements Relighter {
|
||||
private static final EnumProperty stairHalf;
|
||||
private static final EnumProperty stairShape;
|
||||
private static final EnumProperty slabHalf;
|
||||
private static final BooleanProperty waterLogged;
|
||||
|
||||
static {
|
||||
stairDirection = (DirectionalProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("facing");
|
||||
stairHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("half");
|
||||
stairShape = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("shape");
|
||||
slabHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_SLAB.getProperty("type");
|
||||
waterLogged = (BooleanProperty) (Property<?>) BlockTypes.SANDSTONE_SLAB.getProperty("waterlogged");
|
||||
}
|
||||
|
||||
public final MutableBlockVector3 mutableBlockPos = new MutableBlockVector3(0, 0, 0);
|
||||
@ -62,31 +58,27 @@ public class NMSRelighter implements Relighter {
|
||||
private final Map<Long, RelightSkyEntry> skyToRelight;
|
||||
private final Object present = new Object();
|
||||
private final Map<Long, Integer> chunksToSend;
|
||||
private final Map<Long, Map<HeightMapType, int[]>> heightMaps;
|
||||
private final ConcurrentLinkedQueue<RelightSkyEntry> extentdSkyToRelight = new ConcurrentLinkedQueue<>();
|
||||
private final Map<Long, long[][][] /* z y x */> lightQueue;
|
||||
private final AtomicBoolean lightLock = new AtomicBoolean(false);
|
||||
private final ConcurrentHashMap<Long, long[][][]> concurrentLightQueue;
|
||||
private final RelightMode relightMode;
|
||||
private final int maxY;
|
||||
private final boolean calculateHeightMaps;
|
||||
private final ReentrantLock lightingLock;
|
||||
private final AtomicBoolean finished = new AtomicBoolean(false);
|
||||
private boolean removeFirst;
|
||||
|
||||
public NMSRelighter(IQueueExtent<IQueueChunk> queue, boolean calculateHeightMaps) {
|
||||
this(queue, calculateHeightMaps, null);
|
||||
this(queue, null);
|
||||
}
|
||||
|
||||
public NMSRelighter(IQueueExtent<IQueueChunk> queue, boolean calculateHeightMaps, RelightMode relightMode) {
|
||||
public NMSRelighter(IQueueExtent<IQueueChunk> queue, RelightMode relightMode) {
|
||||
this.queue = queue;
|
||||
this.skyToRelight = new Long2ObjectOpenHashMap<>(12);
|
||||
this.lightQueue = new Long2ObjectOpenHashMap<>(12);
|
||||
this.chunksToSend = new Long2ObjectOpenHashMap<>(12);
|
||||
this.concurrentLightQueue = new ConcurrentHashMap<>(12);
|
||||
this.heightMaps = new Long2ObjectOpenHashMap<>(12);
|
||||
this.maxY = queue.getMaxY();
|
||||
this.calculateHeightMaps = calculateHeightMaps;
|
||||
this.relightMode = relightMode != null ? relightMode : RelightMode.valueOf(Settings.IMP.LIGHTING.MODE);
|
||||
this.lightingLock = new ReentrantLock();
|
||||
}
|
||||
@ -160,12 +152,11 @@ public class NMSRelighter implements Relighter {
|
||||
extentdSkyToRelight.clear();
|
||||
skyToRelight.clear();
|
||||
chunksToSend.clear();
|
||||
heightMaps.clear();
|
||||
lightQueue.clear();
|
||||
}
|
||||
|
||||
public boolean addChunk(int cx, int cz, byte[] fix, int bitmask) {
|
||||
RelightSkyEntry toPut = new RelightSkyEntry(cx, cz, fix, bitmask, calculateHeightMaps);
|
||||
RelightSkyEntry toPut = new RelightSkyEntry(cx, cz, fix, bitmask);
|
||||
extentdSkyToRelight.add(toPut);
|
||||
return true;
|
||||
}
|
||||
@ -834,14 +825,6 @@ public class NMSRelighter implements Relighter {
|
||||
int z = MathMan.unpairIntY(pair);
|
||||
ChunkHolder<?> chunk = (ChunkHolder<?>) queue.getOrCreateChunk(x, z);
|
||||
chunk.setBitMask(bitMask);
|
||||
if (calculateHeightMaps && heightMaps != null) {
|
||||
Map<HeightMapType, int[]> heightMapList = heightMaps.get(pair);
|
||||
if (heightMapList != null) {
|
||||
for (Map.Entry<HeightMapType, int[]> heightMapEntry : heightMapList.entrySet()) {
|
||||
chunk.setHeightMap(heightMapEntry.getKey(), heightMapEntry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
iter.remove();
|
||||
}
|
||||
if (Settings.IMP.LIGHTING.ASYNC) {
|
||||
@ -870,14 +853,6 @@ public class NMSRelighter implements Relighter {
|
||||
int z = MathMan.unpairIntY(pair);
|
||||
ChunkHolder<?> chunk = (ChunkHolder<?>) queue.getOrCreateChunk(x, z);
|
||||
chunk.setBitMask(bitMask);
|
||||
if (calculateHeightMaps && heightMaps != null) {
|
||||
Map<HeightMapType, int[]> heightMapList = heightMaps.get(pair);
|
||||
if (heightMapList != null) {
|
||||
for (Map.Entry<HeightMapType, int[]> heightMapEntry : heightMapList.entrySet()) {
|
||||
chunk.setHeightMap(heightMapEntry.getKey(), heightMapEntry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
chunk.flushLightToGet(true);
|
||||
Fawe.imp().getPlatformAdapter().sendChunk(chunk.getOrCreateGet(), bitMask, true);
|
||||
iter.remove();
|
||||
@ -944,33 +919,19 @@ public class NMSRelighter implements Relighter {
|
||||
private void fixSkyLighting(List<RelightSkyEntry> sorted) {
|
||||
RelightSkyEntry[] chunks = sorted.toArray(new RelightSkyEntry[sorted.size()]);
|
||||
boolean remove = this.removeFirst;
|
||||
boolean heightMaps = this.calculateHeightMaps;
|
||||
BlockVectorSet chunkSet = null;
|
||||
if (remove || heightMaps) {
|
||||
if (remove) {
|
||||
BlockVectorSet tmpSet = new BlockVectorSet();
|
||||
if (remove) {
|
||||
chunkSet = new BlockVectorSet();
|
||||
for (RelightSkyEntry chunk : chunks) {
|
||||
tmpSet.add(chunk.x, 0, chunk.z);
|
||||
}
|
||||
chunkSet = new BlockVectorSet();
|
||||
for (RelightSkyEntry chunk : chunks) {
|
||||
tmpSet.add(chunk.x, 0, chunk.z);
|
||||
}
|
||||
for (RelightSkyEntry chunk : chunks) {
|
||||
if (remove) {
|
||||
int x = chunk.x;
|
||||
int z = chunk.z;
|
||||
if (tmpSet.contains(x + 1, 0, z) && tmpSet.contains(x - 1, 0, z) && tmpSet.contains(x, 0, z + 1) && tmpSet
|
||||
.contains(x, 0, z - 1)) {
|
||||
chunkSet.add(x, 0, z);
|
||||
}
|
||||
}
|
||||
if (heightMaps) {
|
||||
long pair = MathMan.pairInt(chunk.x, chunk.z);
|
||||
this.heightMaps.putIfAbsent(pair, new HashMap<>());
|
||||
Map<HeightMapType, int[]> heightMapList = this.heightMaps.get(pair);
|
||||
heightMapList.putIfAbsent(HeightMapType.WORLD_SURFACE, new int[256]);
|
||||
heightMapList.putIfAbsent(HeightMapType.OCEAN_FLOOR, new int[256]);
|
||||
heightMapList.putIfAbsent(HeightMapType.MOTION_BLOCKING, new int[256]);
|
||||
heightMapList.putIfAbsent(HeightMapType.MOTION_BLOCKING_NO_LEAVES, new int[256]);
|
||||
int x = chunk.x;
|
||||
int z = chunk.z;
|
||||
if (tmpSet.contains(x + 1, 0, z) && tmpSet.contains(x - 1, 0, z) && tmpSet.contains(x, 0, z + 1) && tmpSet
|
||||
.contains(x, 0, z - 1)) {
|
||||
chunkSet.add(x, 0, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -996,12 +957,6 @@ public class NMSRelighter implements Relighter {
|
||||
iChunk.removeSectionLighting(y >> 4, true);
|
||||
}
|
||||
|
||||
Map<HeightMapType, int[]> heightMapList = null;
|
||||
if (heightMaps) {
|
||||
long pair = MathMan.pairInt(chunk.x, chunk.z);
|
||||
heightMapList = this.heightMaps.get(pair);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 256; j++) {
|
||||
int x = j & 15;
|
||||
int z = j >> 4;
|
||||
@ -1014,38 +969,6 @@ public class NMSRelighter implements Relighter {
|
||||
addLightUpdate(bx + x, y, bz + z);
|
||||
}
|
||||
|
||||
if (heightMaps) {
|
||||
if (heightMapList.get(HeightMapType.WORLD_SURFACE)[j] == 0 && !material.isAir()) {
|
||||
// MC Requires y+1
|
||||
heightMapList.get(HeightMapType.WORLD_SURFACE)[j] = y + 1;
|
||||
}
|
||||
if (heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] == 0 && material.isSolid()) {
|
||||
heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] = y + 1;
|
||||
}
|
||||
Map<Property<?>, Object> states = state.getStates();
|
||||
try {
|
||||
if (heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] == 0 && (material.isSolid() || material.isLiquid() || (
|
||||
states.containsKey(waterLogged) && state.getState(waterLogged)))) {
|
||||
heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] = y + 1;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
LOGGER.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:");
|
||||
LOGGER.debug(states.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
|
||||
.collect(Collectors.joining(", ", "{", "}")));
|
||||
}
|
||||
try {
|
||||
if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid() || (
|
||||
states.containsKey(waterLogged) && state.getState(waterLogged))) && !state.getBlockType().getId()
|
||||
.toLowerCase().contains("leaves")) {
|
||||
heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
LOGGER.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:");
|
||||
LOGGER.debug(states.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
|
||||
.collect(Collectors.joining(", ", "{", "}")));
|
||||
}
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case 0:
|
||||
if (opacity > 1) {
|
||||
@ -1223,7 +1146,7 @@ public class NMSRelighter implements Relighter {
|
||||
public int bitmask;
|
||||
public boolean smooth;
|
||||
|
||||
public RelightSkyEntry(int x, int z, byte[] fix, int bitmask, boolean heightmaps) {
|
||||
public RelightSkyEntry(int x, int z, byte[] fix, int bitmask) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
byte[] array = new byte[256];
|
||||
|
@ -411,10 +411,7 @@ public class EditSessionBuilder {
|
||||
} else {
|
||||
relighter = NullRelighter.INSTANCE;
|
||||
}
|
||||
// TODO dirty workaround, NMSRelighter and HeightmapProcessor don't work well together
|
||||
if (Settings.IMP.LIGHTING.MODE == 0 || relighter.getClass().getSimpleName().startsWith("Tuinity")) {
|
||||
extent.addProcessor(new HeightmapProcessor(world));
|
||||
}
|
||||
extent.addProcessor(new HeightmapProcessor(world));
|
||||
if (limit != null && !limit.isUnlimited() && regionExtent != null) {
|
||||
this.extent = new LimitExtent(regionExtent, limit);
|
||||
} else if (limit != null && !limit.isUnlimited()) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren