1.20.1 port

This commit is contained in:
Oth3r 2024-12-22 17:58:25 -06:00
commit de1e7d8d65
7 changed files with 48 additions and 78 deletions

View file

@ -19,7 +19,7 @@ public class ClickableImageWidget extends ButtonWidget {
}
@Override
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
protected void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
context.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha);
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();

View file

@ -1,6 +1,7 @@
package one.oth3r.sit.screen;
import com.mojang.blaze3d.systems.RenderSystem;
import com.terraformersmc.modmenu.gui.ModMenuOptionsScreen;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
import net.minecraft.client.gui.screen.Screen;
@ -24,23 +25,23 @@ public class ConfigScreen extends Screen {
int spacing = 36;
TextureButtonWidget serverConfigButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("config.server"),
(button) -> client.setScreen(new UnderConstructionScreen(this, FileData.getServerConfig())), false)
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "server_button"), 246, 26).build());
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/server_button.png"), 246, 26).build());
serverConfigButton.setPosition(this.width / 2 - (serverConfigButton.getWidth()/2), startY);
TextureButtonWidget sittingConfigButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("config.sitting"),
(button) -> client.setScreen(new UnderConstructionScreen(this, FileData.getSittingConfig())), false)
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "sitting_button"), 246, 26).build());
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/sitting_button.png"), 246, 26).build());
sittingConfigButton.setPosition(this.width / 2 - (sittingConfigButton.getWidth()/2), startY+36);
TextureButtonWidget issuesButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.issues"),
ConfirmLinkScreen.opening(this, "https://github.com/Oth3r/Sit/issues"), true)
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "issues"), 15, 15).build());
ConfirmLinkScreen.opening("https://github.com/Oth3r/Sit/issues",this,true), true)
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/issues.png"), 15, 15).build());
issuesButton.setPosition(this.width / 2 - 125, startY + 72 + 12);
this.addDrawableChild(ButtonWidget.builder(Text.translatable("sit!.gui.button.website"),
ConfirmLinkScreen.opening(this, "https://modrinth.com/mod/sit!")
ConfirmLinkScreen.opening("https://modrinth.com/mod/sit!",this,true)
).dimensions(this.width / 2 - 100, startY + 72 + 12, 98, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.done"), (button) -> {
@ -48,17 +49,21 @@ public class ConfigScreen extends Screen {
}).dimensions(this.width / 2 + 2, startY + 72 + 12, 98, 20).build());
TextureButtonWidget donateButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.donate"),
ConfirmLinkScreen.opening(this, "https://Ko-fi.com/oth3r"), true)
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "donate"), 15, 15).build());
ConfirmLinkScreen.opening("https://Ko-fi.com/oth3r",this,true), true)
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/donate.png"), 15, 15).build());
donateButton.setPosition(this.width / 2 + 105, startY + 72 + 12);
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
// render the background because you have to in this version
this.renderBackground(context);
// todo fade in like the title screen on first load?
renderBanner(context,width/2 - 64,this.height / 4 -38,1);
super.render(context, mouseX, mouseY, delta);
}
@Override

View file

@ -25,11 +25,11 @@ public class TextureButtonWidget extends ButtonWidget {
}
@Override
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
super.renderWidget(context, mouseX, mouseY, delta);
protected void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
super.renderButton(context, mouseX, mouseY, delta);
int x = this.getX() + this.getWidth() / 2 - this.textureWidth / 2;
int y = this.getY() + this.getHeight() / 2 - this.textureHeight / 2;
context.drawGuiTexture(this.texture, x, y, this.textureWidth, this.textureHeight);
context.drawTexture(this.texture, x, y, 0, 0, this.textureWidth, this.textureHeight, this.textureWidth, this.textureHeight);
}
@Override

View file

@ -1,5 +1,6 @@
package one.oth3r.sit.screen;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
@ -29,7 +30,7 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
protected void init() {
int startY = this.height / 5-4;
ButtonWidget foxPNG = this.addDrawableChild(new ClickableImageWidget(70,70,140,140, Tooltip.of(Text.of("Art by @bunnestbun")),
Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening(this, "https://www.instagram.com/bunnestbun/")));
Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening("https://www.instagram.com/bunnestbun/",this, true)));
foxPNG.setPosition(this.width / 2 - (foxPNG.getWidth()/2), startY-35);
ButtonWidget openFileButton = this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("sit!.gui.button.file"),
@ -38,8 +39,8 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
openFileButton.setPosition(this.width / 2 - 70, startY+110);
TextureButtonWidget folderButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.folder"),
(button) -> Util.getOperatingSystem().open(this.file.getFile().getParent()), true)
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "folder"), 15, 15).build());
(button) -> Util.getOperatingSystem().open(this.file.getFile().getParentFile().toURI()), true)
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/folder.png"), 15, 15).build());
folderButton.setPosition(this.width / 2 + 50, startY + 110);
TextureButtonWidget resetButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.reset"),
@ -47,7 +48,7 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
this.file.reset();
this.file.save();
}, true)
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "reset_file"), 15, 15).build());
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/reset_file.png"), 15, 15).build());
resetButton.setPosition(this.width / 2 -70, startY + 135);
ButtonWidget revertButton = this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("sit!.gui.button.revert"),
@ -72,6 +73,13 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
saveExitButton.setPosition(this.width / 2 - 70, startY+168);
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// render the background because you have to in this version
this.renderBackground(context);
super.render(context, mouseX, mouseY, delta);
}
@Override
public void close() {
this.client.setScreen(parent);