Search in sources :

Example 6 with AxisAlignedBB

use of cn.nukkit.math.AxisAlignedBB 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

AxisAlignedBB (cn.nukkit.math.AxisAlignedBB)6 Entity (cn.nukkit.entity.Entity)3 SimpleAxisAlignedBB (cn.nukkit.math.SimpleAxisAlignedBB)3 Vector3 (cn.nukkit.math.Vector3)2 Block (cn.nukkit.block.Block)1 BlockFire (cn.nukkit.block.BlockFire)1 BlockIgniteEvent (cn.nukkit.event.block.BlockIgniteEvent)1 MovingObjectPosition (cn.nukkit.level.MovingObjectPosition)1