Make the controller capacity configurable
This commit is contained in:
@@ -64,6 +64,7 @@ public final class RefinedStorage {
|
||||
public int craftingGridRfUsage;
|
||||
public int patternGridRfUsage;
|
||||
|
||||
public int controller;
|
||||
public boolean controllerUsesRf;
|
||||
|
||||
public int wirelessTransmitterBaseRange;
|
||||
@@ -104,6 +105,7 @@ public final class RefinedStorage {
|
||||
craftingGridRfUsage = config.getInt("craftingGrid", "energy", 4, 0, Integer.MAX_VALUE, "The RF/t used by Crafting Grids");
|
||||
patternGridRfUsage = config.getInt("patternGrid", "energy", 3, 0, Integer.MAX_VALUE, "The RF/t used by Pattern Grids");
|
||||
|
||||
controller = config.getInt("controller", "energy", 32000, 0, Integer.MAX_VALUE, "The energy capacity of the controller");
|
||||
controllerUsesRf = config.getBoolean("controllerUsesRf", "energy", true, "Whether the controller uses RF");
|
||||
|
||||
wirelessTransmitterBaseRange = config.getInt("range", "wirelessTransmitter", 16, 0, Integer.MAX_VALUE, "The base range of the Wireless Transmitter");
|
||||
|
||||
@@ -119,6 +119,7 @@ public class BlockController extends BlockBase {
|
||||
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
stack.getTagCompound().setInteger(TileController.NBT_ENERGY, ((TileController) world.getTileEntity(pos)).getEnergy().getEnergyStored());
|
||||
stack.getTagCompound().setInteger(TileController.NBT_ENERGY_CAPACITY, ((TileController) world.getTileEntity(pos)).getEnergy().getMaxEnergyStored());
|
||||
|
||||
drops.add(stack);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class GuiController extends GuiBase {
|
||||
}
|
||||
|
||||
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()) + "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergy().getEnergyStored(), TileController.ENERGY_CAPACITY));
|
||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()) + "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergy().getEnergyStored(), controller.getEnergy().getMaxEnergyStored()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.block.EnumControllerType;
|
||||
import refinedstorage.tile.controller.TileController;
|
||||
@@ -20,12 +21,19 @@ public class ItemBlockController extends ItemBlockBase {
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
|
||||
if (stack.getMetadata() != EnumControllerType.CREATIVE.getId()) {
|
||||
int energyStored = 0;
|
||||
int energyCapacity = RefinedStorage.INSTANCE.controller;
|
||||
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey(TileController.NBT_ENERGY)) {
|
||||
energyStored = stack.getTagCompound().getInteger(TileController.NBT_ENERGY);
|
||||
if (stack.getTagCompound() != null) {
|
||||
if (stack.getTagCompound().hasKey(TileController.NBT_ENERGY)) {
|
||||
energyStored = stack.getTagCompound().getInteger(TileController.NBT_ENERGY);
|
||||
}
|
||||
|
||||
if (stack.getTagCompound().hasKey(TileController.NBT_ENERGY_CAPACITY)) {
|
||||
energyCapacity = stack.getTagCompound().getInteger(TileController.NBT_ENERGY_CAPACITY);
|
||||
}
|
||||
}
|
||||
|
||||
list.add(I18n.format("misc.refinedstorage:energy_stored", energyStored, TileController.ENERGY_CAPACITY));
|
||||
list.add(I18n.format("misc.refinedstorage:energy_stored", energyStored, energyCapacity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +51,7 @@ public class ItemBlockController extends ItemBlockBase {
|
||||
tag = new NBTTagCompound();
|
||||
}
|
||||
|
||||
tag.setInteger(TileController.NBT_ENERGY, stack.getMetadata() == EnumControllerType.CREATIVE.getId() ? TileController.ENERGY_CAPACITY : 0);
|
||||
tag.setInteger(TileController.NBT_ENERGY, stack.getMetadata() == EnumControllerType.CREATIVE.getId() ? RefinedStorage.INSTANCE.controller : 0);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -50,10 +50,9 @@ import refinedstorage.tile.config.RedstoneMode;
|
||||
import java.util.*;
|
||||
|
||||
public class TileController extends TileBase implements INetworkMaster, IEnergyReceiver, ISynchronizedContainer, IRedstoneModeConfig {
|
||||
public static final int ENERGY_CAPACITY = 32000;
|
||||
|
||||
public static final String NBT_CRAFTING_TASKS = "CraftingTasks";
|
||||
public static final String NBT_ENERGY = "Energy";
|
||||
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
||||
|
||||
private GridHandler gridHandler = new GridHandler(this);
|
||||
private WirelessGridHandler wirelessGridHandler = new WirelessGridHandler(this);
|
||||
@@ -72,7 +71,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
private List<ICraftingTask> craftingTasksToAdd = new ArrayList<ICraftingTask>();
|
||||
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<ICraftingTask>();
|
||||
|
||||
private EnergyStorage energy = new EnergyStorage(ENERGY_CAPACITY);
|
||||
private EnergyStorage energy = new EnergyStorage(RefinedStorage.INSTANCE.controller);
|
||||
private int energyUsage;
|
||||
|
||||
private int lastEnergyDisplay;
|
||||
@@ -560,6 +559,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||
super.writeUpdate(tag);
|
||||
|
||||
tag.setInteger(NBT_ENERGY_CAPACITY, energy.getMaxEnergyStored());
|
||||
tag.setInteger(NBT_ENERGY, energy.getEnergyStored());
|
||||
|
||||
return tag;
|
||||
@@ -567,6 +567,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
@Override
|
||||
public void readUpdate(NBTTagCompound tag) {
|
||||
energy.setCapacity(tag.getInteger(NBT_ENERGY_CAPACITY));
|
||||
energy.setEnergyStored(tag.getInteger(NBT_ENERGY));
|
||||
|
||||
super.readUpdate(tag);
|
||||
@@ -583,7 +584,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
}
|
||||
|
||||
public int getEnergyScaled(int i) {
|
||||
return (int) ((float) energy.getEnergyStored() / (float) ENERGY_CAPACITY * (float) i);
|
||||
return (int) ((float) energy.getEnergyStored() / (float) energy.getMaxEnergyStored() * (float) i);
|
||||
}
|
||||
|
||||
public int getEnergyScaledForDisplay() {
|
||||
|
||||
Reference in New Issue
Block a user