Add client config, add config for grid energy usage

This commit is contained in:
raoulvdberge
2019-10-10 14:10:12 +02:00
parent cc7902b890
commit 644f644532
9 changed files with 89 additions and 43 deletions

View File

@@ -15,6 +15,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.FluidStorage
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
import com.raoulvdberge.refinedstorage.block.*; import com.raoulvdberge.refinedstorage.block.*;
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability; import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
import com.raoulvdberge.refinedstorage.config.ClientConfig;
import com.raoulvdberge.refinedstorage.config.ServerConfig; import com.raoulvdberge.refinedstorage.config.ServerConfig;
import com.raoulvdberge.refinedstorage.container.ControllerContainer; import com.raoulvdberge.refinedstorage.container.ControllerContainer;
import com.raoulvdberge.refinedstorage.container.DiskDriveContainer; import com.raoulvdberge.refinedstorage.container.DiskDriveContainer;
@@ -63,11 +64,13 @@ public final class RS {
public static final NetworkHandler NETWORK_HANDLER = new NetworkHandler(); public static final NetworkHandler NETWORK_HANDLER = new NetworkHandler();
public static final ItemGroup MAIN_GROUP = new MainItemGroup(); public static final ItemGroup MAIN_GROUP = new MainItemGroup();
public static final ServerConfig SERVER_CONFIG = new ServerConfig(); public static final ServerConfig SERVER_CONFIG = new ServerConfig();
public static final ClientConfig CLIENT_CONFIG = new ClientConfig();
public RS() { public RS() {
DistExecutor.runWhenOn(Dist.CLIENT, () -> ClientSetup::new); DistExecutor.runWhenOn(Dist.CLIENT, () -> ClientSetup::new);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG.getSpec()); ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG.getSpec());
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CLIENT_CONFIG.getSpec());
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup);
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(Block.class, this::onRegisterBlocks); FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(Block.class, this::onRegisterBlocks);

View File

@@ -2,7 +2,6 @@ package com.raoulvdberge.refinedstorage;
public class RSOldConfig { public class RSOldConfig {
//region Energy //region Energy
public int cableUsage;
public int constructorUsage; public int constructorUsage;
public int crafterUsage; public int crafterUsage;
public int crafterPerPatternUsage; public int crafterPerPatternUsage;
@@ -10,8 +9,6 @@ public class RSOldConfig {
public int crafterManagerUsage; public int crafterManagerUsage;
public int destructorUsage; public int destructorUsage;
public int detectorUsage; public int detectorUsage;
public int diskDriveUsage;
public int diskDrivePerDiskUsage;
public int externalStorageUsage; public int externalStorageUsage;
public int externalStoragePerStorageUsage; public int externalStoragePerStorageUsage;
public int exporterUsage; public int exporterUsage;
@@ -22,7 +19,6 @@ public class RSOldConfig {
public int storageUsage; public int storageUsage;
public int fluidStorageUsage; public int fluidStorageUsage;
public int wirelessTransmitterUsage; public int wirelessTransmitterUsage;
public int gridUsage;
public int craftingGridUsage; public int craftingGridUsage;
public int patternGridUsage; public int patternGridUsage;
public int fluidGridUsage; public int fluidGridUsage;
@@ -33,12 +29,6 @@ public class RSOldConfig {
public int securityManagerPerSecurityCardUsage; public int securityManagerPerSecurityCardUsage;
//endregion //endregion
//region Grid
public int maxRowsStretch;
public boolean largeFont;
public boolean detailedTooltip;
//endregion
//region Wireless Transmitter //region Wireless Transmitter
public int wirelessTransmitterBaseRange; public int wirelessTransmitterBaseRange;
public int wirelessTransmitterRangePerUpgrade; public int wirelessTransmitterRangePerUpgrade;
@@ -92,8 +82,6 @@ public class RSOldConfig {
//region Categories //region Categories
private static final String ENERGY = "energy"; private static final String ENERGY = "energy";
private static final String CONTROLLER = "controller";
private static final String GRID = "grid";
private static final String WIRELESS_TRANSMITTER = "wirelessTransmitter"; private static final String WIRELESS_TRANSMITTER = "wirelessTransmitter";
private static final String WIRELESS_GRID = "wirelessGrid"; private static final String WIRELESS_GRID = "wirelessGrid";
private static final String PORTABLE_GRID = "portableGrid"; private static final String PORTABLE_GRID = "portableGrid";
@@ -106,9 +94,6 @@ public class RSOldConfig {
/*private void loadConfig() { /*private void loadConfig() {
//region Energy //region Energy
controllerBaseUsage = config.getInt("controllerBase", ENERGY, 0, 0, Integer.MAX_VALUE, "The base energy used by the Controller");
controllerMaxReceive = config.getInt("controllerMaxReceive", ENERGY, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, "The maximum energy the controller receives per tick");
cableUsage = config.getInt("cable", ENERGY, 0, 0, Integer.MAX_VALUE, "The energy used by Cables");
constructorUsage = config.getInt("constructor", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Constructors"); constructorUsage = config.getInt("constructor", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Constructors");
crafterUsage = config.getInt("crafter", ENERGY, 2, 0, Integer.MAX_VALUE, "The base energy used by Crafters"); crafterUsage = config.getInt("crafter", ENERGY, 2, 0, Integer.MAX_VALUE, "The base energy used by Crafters");
crafterPerPatternUsage = config.getInt("crafterPerPattern", ENERGY, 1, 0, Integer.MAX_VALUE, "The additional energy used per Pattern in a Crafter"); crafterPerPatternUsage = config.getInt("crafterPerPattern", ENERGY, 1, 0, Integer.MAX_VALUE, "The additional energy used per Pattern in a Crafter");
@@ -116,8 +101,6 @@ public class RSOldConfig {
crafterManagerUsage = config.getInt("crafterManager", ENERGY, 4, 0, Integer.MAX_VALUE, "The energy used by Crafter Managers"); crafterManagerUsage = config.getInt("crafterManager", ENERGY, 4, 0, Integer.MAX_VALUE, "The energy used by Crafter Managers");
destructorUsage = config.getInt("destructor", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Destructors"); destructorUsage = config.getInt("destructor", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Destructors");
detectorUsage = config.getInt("detector", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Detectors"); detectorUsage = config.getInt("detector", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Detectors");
diskDriveUsage = config.getInt("diskDrive", ENERGY, 0, 0, Integer.MAX_VALUE, "The base energy used by Disk Drives");
diskDrivePerDiskUsage = config.getInt("diskDrivePerDisk", ENERGY, 1, 0, Integer.MAX_VALUE, "The additional energy used by Storage Disks in Disk Drives");
externalStorageUsage = config.getInt("externalStorage", ENERGY, 0, 0, Integer.MAX_VALUE, "The base energy used by External Storages"); externalStorageUsage = config.getInt("externalStorage", ENERGY, 0, 0, Integer.MAX_VALUE, "The base energy used by External Storages");
externalStoragePerStorageUsage = config.getInt("externalStoragePerStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The additional energy used per connected storage to an External Storage"); externalStoragePerStorageUsage = config.getInt("externalStoragePerStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The additional energy used per connected storage to an External Storage");
exporterUsage = config.getInt("exporter", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Exporters"); exporterUsage = config.getInt("exporter", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Exporters");
@@ -128,7 +111,6 @@ public class RSOldConfig {
storageUsage = config.getInt("storage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Storage Blocks"); storageUsage = config.getInt("storage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Storage Blocks");
fluidStorageUsage = config.getInt("fluidStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Fluid Storage Blocks"); fluidStorageUsage = config.getInt("fluidStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Fluid Storage Blocks");
wirelessTransmitterUsage = config.getInt("wirelessTransmitter", ENERGY, 8, 0, Integer.MAX_VALUE, "The energy used by Wireless Transmitters"); wirelessTransmitterUsage = config.getInt("wirelessTransmitter", ENERGY, 8, 0, Integer.MAX_VALUE, "The energy used by Wireless Transmitters");
gridUsage = config.getInt("grid", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Grids");
craftingGridUsage = config.getInt("craftingGrid", ENERGY, 4, 0, Integer.MAX_VALUE, "The energy used by Crafting Grids"); craftingGridUsage = config.getInt("craftingGrid", ENERGY, 4, 0, Integer.MAX_VALUE, "The energy used by Crafting Grids");
patternGridUsage = config.getInt("patternGrid", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Pattern Grids"); patternGridUsage = config.getInt("patternGrid", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Pattern Grids");
fluidGridUsage = config.getInt("fluidGrid", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Fluid Grids"); fluidGridUsage = config.getInt("fluidGrid", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Fluid Grids");
@@ -139,17 +121,6 @@ public class RSOldConfig {
securityManagerPerSecurityCardUsage = config.getInt("securityManagerPerSecurityCard", ENERGY, 10, 0, Integer.MAX_VALUE, "The additional energy used by Security Cards in Security Managers"); securityManagerPerSecurityCardUsage = config.getInt("securityManagerPerSecurityCard", ENERGY, 10, 0, Integer.MAX_VALUE, "The additional energy used by Security Cards in Security Managers");
//endregion //endregion
//region Controller
controllerCapacity = config.getInt("capacity", CONTROLLER, 32000, 0, Integer.MAX_VALUE, "The energy capacity of the Controller");
controllerUsesEnergy = config.getBoolean("usesEnergy", CONTROLLER, true, "Whether the Controller uses energy");
//endregion
//region Grid
maxRowsStretch = config.getInt("maxRowsStretch", GRID, Integer.MAX_VALUE, 3, Integer.MAX_VALUE, "The maximum amount of rows that the Grid can show when stretched");
largeFont = config.getBoolean("largeFont", GRID, false, "Whether the Grid should use a large font for stack quantity display");
detailedTooltip = config.getBoolean("detailedTooltip", GRID, true, "Whether the Grid should display a detailed tooltip when hovering over an item or fluid");
//endregion
//region Wireless Transmitter //region Wireless Transmitter
wirelessTransmitterBaseRange = config.getInt("range", WIRELESS_TRANSMITTER, 16, 0, Integer.MAX_VALUE, "The base range of the Wireless Transmitter"); wirelessTransmitterBaseRange = config.getInt("range", WIRELESS_TRANSMITTER, 16, 0, Integer.MAX_VALUE, "The base range of the Wireless Transmitter");
wirelessTransmitterRangePerUpgrade = config.getInt("rangePerUpgrade", WIRELESS_TRANSMITTER, 8, 0, Integer.MAX_VALUE, "The additional range per Range Upgrade in the Wireless Transmitter"); wirelessTransmitterRangePerUpgrade = config.getInt("rangePerUpgrade", WIRELESS_TRANSMITTER, 8, 0, Integer.MAX_VALUE, "The additional range per Range Upgrade in the Wireless Transmitter");

View File

@@ -171,19 +171,18 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
@Override @Override
public int getEnergyUsage() { public int getEnergyUsage() {
/* @TODO switch (getGridType()) { switch (getGridType()) {
case NORMAL: case NORMAL:
return RS.INSTANCE.config.gridUsage; return RS.SERVER_CONFIG.getGrid().getUsage();
case CRAFTING: case CRAFTING:
return RS.INSTANCE.config.craftingGridUsage; return 0;
case PATTERN: case PATTERN:
return RS.INSTANCE.config.patternGridUsage; return 0;
case FLUID: case FLUID:
return RS.INSTANCE.config.fluidGridUsage; return 0;
default: default:
return 0; return 0;
}*/ }
return 0;
} }
public void setViewType(int viewType) { public void setViewType(int viewType) {

View File

@@ -0,0 +1,52 @@
package com.raoulvdberge.refinedstorage.config;
import net.minecraftforge.common.ForgeConfigSpec;
public class ClientConfig {
private ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
private ForgeConfigSpec spec;
private Grid grid;
public ClientConfig() {
grid = new Grid();
spec = builder.build();
}
public ForgeConfigSpec getSpec() {
return spec;
}
public Grid getGrid() {
return grid;
}
public class Grid {
private final ForgeConfigSpec.IntValue maxRowsStretch;
private final ForgeConfigSpec.BooleanValue detailedTooltip;
private final ForgeConfigSpec.BooleanValue largeFont;
public Grid() {
builder.push("grid");
maxRowsStretch = builder.comment("The maximum amount of rows that the Grid can show when stretched").defineInRange("maxRowsStretch", Integer.MAX_VALUE, 3, Integer.MAX_VALUE);
detailedTooltip = builder.comment("Whether the Grid should display a detailed tooltip when hovering over an item or fluid").define("detailedTooltip", true);
largeFont = builder.comment("Whether the Grid should use a large font for stack quantity display").define("largeFont", false);
builder.pop();
}
public int getMaxRowsStretch() {
return maxRowsStretch.get();
}
public boolean getDetailedTooltip() {
return detailedTooltip.get();
}
public boolean getLargeFont() {
return largeFont.get();
}
}
}

View File

@@ -8,12 +8,14 @@ public class ServerConfig {
private Controller controller; private Controller controller;
private Cable cable; private Cable cable;
private Grid grid;
private DiskDrive diskDrive; private DiskDrive diskDrive;
private Upgrades upgrades; private Upgrades upgrades;
public ServerConfig() { public ServerConfig() {
controller = new Controller(); controller = new Controller();
cable = new Cable(); cable = new Cable();
grid = new Grid();
diskDrive = new DiskDrive(); diskDrive = new DiskDrive();
upgrades = new Upgrades(); upgrades = new Upgrades();
@@ -36,6 +38,10 @@ public class ServerConfig {
return upgrades; return upgrades;
} }
public Grid getGrid() {
return grid;
}
public ForgeConfigSpec getSpec() { public ForgeConfigSpec getSpec() {
return spec; return spec;
} }
@@ -112,6 +118,22 @@ public class ServerConfig {
} }
} }
public class Grid {
private final ForgeConfigSpec.IntValue usage;
public Grid() {
builder.push("grid");
usage = builder.comment("The energy used by Grids").defineInRange("usage", 2, 0, Integer.MAX_VALUE);
builder.pop();
}
public int getUsage() {
return usage.get();
}
}
public class Upgrades { public class Upgrades {
private final ForgeConfigSpec.IntValue rangeUpgradeUsage; private final ForgeConfigSpec.IntValue rangeUpgradeUsage;
private final ForgeConfigSpec.IntValue speedUpgradeUsage; private final ForgeConfigSpec.IntValue speedUpgradeUsage;

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.screen; package com.raoulvdberge.refinedstorage.screen;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot; import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
import com.raoulvdberge.refinedstorage.render.FluidRenderer; import com.raoulvdberge.refinedstorage.render.FluidRenderer;
@@ -269,7 +270,7 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
} }
public void renderQuantity(int x, int y, String qty) { public void renderQuantity(int x, int y, String qty) {
boolean large = minecraft.getForceUnicodeFont() /* TODO || RS.INSTANCE.config.largeFont*/; boolean large = minecraft.getForceUnicodeFont() || RS.CLIENT_CONFIG.getGrid().getLargeFont();
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translatef(x, y, 1); GlStateManager.translatef(x, y, 1);

View File

@@ -64,7 +64,7 @@ public class GuiCrafterManager extends BaseScreen<CrafterManagerContainer> imple
case IGrid.SIZE_STRETCH: case IGrid.SIZE_STRETCH:
int screenSpaceAvailable = height - getTopHeight() - getBottomHeight(); int screenSpaceAvailable = height - getTopHeight() - getBottomHeight();
return Math.max(3, Math.min((screenSpaceAvailable / 18) - 3, RS.INSTANCE.config.maxRowsStretch)); return Math.max(3, Math.min((screenSpaceAvailable / 18) - 3, Integer.MAX_VALUE)); // TODO CrafterManager MaxRowsStretch
case IGrid.SIZE_SMALL: case IGrid.SIZE_SMALL:
return 3; return 3;
case IGrid.SIZE_MEDIUM: case IGrid.SIZE_MEDIUM:

View File

@@ -226,7 +226,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
case IGrid.SIZE_STRETCH: case IGrid.SIZE_STRETCH:
int screenSpaceAvailable = height - getTopHeight() - getBottomHeight(); int screenSpaceAvailable = height - getTopHeight() - getBottomHeight();
return Math.max(3, Math.min((screenSpaceAvailable / 18) - 3, Integer.MAX_VALUE));//@TODO: MaxRowsStretch return Math.max(3, Math.min((screenSpaceAvailable / 18) - 3, RS.CLIENT_CONFIG.getGrid().getMaxRowsStretch()));
case IGrid.SIZE_SMALL: case IGrid.SIZE_SMALL:
return 3; return 3;
case IGrid.SIZE_MEDIUM: case IGrid.SIZE_MEDIUM:
@@ -410,8 +410,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
ItemStack stack = gridStack instanceof ItemGridStack ? ((ItemGridStack) gridStack).getStack() : ItemStack.EMPTY; ItemStack stack = gridStack instanceof ItemGridStack ? ((ItemGridStack) gridStack).getStack() : ItemStack.EMPTY;
// @TODO DetailedToolTip RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, RS.CLIENT_CONFIG.getGrid().getDetailedTooltip(), stack, mouseX, mouseY, xSize, ySize, font);
RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, true, stack, mouseX, mouseY, xSize, ySize, font);
} }
@Override @Override

View File

@@ -123,8 +123,7 @@
"misc.refinedstorage.last_modified.weeks": "Last modified %d weeks ago by %s", "misc.refinedstorage.last_modified.weeks": "Last modified %d weeks ago by %s",
"misc.refinedstorage.last_modified.year": "Last modified %d year ago by %s", "misc.refinedstorage.last_modified.year": "Last modified %d year ago by %s",
"misc.refinedstorage.last_modified.years": "Last modified %d years ago by %s", "misc.refinedstorage.last_modified.years": "Last modified %d years ago by %s",
"sidebutton.refinedstorage:compare.1": "Use damage", "sidebutton.refinedstorage:compare.1": "Use NBT",
"sidebutton.refinedstorage:compare.2": "Use NBT",
"sidebutton.refinedstorage:redstone_mode": "Redstone mode", "sidebutton.refinedstorage:redstone_mode": "Redstone mode",
"sidebutton.refinedstorage:redstone_mode.0": "Ignore redstone signal", "sidebutton.refinedstorage:redstone_mode.0": "Ignore redstone signal",
"sidebutton.refinedstorage:redstone_mode.1": "Only work with redstone signal", "sidebutton.refinedstorage:redstone_mode.1": "Only work with redstone signal",