Search in sources :

Example 1 with IRotatable

use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.

the class BlockContainerBase method getIcon.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    if (textures == null)
        return super.getIcon(world, x, y, z, side);
    TileEntity te = get(world, x, y, z);
    RendererBlockBase.EnumFaceType faceType = EnumFaceType.SIDE;
    boolean powered = false;
    boolean ejecting = false;
    if (te instanceof IRotatable) {
        ForgeDirection rotation = ((IRotatable) te).getFacingDirection();
        if (rotation.ordinal() == side)
            faceType = EnumFaceType.FRONT;
        if (rotation.getOpposite().ordinal() == side)
            faceType = EnumFaceType.BACK;
    }
    if (te instanceof IBluePowered) {
        powered = ((IBluePowered) te).isPowered();
    }
    if (te instanceof IEjectAnimator) {
        ejecting = ((IEjectAnimator) te).isEjecting();
    }
    return getIcon(faceType, ejecting, powered, side, te);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFaceType(com.bluepowermod.client.render.RendererBlockBase.EnumFaceType) IBluePowered(com.bluepowermod.tile.IBluePowered) IRotatable(com.bluepowermod.tile.IRotatable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IEjectAnimator(com.bluepowermod.tile.IEjectAnimator) RendererBlockBase(com.bluepowermod.client.render.RendererBlockBase) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with IRotatable

use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.

the class BlockContainerBase method onBlockPlacedBy.

/**
     * Method to detect how the block was placed, and what way it's facing.
     */
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack iStack) {
    BPApi.getInstance().loadSilkySettings(world, x, y, z, iStack);
    TileEntity te = get(world, x, y, z);
    if (te instanceof IRotatable) {
        ((IRotatable) te).setFacingDirection(ForgeDirectionUtils.getDirectionFacing(player, canRotateVertical()).getOpposite());
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IRotatable(com.bluepowermod.tile.IRotatable)

Example 3 with IRotatable

use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.

the class BlockIgniter method rotateBlock.

@Override
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
    TileEntity te = worldObj.getTileEntity(x, y, z);
    if (te instanceof IRotatable) {
        IRotatable rotatable = (IRotatable) te;
        ForgeDirection dir = rotatable.getFacingDirection();
        Block target = worldObj.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
        if (target == Blocks.fire || target == Blocks.portal) {
            worldObj.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, Blocks.air);
        }
        dir = dir.getRotation(axis);
        if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN || canRotateVertical()) {
            rotatable.setFacingDirection(dir);
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IRotatable(com.bluepowermod.tile.IRotatable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block)

Example 4 with IRotatable

use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.

the class BlockProjectTable method getIcon.

@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    IRotatable rotatable = (IRotatable) world.getTileEntity(x, y, z);
    ForgeDirection s = ForgeDirection.getOrientation(side);
    if (rotatable.getFacingDirection() == s) {
        return textureFront;
    }
    switch(s) {
        case UP:
            return textureTop;
        case DOWN:
            return textureBottom;
        case EAST:
        case NORTH:
        case SOUTH:
        case WEST:
        case UNKNOWN:
            return textureSide;
        default:
            break;
    }
    return null;
}
Also used : IRotatable(com.bluepowermod.tile.IRotatable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 5 with IRotatable

use of com.bluepowermod.tile.IRotatable in project BluePower by Qmunity.

the class RendererBlockBase method renderWorldBlock.

/*
     * UV Deobfurscation derp: West = South East = North North = East South = West
     */
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof IRotatable) {
        switch(((IRotatable) te).getFacingDirection()) {
            case DOWN:
                renderer.uvRotateSouth = 3;
                renderer.uvRotateNorth = 3;
                renderer.uvRotateEast = 3;
                renderer.uvRotateWest = 3;
                break;
            case NORTH:
                renderer.uvRotateSouth = 1;
                renderer.uvRotateNorth = 2;
                break;
            case SOUTH:
                renderer.uvRotateSouth = 2;
                renderer.uvRotateNorth = 1;
                renderer.uvRotateTop = 3;
                renderer.uvRotateBottom = 3;
                break;
            case WEST:
                renderer.uvRotateEast = 1;
                renderer.uvRotateWest = 2;
                renderer.uvRotateTop = 2;
                renderer.uvRotateBottom = 1;
                break;
            case EAST:
                renderer.uvRotateEast = 2;
                renderer.uvRotateWest = 1;
                renderer.uvRotateTop = 1;
                renderer.uvRotateBottom = 2;
                break;
            default:
                break;
        }
    }
    boolean ret = renderer.renderStandardBlock(block, x, y, z);
    renderer.uvRotateSouth = 0;
    renderer.uvRotateEast = 0;
    renderer.uvRotateWest = 0;
    renderer.uvRotateNorth = 0;
    renderer.uvRotateTop = 0;
    renderer.uvRotateBottom = 0;
    return ret;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IRotatable(com.bluepowermod.tile.IRotatable)

Aggregations

IRotatable (com.bluepowermod.tile.IRotatable)6 TileEntity (net.minecraft.tileentity.TileEntity)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 RendererBlockBase (com.bluepowermod.client.render.RendererBlockBase)1 EnumFaceType (com.bluepowermod.client.render.RendererBlockBase.EnumFaceType)1 IBluePowered (com.bluepowermod.tile.IBluePowered)1 IEjectAnimator (com.bluepowermod.tile.IEjectAnimator)1 Block (net.minecraft.block.Block)1