Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions net/neoforged/neoforge/client/event/ClientTickEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) NeoForged and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.neoforge.client.event;

import net.neoforged.bus.api.Event;

/**
* Base class of the two client tick events.
* <p>
* For the event that fires once per frame (instead of per tick), see {@link RenderFrameEvent}.
*
* @see ClientTickEvent.Pre
* @see ClientTickEvent.Post
*/
public abstract class ClientTickEvent extends Event {
/**
* {@link ClientTickEvent.Pre} is fired once per client tick, before the client performs work for the current tick.
* <p>
* This event only fires on the physical client.
*/
public static class Pre extends ClientTickEvent {
public Pre() {}
}

/**
* {@link ClientTickEvent.Post} is fired once per client tick, after the client performs work for the current tick.
* <p>
* This event only fires on the physical client.
*/
public static class Post extends ClientTickEvent {
public Post() {}
}
}
38 changes: 38 additions & 0 deletions net/neoforged/neoforge/client/event/RegisterKeyMappingsEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/

package net.neoforged.neoforge.client.event;

import net.minecraft.client.KeyMapping;
import net.minecraft.client.Options;
import net.neoforged.bus.api.Event;
import net.neoforged.bus.api.ICancellableEvent;
import net.neoforged.fml.LogicalSide;
import net.neoforged.fml.event.IModBusEvent;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.ApiStatus;

/**
* Allows users to register custom {@link net.minecraft.client.KeyMapping key mappings}.
*
* <p>This event is not {@linkplain ICancellableEvent cancellable}, and does not {@linkplain HasResult have a result}.
*
* <p>This event is fired on the mod-specific event bus, only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
public class RegisterKeyMappingsEvent extends Event implements IModBusEvent {
private final Options options;

@ApiStatus.Internal
public RegisterKeyMappingsEvent(Options options) {
this.options = options;
}

/**
* Registers a new key mapping.
*/
public void register(KeyMapping key) {
options.keyMappings = ArrayUtils.add(options.keyMappings, key);
}
}
Loading