當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。