当前位置: 首页>>代码示例>>Java>>正文


Java Location.getRelative方法代码示例

本文整理汇总了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;
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:19,代码来源:BlockBreakListener.java

示例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();
}
 
开发者ID:prism,项目名称:Keys,代码行数:33,代码来源:WorldUtil.java


注:本文中的org.spongepowered.api.world.Location.getRelative方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。