Skip to content

Commit

Permalink
Merge pull request #7 from jaanonim/main-to-1.18
Browse files Browse the repository at this point in the history
sync to 1.18.2
  • Loading branch information
jaanonim authored Feb 13, 2024
2 parents fc4ac25 + 60412a2 commit 0878542
Show file tree
Hide file tree
Showing 22 changed files with 407 additions and 296 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# against bad commits.

name: build
on: [pull_request, push]
on: [push]

jobs:
build:
Expand Down
31 changes: 8 additions & 23 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Publish on GitHub, CurseForge & Modrinth

on: [pull_request, workflow_dispatch]
on: [workflow_dispatch]

env:
MINECRAFT_VERSION: 1.18.2
MINECRAFT_VERSION: 1.20.1
JAVA_VERSION: 17
VERSION: 1.0.2+1.18.2
VERSION: 1.0.3+1.20.1
MODRINTH_TOKEN: ${{ secrets.PUBLISH_MODRINTH_TOKEN }}
CURSEFORGE_TOKEN: ${{ secrets.PUBLISH_CURSEFORGE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }}
Expand Down Expand Up @@ -47,38 +47,23 @@ jobs:
with:
name: Artifacts
path: ${{ matrix.dir }}/build/libs/
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Get Build Artifacts
uses: actions/download-artifact@master
with:
name: Artifacts
path: artifacts
- name: Check build files
run: |
rm -r artifacts/*-sources.jar
ls artifacts/*.jar
- name: Publish (CurseForge/Modrinth/GitHub)
uses: Kir-Antipov/mc-publish@v3.2
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: 882715
curseforge-token: "${{env.CURSEFORGE_TOKEN}}"

modrinth-id: oTmCQ7Y1
modrinth-token: "${{env.MODRINTH_TOKEN}}"

github-tag: "v${{env.VERSION}}"
github-tag: "v${{env.VERSION}}_${{ matrix.dir }}"
github-token: "${{env.GITHUB_TOKEN}}"

name: "${{env.VERSION}}"
name: "${{env.VERSION}}_${{ matrix.dir }}"
version: "${{env.VERSION}}"
version-type: release

loaders: |
fabric
forge
game-versions: "${{env.MINECRAFT_VERSION}}"
java: "${{env.JAVA_VERSION}}"
files: artifacts/*.jar
files: ${{ matrix.dir }}/build/libs/*.jar

6 changes: 3 additions & 3 deletions Fabric/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.4
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.21

# Mod Properties
Expand All @@ -14,4 +14,4 @@ maven_group=com.jaanonim.ngrokapi
archives_base_name=ngrok-api-fabric

# Dependencies
fabric_version=0.76.0+1.18.2
fabric_version=0.86.1+1.20.1
45 changes: 23 additions & 22 deletions Fabric/src/main/java/com/jaanonim/ngrokapi/AddNgrokTokenScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

@Environment(value = EnvType.CLIENT)
public class AddNgrokTokenScreen extends Screen {
Expand All @@ -31,29 +30,32 @@ public void tick() {

@Override
protected void init() {

this.nameField = new TextFieldWidget(this.textRenderer, this.width / 2 -
100, 70, 200, 20,
new TranslatableText("addServer.enterName"));
Text.translatable("addServer.enterName"));
this.nameField.setFocused(true);
this.nameField.setMaxLength(100);
this.nameField.setChangedListener(serverName -> this.updateSaveButton());
this.addSelectableChild(this.nameField);

this.tokenField = new TextFieldWidget(this.textRenderer, this.width / 2 -
100, 120, 200, 20,
new TranslatableText("addServer.enterName"));
Text.translatable("addServer.enterName"));
this.tokenField.setMaxLength(100);
this.tokenField.setChangedListener(serverName -> this.updateSaveButton());
this.addSelectableChild(this.tokenField);

this.saveButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 110,
this.height - 55,
100, 20,
Text.of("Save"), button -> this.save()));
this.saveButton = this.addDrawableChild(ButtonWidget.builder(
Text.of("Save"), button -> this.save()).dimensions(this.width / 2 - 110,
this.height - 55,
100, 20)
.build());

this.addDrawableChild(new ButtonWidget(
this.width / 2 + 10, this.height - 55,
100, 20, ScreenTexts.CANCEL, button -> this.close()));
this.addDrawableChild(ButtonWidget.builder(
ScreenTexts.CANCEL, button -> this.close())
.dimensions(this.width / 2 + 10, this.height - 55,
100, 20)
.build());

this.updateSaveButton();
}
Expand Down Expand Up @@ -82,21 +84,20 @@ private void updateSaveButton() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
NgrokApiScreen.drawCenteredTextWithShadow(matrices, this.textRenderer, this.title.asOrderedText(),
this.width / 2, 17,
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context);
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 17,
0xFFFFFF);

NgrokApiScreen.drawTextWithShadow(matrices, this.textRenderer, Text.of("Name"), this.width / 2 - 100,
context.drawTextWithShadow(this.textRenderer, Text.of("Name"), this.width / 2 - 100,
54,
0xA0A0A0);
NgrokApiScreen.drawTextWithShadow(matrices, this.textRenderer, Text.of("Ngrok API token"), this.width / 2 - 100,
context.drawTextWithShadow(this.textRenderer, Text.of("Ngrok API token"), this.width / 2 - 100,
104,
0xA0A0A0);

this.nameField.render(matrices, mouseX, mouseY, delta);
this.tokenField.render(matrices, mouseX, mouseY, delta);
super.render(matrices, mouseX, mouseY, delta);
this.nameField.render(context, mouseX, mouseY, delta);
this.tokenField.render(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
}
}
67 changes: 39 additions & 28 deletions Fabric/src/main/java/com/jaanonim/ngrokapi/NgrokApiScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;

@Environment(value = EnvType.CLIENT)
Expand All @@ -30,27 +32,36 @@ public NgrokApiScreen(Screen parent) {
protected void init() {
this.list = new NgrokTokenList();

this.joinButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 110,
this.height - 55,
100, 20,
Text.of("Join"), button -> this.join()));

this.delButton = this.addDrawableChild(new ButtonWidget(this.width / 2 + 10, this.height - 55,
100, 20,
Text.of("Delete"), button -> this.delete()));

this.addDrawableChild(new ButtonWidget(this.width / 2 - 140, this.height - 30,
80, 20,
Text.of("Add"), button -> this.add()));

this.addDrawableChild(new ButtonWidget(this.width / 2 - 40, this.height - 30,
80, 20,
Text.of("Refresh"), button -> this.refresh()));

this.addDrawableChild(new ButtonWidget(this.width / 2 + 60,
this.height - 30,
80, 20,
Text.of("Cancel"), button -> this.close()));
this.joinButton = this.addDrawableChild(ButtonWidget.builder(
Text.of("Join"), button -> this.join()).dimensions(this.width / 2 - 110,
this.height - 55,
100, 20)
.build());

this.delButton = this.addDrawableChild(ButtonWidget.builder(
Text.of("Delete"), button -> this.delete())
.dimensions(this.width / 2 + 10, this.height - 55,
100, 20)
.build());

this.addDrawableChild(ButtonWidget.builder(
Text.of("Add"), button -> this.add())
.dimensions(this.width / 2 - 140, this.height - 30,
80, 20)
.build());

this.addDrawableChild(ButtonWidget.builder(
Text.of("Refresh"), button -> this.refresh())
.dimensions(this.width / 2 - 40, this.height - 30,
80, 20)
.build());

this.addDrawableChild(ButtonWidget.builder(
ScreenTexts.CANCEL, button -> this.close())
.dimensions(this.width / 2 + 60,
this.height - 30,
80, 20)
.build());

this.listWidget = new NgrokTokenListWidget(client, width, height - 120, 40, height
- 60, 30);
Expand Down Expand Up @@ -102,7 +113,6 @@ private void updateButtons() {

public void selected(NgrokTokenListWidget.NgrokTokenEntry entry) {
this.selectedEntry = entry;
this.listWidget.setSelected(entry);
updateButtons();
}

Expand All @@ -120,15 +130,16 @@ public void join() {
NgrokAddress adr = this.selectedEntry.getAddress();
if (adr.canConnect()) {
ServerAddress sa = new ServerAddress(adr.getHost(), adr.getPort());
ConnectScreen.connect(this, this.client, sa, null);
ConnectScreen.connect(this, this.client, sa,
new ServerInfo(this.selectedEntry.getEntry().getName(), adr.getFull(), false), false);
}
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context);

this.listWidget.render(matrices, mouseX, mouseY, delta);
super.render(matrices, mouseX, mouseY, delta);
this.listWidget.render(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.jaanonim.ngrokapi;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.util.math.MatrixStack;

import net.minecraft.text.Text;

Expand Down Expand Up @@ -42,14 +42,15 @@ public NgrokTokenEntry(NgrokApiScreen screen, NgrokToken entry) {
}

@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX,
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX,
int mouseY, boolean hovered, float tickDelta) {
this.client.textRenderer.draw(matrices, Text.of(this.entry.getName()), (float) (x + 32 + 3),
(float) (y + 2), 0xFFFFFF);
context.drawText(this.client.textRenderer, Text.of(this.entry.getName()), (x + 32 + 3),
(y + 2), 0xFFFFFF, false);

String s = this.address.getFull();
Text t = !s.isEmpty() ? Text.of(s) : Text.of("None");
this.client.textRenderer.draw(matrices, t, (float) (x + 32 + 3),
(float) (y + 12), 0xAAAAAA);
context.drawText(this.client.textRenderer, t, (x + 32 + 3),
(y + 12), 0xAAAAAA, false);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ protected TitleScreenMixin(Text title) {
@Inject(at = @At("RETURN"), method = "initWidgetsNormal")
private void addCustomButton(int y, int spacingY, CallbackInfo ci) {

ButtonWidget btn = new ButtonWidget(this.width / 2 - 100 + 205, y, 50, 20, Text.of("Ngrok"),
button -> this.client.setScreen(new NgrokApiScreen(this)));
ButtonWidget btn = ButtonWidget
.builder(Text.of("Ngrok"),
button -> this.client.setScreen(new NgrokApiScreen(this)))
.dimensions(this.width / 2 - 100 + 205, y, 50, 20).build();

this.addDrawableChild(btn);
}
Expand Down
4 changes: 2 additions & 2 deletions Fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"ngrok-api.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.19",
"minecraft": "~1.18.2",
"fabricloader": ">=0.14.21",
"minecraft": "~1.20.1",
"java": ">=17",
"fabric-api": "*"
}
Expand Down
Loading

0 comments on commit 0878542

Please sign in to comment.