Search in sources :

Example 6 with DimensionStorage

use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.

the class DimensionMonitorItem method getIconIndex.

@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];
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 7 with DimensionStorage

use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.

the class DimensionMonitorItem method addInformation.

@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    int id = player.worldObj.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.worldObj);
    DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
    if (dimensionInformation == null) {
        list.add("Not an RFTools dimension!");
    } else {
        if (System.currentTimeMillis() - lastTime > 500) {
            lastTime = System.currentTimeMillis();
            RFToolsMessages.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(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
        list.add(EnumChatFormatting.YELLOW + "Power: " + power + " RF");
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) PacketGetDimensionEnergy(mcjty.rftools.dimension.network.PacketGetDimensionEnergy)

Example 8 with DimensionStorage

use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.

the class GenericWorldProvider method getRespawnDimension.

@Override
public int getRespawnDimension(EntityPlayerMP player) {
    getDimensionInformation();
    if (DimletConfiguration.respawnSameDim || (dimensionInformation != null && dimensionInformation.isRespawnHere())) {
        DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(worldObj);
        int power = dimensionStorage.getEnergyLevel(dimensionId);
        if (power < 1000) {
            return DimletConfiguration.spawnDimension;
        } else {
            return dimensionId;
        }
    }
    return DimletConfiguration.spawnDimension;
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage)

Example 9 with DimensionStorage

use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.

the class CmdSetPower method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int rf = fetchInt(sender, args, 1, DimletConfiguration.MAX_DIMENSION_POWER);
    World world = sender.getEntityWorld();
    int dim = world.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
    storage.setEnergyLevel(dim, rf);
    storage.save(world);
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 10 with DimensionStorage

use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.

the class PacketGetDimensionEnergy method onMessage.

@Override
public PacketReturnEnergy onMessage(PacketGetDimensionEnergy message, MessageContext ctx) {
    World world = ctx.getServerHandler().playerEntity.worldObj;
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
    return new PacketReturnEnergy(message.dimension, dimensionStorage.getEnergyLevel(message.dimension));
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World)

Aggregations

DimensionStorage (mcjty.rftools.dimension.DimensionStorage)20 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)11 World (net.minecraft.world.World)10 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)8 ChatComponentText (net.minecraft.util.ChatComponentText)4 TileEntity (net.minecraft.tileentity.TileEntity)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 File (java.io.File)2 IOException (java.io.IOException)2 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)2 Coordinate (mcjty.lib.varia.Coordinate)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)2 PacketGetDimensionEnergy (mcjty.rftools.dimension.network.PacketGetDimensionEnergy)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IEnergyConnection (cofh.api.energy.IEnergyConnection)1 Map (java.util.Map)1 GenericEnergyProviderTileEntity (mcjty.lib.entity.GenericEnergyProviderTileEntity)1 DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)1