From e942e5e9e2978ff12b775a075448eb5d6d85c149 Mon Sep 17 00:00:00 2001 From: Ennui Langeweile <85590273+EnnuiL@users.noreply.github.com> Date: Wed, 16 Oct 2024 20:22:06 -0300 Subject: [PATCH] Prepare for 10.0.0-beta.3! --- gradle/libs.versions.toml | 2 +- .../ennuil/ok_zoomer/OkZoomerClientMod.java | 4 - .../commands/OkZoomerCommandScreen.java | 95 -------- .../ok_zoomer/compat/TrinketsCompat.java | 1 - .../ennuil/ok_zoomer/config/ConfigEnums.java | 56 +---- .../config/screen/OkZoomerConfigScreen.java | 8 +- .../events/ManageExtraKeysEvent.java | 1 - .../ok_zoomer/events/ManageZoomEvent.java | 11 +- .../ok_zoomer/events/OpenScreenEvent.java | 4 +- .../ok_zoomer/mixin/common/GuiMixin.java | 48 +++- .../mixin/fabric/MouseHandlerMixin.java | 2 + .../ennuil/ok_zoomer/packets/ZoomPackets.java | 225 ------------------ .../payloads/AcknowledgeModPacket.java | 46 ---- .../packets/payloads/DisableZoomPacket.java | 36 --- .../payloads/DisableZoomScrollingPacket.java | 36 --- .../payloads/ForceClassicModePacket.java | 36 --- .../payloads/ForceSpyglassOverlayPacket.java | 35 --- .../packets/payloads/ForceSpyglassPacket.java | 36 --- .../payloads/ForceZoomDivisorPacket.java | 42 ---- .../ennuil/ok_zoomer/utils/ZoomUtils.java | 10 - .../assets/ok_zoomer/lang/en_us.json | 14 +- .../assets/ok_zoomer/lang/pt_br.json | 18 +- .../assets/ok_zoomer/lang/zh_cn.json | 10 - .../assets/ok_zoomer/lang/zh_tw.json | 10 - 24 files changed, 78 insertions(+), 708 deletions(-) delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/commands/OkZoomerCommandScreen.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/ZoomPackets.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/AcknowledgeModPacket.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomPacket.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomScrollingPacket.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceClassicModePacket.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassOverlayPacket.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassPacket.java delete mode 100644 src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceZoomDivisorPacket.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f1985f8..55916e8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ parchment = "2024.07.28" quilt_loom = "1.7.4" quilt_loader = "0.26.4" -fabric_api = "0.105.0+1.21.1" +fabric_api = "0.106.0+1.21.1" wrench_wrapper = "0.5.0" modmenu = "11.0.3" diff --git a/src/main/java/io/github/ennuil/ok_zoomer/OkZoomerClientMod.java b/src/main/java/io/github/ennuil/ok_zoomer/OkZoomerClientMod.java index ecf0a8a..2b15917 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/OkZoomerClientMod.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/OkZoomerClientMod.java @@ -4,7 +4,6 @@ import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; import io.github.ennuil.ok_zoomer.events.*; import io.github.ennuil.ok_zoomer.key_binds.ZoomKeyBinds; -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; @@ -27,9 +26,6 @@ public void onInitializeClient() { KeyBindingHelper.registerKeyBinding(ZoomKeyBinds.RESET_ZOOM_KEY); } - // Register the zoom-controlling packets - ZoomPackets.registerPackets(); - // Register events without entrypoints aughhhhhhhh ClientTickEvents.START_CLIENT_TICK.register(ManageZoomEvent::startClientTick); ClientTickEvents.START_CLIENT_TICK.register(ManageExtraKeysEvent::startClientTick); diff --git a/src/main/java/io/github/ennuil/ok_zoomer/commands/OkZoomerCommandScreen.java b/src/main/java/io/github/ennuil/ok_zoomer/commands/OkZoomerCommandScreen.java deleted file mode 100644 index a0c1130..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/commands/OkZoomerCommandScreen.java +++ /dev/null @@ -1,95 +0,0 @@ -package io.github.ennuil.ok_zoomer.commands; - -import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; -import io.github.ennuil.ok_zoomer.config.screen.OkZoomerConfigScreen; -import io.github.ennuil.ok_zoomer.config.screen.components.OkZoomerAbstractSelectionList; -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.layouts.HeaderAndFooterLayout; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.CommonComponents; -import net.minecraft.network.chat.Component; - -public class OkZoomerCommandScreen extends Screen { - private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this); - private OkZoomerAbstractSelectionList entryListWidget; - - public OkZoomerCommandScreen() { - super(Component.translatable("command.ok_zoomer.title")); - } - - @Override - protected void init() { - this.entryListWidget = new OkZoomerAbstractSelectionList(this.minecraft, this.width, this.height - 64, 32); - this.entryListWidget.addButton( - Button.builder( - Component.translatable("command.ok_zoomer.config"), - button -> this.minecraft.setScreen(new OkZoomerConfigScreen(this)) - ) - .build() - ); - this.entryListWidget.addCategory(Component.translatable("command.ok_zoomer.restrictions")); - - if (ZoomPackets.hasRestrictions()) { - this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.acknowledgement")); - } - - if (ZoomPackets.shouldDisableZoom()) { - this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.disable_zoom")); - } - - if (ZoomPackets.shouldDisableZoomScrolling()) { - this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.disable_zoom_scrolling")); - } - - if (ZoomPackets.shouldForceClassicMode()) { - this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.force_classic_mode")); - } - - if (ZoomPackets.shouldForceZoomDivisors()) { - double minimumZoomDivisor = ZoomPackets.getMinimumZoomDivisor(); - double maximumZoomDivisor = ZoomPackets.getMaximumZoomDivisor(); - this.entryListWidget.addServerEffectEntry(minimumZoomDivisor != maximumZoomDivisor - ? Component.translatable("command.ok_zoomer.restrictions.force_zoom_divisors", minimumZoomDivisor, maximumZoomDivisor) - : Component.translatable("command.ok_zoomer.restrictions.force_zoom_divisor", minimumZoomDivisor)); - } - - if (ZoomPackets.shouldForceSpyglassMode()) { - var text = switch (OkZoomerConfigManager.CONFIG.features.spyglassMode.value()) { - case REQUIRE_ITEM -> Component.translatable("command.ok_zoomer.restrictions.force_spyglass.require_item"); - case REPLACE_ZOOM -> Component.translatable("command.ok_zoomer.restrictions.force_spyglass.replace_zoom"); - case BOTH -> Component.translatable("command.ok_zoomer.restrictions.force_spyglass.both"); - default -> CommonComponents.EMPTY; - }; - this.entryListWidget.addServerEffectEntry(text); - } - - if (ZoomPackets.shouldForceSpyglassOverlay()) { - this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.force_spyglass_overlay")); - } - - if (!ZoomPackets.hasRestrictions()) { - boolean acknowledged = ZoomPackets.getAcknowledgement().equals(ZoomPackets.Acknowledgement.HAS_NO_RESTRICTIONS); - this.entryListWidget.addServerEffectEntry(Component.translatable(acknowledged - ? "command.ok_zoomer.restrictions.no_restrictions.acknowledged" - : "command.ok_zoomer.restrictions.no_restrictions")); - } - - this.entryListWidget.finish(); - this.addRenderableWidget(this.entryListWidget); - - this.layout.addTitleHeader(this.title, this.font); - this.layout.addToFooter( - Button.builder(CommonComponents.GUI_DONE, button -> this.onClose()) - .bounds(this.width / 2 - 100, this.height - 27, 200, 20) - .build()); - this.layout.visitWidgets(this::addRenderableWidget); - this.layout.arrangeElements(); - } - - @Override - protected void repositionElements() { - this.layout.arrangeElements(); - this.entryListWidget.updateSize(this.width, this.layout); - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/compat/TrinketsCompat.java b/src/main/java/io/github/ennuil/ok_zoomer/compat/TrinketsCompat.java index 936e752..b851901 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/compat/TrinketsCompat.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/compat/TrinketsCompat.java @@ -4,7 +4,6 @@ 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 diff --git a/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java b/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java index 5951619..3017b34 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java @@ -4,79 +4,41 @@ public class ConfigEnums { public enum CinematicCameraOptions implements ConfigEnum { OFF, VANILLA, - MULTIPLIED; - - @Override - public Enum next() { - var enumValues = this.getDeclaringClass().getEnumConstants(); - return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0]; - } + MULTIPLIED } public enum ZoomTransitionOptions implements ConfigEnum { OFF, SMOOTH, - LINEAR; - - @Override - public Enum next() { - var enumValues = this.getDeclaringClass().getEnumConstants(); - return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0]; - } + LINEAR } public enum ZoomModes implements ConfigEnum { HOLD, TOGGLE, - PERSISTENT; - - @Override - public Enum next() { - var enumValues = this.getDeclaringClass().getEnumConstants(); - return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0]; - } + PERSISTENT } public enum ZoomOverlays implements ConfigEnum { OFF, VIGNETTE, - SPYGLASS; - - @Override - public Enum next() { - var enumValues = this.getDeclaringClass().getEnumConstants(); - return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0]; - } + SPYGLASS } public enum SpyglassMode implements ConfigEnum { OFF, REQUIRE_ITEM, REPLACE_ZOOM, - BOTH; - - @Override - public Enum next() { - var enumValues = this.getDeclaringClass().getEnumConstants(); - return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0]; - } + BOTH } public enum ZoomPresets implements ConfigEnum { - DEFAULT, - CLASSIC_ZOOMER, + CAMERA, + COMPETITIVE, CLASSIC, PERSISTENT, - SPYGLASS; - - @Override - public Enum next() { - var enumValues = this.getDeclaringClass().getEnumConstants(); - return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0]; - } + SPYGLASS } - public interface ConfigEnum { - Enum next(); - } + public interface ConfigEnum {} } diff --git a/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java b/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java index 7d74a84..650278d 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/config/screen/OkZoomerConfigScreen.java @@ -61,7 +61,7 @@ protected void init() { var presetButton = CycleButton.builder(value -> Component.translatable(String.format("config.ok_zoomer.presets.preset.%s", value.toString().toLowerCase(Locale.ROOT)))) .withValues(ConfigEnums.ZoomPresets.values()) .withTooltip(value -> Tooltip.create(Component.translatable(String.format("config.ok_zoomer.presets.preset.%s.tooltip", value.toString().toLowerCase(Locale.ROOT))))) - .withInitialValue(ConfigEnums.ZoomPresets.DEFAULT) + .withInitialValue(ConfigEnums.ZoomPresets.CAMERA) .create(0, 0, 150, 20, Component.translatable("config.ok_zoomer.presets.preset")); var resetButton = Button.builder( @@ -266,7 +266,7 @@ public void resetToPreset(ConfigEnums.ZoomPresets preset) { Map.entry(OkZoomerConfigManager.CONFIG.features.reduceSensitivity, preset != ConfigEnums.ZoomPresets.CLASSIC), Map.entry(OkZoomerConfigManager.CONFIG.features.zoomTransition, preset == ConfigEnums.ZoomPresets.CLASSIC ? ConfigEnums.ZoomTransitionOptions.OFF : ConfigEnums.ZoomTransitionOptions.SMOOTH), Map.entry(OkZoomerConfigManager.CONFIG.features.reduceViewBobbing, switch (preset) { - case CLASSIC, CLASSIC_ZOOMER, SPYGLASS -> false; + case CLASSIC, COMPETITIVE, SPYGLASS -> false; default -> true; }), Map.entry(OkZoomerConfigManager.CONFIG.features.zoomMode, preset == ConfigEnums.ZoomPresets.PERSISTENT ? ConfigEnums.ZoomModes.PERSISTENT : ConfigEnums.ZoomModes.HOLD), @@ -274,7 +274,7 @@ public void resetToPreset(ConfigEnums.ZoomPresets preset) { case CLASSIC, SPYGLASS -> false; default -> true; }), - Map.entry(OkZoomerConfigManager.CONFIG.features.persistentInterface, preset != ConfigEnums.ZoomPresets.DEFAULT), + Map.entry(OkZoomerConfigManager.CONFIG.features.persistentInterface, preset != ConfigEnums.ZoomPresets.CAMERA), Map.entry(OkZoomerConfigManager.CONFIG.features.extraKeyBinds, preset != ConfigEnums.ZoomPresets.CLASSIC), Map.entry(OkZoomerConfigManager.CONFIG.features.zoomOverlay, preset == ConfigEnums.ZoomPresets.SPYGLASS ? ConfigEnums.ZoomOverlays.SPYGLASS : ConfigEnums.ZoomOverlays.OFF), Map.entry(OkZoomerConfigManager.CONFIG.features.spyglassMode, preset == ConfigEnums.ZoomPresets.SPYGLASS ? ConfigEnums.SpyglassMode.BOTH : ConfigEnums.SpyglassMode.OFF), @@ -300,7 +300,7 @@ public void resetToPreset(ConfigEnums.ZoomPresets preset) { Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.minimumLinearStep, 0.16), Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.maximumLinearStep, 0.22), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.resetZoomWithMouse, preset != ConfigEnums.ZoomPresets.CLASSIC), - Map.entry(OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, preset == ConfigEnums.ZoomPresets.DEFAULT), + Map.entry(OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, preset == ConfigEnums.ZoomPresets.CAMERA), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.forgetZoomDivisor, true), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.unbindConflictingKey, false), Map.entry(OkZoomerConfigManager.CONFIG.tweaks.useSpyglassSounds, preset == ConfigEnums.ZoomPresets.SPYGLASS), diff --git a/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java b/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java index 24a4153..4167fa6 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/events/ManageExtraKeysEvent.java @@ -10,7 +10,6 @@ public class ManageExtraKeysEvent { public static void startClientTick(Minecraft minecraft) { if (!ZoomKeyBinds.areExtraKeyBindsEnabled()) return; if (!OkZoomerConfigManager.CONFIG.features.extraKeyBinds.value()) return; - if (OkZoomerConfigManager.CONFIG.features.zoomScrolling.isBeingOverridden()) return; if (ZoomKeyBinds.DECREASE_ZOOM_KEY.isDown() && !ZoomKeyBinds.INCREASE_ZOOM_KEY.isDown()) { ZoomUtils.changeZoomDivisor(false); diff --git a/src/main/java/io/github/ennuil/ok_zoomer/events/ManageZoomEvent.java b/src/main/java/io/github/ennuil/ok_zoomer/events/ManageZoomEvent.java index 00496bb..db5e644 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/events/ManageZoomEvent.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/events/ManageZoomEvent.java @@ -1,11 +1,10 @@ package io.github.ennuil.ok_zoomer.events; -import io.github.ennuil.ok_zoomer.zoom.Zoom; import io.github.ennuil.ok_zoomer.config.ConfigEnums.ZoomModes; import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; import io.github.ennuil.ok_zoomer.key_binds.ZoomKeyBinds; -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; import io.github.ennuil.ok_zoomer.utils.ZoomUtils; +import io.github.ennuil.ok_zoomer.zoom.Zoom; import net.minecraft.client.Minecraft; import net.minecraft.sounds.SoundEvents; @@ -22,11 +21,13 @@ public static void startClientTick(Minecraft minecraft) { if (minecraft.player == null) return; // If zoom is disabled, do not allow for zooming at all - boolean disableZoom = ZoomPackets.shouldDisableZoom() || - (switch (OkZoomerConfigManager.CONFIG.features.spyglassMode.value()) { + /* If you want to reimplement mandatory spyglass control? It's easy: + * Quilt Config has value overrides, use them. This mod is ARR but it's anti-vulture; + * You can make a third-party addon mod, I won't bite. */ + boolean disableZoom = switch (OkZoomerConfigManager.CONFIG.features.spyglassMode.value()) { case REQUIRE_ITEM, BOTH -> true; default -> false; - } && !ZoomUtils.hasSpyglass(minecraft.player)); + } && !ZoomUtils.hasSpyglass(minecraft.player); if (disableZoom) { Zoom.setZooming(false); diff --git a/src/main/java/io/github/ennuil/ok_zoomer/events/OpenScreenEvent.java b/src/main/java/io/github/ennuil/ok_zoomer/events/OpenScreenEvent.java index ee94586..509e8fb 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/events/OpenScreenEvent.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/events/OpenScreenEvent.java @@ -1,13 +1,13 @@ package io.github.ennuil.ok_zoomer.events; -import io.github.ennuil.ok_zoomer.commands.OkZoomerCommandScreen; +import io.github.ennuil.ok_zoomer.config.screen.OkZoomerConfigScreen; import io.github.ennuil.ok_zoomer.utils.ZoomUtils; import net.minecraft.client.Minecraft; public class OpenScreenEvent { public static void endClientTick(Minecraft minecraft) { if (ZoomUtils.shouldOpenCommandScreen()) { - minecraft.setScreen(new OkZoomerCommandScreen()); + minecraft.setScreen(new OkZoomerConfigScreen(minecraft.screen)); ZoomUtils.setOpenCommandScreen(false); } } diff --git a/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java b/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java index 676dcf5..d1ee163 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/GuiMixin.java @@ -3,6 +3,8 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +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; @@ -11,7 +13,10 @@ import net.minecraft.client.DeltaTracker; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.DebugScreenOverlay; +import org.joml.Vector3f; import org.quiltmc.loader.api.minecraft.ClientOnly; +import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -25,6 +30,12 @@ public abstract class GuiMixin { @Unique private boolean hideCrossbar = false; + @Unique + private double translation = 0.0; + + @Unique + private float scale = 0.0F; + @Shadow protected abstract void renderCrosshair(GuiGraphics guiGraphics, DeltaTracker deltaTracker); @@ -82,11 +93,11 @@ private void zoomGui(GuiGraphics graphics, DeltaTracker deltaTracker, Operation< hideCrossbar = true; } double fov = Zoom.getTransitionMode().applyZoom(1.0F, deltaTracker.getGameTimeDeltaPartialTick(true)); - float divisor = (float) (1.0D / fov); - double translation = 2.0D / ((1.0D / fov) - 1); + translation = 2.0D / ((1.0D / fov) - 1); + scale = (float) (1.0D / fov); graphics.pose().pushPose(); - graphics.pose().translate(-(graphics.guiWidth() / (translation)), -(graphics.guiHeight() / (translation)), 0.0F); - graphics.pose().scale(divisor, divisor, divisor); + graphics.pose().translate(-(graphics.guiWidth() / translation), -(graphics.guiHeight() / translation), 0.0F); + graphics.pose().scale(scale, scale, 1.0F); original.call(graphics, deltaTracker); graphics.pose().popPose(); } @@ -107,4 +118,33 @@ private void hideCrosshair(GuiGraphics graphics, DeltaTracker deltaTracker, Oper hideCrossbar = false; } } + + // TODO - This is a very promising method to get individual HUDs persistent, but I'm not sure if it's bulletproof! + // It doesn't crash with Sodium nor ImmediatelyFast though, and that's good + @WrapOperation( + method = { + "method_55807", + "lambda$new$6" // Heck yeah! It's Neo-specific hack time! + }, + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/gui/components/DebugScreenOverlay;render(Lnet/minecraft/client/gui/GuiGraphics;)V" + ), + allow = 1 + ) + private void ensureDebugHudVisibility(DebugScreenOverlay instance, GuiGraphics graphics, Operation original, @Local(argsOnly = true) DeltaTracker deltaTracker) { + if (OkZoomerConfigManager.CONFIG.features.persistentInterface.value() || !Zoom.getTransitionMode().getActive()) { + original.call(instance, graphics); + } else { + var lastPose = graphics.pose().last().pose(); + graphics.pose().popPose(); + graphics.pose().popPose(); + graphics.pose().pushPose(); + graphics.pose().translate(0.0F, 0.0F, lastPose.getTranslation(new Vector3f()).z); + original.call(instance, graphics); + graphics.pose().pushPose(); + graphics.pose().translate(-(graphics.guiWidth() / translation), -(graphics.guiHeight() / translation), 0.0F); + graphics.pose().scale(scale, scale, 1.0F); + } + } } diff --git a/src/main/java/io/github/ennuil/ok_zoomer/mixin/fabric/MouseHandlerMixin.java b/src/main/java/io/github/ennuil/ok_zoomer/mixin/fabric/MouseHandlerMixin.java index ad037e9..8dbabc8 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/mixin/fabric/MouseHandlerMixin.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/mixin/fabric/MouseHandlerMixin.java @@ -4,11 +4,13 @@ import com.llamalad7.mixinextras.sugar.ref.LocalDoubleRef; import io.github.ennuil.ok_zoomer.zoom.Zoom; import net.minecraft.client.MouseHandler; +import org.quiltmc.loader.api.minecraft.ClientOnly; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +@ClientOnly @Mixin(MouseHandler.class) public abstract class MouseHandlerMixin { @Inject( diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/ZoomPackets.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/ZoomPackets.java deleted file mode 100644 index 1191317..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/ZoomPackets.java +++ /dev/null @@ -1,225 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets; - -import io.github.ennuil.ok_zoomer.config.ConfigEnums; -import io.github.ennuil.ok_zoomer.config.ConfigEnums.CinematicCameraOptions; -import io.github.ennuil.ok_zoomer.config.ConfigEnums.SpyglassMode; -import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; -import io.github.ennuil.ok_zoomer.packets.payloads.*; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.toasts.SystemToast; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; - -/* Manages the zoom packets and their signals. - These packets are intended to be used by the future "Zoomer Boomer" server-side mod, - although developers are welcome to independently transmit them for other loaders */ -public class ZoomPackets { - public static void applyDisableZooming() { - disableZoom = true; - } - - public enum Acknowledgement { - NONE, - HAS_RESTRICTIONS, - HAS_NO_RESTRICTIONS - } - - // The signals used by other parts of the zoom in order to enforce the packets - private static boolean hasRestrictions = false; - private static boolean disableZoom = false; - private static boolean disableZoomScrolling = false; - private static boolean forceClassicMode = false; - private static boolean forceZoomDivisors = false; - private static Acknowledgement acknowledgement = Acknowledgement.NONE; - private static double maximumZoomDivisor = 0.0D; - private static double minimumZoomDivisor = 0.0D; - private static boolean forceSpyglassMode = false; - private static boolean forceSpyglassOverlay = false; - - private static final Component TOAST_TITLE = Component.translatable("toast.ok_zoomer.title"); - - public static void sendToast(Component description) { - ZoomPackets.sendToast(Minecraft.getInstance(), description); - } - - public static void sendToast(Minecraft minecraft, Component description) { - if (OkZoomerConfigManager.CONFIG.tweaks.showRestrictionToasts.value()) { - minecraft.getToasts().addToast(SystemToast.multiline(minecraft, ZoomUtils.TOAST_ID, TOAST_TITLE, description)); - } - } - - private static void registerConfigurationPacket(CustomPacketPayload.Type type, StreamCodec streamCodec, ClientConfigurationNetworking.ConfigurationPayloadHandler handler) { - PayloadTypeRegistry.configurationS2C().register(type, streamCodec); - ClientConfigurationNetworking.registerGlobalReceiver(type, handler); - } - - //Registers all the packets - public static void registerPackets() { - /* The "Disable Zoom" packet, - If this packet is received, Ok Zoomer's zoom will be disabled completely while in the server - Supported since Ok Zoomer 4.0.0 (1.16) - Arguments: None */ - registerConfigurationPacket(DisableZoomPacket.TYPE, DisableZoomPacket.STREAM_CODEC, DisableZoomPacket::handle); - - /* The "Disable Zoom Scrolling" packet, - If this packet is received, zoom scrolling will be disabled while in the server - Supported since Ok Zoomer 4.0.0 (1.16) - Arguments: None */ - registerConfigurationPacket(DisableZoomScrollingPacket.TYPE, DisableZoomScrollingPacket.STREAM_CODEC, DisableZoomScrollingPacket::handle); - - /* The "Force Classic Mode" packet, - If this packet is received, the Classic Mode will be activated while connected to the server, - under the Classic mode, the Classic preset will be forced on all non-cosmetic options - Supported since Ok Zoomer 5.0.0-beta.1 (1.17) - Arguments: None */ - registerConfigurationPacket(ForceClassicModePacket.TYPE, ForceClassicModePacket.STREAM_CODEC, ForceClassicModePacket::handle); - - /* The "Force Zoom Divisor" packet, - If this packet is received, the minimum and maximum zoom divisor values will be overriden - with the provided arguments - Supported since Ok Zoomer 5.0.0-beta.2 (1.17) - Arguments: One double (max & min) or two doubles (first is max, second is min) */ - registerConfigurationPacket(ForceZoomDivisorPacket.TYPE, ForceZoomDivisorPacket.STREAM_CODEC, ForceZoomDivisorPacket::handle); - - /* The "Acknowledge Mod" packet, - If received, a toast will appear, the toast will either state that - the server won't restrict the mod or say that the server controls will be activated - Supported since Ok Zoomer 5.0.0-beta.2 (1.17) - Arguments: one boolean, false for restricting, true for restrictionless */ - registerConfigurationPacket(AcknowledgeModPacket.TYPE, AcknowledgeModPacket.STREAM_CODEC, AcknowledgeModPacket::handle); - - /* The "Force Spyglass" packet, - This packet lets the server to impose a spyglass restriction - Supported since Ok Zoomer 5.0.0-beta.4 (1.18.2) - Arguments: 2 booleans: requireItem and replaceZoom */ - registerConfigurationPacket(ForceSpyglassPacket.TYPE, ForceSpyglassPacket.STREAM_CODEC, ForceSpyglassPacket::handle); - - /* The "Force Spyglass Overlay" packet, - This packet will let the server restrict the mod to spyglass-only usage - Not supported yet! - Arguments: None */ - registerConfigurationPacket(ForceSpyglassOverlayPacket.TYPE, ForceSpyglassOverlayPacket.STREAM_CODEC, ForceSpyglassOverlayPacket::handle); - - ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { - if (ZoomPackets.hasRestrictions) { - ZoomPackets.resetPacketSignals(); - } - }); - } - - public static boolean hasRestrictions() { - return hasRestrictions; - } - - public static void checkRestrictions() { - boolean hasRestrictions = disableZoom - || disableZoomScrolling - || forceClassicMode - || forceZoomDivisors - || forceSpyglassMode - || forceSpyglassOverlay; - - ZoomPackets.hasRestrictions = hasRestrictions; - if (hasRestrictions) { - ZoomPackets.acknowledgement = Acknowledgement.HAS_RESTRICTIONS; - } else { - ZoomPackets.acknowledgement = Acknowledgement.HAS_NO_RESTRICTIONS; - } - } - - public static boolean shouldDisableZoom() { - return disableZoom; - } - - public static boolean shouldDisableZoomScrolling() { - return disableZoomScrolling; - } - - public static boolean shouldForceClassicMode() { - return forceClassicMode; - } - - public static boolean shouldForceZoomDivisors() { - return forceZoomDivisors; - } - - public static Acknowledgement getAcknowledgement() { - return acknowledgement; - } - - public static double getMaximumZoomDivisor() { - return maximumZoomDivisor; - } - - public static double getMinimumZoomDivisor() { - return minimumZoomDivisor; - } - - public static boolean shouldForceSpyglassMode() { - return forceSpyglassMode; - } - - public static boolean shouldForceSpyglassOverlay() { - return forceSpyglassOverlay; - } - - public static void applyDisableZoomScrolling() { - disableZoomScrolling = true; - OkZoomerConfigManager.CONFIG.features.zoomScrolling.setOverride(false); - OkZoomerConfigManager.CONFIG.features.extraKeyBinds.setOverride(false); - } - - public static void applyClassicMode() { - forceClassicMode = true; - ZoomPackets.applyDisableZoomScrolling(); - OkZoomerConfigManager.CONFIG.features.cinematicCamera.setOverride(CinematicCameraOptions.VANILLA); - OkZoomerConfigManager.CONFIG.features.reduceSensitivity.setOverride(false); - OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor.setOverride(4.0D); - OkZoomerConfigManager.configureZoomInstance(); - } - - public static void applyForcedZoomDivisor(double max, double min) { - maximumZoomDivisor = max; - minimumZoomDivisor = min; - forceZoomDivisors = true; - } - - public static void applySpyglassDependency(boolean requireItem, boolean replaceZoom) { - OkZoomerConfigManager.CONFIG.features.spyglassMode.setOverride(requireItem - ? (replaceZoom ? SpyglassMode.BOTH : SpyglassMode.REQUIRE_ITEM) - : (replaceZoom ? SpyglassMode.REPLACE_ZOOM : null)); - forceSpyglassMode = true; - } - - public static void applyForceSpyglassOverlay() { - OkZoomerConfigManager.CONFIG.features.zoomOverlay.setOverride(ConfigEnums.ZoomOverlays.SPYGLASS); - forceSpyglassOverlay = true; - } - - //The method used to reset the signals once left the server. - private static void resetPacketSignals() { - ZoomPackets.hasRestrictions = false; - ZoomPackets.disableZoom = false; - ZoomPackets.disableZoomScrolling = false; - OkZoomerConfigManager.CONFIG.features.zoomScrolling.removeOverride(); - OkZoomerConfigManager.CONFIG.features.extraKeyBinds.removeOverride(); - ZoomPackets.forceClassicMode = false; - OkZoomerConfigManager.CONFIG.features.cinematicCamera.removeOverride(); - OkZoomerConfigManager.CONFIG.features.reduceSensitivity.removeOverride(); - OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor.removeOverride(); - ZoomPackets.forceZoomDivisors = false; - ZoomPackets.maximumZoomDivisor = 0.0D; - ZoomPackets.minimumZoomDivisor = 0.0D; - ZoomPackets.acknowledgement = Acknowledgement.NONE; - ZoomPackets.forceSpyglassMode = false; - OkZoomerConfigManager.CONFIG.features.spyglassMode.removeOverride(); - ZoomPackets.forceSpyglassOverlay = false; - OkZoomerConfigManager.CONFIG.features.zoomScrolling.removeOverride(); - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/AcknowledgeModPacket.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/AcknowledgeModPacket.java deleted file mode 100644 index 565c37b..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/AcknowledgeModPacket.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets.payloads; - -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import org.jetbrains.annotations.NotNull; -import org.quiltmc.loader.api.minecraft.ClientOnly; - -public record AcknowledgeModPacket(boolean unrestricted) implements CustomPacketPayload { - public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(AcknowledgeModPacket::write, AcknowledgeModPacket::new); - public static final CustomPacketPayload.Type TYPE = new Type<>(ModUtils.id("acknowledge_mod")); - - public AcknowledgeModPacket(FriendlyByteBuf buffer) { - this(buffer.readBoolean()); - } - - @Override - public @NotNull Type type() { - return TYPE; - } - - public void write(FriendlyByteBuf buffer) { - buffer.writeBoolean(this.unrestricted()); - } - - @ClientOnly - public static void handle(AcknowledgeModPacket payload, ClientConfigurationNetworking.Context context) { - ZoomPackets.checkRestrictions(); - if (payload.unrestricted()) { - if (ZoomPackets.getAcknowledgement().equals(ZoomPackets.Acknowledgement.HAS_NO_RESTRICTIONS)) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server acknowledges the mod and establishes no restrictions"); - ZoomPackets.sendToast(Component.translatable("toast.ok_zoomer.acknowledge_mod")); - } - } else { - if (ZoomPackets.getAcknowledgement().equals(ZoomPackets.Acknowledgement.HAS_RESTRICTIONS)) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server acknowledges the mod and has established some restrictions"); - ZoomPackets.sendToast(Component.translatable("toast.ok_zoomer.acknowledge_mod_restrictions")); - } - } - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomPacket.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomPacket.java deleted file mode 100644 index 27e0ecd..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomPacket.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets.payloads; - -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import org.jetbrains.annotations.NotNull; -import org.quiltmc.loader.api.minecraft.ClientOnly; - -public record DisableZoomPacket() implements CustomPacketPayload { - public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(DisableZoomPacket::write, DisableZoomPacket::new); - public static final CustomPacketPayload.Type TYPE = new Type<>(ModUtils.id(("disable_zoom"))); - - public DisableZoomPacket(FriendlyByteBuf buf) { - this(); - } - - @Override - public @NotNull Type type() { - return TYPE; - } - - public void write(FriendlyByteBuf buffer) { - // NO-OP - } - - @ClientOnly - public static void handle(DisableZoomPacket payload, ClientConfigurationNetworking.Context context) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server has disabled zooming"); - ZoomPackets.applyDisableZooming(); - ZoomPackets.checkRestrictions(); - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomScrollingPacket.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomScrollingPacket.java deleted file mode 100644 index 8e3b5d6..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/DisableZoomScrollingPacket.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets.payloads; - -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import org.jetbrains.annotations.NotNull; -import org.quiltmc.loader.api.minecraft.ClientOnly; - -public record DisableZoomScrollingPacket() implements CustomPacketPayload { - public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(DisableZoomScrollingPacket::write, DisableZoomScrollingPacket::new); - public static final CustomPacketPayload.Type TYPE = new Type<>(ModUtils.id("disable_zoom_scrolling")); - - public DisableZoomScrollingPacket(FriendlyByteBuf buf) { - this(); - } - - @Override - public @NotNull Type type() { - return TYPE; - } - - public void write(FriendlyByteBuf buffer) { - throw new UnsupportedOperationException("Packet is read-only"); - } - - @ClientOnly - public static void handle(DisableZoomScrollingPacket payload, ClientConfigurationNetworking.Context context) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server has disabled zoom scrolling"); - ZoomPackets.applyDisableZoomScrolling(); - ZoomPackets.checkRestrictions(); - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceClassicModePacket.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceClassicModePacket.java deleted file mode 100644 index 02e5a38..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceClassicModePacket.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets.payloads; - -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import org.jetbrains.annotations.NotNull; -import org.quiltmc.loader.api.minecraft.ClientOnly; - -public record ForceClassicModePacket() implements CustomPacketPayload { - public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ForceClassicModePacket::write, ForceClassicModePacket::new); - public static final CustomPacketPayload.Type TYPE = new Type<>(ModUtils.id("force_classic_mode")); - - public ForceClassicModePacket(FriendlyByteBuf buf) { - this(); - } - - @Override - public @NotNull Type type() { - return TYPE; - } - - public void write(FriendlyByteBuf buffer) { - // NO-OP - } - - @ClientOnly - public static void handle(ForceClassicModePacket payload, ClientConfigurationNetworking.Context context) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server has imposed classic mode"); - ZoomPackets.applyClassicMode(); - ZoomPackets.checkRestrictions(); - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassOverlayPacket.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassOverlayPacket.java deleted file mode 100644 index 01014c4..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassOverlayPacket.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets.payloads; - -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import org.quiltmc.loader.api.minecraft.ClientOnly; - -public record ForceSpyglassOverlayPacket() implements CustomPacketPayload { - public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ForceSpyglassOverlayPacket::write, ForceSpyglassOverlayPacket::new); - public static final CustomPacketPayload.Type TYPE = new Type<>(ModUtils.id("force_spyglass_overlay")); - - public ForceSpyglassOverlayPacket(FriendlyByteBuf buf) { - this(); - } - - @Override - public Type type() { - return TYPE; - } - - public void write(FriendlyByteBuf buffer) { - // NO-OP - } - - @ClientOnly - public static void handle(ForceSpyglassOverlayPacket payload, ClientConfigurationNetworking.Context context) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server has imposed a spyglass overlay on the zoom"); - ZoomPackets.applyForceSpyglassOverlay(); - ZoomPackets.checkRestrictions(); - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassPacket.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassPacket.java deleted file mode 100644 index 2fc101f..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceSpyglassPacket.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets.payloads; - -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import org.quiltmc.loader.api.minecraft.ClientOnly; - -public record ForceSpyglassPacket(boolean requireItem, boolean replaceZoom) implements CustomPacketPayload { - public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ForceSpyglassPacket::write, ForceSpyglassPacket::new); - public static final CustomPacketPayload.Type TYPE = new Type<>(ModUtils.id("force_spyglass")); - - public ForceSpyglassPacket(FriendlyByteBuf buf) { - this(buf.readBoolean(), buf.readBoolean()); - } - - @Override - public Type type() { - return TYPE; - } - - public void write(FriendlyByteBuf buffer) { - buffer.writeBoolean(this.requireItem()); - buffer.writeBoolean(this.replaceZoom()); - } - - @ClientOnly - public static void handle(ForceSpyglassPacket payload, ClientConfigurationNetworking.Context context) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server has the following spyglass restrictions: Require Item: {}, Replace Zoom: {}", payload.requireItem(), payload.replaceZoom()); - ZoomPackets.applySpyglassDependency(payload.requireItem(), payload.replaceZoom()); - ZoomPackets.checkRestrictions(); - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceZoomDivisorPacket.java b/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceZoomDivisorPacket.java deleted file mode 100644 index f2db418..0000000 --- a/src/main/java/io/github/ennuil/ok_zoomer/packets/payloads/ForceZoomDivisorPacket.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.ennuil.ok_zoomer.packets.payloads; - -import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; -import io.github.ennuil.ok_zoomer.utils.ModUtils; -import io.github.ennuil.ok_zoomer.utils.ZoomUtils; -import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import org.quiltmc.loader.api.minecraft.ClientOnly; - -public record ForceZoomDivisorPacket(double max, double min) implements CustomPacketPayload { - public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ForceZoomDivisorPacket::write, ForceZoomDivisorPacket::new); - public static final CustomPacketPayload.Type TYPE = new Type<>(ModUtils.id("force_zoom_divisor")); - - public ForceZoomDivisorPacket(FriendlyByteBuf buf) { - this(buf.readDouble(), buf.readableBytes() >= 8 ? buf.readDouble() : buf.getDouble(0)); - } - - @Override - public Type type() { - return TYPE; - } - - public void write(FriendlyByteBuf buffer) { - buffer.writeDouble(this.max()); - buffer.writeDouble(this.min()); - } - - @ClientOnly - public static void handle(ForceZoomDivisorPacket payload, ClientConfigurationNetworking.Context context) { - if ((payload.min() <= 0.0 || payload.max() <= 0.0) || payload.min() > payload.max()) { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server has attempted to set invalid divisor values! (min {}, max {})", payload.min(), payload.max()); - } else { - ZoomUtils.LOGGER.info("[Ok Zoomer] This server has set the zoom divisors to minimum {} and maximum {}", payload.min(), payload.max()); - ZoomPackets.applyForcedZoomDivisor(payload.max(), payload.min()); - OkZoomerConfigManager.configureZoomInstance(); - ZoomPackets.checkRestrictions(); - } - } -} diff --git a/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java b/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java index 9bced6f..0f4c572 100644 --- a/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java +++ b/src/main/java/io/github/ennuil/ok_zoomer/utils/ZoomUtils.java @@ -4,7 +4,6 @@ import io.github.ennuil.ok_zoomer.zoom.Zoom; import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; import io.github.ennuil.ok_zoomer.key_binds.ZoomKeyBinds; -import io.github.ennuil.ok_zoomer.packets.ZoomPackets; import net.fabricmc.fabric.api.tag.client.v1.ClientTags; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; @@ -41,20 +40,12 @@ public class ZoomUtils { // The method used for changing the zoom divisor, used by zoom scrolling and the key binds public static void changeZoomDivisor(boolean increase) { - //If the zoom is disabled, don't allow for zoom scrolling - if (ZoomPackets.shouldDisableZoom()) return; - double zoomDivisor = OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor.value(); double minimumZoomDivisor = OkZoomerConfigManager.CONFIG.zoomValues.minimumZoomDivisor.value(); double maximumZoomDivisor = OkZoomerConfigManager.CONFIG.zoomValues.maximumZoomDivisor.value(); int upperScrollStep = OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps.value(); int lowerScrollStep = OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps.value(); - if (ZoomPackets.shouldForceZoomDivisors()) { - minimumZoomDivisor = Math.max(minimumZoomDivisor, ZoomPackets.getMinimumZoomDivisor()); - maximumZoomDivisor = Math.min(maximumZoomDivisor, ZoomPackets.getMaximumZoomDivisor()); - } - zoomStep = increase ? Math.min(zoomStep + 1, upperScrollStep) : Math.max(zoomStep - 1, -lowerScrollStep); if (zoomStep > 0) { @@ -68,7 +59,6 @@ public static void changeZoomDivisor(boolean increase) { // The method used by both the "Reset Zoom" keybind and the "Reset Zoom With Mouse" tweak public static void resetZoomDivisor(boolean userPrompted) { - if (userPrompted && ZoomPackets.shouldDisableZoom()) return; if (!userPrompted && !OkZoomerConfigManager.CONFIG.tweaks.forgetZoomDivisor.value()) return; Zoom.resetZoomDivisor(); diff --git a/src/main/resources/assets/ok_zoomer/lang/en_us.json b/src/main/resources/assets/ok_zoomer/lang/en_us.json index f53e948..50f95ca 100644 --- a/src/main/resources/assets/ok_zoomer/lang/en_us.json +++ b/src/main/resources/assets/ok_zoomer/lang/en_us.json @@ -85,10 +85,10 @@ "config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "Prints a random owo in the console when the game starts.", "config.ok_zoomer.presets": "Presets", "config.ok_zoomer.presets.preset": "Preset", - "config.ok_zoomer.presets.preset.default": "Default", - "config.ok_zoomer.presets.preset.default.tooltip": "Reset to the default settings.", - "config.ok_zoomer.presets.preset.classic_zoomer": "Classic Zoomer", - "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "Reset to this mod's old default settings.", + "config.ok_zoomer.presets.preset.camera": "Camera", + "config.ok_zoomer.presets.preset.camera.tooltip": "Reset to the default settings, which prioritizes a clean view.", + "config.ok_zoomer.presets.preset.competitive": "Competitive", + "config.ok_zoomer.presets.preset.competitive.tooltip": "Reset to a preset which prioritizes the game's interface over the view.", "config.ok_zoomer.presets.preset.classic": "Classic", "config.ok_zoomer.presets.preset.classic.tooltip": "Reset to a preset that emulates the OptiFine zoom.", "config.ok_zoomer.presets.preset.persistent": "Persistent", @@ -102,15 +102,9 @@ "command.ok_zoomer.config": "Mod Settings", "command.ok_zoomer.restrictions": "Restrictions", "command.ok_zoomer.restrictions.acknowledgement": "This server has imposed the following restrictions:", - "command.ok_zoomer.restrictions.disable_zoom": "Zooming has been disabled.", - "command.ok_zoomer.restrictions.disable_zoom_scrolling": "Zoom scrolling has been disabled.", - "command.ok_zoomer.restrictions.force_classic_mode": "Classic mode has been enabled.", - "command.ok_zoomer.restrictions.force_zoom_divisors": "Zoom divisors were restricted (minimum: %s, maximum: %s).", - "command.ok_zoomer.restrictions.force_zoom_divisor": "The zoom divisor has been locked to %s.", "command.ok_zoomer.restrictions.force_spyglass.require_item": "This zoom requires a spyglass.", "command.ok_zoomer.restrictions.force_spyglass.replace_zoom": "This zoom replaces the spyglass' zoom.", "command.ok_zoomer.restrictions.force_spyglass.both": "This zoom requires a spyglass but also replaces its zoom.", - "command.ok_zoomer.restrictions.force_spyglass_overlay": "The spyglass overlay has been enabled.", "command.ok_zoomer.restrictions.no_restrictions.acknowledge": "This server allows this mod, therefore it hasn't imposed any restrictions.", "command.ok_zoomer.restrictions.no_restrictions": "This server didn't impose any restrictions.", "toast.ok_zoomer.title": "Ok Zoomer", diff --git a/src/main/resources/assets/ok_zoomer/lang/pt_br.json b/src/main/resources/assets/ok_zoomer/lang/pt_br.json index d883cc5..9b6ac3c 100644 --- a/src/main/resources/assets/ok_zoomer/lang/pt_br.json +++ b/src/main/resources/assets/ok_zoomer/lang/pt_br.json @@ -72,8 +72,8 @@ "config.ok_zoomer.tweaks": "Ajustes", "config.ok_zoomer.tweaks.unbind_conflicting_key": "Corrigir atalho conflitante", "config.ok_zoomer.tweaks.unbind_conflicting_key.tooltip": "Se pressionado, o atalho \"Salvar barra rápida\" será anulada caso tenha conflito com o atalho de zoom.", - "config.ok_zoomer.tweaks.hide_crosshair": "Hide Crosshair", - "config.ok_zoomer.tweaks.hide_crosshair.tooltip": "Hides the crosshair while zooming.", + "config.ok_zoomer.tweaks.hide_crosshair": "Esconder mira", + "config.ok_zoomer.tweaks.hide_crosshair.tooltip": "Esconde a mira durante o zoom.", "config.ok_zoomer.tweaks.reset_zoom_with_mouse": "Reiniciar zoom com mouse", "config.ok_zoomer.tweaks.reset_zoom_with_mouse.tooltip": "Permite reiniciar o zoom com o botão do meio do mouse.", "config.ok_zoomer.tweaks.forget_zoom_divisor": "Esquecer divisor de zoom", @@ -86,10 +86,10 @@ "config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "Imprime um owo aleatório no console quando o jogo iniciar", "config.ok_zoomer.presets": "Predefinições", "config.ok_zoomer.presets.preset": "Predefinição", - "config.ok_zoomer.presets.preset.default": "Padrão", - "config.ok_zoomer.presets.preset.default.tooltip": "Redefine para as definições padrões.", - "config.ok_zoomer.presets.preset.classic_zoomer": "Zoomer clássico", - "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "Redefine para as definições padrões antigas desse mod.", + "config.ok_zoomer.presets.preset.camera": "Câmera", + "config.ok_zoomer.presets.preset.camera.tooltip": "Redefine para as definições padrões, a qual prioriza uma vista limpa.", + "config.ok_zoomer.presets.preset.competitive": "Competitivo", + "config.ok_zoomer.presets.preset.competitive.tooltip": "Redefine para uma predefinição que prioriza a interface do jogo sobre a vista.", "config.ok_zoomer.presets.preset.classic": "Clássica", "config.ok_zoomer.presets.preset.classic.tooltip": "Redefine para uma predefinição que emula o zoom do OptiFine.", "config.ok_zoomer.presets.preset.persistent": "Persistente", @@ -103,15 +103,9 @@ "command.ok_zoomer.config": "Definições do mod", "command.ok_zoomer.restrictions": "Restrições", "command.ok_zoomer.restrictions.acknowledgement": "O servidor impôs as seguintes restrições:", - "command.ok_zoomer.restrictions.disable_zoom": "O zoom foi desativado.", - "command.ok_zoomer.restrictions.disable_zoom_scrolling": "A rolagem de zoom foi desativada.", - "command.ok_zoomer.restrictions.force_classic_mode": "O modo clássico foi ligado.", - "command.ok_zoomer.restrictions.force_zoom_divisors": "Os divisores de zoom foram restringidos (mínimo: %s, máximo: %s).", - "command.ok_zoomer.restrictions.force_zoom_divisor": "O divisor de zoom foi travado no valor %s.", "command.ok_zoomer.restrictions.force_spyglass.require_item": "O zoom requer uma luneta.", "command.ok_zoomer.restrictions.force_spyglass.replace_zoom": "O zoom substitui o zoom da luneta.", "command.ok_zoomer.restrictions.force_spyglass.both": "O zoom requer uma luneta, mas também substitui o zoom da luneta.", - "command.ok_zoomer.restrictions.force_spyglass_overlay": "A sobreposição da luneta foi ativada.", "command.ok_zoomer.restrictions.no_restrictions.acknowledge": "Esse servidor permite o uso desse mod, portanto ele não impôs nenhuma restrição", "command.ok_zoomer.restrictions.no_restrictions": "Esse servidor não impôs quaisquer restrições", "toast.ok_zoomer.title": "Ok Zoomer", diff --git a/src/main/resources/assets/ok_zoomer/lang/zh_cn.json b/src/main/resources/assets/ok_zoomer/lang/zh_cn.json index 2872737..d03d66e 100644 --- a/src/main/resources/assets/ok_zoomer/lang/zh_cn.json +++ b/src/main/resources/assets/ok_zoomer/lang/zh_cn.json @@ -79,10 +79,6 @@ "config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "游戏启动时在控制台中随机打印一个owo。", "config.ok_zoomer.presets": "预设", "config.ok_zoomer.presets.preset": "预设", - "config.ok_zoomer.presets.preset.default": "默认", - "config.ok_zoomer.presets.preset.default.tooltip": "重置为默认设置。", - "config.ok_zoomer.presets.preset.classic_zoomer": "经典缩放器", - "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "重置为旧的默认设置,具有更快的平滑过渡因子。", "config.ok_zoomer.presets.preset.classic": "经典", "config.ok_zoomer.presets.preset.classic.tooltip": "重置为模拟OptiFine缩放的预设。", "config.ok_zoomer.presets.preset.persistent": "持久", @@ -96,15 +92,9 @@ "command.ok_zoomer.config": "模组设置", "command.ok_zoomer.restrictions": "限制", "command.ok_zoomer.restrictions.acknowledgement": "此服务器已施加以下限制:", - "command.ok_zoomer.restrictions.disable_zoom": "缩放已被禁用。", - "command.ok_zoomer.restrictions.disable_zoom_scrolling": "缩放滚动已被禁用。", - "command.ok_zoomer.restrictions.force_classic_mode": "经典模式已被启用。", - "command.ok_zoomer.restrictions.force_zoom_divisors": "缩放倍数被限制(最小:%s,最大:%s)。", - "command.ok_zoomer.restrictions.force_zoom_divisor": "缩放倍数已被锁定为 %s。", "command.ok_zoomer.restrictions.force_spyglass.require_item": "此缩放需要望远镜。", "command.ok_zoomer.restrictions.force_spyglass.replace_zoom": "此缩放替代了望远镜的缩放。", "command.ok_zoomer.restrictions.force_spyglass.both": "此缩放需要望远镜但同时也替代了其缩放。", - "command.ok_zoomer.restrictions.force_spyglass_overlay": "望远镜覆盖层已被启用。", "command.ok_zoomer.restrictions.no_restrictions.acknowledge": "此服务器允许此模组,因此未施加任何限制。", "command.ok_zoomer.restrictions.no_restrictions": "此服务器未施加任何限制。", "toast.ok_zoomer.title": "Ok Zoomer", diff --git a/src/main/resources/assets/ok_zoomer/lang/zh_tw.json b/src/main/resources/assets/ok_zoomer/lang/zh_tw.json index c4d54ff..de0bd74 100644 --- a/src/main/resources/assets/ok_zoomer/lang/zh_tw.json +++ b/src/main/resources/assets/ok_zoomer/lang/zh_tw.json @@ -79,10 +79,6 @@ "config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "遊戲啟動時在主控台中列印一個隨機的 owo。", "config.ok_zoomer.presets": "預設", "config.ok_zoomer.presets.preset": "預設", - "config.ok_zoomer.presets.preset.default": "預設", - "config.ok_zoomer.presets.preset.default.tooltip": "重設為預設設定。", - "config.ok_zoomer.presets.preset.classic_zoomer": "經典縮放器", - "config.ok_zoomer.presets.preset.classic_zoomer.tooltip": "重設為舊的預設設定,具有更快的平滑過渡因子。", "config.ok_zoomer.presets.preset.classic": "經典", "config.ok_zoomer.presets.preset.classic.tooltip": "重設為模擬 OptiFine 縮放的預設。", "config.ok_zoomer.presets.preset.persistent": "持續", @@ -96,15 +92,9 @@ "command.ok_zoomer.config": "模組設定", "command.ok_zoomer.restrictions": "限制", "command.ok_zoomer.restrictions.acknowledgement": "此伺服器已強制執行以下限制:", - "command.ok_zoomer.restrictions.disable_zoom": "縮放已被停用。", - "command.ok_zoomer.restrictions.disable_zoom_scrolling": "縮放捲動已被停用。", - "command.ok_zoomer.restrictions.force_classic_mode": "經典模式已啟用。", - "command.ok_zoomer.restrictions.force_zoom_divisors": "縮放除數受到限制(最小值: %s,最大值: %s)。", - "command.ok_zoomer.restrictions.force_zoom_divisor": "縮放除數已鎖定為 %s。", "command.ok_zoomer.restrictions.force_spyglass.require_item": "此縮放需要望遠鏡。", "command.ok_zoomer.restrictions.force_spyglass.replace_zoom": "此縮放取代望遠鏡的縮放。", "command.ok_zoomer.restrictions.force_spyglass.both": "此縮放需要望遠鏡,但也取代其縮放。", - "command.ok_zoomer.restrictions.force_spyglass_overlay": "望遠鏡覆蓋已啟用。", "command.ok_zoomer.restrictions.no_restrictions.acknowledge": "此伺服器允許此模組,因此它沒有強制執行任何限制。", "command.ok_zoomer.restrictions.no_restrictions": "此伺服器沒有強制執行任何限制。", "toast.ok_zoomer.title": "Ok Zoomer",