diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02a36a4..d2881c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,23 +1,15 @@ -name: Build -on: [ push, pull_request ] +name: "build" + +on: + push: + branches: [ "**" ] + tags-ignore: [ "**" ] + pull_request: + jobs: - build: - # Only run on PRs if the source branch is on someone else's repo - if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: gradle/wrapper-validation-action@v1 - - name: JDK - uses: actions/setup-java@v2.3.1 + call-build: + uses: "jpenilla/actions/.github/workflows/shared-ci.yml@master" + secrets: "inherit" with: - cache: 'gradle' - distribution: 'temurin' - java-version: '17' - - name: Build with Gradle - run: ./gradlew build - - run: mkdir staging && cp build/libs/*.jar staging - - uses: actions/upload-artifact@v2 - with: - name: Package - path: staging + artifacts-path: 'build/libs/*.jar' + loom: true diff --git a/build.gradle.kts b/build.gradle.kts index ee5141f..c32ce1a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,11 @@ plugins { - id("quiet-fabric-loom") version "1.0-SNAPSHOT" + id("quiet-fabric-loom") version "1.4-SNAPSHOT" } group = "xyz.jpenilla.squaremap.client" version = "1.4.0-SNAPSHOT" -val mcVersion = "1.19" +val mcVersion = "1.20.2" java { toolchain { @@ -14,23 +14,32 @@ java { } repositories { - maven("https://oss.sonatype.org/content/repositories/snapshots/") { - mavenContent { snapshotsOnly() } - } + mavenCentral() maven("https://maven.terraformersmc.com/") { mavenContent { includeGroup("com.terraformersmc") } } + maven("https://maven.parchmentmc.org/") { + mavenContent { + includeGroup("org.parchmentmc.data") + } + } } dependencies { minecraft("com.mojang:minecraft:$mcVersion") - mappings(loom.officialMojangMappings()) - modImplementation("net.fabricmc:fabric-loader:0.14.8") - modImplementation("net.fabricmc.fabric-api:fabric-api:0.56.1+1.19") - modImplementation("com.terraformersmc:modmenu:4.0.0") - modImplementation(include("ca.stellardrift", "confabricate", "3.0.0-SNAPSHOT")) + mappings(loom.layered { + officialMojangMappings() + parchment("org.parchmentmc.data:parchment-1.20.2:2023.10.08@zip") + }) + modImplementation("net.fabricmc:fabric-loader:0.15.0") + modImplementation("net.fabricmc.fabric-api:fabric-api:0.91.0+1.20.2") + modImplementation("com.terraformersmc:modmenu:8.0.0") + + val configurate = "org.spongepowered:configurate-hocon:4.1.2" + transitiveInclude(configurate) + modImplementation(configurate) } tasks { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..d64cd49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..1af9e09 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index f127cfd..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/settings.gradle.kts b/settings.gradle.kts index 83f639a..624fea0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,9 +1,9 @@ pluginManagement { repositories { + gradlePluginPortal() + mavenCentral() maven("https://maven.fabricmc.net/") - maven("https://maven.quiltmc.org/repository/release/") maven("https://repo.jpenilla.xyz/snapshots/") - gradlePluginPortal() } } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/MiniMap.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/MiniMap.java index 6aaba85..3260f26 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/MiniMap.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/MiniMap.java @@ -5,7 +5,7 @@ import java.util.concurrent.CompletableFuture; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.texture.DynamicTexture; import org.lwjgl.opengl.GL11; @@ -78,18 +78,20 @@ public MiniMap(SquaremapClientInitializer squaremap) { } public void initialize() { - HudRenderCallback.EVENT.register((matrixStack, delta) -> { + HudRenderCallback.EVENT.register((guiGraphics, delta) -> { if (!this.enabled || !this.visible) { return; } - if (this.client.options.renderDebug) { + // todo + if (false) { + //if (this.client.options.debug) { return; } // do not show minimap if no squaremap world set if (this.squaremap.getWorld() == null) { return; } - this.render(matrixStack, delta); + this.render(guiGraphics, delta); }); } @@ -352,7 +354,8 @@ public void updateMapTexture() { }); } - public void render(PoseStack matrixStack, float delta) { + public void render(GuiGraphics guiGraphics, float delta) { + PoseStack matrixStack = guiGraphics.pose(); TextureManager tex = this.squaremap.getTextureManager(); // get fresh reference to player since vanilla destroys this object on dimension change @@ -392,15 +395,14 @@ public void render(PoseStack matrixStack, float delta) { // on circle maps and prevents corners from extending beyond the frame on rotating square maps. RenderSystem.blendFuncSeparate(GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_SRC_COLOR, GL11.GL_ZERO); { - RenderSystem.setShaderTexture(0, this.circular ? TextureManager.MASK_CIRCLE : TextureManager.MASK_SQUARE); - GuiComponent.blit(matrixStack, this.left - this.halfSize, this.top - this.halfSize, 0, 0, 0, this.doubleSize, this.doubleSize, this.doubleSize, this.doubleSize); + guiGraphics.blit(this.circular ? TextureManager.MASK_CIRCLE : TextureManager.MASK_SQUARE, this.left - this.halfSize, this.top - this.halfSize, 0, 0, 0, this.doubleSize, this.doubleSize, this.doubleSize, this.doubleSize); } // draw sky background - uses special blend which only writes where high alpha values exist from above RenderSystem.blendFunc(GL11.GL_DST_ALPHA, GL11.GL_ONE_MINUS_DST_ALPHA); { matrixStack.pushPose(); - tex.drawTexture(matrixStack, tex.getTexture(this.player.level), x0 - halfScale, y0 + halfScale, x1 - halfScale, y1 + halfScale, u2, v2); + tex.drawTexture(matrixStack, tex.getTexture(this.player.level()), x0 - halfScale, y0 + halfScale, x1 - halfScale, y1 + halfScale, u2, v2); matrixStack.popPose(); } @@ -436,8 +438,7 @@ public void render(PoseStack matrixStack, float delta) { // draw the frame if (this.showFrame) { - RenderSystem.setShaderTexture(0, this.circular ? TextureManager.FRAME_CIRCLE : TextureManager.FRAME_SQUARE); - GuiComponent.blit(matrixStack, this.left, this.top, 0, 0, 0, this.size, this.size, this.size, this.size); + guiGraphics.blit(this.circular ? TextureManager.FRAME_CIRCLE : TextureManager.FRAME_SQUARE, this.left, this.top, 0, 0, 0, this.size, this.size, this.size, this.size); } // draw cardinal directions @@ -456,19 +457,19 @@ public void render(PoseStack matrixStack, float delta) { { matrixStack.pushPose(); matrixStack.translate(distance * sin(angle2 - 180), distance * cos(angle2 - 180), 0); - text(matrixStack, "N", dirX, dirY); + text(guiGraphics, "N", dirX, dirY); matrixStack.popPose(); matrixStack.pushPose(); matrixStack.translate(distance * sin(angle2 + 90), distance * cos(angle2 + 90), 0); - text(matrixStack, "E", dirX, dirY); + text(guiGraphics, "E", dirX, dirY); matrixStack.popPose(); matrixStack.pushPose(); matrixStack.translate(distance * sin(angle2), distance * cos(angle2), 0); - text(matrixStack, "S", dirX, dirY); + text(guiGraphics, "S", dirX, dirY); matrixStack.popPose(); matrixStack.pushPose(); matrixStack.translate(distance * sin(angle2 - 90), distance * cos(angle2 - 90), 0); - text(matrixStack, "W", dirX, dirY); + text(guiGraphics, "W", dirX, dirY); matrixStack.popPose(); } matrixStack.popPose(); @@ -478,7 +479,7 @@ public void render(PoseStack matrixStack, float delta) { if (this.showCoordinates) { matrixStack.pushPose(); matrixStack.scale(this.textScale, this.textScale, this.textScale); - text(matrixStack, String.format("%s, %s, %s", (int) Math.floor(this.player.getX()), (int) Math.floor(this.player.getY()), (int) Math.floor(this.player.getZ())), this.textX, this.textZ + 8); + text(guiGraphics, String.format("%s, %s, %s", (int) Math.floor(this.player.getX()), (int) Math.floor(this.player.getY()), (int) Math.floor(this.player.getZ())), this.textX, this.textZ + 8); matrixStack.popPose(); } @@ -488,10 +489,10 @@ public void render(PoseStack matrixStack, float delta) { matrixStack.popPose(); } - private void text(PoseStack matrixStack, String text, int x, int y) { + private void text(GuiGraphics guiGraphics, String text, int x, int y) { x -= (int) (this.client.font.width(text) / 2F); - this.client.font.draw(matrixStack, text, x + 1, y + 1, 0xFF3F3F3F); - this.client.font.draw(matrixStack, text, x, y, 0xFFFFFFFF); + guiGraphics.drawString(Minecraft.getInstance().font, text, x + 1, y + 1, 0xFF3F3F3F); + guiGraphics.drawString(Minecraft.getInstance().font, text, x, y, 0xFFFFFFFF); } private float cos(float degree) { diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/AbstractScreen.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/AbstractScreen.java index ad27556..ada60d4 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/AbstractScreen.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/AbstractScreen.java @@ -1,9 +1,9 @@ package xyz.jpenilla.squaremap.client.gui.screen; import com.mojang.blaze3d.platform.InputConstants; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.HashMap; import java.util.Map; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import xyz.jpenilla.squaremap.client.SquaremapClientInitializer; @@ -23,17 +23,17 @@ protected AbstractScreen(SquaremapClientInitializer squaremap, Screen parent) { } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { - renderBackground(matrixStack); - super.render(matrixStack, mouseX, mouseY, delta); + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + renderBackground(guiGraphics, mouseX, mouseY, delta); + super.render(guiGraphics, mouseX, mouseY, delta); } @Override - public void renderBackground(PoseStack matrixStack, int vOffset) { + public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { if (this.minecraft != null && this.minecraft.level != null) { - this.fillGradient(matrixStack, 0, 0, this.width, this.height, 0xD00F4863, 0xC0370038); + guiGraphics.fillGradient(0, 0, this.width, this.height, 0xD00F4863, 0xC0370038); } else { - this.renderDirtBackground(vOffset); + this.renderDirtBackground(guiGraphics); } } @@ -57,13 +57,13 @@ public void onClose() { } } - protected void drawText(PoseStack matrixStack, String text, int x, int y) { - drawText(matrixStack, Component.nullToEmpty(text), x, y); + protected void drawText(GuiGraphics guiGraphics, String text, int x, int y) { + drawText(guiGraphics, Component.nullToEmpty(text), x, y); } - protected void drawText(PoseStack matrixStack, Component text, int x, int y) { + protected void drawText(GuiGraphics guiGraphics, Component text, int x, int y) { x = x - (int) (this.font.width(text) / 2F); - this.font.drawShadow(matrixStack, text, x, y, 0xFFFFFFFF); + guiGraphics.drawString(this.font, text, x, y, 0xFFFFFFFF, true); } public class KeyHandler extends Task { diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/FullMapScreen.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/FullMapScreen.java index d5c4e0a..6c2191d 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/FullMapScreen.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/FullMapScreen.java @@ -1,11 +1,11 @@ package xyz.jpenilla.squaremap.client.gui.screen; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import net.minecraft.Util; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; @@ -83,9 +83,9 @@ protected void init() { this.confirmLink.clear(); this.confirmLink.addAll(List.of( - new net.minecraft.client.gui.components.Button(this.width / 2 - 50 - 105, this.height / 6 + 96, 100, 20, OPEN, (button) -> openLink()), - new net.minecraft.client.gui.components.Button(this.width / 2 - 50, this.height / 6 + 96, 100, 20, COPY, (button) -> copyLink()), - new net.minecraft.client.gui.components.Button(this.width / 2 - 50 + 105, this.height / 6 + 96, 100, 20, CANCEL, (button) -> cancel()) + net.minecraft.client.gui.components.Button.builder(OPEN, button -> openLink()).pos(this.width / 2 - 50 - 105, this.height / 6 + 96).size(100, 20).build(), + net.minecraft.client.gui.components.Button.builder(COPY, button -> copyLink()).pos(this.width / 2 - 50, this.height / 6 + 96).size(100, 20).build(), + net.minecraft.client.gui.components.Button.builder(CANCEL, button -> cancel()).pos(this.width / 2 - 50 + 105, this.height / 6 + 96).size(100, 20).build() )); // reverse the elements to draw bottom up and click top down @@ -94,29 +94,29 @@ protected void init() { } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { if (this.background == null) { - renderBackground(matrixStack); + renderBackground(guiGraphics, mouseX, mouseY, delta); } else { - this.squaremap.getTextureManager().drawTexture(matrixStack, this.background, 0, 0, this.width, this.height, 0, 0, this.width / 512F, this.height / 512F); + this.squaremap.getTextureManager().drawTexture(guiGraphics.pose(), this.background, 0, 0, this.width, this.height, 0, 0, this.width / 512F, this.height / 512F); } - super.render(matrixStack, mouseX, mouseY, delta); + super.render(guiGraphics, mouseX, mouseY, delta); - drawText(matrixStack, this.title, (int) (this.width / 2F), 15); + drawText(guiGraphics, this.title, (int) (this.width / 2F), 15); if (openURL != null) { - this.fillGradient(matrixStack, 0, 0, this.width, this.height, 0xD00F4863, 0xC0370038); - drawCenteredString(matrixStack, this.font, LINK_CONFIRMATION, this.width / 2, 70, 16777215); - drawCenteredString(matrixStack, this.font, this.openURL, this.width / 2, 90, 16777215); + guiGraphics.fillGradient(0, 0, this.width, this.height, 0xD00F4863, 0xC0370038); + guiGraphics.drawCenteredString(this.font, LINK_CONFIRMATION, this.width / 2, 70, 16777215); + guiGraphics.drawCenteredString(this.font, this.openURL, this.width / 2, 90, 16777215); for (net.minecraft.client.gui.components.Button buttonWidget : this.confirmLink) { - buttonWidget.render(matrixStack, mouseX, mouseY, delta); + buttonWidget.render(guiGraphics, mouseX, mouseY, delta); } } } @Override - public void renderBackground(PoseStack matrixStack, int vOffset) { + public void renderBackground(GuiGraphics matrixStack, int i, int j, float f) { // don't waste cpu on super's background } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/OptionsScreen.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/OptionsScreen.java index 9ee8ed5..0dfa330 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/OptionsScreen.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/OptionsScreen.java @@ -1,8 +1,8 @@ package xyz.jpenilla.squaremap.client.gui.screen; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.List; import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; @@ -157,20 +157,20 @@ public void init() { } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { int centerX = (int) (this.width / 2F); if (parent instanceof FullMapScreen) { int centerY = (int) (this.height / 2F); - this.parent.render(matrixStack, centerX, centerY, 0); + this.parent.render(guiGraphics, centerX, centerY, 0); } - super.render(matrixStack, mouseX, mouseY, delta); + super.render(guiGraphics, mouseX, mouseY, delta); - drawText(matrixStack, this.title, centerX, 15); + drawText(guiGraphics, this.title, centerX, 15); - drawText(matrixStack, RENDERER, centerX, 50); - drawText(matrixStack, MINIMAP, centerX, 95); + drawText(guiGraphics, RENDERER, centerX, 50); + drawText(guiGraphics, MINIMAP, centerX, 95); } @Override diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/PositionScreen.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/PositionScreen.java index d6631d2..9607926 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/PositionScreen.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/PositionScreen.java @@ -1,6 +1,6 @@ package xyz.jpenilla.squaremap.client.gui.screen; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import org.lwjgl.glfw.GLFW; @@ -37,21 +37,21 @@ protected void init() { } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { - super.render(matrixStack, mouseX, mouseY, delta); + public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + super.render(guiGraphics, mouseX, mouseY, delta); int centerX = (int) (this.width / 2F); int centerY = (int) (this.height / 2F); - drawText(matrixStack, this.title, centerX, 15); + drawText(guiGraphics, this.title, centerX, 15); - drawText(matrixStack, Component.translatable("squaremap-client.screen.position.size", this.minimap.getSize(), this.minimap.getZoom()), centerX, 30); - drawText(matrixStack, Component.translatable("squaremap-client.screen.position.center", this.minimap.getCenterX(), this.minimap.getCenterZ()), centerX, 40); + drawText(guiGraphics, Component.translatable("squaremap-client.screen.position.size", this.minimap.getSize(), this.minimap.getZoom()), centerX, 30); + drawText(guiGraphics, Component.translatable("squaremap-client.screen.position.center", this.minimap.getCenterX(), this.minimap.getCenterZ()), centerX, 40); - drawText(matrixStack, HELP_1, centerX, centerY - 30); - drawText(matrixStack, HELP_2, centerX, centerY - 10); - drawText(matrixStack, HELP_3, centerX, centerY + 10); - drawText(matrixStack, HELP_4, centerX, centerY + 30); + drawText(guiGraphics, HELP_1, centerX, centerY - 30); + drawText(guiGraphics, HELP_2, centerX, centerY - 10); + drawText(guiGraphics, HELP_3, centerX, centerY + 10); + drawText(guiGraphics, HELP_4, centerX, centerY + 30); } @Override diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Button.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Button.java index f2c43bb..1def50d 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Button.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Button.java @@ -1,9 +1,9 @@ package xyz.jpenilla.squaremap.client.gui.screen.widget; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.List; import java.util.function.Function; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; @@ -45,10 +45,10 @@ public void onPress() { } @Override - public void renderButton(PoseStack matrixStack, int mouseX, int mouseY, float delta) { - super.renderButton(matrixStack, mouseX, mouseY, delta); + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + super.renderWidget(guiGraphics, mouseX, mouseY, delta); if (this.isHoveredOrFocused() && this.tooltipDelay > 10) { - this.renderToolTip(matrixStack, mouseX, mouseY); + this.renderToolTip(guiGraphics, mouseX, mouseY); } } @@ -61,14 +61,13 @@ public void tick() { } } - @Override - public void renderToolTip(PoseStack matrixStack, int mouseX, int mouseY) { + public void renderToolTip(GuiGraphics graphics, int mouseX, int mouseY) { List tooltip = Minecraft.getInstance().font.split(this.tooltip, 150); - this.screen.renderTooltip(matrixStack, tooltip, mouseX, mouseY); + graphics.renderTooltip(Minecraft.getInstance().font, tooltip, mouseX, mouseY); } @Override - public void updateNarration(NarrationElementOutput builder) { + public void updateWidgetNarration(NarrationElementOutput builder) { this.defaultButtonNarrationText(builder); } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Coordinates.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Coordinates.java index 41d2e32..31df249 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Coordinates.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Coordinates.java @@ -1,21 +1,16 @@ package xyz.jpenilla.squaremap.client.gui.screen.widget; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import java.text.NumberFormat; import java.util.Locale; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.client.gui.components.Widget; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.narration.NarratableEntry; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; -import xyz.jpenilla.squaremap.client.mixin.ToastAccess; +import xyz.jpenilla.squaremap.client.mixin.AdvancementToastAccess; -public class Coordinates extends GuiComponent implements Widget, GuiEventListener, NarratableEntry { +public class Coordinates extends AbstractWidget { private static final NumberFormat NUMBER = NumberFormat.getInstance(Locale.US); private final FullMapWidget fullmap; private final int x; @@ -24,6 +19,7 @@ public class Coordinates extends GuiComponent implements Widget, GuiEventListene private final int height; public Coordinates(FullMapWidget fullmap, int x, int y, int width, int height) { + super(x, y, width, height, null); this.fullmap = fullmap; this.x = x; this.y = y; @@ -38,23 +34,14 @@ public Component getCoordinates(int mouseX, int mouseY) { } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { Minecraft minecraftClient = Minecraft.getInstance(); Font textRenderer = minecraftClient.font; - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, ToastAccess.texture()); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.enableDepthTest(); Component coordinates = getCoordinates(mouseX, mouseY); int w2 = (int) ((textRenderer.width(coordinates) + 20) / 2F); int h2 = (int) (this.height / 2F); - blit(matrixStack, x, y, w2, h2, 0, 0, w2, h2, 256, 256); - blit(matrixStack, x, y + h2, w2, h2, 0, 32 - h2, w2, h2, 256, 256); - blit(matrixStack, x + w2, y, w2, h2, 160 - w2, 0, w2, h2, 256, 256); - blit(matrixStack, x + w2, y + h2, w2, h2, 160 - w2, 32 - h2, w2, h2, 256, 256); - drawCenteredString(matrixStack, textRenderer, coordinates, this.x + w2, this.y + (this.height - 8) / 2, 0xffcccccc); + guiGraphics.blitSprite(AdvancementToastAccess.backgroundSprite(), x, y, w2 * 2, h2 * 2); + guiGraphics.drawCenteredString(textRenderer, coordinates, this.x + w2, this.y + (this.height - 8) / 2, 0xffcccccc); } @Override @@ -63,6 +50,6 @@ public NarrationPriority narrationPriority() { } @Override - public void updateNarration(NarrationElementOutput builder) { + public void updateWidgetNarration(NarrationElementOutput builder) { } } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/FullMapWidget.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/FullMapWidget.java index 1a8e91d..74f6aad 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/FullMapWidget.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/FullMapWidget.java @@ -4,10 +4,8 @@ import java.util.LinkedHashSet; import java.util.Set; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; -import net.minecraft.client.gui.components.Widget; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.narration.NarratableEntry; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.network.chat.Component; import xyz.jpenilla.squaremap.client.SquaremapClientInitializer; @@ -16,7 +14,7 @@ import xyz.jpenilla.squaremap.client.util.Util; import xyz.jpenilla.squaremap.client.util.WorldInfo; -public class FullMapWidget implements Widget, GuiEventListener, NarratableEntry { +public class FullMapWidget extends AbstractWidget { private static final boolean DEBUG = false; private final Set tiles = new LinkedHashSet<>(); @@ -40,6 +38,7 @@ public class FullMapWidget implements Widget, GuiEventListener, NarratableEntry private boolean showSelf; public FullMapWidget(SquaremapClientInitializer squaremap, Minecraft client, int width, int height) { + super(0, 0, width, height, null); this.squaremap = squaremap; this.client = client; this.width = width; @@ -93,8 +92,8 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double amount) { - zoom(mouseX, mouseY, amount); + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { + zoom(mouseX, mouseY, scrollY); return true; } @@ -185,7 +184,8 @@ public void updateTiles() { } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + final PoseStack matrixStack = guiGraphics.pose(); double extra = Math.pow(2, this.zoom > this.world.zoomMax() ? this.zoom - this.world.zoomMax() : 0); double pow = Math.pow(2, this.world.zoomMax() - this.zoom) * extra; double size = Tile.SIZE / this.client.getWindow().getGuiScale() * extra; @@ -199,8 +199,8 @@ public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { tile.render(matrixStack, x0, y0, x1, y1, 0F, 0F, 1F, 1F); if (DEBUG) { - GuiComponent.fill(matrixStack, (int) x0, (int) y0, (int) x0 + 1, (int) y1, 0x88888888); - GuiComponent.fill(matrixStack, (int) x0, (int) y0, (int) x1, (int) y0 + 1, 0x88888888); + guiGraphics.fill((int) x0, (int) y0, (int) x0 + 1, (int) y1, 0x88888888); + guiGraphics.fill((int) x0, (int) y0, (int) x1, (int) y0 + 1, 0x88888888); } } matrixStack.popPose(); @@ -212,16 +212,16 @@ public void render(PoseStack matrixStack, int mouseX, int mouseY, float delta) { if (DEBUG) { int i = -1; - debug(matrixStack, "player pos: " + this.client.player.getBlockX() + " " + this.client.player.getBlockZ(), ++i); - debug(matrixStack, "pow: " + pow, ++i); - debug(matrixStack, "offset: " + this.offsetX + " " + this.offsetY, ++i); - debug(matrixStack, "mouse: " + mouseX + " " + mouseY, ++i); - debug(matrixStack, "scale: " + getScale(), ++i); - debug(matrixStack, "zoom: " + this.zoom, ++i); - debug(matrixStack, "size: " + size, ++i); - debug(matrixStack, "window: " + width + " " + height, ++i); - debug(matrixStack, "tile count: " + this.tiles.size(), ++i); - debug(matrixStack, "loaded tile count: " + this.squaremap.getTileManager().count(), ++i); + debug(guiGraphics, "player pos: " + this.client.player.getBlockX() + " " + this.client.player.getBlockZ(), ++i); + debug(guiGraphics, "pow: " + pow, ++i); + debug(guiGraphics, "offset: " + this.offsetX + " " + this.offsetY, ++i); + debug(guiGraphics, "mouse: " + mouseX + " " + mouseY, ++i); + debug(guiGraphics, "scale: " + getScale(), ++i); + debug(guiGraphics, "zoom: " + this.zoom, ++i); + debug(guiGraphics, "size: " + size, ++i); + debug(guiGraphics, "window: " + width + " " + height, ++i); + debug(guiGraphics, "tile count: " + this.tiles.size(), ++i); + debug(guiGraphics, "loaded tile count: " + this.squaremap.getTileManager().count(), ++i); } } @@ -236,14 +236,16 @@ private void drawPlayerIcon(final PoseStack matrixStack, final float delta, fina matrixStack.popPose(); } - private void debug(PoseStack matrixStack, String str, int y) { - this.client.font.drawShadow(matrixStack, Component.nullToEmpty(str), 10, 50 + 10 * y, 0xFFFFFFFF); + private void debug(GuiGraphics guiGraphics, String str, int y) { + guiGraphics.drawString(this.client.font, Component.nullToEmpty(str), 10, 50 + 10 * y, 0xFFFFFFFF); } + /* @Override public boolean changeFocus(boolean lookForwards) { return true; } + */ @Override public NarrationPriority narrationPriority() { @@ -251,7 +253,7 @@ public NarrationPriority narrationPriority() { } @Override - public void updateNarration(NarrationElementOutput builder) { + public void updateWidgetNarration(NarrationElementOutput builder) { } public boolean showSelf() { diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/MiniMapWidget.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/MiniMapWidget.java index 6bb0757..fb27b0c 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/MiniMapWidget.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/MiniMapWidget.java @@ -1,6 +1,6 @@ package xyz.jpenilla.squaremap.client.gui.screen.widget; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; @@ -18,7 +18,7 @@ public MiniMapWidget(MiniMap minimap) { } @Override - public void updateNarration(NarrationElementOutput builder) { + public void updateWidgetNarration(NarrationElementOutput builder) { this.defaultButtonNarrationText(builder); } @@ -33,7 +33,7 @@ public int getHeight() { } @Override - public void renderButton(PoseStack matrixStack, int mouseX, int mouseY, float delta) { + public void renderWidget(GuiGraphics matrixStack, int mouseX, int mouseY, float delta) { this.minimap.render(matrixStack, delta); } @@ -51,17 +51,17 @@ public void onRelease(double mouseX, double mouseY) { @Override protected void onDrag(double mouseX, double mouseY, double deltaX, double deltaY) { - this.x = (int) (mouseX - clickX); - this.y = (int) (mouseY - clickY); - this.minimap.setCenter(this.x + this.minimap.getHalfSize(), this.y + this.minimap.getHalfSize(), true); + this.setX((int) (mouseX - clickX)); + this.setY((int) (mouseY - clickY)); + this.minimap.setCenter(this.getX() + this.minimap.getHalfSize(), this.getY() + this.minimap.getHalfSize(), true); } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double amount) { + public boolean mouseScrolled(double mouseX, double mouseY, double scrollX, double scrollY) { if (!Screen.hasControlDown()) { - this.minimap.addZoomLevel((int) amount); + this.minimap.addZoomLevel((int) scrollY); } else { - this.minimap.addSize(amount > 0 ? 16 : -16); + this.minimap.addSize(scrollY > 0 ? 16 : -16); } return true; } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Player.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Player.java index c0cd411..4f96d56 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Player.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Player.java @@ -1,14 +1,16 @@ package xyz.jpenilla.squaremap.client.gui.screen.widget; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.gui.components.Widget; -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.narration.NarratableEntry; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; -public class Player implements Widget, GuiEventListener, NarratableEntry { +public class Player extends AbstractWidget { + public Player() { + super(0, 0, 0, 0, null); + } + @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { } @Override @@ -17,6 +19,6 @@ public NarrationPriority narrationPriority() { } @Override - public void updateNarration(NarrationElementOutput builder) { + public void updateWidgetNarration(NarrationElementOutput builder) { } } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Slider.java b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Slider.java index fc3d989..bcf48d1 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Slider.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/gui/screen/widget/Slider.java @@ -1,10 +1,9 @@ package xyz.jpenilla.squaremap.client.gui.screen.widget; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.List; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.AbstractSliderButton; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.sounds.SoundManager; @@ -14,7 +13,8 @@ import org.lwjgl.glfw.GLFW; import xyz.jpenilla.squaremap.client.config.options.IntegerOption; -public class Slider extends AbstractWidget implements Tickable { +// todo this is kind of broken in 1.20.2 +public class Slider extends AbstractSliderButton implements Tickable { private final Screen screen; private final IntegerOption option; private final double step; @@ -22,7 +22,7 @@ public class Slider extends AbstractWidget implements Tickable { private int tooltipDelay; public Slider(Screen screen, int x, int y, int width, int height, IntegerOption option) { - super(x, y, width, height, option.getName()); + super(x, y, width, height, option.getName(), option.getValue()); this.screen = screen; this.option = option; this.step = option.getMin() / (double) option.getMax(); @@ -31,24 +31,27 @@ public Slider(Screen screen, int x, int y, int width, int height, IntegerOption updateMessage(); } + /* @Override protected int getYImage(boolean hovered) { return 0; } + */ @Override - public void updateNarration(NarrationElementOutput builder) { + public void updateWidgetNarration(NarrationElementOutput builder) { this.defaultButtonNarrationText(builder); } @Override - public void renderButton(PoseStack matrixStack, int mouseX, int mouseY, float delta) { - super.renderButton(matrixStack, mouseX, mouseY, delta); + public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { + super.renderWidget(guiGraphics, mouseX, mouseY, delta); if (this.isHoveredOrFocused() && this.tooltipDelay > 10) { - this.renderToolTip(matrixStack, mouseX, mouseY); + this.renderToolTip(guiGraphics, mouseX, mouseY); } } + /* @Override protected void renderBg(PoseStack matrixStack, Minecraft client, int mouseX, int mouseY) { RenderSystem.setShaderTexture(0, WIDGETS_LOCATION); @@ -57,11 +60,11 @@ protected void renderBg(PoseStack matrixStack, Minecraft client, int mouseX, int this.blit(matrixStack, this.x + (int) (this.value * (double) (this.width - 8)), this.y, 0, 46 + i, 4, 20); this.blit(matrixStack, this.x + (int) (this.value * (double) (this.width - 8)) + 4, this.y, 196, 46 + i, 4, 20); } + */ - @Override - public void renderToolTip(PoseStack matrixStack, int mouseX, int mouseY) { + public void renderToolTip(GuiGraphics guiGraphics, int mouseX, int mouseY) { List tooltip = Minecraft.getInstance().font.split(this.option.tooltip(), 200); - this.screen.renderTooltip(matrixStack, tooltip, mouseX, mouseY); + guiGraphics.renderTooltip(Minecraft.getInstance().font, tooltip, mouseX, mouseY); } @Override @@ -86,7 +89,7 @@ protected void onDrag(double mouseX, double mouseY, double deltaX, double deltaY } private void setValueFromMouse(double mouseX) { - this.setValue((mouseX - (double) (this.x + 4)) / (double) (this.width - 8)); + this.setValue((mouseX - (double) (this.getX() + 4)) / (double) (this.width - 8)); } private void setValue(double value) { @@ -125,10 +128,15 @@ private double adjust(double value) { return Mth.clamp(value, this.option.getMin(), this.option.getMax()); } - private void updateMessage() { + public void updateMessage() { setMessage(Component.literal(this.option.getName().getString() + ": " + this.option.getValue())); } + @Override + protected void applyValue() { + + } + @Override public void tick() { if (this.isHoveredOrFocused()) { diff --git a/src/main/java/xyz/jpenilla/squaremap/client/manager/NetworkManager.java b/src/main/java/xyz/jpenilla/squaremap/client/manager/NetworkManager.java index 9b22a97..9bff003 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/manager/NetworkManager.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/manager/NetworkManager.java @@ -25,7 +25,7 @@ public NetworkManager(SquaremapClientInitializer squaremap) { public void initialize() { ClientPlayNetworking.registerGlobalReceiver(this.channel, (client, handler, buf, responseSender) -> { - ByteArrayDataInput packet = in(buf.accessByteBufWithCorrectSize()); + ByteArrayDataInput packet = in(buf); int packetType = packet.readInt(); int protocol = packet.readInt(); if (protocol != Constants.PROTOCOL) { @@ -97,13 +97,13 @@ private void sendPacket(ByteArrayDataOutput packet) { } } - @SuppressWarnings("UnstableApiUsage") private ByteArrayDataOutput out() { return ByteStreams.newDataOutput(); } - @SuppressWarnings("UnstableApiUsage") - private ByteArrayDataInput in(byte[] bytes) { - return ByteStreams.newDataInput(bytes); + private ByteArrayDataInput in(FriendlyByteBuf buf) { + final byte[] copy = new byte[buf.readableBytes()]; + buf.readBytes(copy); + return ByteStreams.newDataInput(copy); } } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/manager/TextureManager.java b/src/main/java/xyz/jpenilla/squaremap/client/manager/TextureManager.java index fd236c5..7069754 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/manager/TextureManager.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/manager/TextureManager.java @@ -8,7 +8,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.math.Matrix4f; import java.io.IOException; import java.io.InputStream; import net.minecraft.client.Minecraft; @@ -16,6 +15,7 @@ import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; +import org.joml.Matrix4f; import xyz.jpenilla.squaremap.client.SquaremapClientInitializer; import xyz.jpenilla.squaremap.client.util.Constants; diff --git a/src/main/java/xyz/jpenilla/squaremap/client/mixin/ToastAccess.java b/src/main/java/xyz/jpenilla/squaremap/client/mixin/AdvancementToastAccess.java similarity index 50% rename from src/main/java/xyz/jpenilla/squaremap/client/mixin/ToastAccess.java rename to src/main/java/xyz/jpenilla/squaremap/client/mixin/AdvancementToastAccess.java index 9ee548c..16428aa 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/mixin/ToastAccess.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/mixin/AdvancementToastAccess.java @@ -1,15 +1,15 @@ package xyz.jpenilla.squaremap.client.mixin; -import net.minecraft.client.gui.components.toasts.Toast; +import net.minecraft.client.gui.components.toasts.AdvancementToast; import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(Toast.class) -public interface ToastAccess { +@Mixin(AdvancementToast.class) +public interface AdvancementToastAccess { - @Accessor("TEXTURE") - static ResourceLocation texture() { + @Accessor("BACKGROUND_SPRITE") + static ResourceLocation backgroundSprite() { throw new AssertionError(); } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/mixin/MapInstanceMixin.java b/src/main/java/xyz/jpenilla/squaremap/client/mixin/MapInstanceMixin.java index 3f76d3c..1313e4e 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/mixin/MapInstanceMixin.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/mixin/MapInstanceMixin.java @@ -2,7 +2,7 @@ import net.minecraft.client.gui.MapRenderer; import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -114,7 +114,7 @@ private void updateMapTexture() { } else { squaremapColor = this.image.getPixel(x, z); if (squaremapColor == 0) { - setPixelColor(x, z, /*MapColorAccessor.getColors()[color / 4]*/MaterialColor.getColorFromPackedId(color & 3)); + setPixelColor(x, z, /*MapColorAccessor.getColors()[color / 4]*/MapColor.getColorFromPackedId(color & 3)); } else { setPixelColor(x, z, squaremapColor); } diff --git a/src/main/java/xyz/jpenilla/squaremap/client/util/Util.java b/src/main/java/xyz/jpenilla/squaremap/client/util/Util.java index b572cf7..684be99 100644 --- a/src/main/java/xyz/jpenilla/squaremap/client/util/Util.java +++ b/src/main/java/xyz/jpenilla/squaremap/client/util/Util.java @@ -1,7 +1,7 @@ package xyz.jpenilla.squaremap.client.util; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; public final class Util { private Util() { @@ -14,7 +14,7 @@ public static RuntimeException rethrow(final Throwable t) public static void rotateScene(final PoseStack matrixStack, final double x, final double y, final float degrees) { matrixStack.translate(x, y, 0); - matrixStack.mulPose(Vector3f.ZP.rotationDegrees(degrees)); + matrixStack.mulPose(Axis.ZP.rotationDegrees(degrees)); matrixStack.translate(-x, -y, 0); } } diff --git a/src/main/resources/assets/icon.png b/src/main/resources/assets/icon.png deleted file mode 100644 index fa02c40..0000000 Binary files a/src/main/resources/assets/icon.png and /dev/null differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ae137ef..4a746ca 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -14,7 +14,6 @@ "sources": "https://github.com/jpenilla/squaremap-client" }, "license": "MIT", - "icon": "assets/icon.png", "environment": "client", "entrypoints": { "client": [ @@ -29,9 +28,9 @@ ], "accessWidener": "squaremap-client.accesswidener", "depends": { - "fabricloader": ">=0.13.3", + "fabricloader": ">=0.14.0", "fabric": "*", - "minecraft": "~1.19" + "minecraft": "~1.20.2" }, "conflicts": { "pl3xmap": "*" diff --git a/src/main/resources/squaremap-client.mixins.json b/src/main/resources/squaremap-client.mixins.json index ef9a2ff..f4e16d8 100644 --- a/src/main/resources/squaremap-client.mixins.json +++ b/src/main/resources/squaremap-client.mixins.json @@ -5,9 +5,9 @@ "compatibilityLevel": "JAVA_17", "refmap": "squaremap-client.refmap.json", "client": [ + "AdvancementToastAccess", "MapRendererAccess", - "MapInstanceMixin", - "ToastAccess" + "MapInstanceMixin" ], "injectors": { "defaultRequire": 1