Skip to content

Commit 11edc7a

Browse files
committed
actually mark dirty on change
only add muffler and maint line they're enabled
1 parent 3864b05 commit 11edc7a

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIFactory.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ public class MultiblockUIFactory {
5959

6060
public MultiblockUIFactory(@NotNull MultiblockWithDisplayBase mte) {
6161
this.mte = mte;
62-
configureErrorText(builder -> builder.addMufflerObstructedLine(!mte.isMufflerFaceFree()));
63-
configureWarningText(builder -> builder.addMaintenanceProblemLines(mte.getMaintenanceProblems()));
62+
configureErrorText(builder -> {
63+
if (mte.hasMufflerMechanics())
64+
builder.addMufflerObstructedLine(!mte.isMufflerFaceFree());
65+
});
66+
configureWarningText(builder -> {
67+
if (mte.hasMaintenanceMechanics())
68+
builder.addMaintenanceProblemLines(mte.getMaintenanceProblems());
69+
});
6470
configureDisplayText(builder -> builder.title(mte.getMetaFullName()).structureFormed(mte.isStructureFormed()));
6571
}
6672

@@ -816,11 +822,11 @@ public Builder addCustom(Consumer<List<IDrawable>> customConsumer) {
816822
}
817823

818824
public boolean isEmpty() {
819-
return textList.isEmpty();
825+
return this.textList.isEmpty();
820826
}
821827

822828
public void clear() {
823-
textList.clear();
829+
this.textList.clear();
824830
}
825831

826832
protected boolean hasChanged() {
@@ -846,8 +852,12 @@ private SyncHandler makeSyncHandler() {
846852
@Override
847853
public void detectAndSendChanges(boolean init) {
848854
if (init || hasChanged()) {
849-
if (init) build();
855+
if (init) {
856+
onRebuild();
857+
build();
858+
}
850859
sync(0, this::syncText);
860+
markDirty();
851861
}
852862
}
853863

@@ -877,9 +887,7 @@ public void readOnServer(int id, PacketBuffer buf) {}
877887

878888
public void build(IRichTextBuilder<?> richText) {
879889
if (dirty) {
880-
if (this.onRebuild != null) {
881-
this.onRebuild.run();
882-
}
890+
onRebuild();
883891
build();
884892
dirty = false;
885893
}
@@ -888,12 +896,18 @@ public void build(IRichTextBuilder<?> richText) {
888896
}
889897
}
890898

899+
private void onRebuild() {
900+
if (this.onRebuild != null) {
901+
this.onRebuild.run();
902+
}
903+
}
904+
891905
public void markDirty() {
892906
dirty = true;
893907
}
894908

895909
protected void build() {
896-
this.textList.clear();
910+
clear();
897911
if (this.action != null) this.action.accept(this);
898912
}
899913

0 commit comments

Comments
 (0)