Skip to content

Commit a5523d4

Browse files
authored
Misc mui fixes (#5095)
1 parent 3c0b108 commit a5523d4

5 files changed

Lines changed: 28 additions & 8 deletions

File tree

docs/content/Modpacks/Changes/v8.0.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,5 @@ As a recipe-matching optimization, input handlers whose `getTotalContentAmount()
143143
- Refactored Jade provider code. Use the `MachineInfoProvider` class for jade providers for a specific machine type, and `MachineTraitProvider` for providers for a specific machine trait.
144144
- `GTUtil.getMoltenFluid(Material)` has been moved to `Material.getHotFluid()`.
145145
- `ICopyable::copyConfig`'s `CompoundTag` argument should now be mutated by reference instead of a new one returned (and thus, the return type has been changed to `void`).
146-
- Tiered Chance Boosting has been formally removed from the API (as it was deprecated in v7.0.) `ChancedInput` and `ChancedOutput` kubeJS calls will throw errors if they still had chance boost values as arguments.
146+
- Tiered Chance Boosting has been formally removed from the API (as it was deprecated in v7.0.) `ChancedInput` and `ChancedOutput` kubeJS calls will throw errors if they still had chance boost values as arguments.
147+
- Any custom `IDistinctPart`'s will have to implement `supportsDistinct` if they don't extend `ItemBusPartMachine`.

src/main/java/com/gregtechceu/gtceu/api/machine/feature/multiblock/IDistinctPart.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ public interface IDistinctPart {
55
boolean isDistinct();
66

77
void setDistinct(boolean isDistinct);
8+
9+
boolean supportsDistinct();
810
}

src/main/java/com/gregtechceu/gtceu/api/machine/mui/MachineUIPanelBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public MachineUIPanel build(PanelSyncManager syncManager, UISettings settings) {
8383
attachRight.child(GTMuiWidgets.createVoidingButton(voidable));
8484
}
8585
if (machine instanceof IDistinctPart distinctPart) {
86-
attachRight.child(GTMuiWidgets.createDistinctnessButton(distinctPart));
86+
attachRight.childIf(distinctPart.supportsDistinct(),
87+
() -> GTMuiWidgets.createDistinctnessButton(distinctPart));
8788
}
8889
}
8990

src/main/java/com/gregtechceu/gtceu/common/machine/electric/BatteryBufferMachine.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.gregtechceu.gtceu.common.mui.GTGuiTextures;
2020
import com.gregtechceu.gtceu.common.mui.GTMuiMachineUtil;
2121
import com.gregtechceu.gtceu.config.ConfigHolder;
22-
import com.gregtechceu.gtceu.utils.GTStringUtils;
22+
import com.gregtechceu.gtceu.utils.FormattingUtil;
2323
import com.gregtechceu.gtceu.utils.GTUtil;
2424

2525
import net.minecraft.core.Direction;
@@ -30,9 +30,9 @@
3030
import net.minecraftforge.energy.IEnergyStorage;
3131

3232
import brachy.modularui.api.drawable.IDrawable;
33-
import brachy.modularui.api.drawable.Text;
3433
import brachy.modularui.drawable.progress.ProgressDrawable;
3534
import brachy.modularui.factory.PosGuiData;
35+
import brachy.modularui.screen.RichTooltip;
3636
import brachy.modularui.screen.UISettings;
3737
import brachy.modularui.value.sync.DoubleSyncValue;
3838
import brachy.modularui.value.sync.PanelSyncManager;
@@ -152,10 +152,8 @@ public void buildMainUI(ParentWidget<?> mainWidget, PosGuiData guiData, PanelSyn
152152
.value(energyPercentage)
153153
.marginLeft(5)
154154
.size(18, 60)
155-
.addTooltipLine(Text.dynamic(() -> Component.literal(
156-
"%s/%s EU".formatted(
157-
GTStringUtils.formatInt(energyContainer.getEnergyStored()),
158-
GTStringUtils.formatInt(energyContainer.getEnergyCapacity()))))))
155+
.tooltipDynamic(this::getRichTooltip))
156+
.tooltipAutoUpdate(true)
159157
.child(GTMuiMachineUtil.createSlotGroupFromInventory(
160158
batteryInventory, "batteries",
161159
inventorySize, 'B',
@@ -167,6 +165,19 @@ public void buildMainUI(ParentWidget<?> mainWidget, PosGuiData guiData, PanelSyn
167165
mainWidget.child(flow);
168166
}
169167

168+
private void getRichTooltip(RichTooltip r) {
169+
if (GTUtil.isShiftDown()) {
170+
r.addLine(Component.literal(
171+
"%s/%s EU".formatted(
172+
energyContainer.getEnergyStored(), energyContainer.getEnergyCapacity())));
173+
} else {
174+
r.addLine(Component.literal(
175+
"%s/%s EU".formatted(
176+
FormattingUtil.formatNumberReadable(energyContainer.getEnergyStored()),
177+
FormattingUtil.formatNumberReadable(energyContainer.getEnergyCapacity()))));
178+
}
179+
}
180+
170181
private double getEnergyPercentage() {
171182
return (double) this.energyContainer.getEnergyStored() / this.energyContainer.getEnergyCapacity();
172183
}

src/main/java/com/gregtechceu/gtceu/common/machine/multiblock/part/ItemBusPartMachine.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ public void setDistinct(boolean distinct) {
136136
getHandlerList().setDistinctAndNotify(isDistinct);
137137
}
138138

139+
@Override
140+
public boolean supportsDistinct() {
141+
return !io.support(IO.OUT);
142+
}
143+
139144
@Override
140145
public int tintColor(int index) {
141146
if (index == 9) return getRealColor();

0 commit comments

Comments
 (0)