From 7086eb8b3e554b3b7dd02af678857ab6e23fa21f Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 3 Apr 2019 22:28:57 +1100 Subject: [PATCH] continue with merge --- .../worldedit/bukkit/BukkitBiomeRegistry.java | 1 - .../java/com/sk89q/worldedit/EditSession.java | 94 ++++++++----------- .../com/sk89q/worldedit/LocalSession.java | 10 ++ .../worldedit/command/UtilityCommands.java | 11 ++- .../worldedit/command/tool/AreaPickaxe.java | 26 +++-- .../worldedit/command/tool/FloodFillTool.java | 13 ++- .../extension/platform/PlatformManager.java | 15 ++- .../extent/AbstractDelegateExtent.java | 10 +- .../com/sk89q/worldedit/extent/Extent.java | 10 +- .../sk89q/worldedit/extent/InputExtent.java | 1 + .../extent/reorder/MultiStageReorder.java | 4 +- .../worldedit/function/mask/BlockMask.java | 7 ++ .../function/mask/BlockMaskBuilder.java | 4 +- .../worldedit/function/pattern/Pattern.java | 4 + .../internal/command/WorldEditBinding.java | 3 +- .../sk89q/worldedit/regions/CuboidRegion.java | 1 + .../regions/shape/ArbitraryBiomeShape.java | 24 ++--- .../worldedit/world/biome/BiomeTypes.java | 4 + .../worldedit/world/block/BlockState.java | 8 +- .../worldedit/world/block/BlockTypes.java | 1 + 20 files changed, 136 insertions(+), 115 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java index 27474678f..d7e2f3c5a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBiomeRegistry.java @@ -40,5 +40,4 @@ class BukkitBiomeRegistry implements BiomeRegistry { final Biome bukkitBiome = BukkitAdapter.adapt(biome); return bukkitBiome == null ? null : bukkitBiome::name; } - } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index b1779c154..69642107a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -50,6 +50,7 @@ import com.boydti.fawe.object.extent.FaweRegionExtent; import com.boydti.fawe.object.extent.HeightBoundExtent; import com.boydti.fawe.object.extent.MultiRegionExtent; import com.boydti.fawe.object.extent.NullExtent; +import com.boydti.fawe.object.extent.ProcessedWEExtent; import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.object.extent.SingleRegionExtent; import com.boydti.fawe.object.extent.SlowExtent; @@ -194,6 +195,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, private static final Logger log = LoggerFactory.getLogger(EditSession.class); + public enum Stage { + BEFORE_HISTORY, + BEFORE_REORDER, + BEFORE_CHANGE + } + private World world; private String worldName; private FaweQueue queue; @@ -218,12 +225,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7"); public static final BlockState nullBlock = BlockTypes.AIR.getDefaultState(); - public enum Stage { - BEFORE_HISTORY, - BEFORE_REORDER, - BEFORE_CHANGE - } - @Deprecated public EditSession(@Nonnull World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { this(null, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event); @@ -417,10 +418,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, this(WorldEdit.getInstance().getEventBus(), world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks, null)); } - private ReorderMode reorderMode = ReorderMode.MULTI_STAGE; - - private Mask oldMask; - /** * Construct the object with a maximum number of blocks and a block bag. * @@ -449,8 +446,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, if (find != null && find.get() != null) { find.get().setLimit(this.limit); } - - setReorderMode(this.reorderMode); } /** @@ -619,15 +614,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // pkg private for TracedEditSession only, may later become public API boolean commitRequired() { - if (reorderExtent != null && reorderExtent.commitRequired()) { - return true; - } - if (chunkBatchingExtent != null && chunkBatchingExtent.commitRequired()) { - return true; - } - if (fastModeExtent != null && fastModeExtent.commitRequired()) { - return true; - } return false; } @@ -1400,7 +1386,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * and that it should apply them to the world. */ public void flushSession() { - Operations.completeBlindly(commit()); + flushQueue(); } @Override @@ -2895,11 +2881,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, counter[type.getInternalId()]++; } } - List> distribution = new ArrayList<>(); + List> distribution = new ArrayList<>(); for (int i = 0; i < counter.length; i++) { int count = counter[i]; if (count != 0) { - distribution.add(new Countable<>(BlockTypes.get(i), count)); + distribution.add(new Countable<>(BlockTypes.get(i).getDefaultState(), count)); } } Collections.sort(distribution); @@ -2919,7 +2905,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @throws ExpressionException * @throws MaxChangedBlocksException */ - public List> getBlockDistributionWithData(final Region region) { + public List> getBlockDistributionWithData(final Region region) { int[][] counter = new int[BlockTypes.size()][]; if (region instanceof CuboidRegion) { @@ -2958,7 +2944,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, stateCounter[blk.getInternalPropertiesId()]++; } } - List> distribution = new ArrayList<>(); + List> distribution = new ArrayList<>(); for (int typeId = 0; typeId < counter.length; typeId++) { BlockType type = BlockTypes.get(typeId); int[] stateCount = counter[typeId]; @@ -2966,7 +2952,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, for (int propId = 0; propId < stateCount.length; propId++) { int count = stateCount[propId]; if (count != 0) { - BlockStateHolder state = type.withPropertyId(propId); + BlockState state = type.withPropertyId(propId); distribution.add(new Countable<>(state, count)); } @@ -3333,26 +3319,28 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } private void recurseHollow(Region region, BlockVector3 origin, Set outside) { - final BlockVectorSet queue = new BlockVectorSet<>(); - queue.addLast(origin); - + final BlockVectorSet queue = new BlockVectorSet(); while (!queue.isEmpty()) { - final BlockVector3 current = queue.removeFirst(); - final BlockState block = getBlock(current); - if (block.getBlockType().getMaterial().isMovementBlocker()) { - continue; - } + Iterator iter = queue.iterator(); + while (iter.hasNext()) { + BlockVector3 current = iter.next(); + iter.remove(); + final BlockState block = getBlock(current); + if (block.getBlockType().getMaterial().isMovementBlocker()) { + continue; + } - if (!outside.add(current)) { - continue; - } + if (!outside.add(current)) { + continue; + } - if (!region.contains(current)) { - continue; - } + if (!region.contains(current)) { + continue; + } - for (BlockVector3 recurseDirection : recurseDirections) { - queue.addLast(current.add(recurseDirection)); + for (BlockVector3 recurseDirection : recurseDirections) { + queue.add(current.add(recurseDirection)); + } } } } @@ -3388,11 +3376,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } }; int changed = shape.generate(this, biomeType, hollow); - if (timedOut[0] > 0) { - throw new ExpressionTimeoutException( - String.format("%d blocks changed. %d blocks took too long to evaluate (increase time with //timeout)", - changed, timedOut[0])); - } return changed; } private static final BlockVector3[] recurseDirections = { @@ -3504,9 +3487,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, for (int z = 0; z < 16; z++) { int zz = z + bz; for (int y = 0; y < getMaxY() + 1; y++) { -// BlockStateHolder block = getFullBlock(mutable.setComponents(xx, y, zz)); - BlockVector3 bv = BlockVector3.at(xx, y, zz); - BaseBlock block = getFullBlock(bv); + BaseBlock block = getFullBlock(mutable.setComponents(xx, y, zz)); fcs.add(mbv, block, BlockTypes.AIR.getDefaultState().toBaseBlock()); } } @@ -3530,18 +3511,17 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, mutable.mutZ(zz); for (int y = 0; y < getMaxY() + 1; y++) { mutable.mutY(y); - BlockVector3 mbv = BlockVector3.at(xx, y, zz); - boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mbv); + boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable); if (contains) { containsAny = true; if (fcs != null) { - BaseBlock block = getFullBlock(mbv); - fcs.add(mbv, block, BlockTypes.AIR.getDefaultState().toBaseBlock()); + BaseBlock block = getFullBlock(mutable); + fcs.add(mutable, block, BlockTypes.AIR.getDefaultState().toBaseBlock()); } } else { - BlockStateHolder block = getFullBlock(mbv); + BlockStateHolder block = getFullBlock(mutable); try { - setBlock(mbv, block); + setBlock(mutable, block); } catch (MaxChangedBlocksException e) { throw new RuntimeException(e); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index a1a56f980..fd9f4788f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -68,12 +68,22 @@ import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.snapshot.Snapshot; +import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Calendar; +import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.TimeZone; +import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index d111b86f8..1d8e2b84d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -113,8 +113,11 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT; */ @Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)") public class UtilityCommands extends MethodCommands { + private final WorldEdit we; + public UtilityCommands(WorldEdit we) { super(we); + this.we = we; } @Command( @@ -536,15 +539,19 @@ public class UtilityCommands extends MethodCommands { EditSession editSession = null; if (player != null) { - session = worldEdit.getSessionManager().get(player); + session = we.getSessionManager().get(player); BlockVector3 center = session.getPlacementPosition(player); editSession = session.createEditSession(player); List entities; if (radius >= 0) { CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius); + entities = editSession.getEntities(region); } else { + entities = editSession.getEntities(); + } + visitors.add(new EntityVisitor(entities.iterator(), flags.createFunction())); } else { - Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING); + Platform platform = we.getPlatformManager().queryCapability(Capability.WORLD_EDITING); for (World world : platform.getWorlds()) { List entities = world.getEntities(); visitors.add(new EntityVisitor(entities.iterator(), flags.createFunction())); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java index ac1d0de52..aa18e499f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java @@ -44,27 +44,23 @@ public class AreaPickaxe implements BlockTool { } try (EditSession editSession = session.createEditSession(player)) { - editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); - - for (int x = ox - range; x <= ox + range; ++x) { - for (int z = oz - range; z <= oz + range; ++z) { - for (int y = oy + range; y >= oy - range; --y) { - if (initialType.equals(editSession.getLazyBlock(x, y, z))) { - continue; + try { + editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop); + for (int x = ox - range; x <= ox + range; ++x) { + for (int z = oz - range; z <= oz + range; ++z) { + for (int y = oy + range; y >= oy - range; --y) { + if (initialType.equals(editSession.getLazyBlock(x, y, z))) { + continue; + } + editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); + } } - editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); } - } catch (MaxChangedBlocksException e) { - player.printError("Max blocks change limit reached."); + editSession.flushQueue(); } finally { session.remember(editSession); } } - editSession.flushQueue(); - session.remember(editSession); - return true; } - - } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java index 541e9056f..594beb60b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.command.tool; +import com.boydti.fawe.object.mask.IdMask; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -26,7 +27,12 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; +import com.sk89q.worldedit.function.block.BlockReplace; +import com.sk89q.worldedit.function.mask.BlockTypeMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; @@ -71,8 +77,11 @@ public class FloodFillTool implements BlockTool { try (EditSession editSession = session.createEditSession(player)) { try { - TODO fillDirection (but replace) - recurse(editSession, origin, origin, range, initialType, new HashSet<>()); + Mask mask = initialType.toMask(editSession); + BlockReplace function = new BlockReplace(editSession, pattern); + RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range, editSession.getQueue()); + visitor.visit(origin); + Operations.completeLegacy(visitor); } catch (MaxChangedBlocksException e) { player.printError("Max blocks change limit reached."); } finally { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index b0cd5c41d..a00eae891 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -32,6 +32,8 @@ import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.tool.BlockTool; +import com.sk89q.worldedit.command.tool.BrushTool; +import com.sk89q.worldedit.command.tool.DoubleActionBlockTool; import com.sk89q.worldedit.command.tool.DoubleActionTraceTool; import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.command.tool.TraceTool; @@ -42,7 +44,10 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.session.request.Request; +import com.sk89q.worldedit.util.HandSide; +import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.eventbus.Subscribe; +import com.sk89q.worldedit.world.World; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,6 +57,8 @@ import java.util.EnumMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; + import static com.google.common.base.Preconditions.checkNotNull; /** @@ -131,9 +138,9 @@ public class PlatformManager { // Check whether this platform was chosen to be the preferred one // for any capability and be sure to remove it - Iterator> it = preferences.entrySet().iterator(); + Iterator> it = preferences.entrySet().iterator(); while (it.hasNext()) { - Entry entry = it.next(); + Map.Entry entry = it.next(); if (entry.getValue().equals(platform)) { entry.getKey().unload(this, entry.getValue()); it.remove(); @@ -409,11 +416,11 @@ public class PlatformManager { } } } - } finally { - Request.reset(); } } catch (Throwable e) { handleThrowable(e, actor); + } finally { + Request.reset(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index a366b42df..41aeab1cb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -37,6 +37,8 @@ import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BundledBlockData; @@ -44,9 +46,8 @@ import java.util.List; import javax.annotation.Nullable; public class AbstractDelegateExtent implements LightingExtent { - private transient final Extent extent; -// private MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); + private MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0); /** * Create a new instance. @@ -75,11 +76,6 @@ public class AbstractDelegateExtent implements LightingExtent { return extent.getBlockType(position); } - @Override - public BaseBlock getFullBlock(BlockVector3 position) { - return extent.getFullBlock(position); - } - public int getBlockLight(int x, int y, int z) { if (extent instanceof LightingExtent) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 778eb014e..6523ae829 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -27,6 +27,8 @@ import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; @@ -330,11 +332,11 @@ public interface Extent extends InputExtent, OutputExtent { * @param region a region * @return the results */ - default List> getBlockDistributionWithData(final Region region) { + default List> getBlockDistributionWithData(final Region region) { int[][] counter = new int[BlockTypes.size()][]; for (final BlockVector3 pt : region) { - BlockStateHolder blk = this.getBlock(pt); + BlockState blk = this.getBlock(pt); BlockType type = blk.getBlockType(); int[] stateCounter = counter[type.getInternalId()]; if (stateCounter == null) { @@ -342,7 +344,7 @@ public interface Extent extends InputExtent, OutputExtent { } stateCounter[blk.getInternalPropertiesId()]++; } - List> distribution = new ArrayList<>(); + List> distribution = new ArrayList<>(); for (int typeId = 0; typeId < counter.length; typeId++) { BlockType type = BlockTypes.get(typeId); int[] stateCount = counter[typeId]; @@ -350,7 +352,7 @@ public interface Extent extends InputExtent, OutputExtent { for (int propId = 0; propId < stateCount.length; propId++) { int count = stateCount[propId]; if (count != 0) { - BlockStateHolder state = type.withPropertyId(propId); + BlockState state = type.withPropertyId(propId); distribution.add(new Countable<>(state, count)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java index 8ce3dc1fa..3edcccb43 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/InputExtent.java @@ -25,6 +25,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockType; /** * Provides the current state of blocks, entities, and so on. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java index 845444ef8..1d4fe4d8d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java @@ -168,6 +168,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder public MultiStageReorder(Extent extent, boolean enabled) { super(extent); this.enabled = enabled; + for (PlacementPriority priority : PlacementPriority.values()) { stages.put(priority, new LocatedBlockList()); } @@ -229,7 +230,6 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder stages.get(PlacementPriority.CLEAR_LAST).add(location, replacement); break; } - } if (block.getBlockType().getMaterial().isAir()) { return !existing.equalsFuzzy(block); @@ -252,4 +252,4 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder return new OperationQueue(operations); } -} +} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index 4100ca98c..d20da2936 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -38,6 +38,13 @@ public class BlockMask extends AbstractExtentMask { private final long[][] bitSets; protected final static long[] ALL = new long[0]; + @Deprecated + public BlockMask(Extent extent, Collection blocks) { + super(extent); + MainUtil.warnDeprecated(BlockMaskBuilder.class); + this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits(); + } + @Deprecated public BlockMask(Extent extent, BaseBlock... blocks) { super(extent); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java index 7c3d86caf..fe2844bbc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMaskBuilder.java @@ -387,7 +387,7 @@ public class BlockMaskBuilder { return this; } - public BlockMaskBuilder addBlocks(Collection blocks) { + public BlockMaskBuilder addBlocks(Collection blocks) { for (BlockStateHolder block : blocks) add(block); return this; } @@ -397,7 +397,7 @@ public class BlockMaskBuilder { return this; } - public BlockMaskBuilder addBlocks(BlockStateHolder... blocks) { + public BlockMaskBuilder addBlocks(T... blocks) { for (BlockStateHolder block : blocks) add(block); return this; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java index a91354fe2..290240c2c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java @@ -19,6 +19,10 @@ package com.sk89q.worldedit.function.pattern; +import com.sk89q.minecraft.util.commands.Link; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.command.UtilityCommands; +import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java index 937a9d79a..b3b170ada 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java @@ -49,6 +49,7 @@ import com.sk89q.worldedit.util.command.parametric.BindingMatch; import com.sk89q.worldedit.util.command.parametric.ParameterException; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.Biomes; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -358,7 +359,7 @@ public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, String input = context.next(); if (input != null) { - if (MathMan.isInteger(input)) return new BiomeType(Integer.parseInt(input)); TODO FIXME + if (MathMan.isInteger(input)) return BiomeTypes.get(Integer.parseInt(input)); BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 77bd47f7e..17b4c87a0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -478,6 +478,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } else { x = cbx; z = cbz; + } } else { x = cbx; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java index d6494bc64..3c3316af9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java @@ -84,12 +84,12 @@ public abstract class ArbitraryBiomeShape { */ protected abstract BiomeType getBiome(int x, int z, BiomeType defaultBiomeType); - private BiomeType getBiomeCached(int x, int z, BiomeType BiomeType) { + private BiomeType getBiomeCached(int x, int z, BiomeType biomeType) { final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ; final BiomeType cacheEntry = cache[index]; if (cacheEntry == null) {// unknown, fetch material - final BiomeType material = getBiome(x, z, BiomeType); + final BiomeType material = getBiome(x, z, biomeType); if (material == null) { // outside cache[index] = BiomeTypes.THE_VOID; @@ -108,13 +108,13 @@ public abstract class ArbitraryBiomeShape { return cacheEntry; } - private boolean isInsideCached(int x, int z, BiomeType BiomeType) { + private boolean isInsideCached(int x, int z, BiomeType biomeType) { final int index = (z - cacheOffsetZ) + (x - cacheOffsetX) * cacheSizeZ; final BiomeType cacheEntry = cache[index]; if (cacheEntry == null) { // unknown block, meaning they must be outside the extent at this stage, but might still be inside the shape - return getBiomeCached(x, z, BiomeType) != null; + return getBiomeCached(x, z, biomeType) != null; } return cacheEntry != BiomeTypes.THE_VOID; @@ -124,11 +124,11 @@ public abstract class ArbitraryBiomeShape { * Generates the shape. * * @param editSession The EditSession to use. - * @param BiomeType The default biome type. + * @param biomeType The default biome type. * @param hollow Specifies whether to generate a hollow shape. * @return number of affected blocks. */ - public int generate(EditSession editSession, BiomeType BiomeType, boolean hollow) { + public int generate(EditSession editSession, BiomeType biomeType, boolean hollow) { int affected = 0; for (BlockVector2 position : getExtent()) { @@ -136,7 +136,7 @@ public abstract class ArbitraryBiomeShape { int z = position.getBlockZ(); if (!hollow) { - final BiomeType material = getBiome(x, z, BiomeType); + final BiomeType material = getBiome(x, z, biomeType); if (material != null && material != BiomeTypes.THE_VOID) { editSession.getWorld().setBiome(position, material); ++affected; @@ -145,26 +145,26 @@ public abstract class ArbitraryBiomeShape { continue; } - final BiomeType material = getBiomeCached(x, z, BiomeType); + final BiomeType material = getBiomeCached(x, z, biomeType); if (material == null) { continue; } boolean draw = false; do { - if (!isInsideCached(x + 1, z, BiomeType)) { + if (!isInsideCached(x + 1, z, biomeType)) { draw = true; break; } - if (!isInsideCached(x - 1, z, BiomeType)) { + if (!isInsideCached(x - 1, z, biomeType)) { draw = true; break; } - if (!isInsideCached(x, z + 1, BiomeType)) { + if (!isInsideCached(x, z + 1, biomeType)) { draw = true; break; } - if (!isInsideCached(x, z - 1, BiomeType)) { + if (!isInsideCached(x, z - 1, biomeType)) { draw = true; break; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java index bc9a5c571..f4e10fa76 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeTypes.java @@ -117,4 +117,8 @@ public class BiomeTypes { public static @Nullable BiomeType get(final String id) { return BiomeType.REGISTRY.get(id); } + + public static BiomeType get(int parseInt) { + // TODO + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index a0dc34982..ab5b18197 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -30,6 +30,7 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.function.pattern.FawePattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; @@ -50,7 +51,7 @@ import java.util.Set; * An immutable class that represents the state a block can be in. */ @SuppressWarnings("unchecked") -public class BlockState implements BlockStateHolder { +public class BlockState implements BlockStateHolder, FawePattern { private final BlockType blockType; private BaseBlock emptyBaseBlock; @@ -356,11 +357,6 @@ public class BlockState implements BlockStateHolder { return this; } - @Override - public BaseBlock toBaseBlock() { - return this.emptyBaseBlock; - } - @Override public int getInternalId() { return blockType.getInternalId(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index 903f2a7eb..31ff2c0c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -60,6 +60,7 @@ import java.util.stream.Stream; */ public final class BlockTypes { + @Nullable public static final BlockType __RESERVED__ = get("minecraft:__reserved__"); @Nullable public static final BlockType ACACIA_BUTTON = get("minecraft:acacia_button"); @Nullable public static final BlockType ACACIA_DOOR = get("minecraft:acacia_door"); @Nullable public static final BlockType ACACIA_FENCE = get("minecraft:acacia_fence");