Search in sources :

Example 16 with DimensionStorage

use of mcjty.rftoolsdim.dimensions.DimensionStorage in project RFToolsDimensions by McJty.

the class RealizedDimensionTab method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, World world, List<String> list, ITooltipFlag whatIsThis) {
    super.addInformation(itemStack, world, list, whatIsThis);
    NBTTagCompound tagCompound = itemStack.getTagCompound();
    if (tagCompound != null) {
        String name = tagCompound.getString("name");
        int id = 0;
        if (name != null) {
            id = tagCompound.getInteger("id");
            if (id == 0) {
                list.add(TextFormatting.BLUE + "Name: " + name);
            } else {
                list.add(TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
            }
        }
        String descriptionString = tagCompound.getString("descriptionString");
        constructDescriptionHelp(list, descriptionString);
        Integer ticksLeft = tagCompound.getInteger("ticksLeft");
        if (ticksLeft == 0) {
            DimensionInformation information = RfToolsDimensionManager.getDimensionManagerClient().getDimensionInformation(id);
            if (information == null) {
                list.add(TextFormatting.RED + "Dimension information Missing!");
            } else {
                list.add(TextFormatting.BLUE + "Dimension ready!");
                int maintainCost = tagCompound.getInteger("rfMaintainCost");
                int actualCost = information.getActualRfCost();
                if (actualCost == maintainCost || actualCost == 0) {
                    list.add(TextFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
                } else {
                    list.add(TextFormatting.YELLOW + "    Maintenance cost: " + actualCost + " RF/tick (Specified: " + maintainCost + " RF/tick)");
                }
                if (id != 0) {
                    if (System.currentTimeMillis() - lastTime > 500) {
                        lastTime = System.currentTimeMillis();
                        RFToolsDimMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
                    }
                    DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
                    int power = storage.getEnergyLevel(id);
                    list.add(TextFormatting.YELLOW + "    Current power: " + power + " RF");
                }
            }
        } else {
            int createCost = tagCompound.getInteger("rfCreateCost");
            int maintainCost = tagCompound.getInteger("rfMaintainCost");
            int tickCost = tagCompound.getInteger("tickCost");
            int percentage = (tickCost - ticksLeft) * 100 / tickCost;
            list.add(TextFormatting.BLUE + "Dimension progress: " + percentage + "%");
            list.add(TextFormatting.YELLOW + "    Creation cost: " + createCost + " RF/tick");
            list.add(TextFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
            list.add(TextFormatting.YELLOW + "    Tick cost: " + tickCost + " ticks");
        }
    }
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) PacketGetDimensionEnergy(mcjty.rftoolsdim.network.PacketGetDimensionEnergy) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)16 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)11 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)8 World (net.minecraft.world.World)5 PacketGetDimensionEnergy (mcjty.rftoolsdim.network.PacketGetDimensionEnergy)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ITextComponent (net.minecraft.util.text.ITextComponent)3 TextComponentString (net.minecraft.util.text.TextComponentString)3 File (java.io.File)2 IOException (java.io.IOException)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ActionResult (net.minecraft.util.ActionResult)2 EnumActionResult (net.minecraft.util.EnumActionResult)2 Map (java.util.Map)1 GenericEnergyProviderTileEntity (mcjty.lib.entity.GenericEnergyProviderTileEntity)1 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)1 GenericWorldProvider (mcjty.rftoolsdim.dimensions.world.GenericWorldProvider)1 WorldClient (net.minecraft.client.multiplayer.WorldClient)1