本文整理汇总了Java中cn.nukkit.math.Vector3.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3.getY方法的具体用法?Java Vector3.getY怎么用?Java Vector3.getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.math.Vector3
的用法示例。
在下文中一共展示了Vector3.getY方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustPosToNearbyEntity
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
public Vector3 adjustPosToNearbyEntity(Vector3 pos) {
pos.y = this.getHighestBlockAt(pos.getFloorX(), pos.getFloorZ());
AxisAlignedBB axisalignedbb = new AxisAlignedBB(pos.x, pos.y, pos.z, pos.getX(), 255, pos.getZ()).expand(3, 3, 3);
List<Entity> list = new ArrayList<>();
for (Entity entity : this.getCollidingEntities(axisalignedbb)) {
if (entity.isAlive() && canBlockSeeSky(entity)) {
list.add(entity);
}
}
if (!list.isEmpty()) {
return list.get(this.rand.nextInt(list.size())).getPosition();
} else {
if (pos.getY() == -1) {
pos = pos.up(2);
}
return pos;
}
}
示例2: isSpaceAt
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
/**
* returns whether or not there is space for a tree to grow at a certain position
*/
private boolean isSpaceAt(ChunkManager worldIn, Vector3 leavesPos, int height) {
boolean flag = true;
if (leavesPos.getY() >= 1 && leavesPos.getY() + height + 1 <= 256) {
for (int i = 0; i <= 1 + height; ++i) {
int j = 2;
if (i == 0) {
j = 1;
} else if (i >= 1 + height - 2) {
j = 2;
}
for (int k = -j; k <= j && flag; ++k) {
for (int l = -j; l <= j && flag; ++l) {
Vector3 blockPos = leavesPos.add(k, i, l);
if (leavesPos.getY() + i < 0 || leavesPos.getY() + i >= 256 || !this.canGrowInto(worldIn.getBlockIdAt((int) blockPos.x, (int) blockPos.y, (int) blockPos.z))) {
flag = false;
}
}
}
}
return flag;
} else {
return false;
}
}
示例3: ensureDirtsUnderneath
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
/**
* returns whether or not there is dirt underneath the block where the tree will be grown.
* It also generates dirt around the block in a 2x2 square if there is dirt underneath the blockpos.
*/
private boolean ensureDirtsUnderneath(Vector3 pos, ChunkManager worldIn) {
Vector3 blockpos = pos.down();
int block = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);
if ((block == Block.GRASS || block == Block.DIRT) && pos.getY() >= 2) {
this.setDirtAt(worldIn, blockpos);
this.setDirtAt(worldIn, blockpos.east());
this.setDirtAt(worldIn, blockpos.south());
this.setDirtAt(worldIn, blockpos.south().east());
return true;
} else {
return false;
}
}
示例4: vectorToLocation
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
private Location vectorToLocation(Level baseLevel, Vector3 vector) {
if (vector instanceof Location) return (Location) vector;
if (vector instanceof Position) return ((Position) vector).getLocation();
return new Location(vector.getX(), vector.getY(), vector.getZ(), 0, 0, baseLevel);
}
示例5: add
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
@Override
public Position add(Vector3 x) {
return new Position(this.x + x.getX(), this.y + x.getY(), this.z + x.getZ(), this.level);
}
示例6: generate
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position) {
int height = this.getHeight(rand);
if (!this.ensureGrowable(level, rand, position, height)) {
return false;
} else {
this.createCrown(level, position.up(height), 2);
for (int j = (int) position.getY() + height - 2 - rand.nextBoundedInt(4); j > position.getY() + height / 2; j -= 2 + rand.nextBoundedInt(4)) {
float f = rand.nextFloat() * ((float) Math.PI * 2F);
int k = (int) (position.getX() + (0.5F + MathHelper.cos(f) * 4.0F));
int l = (int) (position.getZ() + (0.5F + MathHelper.sin(f) * 4.0F));
for (int i1 = 0; i1 < 5; ++i1) {
k = (int) (position.getX() + (1.5F + MathHelper.cos(f) * (float) i1));
l = (int) (position.getZ() + (1.5F + MathHelper.sin(f) * (float) i1));
this.setBlockAndNotifyAdequately(level, new Vector3(k, j - 3 + i1 / 2, l), this.woodMetadata);
}
int j2 = 1 + rand.nextBoundedInt(2);
int j1 = j;
for (int k1 = j - j2; k1 <= j1; ++k1) {
int l1 = k1 - j1;
this.growLeavesLayer(level, new Vector3(k, k1, l), 1 - l1);
}
}
for (int i2 = 0; i2 < height; ++i2) {
Vector3 blockpos = position.up(i2);
if (this.canGrowInto(level.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z))) {
this.setBlockAndNotifyAdequately(level, blockpos, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos.west(), 8);
this.placeVine(level, rand, blockpos.north(), 1);
}
}
if (i2 < height - 1) {
Vector3 blockpos1 = blockpos.east();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos1.x, (int) blockpos1.y, (int) blockpos1.z))) {
this.setBlockAndNotifyAdequately(level, blockpos1, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos1.east(), 2);
this.placeVine(level, rand, blockpos1.north(), 1);
}
}
Vector3 blockpos2 = blockpos.south().east();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos2.x, (int) blockpos2.y, (int) blockpos2.z))) {
this.setBlockAndNotifyAdequately(level, blockpos2, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos2.east(), 2);
this.placeVine(level, rand, blockpos2.south(), 4);
}
}
Vector3 blockpos3 = blockpos.south();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos3.x, (int) blockpos3.y, (int) blockpos3.z))) {
this.setBlockAndNotifyAdequately(level, blockpos3, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos3.west(), 8);
this.placeVine(level, rand, blockpos3.south(), 4);
}
}
}
}
return true;
}
}
示例7: add
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
@Override
public Location add(Vector3 x) {
return new Location(this.x + x.getX(), this.y + x.getY(), this.z + x.getZ(), this.yaw, this.pitch, this.level);
}
示例8: setFlyingVelocityMod
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
public void setFlyingVelocityMod(Vector3 flying) {
Objects.requireNonNull(flying, "Flying velocity modifiers cannot be null");
flyingX = flying.getX();
flyingY = flying.getY();
flyingZ = flying.getZ();
}
示例9: setDerailedVelocityMod
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
public void setDerailedVelocityMod(Vector3 derailed) {
Objects.requireNonNull(derailed, "Derailed velocity modifiers cannot be null");
derailedX = derailed.getX();
derailedY = derailed.getY();
derailedZ = derailed.getZ();
}
示例10: canBlockSeeSky
import cn.nukkit.math.Vector3; //导入方法依赖的package包/类
public boolean canBlockSeeSky(Vector3 pos) {
return this.getHighestBlockAt(pos.getFloorX(), pos.getFloorZ()) < pos.getY();
}