Search in sources :

Example 1 with SimpleAxisAlignedBB

use of cn.nukkit.math.SimpleAxisAlignedBB in project Nukkit by Nukkit.

the class BlockEntityHopper method initBlockEntity.

@Override
protected void initBlockEntity() {
    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 SimpleAxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 2, this.z + 1);
    this.scheduleUpdate();
    super.initBlockEntity();
}
Also used : HopperInventory(cn.nukkit.inventory.HopperInventory) ListTag(cn.nukkit.nbt.tag.ListTag) SimpleAxisAlignedBB(cn.nukkit.math.SimpleAxisAlignedBB) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Example 2 with SimpleAxisAlignedBB

use of cn.nukkit.math.SimpleAxisAlignedBB in project Nukkit by Nukkit.

the class BlockStairs method collidesWithBB.

@Override
public boolean collidesWithBB(AxisAlignedBB bb) {
    int damage = this.getDamage();
    int side = damage & 0x03;
    double f = 0;
    double f1 = 0.5;
    double f2 = 0.5;
    double f3 = 1;
    if ((damage & 0x04) > 0) {
        f = 0.5;
        f1 = 1;
        f2 = 0;
        f3 = 0.5;
    }
    if (bb.intersectsWith(new SimpleAxisAlignedBB(this.x, this.y + f, this.z, this.x + 1, this.y + f1, this.z + 1))) {
        return true;
    }
    if (side == 0) {
        if (bb.intersectsWith(new SimpleAxisAlignedBB(this.x + 0.5, this.y + f2, this.z, this.x + 1, this.y + f3, this.z + 1))) {
            return true;
        }
    } else if (side == 1) {
        if (bb.intersectsWith(new SimpleAxisAlignedBB(this.x, this.y + f2, this.z, this.x + 0.5, this.y + f3, this.z + 1))) {
            return true;
        }
    } else if (side == 2) {
        if (bb.intersectsWith(new SimpleAxisAlignedBB(this.x, this.y + f2, this.z + 0.5, this.x + 1, this.y + f3, this.z + 1))) {
            return true;
        }
    } else if (side == 3) {
        if (bb.intersectsWith(new SimpleAxisAlignedBB(this.x, this.y + f2, this.z, this.x + 1, this.y + f3, this.z + 0.5))) {
            return true;
        }
    }
    return false;
}
Also used : SimpleAxisAlignedBB(cn.nukkit.math.SimpleAxisAlignedBB)

Example 3 with SimpleAxisAlignedBB

use of cn.nukkit.math.SimpleAxisAlignedBB in project Nukkit by Nukkit.

the class BlockEntityPistonArm method pushEntities.

private void pushEntities() {
    float lastProgress = this.getExtendedProgress(this.lastProgress);
    double x = (double) (lastProgress * (float) this.facing.getXOffset());
    double y = (double) (lastProgress * (float) this.facing.getYOffset());
    double z = (double) (lastProgress * (float) this.facing.getZOffset());
    AxisAlignedBB bb = new SimpleAxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D);
    Entity[] entities = this.level.getCollidingEntities(bb);
    if (entities.length != 0) {
        ;
    }
}
Also used : SimpleAxisAlignedBB(cn.nukkit.math.SimpleAxisAlignedBB) AxisAlignedBB(cn.nukkit.math.AxisAlignedBB) Entity(cn.nukkit.entity.Entity) SimpleAxisAlignedBB(cn.nukkit.math.SimpleAxisAlignedBB)

Example 4 with SimpleAxisAlignedBB

use of cn.nukkit.math.SimpleAxisAlignedBB in project Nukkit by Nukkit.

the class BlockRailDetector method updateState.

protected void updateState() {
    boolean wasPowered = isActive();
    boolean isPowered = false;
    for (Entity entity : level.getNearbyEntities(new SimpleAxisAlignedBB(getFloorX() + 0.125D, getFloorY(), getFloorZ() + 0.125D, getFloorX() + 0.875D, getFloorY() + 0.525D, getFloorZ() + 0.875D))) {
        if (entity instanceof EntityMinecartAbstract) {
            isPowered = true;
        }
    }
    if (isPowered && !wasPowered) {
        setActive(true);
        level.scheduleUpdate(this, this, 0);
        level.scheduleUpdate(this, this.down(), 0);
    }
    if (!isPowered && wasPowered) {
        setActive(false);
        level.scheduleUpdate(this, this, 0);
        level.scheduleUpdate(this, this.down(), 0);
    }
    level.updateComparatorOutputLevel(this);
}
Also used : Entity(cn.nukkit.entity.Entity) EntityMinecartAbstract(cn.nukkit.entity.item.EntityMinecartAbstract) SimpleAxisAlignedBB(cn.nukkit.math.SimpleAxisAlignedBB)

Example 5 with SimpleAxisAlignedBB

use of cn.nukkit.math.SimpleAxisAlignedBB in project Nukkit by Nukkit.

the class BlockDoor method recalculateBoundingBox.

@Override
protected AxisAlignedBB recalculateBoundingBox() {
    double f = 0.1875;
    int damage = this.getFullDamage();
    AxisAlignedBB bb = new SimpleAxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 2, this.z + 1);
    int j = damage & 0x03;
    boolean isOpen = ((damage & 0x04) > 0);
    boolean isRight = ((damage & 0x10) > 0);
    if (j == 0) {
        if (isOpen) {
            if (!isRight) {
                bb.setBounds(this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + f);
            } else {
                bb.setBounds(this.x, this.y, this.z + 1 - f, this.x + 1, this.y + 1, this.z + 1);
            }
        } else {
            bb.setBounds(this.x, this.y, this.z, this.x + f, this.y + 1, this.z + 1);
        }
    } else if (j == 1) {
        if (isOpen) {
            if (!isRight) {
                bb.setBounds(this.x + 1 - f, this.y, this.z, this.x + 1, this.y + 1, this.z + 1);
            } else {
                bb.setBounds(this.x, this.y, this.z, this.x + f, this.y + 1, this.z + 1);
            }
        } else {
            bb.setBounds(this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + f);
        }
    } else if (j == 2) {
        if (isOpen) {
            if (!isRight) {
                bb.setBounds(this.x, this.y, this.z + 1 - f, this.x + 1, this.y + 1, this.z + 1);
            } else {
                bb.setBounds(this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + f);
            }
        } else {
            bb.setBounds(this.x + 1 - f, this.y, this.z, this.x + 1, this.y + 1, this.z + 1);
        }
    } else if (j == 3) {
        if (isOpen) {
            if (!isRight) {
                bb.setBounds(this.x, this.y, this.z, this.x + f, this.y + 1, this.z + 1);
            } else {
                bb.setBounds(this.x + 1 - f, this.y, this.z, this.x + 1, this.y + 1, this.z + 1);
            }
        } else {
            bb.setBounds(this.x, this.y, this.z + 1 - f, this.x + 1, this.y + 1, this.z + 1);
        }
    }
    return bb;
}
Also used : SimpleAxisAlignedBB(cn.nukkit.math.SimpleAxisAlignedBB) AxisAlignedBB(cn.nukkit.math.AxisAlignedBB) SimpleAxisAlignedBB(cn.nukkit.math.SimpleAxisAlignedBB)

Aggregations

SimpleAxisAlignedBB (cn.nukkit.math.SimpleAxisAlignedBB)5 Entity (cn.nukkit.entity.Entity)2 AxisAlignedBB (cn.nukkit.math.AxisAlignedBB)2 EntityMinecartAbstract (cn.nukkit.entity.item.EntityMinecartAbstract)1 HopperInventory (cn.nukkit.inventory.HopperInventory)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 ListTag (cn.nukkit.nbt.tag.ListTag)1