From 05fef55e7725b6400ed2d7f9e638ad43326f0f4f Mon Sep 17 00:00:00 2001 From: TexTrue <65154269+TexBlock@users.noreply.github.com> Date: Sat, 9 Mar 2024 21:04:20 +0800 Subject: [PATCH] 1.19.2 --- .../zoomerlibrary/api/ZoomOverlay.java | 6 ++--- .../api/overlays/SpyglassZoomOverlay.java | 25 +++++++++++-------- .../zoomerlibrary/impl/SpyglassHelper.java | 7 +++--- .../zoomerlibrary/mixin/InGameHudMixin.java | 8 +++--- .../PlayerHeldItemFeatureRendererMixin.java | 4 +-- fabric/build.gradle | 4 +-- forge/build.gradle | 2 +- gradle.properties | 12 ++++----- 8 files changed, 37 insertions(+), 31 deletions(-) diff --git a/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/ZoomOverlay.java b/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/ZoomOverlay.java index 03ab0ea..0b43114 100644 --- a/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/ZoomOverlay.java +++ b/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/ZoomOverlay.java @@ -1,6 +1,6 @@ package org.thinkingstudio.zoomerlibrary.api; -import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; /** @@ -32,9 +32,9 @@ public interface ZoomOverlay { /** * Renders the overlay itself. It's injected by LibZoomer itself. * - * @param graphics the in-game HUD's graphics + * @param matrices the in-game HUD's graphics */ - void renderOverlay(GuiGraphics graphics); + void renderOverlay(MatrixStack matrices); /** * The tick method. Used in order to keep the internal variables accurate and the overlay functional. diff --git a/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/overlays/SpyglassZoomOverlay.java b/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/overlays/SpyglassZoomOverlay.java index 25aa2e5..f35f02e 100644 --- a/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/overlays/SpyglassZoomOverlay.java +++ b/common/src/main/java/org/thinkingstudio/zoomerlibrary/api/overlays/SpyglassZoomOverlay.java @@ -1,9 +1,10 @@ package org.thinkingstudio.zoomerlibrary.api.overlays; +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; import org.thinkingstudio.zoomerlibrary.api.ZoomOverlay; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.client.render.RenderLayer; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -45,9 +46,10 @@ public boolean cancelOverlayRendering() { } @Override - public void renderOverlay(GuiGraphics graphics) { - int scaledWidth = graphics.getScaledWindowWidth(); - int scaledHeight = graphics.getScaledWindowHeight(); + public void renderOverlay(MatrixStack matrices) { + var window = this.client.getWindow(); + int scaledWidth = window.getScaledWidth(); + int scaledHeight = window.getScaledHeight(); float f = (float) Math.min(scaledWidth, scaledHeight); float h = Math.min((float) scaledWidth / f, (float) scaledHeight / f) * scale; int i = MathHelper.floor(f * h); @@ -56,11 +58,14 @@ public void renderOverlay(GuiGraphics graphics) { int l = (scaledHeight - j) / 2; int m = k + i; int n = l + j; - graphics.drawTexture(textureId, k, l, -90, 0.0F, 0.0F, i, j, i, j); - graphics.fill(RenderLayer.getGuiOverlay(), 0, n, scaledWidth, scaledHeight, -90, 0xFF000000); - graphics.fill(RenderLayer.getGuiOverlay(), 0, 0, scaledWidth, l, -90, 0xFF000000); - graphics.fill(RenderLayer.getGuiOverlay(), 0, l, k, n, -90, 0xFF000000); - graphics.fill(RenderLayer.getGuiOverlay(), m, l, scaledWidth, n, -90, 0xFF000000); + RenderSystem.setShaderTexture(0, textureId); + DrawableHelper.drawTexture(matrices, k, l, -90, 0.0F, 0.0F, i, j, i, j); + DrawableHelper.fill(matrices, 0, n, scaledWidth, scaledHeight, 0xFF000000); + DrawableHelper.fill(matrices, 0, 0, scaledWidth, l, 0xFF000000); + DrawableHelper.fill(matrices, 0, l, k, n, 0xFF000000); + DrawableHelper.fill(matrices, m, l, scaledWidth, n, 0xFF000000); + RenderSystem.depthMask(true); + RenderSystem.enableDepthTest(); } @Override diff --git a/common/src/main/java/org/thinkingstudio/zoomerlibrary/impl/SpyglassHelper.java b/common/src/main/java/org/thinkingstudio/zoomerlibrary/impl/SpyglassHelper.java index 0cf1125..df19966 100644 --- a/common/src/main/java/org/thinkingstudio/zoomerlibrary/impl/SpyglassHelper.java +++ b/common/src/main/java/org/thinkingstudio/zoomerlibrary/impl/SpyglassHelper.java @@ -1,9 +1,10 @@ package org.thinkingstudio.zoomerlibrary.impl; +import net.minecraft.tag.TagKey; +import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryKey; import org.thinkingstudio.zoomerlibrary.ZoomerLibrary; import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; /** @@ -13,5 +14,5 @@ public class SpyglassHelper { /** * The spyglass tag, which is used internally in order to unhardcode behavior specific to vanilla spyglasses */ - public static final TagKey SPYGLASSES = TagKey.of(RegistryKeys.ITEM, new Identifier(ZoomerLibrary.MODID, "spyglasses")); + public static final TagKey SPYGLASSES = TagKey.of(Registry.ITEM_KEY, new Identifier(ZoomerLibrary.MODID, "spyglasses")); } diff --git a/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/InGameHudMixin.java b/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/InGameHudMixin.java index 5cabd10..1444c69 100644 --- a/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/InGameHudMixin.java +++ b/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/InGameHudMixin.java @@ -3,10 +3,10 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Share; import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; +import net.minecraft.client.util.math.MatrixStack; import org.thinkingstudio.zoomerlibrary.api.ZoomInstance; import org.thinkingstudio.zoomerlibrary.api.ZoomOverlay; import org.thinkingstudio.zoomerlibrary.api.ZoomRegistry; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.hud.InGameHud; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -16,13 +16,13 @@ @Mixin(InGameHud.class) public class InGameHudMixin { @Inject( - method = "render(Lnet/minecraft/client/gui/GuiGraphics;F)V", + method = "render", at = @At( value = "INVOKE", target = "net/minecraft/client/MinecraftClient.getLastFrameDuration()F" ) ) - private void injectZoomOverlay(GuiGraphics graphics, float tickDelta, CallbackInfo ci, @Share("cancelOverlay") LocalBooleanRef cancelOverlay) { + private void injectZoomOverlay(MatrixStack matrices, float tickDelta, CallbackInfo ci, @Share("cancelOverlay") LocalBooleanRef cancelOverlay) { cancelOverlay.set(false); for (ZoomInstance instance : ZoomRegistry.getZoomInstances()) { ZoomOverlay overlay = instance.getZoomOverlay(); @@ -30,7 +30,7 @@ private void injectZoomOverlay(GuiGraphics graphics, float tickDelta, CallbackIn overlay.tickBeforeRender(); if (overlay.getActive()) { cancelOverlay.set(overlay.cancelOverlayRendering()); - overlay.renderOverlay(graphics); + overlay.renderOverlay(matrices); } } } diff --git a/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/PlayerHeldItemFeatureRendererMixin.java b/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/PlayerHeldItemFeatureRendererMixin.java index 18da196..f51da6a 100644 --- a/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/PlayerHeldItemFeatureRendererMixin.java +++ b/common/src/main/java/org/thinkingstudio/zoomerlibrary/mixin/PlayerHeldItemFeatureRendererMixin.java @@ -1,9 +1,9 @@ package org.thinkingstudio.zoomerlibrary.mixin; +import net.minecraft.client.render.model.json.ModelTransformation; import org.thinkingstudio.zoomerlibrary.impl.SpyglassHelper; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.PlayerHeldItemFeatureRenderer; -import net.minecraft.client.render.model.json.ModelTransformationMode; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; @@ -17,7 +17,7 @@ @Mixin(PlayerHeldItemFeatureRenderer.class) public abstract class PlayerHeldItemFeatureRendererMixin { @Inject(method = "renderItem", at = @At("HEAD"), cancellable = true) - private void renderCustomSpyglassesAsSpyglass(LivingEntity entity, ItemStack stack, ModelTransformationMode modelTransformationMode, Arm arm, + private void renderCustomSpyglassesAsSpyglass(LivingEntity entity, ItemStack stack, ModelTransformation.Mode modelTransformationMode, Arm arm, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { if (stack.isIn(SpyglassHelper.SPYGLASSES) && entity.getActiveItem() == stack && entity.handSwingTicks == 0) { this.renderSpyglass(entity, stack, arm, matrices, vertexConsumers, light); diff --git a/fabric/build.gradle b/fabric/build.gradle index 1c92763..bb3dc42 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -96,8 +96,8 @@ publisher { setVersionType("alpha") setChangelog(file("CHANGELOG.md").getText("UTF-8")) setVersion("${project.version}-fabric") - setDisplayName("[Forge] ${project.version}") - setGameVersions("1.20", "1.20.1") + setDisplayName("[Fabric] ${project.version}") + setGameVersions("1.19", "1.19.1", "1.19.2") setLoaders("fabric") setArtifact(remapJar) addAdditionalFile(sourcesJar) diff --git a/forge/build.gradle b/forge/build.gradle index 05cfee0..8611abc 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -106,7 +106,7 @@ publisher { setChangelog(file("CHANGELOG.md").getText("UTF-8")) setVersion("${project.version}-forge") setDisplayName("[Forge] ${project.version}") - setGameVersions("1.20", "1.20.1") + setGameVersions("1.19", "1.19.1", "1.19.2") setLoaders("forge") setArtifact(remapJar) addAdditionalFile(sourcesJar) diff --git a/gradle.properties b/gradle.properties index 85ccffe..f82263a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,19 @@ org.gradle.jvmargs=-Xmx2G -minecraft_version=1.20.1 +minecraft_version=1.19.2 enabled_platforms=fabric,forge -quilt_mappings=1.20.1+build.23 +quilt_mappings=1.19.2+build.22 archives_base_name=ZoomerLibrary -mod_version=0.1.2 +mod_version=0.1.0 maven_group=org.thinkingstudio -architectury_version=9.1.12 +architectury_version=6.6.92 fabric_loader_version=0.15.7 -fabric_api_version=0.91.0+1.20.1 +fabric_api_version=0.77.0+1.19.2 -forge_version=1.20.1-47.2.20 +forge_version=1.19.2-43.3.8 modrinth_id=M1jKlKtx curseforge_id=969061