Java Code Examples for net.minecraft.util.AxisAlignedBB#offset()

The following examples show how to use net.minecraft.util.AxisAlignedBB#offset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 4 votes vote down vote up
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) {
    TileEntityGarden te = getGardenEntity(world, x, y, z);
    if (te == null)
        return null;

    BlockGarden garden = getGardenBlock(world, x, y, z);
    if (garden == null)
        return null;

    int baseY = getBaseBlockYCoord(world, x, y, z);

    AxisAlignedBB aabb = null;
    for (int slot : garden.getSlotProfile().getPlantSlots()) {
        Block block = getPlantBlock(te, slot);
        if (block == null)
            continue;

        bindSlot(world, x, y, z, te, slot);
        try {
            AxisAlignedBB sub = block.getCollisionBoundingBoxFromPool(world, x, y, z);
            if (sub == null)
                continue;

            float offsetX = garden.getSlotProfile().getPlantOffsetX(world, x, baseY, z, slot);
            float offsetY = garden.getSlotProfile().getPlantOffsetY(world, x, baseY, z, slot);
            float offsetZ = garden.getSlotProfile().getPlantOffsetZ(world, x, baseY, z, slot);
            sub.offset(offsetX, offsetY, offsetZ);

            if (aabb == null)
                aabb = sub;
            else
                aabb = aabb.func_111270_a(sub); // Union
        }
        catch (Exception e) {
            continue;
        }
        finally {
            unbindSlot(world, x, y, z, te);
        }
    }

    return aabb;
}
 
Example 2
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 4 votes vote down vote up
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z) {
    TileEntityGarden te = getGardenEntity(world, x, y, z);
    BlockGarden garden = getGardenBlock(world, x, y, z);
    if (te == null || garden == null)
        return super.getSelectedBoundingBoxFromPool(world, x, y, z);

    int baseY = getBaseBlockYCoord(world, x, y, z);

    AxisAlignedBB aabb = null;
    for (int slot : garden.getSlotProfile().getPlantSlots()) {
        Block block = getPlantBlock(te, slot);
        if (block == null)
            continue;

        bindSlot(world, x, y, z, te, slot);
        try {
            AxisAlignedBB sub = block.getSelectedBoundingBoxFromPool(world, x, y, z);
            if (sub == null)
                continue;

            float offsetX = garden.getSlotProfile().getPlantOffsetX(world, x, baseY, z, slot);
            float offsetY = garden.getSlotProfile().getPlantOffsetY(world, x, baseY, z, slot);
            float offsetZ = garden.getSlotProfile().getPlantOffsetZ(world, x, baseY, z, slot);
            sub.offset(offsetX, offsetY, offsetZ);

            if (aabb == null)
                aabb = sub;
            else
                aabb = aabb.func_111270_a(sub); // Union
        }
        catch (Exception e) {
            continue;
        }
        finally {
            unbindSlot(world, x, y, z, te);
        }
    }

    if (aabb == null)
        aabb = super.getSelectedBoundingBoxFromPool(world, x, y, z);

    return aabb;
}
 
Example 3
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 4 votes vote down vote up
@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB mask, List list, Entity colliding) {
    TileEntityGarden te = getGardenEntity(world, x, y, z);
    BlockGarden garden = getGardenBlock(world, x, y, z);
    if (te == null || garden == null) {
        super.addCollisionBoxesToList(world, x, y, z, mask, list, colliding);
        return;
    }

    int baseY = getBaseBlockYCoord(world, x, y, z);

    for (int slot : garden.getSlotProfile().getPlantSlots()) {
        Block block = getPlantBlock(te, slot);
        if (block == null)
            continue;

        bindSlot(world, x, y, z, te, slot);
        try {
            AxisAlignedBB sub = block.getCollisionBoundingBoxFromPool(world, x, y, z);
            if (sub == null)
                continue;

            float offsetX = garden.getSlotProfile().getPlantOffsetX(world, x, baseY, z, slot);
            float offsetY = garden.getSlotProfile().getPlantOffsetY(world, x, baseY, z, slot);
            float offsetZ = garden.getSlotProfile().getPlantOffsetZ(world, x, baseY, z, slot);
            sub.offset(offsetX, offsetY, offsetZ);

            if (mask.intersectsWith(sub))
                list.add(sub);
        }
        catch (Exception e) {
            continue;
        }
        finally {
            unbindSlot(world, x, y, z, te);
        }
    }

    if (list.isEmpty())
        super.addCollisionBoxesToList(world, x, y, z, mask, list, colliding);
}