Skip to content

Commit c913953

Browse files
committed
Rework MUI2 Multi Syncing (#2734)
1 parent fa66237 commit c913953

29 files changed

+406
-595
lines changed

src/main/java/gregtech/api/metatileentity/multiblock/RecipeMapSteamMultiblockController.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import gregtech.api.recipes.Recipe;
1717
import gregtech.api.recipes.RecipeMap;
1818
import gregtech.api.util.KeyUtil;
19-
import gregtech.api.util.TextFormattingUtil;
2019
import gregtech.common.ConfigHolder;
2120

2221
import net.minecraft.entity.player.EntityPlayer;
@@ -102,14 +101,15 @@ private void resetTileAbilities() {
102101
@Override
103102
protected void configureDisplayText(MultiblockUIBuilder builder) {
104103
builder.setWorkingStatus(recipeMapWorkable.isWorkingEnabled(), recipeMapWorkable.isActive())
105-
.addCustom(keyManager -> {
104+
.addCustom((keyManager, syncer) -> {
106105
// custom steam tank line
107106
IFluidTank steamFluidTank = recipeMapWorkable.getSteamFluidTankCombined();
108-
if (steamFluidTank != null && steamFluidTank.getCapacity() > 0) {
109-
String stored = TextFormattingUtil.formatNumbers(steamFluidTank.getFluidAmount());
110-
String capacity = TextFormattingUtil.formatNumbers(steamFluidTank.getCapacity());
111-
112-
IKey steamInfo = KeyUtil.string(TextFormatting.BLUE, "%s/%s L", stored, capacity);
107+
int stored = syncer.syncInt(steamFluidTank.getFluidAmount());
108+
int capacity = syncer.syncInt(steamFluidTank.getCapacity());
109+
if (capacity > 0) {
110+
IKey steamInfo = KeyUtil.string(TextFormatting.BLUE, "%s/%s L",
111+
KeyUtil.number(stored),
112+
KeyUtil.number(capacity));
113113
IKey steamStored = KeyUtil.lang(TextFormatting.GRAY,
114114
"gregtech.multiblock.steam.steam_stored", steamInfo);
115115
keyManager.add(steamStored);
@@ -122,12 +122,12 @@ protected void configureDisplayText(MultiblockUIBuilder builder) {
122122

123123
@Override
124124
protected void configureWarningText(MultiblockUIBuilder builder) {
125-
builder.addCustom(list -> {
126-
if (isStructureFormed() && recipeMapWorkable.isHasNotEnoughEnergy()) {
125+
builder.addCustom((list, syncer) -> {
126+
boolean noEnergy = syncer.syncBoolean(recipeMapWorkable.isHasNotEnoughEnergy());
127+
if (isStructureFormed() && noEnergy) {
127128
list.add(KeyUtil.lang(TextFormatting.YELLOW, "gregtech.multiblock.steam.low_steam"));
128129
}
129-
})
130-
.addMaintenanceProblemLines(getMaintenanceProblems());
130+
}).addMaintenanceProblemLines(getMaintenanceProblems());
131131
}
132132

133133
@Override
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package gregtech.api.metatileentity.multiblock.ui;
2+
3+
@FunctionalInterface
4+
public interface CustomKeyFunction {
5+
6+
void addCustom(KeyManager manager, UISyncer syncer);
7+
}

0 commit comments

Comments
 (0)