本文整理汇总了Java中cn.nukkit.math.Vector3类的典型用法代码示例。如果您正苦于以下问题:Java Vector3类的具体用法?Java Vector3怎么用?Java Vector3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector3类属于cn.nukkit.math包,在下文中一共展示了Vector3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isBlockIndirectlyGettingPowered
import cn.nukkit.math.Vector3; //导入依赖的package包/类
public int isBlockIndirectlyGettingPowered(Vector3 pos) {
int power = 0;
for (BlockFace face : BlockFace.values()) {
int blockPower = this.getRedstonePower(pos.getSide(face), face);
if (blockPower >= 15) {
return 15;
}
if (blockPower > power) {
power = blockPower;
}
}
return power;
}
示例2: knockBack
import cn.nukkit.math.Vector3; //导入依赖的package包/类
public void knockBack(Entity attacker, double damage, double x, double z, double base) {
double f = Math.sqrt(x * x + z * z);
if (f <= 0) {
return;
}
f = 1 / f;
Vector3 motion = new Vector3(this.motionX, this.motionY, this.motionZ);
motion.x /= 2d;
motion.y /= 2d;
motion.z /= 2d;
motion.x += x * f * base;
motion.y += base;
motion.z += z * f * base;
if (motion.y > base) {
motion.y = base;
}
this.setMotion(motion);
}
示例3: canPowered
import cn.nukkit.math.Vector3; //导入依赖的package包/类
protected boolean canPowered(Vector3 pos, Rail.Orientation state, int power, boolean relative) {
Block block = level.getBlock(pos);
// What! My block is air??!! Impossible! XD
if (!(block instanceof BlockRailPowered)) {
return false;
}
// Sometimes the rails are diffrent orientation
Rail.Orientation base = ((BlockRailPowered) block).getOrientation();
// Possible way how to know when the rail is activated is rail were directly powered
// OR recheck the surrounding... Which will returns here =w=
return (state != Rail.Orientation.STRAIGHT_EAST_WEST
|| base != Rail.Orientation.STRAIGHT_NORTH_SOUTH
&& base != Rail.Orientation.ASCENDING_NORTH
&& base != Rail.Orientation.ASCENDING_SOUTH)
&& (state != Rail.Orientation.STRAIGHT_NORTH_SOUTH
|| base != Rail.Orientation.STRAIGHT_EAST_WEST
&& base != Rail.Orientation.ASCENDING_EAST
&& base != Rail.Orientation.ASCENDING_WEST)
&& (level.isBlockPowered(pos) || checkSurrounding(pos, relative, power + 1));
}
示例4: onUpdate
import cn.nukkit.math.Vector3; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_RANDOM) {
//TODO: light levels
NukkitRandom random = new NukkitRandom();
x = random.nextRange((int) x - 1, (int) x + 1);
y = random.nextRange((int) y - 1, (int) y + 1);
z = random.nextRange((int) z - 1, (int) z + 1);
Block block = this.getLevel().getBlock(new Vector3(x, y, z));
if (block.getId() == Block.DIRT) {
if (block.up() instanceof BlockTransparent) {
BlockSpreadEvent ev = new BlockSpreadEvent(block, this, new BlockMycelium());
Server.getInstance().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
this.getLevel().setBlock(block, ev.getNewState());
}
}
}
}
return 0;
}
示例5: populate
import cn.nukkit.math.Vector3; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
Vector3 v = new Vector3();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
new NewSavannaTree().generate(level, random, v.setComponents(x, y, z));
}
}
示例6: getIndirectPower
import cn.nukkit.math.Vector3; //导入依赖的package包/类
private int getIndirectPower() {
int power = 0;
Vector3 pos = getLocation();
for (BlockFace face : BlockFace.values()) {
int blockPower = this.getIndirectPower(pos.getSide(face), face);
if (blockPower >= 15) {
return 15;
}
if (blockPower > power) {
power = blockPower;
}
}
return power;
}
示例7: getEffectiveFlowDecay
import cn.nukkit.math.Vector3; //导入依赖的package包/类
protected int getEffectiveFlowDecay(Vector3 pos) {
if (!(pos instanceof Block)) {
pos = this.getLevel().getBlock(pos);
}
if (((Block) pos).getId() != this.getId()) {
return -1;
}
int decay = ((Block) pos).getDamage();
if (decay >= 8) {
decay = 0;
}
return decay;
}
示例8: canPowered
import cn.nukkit.math.Vector3; //导入依赖的package包/类
protected boolean canPowered(Vector3 pos, Rail.Orientation state, int power, boolean relative) {
Block block = level.getBlock(pos);
// What! My block is air??!! Impossible! XD
if (!(block instanceof BlockRailPowered)) {
return false;
}
// Sometimes the rails are diffrent orientation
Rail.Orientation base = ((BlockRailPowered) block).getOrientation();
// Possible way how to know when the rail is activated is rail were directly powered
// OR recheck the surrounding... Which will returns here =w=
return (state != Rail.Orientation.STRAIGHT_EAST_WEST
|| base != Rail.Orientation.STRAIGHT_NORTH_SOUTH
&& base != Rail.Orientation.ASCENDING_NORTH
&& base != Rail.Orientation.ASCENDING_SOUTH)
&& (state != Rail.Orientation.STRAIGHT_NORTH_SOUTH
|| base != Rail.Orientation.STRAIGHT_EAST_WEST
&& base != Rail.Orientation.ASCENDING_EAST
&& base != Rail.Orientation.ASCENDING_WEST)
&& (level.isBlockPowered(pos) || checkSurrounding(pos, relative, power + 1));
}
示例9: canPowered
import cn.nukkit.math.Vector3; //导入依赖的package包/类
protected boolean canPowered(Vector3 pos, Rail.Orientation state, int power, boolean relative) {
Block block = level.getBlock(pos);
if (!(block instanceof BlockRailActivator)) {
return false;
}
Rail.Orientation base = ((BlockRailActivator) block).getOrientation();
return (state != Rail.Orientation.STRAIGHT_EAST_WEST
|| base != Rail.Orientation.STRAIGHT_NORTH_SOUTH
&& base != Rail.Orientation.ASCENDING_NORTH
&& base != Rail.Orientation.ASCENDING_SOUTH)
&& (state != Rail.Orientation.STRAIGHT_NORTH_SOUTH
|| base != Rail.Orientation.STRAIGHT_EAST_WEST
&& base != Rail.Orientation.ASCENDING_EAST
&& base != Rail.Orientation.ASCENDING_WEST)
&& (level.isBlockPowered(pos) || checkSurrounding(pos, relative, power + 1));
}
示例10: 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;
}
}
示例11: onOpen
import cn.nukkit.math.Vector3; //导入依赖的package包/类
@Override
public void onOpen(Player who) {
super.onOpen(who);
ContainerOpenPacket pk = new ContainerOpenPacket();
pk.windowid = (byte) who.getWindowId(this);
pk.type = (byte) this.getType().getNetworkType();
InventoryHolder holder = this.getHolder();
if (holder instanceof Vector3) {
pk.x = (int) ((Vector3) holder).getX();
pk.y = (int) ((Vector3) holder).getY();
pk.z = (int) ((Vector3) holder).getZ();
} else {
pk.x = pk.y = pk.z = 0;
}
who.dataPacket(pk);
this.sendContents(who);
}
示例12: populate
import cn.nukkit.math.Vector3; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
this.level = level;
int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
Vector3 v = new Vector3();
for (int i = 0; i < amount; ++i) {
int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
int y = this.getHighestWorkableBlock(x, z);
if (y == -1) {
continue;
}
new ObjectSwampTree().generate(level, random, v.setComponents(x, y, z));
}
}
示例13: checkState
import cn.nukkit.math.Vector3; //导入依赖的package包/类
private void checkState() {
BlockFace facing = getFacing();
boolean isPowered = this.isPowered();
if (isPowered && !isExtended()) {
if ((new BlocksCalculator(this.level, this, facing, true)).canMove()) {
if (!this.doMove(true)) {
return;
}
this.level.addSound(new PistonOutSound(this));
} else {
}
} else if (!isPowered && isExtended()) {
//this.level.setBlock() TODO: set piston extension?
if (this.sticky) {
Vector3 pos = this.add(facing.getXOffset() * 2, facing.getYOffset() * 2, facing.getZOffset() * 2);
Block block = this.level.getBlock(pos);
if (block.getId() == AIR) {
this.level.setBlock(this.getLocation().getSide(facing), new BlockAir(), true, true);
}
if (canPush(block, facing.getOpposite(), false) && (!(block instanceof BlockFlowable) || block.getId() == PISTON || block.getId() == STICKY_PISTON)) {
this.doMove(false);
}
} else {
this.level.setBlock(getLocation().getSide(facing), new BlockAir(), true, false);
}
this.level.addSound(new PistonInSound(this));
}
}
示例14: onUpdate
import cn.nukkit.math.Vector3; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_NORMAL) {
Block down = down();
if (down.getId() != SAND && down.getId() != CACTUS) {
this.getLevel().useBreakOn(this);
} else {
for (int side = 2; side <= 5; ++side) {
Block block = getSide(BlockFace.fromIndex(side));
if (!block.canBeFlowedInto()) {
this.getLevel().useBreakOn(this);
}
}
}
} else if (type == Level.BLOCK_UPDATE_RANDOM) {
if (down().getId() != CACTUS) {
if (this.meta == 0x0F) {
for (int y = 1; y < 3; ++y) {
Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z));
if (b.getId() == AIR) {
BlockGrowEvent event = new BlockGrowEvent(b, new BlockCactus());
Server.getInstance().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.getLevel().setBlock(b, event.getNewState(), true);
}
}
}
this.meta = 0;
this.getLevel().setBlock(this, this);
} else {
++this.meta;
this.getLevel().setBlock(this, this);
}
}
}
return 0;
}
示例15: onBreak
import cn.nukkit.math.Vector3; //导入依赖的package包/类
@Override
public boolean onBreak(Item item) {
this.getLevel().setBlock(this, new BlockAir(), true, true);
Vector3 pos = getLocation();
for (BlockFace side : BlockFace.values()) {
this.level.updateAroundRedstone(pos.getSide(side), null);
}
return true;
}