Search in sources :

Example 1 with DimensionStorage

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

the class DimensionBuilderTileEntity method getDimensionPower.

private Object[] getDimensionPower() {
    NBTTagCompound tagCompound = hasTab();
    if (tagCompound != null) {
        int id = tagCompound.getInteger("id");
        int power = 0;
        if (id != 0) {
            DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(worldObj);
            power = dimensionStorage.getEnergyLevel(id);
        }
        return new Object[] { power };
    } else {
        return new Object[] { 0 };
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 2 with DimensionStorage

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

the class DimensionMonitorTileEntity method checkStateServer.

@Override
protected void checkStateServer() {
    super.checkStateServer();
    ticker--;
    if (ticker > 0) {
        return;
    }
    ticker = 10;
    DimensionStorage storage = DimensionStorage.getDimensionStorage(worldObj);
    int energy = storage.getEnergyLevel(worldObj.provider.dimensionId);
    int pct = energy / (DimletConfiguration.MAX_DIMENSION_POWER / 100);
    boolean newout = pct < alarmLevel;
    if (newout != redstoneOut) {
        redstoneOut = newout;
        notifyBlockUpdate();
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage)

Example 3 with DimensionStorage

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

the class DialingDeviceTileEntity method checkStatus.

// Server side only
private int checkStatus(Coordinate c, int dim) {
    int cost = TeleportConfiguration.rfPerCheck;
    cost = (int) (cost * (2.0f - getInfusedFactor()) / 2.0f);
    if (getEnergyStored(ForgeDirection.DOWN) < cost) {
        return DialingDeviceTileEntity.DIAL_DIALER_POWER_LOW_MASK;
    }
    consumeEnergy(cost);
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
    World w = dimensionManager.getWorldForDimension(dim);
    if (w == null) {
        TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
        destinations.cleanupInvalid(worldObj);
        return DialingDeviceTileEntity.DIAL_INVALID_DESTINATION_MASK;
    }
    TileEntity tileEntity = w.getTileEntity(c.getX(), c.getY(), c.getZ());
    if (!(tileEntity instanceof MatterReceiverTileEntity)) {
        TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
        destinations.cleanupInvalid(worldObj);
        return DialingDeviceTileEntity.DIAL_INVALID_DESTINATION_MASK;
    }
    if (dimensionManager.getDimensionInformation(dim) != null) {
        // This is an RFTools dimension. Check power.
        DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(w);
        int energyLevel = dimensionStorage.getEnergyLevel(dim);
        if (energyLevel < DimletConfiguration.DIMPOWER_WARN_TP) {
            return DialingDeviceTileEntity.DIAL_DIMENSION_POWER_LOW_MASK;
        }
    }
    MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) tileEntity;
    return matterReceiverTileEntity.checkStatus();
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 4 with DimensionStorage

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

the class CmdDelDimension method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameters is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    dimensionManager.removeDimension(dim);
    dimensionManager.save(world);
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
    dimensionStorage.removeDimension(dim);
    dimensionStorage.save(world);
    sender.addChatMessage(new ChatComponentText("Dimension deleted."));
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 5 with DimensionStorage

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

the class RealizedDimensionTab method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
    super.addInformation(itemStack, player, 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(EnumChatFormatting.BLUE + "Name: " + name);
            } else {
                list.add(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
            }
        }
        String descriptionString = tagCompound.getString("descriptionString");
        constructDescriptionHelp(list, descriptionString);
        Integer ticksLeft = tagCompound.getInteger("ticksLeft");
        if (ticksLeft == 0) {
            DimensionInformation information = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld()).getDimensionInformation(id);
            if (information == null) {
                list.add(EnumChatFormatting.RED + "Dimension information Missing!");
            } else {
                list.add(EnumChatFormatting.BLUE + "Dimension ready!");
                int maintainCost = tagCompound.getInteger("rfMaintainCost");
                int actualCost = information.getActualRfCost();
                if (actualCost == maintainCost || actualCost == 0) {
                    list.add(EnumChatFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
                } else {
                    list.add(EnumChatFormatting.YELLOW + "    Maintenance cost: " + actualCost + " RF/tick (Specified: " + maintainCost + " RF/tick)");
                }
                if (id != 0) {
                    if (System.currentTimeMillis() - lastTime > 500) {
                        lastTime = System.currentTimeMillis();
                        RFToolsMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
                    }
                    DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
                    int power = storage.getEnergyLevel(id);
                    list.add(EnumChatFormatting.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(EnumChatFormatting.BLUE + "Dimension progress: " + percentage + "%");
            list.add(EnumChatFormatting.YELLOW + "    Creation cost: " + createCost + " RF/tick");
            list.add(EnumChatFormatting.YELLOW + "    Maintenance cost: " + maintainCost + " RF/tick");
            list.add(EnumChatFormatting.YELLOW + "    Tick cost: " + tickCost + " ticks");
        }
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) PacketGetDimensionEnergy(mcjty.rftools.dimension.network.PacketGetDimensionEnergy) SideOnly(cpw.mods.fml.relauncher.SideOnly)

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