Skip to content

Commit 204e5eb

Browse files
committed
Update to mc1.21.11
1 parent 2f17a8a commit 204e5eb

32 files changed

+190
-180
lines changed

common/build.gradle

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import util.PropUtil
22

33
plugins {
44
id("multiloader-common")
5-
id("net.neoforged.moddev")
5+
id("fabric-loom")
66
}
77

88
// Configure new ASM version
@@ -24,6 +24,15 @@ dependencies {
2424
compileOnly("org.ow2.asm:asm-tree:${asm_version}")
2525
compileOnly("org.ow2.asm:asm-util:${asm_version}")
2626

27+
// Minecraft
28+
minecraft("com.mojang:minecraft:${minecraft_version}")
29+
30+
// Mappings
31+
mappings(loom.layered {
32+
officialMojangMappings()
33+
parchment("org.parchmentmc.data:parchment-${parchment_minecraft_version}:${parchment_version}@zip")
34+
})
35+
2736
// Mixin
2837
compileOnly("org.spongepowered:mixin:${mixin_version}")
2938

@@ -37,13 +46,13 @@ dependencies {
3746
return annotationProcessor(dep)
3847
break
3948
case "api": //noinspection DependencyNotationArgument
40-
return api(dep)
49+
return modApi(dep)
4150
break
4251
case "con": //noinspection DependencyNotationArgument
43-
return compileOnly(dep)
52+
return modCompileOnly(dep)
4453
break
4554
case "imp": //noinspection DependencyNotationArgument
46-
return implementation(dep)
55+
return modImplementation(dep)
4756
break
4857
case "-":
4958
return dep
@@ -55,17 +64,16 @@ dependencies {
5564
new PropUtil(project).applyDependencies(project.name, selector)
5665
}
5766

58-
// Configure ModDevGradle
59-
neoForge {
60-
neoFormVersion = neoform_version
61-
// Apply common AccessTransformer if it exists
62-
def at = file("src/main/resources/META-INF/accesstransformer.cfg")
63-
if (at.exists()) accessTransformers.from(at.absolutePath)
64-
validateAccessTransformers = true
65-
// Apply Parchment mappings
66-
parchment {
67-
minecraftVersion = parchment_minecraft_version
68-
mappingsVersion = parchment_version
67+
// Configure Loom
68+
loom {
69+
// Apply common AccessWidener if it exists
70+
def aw = file("src/main/resources/${mod_id}.accesswidener")
71+
if (aw.exists()) accessWidenerPath.set(aw)
72+
if (aw.exists()) {
73+
validateAccessWidener { accessWidener = aw }
74+
afterEvaluate {
75+
validateAccessWidener.run()
76+
}
6977
}
7078
}
7179

common/src/main/java/dev/terminalmc/clientsort/client/ClientSort.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
2929
import net.minecraft.core.registries.BuiltInRegistries;
3030
import net.minecraft.network.chat.Component;
31-
import net.minecraft.resources.ResourceLocation;
31+
import net.minecraft.resources.Identifier;
3232
import org.jetbrains.annotations.Nullable;
3333

3434
import java.util.concurrent.ArrayBlockingQueue;
@@ -74,7 +74,7 @@ public static void afterConfigSaved(Config config) {
7474
options.ctrlSortOrder = SortOrder.SORT_ORDERS.get(options.ctrlSortOrderStr);
7575
options.altSortOrder = SortOrder.SORT_ORDERS.get(options.altSortOrderStr);
7676
// Parse sound location string
77-
options.sortSoundLoc = ResourceLocation.tryParse(options.interactionSound);
77+
options.sortSoundLoc = Identifier.tryParse(options.interactionSound);
7878
// Update interaction manager tick rate
7979
InteractionManager.setTickRate(options.interactionInterval);
8080
// Update class cache
@@ -102,14 +102,14 @@ public static void updateItemSets(Config.Options options) {
102102
int i = 0;
103103
for (String s : options.startOverrideItems) {
104104
int idx = i++;
105-
BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(s))
105+
BuiltInRegistries.ITEM.getOptional(Identifier.tryParse(s))
106106
.ifPresent((item) -> options.startOverrideMap.put(item, idx));
107107
}
108108
options.endOverrideMap.clear();
109109
i = 0;
110110
for (String s : options.endOverrideItems) {
111111
int idx = i++;
112-
BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(s))
112+
BuiltInRegistries.ITEM.getOptional(Identifier.tryParse(s))
113113
.ifPresent((item) -> options.endOverrideMap.put(item, idx));
114114
}
115115
}

common/src/main/java/dev/terminalmc/clientsort/client/config/Config.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import dev.terminalmc.clientsort.client.config.legacy.ButtonLayout;
2323
import dev.terminalmc.clientsort.client.order.SortOrder;
2424
import dev.terminalmc.clientsort.platform.services.PlatformServices;
25-
import net.minecraft.resources.ResourceLocation;
25+
import net.minecraft.resources.Identifier;
2626
import net.minecraft.world.entity.player.Inventory;
2727
import net.minecraft.world.inventory.*;
2828
import net.minecraft.world.item.Item;
@@ -185,8 +185,8 @@ public enum ExtraSlotScope {
185185
public static final String interactionSoundDefault = "minecraft:block.note_block.xylophone";
186186
public String interactionSound = interactionSoundDefault;
187187
public static Validator<String> interactionSoundValidator = (val) -> val != null
188-
&& ResourceLocation.tryParse(val) != null ? val : interactionSoundDefault;
189-
public transient @Nullable ResourceLocation sortSoundLoc = null;
188+
&& Identifier.tryParse(val) != null ? val : interactionSoundDefault;
189+
public transient @Nullable Identifier sortSoundLoc = null;
190190

191191
public static final int SOUND_INTERVAL_MIN = 1;
192192
public static final int SOUND_INTERVAL_MAX = 100;

common/src/main/java/dev/terminalmc/clientsort/client/config/Operation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import dev.terminalmc.clientsort.network.payload.StackFillPayload;
2121
import dev.terminalmc.clientsort.network.payload.TransferPayload;
2222
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
23-
import net.minecraft.resources.ResourceLocation;
23+
import net.minecraft.resources.Identifier;
2424

2525
public enum Operation {
2626
SORT(SortPayload.TYPE, "sort"),
@@ -29,7 +29,7 @@ public enum Operation {
2929
TRANSFER(TransferPayload.TYPE, "transfer");
3030

3131
public final CustomPacketPayload.Type<?> type;
32-
public final ResourceLocation id;
32+
public final Identifier id;
3333
public final String translationKey;
3434

3535
Operation(CustomPacketPayload.Type<?> type, String translationKey) {

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/config/ClothScreenProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import net.minecraft.ChatFormatting;
3535
import net.minecraft.client.gui.screens.Screen;
3636
import net.minecraft.network.chat.Component;
37-
import net.minecraft.resources.ResourceLocation;
37+
import net.minecraft.resources.Identifier;
3838

3939
import java.text.ParseException;
4040
import java.util.*;
@@ -365,8 +365,8 @@ else if (val > Config.Options.AUTO_OP_DELAY_MAX)
365365
.setDefaultValue(Config.Options.interactionSoundDefault)
366366
.setSaveConsumer(val -> options.interactionSound = val)
367367
.setErrorSupplier(val -> {
368-
if (ResourceLocation.tryParse(val) == null)
369-
return Optional.of(localized("error", "resourceLocation.parse"));
368+
if (Identifier.tryParse(val) == null)
369+
return Optional.of(localized("error", "Identifier.parse"));
370370
else
371371
return Optional.empty();
372372
})

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/config/ConfigScreenProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
package dev.terminalmc.clientsort.client.gui.screen.config;
1818

19-
import net.minecraft.Util;
2019
import net.minecraft.client.Minecraft;
2120
import net.minecraft.client.gui.components.Button;
2221
import net.minecraft.client.gui.components.MultiLineTextWidget;
2322
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
2423
import net.minecraft.client.gui.screens.Screen;
2524
import net.minecraft.network.chat.CommonComponents;
25+
import net.minecraft.util.Util;
2626

2727
import static dev.terminalmc.clientsort.util.Localization.localized;
2828

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/edit/EditorScreen.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public EditorScreen(
102102
Screen lastScreen
103103
) {
104104
super(localized("title", "positionEditor"));
105-
this.font = Minecraft.getInstance().font;
106105
this.lastScreen = lastScreen;
107106
this.underlay = underlay;
108107
this.isPlayerInv = isPlayerInv;
@@ -118,7 +117,7 @@ public void init() {
118117
super.init();
119118

120119
// Resize the underlay
121-
underlay.init(Minecraft.getInstance(), width, height);
120+
underlay.init(width, height);
122121

123122
// Reload buttons from the manager
124123
if (!reloadButtonsAndIgnoredSlots()) {
@@ -379,11 +378,11 @@ private void rebuildGui() {
379378
movingY += 21;
380379

381380
// Switch between offset types
382-
CycleButton<Boolean> switchOffsetTypeButton = CycleButton.booleanBuilder(
381+
CycleButton<@NotNull Boolean> switchOffsetTypeButton = CycleButton.booleanBuilder(
383382
localized("editor", "switchOffsetType.slot"),
384-
localized("editor", "switchOffsetType.edge")
383+
localized("editor", "switchOffsetType.edge"),
384+
offsetFromSlot
385385
)
386-
.withInitialValue(offsetFromSlot)
387386
.withTooltip((v) -> Tooltip.create(localized(
388387
"editor",
389388
"switchOffsetType.tooltip." + (v ? "slot" : "edge")
@@ -442,13 +441,13 @@ private void rebuildGui() {
442441
movingY += 21;
443442

444443
// Change the auto trigger behavior
445-
CycleButton<Boolean> autoOpOtherButton = CycleButton.booleanBuilder(
444+
CycleButton<@NotNull Boolean> autoOpOtherButton = CycleButton.booleanBuilder(
446445
Component.literal("1").withStyle(ChatFormatting.RED),
447-
Component.literal("0").withStyle(ChatFormatting.GREEN)
446+
Component.literal("0").withStyle(ChatFormatting.GREEN),
447+
autoOpOther
448448
)
449449
.withTooltip((v) -> Tooltip.create(localized("editor", "autoOp.other.tooltip")))
450450
.displayOnlyValue()
451-
.withInitialValue(autoOpOther)
452451
.create(
453452
x + width - 10,
454453
movingY,
@@ -458,15 +457,16 @@ private void rebuildGui() {
458457
(b, v) -> autoOpOther = v
459458
);
460459
addRenderableWidget(autoOpOtherButton);
461-
CycleButton<Integer> autoOpButton = CycleButton.<Integer>builder((v) -> v == 0
462-
? localized("editor", "autoOp.none")
463-
: localized("key", "op." + Operation.values()[v - 1].translationKey))
460+
CycleButton<@NotNull Integer> autoOpButton = CycleButton.builder(
461+
(v) -> v == 0
462+
? localized("editor", "autoOp.none")
463+
: localized("key", "op." + Operation.values()[v - 1].translationKey),
464+
autoOp == null
465+
? 0
466+
: List.of(Operation.values()).indexOf(autoOp) + 1
467+
)
464468
.withTooltip((v) -> Tooltip.create(localized("editor", "autoOp.tooltip")))
465469
.withValues(0, 1, 2, 3, 4)
466-
.withInitialValue(autoOp == null
467-
? 0
468-
: List.of(Operation.values()).indexOf(autoOp) + 1
469-
)
470470
.create(
471471
x,
472472
movingY,
@@ -640,7 +640,7 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
640640

641641
// Render editable widgets again, above background blur
642642
for (TriggerButton cb : buttons) {
643-
cb.renderWidget(graphics, mouseX, mouseY, partialTick);
643+
cb.renderContents(graphics, mouseX, mouseY, partialTick);
644644
}
645645
}
646646

@@ -695,7 +695,7 @@ private void drawLineFor(GuiGraphics graphics, TriggerButton button) {
695695
@Override
696696
public void onClose() {
697697
super.onClose();
698-
lastScreen.init(Minecraft.getInstance(), width, height);
698+
lastScreen.init(width, height);
699699
Minecraft.getInstance().setScreen(lastScreen);
700700
}
701701

@@ -745,7 +745,7 @@ public boolean keyPressed(KeyEvent event) {
745745
* Allows dragging the selected widget to reposition it.
746746
*/
747747
@Override
748-
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
748+
public boolean mouseClicked(@NotNull MouseButtonEvent event, boolean doubleClick) {
749749
if (super.mouseClicked(event, doubleClick)) {
750750
dragging = false;
751751
return true;
@@ -780,7 +780,7 @@ public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
780780
* Allows dragging the selected widget to reposition it.
781781
*/
782782
@Override
783-
public boolean mouseDragged(MouseButtonEvent event, double dragX, double dragY) {
783+
public boolean mouseDragged(@NotNull MouseButtonEvent event, double dragX, double dragY) {
784784
if (dragging) {
785785
Vec2i before = rep.offset;
786786
if (rep.mouseDragged(event, dragX, dragY)) {
@@ -796,7 +796,7 @@ public boolean mouseDragged(MouseButtonEvent event, double dragX, double dragY)
796796
* Allows dragging the selected widget to reposition it.
797797
*/
798798
@Override
799-
public boolean mouseReleased(MouseButtonEvent event) {
799+
public boolean mouseReleased(@NotNull MouseButtonEvent event) {
800800
dragging = false;
801801
return super.mouseReleased(event);
802802
}

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/edit/SelectorScreen.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@ public SelectorScreen(AbstractContainerScreen<?> underlay) {
4949

5050
public SelectorScreen(AbstractContainerScreen<?> underlay, Screen lastScreen) {
5151
super(localized("title", "groupSelector"));
52-
this.font = Minecraft.getInstance().font;
5352
this.underlay = underlay;
5453
this.lastScreen = lastScreen;
5554
}
5655

5756
@Override
5857
public void init() {
5958
super.init();
60-
underlay.init(Minecraft.getInstance(), width, height);
59+
underlay.init(width, height);
6160
reloadButtons();
6261
rebuildGui();
6362
}
@@ -71,11 +70,12 @@ private void reloadButtons() {
7170
private void rebuildGui() {
7271
clearWidgets();
7372

74-
CycleButton<Boolean> toggleButton =
73+
CycleButton<@NotNull Boolean> toggleButton =
7574
CycleButton.booleanBuilder(
7675
localized("editor", "enabled").withStyle(ChatFormatting.GREEN),
77-
localized("editor", "disabled").withStyle(ChatFormatting.RED)
78-
).withInitialValue(options().showButtons).create(
76+
localized("editor", "disabled").withStyle(ChatFormatting.RED),
77+
options().showButtons
78+
).create(
7979
width / 2 - 125,
8080
height - 22,
8181
120,
@@ -112,7 +112,7 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
112112

113113
if (options().showButtons) {
114114
for (TriggerButton cb : buttons) {
115-
cb.renderWidget(graphics, mouseX, mouseY, partialTick);
115+
cb.renderContents(graphics, mouseX, mouseY, partialTick);
116116
}
117117
}
118118
}
@@ -149,13 +149,13 @@ public void onClose() {
149149
if (lastScreen instanceof EditorScreen pes && !options().showButtons) {
150150
pes.onClose();
151151
} else {
152-
lastScreen.init(Minecraft.getInstance(), width, height);
152+
lastScreen.init(width, height);
153153
Minecraft.getInstance().setScreen(lastScreen);
154154
}
155155
}
156156

157157
@Override
158-
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
158+
public boolean mouseClicked(@NotNull MouseButtonEvent event, boolean doubleClick) {
159159
if (super.mouseClicked(event, doubleClick)) {
160160
return true;
161161
} else {

common/src/main/java/dev/terminalmc/clientsort/client/gui/widget/MatchTransferButton.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import net.minecraft.client.gui.components.WidgetSprites;
2424
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
2525
import net.minecraft.network.chat.Component;
26-
import net.minecraft.resources.ResourceLocation;
26+
import net.minecraft.resources.Identifier;
2727
import net.minecraft.world.Container;
2828
import net.minecraft.world.inventory.Slot;
2929
import org.jetbrains.annotations.Nullable;
@@ -36,23 +36,23 @@
3636
public class MatchTransferButton extends TriggerButton {
3737

3838
private static final WidgetSprites SPRITES_UP = new WidgetSprites(
39-
ResourceLocation.fromNamespaceAndPath(ClientSort.MOD_ID, "widget/match_transfer_up"),
40-
ResourceLocation.fromNamespaceAndPath(
39+
Identifier.fromNamespaceAndPath(ClientSort.MOD_ID, "widget/match_transfer_up"),
40+
Identifier.fromNamespaceAndPath(
4141
ClientSort.MOD_ID,
4242
"widget/match_transfer_up_disabled"
4343
),
44-
ResourceLocation.fromNamespaceAndPath(
44+
Identifier.fromNamespaceAndPath(
4545
ClientSort.MOD_ID,
4646
"widget/match_transfer_up_highlighted"
4747
)
4848
);
4949
private static final WidgetSprites SPRITES_DOWN = new WidgetSprites(
50-
ResourceLocation.fromNamespaceAndPath(ClientSort.MOD_ID, "widget/match_transfer_down"),
51-
ResourceLocation.fromNamespaceAndPath(
50+
Identifier.fromNamespaceAndPath(ClientSort.MOD_ID, "widget/match_transfer_down"),
51+
Identifier.fromNamespaceAndPath(
5252
ClientSort.MOD_ID,
5353
"widget/match_transfer_down_disabled"
5454
),
55-
ResourceLocation.fromNamespaceAndPath(
55+
Identifier.fromNamespaceAndPath(
5656
ClientSort.MOD_ID,
5757
"widget/match_transfer_down_highlighted"
5858
)

0 commit comments

Comments
 (0)