Search in sources :

Example 31 with RfToolsDimensionManager

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

the class DimensionMonitorItem method addInformation.

//    @SideOnly(Side.CLIENT)
//    @Override
//    public IIcon getIconIndex(ItemStack stack) {
//        EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
//        int id = player.worldObj.provider.dimensionId;
//        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.worldObj);
//        int energyLevel = storage.getEnergyLevel(id);
//        int level = (9*energyLevel) / DimletConfiguration.MAX_DIMENSION_POWER;
//        if (level < 0) {
//            level = 0;
//        } else if (level > 8) {
//            level = 8;
//        }
//        return powerLevel[8-level];
//    }
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    int id = player.getEntityWorld().provider.getDimension();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManagerNullable(player.getEntityWorld());
    DimensionInformation dimensionInformation = dimensionManager == null ? null : dimensionManager.getDimensionInformation(id);
    if (dimensionInformation == null) {
        list.add("Not an RFTools dimension!");
    } else {
        if (System.currentTimeMillis() - lastTime > 500) {
            lastTime = System.currentTimeMillis();
            RFToolsDimMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
        }
        String name = dimensionInformation.getName();
        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
        int power = storage != null ? storage.getEnergyLevel(id) : 0;
        list.add(TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
        list.add(TextFormatting.YELLOW + "Power: " + power + " RF");
    }
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) PacketGetDimensionEnergy(mcjty.rftoolsdim.network.PacketGetDimensionEnergy)

Aggregations

RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)31 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)22 World (net.minecraft.world.World)14 ItemStack (net.minecraft.item.ItemStack)8 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 TextComponentString (net.minecraft.util.text.TextComponentString)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)4 BlockPos (net.minecraft.util.math.BlockPos)4 Block (net.minecraft.block.Block)3 IBlockState (net.minecraft.block.state.IBlockState)3 File (java.io.File)2 IOException (java.io.IOException)2 DimletKey (mcjty.rftoolsdim.dimensions.dimlets.DimletKey)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 IMob (net.minecraft.entity.monster.IMob)2 IAnimals (net.minecraft.entity.passive.IAnimals)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2