1
mirror of https://github.com/Shiewk/ViewServerResources.git synced 2026-04-28 03:44:17 +02:00

1.21.5 support

This commit is contained in:
Shy
2025-04-04 14:32:28 +02:00
parent e9880117d7
commit 70e70cb443
4 changed files with 20 additions and 20 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.8.9'
id 'fabric-loom' version '1.10.1'
id 'maven-publish'
}
+5 -5
View File
@@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.8
minecraft_version=1.21.5
yarn_mappings=1.21.5+build.1
loader_version=0.16.12
# Mod Properties
mod_version=1.0.1
mod_version=1.0.2
maven_group=de.shiewk
archives_base_name=ViewServerResources
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.106.1+1.21.3
fabric_version=0.119.5+1.21.5
@@ -23,6 +23,6 @@ public class ManageListScreen<T> extends Screen {
@Override
protected void init() {
addDrawableChild(new ManageListWidget<T>(textRenderer, 0, 0, width-8, height, title, list));
addDrawableChild(new ManageListWidget<>(textRenderer, 0, 0, width, height, title, list));
}
}
@@ -29,19 +29,19 @@ public class ManageListWidget<T> extends ScrollableWidget {
yp += 4;
final TextWidget tw = new TextWidget(Text.literal(t.toString()), renderer);
tw.setHeight(20);
tw.setPosition((width - 28) / 2 - (tw.getWidth() / 2), yp);
tw.setPosition((width - 34) / 2 - (tw.getWidth() / 2), yp);
elements.add(tw);
elements.add(new ButtonWidget.Builder(Text.literal("x"), btn -> {
btn.active = false;
list.remove(t);
refreshElements(renderer);
}).width(20).position(width - 24, yp).build());
}).width(20).position(width - 30, yp).build());
yp += 20;
}
}
@Override
protected int getContentsHeight() {
protected int getContentsHeightWithPadding() {
return list.size() * 24;
}
@@ -51,11 +51,15 @@ public class ManageListWidget<T> extends ScrollableWidget {
}
@Override
protected void renderContents(DrawContext context, int mouseX, int mouseY, float delta) {
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
mouseY += (int) getScrollY();
context.getMatrices().push();
context.getMatrices().translate(0, -getScrollY(), 0);
for (ClickableWidget element : elements) {
element.render(context, mouseX, mouseY, delta);
}
context.getMatrices().pop();
drawScrollbar(context);
}
@Override
@@ -65,17 +69,13 @@ public class ManageListWidget<T> extends ScrollableWidget {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
mouseY += getScrollY();
double mouseYScrolled = mouseY + getScrollY();
for (ClickableWidget element : elements) {
if (element.isMouseOver(mouseX, mouseY)){
return element.mouseClicked(mouseX, mouseY, button);
if (element.isMouseOver(mouseX, mouseYScrolled)){
return element.mouseClicked(mouseX, mouseYScrolled, button);
}
}
return false;
}
@Override
protected void drawBox(DrawContext context, int x, int y, int width, int height) {
if (super.checkScrollbarDragged(mouseX, mouseY, button)) return true;
return super.mouseClicked(mouseX, mouseY, button);
}
}