Search in sources :

Example 1 with TileEntityBase

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

the class BlockPneumaticCraft method rotateBlock.

@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection side) {
    if (player.isSneaking()) {
        if (!player.capabilities.isCreativeMode)
            dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
        world.setBlockToAir(x, y, z);
        return true;
    } else {
        if (isRotatable()) {
            int meta = world.getBlockMetadata(x, y, z);
            if (!rotateCustom(world, x, y, z, side, meta)) {
                int newMeta;
                if (rotateForgeWay()) {
                    if (!canRotateToTopOrBottom())
                        side = ForgeDirection.UP;
                    newMeta = ForgeDirection.getOrientation(meta).getRotation(side).ordinal();
                    world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
                } else {
                    newMeta = (meta + 1) % 6;
                    if (!canRotateToTopOrBottom()) {
                        if (newMeta == 0) {
                            newMeta = 2;
                        }
                    }
                }
                world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
            }
            TileEntity te = world.getTileEntity(x, y, z);
            if (te instanceof TileEntityBase) {
                ((TileEntityBase) te).onBlockRotated();
            }
            return true;
        } else {
            return false;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBase(pneumaticCraft.common.tileentity.TileEntityBase)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityBase (pneumaticCraft.common.tileentity.TileEntityBase)1