Search in sources :

Example 1 with BlockAdvancedTileMP

use of stevekung.mods.moreplanets.utils.blocks.BlockAdvancedTileMP in project MorePlanets by SteveKunG.

the class ItemBlockDescriptionTESR method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World world, List<String> list, ITooltipFlag flag) {
    if (this.getBlock() instanceof IDescription) {
        if (ClientUtils.isShiftKeyDown()) {
            ((IDescription) this.block).getDescription().addDescription(itemStack, list);
        } else {
            if (this.getBlock() instanceof BlockTileMP) {
                TileEntity tile = ((BlockTileMP) this.getBlock()).createNewTileEntity(null, 0);
                if (tile instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
                if (tile instanceof TileBaseUniversalElectrical) {
                    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
                        int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
                        list.add(TextFormatting.GREEN + LangUtils.translate("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
                    }
                }
            } else if (this.getBlock() instanceof BlockAdvancedTileMP) {
                TileEntity tile = ((BlockAdvancedTileMP) this.getBlock()).createNewTileEntity(null, 0);
                if (tile instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
            }
            list.add(LangUtils.translate("desc.shift_info.name"));
        }
    }
}
Also used : BlockTileMP(stevekung.mods.moreplanets.utils.blocks.BlockTileMP) TileEntity(net.minecraft.tileentity.TileEntity) TileBaseElectricBlock(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock) BlockAdvancedTileMP(stevekung.mods.moreplanets.utils.blocks.BlockAdvancedTileMP) IDescription(stevekung.mods.moreplanets.utils.IDescription) TileBaseUniversalElectrical(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with BlockAdvancedTileMP

use of stevekung.mods.moreplanets.utils.blocks.BlockAdvancedTileMP in project MorePlanets by SteveKunG.

the class ItemBlockDescription method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World world, List<String> list, ITooltipFlag flag) {
    if (this.getBlock() instanceof IDescription) {
        if (ClientUtils.isShiftKeyDown()) {
            ((IDescription) this.block).getDescription().addDescription(itemStack, list);
        } else {
            if (this.getBlock() instanceof BlockTileMP) {
                TileEntity tile = ((BlockTileMP) this.getBlock()).createNewTileEntity(null, 0);
                if (tile instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
                if (tile instanceof TileBaseUniversalElectrical) {
                    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
                        int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
                        list.add(TextFormatting.GREEN + LangUtils.translate("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
                    }
                }
            } else if (this.getBlock() instanceof BlockAdvancedTileMP) {
                TileEntity tile = ((BlockAdvancedTileMP) this.getBlock()).createNewTileEntity(null, 0);
                if (tile instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) tile).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + LangUtils.translate("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
            }
            list.add(LangUtils.translate("desc.shift_info.name"));
        }
    }
}
Also used : BlockTileMP(stevekung.mods.moreplanets.utils.blocks.BlockTileMP) TileEntity(net.minecraft.tileentity.TileEntity) TileBaseElectricBlock(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock) BlockAdvancedTileMP(stevekung.mods.moreplanets.utils.blocks.BlockAdvancedTileMP) IDescription(stevekung.mods.moreplanets.utils.IDescription) TileBaseUniversalElectrical(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

TileBaseElectricBlock (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock)2 TileBaseUniversalElectrical (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical)2 TileEntity (net.minecraft.tileentity.TileEntity)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IDescription (stevekung.mods.moreplanets.utils.IDescription)2 BlockAdvancedTileMP (stevekung.mods.moreplanets.utils.blocks.BlockAdvancedTileMP)2 BlockTileMP (stevekung.mods.moreplanets.utils.blocks.BlockTileMP)2