Skip to content

Commit 5403358

Browse files
authored
Merge branch 'master' into OreDictionary-cleanup
2 parents 7019634 + d13f642 commit 5403358

10 files changed

Lines changed: 85 additions & 48 deletions

File tree

src/main/java/gregtech/api/util/MultiblockTooltipBuilder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gregtech.api.util;
22

3+
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
34
import static gregtech.api.util.tooltip.TooltipHelper.percentageFormat;
45
import static net.minecraft.util.StatCollector.translateToLocal;
56
import static net.minecraft.util.StatCollector.translateToLocalFormatted;
@@ -95,7 +96,6 @@ public class MultiblockTooltipBuilder {
9596
private static final String TT_outputany = StatCollector.translateToLocal("GT5U.MBTT.OutputAny");
9697
private static final String TT_causes = StatCollector.translateToLocal("GT5U.MBTT.Causes");
9798
private static final String TT_produces = StatCollector.translateToLocal("GT5U.MBTT.Produces");
98-
private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS");
9999
private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold");
100100
private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display");
101101
private static final String TT_structurehint = StatCollector.translateToLocal("GT5U.MBTT.StructureHint");
@@ -396,7 +396,10 @@ public MultiblockTooltipBuilder addSeparator(EnumChatFormatting color, int lengt
396396
*/
397397
public MultiblockTooltipBuilder addPollutionAmount(int pollution) {
398398
if (pollution == 0) return this;
399-
iLines.add("" + EnumChatFormatting.DARK_PURPLE + pollution + " " + EnumChatFormatting.GRAY + TT_pps);
399+
iLines.add(
400+
EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted(
401+
"GT5U.MBTT.PPS",
402+
EnumChatFormatting.DARK_PURPLE + formatNumber(pollution) + EnumChatFormatting.GRAY));
400403
return this;
401404
}
402405

src/main/java/gregtech/common/config/Client.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,38 +207,47 @@ public static class Render {
207207

208208
@Config.Comment("if true, enables ambient-occlusion smooth lighting on tiles.")
209209
@Config.DefaultBoolean(true)
210+
@Config.Name("Ambient Occlusion on Tiles")
210211
public boolean renderTileAmbientOcclusion;
211212

212213
@Config.Comment("if true, enables glowing of the machine controllers.")
213214
@Config.DefaultBoolean(true)
215+
@Config.Name("Controller Glow")
214216
public boolean renderGlowTextures;
215217

216218
@Config.Comment("if true, render flipped machine with flipped textures.")
217219
@Config.DefaultBoolean(true)
220+
@Config.Name("Flipped Machine Textures")
218221
public boolean renderFlippedMachinesFlipped;
219222

220223
@Config.Comment("if true, render indicators on hatches.")
221224
@Config.DefaultBoolean(true)
225+
@Config.Name("Hatch Indicators")
222226
public boolean renderIndicatorsOnHatch;
223227

224228
@Config.Comment("if true, enables dirt particles when pollution reaches the threshold.")
225229
@Config.DefaultBoolean(true)
230+
@Config.Name("Pollution Dirt")
226231
public boolean renderDirtParticles;
227232

228233
@Config.Comment("if true, enables pollution fog when pollution reaches the threshold.")
229234
@Config.DefaultBoolean(true)
235+
@Config.Name("Pollution Fog")
230236
public boolean renderPollutionFog;
231237

232238
@Config.Comment("if true, enables the green -> red durability for an item's damage value.")
233239
@Config.DefaultBoolean(true)
240+
@Config.Name("Item Durability")
234241
public boolean renderItemDurabilityBar;
235242

236243
@Config.Comment("if true, enables the blue charge bar for an electric item's charge.")
237244
@Config.DefaultBoolean(true)
245+
@Config.Name("Item Charge Bar")
238246
public boolean renderItemChargeBar;
239247

240248
@Config.Comment("enables BaseMetaTileEntity block updates handled by BlockUpdateHandler.")
241249
@Config.DefaultBoolean(false)
250+
@Config.Name("Use BlockUpdateHandler")
242251
public boolean useBlockUpdateHandler;
243252

244253
@Config.Comment("Disables coil lighting. Requires world reload (f3 + a or relog).")
@@ -273,22 +282,27 @@ public static class Render {
273282

274283
@Config.Comment("Enables or disables Trans Metal rendering, also impacts motors, pistons etc with same rendering. Accessibility option.")
275284
@Config.DefaultBoolean(true)
285+
@Config.Name("Transcendent Metal Rendering")
276286
public boolean renderTransMetalFancy;
277287

278288
@Config.Comment("Enables or disables Infinity rendering, also impacts all items using the same effect. Accessibility option.")
279289
@Config.DefaultBoolean(true)
290+
@Config.Name("Infinity Rendering")
280291
public boolean renderInfinityFancy;
281292

282293
@Config.Comment("Enables or disables Cosmic Neutronium fuzz rendering, also impacts all items using the same effect. Accessibility option.")
283294
@Config.DefaultBoolean(true)
295+
@Config.Name("Cosmic Neutronium Rendering")
284296
public boolean renderCosmicNeutroniumFancy;
285297

286298
@Config.Comment("Enables or disables Six-Phased Copper glitch rendering, also impacts all items using the same effect. Accessibility option.")
287299
@Config.DefaultBoolean(true)
300+
@Config.Name("Six-Phased Copper Rendering")
288301
public boolean renderGlitchFancy;
289302

290303
@Config.Comment("Enables or disables Universium rendering, also impacts all items using the same effect. Accessibility option.")
291304
@Config.DefaultBoolean(true)
305+
@Config.Name("Universium Rendering")
292306
public boolean renderUniversiumFancy;
293307
}
294308

src/main/java/gregtech/common/gui/modularui/adapter/ShutdownReasonAdapter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ public void serialize(PacketBuffer buffer, ShutDownReason result) throws IOExcep
3131

3232
@Override
3333
public boolean areEqual(@NotNull ShutDownReason t1, @NotNull ShutDownReason t2) {
34+
// Simple reasons all share the same ID, so the key has to be compared as well, otherwise switching between
35+
// them is not detected and the reason never gets synced to the client.
3436
return t1.getID()
35-
.equals(t2.getID());
37+
.equals(t2.getID())
38+
&& t1.getKey()
39+
.equals(t2.getKey());
3640
}
3741
}

src/main/java/gregtech/common/gui/modularui/multiblock/base/MTEMultiBlockBaseGui.java

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import com.cleanroommc.modularui.value.sync.IntSyncValue;
5050
import com.cleanroommc.modularui.value.sync.LongSyncValue;
5151
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
52-
import com.cleanroommc.modularui.value.sync.StringSyncValue;
5352
import com.cleanroommc.modularui.widget.EmptyWidget;
5453
import com.cleanroommc.modularui.widget.ParentWidget;
5554
import com.cleanroommc.modularui.widget.Widget;
@@ -278,9 +277,7 @@ protected int getTerminalWidgetHeight() {
278277

279278
protected ListWidget<IWidget, ?> createTerminalTextWidget(PanelSyncManager syncManager, ModularPanel parent) {
280279
IntSyncValue startupCheckSyncer = new IntSyncValue(multiblock::getmStartUpCheck);
281-
StringSyncValue machineModeSyncer = new StringSyncValue(multiblock::getMachineModeName);
282280
syncManager.syncValue("startupCheck", startupCheckSyncer);
283-
syncManager.syncValue("machineModeName", machineModeSyncer);
284281

285282
return new ListWidget<>().fullWidth()
286283
.crossAxisAlignment(Alignment.CrossAxis.START)
@@ -289,7 +286,7 @@ protected int getTerminalWidgetHeight() {
289286
() -> IKey
290287
.dynamic(
291288
() -> StatCollector
292-
.translateToLocalFormatted("gt.interact.desc.mb.mode", machineModeSyncer.getStringValue()))
289+
.translateToLocalFormatted("gt.interact.desc.mb.mode", multiblock.getMachineModeName()))
293290
.asWidget()
294291
.marginBottom(2)
295292
.fullWidth())
@@ -339,13 +336,16 @@ protected IWidget createShutdownDurationWidget(PanelSyncManager syncManager) {
339336
}
340337

341338
protected IWidget createShutdownReasonWidget(PanelSyncManager syncManager) {
342-
StringSyncValue shutdownReasonSync = (StringSyncValue) syncManager
343-
.getSyncHandlerFromMapKey("shutdownDisplayString:0");
344-
return IKey.dynamic(shutdownReasonSync::getValue)
339+
return IKey.dynamic(
340+
() -> baseMetaTileEntity.getLastShutDownReason()
341+
.getDisplayString())
345342
.asWidget()
346343
.fullWidth()
347344
.marginBottom(2)
348-
.setEnabledIf(widget -> shouldShutdownReasonBeDisplayed(shutdownReasonSync.getValue()));
345+
.setEnabledIf(
346+
widget -> shouldShutdownReasonBeDisplayed(
347+
baseMetaTileEntity.getLastShutDownReason()
348+
.getDisplayString()));
349349
}
350350

351351
protected boolean shouldShutdownReasonBeDisplayed(String shutdownString) {
@@ -1108,22 +1108,20 @@ protected void makeMaintenanceHoverableTooltip(RichTooltip t, IntSyncValue maint
11081108

11091109
protected IWidget createShutdownReasonHoverableTerminal(PanelSyncManager syncManager) {
11101110
BooleanSyncValue wasShutdownSyncer = (BooleanSyncValue) syncManager.getSyncHandlerFromMapKey("wasShutdown:0");
1111-
StringSyncValue shutDownReasonSyncer = (StringSyncValue) syncManager
1112-
.getSyncHandlerFromMapKey("shutdownReasonKey:0");
11131111
return new HoverableIcon(new DynamicDrawable(() -> {
11141112
if (wasShutdownSyncer.getBoolValue()) {
1115-
return getTextureForReason(shutDownReasonSyncer.getValue());
1113+
return getTextureForReason(getShutDownReasonKey());
11161114
}
11171115
return null;
11181116
}).asIcon()).asWidget()
11191117
.size(18, 18)
11201118
.tooltipBuilder(t -> {
11211119
if (wasShutdownSyncer.getBoolValue()) {
1122-
t.add(getToolTipForReason(shutDownReasonSyncer.getValue()));
1120+
t.add(getToolTipForReason(getShutDownReasonKey()));
11231121
}
11241122
})
11251123
.tooltipAutoUpdate(true)
1126-
.setEnabledIf(widget -> shouldShutdownReasonBeDisplayed(shutDownReasonSyncer.getValue()));
1124+
.setEnabledIf(widget -> shouldShutdownReasonBeDisplayed(getShutDownReasonKey()));
11271125
}
11281126

11291127
protected IWidget createInventoryRow(ModularPanel panel, PanelSyncManager syncManager) {
@@ -1223,16 +1221,6 @@ protected void registerSyncValues(PanelSyncManager syncManager) {
12231221
.allowC2S();
12241222
syncManager.syncValue("shutdownReason", shutdownReasonSyncer);
12251223

1226-
syncManager.syncValue(
1227-
"shutdownDisplayString",
1228-
new StringSyncValue(
1229-
() -> baseMetaTileEntity.getLastShutDownReason()
1230-
.getDisplayString()));
1231-
syncManager.syncValue(
1232-
"shutdownReasonKey",
1233-
new StringSyncValue(
1234-
() -> baseMetaTileEntity.getLastShutDownReason()
1235-
.getKey()));
12361224
syncManager.syncValue(
12371225
"checkRecipeResult",
12381226
GenericSyncValue.builder(CheckRecipeResult.class)
@@ -1281,6 +1269,9 @@ public boolean isFluidEqual(FluidStack other) {
12811269

12821270
// Widget Specific
12831271
BooleanSyncValue powerSwitchSyncer = new BooleanSyncValue(multiblock::isAllowedToWork, bool -> {
1272+
// This setter also runs on the client when the value is synced from the server. Toggling the machine there
1273+
// would overwrite state the server just sent, such as the shutdown reason.
1274+
if (!baseMetaTileEntity.isServerSide()) return;
12841275
if (isPowerSwitchDisabled()) return;
12851276
if (bool) multiblock.enableWorking();
12861277
else {
@@ -1348,6 +1339,11 @@ protected void setMachineModeIcons() {}
13481339

13491340
// Method for registering Icons/Tooltip Text to specific ShutDownReasons. Override for custom icons/conditions.
13501341

1342+
protected String getShutDownReasonKey() {
1343+
return baseMetaTileEntity.getLastShutDownReason()
1344+
.getKey();
1345+
}
1346+
13511347
protected UITexture getTextureForReason(String key) {
13521348
return this.shutdownReasonTextureMap.getOrDefault(key, null);
13531349
}

src/main/java/gregtech/common/pollution/PollutionTooltip.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gregtech.common.pollution;
22

3+
import static com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil.formatNumber;
34
import static gregtech.api.enums.Mods.*;
45

56
import net.minecraft.init.Blocks;
@@ -27,16 +28,17 @@ public void getTooltip(ItemTooltipEvent event) {
2728
// Furnace and Iron Furnace
2829
if (GTUtility.areStacksEqual(event.itemStack, new ItemStack(Blocks.furnace))) {
2930
event.toolTip.add(
30-
StatCollector
31-
.translateToLocalFormatted(PRODUCES_POLLUTION_FORMAT, FurnacePollution.FURNACE.getPollution()));
31+
StatCollector.translateToLocalFormatted(
32+
PRODUCES_POLLUTION_FORMAT,
33+
formatNumber(FurnacePollution.FURNACE.getPollution())));
3234
}
3335

3436
if (GTUtility
3537
.areStacksEqual(event.itemStack, GTModHandler.getModItem(IndustrialCraft2.ID, "blockMachine", 1, 1))) {
3638
event.toolTip.add(
3739
StatCollector.translateToLocalFormatted(
3840
PRODUCES_POLLUTION_FORMAT,
39-
FurnacePollution.IRON_FURNACE.getPollution()));
41+
formatNumber(FurnacePollution.IRON_FURNACE.getPollution())));
4042
}
4143

4244
// Alchemical Furnace
@@ -47,7 +49,7 @@ public void getTooltip(ItemTooltipEvent event) {
4749
event.toolTip.add(
4850
StatCollector.translateToLocalFormatted(
4951
PRODUCES_POLLUTION_FORMAT,
50-
FurnacePollution.ALCHEMICAL_FURNACE.getPollution()));
52+
formatNumber(FurnacePollution.ALCHEMICAL_FURNACE.getPollution())));
5153
}
5254
}
5355

@@ -59,7 +61,7 @@ public void getTooltip(ItemTooltipEvent event) {
5961
event.toolTip.add(
6062
StatCollector.translateToLocalFormatted(
6163
PRODUCES_POLLUTION_FORMAT,
62-
FurnacePollution.ADVANCED_ALCHEMICAL_FURNACE.getPollution()));
64+
formatNumber(FurnacePollution.ADVANCED_ALCHEMICAL_FURNACE.getPollution())));
6365
}
6466
}
6567

@@ -73,7 +75,7 @@ public void getTooltip(ItemTooltipEvent event) {
7375
event.toolTip.add(
7476
StatCollector.translateToLocalFormatted(
7577
PRODUCES_POLLUTION_FORMAT,
76-
FurnacePollution.BLAST_FURNACE.getPollution()));
78+
formatNumber(FurnacePollution.BLAST_FURNACE.getPollution())));
7779
}
7880
}
7981

@@ -83,7 +85,7 @@ public void getTooltip(ItemTooltipEvent event) {
8385
event.toolTip.add(
8486
StatCollector.translateToLocalFormatted(
8587
PRODUCES_POLLUTION_FORMAT,
86-
FurnacePollution.NETHER_FURNACE.getPollution()));
88+
formatNumber(FurnacePollution.NETHER_FURNACE.getPollution())));
8789
}
8890
}
8991

@@ -94,7 +96,7 @@ public void getTooltip(ItemTooltipEvent event) {
9496
event.toolTip.add(
9597
StatCollector.translateToLocalFormatted(
9698
PRODUCES_POLLUTION_FORMAT,
97-
FurnacePollution.SLAB_FURNACE.getPollution()));
99+
formatNumber(FurnacePollution.SLAB_FURNACE.getPollution())));
98100
}
99101
}
100102
}
@@ -108,23 +110,24 @@ public void getTooltip(ItemTooltipEvent event) {
108110
event.toolTip.add(
109111
StatCollector.translateToLocalFormatted(
110112
"GT5U.tooltip.pollution.produces.firebox",
111-
PollutionConfig.fireboxPollutionAmount));
113+
formatNumber(PollutionConfig.fireboxPollutionAmount)));
112114
}
113115

114116
// Tunnel Bore
115117
if (GTUtility.areStacksEqual(event.itemStack, GTModHandler.getModItem(Railcraft.ID, "cart.bore", 1, 0))) {
116118
event.toolTip.add(
117119
StatCollector.translateToLocalFormatted(
118120
PRODUCES_POLLUTION_FORMAT,
119-
PollutionConfig.tunnelBorePollutionAmount));
121+
formatNumber(PollutionConfig.tunnelBorePollutionAmount)));
120122
}
121123

122124
// Coke Oven Brick
123125
if (GTUtility
124126
.areStacksEqual(event.itemStack, GTModHandler.getModItem(Railcraft.ID, "machine.alpha", 1, 7))) {
125127
event.toolTip.add(
126-
StatCollector
127-
.translateToLocalFormatted(MULTI_POLLUTION_FORMAT, PollutionConfig.cokeOvenPollutionAmount));
128+
StatCollector.translateToLocalFormatted(
129+
MULTI_POLLUTION_FORMAT,
130+
formatNumber(PollutionConfig.cokeOvenPollutionAmount)));
128131
}
129132

130133
// Advanced Coke Oven Brick
@@ -133,7 +136,7 @@ public void getTooltip(ItemTooltipEvent event) {
133136
event.toolTip.add(
134137
StatCollector.translateToLocalFormatted(
135138
MULTI_POLLUTION_FORMAT,
136-
PollutionConfig.advancedCokeOvenPollutionAmount));
139+
formatNumber(PollutionConfig.advancedCokeOvenPollutionAmount)));
137140
}
138141

139142
// Hobbyist's Steam Engine
@@ -142,7 +145,7 @@ public void getTooltip(ItemTooltipEvent event) {
142145
event.toolTip.add(
143146
StatCollector.translateToLocalFormatted(
144147
PRODUCES_POLLUTION_FORMAT,
145-
PollutionConfig.hobbyistEnginePollutionAmount));
148+
formatNumber(PollutionConfig.hobbyistEnginePollutionAmount)));
146149
}
147150
}
148151

@@ -160,11 +163,11 @@ public void getTooltip(ItemTooltipEvent event) {
160163
event.toolTip.add(
161164
StatCollector.translateToLocalFormatted(
162165
"GT5U.tooltip.pollution.produces.rocket.ignited",
163-
(PollutionConfig.rocketPollutionAmount * tier / 100)));
166+
formatNumber(PollutionConfig.rocketPollutionAmount * tier / 100)));
164167
event.toolTip.add(
165168
StatCollector.translateToLocalFormatted(
166169
"GT5U.tooltip.pollution.produces.rocket.flying",
167-
PollutionConfig.rocketPollutionAmount * tier));
170+
formatNumber(PollutionConfig.rocketPollutionAmount * tier)));
168171
break;
169172
}
170173
}

src/main/java/gregtech/common/tileentities/machines/multi/MTEMegaOilCracker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class MTEMegaOilCracker extends MTEExtendedPowerMultiBlockBase<MTEMegaOil
8686
{" D D ","DBAAAAAAAAABD"," A A "," AE E E E EA "," FE E E E EF "," AE E E E EA "," A A ","DBAAAAAAAAABD"," D D "},
8787
{" D D ","DBAAAAAAAAABD"," AE E E E EA "," L R "," LE E E E ER "," L R "," AE E E E EA ","DBAAAAAAAAABD"," D D "},
8888
{" D D ","DBAAAAAAAAABD"," FE E E E EF "," LE E E E ER "," LCCCCCCCCCR "," LE E E E ER "," FE E E E EF ","DBAAAAAAAAABD"," D D "},
89-
{" D D ","DBAAAAAAAAABD"," AE E E E EA "," L R "," LE ER "," L R "," AE E E E EA ","DBAAAAAAAAABD"," D D "},
89+
{" D D ","DBAAAAAAAAABD"," AE E E E EA "," L R "," LE E E E ER "," L R "," AE E E E EA ","DBAAAAAAAAABD"," D D "},
9090
{" D D ","DBAAAAAAAAABD"," A A "," AE E E E EA "," FE E E E EF "," AE E E E EA "," A A ","DBAAAAAAAAABD"," D D "},
9191
{"DBBBBB~BBBBBD","DBBBBBBBBBBBD","DBBBBBBBBBBBD","DBBBBBBBBBBBD","DBBBBBBBBBBBD","DBBBBBBBBBBBD","DBBBBBBBBBBBD","DBBBBBBBBBBBD","DBBBBBBBBBBBD"}
9292
}))
@@ -212,7 +212,7 @@ protected MultiblockTooltipBuilder createTooltip() {
212212
.addCasing("162", "Any Tiered Glass", true)
213213
.addCasing("145-151", "Naquadah Reinforced Distillation Casing", false)
214214
.addCasing("84", "Clean Stainless Steel Machine Casing", false)
215-
.addCasing("77", "Heating Coil", true)
215+
.addCasing("80", "Heating Coil", true)
216216
.addCasing("14", "Naquadah Sheetmetal", false)
217217
.addCasing("9", "Steel Pipe Casing", false)
218218
.addEnergyHatch("1+", "Any reinforced distillation casing", 1)

0 commit comments

Comments
 (0)