Search in sources :

Example 1 with BlockTileMP

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

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

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

TileBaseUniversalElectrical (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectrical)3 TileEntity (net.minecraft.tileentity.TileEntity)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 IDescription (stevekung.mods.moreplanets.utils.IDescription)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 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