Add key to disable/enable slyde
This commit is contained in:
parent
6d98a0b711
commit
d517f1f641
|
@ -11,6 +11,7 @@ import java.util.Properties;
|
||||||
public class Cfg {
|
public class Cfg {
|
||||||
public boolean sodiumCompat = true;
|
public boolean sodiumCompat = true;
|
||||||
public boolean forceSodiumCompat = false;
|
public boolean forceSodiumCompat = false;
|
||||||
|
public boolean holdKeyToActivate = false;
|
||||||
|
|
||||||
private static Cfg conf = null;
|
private static Cfg conf = null;
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ public class Cfg {
|
||||||
}
|
}
|
||||||
conf.sodiumCompat = getBool(p, "sodiumCompat", conf.sodiumCompat);
|
conf.sodiumCompat = getBool(p, "sodiumCompat", conf.sodiumCompat);
|
||||||
conf.forceSodiumCompat = getBool(p, "forceSodiumCompat", conf.forceSodiumCompat);
|
conf.forceSodiumCompat = getBool(p, "forceSodiumCompat", conf.forceSodiumCompat);
|
||||||
|
conf.holdKeyToActivate = getBool(p, "holdKeyToActivate", conf.holdKeyToActivate);
|
||||||
try {
|
try {
|
||||||
p.store(Files.newOutputStream(c), "Slyde config");
|
p.store(Files.newOutputStream(c), "Slyde config");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package io.gitlab.jfronny.slyde;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.util.InputUtil;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class SlydeClient implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
Cfg.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isActive() {
|
||||||
|
long handle = MinecraftClient.getInstance().getWindow().getHandle();
|
||||||
|
boolean down = InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_LEFT_SHIFT)
|
||||||
|
|| InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_RIGHT_SHIFT)
|
||||||
|
|| InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_LEFT_CONTROL)
|
||||||
|
|| InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_RIGHT_CONTROL);
|
||||||
|
return down == Cfg.get().holdKeyToActivate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
package io.gitlab.jfronny.slyde.client;
|
|
||||||
|
|
||||||
import io.gitlab.jfronny.slyde.Cfg;
|
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public class SlydeClient implements ClientModInitializer {
|
|
||||||
@Override
|
|
||||||
public void onInitializeClient() {
|
|
||||||
Cfg.get();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.gitlab.jfronny.slyde.mixin;
|
package io.gitlab.jfronny.slyde.mixin;
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.slyde.SlydeClient;
|
||||||
import net.minecraft.client.gui.widget.SliderWidget;
|
import net.minecraft.client.gui.widget.SliderWidget;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
@ -20,8 +21,9 @@ public abstract class SliderWidgetMixin {
|
||||||
@Overwrite
|
@Overwrite
|
||||||
private void setValue(double mouseX) {
|
private void setValue(double mouseX) {
|
||||||
double d = value;
|
double d = value;
|
||||||
//this.value = MathHelper.clamp(mouseX, 0.0D, 1.0D);
|
|
||||||
value = mouseX;
|
value = mouseX;
|
||||||
|
if (!SlydeClient.isActive())
|
||||||
|
value = MathHelper.clamp(value, 0.0D, 1.0D);
|
||||||
if (d != value) {
|
if (d != value) {
|
||||||
applyValue();
|
applyValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package io.gitlab.jfronny.slyde.mixin;
|
package io.gitlab.jfronny.slyde.mixin;
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.slyde.SlydeClient;
|
||||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||||
import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement;
|
import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement;
|
||||||
import me.jellysquid.mods.sodium.client.util.Dim2i;
|
import me.jellysquid.mods.sodium.client.util.Dim2i;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
@ -24,6 +26,8 @@ public abstract class SodiumSliderControlMixin extends ControlElement<Integer> {
|
||||||
@Overwrite(remap = false)
|
@Overwrite(remap = false)
|
||||||
private void setValue(double d) {
|
private void setValue(double d) {
|
||||||
this.thumbPosition = d;
|
this.thumbPosition = d;
|
||||||
|
if (!SlydeClient.isActive())
|
||||||
|
this.thumbPosition = MathHelper.clamp(this.thumbPosition, 0.0D, 1.0D);
|
||||||
int value = this.getIntValue();
|
int value = this.getIntValue();
|
||||||
if (this.option.getValue() != value) {
|
if (this.option.getValue() != value) {
|
||||||
this.option.setValue(value);
|
this.option.setValue(value);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"client": [
|
"client": [
|
||||||
"io.gitlab.jfronny.slyde.client.SlydeClient"
|
"io.gitlab.jfronny.slyde.SlydeClient"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
|
Loading…
Reference in New Issue