本文整理匯總了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();
}
示例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)));
}
示例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));
}
示例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();
}
示例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();
}