From cec6e713b3eca5355a1301a35baab995081e37f2 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 31 Dec 2023 17:00:35 +0100 Subject: [PATCH] feat: portable grid config --- .../platform/common/Config.java | 12 ++++++ .../common/content/DefaultEnergyUsage.java | 5 +++ .../AbstractPortableGridBlockEntity.java | 6 +-- .../PortableGridLootItemFunction.java | 2 +- .../assets/refinedstorage2/lang/en_us.json | 6 ++- .../platform/fabric/ConfigImpl.java | 38 ++++++++++++++++ .../platform/forge/ConfigImpl.java | 43 +++++++++++++++++++ 7 files changed, 106 insertions(+), 6 deletions(-) diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Config.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Config.java index 8e20884c5..54bdec5c8 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Config.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/Config.java @@ -50,6 +50,8 @@ public interface Config { SimpleEnergyUsageEntry getNetworkTransmitter(); + PortableGridEntry getPortableGrid(); + interface SimpleEnergyUsageEntry { long getEnergyUsage(); } @@ -167,4 +169,14 @@ interface WirelessGridEntry { interface WirelessTransmitterEntry extends SimpleEnergyUsageEntry { int getBaseRange(); } + + interface PortableGridEntry { + long getEnergyCapacity(); + + long getOpenEnergyUsage(); + + long getInsertEnergyUsage(); + + long getExtractEnergyUsage(); + } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/DefaultEnergyUsage.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/DefaultEnergyUsage.java index 041f44474..bdbd5caf9 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/DefaultEnergyUsage.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/content/DefaultEnergyUsage.java @@ -50,6 +50,11 @@ public final class DefaultEnergyUsage { public static final long WIRELESS_TRANSMITTER = 16; public static final int WIRELESS_TRANSMITTER_BASE_RANGE = 16; + public static final long PORTABLE_GRID_CAPACITY = 1000; + public static final long PORTABLE_GRID_OPEN = 5; + public static final long PORTABLE_GRID_INSERT = 5; + public static final long PORTABLE_GRID_EXTRACT = 5; + private DefaultEnergyUsage() { } } diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java index 455f2b0a6..7c85c3906 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/AbstractPortableGridBlockEntity.java @@ -92,7 +92,7 @@ private static EnergyStorage createEnergyStorage(final PortableGridType type, fi return CreativeEnergyStorage.INSTANCE; } return new BlockEntityEnergyStorage( - Platform.INSTANCE.getConfig().getController().getEnergyCapacity(), // TODO + Platform.INSTANCE.getConfig().getPortableGrid().getEnergyCapacity(), blockEntity ); } @@ -244,6 +244,7 @@ public void removeWatcher(final GridWatcher watcher) { @Override public Storage getItemStorage() { + // TODO return new InMemoryStorageImpl<>(); } @@ -252,9 +253,6 @@ public boolean isGridActive() { return energyStorage.getStored() > 0 && level != null && redstoneMode.isActive(level.hasNeighborSignal(worldPosition)); - // TODO: add energy component - // TODO: sync activeness to block state - // TODO: energy level in GUI } @Override diff --git a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridLootItemFunction.java b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridLootItemFunction.java index 0eeaca775..de9c1fc5b 100644 --- a/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridLootItemFunction.java +++ b/refinedstorage2-platform-common/src/main/java/com/refinedmods/refinedstorage2/platform/common/storage/portablegrid/PortableGridLootItemFunction.java @@ -15,7 +15,7 @@ public LootItemFunctionType getType() { @Override public ItemStack apply(final ItemStack itemStack, final LootContext lootContext) { - // todo ! + // TODO: item representation of the portable grid return itemStack; } } diff --git a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json index e7ea7a9a2..35ca4573b 100644 --- a/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json +++ b/refinedstorage2-platform-common/src/main/resources/assets/refinedstorage2/lang/en_us.json @@ -306,7 +306,6 @@ "text.autoconfig.refinedstorage2.option.externalStorage": "External Storage", "text.autoconfig.refinedstorage2.option.externalStorage.energyUsage": "Energy usage", "text.autoconfig.refinedstorage2.option.wirelessGrid": "Wireless Grid", - "text.autoconfig.refinedstorage2.option.wirelessGrid.useEnergy": "Use energy", "text.autoconfig.refinedstorage2.option.wirelessGrid.energyCapacity": "Energy capacity", "text.autoconfig.refinedstorage2.option.wirelessGrid.openEnergyUsage": "Open energy usage", "text.autoconfig.refinedstorage2.option.wirelessGrid.insertEnergyUsage": "Insert energy usage", @@ -318,6 +317,11 @@ "text.autoconfig.refinedstorage2.option.storageMonitor.energyUsage": "Energy usage", "text.autoconfig.refinedstorage2.option.networkReceiver": "Network Receiver", "text.autoconfig.refinedstorage2.option.networkReceiver.energyUsage": "Energy usage", + "text.autoconfig.refinedstorage2.option.portableGrid": "Portable Grid", + "text.autoconfig.refinedstorage2.option.portableGrid.energyCapacity": "Energy capacity", + "text.autoconfig.refinedstorage2.option.portableGrid.openEnergyUsage": "Open energy usage", + "text.autoconfig.refinedstorage2.option.portableGrid.insertEnergyUsage": "Insert energy usage", + "text.autoconfig.refinedstorage2.option.portableGrid.extractEnergyUsage": "Extract energy usage", "advancements.refinedstorage2.root.description": "Use one or multiple Controllers in a network to provide your network with energy", "advancements.refinedstorage2.connecting": "Connecting", "advancements.refinedstorage2.connecting.description": "Use Cable to connect devices with each other, or place devices against each other", diff --git a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ConfigImpl.java b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ConfigImpl.java index df268b19a..d6d95a1c5 100644 --- a/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ConfigImpl.java +++ b/refinedstorage2-platform-fabric/src/main/java/com/refinedmods/refinedstorage2/platform/fabric/ConfigImpl.java @@ -85,6 +85,9 @@ public class ConfigImpl implements ConfigData, com.refinedmods.refinedstorage2.p DefaultEnergyUsage.NETWORK_TRANSMITTER ); + @ConfigEntry.Gui.CollapsibleObject + private PortableGridEntryImpl portableGrid = new PortableGridEntryImpl(); + public static ConfigImpl get() { return AutoConfig.getConfigHolder(ConfigImpl.class).getConfig(); } @@ -189,6 +192,11 @@ public SimpleEnergyUsageEntry getNetworkTransmitter() { return networkTransmitter; } + @Override + public PortableGridEntry getPortableGrid() { + return portableGrid; + } + private static class GridEntryImpl implements GridEntry { private boolean largeFont = false; @@ -578,4 +586,34 @@ public int getBaseRange() { return baseRange; } } + + private static class PortableGridEntryImpl implements PortableGridEntry { + private long energyCapacity = DefaultEnergyUsage.PORTABLE_GRID_CAPACITY; + + private long openEnergyUsage = DefaultEnergyUsage.PORTABLE_GRID_OPEN; + + private long insertEnergyUsage = DefaultEnergyUsage.PORTABLE_GRID_INSERT; + + private long extractEnergyUsage = DefaultEnergyUsage.PORTABLE_GRID_EXTRACT; + + @Override + public long getEnergyCapacity() { + return energyCapacity; + } + + @Override + public long getOpenEnergyUsage() { + return openEnergyUsage; + } + + @Override + public long getInsertEnergyUsage() { + return insertEnergyUsage; + } + + @Override + public long getExtractEnergyUsage() { + return extractEnergyUsage; + } + } } diff --git a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ConfigImpl.java b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ConfigImpl.java index d7a1309fa..d9cfb8997 100644 --- a/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ConfigImpl.java +++ b/refinedstorage2-platform-forge/src/main/java/com/refinedmods/refinedstorage2/platform/forge/ConfigImpl.java @@ -38,6 +38,7 @@ public class ConfigImpl implements Config { private final SimpleEnergyUsageEntry storageMonitor; private final SimpleEnergyUsageEntry networkReceiver; private final SimpleEnergyUsageEntry networkTransmitter; + private final PortableGridEntry portableGrid; public ConfigImpl() { cable = new SimpleEnergyUsageEntryImpl("cable", "Cable", DefaultEnergyUsage.CABLE); @@ -76,6 +77,7 @@ public ConfigImpl() { "Network Transmitter", DefaultEnergyUsage.NETWORK_TRANSMITTER ); + portableGrid = new PortableGridEntryImpl(); spec = builder.build(); } @@ -183,6 +185,11 @@ public SimpleEnergyUsageEntry getNetworkTransmitter() { return networkTransmitter; } + @Override + public PortableGridEntry getPortableGrid() { + return portableGrid; + } + private class SimpleEnergyUsageEntryImpl implements SimpleEnergyUsageEntry { private final ForgeConfigSpec.LongValue energyUsage; @@ -730,4 +737,40 @@ public int getBaseRange() { return baseRange.get(); } } + + private class PortableGridEntryImpl implements PortableGridEntry { + private final ForgeConfigSpec.LongValue energyCapacity; + private final ForgeConfigSpec.LongValue openEnergyUsage; + private final ForgeConfigSpec.LongValue extractEnergyUsage; + private final ForgeConfigSpec.LongValue insertEnergyUsage; + + PortableGridEntryImpl() { + builder.push("portableGrid"); + energyCapacity = builder.comment("The energy capacity of the Portable Grid") + .defineInRange("energyCapacity", DefaultEnergyUsage.PORTABLE_GRID_CAPACITY, 0, Long.MAX_VALUE); + openEnergyUsage = builder.comment("The energy used by the Portable Grid to open") + .defineInRange("openEnergyUsage", DefaultEnergyUsage.PORTABLE_GRID_OPEN, 0, Long.MAX_VALUE); + extractEnergyUsage = builder.comment("The energy used by the Portable Grid to extract resources") + .defineInRange("extractEnergyUsage", DefaultEnergyUsage.PORTABLE_GRID_EXTRACT, 0, Long.MAX_VALUE); + insertEnergyUsage = builder.comment("The energy used by the Portable Grid to insert resources") + .defineInRange("insertEnergyUsage", DefaultEnergyUsage.PORTABLE_GRID_INSERT, 0, Long.MAX_VALUE); + builder.pop(); + } + + public long getEnergyCapacity() { + return energyCapacity.get(); + } + + public long getOpenEnergyUsage() { + return openEnergyUsage.get(); + } + + public long getExtractEnergyUsage() { + return extractEnergyUsage.get(); + } + + public long getInsertEnergyUsage() { + return insertEnergyUsage.get(); + } + } }