Skip to content

Commit

Permalink
Port to Minecraft 1.20.2, 5.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL committed Feb 29, 2024
1 parent f4d251c commit 447753f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true

# Mod Properties
version = 5.0.1
version = 5.0.2
maven_group = io.github.ennuil
archives_base_name = ok_zoomer
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[versions]
# Latest version is available at https://lambdaurora.dev/tools/import_quilt.html
minecraft = "1.20.1"
quilt_mappings = "1.20.1+build.23"
minecraft = "1.20.2"
quilt_mappings = "1.20.2+build.3"
quilt_loader = "0.23.1"

quilted_fabric_api = "7.5.0+0.91.0-1.20.1"
quilted_fabric_api = "8.0.0-alpha.4+0.91.6-1.20.2"
libzoomer = "0.8.0+1.20.1"
mod_menu = "7.2.2"
spruceui = "5.0.2+1.20"
mod_menu = "8.0.1"
spruceui = "5.0.3+1.20.2"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ protected void init() {
);
}

this.addDrawableChild(list);
this.addDrawableChild(new SpruceButtonWidget(Position.of(this, this.width / 2 - 100, this.height - 28), 200, 20, SpruceTexts.GUI_DONE,
this.addDrawableSelectableElement(list);
this.addDrawableSelectableElement(new SpruceButtonWidget(Position.of(this, this.width / 2 - 100, this.height - 28), 200, 20, SpruceTexts.GUI_DONE,
btn -> this.client.setScreen(null)).asVanilla());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ protected void init() {
this.initializeOptionList();
this.appendPresetSection();

this.addDrawableChild(this.list);
this.addDrawableChild(new SpruceButtonWidget(Position.of(this, this.width / 2 - 154, this.height - 28), 150, 20, Text.translatable("config.ok_zoomer.discard_changes"),
this.addDrawableSelectableElement(this.list);
this.addDrawableSelectableElement(new SpruceButtonWidget(Position.of(this, this.width / 2 - 154, this.height - 28), 150, 20, Text.translatable("config.ok_zoomer.discard_changes"),
btn -> {
this.resetNewValues();
this.refresh();
}).asVanilla());
this.addDrawableChild(new SpruceButtonWidget(Position.of(this, this.width / 2 + 4, this.height - 28), 150, 20, SpruceTexts.GUI_DONE,
this.addDrawableSelectableElement(new SpruceButtonWidget(Position.of(this, this.width / 2 + 4, this.height - 28), 150, 20, SpruceTexts.GUI_DONE,
btn -> {
this.newValues.forEach((trackedValue, newValue) -> {
if (trackedValue.value() != null) {
Expand Down Expand Up @@ -301,8 +301,16 @@ public void resetToPreset(ZoomPresets preset) {
}),
Map.entry(OkZoomerConfigManager.CONFIG.values.minimum_zoom_divisor, 1.0D),
Map.entry(OkZoomerConfigManager.CONFIG.values.maximum_zoom_divisor, 50.0D),
Map.entry(OkZoomerConfigManager.CONFIG.values.upper_scroll_steps, preset == ZoomPresets.SPYGLASS ? 16 : 20),
Map.entry(OkZoomerConfigManager.CONFIG.values.lower_scroll_steps, preset == ZoomPresets.SPYGLASS ? 8 : 4),
Map.entry(OkZoomerConfigManager.CONFIG.values.upper_scroll_steps, switch (preset) {
case PERSISTENT -> 38;
case SPYGLASS -> 16;
default -> 20;
}),
Map.entry(OkZoomerConfigManager.CONFIG.values.lower_scroll_steps, switch (preset) {
case PERSISTENT -> 0;
case SPYGLASS -> 8;
default -> 4;
}),
Map.entry(OkZoomerConfigManager.CONFIG.values.smooth_multiplier, preset == ZoomPresets.SPYGLASS ? 0.5D : 0.75D),
Map.entry(OkZoomerConfigManager.CONFIG.values.cinematic_multiplier, 4.0D),
Map.entry(OkZoomerConfigManager.CONFIG.values.minimum_linear_step, 0.125D),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;

import net.minecraft.client.gui.hud.in_game.InGameHud;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager;
import net.minecraft.client.gui.hud.InGameHud;

@Mixin(InGameHud.class)
public abstract class InGameHudMixin {
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/io/github/ennuil/ok_zoomer/mixin/MouseMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;

import com.llamalad7.mixinextras.sugar.Local;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -19,24 +20,21 @@
// This mixin is responsible for the mouse-behavior-changing part of the zoom
@Mixin(Mouse.class)
public abstract class MouseMixin {
@Shadow
private double scrollDelta;

// Handles zoom scrolling
@Inject(
method = "onMouseScroll",
at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;scrollDelta:D", ordinal = 7),
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSpectator()Z"),
cancellable = true
)
private void zoomerOnMouseScroll(CallbackInfo ci) {
if (this.scrollDelta != 0.0) {
private void zoomerOnMouseScroll(CallbackInfo ci, @Local(ordinal = 2) int k) {
if (k != 0) {
if (OkZoomerConfigManager.CONFIG.features.zoom_scrolling.value()) {
if (OkZoomerConfigManager.CONFIG.features.zoom_mode.value().equals(ZoomModes.PERSISTENT)) {
if (!ZoomKeyBinds.ZOOM_KEY.isPressed()) return;
}

if (ZoomUtils.ZOOMER_ZOOM.getZoom()) {
ZoomUtils.changeZoomDivisor(this.scrollDelta > 0.0);
ZoomUtils.changeZoomDivisor(k > 0);
ci.cancel();
}
}
Expand Down

0 comments on commit 447753f

Please sign in to comment.