当前位置: 首页>>代码示例>>Java>>正文


Java Block.collidesWithBB方法代码示例

本文整理汇总了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;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:25,代码来源:Level.java

示例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;
}
 
开发者ID:WetABQ,项目名称:Nukkit-AntiCheat,代码行数:22,代码来源:CheckBB.java

示例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;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:14,代码来源:Entity.java

示例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);
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:30,代码来源:Level.java


注:本文中的cn.nukkit.block.Block.collidesWithBB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。