Skip to content

Commit 0d5bde5

Browse files
committed
Update to mc1.21.9
1 parent 9e949ec commit 0d5bde5

22 files changed

Lines changed: 235 additions & 261 deletions

common/build.gradle

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

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

88
// Configure common dependencies
99
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+
1019
// Mixin
1120
compileOnly("org.spongepowered:mixin:${mixin_version}")
1221

@@ -20,13 +29,13 @@ dependencies {
2029
return annotationProcessor(dep)
2130
break
2231
case "api": //noinspection DependencyNotationArgument
23-
return api(dep)
32+
return modApi(dep)
2433
break
2534
case "con": //noinspection DependencyNotationArgument
26-
return compileOnly(dep)
35+
return modCompileOnly(dep)
2736
break
2837
case "imp": //noinspection DependencyNotationArgument
29-
return implementation(dep)
38+
return modImplementation(dep)
3039
break
3140
case "-":
3241
return dep
@@ -38,17 +47,19 @@ dependencies {
3847
new PropUtil(project).applyDependencies(project.name, selector)
3948
}
4049

41-
// Configure ModDevGradle
42-
neoForge {
43-
neoFormVersion = neoform_version
44-
// Apply common AccessTransformer if it exists
45-
def at = file("src/main/resources/META-INF/accesstransformer.cfg")
46-
if (at.exists()) accessTransformers.from(at.absolutePath)
47-
validateAccessTransformers = true
48-
// Apply Parchment mappings
49-
parchment {
50-
minecraftVersion = parchment_minecraft_version
51-
mappingsVersion = parchment_version
50+
// Configure Loom
51+
loom {
52+
// Apply common AccessWidener if it exists
53+
def aw = project(":common").file("src/main/resources/${mod_id}.accesswidener")
54+
if (aw.exists()) accessWidenerPath.set(aw)
55+
if (aw.exists()) {
56+
validateAccessWidener { accessWidener = aw }
57+
afterEvaluate {
58+
validateAccessWidener.run()
59+
}
60+
}
61+
mixin {
62+
defaultRefmapName.set("${mod_id}.refmap.json")
5263
}
5364
}
5465

common/src/main/java/dev/terminalmc/chatnotify/gui/screen/OptionScreen.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import net.minecraft.client.gui.components.events.GuiEventListener;
3030
import net.minecraft.client.gui.screens.Screen;
3131
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
32+
import net.minecraft.client.input.CharacterEvent;
33+
import net.minecraft.client.input.KeyEvent;
3234
import net.minecraft.network.chat.CommonComponents;
3335
import net.minecraft.network.chat.Component;
3436
import org.jetbrains.annotations.NotNull;
@@ -306,27 +308,27 @@ private void setChildrenVisible(boolean visible) {
306308
}
307309

308310
@Override
309-
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
311+
public boolean keyPressed(KeyEvent event) {
310312
if (overlay != null) {
311-
if (keyCode == InputConstants.KEY_ESCAPE) {
313+
if (event.key() == InputConstants.KEY_ESCAPE) {
312314
overlay.onClose();
313315
removeOverlay();
314316
} else {
315-
overlay.keyPressed(keyCode, scanCode, modifiers);
317+
overlay.keyPressed(event);
316318
}
317319
return true;
318320
} else {
319-
return super.keyPressed(keyCode, scanCode, modifiers);
321+
return super.keyPressed(event);
320322
}
321323
}
322324

323325
@Override
324-
public boolean charTyped(char chr, int modifiers) {
326+
public boolean charTyped(CharacterEvent event) {
325327
if (overlay != null) {
326-
overlay.charTyped(chr, modifiers);
328+
overlay.charTyped(event);
327329
return true;
328330
} else {
329-
return super.charTyped(chr, modifiers);
331+
return super.charTyped(event);
330332
}
331333
}
332334
}

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/ConfirmButton.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package dev.terminalmc.chatnotify.gui.widget;
1818

1919
import net.minecraft.client.gui.components.Button;
20+
import net.minecraft.client.input.InputWithModifiers;
2021
import net.minecraft.network.chat.Component;
2122
import org.jetbrains.annotations.NotNull;
2223

@@ -63,12 +64,12 @@ public void setConfirmMessage(@NotNull Component confirmMessage) {
6364
}
6465

6566
@Override
66-
public void onPress() {
67+
public void onPress(InputWithModifiers input) {
6768
if (!hasBeenPressed) {
6869
hasBeenPressed = true;
6970
super.setMessage(confirmMessage);
7071
} else {
71-
super.onPress();
72+
super.onPress(input);
7273
}
7374
}
7475
}

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/ExpandingList.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ExpandingList extends ContainerObjectSelectionList<ExpandingList.En
5353
* @param y the y position of the list widget.
5454
* @param width the full width of the list widget.
5555
* @param maxHeight the maximum allowable height of the list widget.
56-
* @param itemHeight the space to allocate for each list entry.
56+
* @param defaultEntryHeight the space to allocate for each list entry.
5757
* @param entryHeight the actual height of each list entry.
5858
* @param xMargin the space between the side of each entry and the edge of the list widget.
5959
*/
@@ -62,23 +62,27 @@ public ExpandingList(
6262
int y,
6363
int width,
6464
int maxHeight,
65-
int itemHeight,
65+
int defaultEntryHeight,
6666
int entryHeight,
6767
int xMargin
6868
) {
69-
super(Minecraft.getInstance(), width, 0, y, itemHeight);
69+
super(Minecraft.getInstance(), width, 0, y, defaultEntryHeight);
7070
super.setX(x);
7171
this.maxHeight = maxHeight;
7272
this.entryWidth = width - SCROLLBAR_WIDTH - (xMargin * 2);
7373
this.entryHeight = entryHeight;
7474
this.entryX = x + xMargin;
7575
}
7676

77+
protected Entry getEntry(int index) {
78+
return this.children().get(index);
79+
}
80+
7781
/**
7882
* Scrolls the list as required to make the {@link Entry} at {@code index} visible.
7983
*/
8084
public void ensureVisible(int index) {
81-
ensureVisible(getEntry(index));
85+
scrollToEntry(getEntry(index));
8286
}
8387

8488
public boolean isEmpty() {
@@ -104,7 +108,7 @@ public AbstractWidget get(int index) {
104108
public void replaceWidgets(Iterable<AbstractWidget> widgets) {
105109
clearWidgets();
106110
widgets.forEach(this::addWidget);
107-
setHeight(Math.min(itemHeight * children().size() + VERTICAL_BUFFER, maxHeight));
111+
setHeight(Math.min(defaultEntryHeight * children().size() + VERTICAL_BUFFER, maxHeight));
108112
}
109113

110114
/**
@@ -120,7 +124,7 @@ public void clearWidgets() {
120124
*/
121125
public void addWidget(AbstractWidget widget) {
122126
addEntry(new Entry(entryX, entryWidth, entryHeight, widget));
123-
setHeight(Math.min(itemHeight * children().size() + VERTICAL_BUFFER, maxHeight));
127+
setHeight(Math.min(defaultEntryHeight * children().size() + VERTICAL_BUFFER, maxHeight));
124128
}
125129

126130
@Override
@@ -129,14 +133,9 @@ protected void renderItem(
129133
int mouseX,
130134
int mouseY,
131135
float delta,
132-
int index,
133-
int x,
134-
int y,
135-
int width,
136-
int height
136+
ExpandingList.Entry widget
137137
) {
138-
if (index == highlightIndex) {
139-
AbstractWidget widget = getEntry(index).widget;
138+
if (highlightIndex != -1 && widget == getEntry(highlightIndex)) {
140139
graphics.fill(
141140
widget.getX(),
142141
widget.getY(),
@@ -145,7 +144,7 @@ protected void renderItem(
145144
HIGHLIGHT_COLOR
146145
);
147146
}
148-
super.renderItem(graphics, mouseX, mouseY, delta, index, x, y, width, height);
147+
super.renderItem(graphics, mouseX, mouseY, delta, widget);
149148
}
150149

151150
@Override
@@ -188,19 +187,14 @@ public AbstractWidget getWidget() {
188187
}
189188

190189
@Override
191-
public void render(
190+
public void renderContent(
192191
@NotNull GuiGraphics graphics,
193-
int index,
194-
int y,
195-
int x,
196-
int entryWidth,
197-
int entryHeight,
198192
int mouseX,
199193
int mouseY,
200194
boolean hovered,
201195
float delta
202196
) {
203-
widget.setY(y);
197+
widget.setY(getContentY());
204198
widget.render(graphics, mouseX, mouseY, delta);
205199
}
206200
}

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/HorizontalList.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import net.minecraft.client.gui.narration.NarratedElementType;
2727
import net.minecraft.client.gui.narration.NarrationElementOutput;
2828
import net.minecraft.client.gui.screens.Screen;
29+
import net.minecraft.client.input.MouseButtonEvent;
2930
import net.minecraft.client.renderer.RenderPipelines;
3031
import net.minecraft.network.chat.Component;
3132
import net.minecraft.resources.ResourceLocation;
@@ -418,28 +419,22 @@ protected void ensureVisible(E entry) {
418419
// Scrolling
419420

420421
@Override
421-
public boolean mouseClicked(double mouseX, double mouseY, int button) {
422-
updateScrollingState(mouseX, mouseY, button);
423-
if (!isMouseOver(mouseX, mouseY)) {
422+
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
423+
updateScrollingState(event);
424+
if (!isMouseOver(event.x(), event.y())) {
424425
return false;
425426
} else {
426-
return scrolling || super.mouseClicked(mouseX, mouseY, button);
427+
return scrolling || super.mouseClicked(event, doubleClick);
427428
}
428429

429430
}
430431

431432
@Override
432-
public boolean mouseDragged(
433-
double mouseX,
434-
double mouseY,
435-
int button,
436-
double dragX,
437-
double dragY
438-
) {
439-
if (button == 0 && scrolling) {
440-
if (mouseX < getX()) {
433+
public boolean mouseDragged(MouseButtonEvent event, double dragX, double dragY) {
434+
if (event.button() == 0 && scrolling) {
435+
if (event.x() < getX()) {
441436
setScrollAmount(0.0F);
442-
} else if (mouseX > getRight()) {
437+
} else if (event.x() > getRight()) {
443438
setScrollAmount(getMaxScroll());
444439
} else {
445440
double maxScroll = Math.max(1, getMaxScroll());
@@ -455,7 +450,7 @@ public boolean mouseDragged(
455450
}
456451
return true;
457452
} else {
458-
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
453+
return super.mouseDragged(event, dragX, dragY);
459454
}
460455
}
461456

@@ -466,10 +461,10 @@ public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, doubl
466461
return true;
467462
}
468463

469-
protected void updateScrollingState(double mouseX, double mouseY, int button) {
464+
protected void updateScrollingState(MouseButtonEvent event) {
470465
scrolling =
471-
button == 0 && mouseY >= scrollBarX() && mouseY < (scrollBarX()
472-
+ SCROLLBAR_HEIGHT) && mouseX >= getX() && mouseX < getRight();
466+
event.button() == 0 && event.y() >= scrollBarX() && event.y() < (scrollBarX()
467+
+ SCROLLBAR_HEIGHT) && event.x() >= getX() && event.x() < getRight();
473468
}
474469

475470
protected int scrollBarX() {

0 commit comments

Comments
 (0)