What are the dud BlockCategories?

Dieser Commit ist enthalten in:
Jesse Boyd 2018-08-14 11:00:44 +10:00
Ursprung 76a55b7712
Commit 1740c845d2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
13 geänderte Dateien mit 40 neuen und 31 gelöschten Zeilen

Datei anzeigen

@ -63,7 +63,7 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
@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");
}
@ -107,7 +107,7 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
@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()) {

Datei anzeigen

@ -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();
}
}

Datei anzeigen

@ -233,7 +233,7 @@ public class PlayerWrapper extends AbstractPlayerActor {
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;
}

Datei anzeigen

@ -148,7 +148,7 @@ public class CuboidClipboard {
// }
//
// public boolean setBlock(int x, int y, int z, BaseBlock block) {
// if (block == null || block.getBlockType() == BlockTypes.AIR) {
// if (block == null || block.getBlockType().getMaterial().isAir()) {
// int i = x + z * dx + (y >> 4) * dxz;
// int y2 = y & 0xF;
// int[] idArray = states[i];
@ -238,7 +238,7 @@ public class CuboidClipboard {
// final int newZ = v.getBlockZ();
// for (int y = 0; y < height; ++y) {
// BaseBlock block = getBlock(x, y, z);
// if (block.getBlockType() == BlockTypes.AIR) {
// if (block.getBlockType().getMaterial().isAir()) {
// continue;
// }
// if (reverse) {
@ -484,7 +484,7 @@ public class CuboidClipboard {
// if (block == null) {
// continue;
// }
// if (noAir && block.getBlockType() == BlockTypes.AIR) {
// if (noAir && block.getBlockType().getMaterial().isAir()) {
// continue;
// }
// editSession.setBlock(x + ox, y + oy, z + oz, block);

Datei anzeigen

@ -1026,7 +1026,7 @@ public class LocalSession implements TextureHolder {
public void setTool(BaseItem item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
ItemTypes type = item.getType();
if (type.hasBlockType() && type.getBlockType() != BlockTypes.AIR) {
if (!type.hasBlockType() && type.getBlockType().getMaterial().isAir()) {
throw new InvalidToolBindException(type, "Blocks can't be used");
} else if (type == config.wandItem) {
throw new InvalidToolBindException(type, "Already used for the wand");

Datei anzeigen

@ -134,8 +134,13 @@ public class FloatingTreeRemover implements BlockTool {
if (visited.add(next)) {
BlockState state = world.getBlock(next);
if (state.getBlockType() == BlockTypes.AIR || state.getBlockType() == BlockTypes.SNOW) {
continue;
BlockTypes type = state.getBlockType();
switch (type) {
case AIR:
case CAVE_AIR:
case VOID_AIR:
case SNOW:
continue;
}
if (isTreeBlock(state.getBlockType())) {
queue.addLast(next);

Datei anzeigen

@ -214,18 +214,22 @@ 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 com.sk89q.worldedit.world.block.BlockTypes type = block.getBlockType();
// Don't want to end up in lava
if (type != BlockTypes.AIR && type != BlockTypes.LAVA) {
// Found a block!
setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5));
return true;
switch (type) {
case AIR:
case CAVE_AIR:
case VOID_AIR:
case LAVA:
--y;
continue;
default:
// Found a block!
setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5));
return true;
}
--y;
}
return false;
}
@ -250,7 +254,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;
}

Datei anzeigen

@ -58,7 +58,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);
}

Datei anzeigen

@ -82,7 +82,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 {
@ -92,7 +92,7 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
@Override
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
if (toolUse && block.getBlockType() == BlockTypes.AIR) {
if (toolUse && block.getBlockType().getMaterial().isAir()) {
world.simulateBlockMine(MutableBlockVector.get(x, y, z));
return true;
} else {

Datei anzeigen

@ -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 {
BlockStateHolder 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);
}
/**

Datei anzeigen

@ -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

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -211,7 +211,7 @@ public class SpongeWorldEdit {
BlockType interactedType = targetBlock.getState().getType();
if (event instanceof InteractBlockEvent.Primary) {
if (interactedType != BlockTypes.AIR) {
if (!interactedType.getMaterial().isAir()) {
if (!optLoc.isPresent()) {
return;
}
@ -233,7 +233,7 @@ public class SpongeWorldEdit {
}
}
} else if (event instanceof InteractBlockEvent.Secondary) {
if (interactedType != BlockTypes.AIR) {
if (!interactedType.getMaterial().isAir()) {
if (!optLoc.isPresent()) {
return;
}