當前位置: 首頁>>代碼示例>>Java>>正文


Java Vector3i.sub方法代碼示例

本文整理匯總了Java中com.flowpowered.math.vector.Vector3i.sub方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector3i.sub方法的具體用法?Java Vector3i.sub怎麽用?Java Vector3i.sub使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.flowpowered.math.vector.Vector3i的用法示例。


在下文中一共展示了Vector3i.sub方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBlock

import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public Optional<Transform<World>> getBlock(final Transform<World> location, final boolean safe) {
	int max = location.getExtent().getBlockMax().getY() + 1;
	Vector3i destinationMax = new Vector3i(location.getLocation().getBlockX(), location.getLocation().getBlockY(), location.getLocation().getBlockZ());
	Vector3i destinationMin = new Vector3i(location.getLocation().getBlockX(), location.getLocation().getBlockY() - 1, location.getLocation().getBlockZ());
	Vector3i destination = null;
	while (destination == null && (destinationMin.getY() >= 0 || destinationMax.getY() <= max)) {
		if (destinationMax.getY() <= max && isBlock(location.getExtent(), destinationMax, safe)) {
			destination = destinationMax;
		} else if (destinationMin.getY() > 0 && isBlock(location.getExtent(), destinationMin, safe)) {
			destination = destinationMin;
		}
		if (destination == null) {
			if (destinationMax.getY() <= max) {
				destinationMax = destinationMax.add(0, 1, 0);
			}
			if (destinationMin.getY() >= 0) {
				destinationMin = destinationMin.sub(0, 1, 0);
			}
		}
	}
	if (destination != null){
		return Optional.of(location.setPosition(destination.toDouble().add(0.5, 0, 0.5)));
	}
	return Optional.empty();
}
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:26,代碼來源:UtilsLocation.java

示例2: addTarget

import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public void addTarget(BlockSnapshot pistonBlock, EnhancedCustomBlock block, BlockData blockData,
        Vector3i blockPos) {
    Direction pistonFacing = pistonBlock.getState().get(Keys.DIRECTION).get();
    boolean isRetracting;
    if (pistonBlock.getState().getType() == BlockTypes.PISTON_EXTENSION) {
        // Followed up from sticky piston - retraction has cause of the piston extension
        // See CustomBlockEventListeners#getPistonCause
        isRetracting = true;
    } else {
        isRetracting = pistonBlock.getState().get(Keys.EXTENDED).get();
    }
    Vector3i destPos;
    if (isRetracting) {
        destPos = blockPos.sub(pistonFacing.asBlockOffset());
    } else {
        destPos = blockPos.add(pistonFacing.asBlockOffset());
    }
    this.locations.put(destPos, new Tuple<>(blockPos, new ImmutablePair<>(block, blockData)));
}
 
開發者ID:simon816,項目名稱:Industrialization,代碼行數:20,代碼來源:WorldManager.java

示例3: isPositionSafe

import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public boolean isPositionSafe(final Transform<World> location) {
	Vector3i position = location.getLocation().getBlockPosition().sub(0, 1, 0);
	
	if (MATERIALS_EMPTY.contains(location.getExtent().getBlock(position).getType().getId())) {
		position = position.sub(0, 1, 0);
	}
	
	return !MATERIALS_DAMAGE.contains(location.getExtent().getBlock(position).getType().getId()) && 
			!MATERIALS_EMPTY.contains(location.getExtent().getBlock(position).getType().getId()) &&
			isBlockAir(location.getExtent(), position.add(0, 1, 0));
}
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:12,代碼來源:UtilsLocation.java

示例4: getMaxBlock

import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public Optional<Transform<World>> getMaxBlock(final Transform<World> location, final boolean safe) {
	Vector3i destination = new Vector3i(location.getLocation().getBlockX(), location.getExtent().getBlockMax().getY() + 1, location.getLocation().getBlockZ());

	while (!isBlock(location.getExtent(), destination, safe) && destination.getY() > 1) {
		destination = destination.sub(0, 1, 0);
	}
	if (destination.getY() > 1){
		return Optional.of(location.setPosition(destination.toDouble().add(0.5, 0, 0.5)));
	}
	return Optional.empty();
}
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:12,代碼來源:UtilsLocation.java

示例5: getBlockBottom

import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public Optional<Transform<World>> getBlockBottom(final Transform<World> location) {
	Vector3i destination = new Vector3i(location.getLocation().getBlockX(), location.getLocation().getBlockY() + 1, location.getLocation().getBlockZ());

	while (!isBlock(location.getExtent(), destination, false) && destination.getY() > 1) {
		destination = destination.sub(0, 1, 0);
	}
	if (destination.getY() > 1){
		return Optional.of(location.setPosition(destination.toDouble().add(0.5, 1, 0.5)));
	}
	return Optional.empty();
}
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:12,代碼來源:UtilsLocation.java


注:本文中的com.flowpowered.math.vector.Vector3i.sub方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。