本文整理汇总了Java中org.spongepowered.api.world.Location.getRelative方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getRelative方法的具体用法?Java Location.getRelative怎么用?Java Location.getRelative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.world.Location
的用法示例。
在下文中一共展示了Location.getRelative方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSignAndShop
import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
private boolean isSignAndShop(Location<World> loc, Direction dir, boolean wall) {
if (loc.getRelative(dir).getBlockType() == (wall ? BlockTypes.WALL_SIGN : BlockTypes.STANDING_SIGN)) {
if (wall) {
Location<World> sign = loc.getRelative(dir);
if (sign.supports(Keys.DIRECTION)) {
Optional<Direction> direction = sign.get(Keys.DIRECTION);
if (direction.isPresent()) {
if (direction.get() != dir)
return false;
}
}
}
Optional<List<Shop>> shops = ShopsData.getShops(loc.getRelative(dir));
if (shops.isPresent())
return true;
}
return false;
}
示例2: 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();
}