From bc5609114b6c632fcc656dc0cee309d30598c16f Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Thu, 16 Aug 2018 15:42:11 +1000 Subject: [PATCH] Add a material to check if air is air, because there are now 3 types of air. --- .../sk89q/worldedit/bukkit/BukkitBlockRegistry.java | 5 +++++ .../sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java | 4 ++-- .../bukkit/EditSessionBlockChangeDelegate.java | 2 +- .../src/main/java/com/sk89q/worldedit/EditSession.java | 8 ++++---- .../com/sk89q/worldedit/command/tool/AreaPickaxe.java | 2 +- .../worldedit/command/tool/FloatingTreeRemover.java | 2 +- .../sk89q/worldedit/command/tool/FloodFillTool.java | 2 +- .../worldedit/command/tool/LongRangeBuildTool.java | 4 ++-- .../sk89q/worldedit/command/tool/RecursivePickaxe.java | 2 +- .../worldedit/command/tool/brush/GravityBrush.java | 4 ++-- .../extension/platform/AbstractPlayerActor.java | 7 ++++--- .../com/sk89q/worldedit/extent/inventory/BlockBag.java | 4 ++-- .../worldedit/extent/inventory/BlockBagExtent.java | 4 ++-- .../worldedit/extent/world/SurvivalModeExtent.java | 2 +- .../function/generator/GardenPatchGenerator.java | 10 +++++----- .../worldedit/function/mask/ExistingBlockMask.java | 2 +- .../java/com/sk89q/worldedit/util/TargetBlock.java | 4 ++-- .../java/com/sk89q/worldedit/util/TreeGenerator.java | 2 +- .../java/com/sk89q/worldedit/world/chunk/OldChunk.java | 2 +- .../sk89q/worldedit/world/registry/BlockMaterial.java | 7 +++++++ .../world/registry/PassthroughBlockMaterial.java | 9 +++++++++ .../worldedit/world/registry/SimpleBlockMaterial.java | 10 ++++++++++ 22 files changed, 65 insertions(+), 33 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java index 6f272af72..e347f2593 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java @@ -60,6 +60,11 @@ public class BukkitBlockRegistry extends BundledBlockRegistry { this.material = bukkitMaterial; } + @Override + public boolean isAir() { + return material == Material.AIR || material == Material.CAVE_AIR || material == Material.VOID_AIR; + } + @Override public boolean isSolid() { return material.isSolid(); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java index 7334a48c8..d4ec870bc 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java @@ -64,7 +64,7 @@ public class BukkitPlayerBlockBag extends BlockBag { @Override public void fetchBlock(BlockState blockState) throws BlockBagException { - if (blockState.getBlockType() == BlockTypes.AIR) { + if (blockState.getBlockType().getMaterial().isAir()) { throw new IllegalArgumentException("Can't fetch air block"); } @@ -108,7 +108,7 @@ public class BukkitPlayerBlockBag extends BlockBag { @Override public void storeBlock(BlockState blockState, int amount) throws BlockBagException { - if (blockState.getBlockType() == BlockTypes.AIR) { + if (blockState.getBlockType().getMaterial().isAir()) { throw new IllegalArgumentException("Can't store air block"); } if (!blockState.getBlockType().hasItemType()) { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java index 24e14d964..97fa2b170 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java @@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { @Override public boolean isEmpty(int x, int y, int z) { - return editSession.getBlock(new Vector(x, y, z)).getBlockType() == BlockTypes.AIR; + return editSession.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir(); } } 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 1984abf94..722c88d71 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1446,7 +1446,7 @@ public class EditSession implements Extent { if (setBlock(pt, air)) { ++affected; } - } else if (id == BlockTypes.AIR) { + } else if (id.getMaterial().isAir()) { continue; } @@ -1488,7 +1488,7 @@ public class EditSession implements Extent { Vector pt = new Vector(x, y, z); BlockType id = getBlock(pt).getBlockType(); - if (id == BlockTypes.AIR) { + if (id.getMaterial().isAir()) { continue; } @@ -1619,7 +1619,7 @@ public class EditSession implements Extent { for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ() + size; ++z) { // Don't want to be in the ground - if (getBlock(new Vector(x, basePosition.getBlockY(), z)).getBlockType() != BlockTypes.AIR) { + if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) { continue; } // The gods don't want a tree here @@ -1636,7 +1636,7 @@ public class EditSession implements Extent { break; } else if (t == BlockTypes.SNOW) { setBlock(new Vector(x, y, z), BlockTypes.AIR.getDefaultState()); - } else if (t != BlockTypes.AIR) { // Trees won't grow on this! + } else if (!t.getMaterial().isAir()) { // Trees won't grow on this! break; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java index 6401eb993..e7b64ad7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/AreaPickaxe.java @@ -54,7 +54,7 @@ public class AreaPickaxe implements BlockTool { int oz = clicked.getBlockZ(); BlockType initialType = clicked.getExtent().getBlock(clicked.toVector()).getBlockType(); - if (initialType == BlockTypes.AIR) { + if (initialType.getMaterial().isAir()) { return true; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index 5f2d822cc..b0a47626d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -134,7 +134,7 @@ public class FloatingTreeRemover implements BlockTool { if (visited.add(next)) { BlockState state = world.getBlock(next); - if (state.getBlockType() == BlockTypes.AIR || state.getBlockType() == BlockTypes.SNOW) { + if (state.getBlockType().getMaterial().isAir() || state.getBlockType() == BlockTypes.SNOW) { continue; } if (isTreeBlock(state.getBlockType())) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java index 3d178cb9c..3d5220c8a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloodFillTool.java @@ -61,7 +61,7 @@ public class FloodFillTool implements BlockTool { BlockType initialType = world.getBlock(clicked.toVector()).getBlockType(); - if (initialType == BlockTypes.AIR) { + if (initialType.getMaterial().isAir()) { return true; } 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 af20ea56d..0522e8579 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 @@ -57,7 +57,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo EditSession eS = session.createEditSession(player); try { BlockStateHolder applied = secondary.apply(pos.toVector()); - if (applied.getBlockType() == BlockTypes.AIR) { + if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(pos.toVector(), secondary); } else { eS.setBlock(pos.getDirection(), secondary); @@ -77,7 +77,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo EditSession eS = session.createEditSession(player); try { BlockStateHolder applied = primary.apply(pos.toVector()); - if (applied.getBlockType() == BlockTypes.AIR) { + if (applied.getBlockType().getMaterial().isAir()) { eS.setBlock(pos.toVector(), primary); } else { eS.setBlock(pos.getDirection(), primary); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java index f513cb075..b2fcf6525 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/RecursivePickaxe.java @@ -58,7 +58,7 @@ public class RecursivePickaxe implements BlockTool { BlockType initialType = world.getBlock(clicked.toVector()).getBlockType(); - if (initialType == BlockTypes.AIR) { + if (initialType.getMaterial().isAir()) { return true; } 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 c452e7d7e..8eaf1fbce 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 @@ -48,7 +48,7 @@ public class GravityBrush implements Brush { for (; y > position.getBlockY() - size; --y) { final Vector pt = new Vector(x, y, z); final BlockStateHolder block = editSession.getBlock(pt); - if (block.getBlockType() != BlockTypes.AIR) { + if (!block.getBlockType().getMaterial().isAir()) { blockTypes.add(block); editSession.setBlock(pt, BlockTypes.AIR.getDefaultState()); } @@ -56,7 +56,7 @@ public class GravityBrush implements Brush { Vector pt = new Vector(x, y, z); Collections.reverse(blockTypes); for (int i = 0; i < blockTypes.size();) { - if (editSession.getBlock(pt).getBlockType() == BlockTypes.AIR) { + if (editSession.getBlock(pt).getBlockType().getMaterial().isAir()) { editSession.setBlock(pt, blockTypes.get(i++)); } pt = pt.add(0, 1, 0); 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 36e84ded7..4c3ced012 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 @@ -32,6 +32,7 @@ import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.auth.AuthorizationException; 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.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; @@ -210,10 +211,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { while (y >= 0) { final Vector platform = new Vector(x, y, z); final BlockStateHolder block = world.getBlock(platform); - final com.sk89q.worldedit.world.block.BlockType type = block.getBlockType(); + final BlockType type = block.getBlockType(); // Don't want to end up in lava - if (type != BlockTypes.AIR && type != BlockTypes.LAVA) { + if (!type.getMaterial().isAir() && type != BlockTypes.LAVA) { // Found a block! setPosition(platform.add(0.5, 1, 0.5)); return true; @@ -246,7 +247,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { Extent world = getLocation().getExtent(); // No free space above - if (world.getBlock(new Vector(x, y, z)).getBlockType() != BlockTypes.AIR) { + if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isAir()) { return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java index c779f833d..b48e8d509 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java @@ -37,7 +37,7 @@ public abstract class BlockBag { public void storeDroppedBlock(BlockState blockState) throws BlockBagException { BlockState dropped = blockState; // TODO BlockType.getBlockBagItem(id, data); if (dropped == null) return; - if (dropped.getBlockType() == BlockTypes.AIR) return; + if (dropped.getBlockType().getMaterial().isAir()) return; storeBlock(dropped); } @@ -57,7 +57,7 @@ public abstract class BlockBag { fetchBlock(blockState); } catch (OutOfBlocksException e) { BlockState placed = blockState;// TODO BlockType.getBlockBagItem(id, data); - if (placed == null || placed.getBlockType() == BlockTypes.AIR) throw e; // TODO: check + if (placed == null || placed.getBlockType().getMaterial().isAir()) throw e; // TODO: check fetchBlock(placed); } 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 343181e25..b528c1c79 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 @@ -87,7 +87,7 @@ public class BlockBagExtent extends AbstractDelegateExtent { if (blockBag != null) { BlockState existing = getExtent().getBlock(position); - if (block.getBlockType() != BlockTypes.AIR) { + if (!block.getBlockType().getMaterial().isAir()) { try { blockBag.fetchPlacedBlock(block.toImmutableState()); } catch (UnplaceableBlockException e) { @@ -102,7 +102,7 @@ public class BlockBagExtent extends AbstractDelegateExtent { } } - if (existing.getBlockType() != BlockTypes.AIR) { + if (!existing.getBlockType().getMaterial().isAir()) { try { blockBag.storeDroppedBlock(existing); } catch (BlockBagException ignored) { 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 97d8ee9c3..52682bdca 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(Vector location, BlockStateHolder block) throws WorldEditException { - if (toolUse && block.getBlockType() == BlockTypes.AIR) { + if (toolUse && block.getBlockType().getMaterial().isAir()) { world.simulateBlockMine(location); return true; } else { 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 b23af44ac..48f85b841 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 @@ -86,11 +86,11 @@ public class GardenPatchGenerator implements RegionFunction { */ private void placeVine(Vector basePos, Vector pos) throws MaxChangedBlocksException { if (pos.distance(basePos) > 4) return; - if (editSession.getBlock(pos).getBlockType() != BlockTypes.AIR) return; + if (!editSession.getBlock(pos).getBlockType().getMaterial().isAir()) return; for (int i = -1; i > -3; --i) { Vector testPos = pos.add(0, i, 0); - if (editSession.getBlock(testPos).getBlockType() == BlockTypes.AIR) { + if (editSession.getBlock(testPos).getBlockType().getMaterial().isAir()) { pos = testPos; } else { break; @@ -159,7 +159,7 @@ public class GardenPatchGenerator implements RegionFunction { @Override public boolean apply(Vector position) throws WorldEditException { - if (editSession.getBlock(position).getBlockType() != BlockTypes.AIR) { + if (!editSession.getBlock(position).getBlockType().getMaterial().isAir()) { position = position.add(0, 1, 0); } @@ -169,7 +169,7 @@ public class GardenPatchGenerator implements RegionFunction { BlockState leavesBlock = BlockTypes.OAK_LEAVES.getDefaultState(); - if (editSession.getBlock(position).getBlockType() == BlockTypes.AIR) { + if (editSession.getBlock(position).getBlockType().getMaterial().isAir()) { editSession.setBlock(position, leavesBlock); } @@ -199,7 +199,7 @@ public class GardenPatchGenerator implements RegionFunction { * @throws MaxChangedBlocksException thrown if too many blocks are changed */ private static boolean setBlockIfAir(EditSession session, Vector position, BlockStateHolder block) throws MaxChangedBlocksException { - return session.getBlock(position).getBlockType() == BlockTypes.AIR && session.setBlock(position, block); + return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index 552197d10..07c4545fc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -42,7 +42,7 @@ public class ExistingBlockMask extends AbstractExtentMask { @Override public boolean test(Vector vector) { - return getExtent().getBlock(vector).getBlockType() != BlockTypes.AIR; + return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java index a703e6baf..27fce4979 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/TargetBlock.java @@ -102,7 +102,7 @@ public class TargetBlock { boolean searchForLastBlock = true; Location lastBlock = null; while (getNextBlock() != null) { - if (world.getBlock(getCurrentBlock().toVector()).getBlockType() == BlockTypes.AIR) { + if (world.getBlock(getCurrentBlock().toVector()).getBlockType().getMaterial().isAir()) { if (searchForLastBlock) { lastBlock = getCurrentBlock(); if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) { @@ -124,7 +124,7 @@ public class TargetBlock { * @return Block */ public Location getTargetBlock() { - while (getNextBlock() != null && world.getBlock(getCurrentBlock().toVector()).getBlockType() == BlockTypes.AIR) ; + while (getNextBlock() != null && world.getBlock(getCurrentBlock().toVector()).getBlockType().getMaterial().isAir()) ; return getCurrentBlock(); } 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 d0167bc73..58f32b480 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 @@ -264,6 +264,6 @@ public class TreeGenerator { * @throws MaxChangedBlocksException thrown if too many blocks are changed */ private static boolean setBlockIfAir(EditSession session, Vector position, BlockStateHolder block) throws MaxChangedBlocksException { - return session.getBlock(position).getBlockType() == BlockTypes.AIR && session.setBlock(position, block); + return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block); } } 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 e11d0cefb..631470ac2 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 @@ -154,7 +154,7 @@ public class OldChunk implements Chunk { @Override public BaseBlock getBlock(Vector position) throws DataException { - if(position.getBlockY() >= 128) BlockTypes.AIR.getDefaultState().toBaseBlock(); + if(position.getBlockY() >= 128) BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); int id, dataVal; int x = position.getBlockX() - rootX * 16; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java index 9f8d32a15..1cea2e127 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockMaterial.java @@ -24,6 +24,13 @@ package com.sk89q.worldedit.world.registry; */ public interface BlockMaterial { + /** + * Gets if this block is a type of air. + * + * @return If it's air + */ + boolean isAir(); + /** * Get whether this block is a full sized cube. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java index 97dd617f9..fef791531 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/PassthroughBlockMaterial.java @@ -29,6 +29,15 @@ public class PassthroughBlockMaterial implements BlockMaterial { this.blockMaterial = material; } + @Override + public boolean isAir() { + if (blockMaterial == null) { + return false; + } else { + return blockMaterial.isAir(); + } + } + @Override public boolean isFullCube() { if (blockMaterial == null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java index e0247ce49..b1e1f1ce6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/SimpleBlockMaterial.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.registry; class SimpleBlockMaterial implements BlockMaterial { + private boolean isAir; private boolean fullCube; private boolean opaque; private boolean powerSource; @@ -40,6 +41,15 @@ class SimpleBlockMaterial implements BlockMaterial { private boolean isTranslucent; private boolean hasContainer; + @Override + public boolean isAir() { + return this.isAir; + } + + public void setIsAir(boolean isAir) { + this.isAir = isAir; + } + @Override public boolean isFullCube() { return fullCube;