forked from Clones/Controlify
improve bindings
This commit is contained in:
@ -8,6 +8,7 @@ import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
/**
|
||||
* Handles registering new bindings for controllers.
|
||||
@ -15,6 +16,8 @@ import java.util.function.BooleanSupplier;
|
||||
* Should be called within {@link dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint#onControlifyPreInit(ControlifyApi)}
|
||||
*/
|
||||
public interface ControlifyBindingsApi {
|
||||
BindingSupplier registerBind(ResourceLocation id, UnaryOperator<ControllerBindingBuilder<?>> builder);
|
||||
|
||||
/**
|
||||
* Registers a custom binding for all available controllers.
|
||||
* If the controller is not a gamepad, the binding with be empty by default.
|
||||
@ -23,6 +26,7 @@ public interface ControlifyBindingsApi {
|
||||
* @param id the identifier for the binding, the namespace should be your modid.
|
||||
* @return the binding supplier to fetch the binding for a specific controller.
|
||||
*/
|
||||
@Deprecated
|
||||
BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id);
|
||||
|
||||
/**
|
||||
@ -35,8 +39,11 @@ public interface ControlifyBindingsApi {
|
||||
* @param toggleOverride a supplier that returns true if the vanilla keybind should be treated as a {@link net.minecraft.client.ToggleKeyMapping}
|
||||
* @return the binding supplier to fetch the binding for a specific controller.
|
||||
*/
|
||||
@Deprecated
|
||||
BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride);
|
||||
|
||||
void excludeVanillaBind(KeyMapping... keyMapping);
|
||||
|
||||
static ControlifyBindingsApi get() {
|
||||
return ControllerBindings.Api.INSTANCE;
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package dev.isxander.controlify.api.bind;
|
||||
|
||||
import dev.isxander.controlify.bindings.ControllerBinding;
|
||||
import dev.isxander.controlify.bindings.GamepadBinds;
|
||||
import dev.isxander.controlify.bindings.IBind;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.ControllerState;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public interface ControllerBindingBuilder<T extends ControllerState> {
|
||||
static <T extends ControllerState> ControllerBindingBuilder<T> create(Controller<T, ?> controller) {
|
||||
return new ControllerBinding.ControllerBindingBuilderImpl<>(controller);
|
||||
}
|
||||
|
||||
ControllerBindingBuilder<T> identifier(ResourceLocation id);
|
||||
|
||||
ControllerBindingBuilder<T> identifier(String namespace, String path);
|
||||
|
||||
ControllerBindingBuilder<T> defaultBind(IBind<T> bind);
|
||||
|
||||
ControllerBindingBuilder<T> defaultBind(GamepadBinds gamepadBind);
|
||||
|
||||
ControllerBindingBuilder<T> name(Component name);
|
||||
|
||||
ControllerBindingBuilder<T> description(Component description);
|
||||
|
||||
ControllerBindingBuilder<T> category(Component category);
|
||||
|
||||
ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping, BooleanSupplier toggleable);
|
||||
|
||||
ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping);
|
||||
|
||||
ControllerBinding<T> build();
|
||||
}
|
Reference in New Issue
Block a user