From 806916d6e8698f368d913f69c4c3d38c4580570b Mon Sep 17 00:00:00 2001 From: Aurora <21148213+aurorasmiles@users.noreply.github.com> Date: Sun, 20 Sep 2020 16:33:07 +0200 Subject: [PATCH 1/4] Fix entity rotation (#642) * fix entity rotation fixes #577 Co-authored-by: wea_ondara --- .../function/entity/ExtentEntityCopy.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index d6308af88..36ce61663 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -39,6 +39,9 @@ import com.sk89q.worldedit.world.entity.EntityTypes; import java.util.UUID; import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.jnbt.FloatTag; +import com.sk89q.jnbt.ListTag; +import java.util.Arrays; /** * Copies entities provided to the function to the provided destination @@ -201,6 +204,7 @@ public class ExtentEntityCopy implements EntityFunction { // Handle hanging entities (paintings, item frames, etc.) boolean hasTilePosition = tag.containsKey("TileX") && tag.containsKey("TileY") && tag.containsKey("TileZ"); boolean hasFacing = tag.containsKey("Facing"); + boolean hasRotation = tag.containsKey("Rotation"); if (hasTilePosition) { Vector3 tilePosition = Vector3.at(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); @@ -225,6 +229,22 @@ public class ExtentEntityCopy implements EntityFunction { } } + if (hasRotation) { + ListTag orgrot = state.getNbtData().getListTag("Rotation"); + Vector3 orgDirection = new Location(source, 0, 0, 0, orgrot.getFloat(0), orgrot.getFloat(1)).getDirection(); + Vector3 newDirection = transform.apply(orgDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); + builder.put("Rotation", new ListTag(FloatTag.class, Arrays.asList(new FloatTag((float) newDirection.toYaw()), new FloatTag((float) newDirection.toPitch())))); + } + + return new BaseEntity(state.getType(), builder.build()); + } else if (hasRotation) { //armor stands do not have a tile pos + CompoundTagBuilder builder = tag.createBuilder(); + + ListTag orgrot = state.getNbtData().getListTag("Rotation"); + Vector3 orgDirection = new Location(source, 0, 0, 0, orgrot.getFloat(0), orgrot.getFloat(1)).getDirection(); + Vector3 newDirection = transform.apply(orgDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); + builder.put("Rotation", new ListTag(FloatTag.class, Arrays.asList(new FloatTag((float) newDirection.toYaw()), new FloatTag((float) newDirection.toPitch())))); + return new BaseEntity(state.getType(), builder.build()); } } From 3b2fe2ffde2b7c2155e227da302eb5c07871f7f7 Mon Sep 17 00:00:00 2001 From: Aurora <21148213+aurorasmiles@users.noreply.github.com> Date: Mon, 21 Sep 2020 17:07:35 +0200 Subject: [PATCH 2/4] Fix toggle permission (#644) * Fixes #529 * fix superperms perm toggling Co-authored-by: @weaondara --- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 18 +++++++++++++----- .../extension/platform/PlayerProxy.java | 8 +++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 61403b934..8a84d5d94 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -60,6 +60,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.permissions.PermissionAttachment; import java.util.concurrent.ConcurrentHashMap; import java.util.HashMap; @@ -73,16 +74,19 @@ public class BukkitPlayer extends AbstractPlayerActor { private Player player; private WorldEditPlugin plugin; + private PermissionAttachment permAttachment; public BukkitPlayer(Player player) { super(getExistingMap(WorldEditPlugin.getInstance(), player)); this.plugin = WorldEditPlugin.getInstance(); this.player = player; + this.permAttachment = player.addAttachment(plugin); } public BukkitPlayer(WorldEditPlugin plugin, Player player) { this.plugin = plugin; this.player = player; + this.permAttachment = player.addAttachment(plugin); if (Settings.IMP.CLIPBOARD.USE_DISK) { loadClipboardFromDisk(); } @@ -239,16 +243,20 @@ public class BukkitPlayer extends AbstractPlayerActor { * Permissions are used to managing WorldEdit region restrictions * - The `/wea` command will give/remove the required bypass permission */ + boolean usesuperperms = VaultResolver.perms == null; if (VaultResolver.perms != null) { if (value) { if (!VaultResolver.perms.playerAdd(player, permission)) { - player.addAttachment(plugin).setPermission(permission, value); + usesuperperms = true; + } + } else { + if (!VaultResolver.perms.playerRemove(player, permission)) { + usesuperperms = true; } - } else if (!VaultResolver.perms.playerRemove(player, permission)) { - player.addAttachment(plugin).setPermission(permission, value); } - } else { - player.addAttachment(plugin).setPermission(permission, value); + } + if (usesuperperms) { + permAttachment.setPermission(permission, value); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index dc8916997..c3a2dad04 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -174,11 +174,13 @@ public class PlayerProxy extends AbstractPlayerActor { return permActor.hasPermission(perm); } - @Override public boolean togglePermission(String permission) { - return permActor.hasPermission(permission); + @Override + public boolean togglePermission(String permission) { + return permActor.togglePermission(permission); } - @Override public void setPermission(String permission, boolean value) { + @Override + public void setPermission(String permission, boolean value) { permActor.setPermission(permission, value); } From 3b660756f675e658b91fc510f4c0b5d24a4c0500 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Mon, 21 Sep 2020 17:09:17 +0100 Subject: [PATCH 3/4] Fix #647 --- .../fawe/beta/implementation/filter/MaskFilter.java | 8 +++++++- .../implementation/queue/SingleThreadQueueExtent.java | 2 +- .../java/com/boydti/fawe/object/brush/ImageBrush.java | 6 ++++++ .../java/com/boydti/fawe/object/brush/LayerBrush.java | 6 ++++++ .../com/boydti/fawe/object/brush/SplatterBrush.java | 6 ++++++ .../com/boydti/fawe/object/brush/StencilBrush.java | 6 ++++++ .../java/com/boydti/fawe/object/mask/DataMask.java | 10 ++++++++++ .../java/com/boydti/fawe/object/mask/IdDataMask.java | 7 ++++++- .../main/java/com/boydti/fawe/object/mask/IdMask.java | 11 ++++++++--- .../com/sk89q/worldedit/function/mask/ABlockMask.java | 4 ++++ .../worldedit/function/mask/AbstractExtentMask.java | 3 +++ .../worldedit/function/mask/BlockCategoryMask.java | 5 +++++ .../sk89q/worldedit/function/mask/BlockStateMask.java | 5 +++++ .../sk89q/worldedit/function/mask/BlockTypeMask.java | 5 +++++ .../worldedit/function/mask/DelegateExtentMask.java | 11 ----------- .../worldedit/function/mask/ExistingBlockMask.java | 5 +++++ .../worldedit/function/mask/SingleBlockTypeMask.java | 1 + 17 files changed, 84 insertions(+), 17 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java index 524ce1707..7d821c281 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/MaskFilter.java @@ -3,6 +3,7 @@ package com.boydti.fawe.beta.implementation.filter; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.implementation.filter.block.DelegateFilter; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; +import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.Mask; import java.util.function.Supplier; @@ -33,7 +34,12 @@ public class MaskFilter extends DelegateFilter { @Override public void applyBlock(FilterBlock block) { - if (mask.test(block)) { + if (mask instanceof AbstractExtentMask) { + if (((AbstractExtentMask) mask).test(block, block)) { + getParent().applyBlock(block); + this.changes++; + } + } else if (mask.test(block)) { getParent().applyBlock(block); this.changes++; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 72c449639..571191418 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -216,7 +216,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen } @Override - public synchronized final IQueueChunk getOrCreateChunk(int x, int z) { + public final IQueueChunk getOrCreateChunk(int x, int z) { final long pair = (long) x << 32 | z & 0xffffffffL; if (pair == lastPair) { return lastChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java index 57269d0a7..298ced9d5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/ImageBrush.java @@ -87,6 +87,12 @@ public class ImageBrush implements Brush { RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { private final MutableVector3 mutable = new MutableVector3(); + + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(vector); + } + @Override public boolean test(BlockVector3 vector) { if (solid.test(vector)) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java index 5b3fa03e3..9c2cc2faf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/LayerBrush.java @@ -6,6 +6,7 @@ import com.boydti.fawe.object.mask.RadiusMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.command.tool.brush.Brush; +import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.Mask; @@ -47,6 +48,11 @@ public class LayerBrush implements Brush { Operations.completeBlindly(visitor); BlockVectorSet visited = visitor.getVisited(); visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(vector); + } + @Override public boolean test(BlockVector3 pos) { int depth = visitor.getDepth() + 1; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java index 1143937a8..061235dda 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java @@ -4,6 +4,7 @@ import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.mask.SurfaceMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; @@ -36,6 +37,11 @@ public class SplatterBrush extends ScatterBrush { SurfaceMask surface = new SurfaceMask(editSession); RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(vector); + } + @Override public boolean test(BlockVector3 vector) { double dist = vector.distanceSq(position); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java index 08d5adefb..01e59173a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/StencilBrush.java @@ -4,6 +4,7 @@ import com.boydti.fawe.object.brush.heightmap.HeightMap; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.SolidBlockMask; @@ -55,6 +56,11 @@ public class StencilBrush extends HeightBrush { double scale = (yscale / sizeDouble) * (maxY + 1); RecursiveVisitor visitor = new RecursiveVisitor(new AbstractExtentMask(editSession) { + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(vector); + } + private final MutableVector3 mutable = new MutableVector3(); @Override public boolean test(BlockVector3 vector) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java index d56ccd007..41d5d5aef 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/DataMask.java @@ -22,6 +22,16 @@ public class DataMask extends AbstractExtentMask implements ResettableMask { } } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + if (data != -1) { + return extent.getBlock(vector).getInternalPropertiesId() == data; + } else { + data = extent.getBlock(vector).getInternalPropertiesId(); + return true; + } + } + @Override public void reset() { this.data = -1; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java index cd62830fb..dcdd4987d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdDataMask.java @@ -12,7 +12,7 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask { } @Override - public boolean test(BlockVector3 vector) { + public boolean test(Extent extent, BlockVector3 vector) { if (combined != -1) { return getExtent().getBlock(vector).getInternalId() == combined; } else { @@ -21,6 +21,11 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask { } } + @Override + public boolean test(BlockVector3 vector) { + return test(getExtent(), vector); + } + @Override public void reset() { this.combined = -1; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java index 2a69c2a4a..b73fbedee 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/mask/IdMask.java @@ -13,15 +13,20 @@ public class IdMask extends AbstractExtentMask implements ResettableMask { } @Override - public boolean test(BlockVector3 vector) { + public boolean test(Extent extent, BlockVector3 vector) { if (id != -1) { - return getExtent().getBlock(vector).getInternalBlockTypeId() == id; + return extent.getBlock(vector).getInternalBlockTypeId() == id; } else { - id = getExtent().getBlock(vector).getInternalBlockTypeId(); + id = extent.getBlock(vector).getInternalBlockTypeId(); return true; } } + @Override + public boolean test(BlockVector3 vector) { + return test(getExtent(), vector); + } + @Override public void reset() { this.id = -1; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java index a37946a17..1489f0495 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ABlockMask.java @@ -15,6 +15,10 @@ public abstract class ABlockMask extends AbstractExtentMask { super(extent); } + @Override public boolean test(Extent extent, BlockVector3 vector) { + return test(extent.getBlock(vector)); + } + @Override public boolean test(BlockVector3 vector) { return test(getExtent().getBlock(vector)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java index 7c9192c0c..c5789eb1a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/AbstractExtentMask.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import static com.google.common.base.Preconditions.checkNotNull; @@ -59,4 +60,6 @@ public abstract class AbstractExtentMask extends AbstractMask { this.extent = extent; } + abstract public boolean test(Extent extent, BlockVector3 position); + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java index 671f71acd..7b64f19d6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockCategoryMask.java @@ -46,6 +46,11 @@ public class BlockCategoryMask extends AbstractExtentMask { return category.contains(getExtent().getBlock(vector)); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return category.contains(extent.getBlock(vector)); + } + @Nullable @Override public Mask2D toMask2D() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java index 485246917..1c52df34a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockStateMask.java @@ -57,6 +57,11 @@ public class BlockStateMask extends AbstractExtentMask { return test(getExtent().getBlock(vector)); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(extent.getBlock(vector)); + } + public boolean test(BlockState block) { final Map, Object> checkProps = cache .computeIfAbsent(block.getBlockType(), (b -> Blocks.resolveProperties(states, b))); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java index 664739293..8776037df 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockTypeMask.java @@ -114,6 +114,11 @@ public class BlockTypeMask extends AbstractExtentMask { return test(getExtent().getBlock(vector).getBlockType()); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return test(extent.getBlock(vector).getBlockType()); + } + @Override public boolean replacesAir() { return hasAir; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java deleted file mode 100644 index 65fc2bb26..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/DelegateExtentMask.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.sk89q.worldedit.function.mask; - -import com.boydti.fawe.object.function.mask.AbstractDelegateMask; - -public class DelegateExtentMask extends AbstractDelegateMask { - - public DelegateExtentMask(Mask parent) { - super(parent); - } - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index 7619c15ff..1504d46d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -44,6 +44,11 @@ public class ExistingBlockMask extends AbstractExtentMask { return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); } + @Override + public boolean test(Extent extent, BlockVector3 vector) { + return !extent.getBlock(vector).getBlockType().getMaterial().isAir(); + } + @Nullable @Override public Mask2D toMask2D() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java index d21eaf28d..6ceea320c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockTypeMask.java @@ -1,6 +1,7 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; From 5e67c1b6586d5e901745bf882572e9e02dda424e Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 22 Sep 2020 11:34:45 +0100 Subject: [PATCH 4/4] 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(", ", "{", "}"))); } }