forked from Clones/Controlify
fix binding api not working with generics and iris compat
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
package dev.isxander.controlify.mixins.compat.iris;
|
||||
|
||||
import dev.isxander.controlify.compatibility.iris.BaseOptionElementComponentProcessor;
|
||||
import dev.isxander.controlify.screenop.ComponentProcessor;
|
||||
import dev.isxander.controlify.screenop.ComponentProcessorProvider;
|
||||
import net.coderbot.iris.gui.NavigationController;
|
||||
import net.coderbot.iris.gui.element.widget.BaseOptionElementWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(BaseOptionElementWidget.class)
|
||||
public abstract class BaseOptionElementWidgetMixin implements ComponentProcessorProvider {
|
||||
@Shadow public abstract boolean applyPreviousValue();
|
||||
@Shadow public abstract boolean applyNextValue();
|
||||
|
||||
@Shadow protected NavigationController navigation;
|
||||
@Unique private final BaseOptionElementComponentProcessor processor
|
||||
= new BaseOptionElementComponentProcessor(this::cycle);
|
||||
|
||||
@Override
|
||||
public ComponentProcessor componentProcessor() {
|
||||
return processor;
|
||||
}
|
||||
|
||||
private void cycle(boolean reverse) {
|
||||
boolean needsUpdate = reverse ? applyPreviousValue() : applyNextValue();
|
||||
if (needsUpdate) {
|
||||
navigation.refresh();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package dev.isxander.controlify.mixins.compat.sodium;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import dev.isxander.controlify.compatibility.sodium.SliderControlProcessor;
|
||||
import dev.isxander.controlify.screenop.ComponentProcessor;
|
||||
import dev.isxander.controlify.screenop.ComponentProcessorProvider;
|
||||
@ -8,9 +7,7 @@ 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.util.Dim2i;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Pseudo
|
||||
@Mixin(targets = "me.jellysquid.mods.sodium.client.gui.options.control.SliderControl$Button", remap = false)
|
||||
|
@ -13,6 +13,7 @@ import java.util.function.LongSupplier;
|
||||
public class GLXMixin {
|
||||
@Inject(method = "_initGlfw", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwInit()Z", shift = At.Shift.BEFORE))
|
||||
private static void addInitHints(CallbackInfoReturnable<LongSupplier> cir) {
|
||||
// stops GLFW adding hats to button list (backward compat)
|
||||
GLFW.glfwInitHint(GLFW.GLFW_JOYSTICK_HAT_BUTTONS, GLFW.GLFW_FALSE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user