Skip to content

Commit 0fe9865

Browse files
authored
Update to MUI2 RC3 (#2702)
1 parent b9e8b49 commit 0fe9865

24 files changed

+124
-670
lines changed

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
dependencies {
4141
// Published dependencies
4242
api("codechicken:codechickenlib:3.2.3.358")
43-
api("com.cleanroommc:modularui:2.5.0-rc2") { transitive = false }
43+
api("com.cleanroommc:modularui:2.5.0-rc3") { transitive = false }
4444
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
4545
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
4646
api("appeng:ae2-uel:v0.56.4") { transitive = false }

src/main/java/gregtech/GregTechMod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
acceptedMinecraftVersions = "[1.12.2,1.13)",
3232
version = GTInternalTags.VERSION,
3333
dependencies = "required:forge@[14.23.5.2847,);" + "required-after:codechickenlib@[3.2.3,);" +
34-
"required-after:modularui@[2.3,);" + "required-after:mixinbooter@[8.0,);" + "after:appliedenergistics2;" +
34+
"required-after:modularui@[2.5.0-rc,);" + "required-after:mixinbooter@[8.0,);" +
35+
"after:appliedenergistics2;" +
3536
"after:forestry;" + "after:extrabees;" + "after:extratrees;" + "after:genetics;" + "after:magicbees;" +
3637
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.2.0,);" +
3738
"after:theoneprobe;" + "after:hwyla;")

src/main/java/gregtech/api/mui/GTGuis.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import net.minecraft.item.ItemStack;
1111

12+
import com.cleanroommc.modularui.api.IPanelHandler;
1213
import com.cleanroommc.modularui.factory.GuiManager;
1314
import com.cleanroommc.modularui.screen.ModularPanel;
1415
import com.cleanroommc.modularui.utils.Alignment;
@@ -103,6 +104,9 @@ public PopupPanel(@NotNull String name, int width, int height, boolean disableBe
103104
.onMousePressed(mouseButton -> {
104105
if (mouseButton == 0 || mouseButton == 1) {
105106
this.closeIfOpen(true);
107+
if (isSynced() && getSyncHandler() instanceof IPanelHandler handler) {
108+
handler.deleteCachedPanel();
109+
}
106110
return true;
107111
}
108112
return false;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package gregtech.api.mui;
2+
3+
import net.minecraft.client.resources.Locale;
4+
5+
// todo remove in next mui2 version
6+
public interface LocaleAccessor {
7+
8+
String gregtech$getRawKey(String s);
9+
10+
ThreadLocal<LocaleAccessor> accessor = new ThreadLocal<>();
11+
12+
static String getRawKey(String s) {
13+
if (accessor.get() == null) return s;
14+
return accessor.get().gregtech$getRawKey(s);
15+
}
16+
17+
static void setLocale(Locale locale) {
18+
accessor.set((LocaleAccessor) locale);
19+
}
20+
}

src/main/java/gregtech/api/mui/StateOverlay.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/main/java/gregtech/api/mui/UnboxFix.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ public GTFluidSyncHandler(IFluidTank tank) {
5252
@Override
5353
public void detectAndSendChanges(boolean init) {
5454
var current = getFluid();
55-
if (current == null && lastFluid == null) return;
56-
if (current == null || lastFluid == null || lastFluid.getFluid() != current.getFluid()) {
55+
if (init || current == null || lastFluid == null || current.isFluidEqual(lastFluid)) {
5756
lastFluid = current == null ? null : current.copy();
5857
syncToClient(UPDATE_TANK, buffer -> NetworkUtils.writeFluidStack(buffer, current));
59-
} else if (current.amount != lastFluid.amount) {
58+
} else if (lastFluid != null && current.amount != lastFluid.amount) {
6059
lastFluid.amount = current.amount;
6160
syncToClient(UPDATE_AMOUNT, buffer -> buffer.writeInt(current.amount));
6261
}

src/main/java/gregtech/common/covers/CoverConveyor.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import codechicken.lib.vec.Cuboid6;
4444
import codechicken.lib.vec.Matrix4;
4545
import com.cleanroommc.modularui.api.drawable.IDrawable;
46-
import com.cleanroommc.modularui.api.widget.Interactable;
4746
import com.cleanroommc.modularui.drawable.DynamicDrawable;
4847
import com.cleanroommc.modularui.factory.GuiData;
4948
import com.cleanroommc.modularui.factory.SidedPosGuiData;
@@ -545,7 +544,6 @@ protected ParentWidget<Flow> createUI(GuiData data, PanelSyncManager guiSyncMana
545544
.onMousePressed(mouseButton -> {
546545
int val = throughput.getValue() - getIncrementValue(MouseData.create(mouseButton));
547546
throughput.setValue(val, true, true);
548-
Interactable.playButtonClickSound();
549547
return true;
550548
})
551549
.onUpdateListener(w -> w.overlay(createAdjustOverlay(false))))
@@ -560,7 +558,6 @@ protected ParentWidget<Flow> createUI(GuiData data, PanelSyncManager guiSyncMana
560558
.onMousePressed(mouseButton -> {
561559
int val = throughput.getValue() + getIncrementValue(MouseData.create(mouseButton));
562560
throughput.setValue(val, true, true);
563-
Interactable.playButtonClickSound();
564561
return true;
565562
})
566563
.onUpdateListener(w -> w.overlay(createAdjustOverlay(true)))));

src/main/java/gregtech/common/covers/CoverPump.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import codechicken.lib.vec.Cuboid6;
4242
import codechicken.lib.vec.Matrix4;
4343
import com.cleanroommc.modularui.api.drawable.IDrawable;
44-
import com.cleanroommc.modularui.api.widget.Interactable;
4544
import com.cleanroommc.modularui.drawable.DynamicDrawable;
4645
import com.cleanroommc.modularui.factory.GuiData;
4746
import com.cleanroommc.modularui.factory.SidedPosGuiData;
@@ -226,7 +225,6 @@ protected ParentWidget<?> createUI(GuiData data, PanelSyncManager syncManager) {
226225
.onMousePressed(mouseButton -> {
227226
int val = throughput.getValue() - getIncrementValue(MouseData.create(mouseButton));
228227
throughput.setValue(val);
229-
Interactable.playButtonClickSound();
230228
return true;
231229
})
232230
.onUpdateListener(w -> w.overlay(createAdjustOverlay(false))))
@@ -241,7 +239,6 @@ protected ParentWidget<?> createUI(GuiData data, PanelSyncManager syncManager) {
241239
.onMousePressed(mouseButton -> {
242240
int val = throughput.getValue() + getIncrementValue(MouseData.create(mouseButton));
243241
throughput.setValue(val);
244-
Interactable.playButtonClickSound();
245242
return true;
246243
})
247244
.onUpdateListener(w -> w.overlay(createAdjustOverlay(true)))));

src/main/java/gregtech/common/covers/ender/CoverAbstractEnderLink.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import codechicken.lib.raytracer.CuboidRayTraceResult;
2727
import com.cleanroommc.modularui.api.drawable.IKey;
2828
import com.cleanroommc.modularui.api.widget.IWidget;
29-
import com.cleanroommc.modularui.api.widget.Interactable;
3029
import com.cleanroommc.modularui.drawable.DynamicDrawable;
3130
import com.cleanroommc.modularui.drawable.GuiTextures;
3231
import com.cleanroommc.modularui.drawable.Rectangle;
@@ -50,8 +49,9 @@
5049
import org.jetbrains.annotations.Nullable;
5150
import org.lwjgl.input.Keyboard;
5251

52+
import java.util.ArrayList;
53+
import java.util.List;
5354
import java.util.Objects;
54-
import java.util.Set;
5555
import java.util.UUID;
5656
import java.util.regex.Pattern;
5757

@@ -149,8 +149,7 @@ public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncMan
149149
protected Flow createWidgets(GuiData data, PanelSyncManager syncManager) {
150150
var name = new StringSyncValue(this::getColorStr, this::updateColor);
151151

152-
// todo unneeded cast in mui2 rc3
153-
var entrySelectorSH = (PanelSyncHandler) syncManager.panel("entry_selector", entrySelector(getType()), true);
152+
var entrySelectorSH = syncManager.panel("entry_selector", entrySelector(getType()), true);
154153

155154
return Flow.column().coverChildrenHeight().top(24)
156155
.margin(7, 0).widthRel(1f)
@@ -173,6 +172,7 @@ protected Flow createWidgets(GuiData data, PanelSyncManager syncManager) {
173172
.onMousePressed(i -> {
174173
if (entrySelectorSH.isPanelOpen()) {
175174
entrySelectorSH.closePanel();
175+
entrySelectorSH.deleteCachedPanel();
176176
} else {
177177
entrySelectorSH.openPanel();
178178
}
@@ -284,14 +284,19 @@ public void writeToNBT(@NotNull NBTTagCompound nbt) {
284284

285285
protected PanelSyncHandler.IPanelBuilder entrySelector(EntryTypes<T> type) {
286286
return (syncManager, syncHandler) -> {
287-
Set<String> names = VirtualEnderRegistry.getEntryNames(getOwner(), type);
287+
List<IWidget> rows = new ArrayList<>();
288+
for (String name : VirtualEnderRegistry.getEntryNames(getOwner(), type)) {
289+
rows.add(createRow(name, syncManager, type));
290+
}
288291
return GTGuis.createPopupPanel("entry_selector", 168, 112)
289292
.child(IKey.lang("cover.generic.ender.known_channels")
290293
.color(UI_TITLE_COLOR)
291294
.asWidget()
292295
.top(6)
293296
.left(4))
294-
.child(ListWidget.builder(names, name -> createRow(name, syncManager, type))
297+
.child(new ListWidget<>()
298+
.children(rows)
299+
// .builder(names, name -> createRow(name, syncManager, type))
295300
.background(GTGuiTextures.DISPLAY.asIcon()
296301
.width(168 - 8)
297302
.height(112 - 20))
@@ -391,7 +396,6 @@ protected IWidget createRow(final String name, final PanelSyncManager syncManage
391396
getOwner() == null ? "null" : getOwner().toString());
392397
NetworkUtils.writeStringSafe(buffer, name);
393398
});
394-
Interactable.playButtonClickSound();
395399
return true;
396400
}));
397401
}

0 commit comments

Comments
 (0)