From 590b7e23a9545024ed4b2a224ef40cd66b995a1a Mon Sep 17 00:00:00 2001 From: Kenzie Togami Date: Wed, 26 Dec 2018 16:39:10 -0800 Subject: [PATCH] Remove all raw usages of BSH, improve API generics --- .../adapter/v1_13_1/Spigot_v1_13_R2.java | 16 ++++- .../sk89q/worldedit/bukkit/BukkitAdapter.java | 4 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 18 ++++++ .../sk89q/worldedit/bukkit/BukkitWorld.java | 2 +- .../bukkit/adapter/BukkitImplAdapter.java | 46 +++++++++----- .../boydti/fawe/object/DataAnglePattern.java | 7 ++- .../object/pattern/AngleColorPattern.java | 8 +-- .../object/pattern/AverageColorPattern.java | 8 +-- .../fawe/object/pattern/BufferedPattern.java | 4 +- .../fawe/object/pattern/DataPattern.java | 10 +-- .../object/pattern/DesaturatePattern.java | 6 +- .../fawe/object/pattern/ExistingPattern.java | 6 +- .../object/pattern/ExpressionPattern.java | 7 ++- .../object/pattern/IdDataMaskPattern.java | 8 +-- .../boydti/fawe/object/pattern/IdPattern.java | 9 +-- .../object/pattern/Linear2DBlockPattern.java | 4 +- .../object/pattern/Linear3DBlockPattern.java | 4 +- .../object/pattern/LinearBlockPattern.java | 4 +- .../fawe/object/pattern/MaskedPattern.java | 6 +- .../fawe/object/pattern/NoXPattern.java | 4 +- .../fawe/object/pattern/NoYPattern.java | 4 +- .../fawe/object/pattern/NoZPattern.java | 4 +- .../fawe/object/pattern/OffsetPattern.java | 4 +- .../fawe/object/pattern/PatternExtent.java | 2 +- .../fawe/object/pattern/PropertyPattern.java | 10 +-- .../object/pattern/RandomOffsetPattern.java | 4 +- .../fawe/object/pattern/RelativePattern.java | 4 +- .../fawe/object/pattern/SaturatePattern.java | 6 +- .../fawe/object/pattern/ShadePattern.java | 6 +- .../pattern/SolidRandomOffsetPattern.java | 6 +- .../pattern/SurfaceRandomOffsetPattern.java | 4 +- .../java/com/sk89q/worldedit/EditSession.java | 22 +++---- .../com/sk89q/worldedit/blocks/Blocks.java | 4 +- .../worldedit/command/NavigationCommands.java | 1 - .../worldedit/command/RegionCommands.java | 1 + .../worldedit/command/UtilityCommands.java | 1 + .../worldedit/command/tool/BlockReplacer.java | 2 +- .../command/tool/LongRangeBuildTool.java | 7 +-- .../worldedit/command/tool/QueryTool.java | 4 +- .../command/tool/brush/GravityBrush.java | 24 ------- .../com/sk89q/worldedit/entity/Player.java | 2 +- .../extension/factory/BlockFactory.java | 9 +-- .../factory/parser/DefaultBlockParser.java | 14 ++--- .../parser/pattern/RandomPatternParser.java | 4 +- .../platform/AbstractPlayerActor.java | 2 +- .../extension/platform/PlayerProxy.java | 2 +- .../worldedit/extent/ChangeSetExtent.java | 2 +- .../sk89q/worldedit/extent/MaskingExtent.java | 2 +- .../sk89q/worldedit/extent/NullExtent.java | 2 +- .../extent/buffer/ForgetfulExtentBuffer.java | 13 ++-- .../extent/clipboard/BlockArrayClipboard.java | 22 +------ .../legacycompat/NBTCompatibilityHandler.java | 4 +- .../SignCompatibilityHandler.java | 5 +- .../extent/inventory/BlockBagExtent.java | 4 +- .../extent/reorder/ChunkBatchingExtent.java | 2 +- .../extent/reorder/MultiStageReorder.java | 5 +- .../transform/BlockTransformExtent.java | 2 +- .../extent/validation/BlockChangeLimiter.java | 2 +- .../validation/DataValidatorExtent.java | 2 +- .../extent/world/BlockQuirkExtent.java | 2 +- .../extent/world/ChunkLoadingExtent.java | 2 +- .../extent/world/FastModeExtent.java | 4 +- .../extent/world/SurvivalModeExtent.java | 2 +- .../block/BlockDistributionCounter.java | 21 +++---- .../function/generator/FloraGenerator.java | 4 +- .../function/generator/ForestGenerator.java | 4 +- .../generator/GardenPatchGenerator.java | 2 +- .../worldedit/function/mask/BlockMask.java | 5 +- .../function/pattern/BlockPattern.java | 19 +++--- .../function/pattern/ClipboardPattern.java | 15 +---- .../function/pattern/FawePattern.java | 3 +- .../worldedit/function/pattern/Pattern.java | 3 +- .../function/pattern/RandomPattern.java | 20 +----- .../pattern/RepeatingExtentPattern.java | 8 +-- .../worldedit/history/change/BlockChange.java | 15 ++--- .../internal/command/WorldEditBinding.java | 5 +- .../internal/registry/AbstractFactory.java | 1 - .../worldedit/regions/RegionIntersection.java | 2 +- .../selector/EllipsoidRegionSelector.java | 2 +- .../regions/shape/ArbitraryShape.java | 8 +-- .../worldedit/regions/shape/RegionShape.java | 4 +- .../registry/state/AbstractProperty.java | 2 +- .../scripting/CraftScriptContext.java | 7 ++- .../sk89q/worldedit/util/LocatedBlock.java | 8 +-- .../sk89q/worldedit/util/TreeGenerator.java | 4 +- .../util/collection/LocatedBlockList.java | 4 +- .../sk89q/worldedit/world/AbstractWorld.java | 3 +- .../com/sk89q/worldedit/world/NullWorld.java | 2 +- .../sk89q/worldedit/world/SimpleWorld.java | 4 +- .../java/com/sk89q/worldedit/world/World.java | 4 +- .../worldedit/world/block/BaseBlock.java | 2 +- .../worldedit/world/block/BlockCategory.java | 2 +- .../worldedit/world/block/BlockState.java | 63 ++++++++++++++----- .../world/block/BlockStateHolder.java | 5 +- .../worldedit/world/block/BlockType.java | 4 +- .../worldedit/world/chunk/AnvilChunk.java | 10 +-- .../worldedit/world/chunk/AnvilChunk13.java | 6 +- .../sk89q/worldedit/world/chunk/Chunk.java | 6 +- .../sk89q/worldedit/world/chunk/OldChunk.java | 16 ++--- .../world/registry/BlockRegistry.java | 1 - .../world/registry/LegacyMapper.java | 2 +- .../sk89q/worldedit/forge/ForgePlayer.java | 4 ++ .../com/sk89q/worldedit/forge/ForgeWorld.java | 3 +- .../sk89q/worldedit/sponge/SpongePlayer.java | 3 +- .../sk89q/worldedit/sponge/SpongeWorld.java | 2 +- 105 files changed, 372 insertions(+), 347 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java index 902ee8020..4469dc192 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java @@ -29,7 +29,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.CachedBukkitAdapter; import com.sk89q.worldedit.entity.BaseEntity; -import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.*; @@ -53,6 +52,7 @@ import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import javax.annotation.Nullable; @@ -357,7 +357,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @SuppressWarnings("unchecked") @Override - public Map getProperties(BlockType blockType) { + public Map> getProperties(BlockType blockType) { Block block; try { block = IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource())); @@ -369,7 +369,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit logger.warning("Failed to find properties for " + blockType.getId()); return Collections.emptyMap(); } - Map properties = Maps.newLinkedHashMap(); + Map> properties = Maps.newLinkedHashMap(); BlockStateList blockStateList = block.getStates(); for (IBlockState state : blockStateList.d()) { Property property; @@ -552,6 +552,16 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit @Override public void notifyAndLightBlock(Location position, BlockState previousType) { + this.setBlock(position.getChunk(), position.getBlockX(), position.getBlockY(), position.getBlockZ(), previousType, true); + } + + @Override + public boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight) { + return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight); + } + + @Override + public void sendFakeOP(Player player) { // TODO Auto-generated method stub } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index 87d84d8eb..e68587283 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -146,8 +146,8 @@ public enum BukkitAdapter { return getAdapter().adapt(material); } - public static BlockData adapt(BlockStateHolder block) { - return getAdapter().adapt(block); + public static > BlockData adapt(B block) { + return getAdapter().adapt(block); } public static BlockData getBlockData(int combinedId) { 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 1d86a4fa8..9502dc61f 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 @@ -290,4 +290,22 @@ public class BukkitPlayer extends AbstractPlayerActor { } + @Override + public > void sendFakeBlock(BlockVector3 pos, B block) { + Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()); + if (block == null) { + player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); + } else { + player.sendBlockChange(loc, BukkitAdapter.adapt(block)); + if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) { + BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); + if (adapter != null) { + adapter.sendFakeNBT(player, pos, ((BaseBlock) block).getNbtData()); + if (block.getBlockType() == BlockTypes.STRUCTURE_BLOCK) { + adapter.sendFakeOP(player); + } + } + } + } + } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index dc8b35d85..ad540d116 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -452,7 +452,7 @@ public class BukkitWorld extends AbstractWorld { } @Override - public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { try { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java index 0e411fec8..7090f8234 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java @@ -22,15 +22,10 @@ package com.sk89q.worldedit.bukkit.adapter; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.entity.BaseEntity; -import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.registry.BlockMaterial; @@ -38,6 +33,7 @@ import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.block.Biome; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import java.util.Map; @@ -76,9 +72,18 @@ public interface BukkitImplAdapter extends IBukkitAdapter { */ BlockState getBlock(Location location); - boolean setBlock(Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update); + boolean setBlock(Chunk chunk, int x, int y, int z, BlockStateHolder state, boolean update); boolean isChunkInUse(Chunk chunk); + /** + * Set the block at the given location. + * + * @param location the location + * @param state the block + * @param notifyAndLight notify and light if set + * @return true if a block was likely changed + */ + boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight); /** * Notifies the simulation that the block at the given location has @@ -114,20 +119,12 @@ public interface BukkitImplAdapter extends IBukkitAdapter { * @param blockType The block type * @return The properties map */ - Map getProperties(BlockType blockType); + Map> getProperties(BlockType blockType); default BlockMaterial getMaterial(BlockType blockType) { return null; } - /** - * Send the given NBT data to the player. - * - * @param player The player - * @param pos The position - * @param nbtData The NBT Data - */ - void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData); - + default BlockMaterial getMaterial(BlockState blockState) { return null; } @@ -139,4 +136,21 @@ public interface BukkitImplAdapter extends IBukkitAdapter { default T fromNative(Tag foreign) { return null; } + + /** + * Send the given NBT data to the player. + * + * @param player The player + * @param pos The position + * @param nbtData The NBT Data + */ + void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData); + + /** + * Make the client think it has operator status. + * This does not give them any operator capabilities. + * + * @param player The player + */ + void sendFakeOP(Player player); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java index d47b77754..323e918e3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/DataAnglePattern.java @@ -3,6 +3,7 @@ package com.boydti.fawe.object; import com.boydti.fawe.FaweCache; import com.boydti.fawe.object.extent.ExtentHeightCacher; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -40,12 +41,12 @@ public class DataAnglePattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { BlockStateHolder block = extent.getBlock(position); int slope = getSlope(block, position); - if (slope == -1) return block; + if (slope == -1) return block.toBaseBlock(); int data = (Math.min(slope, 255)) >> 4; - return block.withPropertyId(data); + return block.withPropertyId(data).toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java index dde68793f..f11fc4896 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AngleColorPattern.java @@ -5,7 +5,7 @@ import com.boydti.fawe.FaweCache; import com.boydti.fawe.object.DataAnglePattern; import com.boydti.fawe.util.TextureHolder; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; @@ -32,14 +32,14 @@ public class AngleColorPattern extends DataAnglePattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - BlockStateHolder block = extent.getBlock(position); + public BaseBlock apply(BlockVector3 position) { + BaseBlock block = extent.getFullBlock(position); int slope = getSlope(block, position); if (slope == -1) return block; int color = util.getTextureUtil().getColor(block.getBlockType()); if (color == 0) return block; int newColor = getColor(color, slope); - return util.getTextureUtil().getNearestBlock(newColor).getDefaultState(); + return util.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java index 8bff98adf..bb8395a8c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/AverageColorPattern.java @@ -4,7 +4,7 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureUtil; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; @@ -26,12 +26,12 @@ public class AverageColorPattern extends AbstractExtentPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - BlockStateHolder block = getExtent().getBlock(position); + public BaseBlock apply(BlockVector3 position) { + BaseBlock block = getExtent().getFullBlock(position); TextureUtil util = holder.getTextureUtil(); int currentColor = util.getColor(block.getBlockType()); int newColor = util.averageColor(currentColor, color); - return util.getNearestBlock(newColor).getDefaultState(); + return util.getNearestBlock(newColor).getDefaultState().toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java index 0082e11cf..a9b9a5148 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/BufferedPattern.java @@ -5,7 +5,7 @@ import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.util.FaweTimer; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -33,7 +33,7 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { return pattern.apply(position); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java index 5532b62ce..30c7d85f4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DataPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.FaweCache; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; @@ -22,9 +22,9 @@ public class DataPattern extends AbstractExtentPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - BlockStateHolder oldBlock = getExtent().getBlock(position); - BlockStateHolder newBlock = pattern.apply(position); - return oldBlock.withPropertyId(newBlock.getInternalPropertiesId()); + public BaseBlock apply(BlockVector3 position) { + BaseBlock oldBlock = getExtent().getFullBlock(position); + BaseBlock newBlock = pattern.apply(position); + return oldBlock.withPropertyId(newBlock.getInternalPropertiesId()).toBaseBlock(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java index 391851947..1647b3662 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/DesaturatePattern.java @@ -4,7 +4,7 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureUtil; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -26,7 +26,7 @@ public class DesaturatePattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { BlockType block = extent.getBlockType(position); TextureUtil util = holder.getTextureUtil(); int color = util.getColor(block); @@ -39,7 +39,7 @@ public class DesaturatePattern extends AbstractPattern { int green = (int) (g + value * (l - g)); int blue = (int) (b + value * (l - b)); int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0); - return util.getNearestBlock(newColor).getDefaultState(); + return util.getNearestBlock(newColor).getDefaultState().toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java index 12ee5aea6..e345a1705 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExistingPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; @@ -14,8 +14,8 @@ public class ExistingPattern extends AbstractExtentPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - return getExtent().getBlock(position); + public BaseBlock apply(BlockVector3 position) { + return getExtent().getFullBlock(position); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java index 3df96a01b..c023f4ff3 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ExpressionPattern.java @@ -1,6 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.internal.expression.Expression; @@ -49,16 +50,16 @@ public class ExpressionPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 vector) { + public BaseBlock apply(BlockVector3 vector) { try { if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) { ((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3()); } double combined = expression.evaluate(vector.getX(), vector.getY(), vector.getZ()); - return BlockState.getFromInternalId((int) combined); + return BlockState.getFromInternalId((int) combined).toBaseBlock(); } catch (EvaluationException e) { e.printStackTrace(); - return EditSession.nullBlock; + return EditSession.nullBlock.toBaseBlock(); } catch (Throwable e) { e.printStackTrace(); throw e; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdDataMaskPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdDataMaskPattern.java index 9ccbdad74..2ad33fe3a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdDataMaskPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdDataMaskPattern.java @@ -21,11 +21,11 @@ public class IdDataMaskPattern extends AbstractExtentPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - BlockStateHolder oldBlock = getExtent().getBlock(position); - BlockStateHolder newBlock = pattern.apply(position); + public BaseBlock apply(BlockVector3 position) { + BaseBlock oldBlock = getExtent().getFullBlock(position); + BaseBlock newBlock = pattern.apply(position); int oldData = oldBlock.getInternalPropertiesId(); int newData = newBlock.getInternalPropertiesId() + oldData - (oldData & bitMask); - return newBlock.withPropertyId(newData); + return newBlock.withPropertyId(newData).toBaseBlock(); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java index 29d4d0f1c..9b05385d9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/IdPattern.java @@ -3,6 +3,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import static com.google.common.base.Preconditions.checkNotNull; @@ -17,9 +18,9 @@ public class IdPattern extends AbstractExtentPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - BlockStateHolder oldBlock = getExtent().getBlock(position); - BlockStateHolder newBlock = pattern.apply(position); - return newBlock.withPropertyId(oldBlock.getInternalPropertiesId()); + public BaseBlock apply(BlockVector3 position) { + BaseBlock oldBlock = getExtent().getFullBlock(position); + BaseBlock newBlock = pattern.apply(position); + return newBlock.withPropertyId(oldBlock.getInternalPropertiesId()).toBaseBlock(); } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java index fb1577fac..2e2826525 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear2DBlockPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -18,7 +18,7 @@ public class Linear2DBlockPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { int index = (position.getBlockX() + position.getBlockZ()) % patternsArray.length; if (index < 0) { index += patternsArray.length; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java index 72c8db532..c52c349e9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/Linear3DBlockPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -18,7 +18,7 @@ public class Linear3DBlockPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { int index = (position.getBlockX() + position.getBlockY() + position.getBlockZ()) % patternsArray.length; if (index < 0) { index += patternsArray.length; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java index 04ca3d648..2614dde7a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/LinearBlockPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -19,7 +19,7 @@ public class LinearBlockPattern extends AbstractPattern implements ResettablePat } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { if (index == patternsArray.length) { index = 0; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java index 5f273884c..8f9f72550 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/MaskedPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.Mask; @@ -24,10 +24,10 @@ public class MaskedPattern extends AbstractPattern { @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { patternExtent.setTarget(position); if (mask.test(position)) { - return patternExtent.getAndResetTarget(); + return patternExtent.getAndResetTarget().toBaseBlock(); } return secondaryPattern.apply(position); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java index b94035b41..a6ada3742 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoXPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -22,7 +22,7 @@ public class NoXPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 pos) { + public BaseBlock apply(BlockVector3 pos) { // mutable.mutY((pos.getY())); // mutable.mutZ((pos.getZ())); // return pattern.apply(mutable.toBlockVector3()); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java index 9a8ada077..fd81a3c07 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoYPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -23,7 +23,7 @@ public class NoYPattern extends AbstractPattern { // private transient MutableBlockVector mutable = new MutableBlockVector(); @Override - public BlockStateHolder apply(BlockVector3 pos) { + public BaseBlock apply(BlockVector3 pos) { // mutable.mutX((pos.getX())); // mutable.mutZ((pos.getZ())); return pattern.apply(pos); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java index 56d54ecd8..11b5f3486 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/NoZPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -23,7 +23,7 @@ public class NoZPattern extends AbstractPattern { // private transient MutableBlockVector mutable = new MutableBlockVector(); @Override - public BlockStateHolder apply(BlockVector3 pos) { + public BaseBlock apply(BlockVector3 pos) { // mutable.mutX((pos.getX())); // mutable.mutY((pos.getY())); return pattern.apply(pos); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java index c33739cb2..3802922f9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/OffsetPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -26,7 +26,7 @@ public class OffsetPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { // mutable.mutX((position.getX() + dx)); // mutable.mutY((position.getY() + dy)); // mutable.mutZ((position.getZ() + dz)); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java index 62d31ad5b..90fe4bde8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PatternExtent.java @@ -123,7 +123,7 @@ public class PatternExtent extends AbstractPattern implements Extent { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { return pattern.apply(position); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java index 54ee2f950..def48ef7c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/PropertyPattern.java @@ -192,25 +192,25 @@ public class PropertyPattern extends AbstractExtentPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - BlockState block = getExtent().getBlock(position); + public BaseBlock apply(BlockVector3 position) { + BaseBlock block = getExtent().getFullBlock(position); return apply(block, block); } - public BlockState apply(BlockState block, BlockState orDefault) { + public BaseBlock apply(BaseBlock block, BaseBlock orDefault) { int ordinal = block.getOrdinal(); int newOrdinal = transformed[ordinal]; if (newOrdinal != ordinal) { CompoundTag nbt = block.getNbtData(); BlockState newState = BlockState.getFromOrdinal(newOrdinal); - return nbt != null ? new BaseBlock(newState, nbt).toImmutableState() : newState; + return nbt != null ? new BaseBlock(newState, nbt) : newState.toBaseBlock(); } return orDefault; } @Override public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException { - BlockState block = getExtent().getBlock(get); + BaseBlock block = getExtent().getFullBlock(get); block = apply(block, null); if (block != null) { return extent.setBlock(set, block); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java index 0f64974b4..258c424e0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomOffsetPattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -34,7 +34,7 @@ public class RandomOffsetPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java index 17f4d6233..4020ecb17 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RelativePattern.java @@ -1,7 +1,7 @@ package com.boydti.fawe.object.pattern; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -23,7 +23,7 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter } @Override - public BlockStateHolder apply(BlockVector3 pos) { + public BaseBlock apply(BlockVector3 pos) { if (origin == null) { origin = pos; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java index 9fb6bc651..5499b1507 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SaturatePattern.java @@ -4,7 +4,7 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureUtil; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -28,12 +28,12 @@ public class SaturatePattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { BlockType block = extent.getBlockType(position); TextureUtil util = holder.getTextureUtil(); int currentColor = util.getColor(block); int newColor = util.multiplyColor(currentColor, color); - return util.getNearestBlock(newColor).getDefaultState(); + return util.getNearestBlock(newColor).getDefaultState().toBaseBlock(); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java index 4f16eb1cd..5c8a910f2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/ShadePattern.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.Fawe; import com.boydti.fawe.util.TextureUtil; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -28,9 +28,9 @@ public class ShadePattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { BlockType block = extent.getBlockType(position); - return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState(); + return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock(); } private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java index 395b22ce9..d77181e69 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SolidRandomOffsetPattern.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.FaweCache; import com.sk89q.worldedit.WorldEditException; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.mask.SolidBlockMask; @@ -43,11 +43,11 @@ public class SolidRandomOffsetPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); - BlockStateHolder block = pattern.apply(mutable.toBlockVector3()); + BaseBlock block = pattern.apply(mutable.toBlockVector3()); if (solid[block.getInternalBlockTypeId()]) { return block; } else { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java index 2b9d16330..fe98d4472 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/SurfaceRandomOffsetPattern.java @@ -2,7 +2,7 @@ package com.boydti.fawe.object.pattern; import com.boydti.fawe.FaweCache; import com.boydti.fawe.object.PseudoRandom; - +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.Pattern; @@ -38,7 +38,7 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { return pattern.apply(travel(position)); } 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 7163ff04f..85e4678cf 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1027,7 +1027,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return whether the block changed * @throws WorldEditException thrown on a set error */ - public boolean setBlock(BlockVector3 position, BlockStateHolder block, Stage stage) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, B block, Stage stage) throws WorldEditException { this.changes++; switch (stage) { case BEFORE_HISTORY: @@ -1041,7 +1041,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, throw new RuntimeException("New enum entry added that is unhandled here"); } - public boolean rawSetBlock(BlockVector3 position, BlockStateHolder block) { + public > boolean rawSetBlock(BlockVector3 position, B block) { try { return this.bypassAll.setBlock(position, block); } catch (final WorldEditException e) { @@ -1056,7 +1056,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @param block the block * @return whether the block changed */ - public boolean smartSetBlock(BlockVector3 position, BlockStateHolder block) { + public > boolean smartSetBlock(BlockVector3 position, B block) { try { return setBlock(position, block, Stage.BEFORE_REORDER); } catch (WorldEditException e) { @@ -1065,7 +1065,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } @Override - public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException { + public > boolean setBlock(BlockVector3 position, B block) throws MaxChangedBlocksException { this.changes++; try { return this.extent.setBlock(position, block); @@ -1611,7 +1611,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @throws MaxChangedBlocksException thrown if too many blocks are changed */ @SuppressWarnings("deprecation") - public int setBlocks(final Region region, final BlockStateHolder block) { + public > int setBlocks(final Region region, final B block) { checkNotNull(region); checkNotNull(block); if (canBypassAll(region, false, true) && !block.hasNbtData()) { @@ -1670,7 +1670,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int replaceBlocks(Region region, Set filter, BlockStateHolder replacement) throws MaxChangedBlocksException { + public > int replaceBlocks(Region region, Set filter, B replacement) throws MaxChangedBlocksException { return replaceBlocks(region, filter, new BlockPattern(replacement)); } @@ -1748,7 +1748,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @throws MaxChangedBlocksException thrown if too many blocks are changed */ @SuppressWarnings("deprecation") - public int makeCuboidFaces(final Region region, final BlockStateHolder block) { + public > int makeCuboidFaces(final Region region, final B block) { return this.makeCuboidFaces(region, (Pattern) (block)); } @@ -1803,7 +1803,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @throws MaxChangedBlocksException thrown if too many blocks are changed */ @SuppressWarnings("deprecation") - public int makeCuboidWalls(final Region region, final BlockStateHolder block) { + public > int makeCuboidWalls(final Region region, final B block) { return this.makeCuboidWalls(region, (Pattern) (block)); } @@ -1865,7 +1865,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int overlayCuboidBlocks(Region region, BlockStateHolder block) throws MaxChangedBlocksException { + public > int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException { checkNotNull(block); return this.overlayCuboidBlocks(region, (Pattern) (block)); } @@ -2947,7 +2947,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, final ArbitraryShape shape = new ArbitraryShape(region) { @Override - public BlockStateHolder getMaterial(final int x, final int y, final int z, final BlockStateHolder defaultMaterial) { + public BaseBlock getMaterial(final int x, final int y, final int z, final BaseBlock defaultMaterial) { //TODO Optimize - avoid vector creation (math) // final Vector3 current = mutablev.setComponents(x, y, z); // protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) { @@ -2961,7 +2961,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, return null; } - return BlockTypes.get((int) typeVariable.getValue()).withPropertyId((int) dataVariable.getValue()); + return BlockTypes.get((int) typeVariable.getValue()).withPropertyId((int) dataVariable.getValue()).toBaseBlock(); } catch (final Exception e) { Fawe.debug("Failed to create shape: " + e); return null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java index 939fb7e7e..83ebddc85 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java @@ -180,9 +180,9 @@ public final class Blocks { * @param o the block * @return true if the collection contains the given block */ - public static boolean containsFuzzy(Collection collection, BlockStateHolder o) { + public static > boolean containsFuzzy(Collection> collection, B o) { // Allow masked data in the searchBlocks to match various types - for (BlockStateHolder b : collection) { + for (BlockStateHolder b : collection) { if (b.equalsFuzzy(o)) { return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java index c040a4b12..4e2a225d7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java @@ -45,7 +45,6 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION; @Command(aliases = {}, desc = "Commands for moving the player around: [More Info](https://goo.gl/uQTUiT)") public class NavigationCommands { - @SuppressWarnings("unused") private final WorldEdit worldEdit; /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 94afe9eb7..e7b8e2fd6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -74,6 +74,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.Biomes; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.registry.BiomeRegistry; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; 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 14b0cb68a..a3a76808a 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 @@ -88,6 +88,7 @@ import com.sk89q.worldedit.util.command.binding.Text; import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.ParameterData; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; import javax.imageio.ImageIO; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java index 6fca7840b..986eb16bd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java @@ -36,7 +36,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockState; /** * A mode that replaces one block. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index dbd37b095..3a60dec8a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -30,8 +30,7 @@ import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; /** * A tool that can place (or remove) blocks at a distance. @@ -60,7 +59,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo try { // eS.disableBuffering(); BlockVector3 blockPoint = pos.toVector().toBlockPoint(); - BlockStateHolder applied = secondary.apply(blockPoint); + BaseBlock applied = secondary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(blockPoint, secondary); } else { @@ -82,7 +81,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo try { // eS.disableBuffering(); BlockVector3 blockPoint = pos.toVector().toBlockPoint(); - BlockStateHolder applied = primary.apply(blockPoint); + BaseBlock applied = primary.apply(blockPoint); if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(blockPoint, primary); } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java index 59e21bfde..ef71569f4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; /** * Looks up information about a block. @@ -46,7 +46,7 @@ public class QueryTool implements BlockTool { World world = (World) clicked.getExtent(); EditSession editSession = session.createEditSession(player); BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); - BlockStateHolder block = editSession.getFullBlock(blockPoint); + BaseBlock block = editSession.getFullBlock(blockPoint); player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e" + block.getBlockType().getName() + "\u00A77" + " (" diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java index b394d9ba0..2c67b3fdc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.command.tool.brush; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.pattern.Pattern; @@ -47,23 +46,11 @@ public class GravityBrush implements Brush { int endY = position.getBlockY() + size; int startPerformY = Math.max(0, position.getBlockY() - size); int startCheckY = fullHeight ? 0 : startPerformY; -// Vector mutablePos = new Vector(0, 0, 0); for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) { for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) { int freeSpot = startCheckY; for (int y = startCheckY; y <= endY; y++) { BlockStateHolder block = editSession.getLazyBlock(x, y, z); -//======= -// public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { -// final double startY = fullHeight ? editSession.getWorld().getMaxY() : position.getBlockY() + size; -// for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) { -// for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) { -// double y = startY; -// final List blockTypes = new ArrayList<>(); -// for (; y > position.getBlockY() - size; --y) { -// final BlockVector3 pt = new BlockVector3(x, y, z); -// final BlockStateHolder block = editSession.getBlock(pt); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner if (!block.getBlockType().getMaterial().isAir()) { if (y != freeSpot) { editSession.setBlock(x, y, z, EditSession.nullBlock); @@ -72,17 +59,6 @@ public class GravityBrush implements Brush { freeSpot = y + 1; } } -//<<<<<<< HEAD -//======= -// BlockVector3 pt = new BlockVector3(x, y, z); -// Collections.reverse(blockTypes); -// for (int i = 0; i < blockTypes.size();) { -// if (editSession.getBlock(pt).getBlockType().getMaterial().isAir()) { -// editSession.setBlock(pt, blockTypes.get(i++)); -// } -// pt = pt.add(0, 1, 0); -// } -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index 846924824..2f3235d44 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -276,5 +276,5 @@ public interface Player extends Entity, Actor { * @param pos The position of the block * @param block The block to send, null to reset */ - void sendFakeBlock(BlockVector3 pos, @Nullable BlockStateHolder block); + > void sendFakeBlock(BlockVector3 pos, @Nullable B block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java index 9b97a175e..8ee07c223 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java @@ -23,10 +23,11 @@ import com.sk89q.util.StringUtil; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.extension.factory.parser.DefaultBlockParser; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.internal.registry.AbstractFactory; +import com.sk89q.worldedit.world.block.BaseBlock; + import java.util.HashSet; import java.util.Set; @@ -37,7 +38,7 @@ import java.util.Set; *

Instances of this class can be taken from * {@link WorldEdit#getBlockFactory()}.

*/ -public class BlockFactory extends AbstractFactory { +public class BlockFactory extends AbstractFactory { /** * Create a new instance. @@ -58,8 +59,8 @@ public class BlockFactory extends AbstractFactory { * @return a set of blocks * @throws InputParseException thrown in error with the input */ - public Set parseFromListInput(String input, ParserContext context) throws InputParseException { - Set blocks = new HashSet<>(); + public Set parseFromListInput(String input, ParserContext context) throws InputParseException { + Set blocks = new HashSet<>(); String[] splits = input.split(","); for (String token : StringUtil.parseListInQuotes(splits, ',', '[', ']')) { blocks.add(parseFromInput(token, context)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 3187d095a..79310576e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -34,7 +34,6 @@ import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.blocks.MobSpawnerBlock; import com.sk89q.worldedit.blocks.SignBlock; import com.sk89q.worldedit.blocks.SkullBlock; @@ -53,8 +52,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.world.World; +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.block.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; @@ -69,7 +68,7 @@ import java.util.stream.Stream; /** * Parses block input strings. */ -public class DefaultBlockParser extends InputParser { +public class DefaultBlockParser extends InputParser { public DefaultBlockParser(WorldEdit worldEdit) { super(worldEdit); @@ -89,13 +88,14 @@ public class DefaultBlockParser extends InputParser { } } - public BlockStateHolder parseFromInput(String input, ParserContext context) + @Override + public BaseBlock parseFromInput(String input, ParserContext context) throws InputParseException { String originalInput = input; input = input.replace(";", "|"); Exception suppressed = null; try { - BlockStateHolder modified = parseLogic(input, context); + BaseBlock modified = parseLogic(input, context); if (modified != null) { return modified; } @@ -164,7 +164,7 @@ public class DefaultBlockParser extends InputParser { } } - private BlockStateHolder parseLogic(String input, ParserContext context) throws InputParseException { + private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException { String[] blockAndExtraData = input.trim().split("\\|", 2); blockAndExtraData[0] = woolMapper(blockAndExtraData[0]); @@ -320,7 +320,7 @@ public class DefaultBlockParser extends InputParser { return new SkullBlock(state, type.replace(" ", "_")); // valid MC usernames } else { - return state; + return state.toBaseBlock(); } } } \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java index 3afc9e81d..f9a05c9e3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.internal.registry.InputParser; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; public class RandomPatternParser extends InputParser { @@ -43,7 +43,7 @@ public class RandomPatternParser extends InputParser { String[] splits = input.split(","); for (String token : StringUtil.parseListInQuotes(splits, ',', '[', ']')) { - BlockStateHolder block; + BaseBlock block; double chance; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index d272818c7..64d44a334 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -532,7 +532,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { } @Override - public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { + public > void sendFakeBlock(BlockVector3 pos, B block) { } } 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 8d3b5434c..448e655b4 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 @@ -187,7 +187,7 @@ public class PlayerProxy extends AbstractPlayerActor { } @Override - public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { + public > void sendFakeBlock(BlockVector3 pos, B block) { basePlayer.sendFakeBlock(pos, block); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java index 3bca28dab..a41b0cf8c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java @@ -64,7 +64,7 @@ public class ChangeSetExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { BlockStateHolder previous = getBlock(location); changeSet.add(new BlockChange(location, previous, block)); return super.setBlock(location, block); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 4a0eb7186..2944a0150 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -73,7 +73,7 @@ public class MaskingExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { return mask.test(location) && super.setBlock(location, block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java index c80664b1e..cb9f1ea28 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java @@ -105,7 +105,7 @@ public class NullExtent implements Extent { } @Override - public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, B block) throws WorldEditException { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java index e3451655a..30f1b7b85 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java @@ -31,6 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionOperationException; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; @@ -47,7 +48,7 @@ import java.util.Map; */ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern { - private final Map buffer = new LinkedHashMap<>(); + private final Map buffer = new LinkedHashMap<>(); private final Mask mask; private BlockVector3 min = null; private BlockVector3 max = null; @@ -76,7 +77,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { // Update minimum if (min == null) { min = location; @@ -93,7 +94,7 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat BlockVector3 blockVector = location; if (mask.test(blockVector)) { - buffer.put(blockVector, block); + buffer.put(blockVector, block.toBaseBlock()); return true; } else { return getExtent().setBlock(location, block); @@ -101,12 +102,12 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat } @Override - public BlockStateHolder apply(BlockVector3 pos) { - BlockStateHolder block = buffer.get(pos); + public BaseBlock apply(BlockVector3 pos) { + BaseBlock block = buffer.get(pos); if (block != null) { return block; } else { - return BlockTypes.AIR.getDefaultState(); + return BlockTypes.AIR.getDefaultState().toBaseBlock(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 6613ef820..5037d5194 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -135,6 +135,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public void close() { IMP.close(); + } @Override @@ -197,18 +198,10 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable @Override public BlockState getBlock(BlockVector3 position) { if (region.contains(position)) { -//<<<<<<< HEAD int x = position.getBlockX() - mx; int y = position.getBlockY() - my; int z = position.getBlockZ() - mz; return IMP.getBlock(x, y, z); -//======= -// BlockVector3 v = position.subtract(region.getMinimumPoint()); -// BlockStateHolder block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()]; -// if (block != null) { -// return block.toImmutableState(); -// } -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } return EditSession.nullBlock; } @@ -239,21 +232,12 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (region.contains(location)) { final int x = location.getBlockX(); final int y = location.getBlockY(); final int z = location.getBlockZ(); return setBlock(x, y, z, block); -//======= -// public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { -// if (region.contains(position)) { -// BlockVector3 v = position.subtract(region.getMinimumPoint()); -// blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()] = block; -// return true; -// } else { -// return false; -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } return false; } @@ -266,7 +250,7 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable } @Override - public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { x -= mx; y -= my; z -= mz; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java index b6a814057..ede6aaaac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java @@ -26,6 +26,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.Map; public interface NBTCompatibilityHandler { - boolean isAffectedBlock(BlockStateHolder block); - void updateNBT(BlockStateHolder block, Map values); + > boolean isAffectedBlock(B block); + > void updateNBT(B block, Map values); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java index 24ffc8748..af78a4d36 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java @@ -33,13 +33,14 @@ import com.sk89q.worldedit.world.block.BlockTypes; import java.util.Map; public class SignCompatibilityHandler implements NBTCompatibilityHandler { + @Override - public boolean isAffectedBlock(BlockStateHolder block) { + public > boolean isAffectedBlock(B block) { return block.getBlockType() == BlockTypes.SIGN || block.getBlockType() == BlockTypes.WALL_SIGN; } @Override - public void updateNBT(BlockStateHolder block, Map values) { + public > void updateNBT(B block, Map values) { for (int i = 0; i < 4; ++i) { String key = "Text" + (i + 1); Tag value = values.get(key); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index 945f22d9d..04ec91136 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -86,12 +86,12 @@ public class BlockBagExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 pos, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 pos, B block) throws WorldEditException { return setBlock(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), block); } @Override - public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(int x, int y, int z, B block) throws WorldEditException { if(blockBag != null) { BlockStateHolder lazyBlock = getExtent().getLazyBlock(x, y, z); BlockType fromType = lazyBlock.getBlockType(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java index 9c9947729..6a2686483 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java @@ -73,7 +73,7 @@ public class ChunkBatchingExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (!enabled) { return getExtent().setBlock(location, block); } 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 b2524201e..918a03fbf 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 @@ -31,6 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.LocatedBlock; import com.sk89q.worldedit.util.collection.LocatedBlockList; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -108,7 +109,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder * @param block The block * @return The priority */ - public int getPlacementPriority(BlockStateHolder block) { + public > int getPlacementPriority(B block) { if (Blocks.shouldPlaceLate(block.getBlockType())) { return 1; } else if (Blocks.shouldPlaceLast(block.getBlockType())) { @@ -123,7 +124,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (!enabled) { return super.setBlock(location, block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index bc6887475..515684c8d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -138,7 +138,7 @@ public class BlockTransformExtent extends ResettableExtent { public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { return super.setBlock(location, transformFastInverse((BlockState)block)); } - + private static final Set directionNames = Sets.newHashSet("north", "south", "east", "west"); /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java index 0af3434cd..637ccd821 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java @@ -77,7 +77,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (limit >= 0) { if (count >= limit) { throw new MaxChangedBlocksException(limit); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java index fbab92001..9bc9aaf43 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java @@ -49,7 +49,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { final int y = location.getBlockY(); final BlockType type = block.getBlockType(); if (y < 0 || y > world.getMaxY()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java index 5640d5d83..9631f53ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java @@ -51,7 +51,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, B block) throws WorldEditException { BlockType existing = getExtent().getBlock(position).getBlockType(); if (existing.getMaterial().hasContainer()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java index 897473fa8..f7be704e2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java @@ -61,7 +61,7 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { world.checkLoadedChunk(location); return super.setBlock(location, block); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java index 0c8e6e1b7..a83a4c615 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java @@ -99,8 +99,8 @@ public class FastModeExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { - if (enabled) { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { + if (enabled || postEditSimulation) { dirtyChunks.add(BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4)); if (world.setBlock(location, block, false)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java index 87d7c24e0..35142703b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java @@ -81,7 +81,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent { } @Override - public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException { + public > boolean setBlock(BlockVector3 location, B block) throws WorldEditException { if (toolUse && block.getBlockType().getMaterial().isAir()) { world.simulateBlockMine(location); return true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockDistributionCounter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockDistributionCounter.java index 258e02871..cf5b47f48 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockDistributionCounter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockDistributionCounter.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.ArrayList; import java.util.Collections; @@ -36,27 +35,27 @@ import java.util.Map; public class BlockDistributionCounter implements RegionFunction { private Extent extent; - private boolean fuzzy; + private boolean separateStates; - private List> distribution = new ArrayList<>(); - private Map> map = new HashMap<>(); + private List> distribution = new ArrayList<>(); + private Map> map = new HashMap<>(); - public BlockDistributionCounter(Extent extent, boolean fuzzy) { + public BlockDistributionCounter(Extent extent, boolean separateStates) { this.extent = extent; - this.fuzzy = fuzzy; + this.separateStates = separateStates; } @Override public boolean apply(BlockVector3 position) throws WorldEditException { - BlockStateHolder blk = extent.getBlock(position); - if (fuzzy) { - blk = ((BlockState) blk).toFuzzy(); + BlockState blk = extent.getBlock(position); + if (!separateStates) { + blk = blk.getBlockType().getDefaultState(); } if (map.containsKey(blk)) { map.get(blk).increment(); } else { - Countable c = new Countable<>(blk, 1); + Countable c = new Countable<>(blk, 1); map.put(blk, c); distribution.add(c); } @@ -69,7 +68,7 @@ public class BlockDistributionCounter implements RegionFunction { * * @return The distribution */ - public List> getDistribution() { + public List> getDistribution() { Collections.sort(distribution); Collections.reverse(distribution); return this.distribution; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java index 61972bfe0..e1ab41b03 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java @@ -27,6 +27,8 @@ import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; /** @@ -104,7 +106,7 @@ public class FloraGenerator implements RegionFunction { @Override public boolean apply(BlockVector3 position) throws WorldEditException { - BlockStateHolder block = editSession.getBlock(position); + BlockState block = editSession.getBlock(position); if (block.getBlockType() == BlockTypes.GRASS_BLOCK) { editSession.setBlock(position.add(0, 1, 0), temperatePattern.apply(position)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java index 7a6e81b8a..e0332d550 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java @@ -24,7 +24,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.util.TreeGenerator; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; @@ -50,7 +50,7 @@ public class ForestGenerator implements RegionFunction { @Override public boolean apply(BlockVector3 position) throws WorldEditException { - BlockStateHolder block = editSession.getBlock(position); + BlockState block = editSession.getBlock(position); BlockType t = block.getBlockType(); if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java index dc18d3cc8..0cc3266df 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java @@ -198,7 +198,7 @@ public class GardenPatchGenerator implements RegionFunction { * @return if block was changed * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - private static boolean setBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException { + private static > boolean setBlockIfAir(EditSession session, BlockVector3 position, B block) throws MaxChangedBlocksException { return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block); } 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 bcd424e9d..c3530fd47 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 @@ -11,11 +11,14 @@ import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; import static com.google.common.base.Preconditions.checkNotNull; -import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; import javax.annotation.Nullable; import java.util.ArrayList; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java index 9bdca29c2..947ed20db 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java @@ -12,10 +12,15 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; @Deprecated public class BlockPattern implements Pattern { - private BlockStateHolder block; + private BaseBlock block; - public BlockPattern(BlockStateHolder block) { - this.block = block; + /** + * Create a new pattern with the given block. + * + * @param block the block + */ + public BlockPattern(BlockStateHolder block) { + setBlock(block); } /** @@ -23,7 +28,7 @@ public class BlockPattern implements Pattern { * * @return the block that is always returned */ - public BlockStateHolder getBlock() { + public BaseBlock getBlock() { return block; } @@ -32,13 +37,13 @@ public class BlockPattern implements Pattern { * * @param block the block */ - public void setBlock(BlockStateHolder block) { + public void setBlock(BlockStateHolder block) { checkNotNull(block); - this.block = block; + this.block = block.toBaseBlock(); } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { return block; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java index 9c0c34e48..cbfa5dbf6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java @@ -6,7 +6,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; import static com.google.common.base.Preconditions.checkNotNull; @@ -37,23 +37,14 @@ public class ClipboardPattern extends AbstractPattern { } @Override -//<<<<<<< HEAD - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { int xp = position.getBlockX() % sx; int yp = position.getBlockY() % sy; int zp = position.getBlockZ() % sz; if (xp < 0) xp += sx; if (yp < 0) yp += sy; if (zp < 0) zp += sz; - return clipboard.getBlock(BlockVector3.at(min.getX() + xp, min.getY() + yp, min.getZ() + zp)); -//======= -// public BlockStateHolder apply(BlockVector3 position) { -// int xp = Math.abs(position.getBlockX()) % size.getBlockX(); -// int yp = Math.abs(position.getBlockY()) % size.getBlockY(); -// int zp = Math.abs(position.getBlockZ()) % size.getBlockZ(); -// -// return clipboard.getFullBlock(clipboard.getMinimumPoint().add(xp, yp, zp)); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner + return clipboard.getFullBlock(BlockVector3.at(min.getX() + xp, min.getY() + yp, min.getZ() + zp)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java index e9ee2af4f..e3978d8d3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/FawePattern.java @@ -7,6 +7,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; /** @@ -17,7 +18,7 @@ import com.sk89q.worldedit.world.block.BlockState; public interface FawePattern extends Pattern { @Deprecated - default BlockStateHolder apply(BlockVector3 position) { + default BaseBlock apply(BlockVector3 position) { throw new UnsupportedOperationException("Please use apply(extent, get, set)"); } 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 80a56c84e..107a8aec8 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 @@ -28,6 +28,7 @@ import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.internal.expression.runtime.Return; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState; @@ -55,7 +56,7 @@ public interface Pattern{ * @param position the position * @return a block */ - BlockStateHolder apply(BlockVector3 position); + BaseBlock apply(BlockVector3 position); default boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { return extent.setBlock(set, apply(get)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java index 7a7e4b679..2acf60bf0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java @@ -10,7 +10,7 @@ import com.sk89q.worldedit.extent.Extent; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; import java.util.HashMap; import java.util.LinkedHashSet; @@ -56,24 +56,8 @@ public class RandomPattern extends AbstractPattern { this.patterns.add(pattern); } -//<<<<<<< HEAD public Set getPatterns() { return patterns; -//======= -// @Override -// public BlockStateHolder apply(BlockVector3 position) { -// double r = random.nextDouble(); -// double offset = 0; -// -// for (Chance chance : patterns) { -// if (r <= (offset + chance.getChance()) / max) { -// return chance.getPattern().apply(position); -// } -// offset += chance.getChance(); -// } -// -// throw new RuntimeException("ProportionalFillPattern"); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner } public RandomCollection getCollection() { @@ -81,7 +65,7 @@ public class RandomPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 get) { + public BaseBlock apply(BlockVector3 get) { return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(get); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java index 7f68c536e..d7b799840 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java @@ -23,11 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.extent.Extent; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.worldedit.world.block.BaseBlock; /** * Returns the blocks from {@link Extent}, repeating when out of bounds. @@ -87,7 +83,7 @@ public class RepeatingExtentPattern extends AbstractPattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { + public BaseBlock apply(BlockVector3 position) { BlockVector3 base = position.add(offset); BlockVector3 size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1); int x = base.getBlockX() % size.getBlockX(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java index 34ffc9e04..d4613b277 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java @@ -25,6 +25,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.history.UndoContext; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; /** @@ -37,8 +38,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; public class BlockChange implements Change { private final BlockVector3 position; - private final BlockStateHolder previous; - private final BlockStateHolder current; + private final BaseBlock previous; + private final BaseBlock current; /** * Create a new block change. @@ -47,13 +48,13 @@ public class BlockChange implements Change { * @param previous the previous block * @param current the current block */ - public BlockChange(BlockVector3 position, BlockStateHolder previous, BlockStateHolder current) { + public , BC extends BlockStateHolder> BlockChange(BlockVector3 position, BP previous, BC current) { checkNotNull(position); checkNotNull(previous); checkNotNull(current); this.position = position; - this.previous = previous; - this.current = current; + this.previous = previous.toBaseBlock(); + this.current = current.toBaseBlock(); } /** @@ -70,7 +71,7 @@ public class BlockChange implements Change { * * @return the previous block */ - public BlockStateHolder getPrevious() { + public BaseBlock getPrevious() { return previous; } @@ -79,7 +80,7 @@ public class BlockChange implements Change { * * @return the current block */ - public BlockStateHolder getCurrent() { + public BaseBlock getCurrent() { return current; } 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 13afa3623..c3a8fe906 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 @@ -202,10 +202,10 @@ public class WorldEditBinding extends BindingHelper { return result instanceof BlockState ? (BlockState) result : result.toImmutableState(); } - @BindingMatch(type = BaseBlock.class, + @BindingMatch(type = {BaseBlock.class, BlockState.class, BlockStateHolder.class}, behavior = BindingBehavior.CONSUMES, consumedCount = 1) - public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException { +public BaseBlock getBaseBlock(ArgumentStack context) throws ParameterException, WorldEditException { return new BaseBlock(getBlockState(context)); } @@ -360,7 +360,6 @@ public class WorldEditBinding extends BindingHelper { String input = context.next(); if (input != null) { if (MathMan.isInteger(input)) return new BaseBiome(Integer.parseInt(input)); - BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager() .queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); List knownBiomes = biomeRegistry.getBiomes(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java index bdd40c104..fcee6abcc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.internal.registry; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.collect.Lists; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.NoMatchException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java index 5b26672cb..9442deaca 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java @@ -131,7 +131,7 @@ public class RegionIntersection extends AbstractRegion { return false; } - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"unchecked"}) @Override public Iterator iterator() { Iterator[] iterators = (Iterator[]) new Iterator[regions.size()]; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java index f524c0ba0..3019f7c6b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java @@ -121,7 +121,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion { @Override public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) { - if (position.equals(region.getCenter()) && region.getRadius().lengthSq() == 0) { + if (position.equals(region.getCenter().toBlockPoint()) && region.getRadius().lengthSq() == 0) { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java index a361b528f..142fbb481 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java @@ -24,7 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; /** * Generates solid and hollow shapes according to materials returned by the @@ -51,7 +51,7 @@ public abstract class ArbitraryShape { * @param defaultMaterial The material returned by the pattern for the current block. * @return material to place or null to not place anything. */ - protected abstract BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial); + protected abstract BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial); /** * Generates the shape. @@ -71,7 +71,7 @@ public abstract class ArbitraryShape { int z = position.getBlockZ(); if (!hollow) { - final BlockStateHolder material = getMaterial(x, y, z, pattern.apply(position)); + BaseBlock material = getMaterial(x, y, z, pattern.apply(position)); if (material != null && editSession.setBlock(position, material)) { ++affected; } @@ -79,7 +79,7 @@ public abstract class ArbitraryShape { continue; } - final BlockStateHolder material = getMaterial(x, y, z, pattern.apply(position)); + BaseBlock material = getMaterial(x, y, z, pattern.apply(position)); if (material == null) { continue; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java index 95c542c6f..b066b1d4b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java @@ -21,7 +21,7 @@ package com.sk89q.worldedit.regions.shape; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; /** * Generates solid and hollow shapes according to materials returned by the @@ -34,7 +34,7 @@ public class RegionShape extends ArbitraryShape { } @Override - protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) { + protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) { if (!this.extent.contains(BlockVector3.at(x, y, z))) { return null; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java index 509054bbb..7e4c96fe0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java @@ -131,6 +131,6 @@ public class AbstractProperty implements Property { if (!(obj instanceof Property)) { return false; } - return getName().equals(((Property) obj).getName()); + return getName().equals(((Property) obj).getName()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java index 515d30016..1307508f5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java @@ -29,6 +29,7 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.util.io.file.FilenameException; +import com.sk89q.worldedit.world.block.BaseBlock; import java.io.File; import java.util.ArrayList; @@ -153,7 +154,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * @throws UnknownItemException * @throws DisallowedItemException */ - public BlockStateHolder getBlock(String input, boolean allAllowed) throws WorldEditException { + public BaseBlock getBlock(String input, boolean allAllowed) throws WorldEditException { ParserContext context = new ParserContext(); context.setActor(player); context.setWorld(player.getWorld()); @@ -172,7 +173,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * @throws UnknownItemException * @throws DisallowedItemException */ - public BlockStateHolder getBlock(String id) throws WorldEditException { + public BaseBlock getBlock(String id) throws WorldEditException { return getBlock(id, false); } @@ -201,7 +202,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * @throws UnknownItemException * @throws DisallowedItemException */ - public Set getBlocks(String list, boolean allBlocksAllowed) throws WorldEditException { + public Set getBlocks(String list, boolean allBlocksAllowed) throws WorldEditException { ParserContext context = new ParserContext(); context.setActor(player); context.setWorld(player.getWorld()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java index 35552b8d9..e2b3235f6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java @@ -22,7 +22,7 @@ package com.sk89q.worldedit.util; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; import java.util.Objects; @@ -32,9 +32,9 @@ import java.util.Objects; public final class LocatedBlock { private final BlockVector3 location; - private final BlockStateHolder block; + private final BaseBlock block; - public LocatedBlock(BlockVector3 location, BlockStateHolder block) { + public LocatedBlock(BlockVector3 location, BaseBlock block) { this.location = checkNotNull(location); this.block = checkNotNull(block); } @@ -43,7 +43,7 @@ public final class LocatedBlock { return location; } - public BlockStateHolder getBlock() { + public BaseBlock getBlock() { return block; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java index 3a2fbc4c3..0faf766e8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java @@ -250,7 +250,7 @@ public class TreeGenerator { * @return whether a block was changed * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - private static boolean setChanceBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block, double probability) + private static > boolean setChanceBlockIfAir(EditSession session, BlockVector3 position, B block, double probability) throws MaxChangedBlocksException { return Math.random() <= probability && setBlockIfAir(session, position, block); } @@ -263,7 +263,7 @@ public class TreeGenerator { * @return if block was changed * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - private static boolean setBlockIfAir(EditSession session, BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException { + private static > boolean setBlockIfAir(EditSession session, BlockVector3 position, B block) throws MaxChangedBlocksException { return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java index 4f303acd6..67280031d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java @@ -51,8 +51,8 @@ public class LocatedBlockList implements Iterable { list.add(setBlockCall); } - public void add(BlockVector3 location, BlockStateHolder block) { - add(new LocatedBlock(location, block)); + public > void add(BlockVector3 location, B block) { + add(new LocatedBlock(location, block.toBaseBlock())); } public int size() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java index e83476347..80aaa726b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java @@ -53,7 +53,7 @@ public abstract class AbstractWorld implements World { } @Override - public final boolean setBlock(BlockVector3 pt, BlockStateHolder block) throws WorldEditException { + public final > boolean setBlock(BlockVector3 pt, B block) throws WorldEditException { return setBlock(pt, block, true); } @@ -144,6 +144,7 @@ public abstract class AbstractWorld implements World { this.priority = priority; } + @SuppressWarnings("deprecation") public void play() { playEffect(position, 2001, blockType.getLegacyCombinedId() >> 4); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index 119ac5734..f21e1660f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -60,7 +60,7 @@ public class NullWorld extends AbstractWorld { } @Override - public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java index 7ea6d0e24..d9028c95f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/SimpleWorld.java @@ -54,7 +54,7 @@ public interface SimpleWorld extends World { } @Override - default boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { + default > boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException { return setBlock(position, block); } @@ -64,7 +64,7 @@ public interface SimpleWorld extends World { } @Override - boolean setBlock(BlockVector3 pt, BlockStateHolder block) throws WorldEditException; + > boolean setBlock(BlockVector3 pt, B block) throws WorldEditException; @Override default int getMaxY() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java index b335de3cb..cad0be0f5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java @@ -38,8 +38,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.weather.WeatherType; -import java.util.Vector; - /** * Represents a world (dimension). */ @@ -96,7 +94,7 @@ public interface World extends Extent { * @param notifyAndLight true to to notify and light * @return true if the block was successfully set (return value may not be accurate) */ - boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException; + > boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException; /** * Notifies the simulation that the block at the given location has diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java index 764b378cb..e48145ea3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java @@ -191,7 +191,7 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { public final BlockState toImmutableState() { return blockState; } - + @Override public int getInternalId() { return blockState.getInternalId(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategory.java index 8debc2c47..161b1c304 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategory.java @@ -52,7 +52,7 @@ public class BlockCategory extends Category { * @param blockStateHolder The blockstateholder * @return If it's a part of this category */ - public boolean contains(BlockStateHolder blockStateHolder) { + public > boolean contains(B blockStateHolder) { return this.getAll().contains(blockStateHolder.getBlockType()); } } 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 331cbb8cf..969691f7d 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 @@ -63,6 +63,18 @@ public class BlockState implements BlockStateHolder { this.emptyBaseBlock = baseBlock; } + /** + * Creates a fuzzy BlockState. This can be used for partial matching. + * + * @param blockType The block type + * @param values The block state values + */ + private BlockState(BlockType blockType, Map, Object> values) { + this.blockType = blockType; +// this.values = values; +// this.fuzzy = true; + } + /** * Returns a temporary BlockState for a given internal id * @param combinedId @@ -224,8 +236,8 @@ public class BlockState implements BlockStateHolder { } @Override - public BlockState apply(BlockVector3 position) { - return this; + public BaseBlock apply(BlockVector3 position) { + return this.toBaseBlock(); } @Override @@ -330,15 +342,6 @@ public class BlockState implements BlockStateHolder { return this.blockType; } - /** - * Deprecated, use masks - not try to this fuzzy/non fuzzy state nonsense - * @return - */ - @Deprecated - public BlockState toFuzzy() { - return this; - } - @Override public int hashCode() { return getOrdinal(); @@ -349,10 +352,42 @@ public class BlockState implements BlockStateHolder { return this == obj; } + public BlockState toFuzzy() { + return new BlockState(this.getBlockType(), new HashMap<>()); + } + @Override - @Deprecated - public boolean equalsFuzzy(BlockStateHolder o) { - return o.getOrdinal() == this.getOrdinal(); + public boolean equalsFuzzy(BlockStateHolder o) { + if (this == o) { + // Added a reference equality check for + return true; + } + if (!getBlockType().equals(o.getBlockType())) { + return false; + } + + Set> differingProperties = new HashSet<>(); + for (Object state : o.getStates().keySet()) { + if (getState((Property) state) == null) { + differingProperties.add((Property) state); + } + } + for (Property property : getStates().keySet()) { + if (o.getState(property) == null) { + differingProperties.add(property); + } + } + + for (Property property : getStates().keySet()) { + if (differingProperties.contains(property)) { + continue; + } + if (!Objects.equals(getState(property), o.getState(property))) { + return false; + } + } + + return true; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java index 882d044ae..6fa0a7eb1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java @@ -31,7 +31,7 @@ import com.sk89q.worldedit.world.registry.BlockMaterial; import java.util.Map; import java.util.stream.Collectors; -public interface BlockStateHolder extends FawePattern, TileEntityBlock { +public interface BlockStateHolder> extends FawePattern, TileEntityBlock { /** * Get the block type @@ -121,8 +121,7 @@ public interface BlockStateHolder extends FawePatter * @param o other block * @return true if equal */ - @Deprecated - boolean equalsFuzzy(BlockStateHolder o); + boolean equalsFuzzy(BlockStateHolder o); /** * Returns an immutable {@link BlockState} from this BlockStateHolder. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index 3e3f9b2e7..4479343e5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -326,8 +326,8 @@ public class BlockType implements FawePattern { } @Override - public BlockStateHolder apply(BlockVector3 position) { - return this.getDefaultState(); + public BaseBlock apply(BlockVector3 position) { + return this.getDefaultState().toBaseBlock(); } public Mask toMask(Extent extent) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 814ba0f6c..a5a179965 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -32,8 +32,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; +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.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.storage.InvalidFormatException; @@ -254,14 +254,14 @@ public class AnvilChunk implements Chunk { } @Override - public BlockStateHolder getBlock(BlockVector3 position) throws DataException { + public BaseBlock getBlock(BlockVector3 position) throws DataException { int id = getBlockID(position); int data = getBlockData(position); BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data); if (state == null) { WorldEdit.logger.warning("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk."); - return BlockTypes.AIR.getDefaultState(); + return BlockTypes.AIR.getDefaultState().toBaseBlock(); } if (state.getMaterial().hasContainer()) { CompoundTag tileEntity = getBlockTileEntity(position); @@ -269,6 +269,8 @@ public class AnvilChunk implements Chunk { return new BaseBlock(state, tileEntity); } } - return state; } + + return state.toBaseBlock(); + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java index b0673c4e5..c4d2eb939 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java @@ -32,7 +32,6 @@ import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.DataException; 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.block.BlockTypes; import com.sk89q.worldedit.world.storage.InvalidFormatException; @@ -231,7 +230,7 @@ public class AnvilChunk13 implements Chunk { } @Override - public BlockStateHolder getBlock(BlockVector3 position) throws DataException { + public BaseBlock getBlock(BlockVector3 position) throws DataException { int x = position.getX() - rootX * 16; int y = position.getY(); int z = position.getZ() - rootZ * 16; @@ -249,7 +248,8 @@ public class AnvilChunk13 implements Chunk { CompoundTag tileEntity = getBlockTileEntity(position); if (tileEntity != null) return new BaseBlock(state, tileEntity); } - return state; + + return state.toBaseBlock(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java index 57455bfbe..6987622d3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java @@ -22,13 +22,13 @@ package com.sk89q.worldedit.world.chunk; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.DataException; -import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BaseBlock; /** * A 16 by 16 block chunk. */ public interface Chunk { - + /** * Get a block; * @@ -36,6 +36,6 @@ public interface Chunk { * @return block the block * @throws DataException thrown on data error */ - BlockStateHolder getBlock(BlockVector3 position) throws DataException; + BaseBlock getBlock(BlockVector3 position) throws DataException; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java index 99e265360..c99d55d2a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java @@ -30,8 +30,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; +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.BlockTypes; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.storage.InvalidFormatException; @@ -154,13 +154,9 @@ public class OldChunk implements Chunk { } @Override -//<<<<<<< HEAD - public BlockStateHolder getBlock(BlockVector3 position) throws DataException { - if(position.getBlockY() >= 128) return BlockTypes.VOID_AIR.getDefaultState(); -//======= -// public BlockStateHolder getBlock(BlockVector3 position) throws DataException { -// if(position.getY() >= 128) return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); -//>>>>>>> 399e0ad5... Refactor vector system to be cleaner + + public BaseBlock getBlock(BlockVector3 position) throws DataException { + if(position.getY() >= 128) return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); int id, dataVal; int x = position.getX() - rootX * 16; @@ -189,13 +185,13 @@ public class OldChunk implements Chunk { BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, dataVal); if (state == null) { WorldEdit.logger.warning("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk."); - return BlockTypes.AIR.getDefaultState(); + return BlockTypes.AIR.getDefaultState().toBaseBlock(); } if (state.getBlockType().getMaterial().hasContainer()) { CompoundTag tileEntity = getBlockTileEntity(position); if (tileEntity != null) return new BaseBlock(state, tileEntity); } - return state; + return state.toBaseBlock(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java index 95ad60655..176e77a8f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java @@ -66,7 +66,6 @@ public interface BlockRegistry { */ Map> getProperties(BlockType blockType); - /** * Register all blocks */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java index ed249e877..0d20492d5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java @@ -230,7 +230,7 @@ public class LegacyMapper { return INSTANCE; } - @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection", "unused"}) + @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) private static class LegacyDataFile { private Map blocks; private Map items; diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 007c08c23..fadddd904 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -175,8 +175,12 @@ public class ForgePlayer extends AbstractPlayerActor { @Override <<<<<<< HEAD +<<<<<<< HEAD ======= public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { +======= + public > void sendFakeBlock(BlockVector3 pos, B block) { +>>>>>>> 3fefcbf9... Remove all raw usages of BSH, improve API generics BlockPos loc = ForgeAdapter.toBlockPos(pos); if (block == null) { // TODO diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index c62f8abff..a2c960f26 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -171,7 +171,7 @@ public class ForgeWorld extends AbstractWorld { } @Override - public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException { checkNotNull(position); checkNotNull(block); @@ -186,7 +186,6 @@ public class ForgeWorld extends AbstractWorld { IBlockState old = chunk.getBlockState(pos); Block mcBlock = Block.getBlockFromName(block.getBlockType().getId()); IBlockState newState = mcBlock.getDefaultState(); - @SuppressWarnings("unchecked") Map, Object> states = block.getStates(); newState = applyProperties(mcBlock.getBlockState(), newState, states); IBlockState successState = chunk.setBlockState(pos, newState); diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java index 3a4d74edd..3793ffb87 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java @@ -35,6 +35,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemTypes; + import org.spongepowered.api.Sponge; import org.spongepowered.api.data.type.HandTypes; import org.spongepowered.api.entity.living.player.Player; @@ -196,7 +197,7 @@ public class SpongePlayer extends AbstractPlayerActor { } @Override - public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { + public > void sendFakeBlock(BlockVector3 pos, B block) { org.spongepowered.api.world.Location loc = player.getWorld().getLocation(pos.getX(), pos.getY(), pos.getZ()); if (block == null) { player.sendBlockChange(loc.getBlockPosition(), loc.getBlock()); diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java index d8d80560d..fa088ee86 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java @@ -136,7 +136,7 @@ public abstract class SpongeWorld extends AbstractWorld { private static final BlockSnapshot.Builder builder = BlockSnapshot.builder(); @Override - public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException { + public > boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException { checkNotNull(position); checkNotNull(block);