forked from Clones/Controlify
🐛 Fix vanilla overrides triggering more than once
This commit is contained in:
@ -410,10 +410,11 @@ public class ControllerBindings<T extends ControllerState> {
|
|||||||
|
|
||||||
registerModdedKeybinds();
|
registerModdedKeybinds();
|
||||||
|
|
||||||
// key events are executed in Minecraft#execute, which run at runTick.runAllTasks()
|
ControlifyEvents.CONTROLLER_STATE_UPDATE.register(ctrl -> {
|
||||||
// which this event runs directly after. A normal tick could run multiple
|
if (ctrl == this.controller) {
|
||||||
// times per frame, so you could get double clicks if lagging.
|
this.imitateVanillaClick();
|
||||||
InputHandledEvent.EVENT.register(this::imitateVanillaClick);
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ControlifyEvents.INPUT_MODE_CHANGED.register(mode -> KeyMapping.releaseAll());
|
ControlifyEvents.INPUT_MODE_CHANGED.register(mode -> KeyMapping.releaseAll());
|
||||||
}
|
}
|
||||||
@ -540,8 +541,9 @@ public class ControllerBindings<T extends ControllerState> {
|
|||||||
accessor.setIsDown(!accessor.getIsDown());
|
accessor.setIsDown(!accessor.getIsDown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (binding.justPressed())
|
if (binding.justPressed()) {
|
||||||
KeyMapping.click(vanillaKeyCode);
|
KeyMapping.click(vanillaKeyCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package dev.isxander.controlify.bindings;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
|
|
||||||
public interface InputHandledEvent {
|
|
||||||
void onInputHandled();
|
|
||||||
|
|
||||||
Event<InputHandledEvent> EVENT = EventFactory.createArrayBacked(InputHandledEvent.class, (listeners) -> () -> {
|
|
||||||
for (InputHandledEvent listener : listeners) {
|
|
||||||
listener.onInputHandled();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package dev.isxander.controlify.mixins.feature.bind;
|
|
||||||
|
|
||||||
import dev.isxander.controlify.bindings.InputHandledEvent;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
|
||||||
public class MinecraftMixin {
|
|
||||||
// KeyboardHandler and MouseHandler run input events through Minecraft#execute,
|
|
||||||
// which is polled by the injection point below. Cannot be done in normal tick event
|
|
||||||
// as that could run up to 10 times per frame depending on framerate.
|
|
||||||
@Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;runAllTasks()V", shift = At.Shift.AFTER))
|
|
||||||
private void onTasksExecuted(boolean tick, CallbackInfo ci) {
|
|
||||||
InputHandledEvent.EVENT.invoker().onInputHandled();
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,7 @@
|
|||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
},
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"client": [
|
||||||
"compat.iris.BaseOptionElementWidgetMixin",
|
"compat.iris.BaseOptionElementWidgetMixin",
|
||||||
"compat.sodium.CycleControlElementMixin",
|
"compat.sodium.CycleControlElementMixin",
|
||||||
"compat.sodium.SliderControlElementMixin",
|
"compat.sodium.SliderControlElementMixin",
|
||||||
@ -17,9 +17,7 @@
|
|||||||
"feature.rumble.fishing.FishingHookMixin",
|
"feature.rumble.fishing.FishingHookMixin",
|
||||||
"feature.rumble.itembreak.LivingEntityMixin",
|
"feature.rumble.itembreak.LivingEntityMixin",
|
||||||
"feature.rumble.levelevents.LevelRendererMixin",
|
"feature.rumble.levelevents.LevelRendererMixin",
|
||||||
"feature.rumble.useitem.LivingEntityMixin"
|
"feature.rumble.useitem.LivingEntityMixin",
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
"compat.fapi.KeyBindingRegistryImplAccessor",
|
"compat.fapi.KeyBindingRegistryImplAccessor",
|
||||||
"compat.sodium.SodiumOptionsGUIAccessor",
|
"compat.sodium.SodiumOptionsGUIAccessor",
|
||||||
"compat.sodium.SodiumOptionsGUIMixin",
|
"compat.sodium.SodiumOptionsGUIMixin",
|
||||||
@ -37,7 +35,6 @@
|
|||||||
"feature.autoswitch.ToastComponentAccessor",
|
"feature.autoswitch.ToastComponentAccessor",
|
||||||
"feature.bind.KeyMappingAccessor",
|
"feature.bind.KeyMappingAccessor",
|
||||||
"feature.bind.KeyMappingMixin",
|
"feature.bind.KeyMappingMixin",
|
||||||
"feature.bind.MinecraftMixin",
|
|
||||||
"feature.bind.ToggleKeyMappingAccessor",
|
"feature.bind.ToggleKeyMappingAccessor",
|
||||||
"feature.chatkbheight.ChatComponentMixin",
|
"feature.chatkbheight.ChatComponentMixin",
|
||||||
"feature.chatkbheight.ChatScreenMixin",
|
"feature.chatkbheight.ChatScreenMixin",
|
||||||
|
Reference in New Issue
Block a user