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 };
}
}
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();
}
}
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();
}
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."));
}
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");
}
}
}
Aggregations