本文整理汇总了Java中cn.nukkit.block.Block.collidesWithBB方法的典型用法代码示例。如果您正苦于以下问题:Java Block.collidesWithBB方法的具体用法?Java Block.collidesWithBB怎么用?Java Block.collidesWithBB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.block.Block
的用法示例。
在下文中一共展示了Block.collidesWithBB方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasCollision
import cn.nukkit.block.Block; //导入方法依赖的package包/类
public boolean hasCollision(Entity entity, AxisAlignedBB bb, boolean entities) {
int minX = NukkitMath.floorDouble(bb.minX);
int minY = NukkitMath.floorDouble(bb.minY);
int minZ = NukkitMath.floorDouble(bb.minZ);
int maxX = NukkitMath.ceilDouble(bb.maxX);
int maxY = NukkitMath.ceilDouble(bb.maxY);
int maxZ = NukkitMath.ceilDouble(bb.maxZ);
for (int z = minZ; z <= maxZ; ++z) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
Block block = this.getBlock(this.temporalVector.setComponents(x, y, z));
if (!block.canPassThrough() && block.collidesWithBB(bb)) {
return true;
}
}
}
}
if (entities) {
return this.getCollidingEntities(bb.grow(0.25f, 0.25f, 0.25f), entity).length > 0;
}
return false;
}
示例2: isCheat
import cn.nukkit.block.Block; //导入方法依赖的package包/类
@Override
public boolean isCheat() {
CheckCheatEvent event = new CheckCheatEvent(player, getCheatType());
Server.getInstance().getPluginManager().callEvent(event);
if (player.getGamemode() != 0) event.setCancelled();
if (event.isCancelled()) return false;
double radius = (double) player.getWidth() / 2.0D;
AxisAlignedBB bb = player.getBoundingBox().clone().setBounds(
player.x - radius + 0.2D, player.y + 1.05D, player.z - radius + 0.2D,
player.x + radius - 0.2D, player.y + (double) (player.getHeight() * player.scale), player.z + radius - 0.2D
);
for (Block block : player.getBlocksAround()) {
if (block.collidesWithBB(bb)) {
PlayerCheating event2 = new PlayerCheating(player, getCheatType());
Server.getInstance().getPluginManager().callEvent(event2);
return !event.isCancelled();
//player.teleport(player.getPosition().clone().add(0, 1, 0));
}
}
return false;
}
示例3: getCollisionBlocks
import cn.nukkit.block.Block; //导入方法依赖的package包/类
public List<Block> getCollisionBlocks() {
if (this.collisionBlocks == null) {
this.collisionBlocks = new ArrayList<>();
for (Block b : getBlocksAround()) {
if (b.collidesWithBB(this.getBoundingBox(), true)) {
this.collisionBlocks.add(b);
}
}
}
return this.collisionBlocks;
}
示例4: getCollisionCubes
import cn.nukkit.block.Block; //导入方法依赖的package包/类
public AxisAlignedBB[] getCollisionCubes(Entity entity, AxisAlignedBB bb, boolean entities) {
int minX = NukkitMath.floorDouble(bb.minX);
int minY = NukkitMath.floorDouble(bb.minY);
int minZ = NukkitMath.floorDouble(bb.minZ);
int maxX = NukkitMath.ceilDouble(bb.maxX);
int maxY = NukkitMath.ceilDouble(bb.maxY);
int maxZ = NukkitMath.ceilDouble(bb.maxZ);
List<AxisAlignedBB> collides = new ArrayList<>();
for (int z = minZ; z <= maxZ; ++z) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
Block block = this.getBlock(this.temporalVector.setComponents(x, y, z));
if (!block.canPassThrough() && block.collidesWithBB(bb)) {
collides.add(block.getBoundingBox());
}
}
}
}
if (entities) {
for (Entity ent : this.getCollidingEntities(bb.grow(0.25f, 0.25f, 0.25f), entity)) {
collides.add(ent.boundingBox.clone());
}
}
return collides.stream().toArray(AxisAlignedBB[]::new);
}