本文整理匯總了Java中com.flowpowered.math.vector.Vector3i.getY方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector3i.getY方法的具體用法?Java Vector3i.getY怎麽用?Java Vector3i.getY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.flowpowered.math.vector.Vector3i
的用法示例。
在下文中一共展示了Vector3i.getY方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: computeRemoveBlockLight
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
private void computeRemoveBlockLight(Vector3i loc, byte currentLight, Queue<LightRemoveData> removalQueue, Queue<Vector3i> spreadQueue, TLongSet removalVisited, TLongSet spreadVisited) {
if (loc.getY() >= 256) {
return;
}
ChunkSection section = getOrCreateSection(loc.getY() / 16);
byte presentLight = section.getBlockLight(loc.getX(), loc.getY() % 16, loc.getZ());
long idx = xyzIdx(loc.getX(), loc.getY(), loc.getZ());
if (presentLight != 0 && presentLight < currentLight) {
section.setBlockLight(loc.getX(), loc.getY() % 16, loc.getZ(), (byte) 0);
if (removalVisited.add(idx)) {
if (presentLight > 1) {
removalQueue.add(new LightRemoveData(loc, presentLight));
}
}
} else if (presentLight >= currentLight) {
if (spreadVisited.add(idx)) {
spreadQueue.add(loc);
}
}
}
示例3: computeSpreadBlockLight
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
private void computeSpreadBlockLight(Vector3i loc, byte currentLight, Queue<Vector3i> spreadQueue, TLongSet spreadVisited) {
if (loc.getY() >= 256) {
return;
}
ChunkSection section = getOrCreateSection(loc.getY() / 16);
byte presentLight = section.getBlockLight(loc.getX(), loc.getY() % 16, loc.getZ());
long idx = xyzIdx(loc.getX(), loc.getY(), loc.getZ());
if (presentLight < currentLight) {
section.setBlockLight(loc.getX(), loc.getY() % 16, loc.getZ(), currentLight);
if (spreadVisited.add(idx)) {
if (presentLight > 1) {
spreadQueue.add(loc);
}
}
}
}
示例4: getAxisValue
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public static int getAxisValue(EnumFacing.Axis axis, Vector3i vector) {
switch (axis) {
case X:
return vector.getX();
case Y:
return vector.getY();
case Z:
return vector.getZ();
default:
throw new AssertionError("the hell is the " + axis + " axis? I exist in the 3d plane alone!");
}
}
示例5: expandRegionVertically
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
@Override
public String expandRegionVertically() {
Vector3i p1 = region.getPos1();
Vector3i p2 = region.getPos2();
if (p1.getY() >= p2.getY()) {
region.setPos1(new Vector3i(p1.getX(), 255, p1.getZ()));
region.setPos2(new Vector3i(p2.getX(), 0, p2.getZ()));
} else {
region.setPos1(new Vector3i(p1.getX(), 0, p1.getZ()));
region.setPos2(new Vector3i(p2.getX(), 255, p2.getZ()));
}
return "Expanded the selection vertically.";
}
示例6: isBlockAir
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
/**
* Vérifie les 2 blocks du corps
* @param world
* @param vector
* @return
*/
private boolean isBlockAir(final World world, final Vector3i vector) {
if (vector.getY() > world.getBlockMax().getY()) {
return true;
} else if (vector.getY() == world.getBlockMax().getY()) {
return MATERIALS_EMPTY.contains(world.getBlock(vector).getType().getId());
} else {
return MATERIALS_EMPTY.contains(world.getBlock(vector).getType().getId()) && MATERIALS_EMPTY.contains(world.getBlock(vector.add(0, 1, 0)).getType().getId());
}
}
示例7: 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();
}
示例8: 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();
}
示例9: Vector3iView
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public Vector3iView(Vector3i value) {
super(value);
this.x = value.getX();
this.y = value.getY();
this.z = value.getZ();
}
示例10: processBlock
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
@Override
protected void processBlock(World world, Vector3i pos) {
int x = pos.getX() - min.getX();
int y = pos.getY() - min.getY();
int z = pos.getZ() - min.getZ();
blockStates[x][y][z] = world.getBlock(pos).copy();
}
示例11: isOnGround
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
default boolean isOnGround() {
Vector3i blockPosition = getPosition().sub(0f, 0.1f, 0f).toInt();
if (blockPosition.getY() < 0) {
return false;
}
int chunkX = blockPosition.getX() >> 4;
int chunkZ = blockPosition.getZ() >> 4;
int chunkInX = blockPosition.getX() & 0x0f;
int chunkInZ = blockPosition.getZ() & 0x0f;
Optional<Chunk> chunkOptional = getLevel().getChunkIfLoaded(chunkX, chunkZ);
return chunkOptional.isPresent() && chunkOptional.get().getBlock(chunkInX, blockPosition.getY(), chunkInZ).getBlockState().getBlockType() != BlockTypes.AIR;
}
示例12: updateProgress
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
private void updateProgress(Vector3i pipePos, Direction dest, boolean toCenter) {
Vector3d target = pipePos.toDouble().add(0.5, 0.3, 0.5);
if (!toCenter) {
target = target.add(dest.asOffset().mul(0.5));
}
double dist;
if (dest == Direction.WEST) {// (-1, 0, 0)
dist = this.pos.getX() - pipePos.getX();
} else if (dest == Direction.EAST) {// (1, 0, 0)
dist = (pipePos.getX() + 1) - this.pos.getX();
} else if (dest == Direction.NORTH) {// (0, 0, -1
dist = this.pos.getZ() - pipePos.getZ();
} else if (dest == Direction.SOUTH) {// (0, 0, 1)
dist = (pipePos.getZ() + 1) - this.pos.getZ();
} else if (dest == Direction.UP) {// (0, 1, 0)
dist = (pipePos.getY() + 0.8) - this.pos.getY();
} else if (dest == Direction.DOWN) {// (0, -1, 0)
dist = (this.pos.getY() + 0.3) - pipePos.getY();
} else {
return;
}
if (toCenter) {
dist -= 0.5;
}
if (dist <= 0) { // On or past the target
this.pos = target;
this.itemStand.setLocation(this.itemStand.getLocation().setPosition(target));
this.finish = true;
} else {
this.finish = false;
}
}
示例13: toChunk
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
public static Vector3i toChunk(Vector3i v) {
// NOT EQUAL TO DIVIDING BY 16!
return new Vector3i(v.getX() >> 4, v.getY() >> 4, v.getZ() >> 4);
}
示例14: getArea
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
@Override
public int getArea() {
Vector3i dim = getDimensions();
return dim.getX() * dim.getY() * dim.getZ();
}
示例15: open
import com.flowpowered.math.vector.Vector3i; //導入方法依賴的package包/類
@Override
public void open(Player player, Manager manager) {
PlayerOpenCrateEvent open_event = new PlayerOpenCrateEvent(player, manager);
Sponge.getEventManager().post(open_event);
if (open_event.isCancelled()) return;
Location<World> location = player.getLocation();
Vector3i position = player.getLocation().getBlockPosition();
World world = location.getExtent();
int loc_x = position.getX();
int loc_y = position.getY();
int loc_z = position.getZ();
HashMap<Location<World>, BlockState> original_block_states = new HashMap<Location<World>, BlockState>();
for (int x = -2; x <= 2; x++) {
for (int y = -1; y <= 3; y++) {
for (int z = -2; z <= 2; z++) {
Location loc = new Location<World>(
world, loc_x + x, loc_y + y, loc_z + z);
BlockState loc_state = loc.getBlock();
original_block_states.put(loc, loc_state);
location.setBlockType(BlockTypes.AIR, BlockChangeFlags.NONE);
}
}
}
for (int x = -2; x <= 2; x++) {
for (int z = -2; z <= 2; z++) {
new Location<World>(world, loc_x + x, loc_y - 1, loc_z + z).
setBlockType(floor_block_type, BlockChangeFlags.NONE);
if (z == 2 || z == -2 || x == 2 || x == -2) {
new Location<World>(world, loc_x + x, loc_y , loc_z + z).
setBlockType(fence_block_type, BlockChangeFlags.NONE);
}
}
}
HashSet<HologramsService.Hologram> holograms = new HashSet<HologramsService.Hologram>();
Location<World> loc1 = new Location<World>(world, loc_x + 2, loc_y, loc_z);
loc1.setBlock(BlockState.builder().
blockType(crate_block_type).
add(Keys.DIRECTION, Direction.WEST).
build(),
BlockChangeFlags.NONE);
Location<World> loc2 = new Location<World>(world, loc_x - 2, loc_y, loc_z);
loc2.setBlock(BlockState.builder().
blockType(crate_block_type).
add(Keys.DIRECTION, Direction.EAST).
build(),
BlockChangeFlags.NONE);
Location<World> loc3 = new Location<World>(world, loc_x, loc_y, loc_z + 2);
loc3.setBlock(BlockState.builder().
blockType(crate_block_type).
add(Keys.DIRECTION, Direction.NORTH).
build(),
BlockChangeFlags.NONE);
Location<World> loc4 = new Location<World>(world, loc_x, loc_y, loc_z - 2);
loc4.setBlock(BlockState.builder().
blockType(crate_block_type).
add(Keys.DIRECTION, Direction.SOUTH).
build(),
BlockChangeFlags.NONE);
Utils.tryCreateHologram(loc1, hologram).ifPresent(holograms::add);
Utils.tryCreateHologram(loc2, hologram).ifPresent(holograms::add);
Utils.tryCreateHologram(loc3, hologram).ifPresent(holograms::add);
Utils.tryCreateHologram(loc4, hologram).ifPresent(holograms::add);
getOpenSound().ifPresent(sound -> player.playSound(sound, player.getLocation().getPosition(), 1.));
PLAYERS_OPENING_ANIMATION1.put(player, new Information(this, manager,
new HashMap<Location<World>, Boolean>(){{
put(loc1, false);
put(loc2, false);
put(loc3, false);
put(loc4, false);
}}, original_block_states, holograms));
}