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