Looks like automagical relighting (#838)

Fixes #686
This commit is contained in:
dordsor21
2021-01-11 19:29:16 +00:00
committed by GitHub
parent 74a2f02003
commit b4d7562b87
46 changed files with 932 additions and 142 deletions

View File

@ -20,6 +20,8 @@
package com.sk89q.worldedit;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.implementation.lighting.NullRelighter;
import com.boydti.fawe.beta.implementation.lighting.Relighter;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit;
@ -224,12 +226,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
private final int maxY;
private final List<WatchdogTickingExtent> watchdogExtents = new ArrayList<>(2);
private final Relighter relighter;
private final boolean wnaMode;
@Nullable
private final Region[] allowedRegions;
@Deprecated
public EditSession(@NotNull EventBus bus, World world, @Nullable Player player,
@Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet,
@ -264,6 +266,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
this.maxY = world.getMaxY();
this.blockBag = builder.getBlockBag();
this.history = changeSet != null;
this.relighter = builder.getRelighter();
this.wnaMode = builder.isWNAMode();
this.allowedRegions = builder.getAllowedRegions() != null ? builder.getAllowedRegions().clone() : null;
}
@ -1093,6 +1096,25 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
}
// Reset limit
limit.set(originalLimit);
try {
if (relighter != null && !(relighter instanceof NullRelighter)) {
// Only relight once!
if (!relighter.getLock().tryLock()) {
relighter.getLock().lock();
relighter.getLock().unlock();
} else {
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
relighter.removeAndRelight(true);
} else {
relighter.fixSkyLighting();
relighter.fixBlockLighting();
}
}
}
} catch (Throwable e) {
player.printError(TranslatableComponent.of("fawe.error.lighting"));
e.printStackTrace();
}
// Enqueue it
if (getChangeSet() != null) {
if (Settings.IMP.HISTORY.COMBINE_STAGES) {

View File

@ -23,6 +23,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.implementation.filter.block.ExtentFilterBlock;
import com.boydti.fawe.beta.implementation.processors.ProcessorScope;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.changeset.AbstractChangeSet;
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
@ -707,6 +708,9 @@ public interface Extent extends InputExtent, OutputExtent {
}
default Extent addPostProcessor(IBatchProcessor processor) {
if (processor.getScope() == ProcessorScope.READING_SET_BLOCKS) {
throw new IllegalArgumentException("You cannot alter blocks in a PostProcessor");
}
return processor.construct(this);
}

View File

@ -28,6 +28,7 @@ import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
import com.boydti.fawe.beta.implementation.processors.ProcessorScope;
import com.google.common.cache.LoadingCache;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.Mask;
@ -128,4 +129,9 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
public Filter fork() {
return new MaskingExtent(getExtent(), this.mask.copy(), this.threadIdToFilter);
}
@Override
public ProcessorScope getScope() {
return ProcessorScope.REMOVING_BLOCKS;
}
}

View File

@ -25,6 +25,7 @@ import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.implementation.processors.ProcessorScope;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BlockVectorSet;
import com.sk89q.worldedit.math.BlockVector2;
@ -774,5 +775,4 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return null;
}
}

View File

@ -25,6 +25,7 @@ import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.implementation.processors.ProcessorScope;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.extent.SingleRegionExtent;
import com.sk89q.worldedit.extent.Extent;
@ -365,4 +366,9 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
}
return new SingleRegionExtent(child, FaweLimit.MAX, this);
}
@Override
default ProcessorScope getScope() {
return ProcessorScope.REMOVING_BLOCKS;
}
}