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


Java AxisAlignedBB类代码示例

本文整理汇总了Java中cn.nukkit.math.AxisAlignedBB的典型用法代码示例。如果您正苦于以下问题:Java AxisAlignedBB类的具体用法?Java AxisAlignedBB怎么用?Java AxisAlignedBB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AxisAlignedBB类属于cn.nukkit.math包,在下文中一共展示了AxisAlignedBB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: recalculateBoundingBox

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
protected AxisAlignedBB recalculateBoundingBox() {
    boolean north = this.canConnect(this.north());
    boolean south = this.canConnect(this.south());
    boolean west = this.canConnect(this.west());
    boolean east = this.canConnect(this.east());
    double n = north ? 0 : 0.375;
    double s = south ? 1 : 0.625;
    double w = west ? 0 : 0.375;
    double e = east ? 1 : 0.625;
    return new AxisAlignedBB(
            this.x + w,
            this.y,
            this.z + n,
            this.x + e,
            this.y + 1.5,
            this.z + s
    );
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:19,代码来源:BlockFence.java

示例2: recalculateBoundingBox

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
@Override
protected AxisAlignedBB recalculateBoundingBox() {
    if ((this.getDamage() & 0x04) > 0) {
        return null;
    }
    int i = this.getDamage() & 0x03;
    if (i == 2 || i == 0) {
        return new AxisAlignedBB(
                x,
                y,
                z + 0.375,
                x + 1,
                y + 1.5,
                z + 0.625
        );
    } else {
        return new AxisAlignedBB(
                x + 0.375,
                y,
                z,
                x + 0.625,
                y + 1.5,
                z + 1
        );
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:27,代码来源:BlockFenceGate.java

示例3: getPendingBlockUpdates

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
public List<BlockUpdateEntry> getPendingBlockUpdates(AxisAlignedBB boundingBox) {
    List<BlockUpdateEntry> list = null;

    Iterator<BlockUpdateEntry> iterator;

    iterator = this.updateQueue.iterator();

    while (iterator.hasNext()) {
        BlockUpdateEntry entry = iterator.next();
        Vector3 pos = entry.pos;

        if (pos.getX() >= boundingBox.minX && pos.getX() < boundingBox.maxX && pos.getZ() >= boundingBox.minZ && pos.getZ() < boundingBox.maxZ) {
            if (list == null) {
                list = new ArrayList<>();
            }

            list.add(entry);
        }
    }

    return list;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:23,代码来源:Level.java

示例4: hasCollision

import cn.nukkit.math.AxisAlignedBB; //导入依赖的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

示例5: getCollidingEntities

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
public Entity[] getCollidingEntities(AxisAlignedBB bb, Entity entity) {
    List<Entity> nearby = new ArrayList<>();

    if (entity == null || entity.canCollide()) {
        int minX = NukkitMath.floorDouble((bb.minX - 2) / 16);
        int maxX = NukkitMath.ceilDouble((bb.maxX + 2) / 16);
        int minZ = NukkitMath.floorDouble((bb.minZ - 2) / 16);
        int maxZ = NukkitMath.ceilDouble((bb.maxZ + 2) / 16);

        for (int x = minX; x <= maxX; ++x) {
            for (int z = minZ; z <= maxZ; ++z) {
                for (Entity ent : this.getChunkEntities(x, z).values()) {
                    if ((entity == null || (ent != entity && entity.canCollideWith(ent)))
                            && ent.boundingBox.intersectsWith(bb)) {
                        nearby.add(ent);
                    }
                }
            }
        }
    }

    return nearby.stream().toArray(Entity[]::new);
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:24,代码来源:Level.java

示例6: getNearbyEntities

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
public Entity[] getNearbyEntities(AxisAlignedBB bb, Entity entity) {
    List<Entity> nearby = new ArrayList<>();

    int minX = NukkitMath.floorDouble((bb.minX - 2) / 16);
    int maxX = NukkitMath.ceilDouble((bb.maxX + 2) / 16);
    int minZ = NukkitMath.floorDouble((bb.minZ - 2) / 16);
    int maxZ = NukkitMath.ceilDouble((bb.maxZ + 2) / 16);

    for (int x = minX; x <= maxX; ++x) {
        for (int z = minZ; z <= maxZ; ++z) {
            for (Entity ent : this.getChunkEntities(x, z).values()) {
                if (ent != entity && ent.boundingBox.intersectsWith(bb)) {
                    nearby.add(ent);
                }
            }
        }
    }

    return nearby.stream().toArray(Entity[]::new);
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:21,代码来源:Level.java

示例7: isAreaLoaded

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
private boolean isAreaLoaded(AxisAlignedBB bb) {
    if (bb.maxY < 0 || bb.minY >= 256) {
        return false;
    }
    int minX = NukkitMath.floorDouble(bb.minX) >> 4;
    int minZ = NukkitMath.floorDouble(bb.minZ) >> 4;
    int maxX = NukkitMath.floorDouble(bb.maxX) >> 4;
    int maxZ = NukkitMath.floorDouble(bb.maxZ) >> 4;

    for (int x = minX; x <= maxX; ++x) {
        for (int z = minZ; z <= maxZ; ++z) {
            if (!this.isChunkLoaded(x, z)) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:20,代码来源:Level.java

示例8: BlockEntityHopper

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
public BlockEntityHopper(FullChunk chunk, CompoundTag nbt) {
    super(chunk, nbt);

    if (this.namedTag.contains("TransferCooldown")) {
        this.transferCooldown = this.namedTag.getInt("TransferCooldown");
    }

    this.inventory = new HopperInventory(this);

    if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
        this.namedTag.putList(new ListTag<CompoundTag>("Items"));
    }

    for (int i = 0; i < this.getSize(); i++) {
        this.inventory.setItem(i, this.getItem(i));
    }

    this.pickupArea = new AxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 2, this.z + 1);

    this.scheduleUpdate();
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:22,代码来源:BlockEntityHopper.java

示例9: recalculateBoundingBox

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
@Override
protected AxisAlignedBB recalculateBoundingBox() {
    if ((this.meta & 0x08) > 0) {
        return new AxisAlignedBB(
                this.x,
                this.y + 0.5,
                this.z,
                this.x + 1,
                this.y + 1,
                this.z + 1
        );
    } else {
        return new AxisAlignedBB(
                this.x,
                this.y,
                this.z,
                this.x + 1,
                this.y + 0.5,
                this.z + 1
        );
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:23,代码来源:BlockSlab.java

示例10: canUpdate

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
public boolean canUpdate() {
    if (this.getNetworkId() == 0) {
        return false;
    }

    int count = 0;
    boolean hasPlayer = false;
    AxisAlignedBB boundingBox = new AxisAlignedBB(x - 8.5, y - 4.5, z - 8.5, x + 8.5, y + 4.5, z + 8.5);
    for (Entity entity : this.level.getNearbyEntities(boundingBox)) {
        if (entity.getNetworkId() == this.getNetworkId()) {
            ++count;
        }

        if (entity instanceof Player) {
            hasPlayer = true;
        }
    }

    if (hasPlayer && count < 6) {
        return true;
    }

    return false;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:25,代码来源:BlockEntityMobSpawner.java

示例11: recalculateBoundingBox

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
@Override
protected AxisAlignedBB recalculateBoundingBox() {
    if ((this.getDamage() & 0x04) > 0) {
        return new AxisAlignedBB(
                this.x,
                this.y + 0.5,
                this.z,
                this.x + 1,
                this.y + 1,
                this.z + 1
        );
    } else {
        return new AxisAlignedBB(
                this.x,
                this.y,
                this.z,
                this.x + 1,
                this.y + 0.5,
                this.z + 1
        );
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:23,代码来源:BlockStairs.java

示例12: recalculateBoundingBox

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
protected AxisAlignedBB recalculateBoundingBox() {
    return new AxisAlignedBB(
            this.x,
            this.y,
            this.z,
            this.x + 1,
            this.y + 1,
            this.z + 1
    );
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:11,代码来源:Block.java

示例13: recalculateBoundingBox

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
@Override
protected AxisAlignedBB recalculateBoundingBox() {
    if (isActivated()) {
        return new AxisAlignedBB(this.x + 0.0625, this.y, this.z + 0.0625, this.x + 0.9375, this.y + 0.03125, this.z + 0.9375);
    } else {
        return new AxisAlignedBB(this.x + 0.0625, this.y, this.z + 0.0625, this.x + 0.9375, this.y + 0.0625, this.z + 0.9375);
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:9,代码来源:BlockPressurePlateBase.java

示例14: recalculateBoundingBox

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
@Override
protected AxisAlignedBB recalculateBoundingBox() {
    return new AxisAlignedBB(
            this.x,
            this.y,
            this.z,
            this.x + 1,
            this.y + 0.9375,
            this.z + 1
    );
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:12,代码来源:BlockFarmland.java

示例15: computeRedstoneStrength

import cn.nukkit.math.AxisAlignedBB; //导入依赖的package包/类
@Override
protected int computeRedstoneStrength() {
    AxisAlignedBB bb = getCollisionBoundingBox();

    for (Entity entity : this.level.getCollidingEntities(bb)) {
        if (entity.doesTriggerPressurePlate()) {
            return 15;
        }
    }

    return 0;
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:13,代码来源:BlockPressurePlateWood.java


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