Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Mar 9, 2024
1 parent fd500c9 commit 05fef55
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -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<Item> SPYGLASSES = TagKey.of(RegistryKeys.ITEM, new Identifier(ZoomerLibrary.MODID, "spyglasses"));
public static final TagKey<Item> SPYGLASSES = TagKey.of(Registry.ITEM_KEY, new Identifier(ZoomerLibrary.MODID, "spyglasses"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,21 +16,21 @@
@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();
if (overlay != null) {
overlay.tickBeforeRender();
if (overlay.getActive()) {
cancelOverlay.set(overlay.cancelOverlayRendering());
overlay.renderOverlay(graphics);
overlay.renderOverlay(matrices);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 05fef55

Please sign in to comment.