Search in sources :

Example 1 with IBlockDescription

use of stevekung.mods.moreplanets.util.blocks.IBlockDescription in project MorePlanets by SteveKunG.

the class ItemBlockDarkEnergyGenerator method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World world, List<String> list, ITooltipFlag flag) {
    if (this.getBlock() instanceof IBlockDescription) {
        if (CommonRegisterHelper.isShiftKeyDown()) {
            ((IBlockDescription) this.block).getDescription().addDescription(itemStack, list);
        } else {
            if (this.getBlock() instanceof BlockTileGC) {
                TileEntity te = ((BlockTileGC) this.getBlock()).createTileEntity(null, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
                if (te instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
                if (te instanceof TileBaseUniversalElectrical) {
                    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
                        int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
                        list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
                    }
                }
                if (te instanceof TileEntityDarkEnergyGenerator) {
                    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("DarkEnergyFuel")) {
                        int power = itemStack.getTagCompound().getInteger("DarkEnergyFuel");
                        power = power * 100 / 1000;
                        list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("desc.dark_energy_fuel.name", power) + "%");
                    }
                }
            } else if (this.getBlock() instanceof BlockAdvancedTile) {
                TileEntity te = ((BlockAdvancedTile) this.getBlock()).createTileEntity(world, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
                if (te instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
            }
            list.add(GCCoreUtil.translate("desc.shift_info.name"));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileBaseElectricBlock(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock) IBlockDescription(stevekung.mods.moreplanets.util.blocks.IBlockDescription) BlockTileGC(micdoodle8.mods.galacticraft.core.blocks.BlockTileGC) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator) BlockAdvancedTile(micdoodle8.mods.galacticraft.core.blocks.BlockAdvancedTile) TileBaseUniversalElectrical(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IBlockDescription

use of stevekung.mods.moreplanets.util.blocks.IBlockDescription in project MorePlanets by SteveKunG.

the class WailaTileEntityProviderMP method getWailaBody.

@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    TileEntity tile = accessor.getTileEntity();
    Block block = accessor.getBlock();
    if (ConfigManagerMP.enableDescriptionInWaila) {
        if (block instanceof IBlockDescription) {
            IBlockDescription desc = (IBlockDescription) block;
            if (CommonRegisterHelper.isShiftKeyDown()) {
                desc.getDescription().addDescription(itemStack, tooltip);
            } else {
                tooltip.add(GCCoreUtil.translate("desc.shift_info.name"));
            }
        }
        // block
        if (block == MPBlocks.DUMMY_BLOCK) {
            TileEntityDummy dummy = (TileEntityDummy) tile;
            if (accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock() instanceof IBlockDescription) {
                IBlockDescription desc = (IBlockDescription) accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock();
                if (CommonRegisterHelper.isShiftKeyDown()) {
                    desc.getDescription().addDescription(itemStack, tooltip);
                } else {
                    tooltip.add(GCCoreUtil.translate("desc.shift_info.name"));
                }
            }
        }
    }
    return tooltip;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Block(net.minecraft.block.Block) IBlockDescription(stevekung.mods.moreplanets.util.blocks.IBlockDescription)

Example 3 with IBlockDescription

use of stevekung.mods.moreplanets.util.blocks.IBlockDescription 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 IBlockDescription) {
        if (CommonRegisterHelper.isShiftKeyDown()) {
            ((IBlockDescription) this.block).getDescription().addDescription(itemStack, list);
        } else {
            if (this.getBlock() instanceof BlockTileGC) {
                TileEntity te = ((BlockTileGC) this.getBlock()).createTileEntity(null, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
                if (te instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
                if (te instanceof TileBaseUniversalElectrical) {
                    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("EnergyStored")) {
                        int power = (int) itemStack.getTagCompound().getFloat("EnergyStored");
                        list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("desc.energy_stored.name", EnergyDisplayHelper.getEnergyDisplayS(power)));
                    }
                }
            } else if (this.getBlock() instanceof BlockAdvancedTile) {
                TileEntity te = ((BlockAdvancedTile) this.getBlock()).createTileEntity(world, this.getBlock().getStateFromMeta(itemStack.getItemDamage() & 12));
                if (te instanceof TileBaseElectricBlock) {
                    float powerDrawn = ((TileBaseElectricBlock) te).storage.getMaxExtract();
                    if (powerDrawn > 0) {
                        list.add(TextFormatting.GREEN + GCCoreUtil.translateWithFormat("item_desc.powerdraw.name", EnergyDisplayHelper.getEnergyDisplayS(powerDrawn * 20)));
                    }
                }
            }
            list.add(GCCoreUtil.translate("desc.shift_info.name"));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileBaseElectricBlock(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock) IBlockDescription(stevekung.mods.moreplanets.util.blocks.IBlockDescription) BlockTileGC(micdoodle8.mods.galacticraft.core.blocks.BlockTileGC) BlockAdvancedTile(micdoodle8.mods.galacticraft.core.blocks.BlockAdvancedTile) TileBaseUniversalElectrical(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)3 IBlockDescription (stevekung.mods.moreplanets.util.blocks.IBlockDescription)3 BlockAdvancedTile (micdoodle8.mods.galacticraft.core.blocks.BlockAdvancedTile)2 BlockTileGC (micdoodle8.mods.galacticraft.core.blocks.BlockTileGC)2 TileBaseElectricBlock (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock)2 TileBaseUniversalElectrical (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Block (net.minecraft.block.Block)1 TileEntityDarkEnergyGenerator (stevekung.mods.moreplanets.module.planets.diona.tileentity.TileEntityDarkEnergyGenerator)1