Skip to content

Commit

Permalink
Possible 0.7.0 candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL committed Jun 9, 2023
1 parent 78d14d9 commit 415b9e4
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 99 deletions.
13 changes: 6 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ insert_final_newline = true
tab_width = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.gradle]
indent_style = tab

[*.java]
indent_style = tab

[*.json]
indent_style = space
indent_size = 2
indent_style = tab
tab_width = 2

[quilt.mod.json]
[*.mcmeta]
indent_style = tab
tab_width = 2

Expand All @@ -28,7 +31,3 @@ tab_width = 2
[*.properties]
indent_style = space
indent_size = 2

[.editorconfig]
indent_style = space
indent_size = 4
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Eclipse Temurin 17
- name: Set up Eclipse Temurin 20
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
java-version: 20
- name: Build with Gradle
run: gradle build
- name: Upload build artifacts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# LibZoomer

A library that allows other mods to create zooms and custom spyglasses easily. The current supported version is Minecraft 1.19.4.
A library that allows other mods to create zooms and custom spyglasses easily. The current supported version is Minecraft 1.20.

## Usage

Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ sourceSets {
}
}

repositories {}

// All the dependencies are declared at gradle/libs.version.toml and referenced with "libs.<id>"
// See https://docs.gradle.org/current/userguide/platforms.html for information on how version catalogs work.
dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true

# Mod Properties
version = 0.6.0
version = 0.7.0
maven_group = io.github.ennuil
archives_base_name = libzoomer

Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]
# The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html
minecraft = "1.19.4"
quilt_mappings = "1.19.4+build.3"
quilt_loader = "0.18.3"
minecraft = "1.20"
quilt_mappings = "1.20+build.1"
quilt_loader = "0.18.10"

quilted_fabric_api = "6.0.0-beta.2+0.76.0-1.19.4"
quilted_fabric_api = "7.0.0+0.83.0-1.20"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand All @@ -17,4 +17,4 @@ quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-a
[bundles]

[plugins]
quilt_loom = { id = "org.quiltmc.loom", version = "1.1.+" }
quilt_loom = { id = "org.quiltmc.loom", version = "1.2.+" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Empty file modified gradlew
100644 → 100755
Empty file.
Empty file modified gradlew.bat
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions src/main/java/io/github/ennuil/libzoomer/api/ZoomOverlay.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ennuil.libzoomer.api;

import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.GuiGraphics;
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 matrices the in-game HUD's matrices
* @param graphics the in-game HUD's graphics
*/
void renderOverlay(MatrixStack matrices);
void renderOverlay(GuiGraphics graphics);

/**
* 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,11 +1,9 @@
package io.github.ennuil.libzoomer.api.overlays;

import com.mojang.blaze3d.systems.RenderSystem;

import io.github.ennuil.libzoomer.api.ZoomOverlay;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.util.math.MatrixStack;
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 @@ -47,27 +45,22 @@ public boolean cancelOverlayRendering() {
}

@Override
public void renderOverlay(MatrixStack matrices) {
int scaledWidth = this.client.getWindow().getScaledWidth();
int scaledHeight = this.client.getWindow().getScaledHeight();
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
public void renderOverlay(GuiGraphics graphics) {
int scaledWidth = graphics.getScaledWindowWidth();
int scaledHeight = graphics.getScaledWindowHeight();
float f = (float) Math.min(scaledWidth, scaledHeight);
float h = Math.min((float) scaledWidth / f, (float) scaledHeight / f) * this.scale;
float h = Math.min((float) scaledWidth / f, (float) scaledHeight / f) * scale;
int i = MathHelper.floor(f * h);
int j = MathHelper.floor(f * h);
int k = (scaledWidth - i) / 2;
int l = (scaledHeight - j) / 2;
int m = k + i;
int n = l + j;
RenderSystem.setShaderTexture(0, this.textureId);
DrawableHelper.drawTexture(matrices, k, l, -90, 0.0F, 0.0F, i, j, i, j);
DrawableHelper.fill(matrices, 0, n, scaledWidth, scaledHeight, -90, 0xFF000000);
DrawableHelper.fill(matrices, 0, 0, scaledWidth, l, -90, 0xFF000000);
DrawableHelper.fill(matrices, 0, l, k, n, -90, 0xFF000000);
DrawableHelper.fill(matrices, m, l, scaledWidth, n, -90, 0xFF000000);
RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
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);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,31 @@
import io.github.ennuil.libzoomer.api.ZoomInstance;
import io.github.ennuil.libzoomer.api.ZoomOverlay;
import io.github.ennuil.libzoomer.api.ZoomRegistry;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;

@Mixin(InGameHud.class)
public class InGameHudMixin {
@Unique
private boolean shouldCancelOverlay = false;

@Inject(
method = "render(Lnet/minecraft/client/util/math/MatrixStack;F)V",
method = "render(Lnet/minecraft/client/gui/GuiGraphics;F)V",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/MinecraftClient.getLastFrameDuration()F"
)
)
public void injectZoomOverlay(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
public void injectZoomOverlay(GuiGraphics graphics, float tickDelta, CallbackInfo ci) {
this.shouldCancelOverlay = false;
for (ZoomInstance instance : ZoomRegistry.getZoomInstances()) {
ZoomOverlay overlay = instance.getZoomOverlay();
if (overlay != null) {
overlay.tickBeforeRender();
if (overlay.getActive()) {
this.shouldCancelOverlay = overlay.cancelOverlayRendering();
overlay.renderOverlay(matrices);
overlay.renderOverlay(graphics);
}
}
}
Expand All @@ -50,13 +51,13 @@ public void cancelOverlay(CallbackInfo ci) {

// ...which is why we set cancelOverlayRender to false before that!
@Inject(
method = "render(Lnet/minecraft/client/util/math/MatrixStack;F)V",
method = "render(Lnet/minecraft/client/gui/GuiGraphics;F)V",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/network/ClientPlayerEntity.getFrozenTicks()I"
)
)
public void disableOverlayCancelling(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
public void disableOverlayCancelling(GuiGraphics graphics, float tickDelta, CallbackInfo ci) {
if (this.shouldCancelOverlay) {
this.shouldCancelOverlay = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
public abstract class ModelPredicateProviderRegistryMixin {
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void addScopingPredicateToModdedSpyglasses(CallbackInfo ci) {
ModelPredicateProviderRegistry.register(new Identifier("libzoomer", "scoping"), (stack, clientWorld, entity, i) -> {
return entity != null
&& entity.isUsingItem()
&& entity.getActiveItem() == stack
&& entity.getActiveItem().isIn(SpyglassHelper.SPYGLASSES)
? 1.0F
: 0.0F;
});
ModelPredicateProviderRegistry.register(new Identifier("libzoomer", "scoping"), (stack, clientWorld, entity, i) ->
entity != null
&& entity.isUsingItem()
&& entity.getActiveItem() == stack
&& entity.getActiveItem().isIn(SpyglassHelper.SPYGLASSES)
? 1.0F
: 0.0F
);
}
}
8 changes: 4 additions & 4 deletions src/main/resources/data/libzoomer/tags/items/spyglasses.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"replace": false,
"values": [
"minecraft:spyglass"
]
"replace": false,
"values": [
"minecraft:spyglass"
]
}
6 changes: 3 additions & 3 deletions src/main/resources/quilt.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"depends": [
{
"id": "quilt_loader",
"versions": ">=0.18.0-"
"versions": ">=0.18.10-"
},
{
"id": "quilted_fabric_api",
"versions": ">=6.0.0-"
"versions": ">=7.0.0-"
},
{
"id": "minecraft",
"versions": ">=1.19.4"
"versions": ">=1.20"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.ennuil.libzoomer_test;

import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import org.lwjgl.glfw.GLFW;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
Expand All @@ -21,6 +19,8 @@
import net.minecraft.client.option.KeyBind;
import net.minecraft.item.Item;
import net.minecraft.item.SpyglassItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class LibZoomerTestMod implements ModInitializer, ClientModInitializer, ClientTickEvents.End {
Expand Down Expand Up @@ -71,7 +71,6 @@ public void endClientTick(MinecraftClient client) {
// This is how you get a spyglass-like zoom working
if (client.player == null) return;

// FIXME - midnight ennui definitely ruined this
MICHAEL_ZOOM.setZoom(
client.options.getPerspective().isFirstPerson()
&& (
Expand Down
6 changes: 3 additions & 3 deletions src/testmod/resources/assets/libzoomer_test/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"key.libzoomer_test.category": "LibZoomer Test Mod",
"key.libzoomer_test.michelle": "Michelle",
"item.libzoomer_test.michael": "Michael"
"key.libzoomer_test.category": "LibZoomer Test Mod",
"key.libzoomer_test.michelle": "Michelle",
"item.libzoomer_test.michael": "Michael"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"parent": "item/generated",
"textures": {
"layer0": "libzoomer_test:item/michael"
},
"overrides": [
{
"predicate": {
"libzoomer:scoping": 1
},
"model": "libzoomer_test:item/michael_active"
}
]
"parent": "item/generated",
"textures": {
"layer0": "libzoomer_test:item/michael"
},
"overrides": [
{
"predicate": {
"libzoomer:scoping": 1
},
"model": "libzoomer_test:item/michael_active"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"textures": {
"michael": "libzoomer_test:item/michael_scoping"
"textures": {
"michael": "libzoomer_test:item/michael_scoping"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 0],
"color": 5,
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#michael"},
"south": {"uv": [0, 0, 16, 16], "texture": "#michael"}
}
}
],
"display": {
"firstperson_righthand": {
"scale": [ 0.0, 0.0, 0.0 ]
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 0],
"color": 5,
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#michael"},
"south": {"uv": [0, 0, 16, 16], "texture": "#michael"}
}
}
],
"display": {
"firstperson_righthand": {
"scale": [ 0.0, 0.0, 0.0 ]
},
"firstperson_lefthand": {
"scale": [ 0.0, 0.0, 0.0 ]
}
"firstperson_lefthand": {
"scale": [ 0.0, 0.0, 0.0 ]
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 415b9e4

Please sign in to comment.