Skip to content

Commit

Permalink
Prevent Mouse Cursor Reset
Browse files Browse the repository at this point in the history
See #350

Original Feature was

Co-authored-by: Moulberry <james.jenour@protonmail.com>
  • Loading branch information
My-Name-Is-Jeff and Moulberry committed Mar 21, 2023
1 parent 3046eb7 commit 469d221
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Skytils - Hypixel Skyblock Quality of Life Mod
* Copyright (C) 2020-2023 Skytils
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package gg.skytils.skytilsmod.mixins.transformers.util;

import com.llamalad7.mixinextras.injector.WrapWithCondition;
import gg.skytils.skytilsmod.mixins.hooks.util.MouseHelperHookKt;
import net.minecraft.util.MouseHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(MouseHelper.class)
public class MixinMouseHelper {
@WrapWithCondition(method = "ungrabMouseCursor", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;setCursorPosition(II)V", remap = false))
private boolean shouldSetCursorPos(int newX, int newY) {
return MouseHelperHookKt.shouldResetMouseToCenter();
}
}
8 changes: 7 additions & 1 deletion src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,6 @@ object Config : Vigilant(
)
var hideScoreboardScore = false


@Property(
type = PropertyType.SWITCH, name = "Hide Vanilla Health Display",
description = "Prevents the game from rendering the vanilla heart points.",
Expand Down Expand Up @@ -1971,6 +1970,13 @@ object Config : Vigilant(
)
var partyAddons = false

@Property(
type = PropertyType.SWITCH, name = "Prevent Cursor Reset",
description = "Prevents the cursor from resetting to the center of the screen when you open a GUI.",
category = "Miscellaneous", subcategory = "Quality of Life"
)
var preventCursorReset = false

@Property(
type = PropertyType.SWITCH, name = "Power Orb Lock",
description = "Prevents placing the power orb if the same or better power orb is within range.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Skytils - Hypixel Skyblock Quality of Life Mod
* Copyright (C) 2020-2023 Skytils
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package gg.skytils.skytilsmod.mixins.hooks.util

import gg.skytils.skytilsmod.Skytils

fun shouldResetMouseToCenter(): Boolean {
return !Skytils.config.preventCursorReset
}
3 changes: 2 additions & 1 deletion src/main/resources/mixins.skytils.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
],
"verbose": true,
"client": [
"gui.MixinGuiEditSign"
"gui.MixinGuiEditSign",
"util.MixinMouseHelper"
]
}

0 comments on commit 469d221

Please sign in to comment.