Skip to content

Commit

Permalink
Backport Murderleague to 1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL committed Nov 5, 2024
1 parent 0be4038 commit 55b94d8
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.ennuil.ok_zoomer.config.screen.components;

import com.mojang.blaze3d.systems.RenderSystem;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.client.Minecraft;
Expand All @@ -17,7 +18,6 @@
import net.minecraft.client.gui.navigation.ScreenAxis;
import net.minecraft.client.gui.navigation.ScreenDirection;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -133,15 +133,19 @@ protected void narrateListElementPosition(NarrationElementOutput narrationElemen
}

private void renderListBackground(GuiGraphics graphics) {
RenderSystem.enableBlend();
var backgroundLocation = this.minecraft.level == null ? MENU_LIST_BACKGROUND : INWORLD_MENU_LIST_BACKGROUND;
graphics.blit(RenderType::guiTextured, backgroundLocation, this.getX(), this.getY(), this.getRight(), this.getBottom() + this.getScrollAmount(), this.width, this.height, 32,32);
graphics.blit(backgroundLocation, this.getX(), this.getY(), this.getRight(), this.getBottom() + this.getScrollAmount(), this.width, this.height, 32,32);
RenderSystem.disableBlend();
}

private void renderListSeparators(GuiGraphics graphics) {
RenderSystem.enableBlend();
var headerSeparatorLocation = this.minecraft.level == null ? Screen.HEADER_SEPARATOR : Screen.INWORLD_HEADER_SEPARATOR;
var footerSeparatorLocation = this.minecraft.level == null ? Screen.FOOTER_SEPARATOR : Screen.INWORLD_FOOTER_SEPARATOR;
graphics.blit(RenderType::guiTextured, headerSeparatorLocation, this.getX(), this.getY() - 2, 0.0F, 0.0F, this.width, 2, 32, 2);
graphics.blit(RenderType::guiTextured, footerSeparatorLocation, this.getX(), this.getBottom(), 0.0F, 0.0F, this.width, 2, 32, 2);
graphics.blit(headerSeparatorLocation, this.getX(), this.getY() - 2, 0.0F, 0.0F, this.width, 2, 32, 2);
graphics.blit(footerSeparatorLocation, this.getX(), this.getBottom(), 0.0F, 0.0F, this.width, 2, 32, 2);
RenderSystem.disableBlend();
}

private void renderScrollBar(GuiGraphics graphics) {
Expand All @@ -151,8 +155,10 @@ private void renderScrollBar(GuiGraphics graphics) {
var scale = (this.scrollAmount / (double) (this.contentHeight - this.height));
var y = this.getY() + (int) (scale * (this.height - size));

graphics.blitSprite(RenderType::guiTextured, SCROLLER_BACKGROUND_SPRITE, x, this.getY(), 6, this.height);
graphics.blitSprite(RenderType::guiTextured, SCROLLER_SPRITE, x, y, 6, size);
RenderSystem.enableBlend();
graphics.blitSprite(SCROLLER_BACKGROUND_SPRITE, x, this.getY(), 6, this.height);
graphics.blitSprite(SCROLLER_SPRITE, x, y, 6, size);
RenderSystem.disableBlend();
}

protected int getScrollBarPosX() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ private int modifyCulling(int original) {
}

@ModifyReturnValue(method = "getFov", at = @At(value = "RETURN", ordinal = 1))
private float modifyFov(float original, @Local(argsOnly = true) float partialTicks) {
private double modifyFov(double original, @Local(argsOnly = true) float partialTicks) {
if (!Zoom.isTransitionActive()) {
return original;
} else {
return Zoom.getTransitionMode().applyZoom(original, partialTicks);
return Zoom.getTransitionMode().applyZoom((float) original, partialTicks);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;
import com.mojang.blaze3d.systems.RenderSystem;
import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager;
import io.github.ennuil.ok_zoomer.zoom.Zoom;
import net.minecraft.client.DeltaTracker;
Expand Down Expand Up @@ -89,7 +90,14 @@ private void hideCrosshair(GuiGraphics graphics, DeltaTracker deltaTracker, Oper
boolean persistentInterface = OkZoomerConfigManager.CONFIG.features.persistentInterface.value();
boolean hideCrosshair = OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair.value();
if (persistentInterface || hideCrosshair || !Zoom.isTransitionActive()) {
if (hideCrosshair) {
float fade = 1.0F - Zoom.getTransitionMode().getFade(deltaTracker.getGameTimeDeltaPartialTick(true));
RenderSystem.setShaderColor(fade, fade, fade, fade);
}
original.call(graphics, deltaTracker);
if (hideCrosshair) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
} else {
// TODO - This has been recycled once, this should become a method
var lastPose = graphics.pose().last().pose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class MouseHandlerMixin {
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isSpectator()Z"),
cancellable = true
)
private void zoomerOnMouseScroll(CallbackInfo ci, @Local int k) {
private void zoomerOnMouseScroll(CallbackInfo ci, @Local(ordinal = 2) int k) {
if (k != 0) {
if (OkZoomerConfigManager.CONFIG.features.zoomScrolling.value()) {
if (OkZoomerConfigManager.CONFIG.features.zoomMode.value().equals(ZoomModes.PERSISTENT)) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void validateZoomCulling(Minecraft minecraft) {
int zoomCullingFov = Math.ceilDiv(fov, divisor);

if (zoomCullingFov != lastZoomCullingFov) {
minecraft.levelRenderer.getSectionOcclusionGraph().invalidate();
minecraft.levelRenderer.needsUpdate();
}

lastZoomCullingFov = zoomCullingFov;
Expand Down Expand Up @@ -96,7 +96,7 @@ public static void unbindConflictingKey(Minecraft client, boolean userPrompted)
if (client.options.keySaveHotbarActivator.isDefault()) {
if (userPrompted) {
ZoomUtils.LOGGER.info("[Ok Zoomer] The \"Save Toolbar Activator\" keybind was occupying C! Unbinding...");
client.getToastManager().addToast(SystemToast.multiline(
client.getToasts().addToast(SystemToast.multiline(
client, TOAST_ID, Component.translatable("toast.ok_zoomer.title"),
Component.translatable("toast.ok_zoomer.unbind_conflicting_key.success")));
} else {
Expand All @@ -108,7 +108,7 @@ public static void unbindConflictingKey(Minecraft client, boolean userPrompted)
} else {
ZoomUtils.LOGGER.info("[Ok Zoomer] No conflicts with the \"Save Toolbar Activator\" keybind were found!");
if (userPrompted) {
client.getToastManager().addToast(SystemToast.multiline(
client.getToasts().addToast(SystemToast.multiline(
client, TOAST_ID, Component.translatable("toast.ok_zoomer.title"),
Component.translatable("toast.ok_zoomer.unbind_conflicting_key.no_conflict")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public static <C extends ReflectiveConfig> C create(String family, String id, Cl
if (WrenchWrapper.getClass("org.quiltmc.loader.api.QuiltLoader") != null) {
var clazz = WrenchWrapper.getClass("io.github.ennuil.ok_zoomer.wrench_wrapper.quilt.QuiltWrapper");
return (C) clazz.getMethod("create", String.class, String.class, Class.class).invoke(null, family, id, configCreatorClass);
} else if (WrenchWrapper.getClass("net.fabricmc.loader.FabricLoader") != null) {
} else if (WrenchWrapper.getClass("net.fabricmc.loader.FabricLoader") != null
&& WrenchWrapper.getClass("net.neoforged.neoforge.common.NeoForge") == null) {
// The above check immunizes Wrench Wrapper's wrapper against Sinytra Connector
var clazz = WrenchWrapper.getClass("io.github.ennuil.ok_zoomer.wrench_wrapper.fabric.FabricWrapper");
return (C) clazz.getMethod("create", String.class, String.class, Class.class).invoke(null, family, id, configCreatorClass);
} else if (WrenchWrapper.getClass("net.neoforged.neoforge.common.NeoForge") != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.ennuil.ok_zoomer.zoom.overlays;

import com.mojang.blaze3d.systems.RenderSystem;
import io.github.ennuil.ok_zoomer.zoom.transitions.TransitionMode;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.GuiGraphics;
Expand Down Expand Up @@ -45,7 +46,9 @@ public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, Trans
int y = (guiHeight - height) / 2;
int borderX = x + width;
int borderY = y + height;
graphics.blit(RenderType::guiTextured, textureId, x, y, 0.0F, 0.0F, width, height, width, height);
RenderSystem.enableBlend();
graphics.blit(textureId, x, y, 0.0F, 0.0F, width, height, width, height);
RenderSystem.disableBlend();
graphics.fill(RenderType.guiOverlay(), 0, borderY, guiWidth, guiHeight, -90, CommonColors.BLACK);
graphics.fill(RenderType.guiOverlay(), 0, 0, guiWidth, y, -90, CommonColors.BLACK);
graphics.fill(RenderType.guiOverlay(), 0, y, x, borderY, -90, CommonColors.BLACK);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.ennuil.ok_zoomer.zoom.overlays;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import io.github.ennuil.ok_zoomer.zoom.transitions.TransitionMode;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ARGB;

// Implements the zoom overlay
public class ZoomerZoomOverlay implements ZoomOverlay {
Expand All @@ -24,9 +24,18 @@ public boolean getActive() {

@Override
public void renderOverlay(GuiGraphics graphics, DeltaTracker deltaTracker, TransitionMode transitionMode) {
RenderSystem.disableDepthTest();
RenderSystem.depthMask(false);
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
float fade = transitionMode.getFade(deltaTracker.getGameTimeDeltaPartialTick(true));
int color = ARGB.colorFromFloat(1.0F, fade, fade, fade);
graphics.blit(RenderType::vignette, this.textureId, 0, 0, 0.0F, 0.0F, graphics.guiWidth(), graphics.guiHeight(), graphics.guiWidth(), graphics.guiHeight(), color);
RenderSystem.setShaderColor(fade, fade, fade, 1.0F);
graphics.blit(this.textureId, 0, 0, -90, 0.0F, 0.0F, graphics.guiWidth(), graphics.guiHeight(), graphics.guiWidth(), graphics.guiHeight());
RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/resources/ok_zoomer.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"common.EditBoxMixin",
"common.GameRendererMixin",
"common.GuiMixin",
"common.MouseHandlerMixin",
"common.RenderStateShardMixin"
"common.MouseHandlerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
5 changes: 3 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {

repositories {
maven { url = 'https://maven.terraformersmc.com/releases' }
maven { url = 'https://maven.ladysnake.org/releases' }
}

base.archivesName = 'ok_zoomer-fabric'
Expand All @@ -26,8 +27,8 @@ dependencies {

modCompileOnly libs.wrench.wrapper

//modCompileOnly libs.bundles.trinkets
//modLocalRuntime libs.bundles.trinkets
modCompileOnly libs.bundles.trinkets
modLocalRuntime libs.bundles.trinkets

include libs.wrench.wrapper
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.ennuil.ok_zoomer;

import io.github.ennuil.ok_zoomer.compat.TrinketsCompat;
import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager;
import io.github.ennuil.ok_zoomer.events.*;
import io.github.ennuil.ok_zoomer.key_binds.ZoomKeyBinds;
Expand All @@ -9,6 +10,7 @@
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.loader.api.FabricLoader;

// This class is responsible for registering the commands and packets
public class OkZoomerClientMod implements ClientModInitializer {
Expand All @@ -34,11 +36,9 @@ public void onInitializeClient() {

FabricZoomUtils.addInitialPredicates();

/*
// mod compat
// Mod compat
if (FabricLoader.getInstance().isModLoaded("trinkets")) {
TrinketsCompat.init();
}
*/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.github.ennuil.ok_zoomer.compat;

import dev.emi.trinkets.api.TrinketsApi;
import io.github.ennuil.ok_zoomer.utils.FabricZoomUtils;
import io.github.ennuil.ok_zoomer.utils.ZoomUtils;

public class TrinketsCompat {
public static void init() {
ZoomUtils.addSpyglassProvider(player -> {
// Trinkets inventory is an AutoSyncedComponent and therefore safe to query on the client
return player.getComponent(TrinketsApi.TRINKET_COMPONENT).isEquipped(FabricZoomUtils.IS_VALID_SPYGLASS);
});
}
}
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"depends": {
"fabricloader": ">=0.16.7",
"minecraft": ">=1.21.2 <1.22",
"minecraft": ">=1.21.0 <1.21.2",
"fabric-api": ">=0.106.0"
},
"custom": {
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# The latest versions are available at https://quiltmc.org/en/usage/latest-versions/
[versions]
minecraft = "1.21.3"
minecraft = "1.21.1"

parchment_minecraft = "1.21"
parchment_mappings = "2024.07.28"

quilt_loom = "1.8.5"
quilt_loader = "0.27.0-beta.1"
moddevgradle = "2.0.42-beta"
neoforge = "21.3.10-beta"
neoforge = "21.1.74"

fabric_api = "0.107.0+1.21.3"
fabric_api = "0.107.0+1.21.1"
wrench_wrapper = "0.6.0"

modmenu = "12.0.0-beta.1"
modmenu = "11.0.3"
trinkets = "3.10.0"
cca = "6.1.1"

Expand Down
12 changes: 10 additions & 2 deletions norge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@ Adds a highly configurable zoom key. By default, this mod provides its own take
[[dependencies.ok_zoomer]]
modId = "neoforge"
type = "required"
versionRange = "[21.2.0-beta,)"
versionRange = "[21.1.0,21.2.0)"
ordering = "NONE"
side = "CLIENT"

[[dependencies.ok_zoomer]]
modId = "minecraft"
type = "required"
versionRange = "[1.21.2,1.22)"
versionRange = "[1.21.0,1.21.2)"
ordering = "NONE"
side = "CLIENT"

[[dependencies.ok_zoomer]]
modId = "okzoomer"
type = "incompatible"
reason = "The mod \"okzoomer-neoforge\", a now-redundant port of Ok Zoomer, causes interference with the official Ok Zoomer's zoom. This causes issues on the proper functioning of the zoom when both are used. Please remove one of the zoom mod JARs to proceed."
versionRange = "*"
ordering = "NONE"
side = "BOTH"

[mc-publish]
modrinth = "${modrinth_id}"
curseforge = "${curseforge_id}"
Expand Down

0 comments on commit 55b94d8

Please sign in to comment.