Search in sources :

Example 1 with IMetaTileEntity

use of gregtech.api.interfaces.metatileentity.IMetaTileEntity in project NewHorizonsCoreMod by GTNewHorizons.

the class GT_Block_CasingsNH method getIcon.

@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) {
    int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord);
    if (tMeta > 0 && tMeta < 9 || tMeta == 15) {
        return getIcon(aSide, tMeta);
    }
    if (tMeta != 0 || (!mConnectedMachineTextures)) {
        return getIcon(aSide, tMeta);
    }
    if (aSide == 1) {
        TileEntity tTileEntity;
        IMetaTileEntity tMetaTileEntity;
        for (int xi = -2; xi <= 2; xi++) {
            for (int zi = -2; zi <= 2; zi++) {
                if (null != (tTileEntity = aWorld.getTileEntity(xCoord + xi, yCoord - 3 < 0 ? 0 : yCoord - 3, zCoord + zi)) && tTileEntity instanceof IGregTechTileEntity && null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()) && tMetaTileEntity instanceof GT_MetaTileEntity_AirFilter) {
                    boolean active = false;
                    if (((IGregTechTileEntity) tTileEntity).isActive())
                        active = true;
                    //check for direction and placement and apply the texture
                    switch(((IGregTechTileEntity) tTileEntity).getFrontFacing()) {
                        case 2:
                            if (xi < 2 && xi > -2 && zi < 1) {
                                //if invalid position ignore (aka too far away)
                                try {
                                    return getTurbineCasing(tMeta, -xi + 1 - zi * 3, active);
                                } catch (Exception e) {
                                    return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
                                }
                            }
                            break;
                        case 3:
                            if (xi < 2 && xi > -2 && zi > -1) {
                                try {
                                    return getTurbineCasing(tMeta, -xi + 1 + (2 - zi) * 3, active);
                                } catch (Exception e) {
                                    return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
                                }
                            }
                            break;
                        case 4:
                            if (zi < 2 && zi > -2 && xi < 1) {
                                try {
                                    return getTurbineCasing(tMeta, -xi + (1 - zi) * 3, active);
                                } catch (Exception e) {
                                    return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
                                }
                            }
                            break;
                        case 5:
                            if (zi < 2 && zi > -2 && xi > -1) {
                                try {
                                    return getTurbineCasing(tMeta, -xi + 2 + (1 - zi) * 3, active);
                                } catch (Exception e) {
                                    return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
                                }
                            }
                    }
                }
            }
        }
    }
    return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
}
Also used : IGregTechTileEntity(gregtech.api.interfaces.tileentity.IGregTechTileEntity) IMetaTileEntity(gregtech.api.interfaces.metatileentity.IMetaTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) GT_MetaTileEntity_AirFilter(com.dreammaster.gthandler.multiAirFilter.GT_MetaTileEntity_AirFilter) IGregTechTileEntity(gregtech.api.interfaces.tileentity.IGregTechTileEntity) IMetaTileEntity(gregtech.api.interfaces.metatileentity.IMetaTileEntity) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

GT_MetaTileEntity_AirFilter (com.dreammaster.gthandler.multiAirFilter.GT_MetaTileEntity_AirFilter)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 IMetaTileEntity (gregtech.api.interfaces.metatileentity.IMetaTileEntity)1 IGregTechTileEntity (gregtech.api.interfaces.tileentity.IGregTechTileEntity)1 TileEntity (net.minecraft.tileentity.TileEntity)1