-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.hysky.skyblocker.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import de.hysky.skyblocker.skyblock.garden.LowerSensitivity; | ||
import net.minecraft.client.Mouse; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(Mouse.class) | ||
public class MouseMixin { | ||
|
||
@ModifyExpressionValue(method = "updateMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/SimpleOption;getValue()Ljava/lang/Object;", ordinal = 0)) | ||
public Object skyblocker$gardenMouseLock(Object original) { | ||
if (LowerSensitivity.isSensitivityLowered()) | ||
return -1 / 3d; | ||
else return original; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/de/hysky/skyblocker/skyblock/garden/LowerSensitivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.hysky.skyblocker.skyblock.garden; | ||
|
||
import de.hysky.skyblocker.config.SkyblockerConfigManager; | ||
import de.hysky.skyblocker.utils.ItemUtils; | ||
import de.hysky.skyblocker.utils.Location; | ||
import de.hysky.skyblocker.utils.Utils; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class LowerSensitivity { | ||
|
||
private static boolean sensitivityLowered = false; | ||
|
||
public static void init() { | ||
ClientTickEvents.END_WORLD_TICK.register(world -> { | ||
if (!Utils.isOnSkyblock() || Utils.getLocation() != Location.GARDEN || MinecraftClient.getInstance().player == null) { | ||
if (sensitivityLowered) lowerSensitivity(false); | ||
return; | ||
} | ||
if (SkyblockerConfigManager.get().locations.garden.lockMouseTool) { | ||
ItemStack mainHandStack = MinecraftClient.getInstance().player.getMainHandStack(); | ||
String itemId = ItemUtils.getItemId(mainHandStack); | ||
boolean shouldLockMouse = FarmingHudWidget.FARMING_TOOLS.containsKey(itemId) && (!SkyblockerConfigManager.get().locations.garden.lockMouseGroundOnly || MinecraftClient.getInstance().player.isOnGround()); | ||
if (shouldLockMouse && !sensitivityLowered) lowerSensitivity(true); | ||
else if (!shouldLockMouse && sensitivityLowered) lowerSensitivity(false); | ||
|
||
} | ||
}); | ||
} | ||
|
||
public static void lowerSensitivity(boolean lowerSensitivity) { | ||
if (sensitivityLowered == lowerSensitivity) return; | ||
sensitivityLowered = lowerSensitivity; | ||
} | ||
|
||
public static boolean isSensitivityLowered() { | ||
return sensitivityLowered; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters