Add a material to check if air is air, because there are now 3 types of air.

This commit is contained in:
Matthew Miller
2018-08-16 15:42:11 +10:00
parent c31161d068
commit bc5609114b
22 changed files with 65 additions and 33 deletions

View File

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

View File

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