Search in sources :

Example 1 with TileEntityPneumaticDoor

use of pneumaticCraft.common.tileentity.TileEntityPneumaticDoor in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoor method rotateBlock.

@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection face) {
    int meta = world.getBlockMetadata(x, y, z);
    if (meta < 6) {
        super.rotateBlock(world, player, x, y, z, face);
        world.setBlockMetadataWithNotify(x, y + 1, z, world.getBlockMetadata(x, y, z) + 6, 3);
        TileEntity te = world.getTileEntity(x, y, z);
        if (te instanceof TileEntityPneumaticDoor) {
            ((TileEntityPneumaticDoor) te).rightGoing = true;
            ((TileEntityPneumaticDoor) te).setRotation(0);
            TileEntity topDoor = world.getTileEntity(x, y + 1, z);
            if (topDoor instanceof TileEntityPneumaticDoor) {
                ((TileEntityPneumaticDoor) topDoor).sendDescriptionPacket();
            }
        }
    } else {
        return rotateBlock(world, player, x, y - 1, z, face);
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoor(pneumaticCraft.common.tileentity.TileEntityPneumaticDoor)

Example 2 with TileEntityPneumaticDoor

use of pneumaticCraft.common.tileentity.TileEntityPneumaticDoor in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoor method setBlockBoundsBasedOnState.

@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
    if (isTrackingPlayerEye) {
        setBlockBounds(0, 0, 0, 1, 1, 1);
    } else {
        float xMin = 0;
        float zMin = 0;
        float xMax = 1;
        float zMax = 1;
        TileEntity te = blockAccess.getTileEntity(x, y, z);
        int meta = blockAccess.getBlockMetadata(x, y, z);
        if (te instanceof TileEntityPneumaticDoor) {
            TileEntityPneumaticDoor door = (TileEntityPneumaticDoor) te;
            float cosinus = 13 / 16F - (float) Math.sin(Math.toRadians(door.rotation)) * 13 / 16F;
            float sinus = 13 / 16F - (float) Math.cos(Math.toRadians(door.rotation)) * 13 / 16F;
            if (door.rightGoing) {
                switch(ForgeDirection.getOrientation(meta % 6)) {
                    case NORTH:
                        zMin = cosinus;
                        xMax = 1 - sinus;
                        break;
                    case WEST:
                        xMin = cosinus;
                        zMin = sinus;
                        break;
                    case SOUTH:
                        zMax = 1 - cosinus;
                        xMin = sinus;
                        break;
                    case EAST:
                        xMax = 1 - cosinus;
                        zMax = 1 - sinus;
                        break;
                }
            } else {
                switch(ForgeDirection.getOrientation(meta % 6)) {
                    case NORTH:
                        zMin = cosinus;
                        xMin = sinus;
                        break;
                    case WEST:
                        xMin = cosinus;
                        zMax = 1 - sinus;
                        break;
                    case SOUTH:
                        zMax = 1 - cosinus;
                        xMax = 1 - sinus;
                        break;
                    case EAST:
                        xMax = 1 - cosinus;
                        zMin = sinus;
                        break;
                }
            }
        }
        setBlockBounds(xMin, meta < 6 ? 0 : -1, zMin, xMax, meta < 6 ? 2 : 1, zMax);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoor(pneumaticCraft.common.tileentity.TileEntityPneumaticDoor)

Example 3 with TileEntityPneumaticDoor

use of pneumaticCraft.common.tileentity.TileEntityPneumaticDoor in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoorBase method updateDoorSide.

private void updateDoorSide(TileEntityPneumaticDoorBase doorBase) {
    TileEntity teDoor = doorBase.getWorldObj().getTileEntity(doorBase.xCoord + doorBase.orientation.offsetX, doorBase.yCoord, doorBase.zCoord + doorBase.orientation.offsetZ);
    if (teDoor instanceof TileEntityPneumaticDoor) {
        TileEntityPneumaticDoor door = (TileEntityPneumaticDoor) teDoor;
        if (doorBase.orientation.getRotation(ForgeDirection.UP) == ForgeDirection.getOrientation(door.getBlockMetadata() % 6) && door.rightGoing || doorBase.orientation.getRotation(ForgeDirection.DOWN) == ForgeDirection.getOrientation(door.getBlockMetadata() % 6) && !door.rightGoing) {
            door.rightGoing = !door.rightGoing;
            door.setRotation(0);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityPneumaticDoor(pneumaticCraft.common.tileentity.TileEntityPneumaticDoor)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)3 TileEntityPneumaticDoor (pneumaticCraft.common.tileentity.TileEntityPneumaticDoor)3