Skip to content

Commit

Permalink
Fix saving of internal network energy buffer and make it scale with n…
Browse files Browse the repository at this point in the history
…etwork size (#7406)
  • Loading branch information
shartte authored Sep 14, 2023
1 parent 062473b commit 40ea8c1
Show file tree
Hide file tree
Showing 21 changed files with 393 additions and 479 deletions.
2 changes: 1 addition & 1 deletion guidebook/ae2-mechanics/energy.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ runs out of energy, and thus reboots.

**This can be solved by the addition of energy cells.**

Networks come with a free 800 AE of energy buffer.
Networks have a built-in energy buffer of 25 AE per cable, machine or part.

<ItemLink id="controller" />s have a small amount of internal energy storage, 8,000 AE

Expand Down
37 changes: 20 additions & 17 deletions src/main/java/appeng/api/networking/IGridServiceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

package appeng.api.networking;

import org.jetbrains.annotations.Nullable;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;

/**
Expand Down Expand Up @@ -74,40 +77,40 @@ default void onServerEndTick() {
default void removeNode(IGridNode gridNode) {
}

@Deprecated(forRemoval = true, since = "1.20.1")
default void addNode(IGridNode gridNode) {
}

/**
* Informs the grid service about a node that was added to the grid.
* <p>
* Important: Do not trust the grids state in this method, interact only with the node you are passed, if you need
* to manage other grid information, do it on the next updateTick.
*
* @param gridNode added to grid node
* @param gridNode added to grid node
* @param savedData The grid-related saved data for the node joining the grid. May be null. Contains data written by
* {@link #saveNodeData}.
*/
default void addNode(IGridNode gridNode) {
default void addNode(IGridNode gridNode, @Nullable CompoundTag savedData) {
addNode(gridNode);
}

/**
* Called when a grid splits into two grids, AE will call a split as it iteratively processes changes. The
* destination should receive half, and the current service should retain half.
*
* @param destinationStorage storage which receives half of old grid
* Save provider-specific data for the given node to the given tag. Note that the tag is shared between all
* providers, so take care to use unique names for your properties!
*/
default void saveNodeData(IGridNode gridNode, CompoundTag savedData) {
}

@Deprecated(forRemoval = true, since = "1.20.1")
default void onSplit(IGridStorage destinationStorage) {
}

/**
* Called when two grids merge into one, AE will call a join as it Iteratively processes changes. Use this method to
* incorporate all the data from the source into your service.
*
* @param sourceStorage old storage
*/
@Deprecated(forRemoval = true, since = "1.20.1")
default void onJoin(IGridStorage sourceStorage) {
}

/**
* Called when saving changes,
*
* @param destinationStorage storage
*/
@Deprecated(forRemoval = true, since = "1.20.1")
default void populateGridStorage(IGridStorage destinationStorage) {
}
}
9 changes: 1 addition & 8 deletions src/main/java/appeng/api/networking/IGridStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@

import net.minecraft.nbt.CompoundTag;

@Deprecated(forRemoval = true)
public interface IGridStorage {

/**
* @return an CompoundNBT that can be read, and written too.
*/

CompoundTag dataObject();

/**
* @return the id for this grid storage object, used internally
*/
long getID();
}
7 changes: 7 additions & 0 deletions src/main/java/appeng/core/AEConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public boolean isGuideHotkeyEnabled() {
return CLIENT.enableGuideHotkey.get();
}

public double getGridEnergyStoragePerNode() {
return COMMON.gridEnergyStoragePerNode.get();
}

public void save() {
}

Expand Down Expand Up @@ -667,6 +671,7 @@ private static class CommonConfig {
// Power Ratios
public final DoubleOption powerRatioTechReborn;
public final DoubleOption powerUsageMultiplier;
public final DoubleOption gridEnergyStoragePerNode;

// Vibration Chamber
public final DoubleOption vibrationChamberBaseEnergyPerFuelTick;
Expand Down Expand Up @@ -758,6 +763,8 @@ public CommonConfig(ConfigSection root) {
ConfigSection PowerRatios = root.subsection("PowerRatios");
powerRatioTechReborn = PowerRatios.addDouble("TechReborn", DEFAULT_TR_EXCHANGE);
powerUsageMultiplier = PowerRatios.addDouble("UsageMultiplier", 1.0, 0.01, Double.MAX_VALUE);
gridEnergyStoragePerNode = PowerRatios.addDouble("GridEnergyStoragePerNode", 25, 1, 1000000,
"How much energy can the internal grid buffer storage per node attached to the grid.");

ConfigSection Condenser = root.subsection("Condenser");
condenserMatterBallsPower = Condenser.addInt("MatterBalls", 256);
Expand Down
135 changes: 0 additions & 135 deletions src/main/java/appeng/core/worlddata/GridStorageSaveData.java

This file was deleted.

51 changes: 0 additions & 51 deletions src/main/java/appeng/core/worlddata/IGridStorageSaveData.java

This file was deleted.

Loading

0 comments on commit 40ea8c1

Please sign in to comment.