Search in sources :

Example 1 with IRenderableTile

use of forestry.core.tiles.IRenderableTile in project ForestryMC by ForestryMC.

the class TankManager method updateTankLevels.

private void updateTankLevels(StandardTank tank, boolean sendUpdate) {
    if (!(tile instanceof IRenderableTile)) {
        return;
    }
    int tankIndex = tank.getTankIndex();
    EnumTankLevel tankLevel = EnumTankLevel.rateTankLevel(tank);
    if (tankLevel != tankLevels.get(tankIndex)) {
        tankLevels.set(tankIndex, tankLevel);
        if (sendUpdate) {
            PacketTankLevelUpdate tankLevelUpdate = new PacketTankLevelUpdate(tile, tankIndex, tank.getFluid());
            NetworkUtil.sendNetworkPacket(tankLevelUpdate, tile.getCoordinates(), tile.getWorldObj());
        }
    }
}
Also used : EnumTankLevel(forestry.core.render.EnumTankLevel) IRenderableTile(forestry.core.tiles.IRenderableTile) PacketTankLevelUpdate(forestry.core.network.packets.PacketTankLevelUpdate)

Example 2 with IRenderableTile

use of forestry.core.tiles.IRenderableTile in project ForestryMC by ForestryMC.

the class RenderMachine method render.

/**
 * @param tile If it null its render the item else it render the tile entity.
 */
@Override
public void render(TileBase tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (tile != null) {
        IRenderableTile generator = (IRenderableTile) tile;
        World worldObj = tile.getWorldObj();
        if (worldObj.isBlockLoaded(tile.getPos())) {
            IBlockState blockState = worldObj.getBlockState(tile.getPos());
            if (blockState.getBlock() instanceof BlockBase) {
                EnumFacing facing = blockState.getValue(BlockBase.FACING);
                render(generator.getResourceTankInfo(), generator.getProductTankInfo(), facing, x, y, z, destroyStage);
                return;
            }
        }
    }
    render(TankRenderInfo.EMPTY, TankRenderInfo.EMPTY, EnumFacing.SOUTH, x, y, z, -1);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockBase(forestry.core.blocks.BlockBase) IRenderableTile(forestry.core.tiles.IRenderableTile) EnumFacing(net.minecraft.util.EnumFacing) World(net.minecraft.world.World)

Aggregations

IRenderableTile (forestry.core.tiles.IRenderableTile)2 BlockBase (forestry.core.blocks.BlockBase)1 PacketTankLevelUpdate (forestry.core.network.packets.PacketTankLevelUpdate)1 EnumTankLevel (forestry.core.render.EnumTankLevel)1 IBlockState (net.minecraft.block.state.IBlockState)1 EnumFacing (net.minecraft.util.EnumFacing)1 World (net.minecraft.world.World)1