Search in sources :

Example 1 with IDescription

use of stevekung.mods.moreplanets.utils.IDescription 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 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 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)));
                    }
                }
                if (tile instanceof TileEntityDarkEnergyGenerator) {
                    if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("DarkEnergyFuel") && itemStack.getTagCompound().hasKey("Items")) {
                        int fuelValue = 0;
                        NBTTagList listTag = itemStack.getTagCompound().getTagList("Items", NBT.TAG_COMPOUND);
                        for (int i = 0; i < listTag.tagCount(); ++i) {
                            NBTTagCompound compound = listTag.getCompoundTagAt(i);
                            int slot = compound.getByte("Slot") & 255;
                            ItemStack darkEnergyFuel = new ItemStack(compound);
                            if (slot == 2 && darkEnergyFuel.getItem() instanceof IDarkEnergyFuel) {
                                IDarkEnergyFuel fuel = (IDarkEnergyFuel) darkEnergyFuel.getItem();
                                fuelValue = fuel.getDarkEnergyFuel();
                            }
                        }
                        int power = itemStack.getTagCompound().getInteger("DarkEnergyFuel");
                        power = power * 100 / fuelValue;
                        list.add(TextFormatting.GREEN + LangUtils.translate("desc.dark_energy_fuel.name", power) + "%");
                    }
                }
            }
            list.add(LangUtils.translate("desc.shift_info.name"));
        }
    }
}
Also used : BlockTileMP(stevekung.mods.moreplanets.utils.blocks.BlockTileMP) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) IDescription(stevekung.mods.moreplanets.utils.IDescription) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityDarkEnergyGenerator(stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator) TileBaseUniversalElectrical(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical) ItemStack(net.minecraft.item.ItemStack) IDarkEnergyFuel(stevekung.mods.moreplanets.utils.items.IDarkEnergyFuel) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IDescription

use of stevekung.mods.moreplanets.utils.IDescription 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 3 with IDescription

use of stevekung.mods.moreplanets.utils.IDescription 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.moreplanets_other.enableDescriptionInWaila) {
        if (block instanceof IDescription) {
            IDescription desc = (IDescription) block;
            if (ClientUtils.isShiftKeyDown()) {
                desc.getDescription().addDescription(itemStack, tooltip);
            } else {
                tooltip.add(LangUtils.translate("desc.shift_info.name"));
            }
        }
        // block
        if (block.getClass().equals(BlockDummy.class)) {
            TileEntityDummy dummy = (TileEntityDummy) tile;
            if (accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock() instanceof IDescription) {
                IDescription desc = (IDescription) accessor.getWorld().getBlockState(dummy.mainBlockPosition).getBlock();
                if (ClientUtils.isShiftKeyDown()) {
                    desc.getDescription().addDescription(itemStack, tooltip);
                } else {
                    tooltip.add(LangUtils.translate("desc.shift_info.name"));
                }
            }
        }
    }
    return tooltip;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IDescription(stevekung.mods.moreplanets.utils.IDescription) Block(net.minecraft.block.Block)

Example 4 with IDescription

use of stevekung.mods.moreplanets.utils.IDescription 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

TileEntity (net.minecraft.tileentity.TileEntity)4 IDescription (stevekung.mods.moreplanets.utils.IDescription)4 TileBaseUniversalElectrical (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 BlockTileMP (stevekung.mods.moreplanets.utils.blocks.BlockTileMP)3 TileBaseElectricBlock (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock)2 BlockAdvancedTileMP (stevekung.mods.moreplanets.utils.blocks.BlockAdvancedTileMP)2 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 TileEntityDarkEnergyGenerator (stevekung.mods.moreplanets.planets.diona.tileentity.TileEntityDarkEnergyGenerator)1 IDarkEnergyFuel (stevekung.mods.moreplanets.utils.items.IDarkEnergyFuel)1