Java Code Examples for org.bukkit.block.BlockState#getY()

The following examples show how to use org.bukkit.block.BlockState#getY() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
static String format(BlockState state) {
  return "BlockState{pos=("
      + state.getX()
      + ", "
      + state.getY()
      + ", "
      + state.getZ()
      + ") world="
      + state.getMaterialData()
      + "}";
}
 
Example 2
public int getTypeId(int x, int y, int z) {
    for (BlockState state : blocks) {
        if (state.getX() == x && state.getY() == y && state.getZ() == z) {
            return state.getTypeId();
        }
    }

    return world.getBlockTypeIdAt(x, y, z);
}
 
Example 3
public boolean isEmpty(int x, int y, int z) {
    for (BlockState state : blocks) {
        if (state.getX() == x && state.getY() == y && state.getZ() == z) {
            return Block.getBlockById(state.getTypeId()) == Blocks.AIR;
        }
    }

    return world.getBlockAt(x, y, z).isEmpty();
}
 
Example 4
Source Project: Modern-LWC   File: RedstoneModule.java    License: MIT License 5 votes vote down vote up
@Override
public void onRedstone(LWCRedstoneEvent event) {
    if (event.isCancelled()) {
        return;
    }

    LWC lwc = event.getLWC();
    Protection protection = event.getProtection();

    // check for a player using it
    ProtectionFinder finder = protection.getProtectionFinder();

    if (finder != null) {
        for (BlockState found : finder.getBlocks()) {
            if (DoorMatcher.PRESSURE_PLATES.contains(found.getType())) {
                // find a player that is using it
                int x = found.getX();
                int y = found.getY();
                int z = found.getZ();
                Player player = lwc.findPlayer(x - 1, x + 1, y, y + 1, z - 1, z + 1);

                if (player != null) {
                    if (!lwc.canAccessProtection(player, protection)) {
                        event.setCancelled(true);
                    } else {
                        // bypass the denyRedstone/REDSTONE flag check
                        return;
                    }
                }
            }
        }
    }

    boolean hasFlag = protection.hasFlag(Flag.Type.REDSTONE);
    boolean denyRedstone = lwc.getConfiguration().getBoolean("protections.denyRedstone", false);

    if ((!hasFlag && denyRedstone) || (hasFlag && !denyRedstone)) {
        event.setCancelled(true);
    }
}
 
Example 5
@Override
public boolean matches(IBlockQuery query) {
    final BlockState block = query.getBlock();
    return block.getY() == 0 ||
           (!query.getMatch().needMatchModule(WorldProblemMatchModule.class).wasBlock36(block.getX(), 0, block.getZ()) &&
            block.getWorld().getBlockAt(block.getX(), 0, block.getZ()).getType() == Material.AIR);
}
 
Example 6
public int getTypeId(int x, int y, int z) {
    for (BlockState state : blocks) {
        if (state.getX() == x && state.getY() == y && state.getZ() == z) {
            return state.getTypeId();
        }
    }

    return world.getBlockTypeIdAt(x, y, z);
}
 
Example 7
public boolean isEmpty(int x, int y, int z) {
    for (BlockState state : blocks) {
        if (state.getX() == x && state.getY() == y && state.getZ() == z) {
            return net.minecraft.block.Block.getBlockById(state.getTypeId()) == net.minecraft.init.Blocks.air;
        }
    }

    return world.getBlockAt(x, y, z).isEmpty();
}
 
Example 8
static BlockVector position(BlockState block) {
  return new BlockVector(block.getX(), block.getY(), block.getZ());
}
 
Example 9
public BlockQuery(@Nullable Event event, BlockState block) {
  this(event, checkNotNull(block).getWorld(), block.getX(), block.getY(), block.getZ());
  this.block = block;
}
 
Example 10
public BlockEventQuery(Event event, BlockState block) {
    this(event, block.getWorld(), block.getX(), block.getY(), block.getZ(), block);
}
 
Example 11
public BlockQuery(BlockState block) {
    this(block.getWorld(), block.getX(), block.getY(), block.getZ(), block);
}
 
Example 12
public static String format(BlockState state) {
    return "BlockState{pos=(" + state.getX() + ", " + state.getY() + ", " + state.getZ() +
           ") material=" + state.getMaterialData() + "}";
}
 
Example 13
public static BlockVector position(BlockState block) {
    return new BlockVector(block.getX(), block.getY(), block.getZ());
}
 
Example 14
Source Project: Modern-LWC   File: LWC.java    License: MIT License 3 votes vote down vote up
/**
 * Find a protection linked to the block at [x, y, z]
 *
 * @param block
 * @param block2
 * @return
 */

@SuppressWarnings("deprecation")
public boolean blockEquals(BlockState block, BlockState block2) {
    return block.getType() == block2.getType() && block.getX() == block2.getX() && block.getY() == block2.getY()
            && block.getZ() == block2.getZ() && block.getRawData() == block2.getRawData();
}