diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java index df3f0cc1..0a01fb42 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/FlatteningWrapper15.java @@ -61,6 +61,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Objects; import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiPredicate; import java.util.logging.Level; @@ -138,18 +139,23 @@ public class FlatteningWrapper15 implements FlatteningWrapper { } } + AtomicReference pastePoint = new AtomicReference<>(); if (!pasteBuilder.getPredicates().isEmpty()) { e.setMask(new Mask() { @Override public boolean test(BlockVector3 blockVector3) { - BaseBlock block = clipboard.getFullBlock(blockVector3); - String blockName = block.toString().toLowerCase(); + BaseBlock block = clipboard.getFullBlock(blockVector3.subtract(pastePoint.get()).add(clipboard.getRegion().getMinimumPoint())); + String blockName = block.getBlockType().toString().toLowerCase(); for (BiPredicate predicate : pasteBuilder.getPredicates()) { if (!predicate.test(block, blockName)) return false; } return true; } + public Mask copy() { + return this; + } + @Nullable @Override public Mask2D toMask2D() { @@ -168,6 +174,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper { } else { v = v.subtract(dimensions.getX() / 2, 0, dimensions.getZ() / 2).subtract(offset); } + pastePoint.set(v); if (pasteBuilder.isReset()) { e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java index bf7aa7c0..543d8727 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -67,7 +67,8 @@ public class ColorCommand extends SWCommand { try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) .ignoreAir(true) - .onlyColors(true); + .onlyColors(true) + .color(color.getColor()); region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); RegionUtils.message(region, "REGION_REGION_COLORED"); RegionUtils.message(region, "REGION_REGION_COLORED_FAILED"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index cf8522c6..5caf0af3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -25,6 +25,8 @@ import de.steamwar.bausystem.features.util.SelectCommand; import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; @@ -101,7 +103,8 @@ public class RegionCommand extends SWCommand { try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) - .ignoreAir(true); + .ignoreAir(true) + .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); RegionUtils.message(region, "REGION_REGION_RESTORED"); } catch (SecurityException e) { @@ -122,7 +125,8 @@ public class RegionCommand extends SWCommand { try { PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node)) - .ignoreAir(true); + .ignoreAir(true) + .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); RegionUtils.message(region, "REGION_REGION_RESTORED"); } catch (SecurityException e) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java index bcb46110..03a22027 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java @@ -25,6 +25,8 @@ import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.PasteBuilder; @@ -56,7 +58,8 @@ public class ResetCommand extends SWCommand { Region region = regionCheck(p); if (region == null) return; try { - PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))); + PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) + .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); RegionUtils.message(region, "REGION_RESET_RESETED"); } catch (SecurityException e) { @@ -84,7 +87,8 @@ public class ResetCommand extends SWCommand { return; } try { - PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node)); + PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node)) + .color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); RegionUtils.message(region, "REGION_RESET_RESETED"); } catch (SecurityException e) {