Skip to content

Commit 02d243b

Browse files
committed
feat: update to 1.21.9
1 parent f89a2a5 commit 02d243b

File tree

8 files changed

+63
-132
lines changed

8 files changed

+63
-132
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Update to 1.21.7
1+
Update to 1.21.9

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "architectury-plugin" version "3.4-SNAPSHOT"
3-
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
3+
id "dev.architectury.loom" version "1.11-SNAPSHOT" apply false
44
id "com.github.breadmoirai.github-release" version "2.4.1"
55
id "maven-publish"
66
}

common/src/client/java/io/github/jamalam360/jamlib/client/config/gui/SelectionList.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,28 @@
22

33
import net.minecraft.client.Minecraft;
44
import net.minecraft.client.gui.GuiGraphics;
5-
import net.minecraft.client.gui.components.AbstractWidget;
65
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
7-
import net.minecraft.client.gui.components.events.GuiEventListener;
86
import org.jetbrains.annotations.ApiStatus;
9-
import org.jetbrains.annotations.Nullable;
107

118
@ApiStatus.Internal
129
public class SelectionList extends ContainerObjectSelectionList<SelectionListEntry> {
13-
public SelectionList(Minecraft minecraft, int width, int height, int y, int itemHeight) {
14-
super(minecraft, width, height, y, itemHeight);
15-
this.centerListVertically = false;
16-
}
10+
public SelectionList(Minecraft minecraft, int width, int height, int y, int itemHeight) {
11+
super(minecraft, width, height, y, itemHeight);
12+
this.centerListVertically = false;
13+
}
1714

18-
@Override
19-
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
20-
super.renderWidget(graphics, mouseX, mouseY, delta);
21-
}
15+
@Override
16+
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
17+
super.renderWidget(graphics, mouseX, mouseY, delta);
18+
}
2219

23-
@Override
24-
protected int scrollBarX() {
25-
return this.width - 7;
26-
}
20+
@Override
21+
protected int scrollBarX() {
22+
return this.width - 7;
23+
}
2724

28-
@Override
29-
public int getRowWidth() {
30-
return 1000;
31-
}
25+
@Override
26+
public int getRowWidth() {
27+
return 1000;
28+
}
3229
}

common/src/client/java/io/github/jamalam360/jamlib/client/config/gui/SelectionListEntry.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ public SelectionListEntry(Component title, List<FormattedCharSequence> tooltip,
2727
this.widgets = widgets;
2828
}
2929

30-
@Override
31-
public void render(GuiGraphics graphics, int i, int y, int x, int width, int height, int mouseX, int mouseY, boolean hovered, float delta) {
32-
for (AbstractWidget widget : this.widgets) {
33-
widget.setY(y);
34-
widget.render(graphics, mouseX, mouseY, delta);
35-
}
30+
@Override
31+
public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean hovered, float delta) {
32+
for (AbstractWidget widget : this.widgets) {
33+
widget.setY(this.getY());
34+
widget.render(guiGraphics, mouseX, mouseY, delta);
35+
}
3636

37-
this.renderTitle(graphics, y, 12, x + width / 2 - 10);
38-
}
39-
40-
// Mainly taken from AbstractWidget
37+
this.renderTitle(guiGraphics, this.getY(), 12, this.getX() + this.getWidth() / 2 - 10);
38+
}
39+
40+
// Mainly taken from AbstractWidget
4141
private void renderTitle(GuiGraphics graphics, int minY, int minX, int maxX) {
4242
int textWidth = Minecraft.getInstance().font.width(this.title);
4343
int y = minY + Minecraft.getInstance().font.lineHeight / 2 + 1;

common/src/client/java/io/github/jamalam360/jamlib/client/gui/WidgetList.java

Lines changed: 15 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
import net.minecraft.client.gui.GuiGraphics;
66
import net.minecraft.client.gui.components.AbstractWidget;
77
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
8-
import net.minecraft.client.gui.components.Tooltip;
98
import net.minecraft.client.gui.components.events.GuiEventListener;
109
import net.minecraft.client.gui.narration.NarratableEntry;
11-
import net.minecraft.util.Mth;
1210
import org.jetbrains.annotations.NotNull;
13-
import org.jetbrains.annotations.Nullable;
1411

1512
import java.util.List;
1613

@@ -21,112 +18,43 @@ public class WidgetList extends ContainerObjectSelectionList<WidgetList.Entry> {
2118
public static final int PADDING = 4;
2219

2320
public WidgetList(Minecraft minecraft, int width, int height, int y) {
24-
super(minecraft, width, height, y, 1);
21+
super(minecraft, width, height, y, 20);
2522
this.centerListVertically = false;
26-
this.headerHeight = PADDING;
2723
}
2824

2925
public void addWidgetGroup(List<AbstractWidget> widgets) {
3026
this.addEntry(new Entry(widgets));
3127
}
3228

3329
public void updateWidgetGroup(int index, List<AbstractWidget> widgets) {
34-
this.children().set(index, new Entry(widgets));
30+
this.children().get(index).updateChildren(widgets);
31+
this.swap(index, index); // Force reposition of entries
3532
}
3633

3734
@Override
3835
public int getRowWidth() {
3936
return this.width;
4037
}
4138

42-
@Nullable
43-
public Entry getRealEntryAtPosition(double mouseX, double mouseY) {
44-
int halfRowWidth = this.getRowWidth() / 2;
45-
int centerX = this.getX() + this.width / 2;
46-
int left = centerX - halfRowWidth;
47-
int right = centerX + halfRowWidth;
48-
int m = Mth.floor(mouseY - (double) this.getY()) - this.headerHeight + (int) this.scrollAmount() - 4;
49-
50-
if (mouseX < left || mouseX > right || m < 0) {
51-
return null;
52-
}
53-
54-
int height = 0;
55-
56-
for (int idx = 0; idx < this.getItemCount(); idx++) {
57-
Entry entry = this.getEntry(idx);
58-
height += entry.getHeight() + PADDING;
59-
if (m < height) {
60-
return entry;
61-
}
62-
}
63-
64-
return null;
65-
}
66-
67-
@Override
68-
protected void renderListItems(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
69-
for (int itemIdx = 0; itemIdx < this.getItemCount(); ++itemIdx) {
70-
int top = this.getRowTop(itemIdx);
71-
int bottom = this.getRowBottom(itemIdx);
72-
if (bottom >= this.getY() && top <= this.getBottom()) {
73-
this.renderItem(graphics, mouseX, mouseY, partialTick, itemIdx, this.getRowLeft(), top, this.getRowWidth(), this.getEntry(itemIdx).getHeight());
74-
}
75-
}
76-
}
77-
78-
@Override
79-
protected int contentHeight() {
80-
int itemsHeight = 0;
81-
82-
for (int i = 0; i < this.getItemCount(); i++) {
83-
itemsHeight += this.getEntry(i).getHeight() + PADDING;
84-
}
85-
86-
return itemsHeight + this.headerHeight;
87-
}
88-
89-
@Override
90-
public int getRowTop(int index) {
91-
int itemsHeight = 0;
92-
93-
for (int i = 0; i < index; i++) {
94-
itemsHeight += this.getEntry(i).getHeight() + PADDING;
95-
}
96-
97-
return this.getY() - (int) this.scrollAmount() + itemsHeight + this.headerHeight;
98-
}
99-
100-
@Override
101-
public int getRowBottom(int index) {
102-
return this.getRowTop(index) + this.getEntry(index).getHeight();
103-
}
104-
105-
@Override
106-
protected double scrollRate() {
107-
return 10;
108-
}
109-
11039
@Override
11140
protected int scrollBarX() {
11241
return this.getX() + this.width - 6;
11342
}
11443

11544
public static class Entry extends ContainerObjectSelectionList.Entry<Entry> {
116-
private final List<AbstractWidget> children;
117-
private final List<Integer> childYs;
45+
private List<AbstractWidget> children;
46+
private List<Integer> childYs;
11847

11948
private Entry(List<AbstractWidget> list) {
120-
this.children = ImmutableList.copyOf(list);
121-
this.childYs = this.children.stream().map(AbstractWidget::getY).toList();
49+
this.updateChildren(list);
12250
}
12351

12452
@Override
125-
public void render(GuiGraphics guiGraphics, int index, int top, int left, int width, int height, int mouseX, int mouseY, boolean hovering, float partialTick) {
53+
public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean hovered, float partialTick) {
12654
for (int i = 0; i < this.children.size(); i++) {
12755
AbstractWidget widget = this.children.get(i);
12856
int relativeY = this.childYs.get(i);
129-
widget.setY(top + relativeY);
57+
widget.setY(PADDING + this.getY() + relativeY);
13058
widget.render(guiGraphics, mouseX, mouseY, partialTick);
13159
}
13260
}
@@ -140,7 +68,13 @@ public int getHeight() {
14068
maxY = Math.max(relativeY + widget.getHeight(), maxY);
14169
}
14270

143-
return maxY;
71+
return maxY + PADDING;
72+
}
73+
74+
private void updateChildren(List<AbstractWidget> children) {
75+
System.out.println("Updating children " + this.children + " with " + children);
76+
this.children = ImmutableList.copyOf(children);
77+
this.childYs = this.children.stream().map(AbstractWidget::getY).toList();
14478
}
14579

14680
@Override

common/src/client/java/io/github/jamalam360/jamlib/client/mixin/AbstractSelectionListMixin.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
@Mixin(AbstractSelectionList.class)
1111
public class AbstractSelectionListMixin {
12-
@Inject(
13-
method = "getEntryAtPosition",
14-
at = @At("HEAD"),
15-
cancellable = true
16-
)
17-
private void jamlib$modifyGetEntryAtPositionForWidgetList(double mouseX, double mouseY, CallbackInfoReturnable<Object> cir) {
18-
if ((Object) this instanceof WidgetList widgetList) {
19-
cir.setReturnValue(widgetList.getRealEntryAtPosition(mouseX, mouseY));
20-
}
21-
}
12+
// @Inject(
13+
// method = "getEntryAtPosition",
14+
// at = @At("HEAD"),
15+
// cancellable = true
16+
// )
17+
// private void jamlib$modifyGetEntryAtPositionForWidgetList(double mouseX, double mouseY, CallbackInfoReturnable<Object> cir) {
18+
// if ((Object) this instanceof WidgetList widgetList) {
19+
// cir.setReturnValue(widgetList.getRealEntryAtPosition(mouseX, mouseY));
20+
// }
21+
// }
2222
}

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
org.gradle.jvmargs=-Xmx3G
22
org.gradle.daemon=false
33
org.gradle.parallel=true
4-
version=1.3.5+1.21.8
5-
minecraft_version=1.21.8
4+
version=1.3.5+1.21.9
5+
minecraft_version=1.21.9
66

7-
additional_minecraft_versions=1.21.6,1.21.7
8-
minimum_minecraft_version=1.21.6
9-
minimum_architectury_api_version=17.0.6
10-
minimum_fabric_api_version=0.128.2+1.21.6
7+
additional_minecraft_versions=
8+
minimum_minecraft_version=1.21.9
9+
minimum_architectury_api_version=18.0.3
10+
minimum_fabric_api_version=0.134.0+1.21.9
1111

1212
branch=main
1313
group=io.github.jamalam360

libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[versions]
22
# https://modrinth.com/mod/architectury-api/versions
3-
architectury = "17.0.8"
3+
architectury = "18.0.3"
44

55
# https://parchmentmc.org/docs/getting-started
66
parchment-minecraft = "1.21.8"
77
parchment = "2025.09.14"
88

99
# https://projects.neoforged.net/neoforged/neoforge
10-
neoforge = "21.8.47"
10+
neoforge = "21.9.13-beta"
1111

1212
# https://fabricmc.net/develop
1313
fabric-loader = "0.17.2"
14-
fabric-api = "0.133.4+1.21.8"
14+
fabric-api = "0.134.0+1.21.9"
1515

1616
# https://modrinth.com/mod/modmenu/versions
17-
modmenu = "15.0.0"
17+
modmenu = "16.0.0-rc.1"
1818

1919
# https://github.com/falkreon/Jankson/releases/latest
2020
jankson = "1.2.3"

0 commit comments

Comments
 (0)