Skip to content

Commit

Permalink
feat: portable grid config
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Dec 31, 2023
1 parent cfb40a2 commit cec6e71
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public interface Config {

SimpleEnergyUsageEntry getNetworkTransmitter();

PortableGridEntry getPortableGrid();

interface SimpleEnergyUsageEntry {
long getEnergyUsage();
}
Expand Down Expand Up @@ -167,4 +169,14 @@ interface WirelessGridEntry {
interface WirelessTransmitterEntry extends SimpleEnergyUsageEntry {
int getBaseRange();
}

interface PortableGridEntry {
long getEnergyCapacity();

long getOpenEnergyUsage();

long getInsertEnergyUsage();

long getExtractEnergyUsage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down Expand Up @@ -244,6 +244,7 @@ public void removeWatcher(final GridWatcher watcher) {

@Override
public Storage<ItemResource> getItemStorage() {
// TODO
return new InMemoryStorageImpl<>();
}

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -76,6 +77,7 @@ public ConfigImpl() {
"Network Transmitter",
DefaultEnergyUsage.NETWORK_TRANSMITTER
);
portableGrid = new PortableGridEntryImpl();
spec = builder.build();
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}
}

0 comments on commit cec6e71

Please sign in to comment.