Skip to content

Commit b1cd4da

Browse files
committed
Update to mc1.21.9
1 parent 98d1d1b commit b1cd4da

File tree

20 files changed

+170
-190
lines changed

20 files changed

+170
-190
lines changed

common/build.gradle

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ import util.PropUtil
22

33
plugins {
44
id("multiloader-common")
5-
id("net.neoforged.moddev")
6-
}
7-
8-
// Configure new ASM version
9-
configurations.configureEach {
10-
resolutionStrategy.eachDependency { details ->
11-
if (details.requested.group == "org.ow2.asm") {
12-
details.useVersion(asm_version)
13-
details.because("Mixin config plugin requires new ASM")
14-
}
15-
}
5+
id("fabric-loom")
166
}
177

188
// Configure common dependencies
199
dependencies {
10+
// Minecraft
11+
minecraft("com.mojang:minecraft:${minecraft_version}")
12+
13+
// Mappings
14+
mappings(loom.layered {
15+
officialMojangMappings()
16+
parchment("org.parchmentmc.data:parchment-${parchment_minecraft_version}:${parchment_version}@zip")
17+
})
18+
2019
// ASM
2120
compileOnly("org.ow2.asm:asm:${asm_version}")
2221
compileOnly("org.ow2.asm:asm-analysis:${asm_version}")
@@ -37,13 +36,13 @@ dependencies {
3736
return annotationProcessor(dep)
3837
break
3938
case "api": //noinspection DependencyNotationArgument
40-
return api(dep)
39+
return modApi(dep)
4140
break
4241
case "con": //noinspection DependencyNotationArgument
43-
return compileOnly(dep)
42+
return modCompileOnly(dep)
4443
break
4544
case "imp": //noinspection DependencyNotationArgument
46-
return implementation(dep)
45+
return modImplementation(dep)
4746
break
4847
case "-":
4948
return dep
@@ -55,17 +54,19 @@ dependencies {
5554
new PropUtil(project).applyDependencies(project.name, selector)
5655
}
5756

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
57+
// Configure Loom
58+
loom {
59+
// Apply common AccessWidener if it exists
60+
def aw = project(":common").file("src/main/resources/${mod_id}.accesswidener")
61+
if (aw.exists()) accessWidenerPath.set(aw)
62+
if (aw.exists()) {
63+
validateAccessWidener { accessWidener = aw }
64+
afterEvaluate {
65+
validateAccessWidener.run()
66+
}
67+
}
68+
mixin {
69+
defaultRefmapName.set("${mod_id}.refmap.json")
6970
}
7071
}
7172

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import dev.terminalmc.clientsort.client.config.Config;
2020
import dev.terminalmc.clientsort.client.interaction.InteractionManager;
2121
import dev.terminalmc.clientsort.client.order.SortOrder;
22-
import dev.terminalmc.clientsort.client.util.KeybindManager;
2322
import dev.terminalmc.clientsort.client.util.PolicyManager;
2423
import dev.terminalmc.clientsort.client.util.TaskManager;
2524
import dev.terminalmc.clientsort.mixin.client.accessor.AbstractContainerScreenAccessor;
@@ -32,8 +31,6 @@
3231
import net.minecraft.resources.ResourceLocation;
3332
import org.jetbrains.annotations.Nullable;
3433

35-
import static dev.terminalmc.clientsort.client.config.Config.options;
36-
3734
public class ClientSort {
3835

3936
public static final String MOD_ID = dev.terminalmc.clientsort.ClientSort.MOD_ID;
@@ -85,9 +82,6 @@ public static void afterConfigSaved(Config config) {
8582
// Update sorting item sets
8683
updateItemSets(options);
8784
}
88-
// Isolate keybinds
89-
if (options().isolateKeybinds)
90-
KeybindManager.isolateKeybinds();
9185
}
9286

9387
public static void updateItemTags(Config.Options options) {
@@ -116,11 +110,6 @@ public static void updateItemSets(Config.Options options) {
116110
}
117111
}
118112

119-
public static void afterGameStart() {
120-
if (options().isolateKeybinds)
121-
KeybindManager.isolateKeybinds();
122-
}
123-
124113
public static void setOverlayMessage(
125114
AbstractContainerScreen<?> screen,
126115
Component message,

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,6 @@ public enum ExtraSlotScope {
210210
public static final boolean allowSoundOverlapDefault = true;
211211
public boolean allowSoundOverlap = allowSoundOverlapDefault;
212212

213-
// Keybind options
214-
215-
public static final boolean isolateKeybindsDefault = true;
216-
public boolean isolateKeybinds = isolateKeybindsDefault;
217-
218213
// Button options
219214

220215
public static final boolean showButtonsDefault = false;

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,6 @@ else if (val > Config.Options.SOUND_VOLUME_MAX)
404404

405405
ConfigCategory keybinds = builder.getOrCreateCategory(localized("option", "keybinds"));
406406

407-
keybinds.addEntry(eb.startBooleanToggle(
408-
localized("option", "isolateKeybinds"),
409-
options.isolateKeybinds
410-
)
411-
.setTooltip(localized("option", "isolateKeybinds.tooltip"))
412-
.setDefaultValue(Config.Options.isolateKeybindsDefault)
413-
.setSaveConsumer(val -> options.isolateKeybinds = val)
414-
.build());
415-
416407
keybinds.addEntry((eb.startKeyCodeField(
417408
localized("key", "edit"),
418409
((KeyMappingAccessor) KeybindManager.EDIT_KEY).clientsort$getKey()

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import net.minecraft.client.gui.screens.ConfirmScreen;
3838
import net.minecraft.client.gui.screens.Screen;
3939
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
40+
import net.minecraft.client.input.KeyEvent;
41+
import net.minecraft.client.input.MouseButtonEvent;
4042
import net.minecraft.network.chat.CommonComponents;
4143
import net.minecraft.network.chat.Component;
4244
import net.minecraft.world.SimpleContainer;
@@ -521,9 +523,9 @@ public void saveAndClose() {
521523
* Allows pressing the arrow keys to reposition the set of buttons.
522524
*/
523525
@Override
524-
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
525-
int distance = Screen.hasShiftDown() ? 6 : 1;
526-
@Nullable Vec2i movement = switch (keyCode) {
526+
public boolean keyPressed(KeyEvent event) {
527+
int distance = event.hasShiftDown() ? 6 : 1;
528+
@Nullable Vec2i movement = switch (event.key()) {
527529
case InputConstants.KEY_LEFT -> new Vec2i(-distance, 0);
528530
case InputConstants.KEY_RIGHT -> new Vec2i(distance, 0);
529531
case InputConstants.KEY_UP -> new Vec2i(0, -distance);
@@ -538,29 +540,29 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
538540
repositionButtons(rep, before);
539541
return true;
540542
}
541-
return super.keyPressed(keyCode, scanCode, modifiers);
543+
return super.keyPressed(event);
542544
}
543545

544546
/**
545547
* Allows dragging the selected widget to reposition it.
546548
*/
547549
@Override
548-
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
549-
if (super.mouseClicked(mouseX, mouseY, mouseButton)) {
550+
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
551+
if (super.mouseClicked(event, doubleClick)) {
550552
dragging = false;
551553
return true;
552554
} else {
553555
for (TriggerButton cb : buttons) {
554-
if (cb.isMouseOver(mouseX, mouseY)) {
555-
cb.mouseClicked(mouseX, mouseY, mouseButton);
556+
if (cb.isMouseOver(event.x(), event.y())) {
557+
cb.mouseClicked(event, doubleClick);
556558
rep = cb;
557559
dragging = true;
558560
return true;
559561
}
560562
}
561563
for (Slot slot : underlay.getMenu().slots) {
562564
if (((AbstractContainerScreenAccessor) underlay)
563-
.clientsort$isHovering(slot, mouseX, mouseY)) {
565+
.clientsort$isHovering(slot, event.x(), event.y())) {
564566
Object object = getObj(slot, underlay.getMenu());
565567
if (object != null && object.getClass().getName().equals(lowestPolicyKey)) {
566568
int slotId = ((ISlot) slot).clientsort$getIndexInContainer();
@@ -579,31 +581,25 @@ public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
579581
* Allows dragging the selected widget to reposition it.
580582
*/
581583
@Override
582-
public boolean mouseDragged(
583-
double mouseX,
584-
double mouseY,
585-
int button,
586-
double dragX,
587-
double dragY
588-
) {
584+
public boolean mouseDragged(MouseButtonEvent event, double dragX, double dragY) {
589585
if (dragging) {
590586
Vec2i before = rep.offset;
591-
if (rep.mouseDragged(mouseX, mouseY, button, dragX, dragY)) {
587+
if (rep.mouseDragged(event, dragX, dragY)) {
592588
// Move the other buttons to match the rep's movement
593589
repositionButtons(rep, before);
594590
return true;
595591
}
596592
}
597-
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
593+
return super.mouseDragged(event, dragX, dragY);
598594
}
599595

600596
/**
601597
* Allows dragging the selected widget to reposition it.
602598
*/
603599
@Override
604-
public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) {
600+
public boolean mouseReleased(MouseButtonEvent event) {
605601
dragging = false;
606-
return super.mouseReleased(mouseX, mouseY, mouseButton);
602+
return super.mouseReleased(event);
607603
}
608604

609605
/**

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.minecraft.client.gui.components.StringWidget;
3030
import net.minecraft.client.gui.screens.Screen;
3131
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
32+
import net.minecraft.client.input.MouseButtonEvent;
3233
import net.minecraft.network.chat.CommonComponents;
3334
import org.jetbrains.annotations.NotNull;
3435

@@ -155,12 +156,12 @@ public void onClose() {
155156
}
156157

157158
@Override
158-
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
159-
if (super.mouseClicked(mouseX, mouseY, mouseButton)) {
159+
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
160+
if (super.mouseClicked(event, doubleClick)) {
160161
return true;
161162
} else {
162163
for (TriggerButton cb : buttons) {
163-
if (cb.isMouseOver(mouseX, mouseY)) {
164+
if (cb.isMouseOver(event.x(), event.y())) {
164165
cb.playDownSound(Minecraft.getInstance().getSoundManager());
165166
onClose();
166167
cb.openEditScreen();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import dev.terminalmc.clientsort.client.config.Vec2i;
2525
import dev.terminalmc.clientsort.client.inventory.operator.SingleUseOperator;
2626
import dev.terminalmc.clientsort.client.order.SortOrder;
27+
import dev.terminalmc.clientsort.client.util.KeybindManager;
2728
import net.minecraft.client.gui.components.WidgetSprites;
28-
import net.minecraft.client.gui.screens.Screen;
2929
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
3030
import net.minecraft.network.chat.Component;
3131
import net.minecraft.resources.ResourceLocation;
@@ -70,11 +70,11 @@ public SortButton(
7070
policy != null && policy.showSortButton(),
7171
(button) -> {
7272
SortOrder sortOrder = options().sortOrder;
73-
if (Screen.hasShiftDown()) {
73+
if (KeybindManager.hasShiftDown()) {
7474
sortOrder = options().shiftSortOrder;
75-
} else if (Screen.hasControlDown()) {
75+
} else if (KeybindManager.hasControlDown()) {
7676
sortOrder = options().ctrlSortOrder;
77-
} else if (Screen.hasAltDown()) {
77+
} else if (KeybindManager.hasAltDown()) {
7878
sortOrder = options().altSortOrder;
7979
}
8080

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import net.minecraft.client.gui.components.Tooltip;
3434
import net.minecraft.client.gui.components.WidgetSprites;
3535
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
36-
import net.minecraft.client.gui.screens.Screen;
3736
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
37+
import net.minecraft.client.input.MouseButtonEvent;
3838
import net.minecraft.client.renderer.RenderPipelines;
3939
import net.minecraft.network.chat.CommonComponents;
4040
import net.minecraft.network.chat.Component;
@@ -110,12 +110,12 @@ protected TriggerButton(
110110
}
111111

112112
@Override
113-
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
114-
if (isMouseOver(mouseX, mouseY)) {
115-
boolean rightClick = mouseButton == InputConstants.MOUSE_BUTTON_RIGHT;
113+
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
114+
if (isMouseOver(event.x(), event.y())) {
115+
boolean rightClick = event.button() == InputConstants.MOUSE_BUTTON_RIGHT;
116116
if (Minecraft.getInstance().screen instanceof EditorScreen) {
117117
if (rightClick) {
118-
if (Screen.hasShiftDown()) {
118+
if (event.hasShiftDown()) {
119119
operationAllowed = !operationAllowed;
120120
} else {
121121
active = !active;
@@ -127,7 +127,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
127127
return true;
128128
}
129129
}
130-
return super.mouseClicked(mouseX, mouseY, mouseButton);
130+
return super.mouseClicked(event, doubleClick);
131131
}
132132

133133
/**
@@ -207,19 +207,19 @@ public void renderWidget(
207207
}
208208

209209
@Override
210-
protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) {
210+
protected void onDrag(MouseButtonEvent event, double dragX, double dragY) {
211211
if (Minecraft.getInstance().screen instanceof EditorScreen) {
212212
AbstractContainerScreenAccessor acs = (AbstractContainerScreenAccessor) screen;
213-
int newX = Math.clamp((int) mouseX - HALF_WIDTH, 0, screen.width - WIDTH);
214-
int newY = Math.clamp((int) mouseY - HALF_HEIGHT, 0, screen.height - HEIGHT);
213+
int newX = Math.clamp((int) event.x() - HALF_WIDTH, 0, screen.width - WIDTH);
214+
int newY = Math.clamp((int) event.y() - HALF_HEIGHT, 0, screen.height - HEIGHT);
215215

216216
offset = new Vec2i(
217217
newX - (acs.clientsort$getLeftPos() + acs.clientsort$getImageWidth()),
218218
newY - (acs.clientsort$getTopPos()
219219
+ Math.clamp(referenceSlot.y, 0, screen.height))
220220
);
221221
} else {
222-
super.onDrag(mouseX, mouseY, dragX, dragY);
222+
super.onDrag(event, dragX, dragY);
223223
}
224224
}
225225

0 commit comments

Comments
 (0)