本文整理汇总了Java中org.spongepowered.api.world.Location.getBlockType方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getBlockType方法的具体用法?Java Location.getBlockType怎么用?Java Location.getBlockType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.world.Location
的用法示例。
在下文中一共展示了Location.getBlockType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findPartnerBlock
import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
/**
* Find a matching partner block. Must be the same type
* and in one of the four cardinal directions.
*
* @param location Location of source block.
* @return Optional Location of partner.
*/
public static Optional<Location<World>> findPartnerBlock(Location<World> location) {
BlockType type = location.getBlockType();
Location<World> north = location.getRelative(Direction.NORTH);
if (north.getBlockType().equals(type)) {
return Optional.of(north);
}
Location<World> west = location.getRelative(Direction.WEST);
if (west.getBlockType().equals(type)) {
return Optional.of(west);
}
Location<World> south = location.getRelative(Direction.SOUTH);
if (south.getBlockType().equals(type)) {
return Optional.of(south);
}
Location<World> east = location.getRelative(Direction.EAST);
if (east.getBlockType().equals(type)) {
return Optional.of(east);
}
return Optional.empty();
}
示例2: updateBlock
import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
private static void updateBlock(Location<World> block){
if (block.getBlockType() == BlockTypes.AIR)
return;
block.getExtent().sendBlockChange(block.getPosition().toInt(), block.getBlock());
}