use of net.minecraft.client.options.KeyBinding in project SpeedRunIGT by RedLime.
the class KeyBindingMixin method onPress.
@Inject(method = "setKeyPressed", at = @At("TAIL"))
private static void onPress(InputUtil.Key key, boolean pressed, CallbackInfo ci) {
InGameTimer timer = InGameTimer.getInstance();
KeyBinding keyBinding = keyToBindings.get(key);
if (timer.getStatus() == TimerStatus.NONE || timer.getStatus() == TimerStatus.COMPLETED_LEGACY)
return;
if (keyBinding != null && pressed) {
if (// Advancement
keyBinding == MinecraftClient.getInstance().options.keyAdvancements || Objects.equals(keyBinding.getCategory(), "key.categories.inventory") || Objects.equals(keyBinding.getCategory(), "key.categories.gameplay")) {
if (InGameTimerUtils.canUnpauseTimer(false)) {
timer.setPause(false, "pressed key");
}
timer.updateFirstInput();
}
if (keyBinding == SpeedRunIGT.timerResetKeyBinding) {
if (timer.getCategory() == RunCategories.CUSTOM && timer.isResettable()) {
InGameTimer.reset();
}
}
if (keyBinding == SpeedRunIGT.timerStopKeyBinding) {
if (timer.getCategory() == RunCategories.CUSTOM && timer.isStarted()) {
InGameTimer.complete();
}
}
}
}
use of net.minecraft.client.options.KeyBinding in project fabric by FabricMC.
the class KeyBindingRegistryImpl method process.
public KeyBinding[] process(KeyBinding[] keysAll) {
List<KeyBinding> newKeysAll = new ArrayList<>();
for (KeyBinding binding : keysAll) {
if (!(binding instanceof FabricKeyBinding)) {
newKeysAll.add(binding);
}
}
newKeysAll.addAll(fabricKeyBindingList);
return newKeysAll.toArray(new KeyBinding[0]);
}
use of net.minecraft.client.options.KeyBinding in project fabric by FabricMC.
the class KeyBindingRegistryImpl method register.
@Override
public boolean register(FabricKeyBinding binding) {
for (KeyBinding exBinding : fabricKeyBindingList) {
if (exBinding == binding) {
return false;
} else if (exBinding.getId().equals(binding.getId())) {
throw new RuntimeException("Attempted to register two key bindings with equal ID: " + binding.getId() + "!");
}
}
if (!hasCategory(binding.getCategory())) {
LOGGER.warn("Tried to register key binding with unregistered category '" + binding.getCategory() + "' - please use addCategory to ensure intended category ordering!");
addCategory(binding.getCategory());
}
fabricKeyBindingList.add(binding);
return true;
}
use of net.minecraft.client.options.KeyBinding in project BedrockIfy by juancarloscp52.
the class BedrockifyClient method onInitializeClient.
@Override
public void onInitializeClient() {
LOGGER.info("Initializing BedrockIfy Client.");
overlay = new Overlay((MinecraftClient.getInstance()));
reachAroundPlacement = new ReachAroundPlacement(MinecraftClient.getInstance());
heldItemTooltips = new HeldItemTooltips();
settingsGUI = new SettingsGUI();
keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding("bedrockIfy.key.settings", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_B, "BedrockIfy"));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (keyBinding.wasPressed()) {
client.openScreen(settingsGUI.getConfigScreen(client.currentScreen, true));
}
});
instance = this;
}
use of net.minecraft.client.options.KeyBinding in project StationAPI by ModificationStation.
the class MixinGameOptions method initKeyBindings.
@Unique
private void initKeyBindings() {
List<KeyBinding> keyBindingList = new ArrayList<>(Arrays.asList(keyBindings));
StationAPI.EVENT_BUS.post(new KeyBindingRegisterEvent(keyBindingList));
keyBindings = keyBindingList.toArray(new KeyBinding[0]);
}
Aggregations