1
0
forked from Clones/Controlify

fix binding api not working with generics and iris compat

This commit is contained in:
isXander
2023-02-25 23:27:23 +00:00
parent 05be05bab5
commit 05f863a0d7
36 changed files with 180 additions and 109 deletions

View File

@ -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();
}
}
}

View File

@ -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)

View File

@ -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);
}
}