From 5e67c1b6586d5e901745bf882572e9e02dda424e Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 22 Sep 2020 11:34:45 +0100 Subject: [PATCH] Squash errors and debug to aid fixing #652 properly --- .../implementation/lighting/NMSRelighter.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java index f30fa0383..7b55ce48d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/lighting/NMSRelighter.java @@ -18,6 +18,8 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.BlockMaterial; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayDeque; import java.util.ArrayList; @@ -31,8 +33,11 @@ import java.util.Queue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; public class NMSRelighter implements Relighter { + + private static final Logger log = LoggerFactory.getLogger(NMSRelighter.class); private static final int DISPATCH_SIZE = 64; private static final DirectionalProperty stairDirection; private static final EnumProperty stairHalf; @@ -950,14 +955,26 @@ public class NMSRelighter implements Relighter { if (heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] == 0 && material.isSolid()) { heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] = y + 1; } - if (heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] == 0 && (material.isSolid() || material.isLiquid() || ( - state.getStates().containsKey(waterLogged) && state.getState(waterLogged)))) { - heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] = y + 1; + try { + if (heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] == 0 && (material.isSolid() || material.isLiquid() || ( + state.getStates().containsKey(waterLogged) && state.getState(waterLogged)))) { + heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] = y + 1; + } + } catch (Exception ignored) { + log.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:"); + log.debug(state.getStates().entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()) + .collect(Collectors.joining(", ", "{", "}"))); } - if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid() || ( - state.getStates().containsKey(waterLogged) && state.getState(waterLogged))) && !state.getBlockType().getId().toLowerCase() - .contains("leaves")) { - heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1; + try { + if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid() || ( + state.getStates().containsKey(waterLogged) && state.getState(waterLogged))) && !state.getBlockType().getId() + .toLowerCase().contains("leaves")) { + heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1; + } + } catch (Exception ignored) { + log.debug("Error calculating waterlogged state for BlockState: " + state.getBlockType().getId() + ". States:"); + log.debug(state.getStates().entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()) + .collect(Collectors.joining(", ", "{", "}"))); } }