Improve event javadocs based on community feedback, apply jSpecify to more events

This commit is contained in:
Paint_Ninja committed 2025-10-10 14:57:38 +01:00
1 parent 8e09d47cd6
commit 8443262e39
66 files changed
+217 -165

No files matched your search

@@ -29,9 +29,7 @@ public record AddGuiOverlayLayersEvent(ForgeLayeredDraw getLayeredDraw) implemen
@ApiStatus.Internal
public AddGuiOverlayLayersEvent {}
/**
* @deprecated {@link AddGuiOverlayLayersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly.
*/
/** @deprecated {@link AddGuiOverlayLayersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<AddGuiOverlayLayersEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -12,16 +12,19 @@ import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
* Fired when the client is about to send a chat message to the server.
*
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the chat message will not be sent to the server.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
**/
@NullMarked
public final class ClientChatEvent extends MutableEvent implements Cancellable {
public static final CancellableEventBus<ClientChatEvent> BUS = CancellableEventBus.create(ClientChatEvent.class);
@@ -47,7 +50,7 @@ public final class ClientChatEvent extends MutableEvent implements Cancellable {
*
* @param message the new message to be sent
*/
public void setMessage(String message) {
public void setMessage(@Nullable String message) {
this.message = Strings.nullToEmpty(message);
}
@@ -22,7 +22,7 @@ import java.util.UUID;
* Fired when a chat message is received on the client.
* This can be used for filtering and detecting messages with specific words or phrases, and suppressing them.
*
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the message is not displayed in the chat message window.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -89,7 +89,7 @@ public sealed class ClientChatReceivedEvent extends MutableEvent implements Canc
/**
* Fired when a player chat message is received on the client.
*
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the message is not displayed in the chat message window.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -120,8 +120,8 @@ public sealed class ClientChatReceivedEvent extends MutableEvent implements Canc
/**
* Fired when a system message is received on the client.
*
* @Deprecated Mojang made ChatType a registry, which isn't always accessible when the System messages are sent.
* So moved to it's own event. {@link SystemMessageReceivedEvent}
* @deprecated Mojang made ChatType a registry, which isn't always accessible when the System messages are sent.
* So moved to its own event. {@link SystemMessageReceivedEvent}
*/
@Deprecated(forRemoval = true, since = "1.21.1")
public static final class System extends ClientChatReceivedEvent {
@@ -12,6 +12,7 @@ import net.minecraftforge.eventbus.api.event.InheritableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import net.minecraftforge.fml.LogicalSide;
import org.jspecify.annotations.NullMarked;
/**
* Fired when pause is about to change
@@ -21,6 +22,7 @@ import net.minecraftforge.fml.LogicalSide;
* @see ClientPauseChangeEvent.Pre
* @see ClientPauseChangeEvent.Post
*/
@NullMarked
public sealed interface ClientPauseChangeEvent extends InheritableEvent {
EventBus<ClientPauseChangeEvent> BUS = EventBus.create(ClientPauseChangeEvent.class);
@@ -7,10 +7,8 @@ package net.minecraftforge.client.event;
import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.world.level.GameType;
import net.minecraftforge.common.util.HasResult;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -18,8 +16,6 @@ import org.jspecify.annotations.NullMarked;
/**
* Fired when the client player is notified of a change of {@link GameType} from the server.
*
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*
* @param getInfo the client player information
@@ -12,17 +12,17 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
/**
* Fired after the field of vision (FOV) modifier for the player is calculated to allow developers to adjust it further.
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*
* @see ViewportEvent.ComputeFov
*/
@NullMarked
public final class ComputeFovModifierEvent extends MutableEvent {
public static final EventBus<ComputeFovModifierEvent> BUS = EventBus.create(ComputeFovModifierEvent.class);
@@ -62,8 +62,6 @@ public sealed interface ContainerScreenEvent {
* <p>This can be used for rendering elements that must be above other screen elements, but
* below tooltips and the dragged stack, such as slot or item stack specific overlays.</p>
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@@ -83,8 +81,6 @@ public sealed interface ContainerScreenEvent {
* Fired after the container screen's background layer and elements are drawn.
* This can be used for rendering new background elements.
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@@ -39,6 +39,7 @@ import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
@@ -69,6 +70,7 @@ public sealed interface EntityRenderersEvent {
record RegisterLayerDefinitions() implements SelfDestructing, RecordEvent, EntityRenderersEvent {
public static final EventBus<RegisterLayerDefinitions> BUS = EventBus.create(RegisterLayerDefinitions.class);
/** @deprecated {@link EntityRenderersEvent.RegisterLayerDefinitions} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterLayerDefinitions> getBus(BusGroup modBusGroup) {
return BUS;
@@ -102,6 +104,7 @@ public sealed interface EntityRenderersEvent {
record RegisterRenderers() implements SelfDestructing, RecordEvent, EntityRenderersEvent {
public static final EventBus<RegisterRenderers> BUS = EventBus.create(RegisterRenderers.class);
/** @deprecated {@link RegisterRenderers} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterRenderers> getBus(BusGroup modBusGroup) {
return BUS;
@@ -140,6 +143,7 @@ public sealed interface EntityRenderersEvent {
final class AddLayers extends MutableEvent implements EntityRenderersEvent {
public static final EventBus<AddLayers> BUS = EventBus.create(AddLayers.class);
/** @deprecated {@link EntityRenderersEvent.AddLayers} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<AddLayers> getBus(BusGroup modBusGroup) {
return BUS;
@@ -231,6 +235,7 @@ public sealed interface EntityRenderersEvent {
final class CreateSkullModels extends MutableEvent implements EntityRenderersEvent {
public static final EventBus<CreateSkullModels> BUS = EventBus.create(CreateSkullModels.class);
/** @deprecated {@link EntityRenderersEvent.CreateSkullModels} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<CreateSkullModels> getBus(BusGroup modBusGroup) {
return BUS;
@@ -17,6 +17,7 @@ import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
import org.lwjgl.glfw.GLFW;
/**
@@ -127,6 +128,7 @@ public sealed interface InputEvent {
* @param getMouseX the X position of the mouse cursor
* @param getMouseY the Y position of the mouse cursor
*/
@NullMarked
record MouseScrollingEvent(
double getDeltaX,
double getDeltaY,
@@ -18,7 +18,6 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -51,6 +50,7 @@ public sealed interface ModelEvent {
implements RecordEvent, ModelEvent {
public static final EventBus<ModifyBakingResult> BUS = EventBus.create(ModifyBakingResult.class);
/** @deprecated {@link ModelEvent.ModifyBakingResult} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<ModifyBakingResult> getBus(BusGroup modBusGroup) {
return BUS;
@@ -75,6 +75,7 @@ public sealed interface ModelEvent {
implements RecordEvent, ModelEvent {
public static final EventBus<BakingCompleted> BUS = EventBus.create(BakingCompleted.class);
/** @deprecated {@link ModelEvent.BakingCompleted} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<BakingCompleted> getBus(BusGroup modBusGroup) {
return BUS;
@@ -95,6 +96,7 @@ public sealed interface ModelEvent {
final class RegisterModelStateDefinitions extends MutableEvent implements ModelEvent {
public static final EventBus<RegisterModelStateDefinitions> BUS = EventBus.create(RegisterModelStateDefinitions.class);
/** @deprecated {@link ModelEvent.RegisterModelStateDefinitions} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterModelStateDefinitions> getBus(BusGroup modBusGroup) {
return BUS;
@@ -130,6 +132,7 @@ public sealed interface ModelEvent {
final class RegisterGeometryLoaders extends MutableEvent implements ModelEvent {
public static final EventBus<RegisterGeometryLoaders> BUS = EventBus.create(RegisterGeometryLoaders.class);
/** @deprecated {@link ModelEvent.RegisterGeometryLoaders} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterGeometryLoaders> getBus(BusGroup modBusGroup) {
return BUS;
@@ -15,8 +15,6 @@ import org.jetbrains.annotations.ApiStatus;
/**
* Fired when the {@link ClientRecipeBook} has updated information about recipes from the server to the client.
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*
@@ -6,14 +6,13 @@
package net.minecraftforge.client.event;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.ObjectiveArgument;
import net.minecraft.commands.arguments.ResourceLocationArgument;
import net.minecraftforge.common.util.HasResult;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -23,14 +22,12 @@ import org.jspecify.annotations.NullMarked;
*
* <p>Some command arguments behave differently for the client commands dispatcher:</p>
* <ul>
* <li>{@link ResourceLocationArgument#getAdvancement(com.mojang.brigadier.context.CommandContext, String)} only returns
* advancements that are shown on the advancements screen.
* <li>{@link ResourceLocationArgument#getId(CommandContext, String)} only returns advancements that are shown on
* the advancements screen.
* <li>{@link ObjectiveArgument#getObjective(com.mojang.brigadier.context.CommandContext, String)} only returns
* objectives that are displayed to the player.
* </ul>
*
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*
* @param getDispatcher the command dispatcher for registering commands to be executed on the client
@@ -14,6 +14,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -29,6 +30,7 @@ import org.jspecify.annotations.NullMarked;
public final class RegisterClientReloadListenersEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterClientReloadListenersEvent> BUS = EventBus.create(RegisterClientReloadListenersEvent.class);
/** @deprecated {@link RegisterClientReloadListenersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterClientReloadListenersEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -12,6 +12,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -28,6 +29,7 @@ import java.util.function.Function;
public final class RegisterClientTooltipComponentFactoriesEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterClientTooltipComponentFactoriesEvent> BUS = EventBus.create(RegisterClientTooltipComponentFactoriesEvent.class);
/** @deprecated {@link RegisterClientTooltipComponentFactoriesEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterClientTooltipComponentFactoriesEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -15,6 +15,7 @@ import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -38,6 +39,7 @@ public sealed interface RegisterColorHandlersEvent {
record Block(BlockColors getBlockColors) implements RecordEvent, RegisterColorHandlersEvent {
public static final EventBus<Block> BUS = EventBus.create(Block.class);
/** @deprecated {@link RegisterColorHandlersEvent.Block} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<Block> getBus(BusGroup modBusGroup) {
return BUS;
@@ -75,6 +77,7 @@ public sealed interface RegisterColorHandlersEvent {
final class ColorResolvers extends MutableEvent implements SelfDestructing, RegisterColorHandlersEvent {
public static final EventBus<ColorResolvers> BUS = EventBus.create(ColorResolvers.class);
/** @deprecated {@link RegisterColorHandlersEvent.ColorResolvers} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<ColorResolvers> getBus(BusGroup modBusGroup) {
return BUS;
@@ -12,6 +12,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -26,6 +27,7 @@ import java.util.Map;
public final class RegisterDimensionSpecialEffectsEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterDimensionSpecialEffectsEvent> BUS = EventBus.create(RegisterDimensionSpecialEffectsEvent.class);
/** @deprecated {@link RegisterDimensionSpecialEffectsEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterDimensionSpecialEffectsEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -12,6 +12,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -27,6 +28,7 @@ import java.util.Map;
public final class RegisterEntitySpectatorShadersEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterEntitySpectatorShadersEvent> BUS = EventBus.create(RegisterEntitySpectatorShadersEvent.class);
/** @deprecated {@link RegisterEntitySpectatorShadersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterEntitySpectatorShadersEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -14,6 +14,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -30,6 +31,7 @@ import java.util.Map;
public final class RegisterItemDecorationsEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterItemDecorationsEvent> BUS = EventBus.create(RegisterItemDecorationsEvent.class);
/** @deprecated {@link RegisterItemDecorationsEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterItemDecorationsEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -12,6 +12,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -25,6 +26,7 @@ import org.jspecify.annotations.NullMarked;
public final class RegisterKeyMappingsEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterKeyMappingsEvent> BUS = EventBus.create(RegisterKeyMappingsEvent.class);
/** @deprecated {@link RegisterKeyMappingsEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterKeyMappingsEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -16,6 +16,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import java.util.Map;
@@ -28,6 +29,7 @@ import java.util.Map;
public final class RegisterNamedRenderTypesEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterNamedRenderTypesEvent> BUS = EventBus.create(RegisterNamedRenderTypesEvent.class);
/** @deprecated {@link RegisterNamedRenderTypesEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterNamedRenderTypesEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -13,6 +13,7 @@ import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.registries.RegisterEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -29,6 +30,7 @@ import org.jspecify.annotations.NullMarked;
public final class RegisterParticleProvidersEvent extends MutableEvent {
public static EventBus<RegisterParticleProvidersEvent> BUS = EventBus.create(RegisterParticleProvidersEvent.class);
/** @deprecated {@link RegisterParticleProvidersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterParticleProvidersEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -25,7 +25,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
/**
* <p>Event for registering {@link PresetEditor} screen factories for world presets.</p>
*
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModBusGroup() mod BusGroup},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
public final class RegisterPresetEditorsEvent implements SelfDestructing, IModBusEvent {
@@ -15,6 +15,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
/**
@@ -25,6 +26,7 @@ import org.jetbrains.annotations.ApiStatus;
public final class RegisterTextureAtlasSpriteLoadersEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterTextureAtlasSpriteLoadersEvent> BUS = EventBus.create(RegisterTextureAtlasSpriteLoadersEvent.class);
/** {@link RegisterTextureAtlasSpriteLoadersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterTextureAtlasSpriteLoadersEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -22,9 +22,9 @@ import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
/**
* Fired before a selection highlight is rendered.
* Fired before a selection highlight is rendered.<br>
* You should extract your custom data here so that you can use it in the render callback without effecting world state.
*
* <br><br>
* See the two subclasses to listen for blocks or entities.
*
* @see Block
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.ApiStatus;
/**
* Fired before an entity renderer renders the nameplate of an entity.
*
* <p>This event is not {@linkplain Cancelable cancellable}, and {@linkplain HasResult has a result}.</p>
* <p>This event {@linkplain HasResult has a result}:</p>
* <ul>
* <li>{@link Result#ALLOW} - the nameplate will be forcibly rendered.</li>
* <li>{@link Result#DEFAULT} - the vanilla logic will be used.</li>
@@ -24,6 +24,7 @@ import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.lwjgl.glfw.GLFW;
import java.util.Collections;
@@ -110,7 +111,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the screen's overridable initialization method is fired.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the initialization method will not be called, and the widgets and children lists
* will not be cleared.</p>
*
@@ -129,8 +130,6 @@ public sealed interface ScreenEvent {
/**
* Fired <b>after</b> the screen's overridable initialization method is called.
*
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@@ -175,7 +174,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the screen is drawn.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen will not be drawn.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -192,8 +191,6 @@ public sealed interface ScreenEvent {
/**
* Fired <b>after</b> the screen is drawn.
*
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@@ -343,7 +340,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the mouse click is handled by the screen.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen's mouse click handler will be bypassed
* and the corresponding {@link MouseButtonPressed.Post} will not be fired.</p>
*
@@ -362,7 +359,7 @@ public sealed interface ScreenEvent {
* Fired <b>after</b> the mouse click is handled, if the corresponding {@link MouseButtonPressed.Pre} was not
* cancelled.
*
* <p>This event is not {@linkplain Cancellable cancellable}, {@linkplain HasResult has a result}.</p>
* <p>This event {@linkplain HasResult has a result}:</p>
* <ul>
* <li>{@link Result#ALLOW} - forcibly sets the mouse click as handled</li>
* <li>{@link Result#DEFAULT} - defaults to the return value of
@@ -415,7 +412,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the mouse release is handled by the screen.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen's mouse release handler will be bypassed
* and the corresponding {@link MouseButtonReleased.Post} will not be fired.</p>
*
@@ -434,11 +431,11 @@ public sealed interface ScreenEvent {
* Fired <b>after</b> the mouse release is handled, if the corresponding {@link MouseButtonReleased.Pre} was
* not cancelled.
*
* <p>This event is not {@linkplain Cancellable cancellable}, {@linkplain HasResult has a result}.</p>
* <p>This event {@linkplain HasResult has a result}:</p>
* <ul>
* <li>{@link Result#ALLOW} - forcibly sets the mouse release as handled</li>
* <li>{@link Result#DEFAULT} - defaults to the return value of
* {@link Screen#mouseReleased(double, double, int)} from the screen (see {@link #wasHandled()}.</li>
* {@link Screen#mouseReleased(MouseButtonEvent)} from the screen (see {@link #wasHandled()}.</li>
* <li>{@link Result#DENY} - forcibly sets the mouse release as not handled.</li>
* </ul>
*
@@ -476,6 +473,7 @@ public sealed interface ScreenEvent {
* @see MouseDragged.Pre
* @see MouseDragged.Post
*/
@NullMarked
sealed interface MouseDragged extends MouseInput {
/**
* {@return the mouse button's input code}
@@ -498,7 +496,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the mouse drag is handled by the screen.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen's mouse drag handler will be bypassed
* and the corresponding {@link MouseDragged.Post} will not be fired.</p>
*
@@ -551,6 +549,7 @@ public sealed interface ScreenEvent {
* @see MouseScrolled.Pre
* @see MouseScrolled.Post
*/
@NullMarked
sealed interface MouseScrolled extends MouseInput {
/**
* {@return the amount of change / delta of the mouse scroll in the vertical direction}
@@ -565,7 +564,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the mouse scroll is handled by the screen.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen's mouse scroll handler will be bypassed
* and the corresponding {@link MouseScrolled.Post} will not be fired.</p>
*
@@ -666,7 +665,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the key press is handled by the screen.
*
* <p>This event is {@linkplain Cancellable cancellable} and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen's key press handler will be bypassed
* and the corresponding {@link KeyPressed.Post} will not be fired.</p>
*
@@ -684,7 +683,7 @@ public sealed interface ScreenEvent {
* Fired <b>after</b> the key press is handled, if not handled by the screen
* and the corresponding {@link KeyPressed.Pre} is not cancelled.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the key press will be set as handled.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -709,7 +708,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the key release is handled by the screen.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen's key release handler will be bypassed
* and the corresponding {@link KeyReleased.Post} will not be fired.</p>
*
@@ -727,7 +726,7 @@ public sealed interface ScreenEvent {
* Fired <b>after</b> the key release is handled, if not handled by the screen
* and the corresponding {@link KeyReleased.Pre} is not cancelled.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the key release will be set as handled.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -781,7 +780,7 @@ public sealed interface ScreenEvent {
/**
* Fired <b>before</b> the character input is handled by the screen.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the screen's character input handler will be bypassed
* and the corresponding {@link CharacterTyped.Post} will not be fired.</p>
*
@@ -799,7 +798,7 @@ public sealed interface ScreenEvent {
* Fired <b>after</b> the character input is handled, if not handled by the screen
* and the corresponding {@link CharacterTyped.Pre} is not cancelled.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If the event is cancelled, the character input will be set as handled.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -817,7 +816,7 @@ public sealed interface ScreenEvent {
* Fired before any {@link Screen} is opened, to allow changing it or preventing it from being opened.
* All screen layers on the screen are closed before this event is fired.
*
* <p>This event is {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If this event is cancelled, then the {@code Screen} shall be prevented from opening and any previous screen
* will remain open. However, cancelling this event will not prevent the closing of screen layers which happened before
* this event fired.</p>
@@ -874,8 +873,6 @@ public sealed interface ScreenEvent {
* Fired before a {@link Screen} is closed.
* All screen layers on the screen are closed before this event is fired.
*
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@@ -14,7 +14,8 @@ import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import java.io.File;
import java.io.IOException;
@@ -22,7 +23,7 @@ import java.io.IOException;
/**
* Fired when a screenshot is taken, but before it is written to disk.
*
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* If this event is cancelled, then the screenshot is not written to disk, and the message in the event will be posted
* to the player's chat.</p>
*
@@ -31,6 +32,7 @@ import java.io.IOException;
*
* @see Screenshot
*/
@NullMarked
public final class ScreenshotEvent extends MutableEvent implements Cancellable {
public static final CancellableEventBus<ScreenshotEvent> BUS = CancellableEventBus.create(ScreenshotEvent.class);
public static final Component DEFAULT_CANCEL_REASON = Component.literal("Screenshot canceled");
@@ -80,7 +82,7 @@ public final class ScreenshotEvent extends MutableEvent implements Cancellable {
*
* @param resultMessage the new result message
*/
public void setResultMessage(Component resultMessage) {
public void setResultMessage(@Nullable Component resultMessage) {
this.resultMessage = resultMessage;
}
@@ -10,6 +10,7 @@ import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -63,6 +64,7 @@ public sealed interface TextureStitchEvent {
record Post(TextureAtlas getAtlas) implements RecordEvent, TextureStitchEvent {
public static final EventBus<Post> BUS = EventBus.create(Post.class);
/** @deprecated {@link TextureStitchEvent.Post} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<Post> getBus(BusGroup modBusGroup) {
return BUS;
@@ -16,7 +16,7 @@ import net.minecraftforge.fml.LogicalSide;
* Fired when the client queues a {@link Toast} message to be shown onscreen.
* Toasts are small popups that appear on the top right of the screen, for certain actions such as unlocking Advancements and Recipes.
*
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>This event is {@linkplain Cancellable cancellable}.
* Cancelling the event stops the toast from being queued, which means it never renders.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -19,6 +19,7 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import org.joml.Vector4f;
import org.jspecify.annotations.NullMarked;
/**
* Fired for hooking into the entity view rendering in {@link GameRenderer}.
@@ -52,7 +53,7 @@ public sealed interface ViewportEvent {
/**
* Fired for <b>rendering</b> custom fog. The plane distances are based on the player's render distance.
*
* <p>This event is {@linkplain Cancelable cancellable}, and {@linkplain HasResult has a result}. <br/>
* <p>This event is {@linkplain Cancellable cancellable}.<br>
* The event must be cancelled for any changes to the plane distances to take effect.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
@@ -140,8 +141,6 @@ public sealed interface ViewportEvent {
/**
* Fired for customizing the <b>color</b> of the fog visible to the player.
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@@ -234,11 +233,10 @@ public sealed interface ViewportEvent {
* Fired to allow altering the angles of the player's camera.
* This can be used to alter the player's view for different effects, such as applying roll.
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@NullMarked
final class ComputeCameraAngles extends MutableEvent implements ViewportEvent {
public static final EventBus<ComputeCameraAngles> BUS = EventBus.create(ComputeCameraAngles.class);
@@ -327,13 +325,12 @@ public sealed interface ViewportEvent {
* Fired for altering the raw field of view (FOV).
* This is after the FOV settings are applied, and before modifiers such as the Nausea effect.
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
*
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*
* @see ComputeFovModifierEvent
*/
@NullMarked
final class ComputeFov extends MutableEvent implements ViewportEvent {
public static final EventBus<ComputeFov> BUS = EventBus.create(ComputeFov.class);
@@ -10,6 +10,7 @@ import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -23,6 +24,7 @@ import org.jspecify.annotations.NullMarked;
public record SoundEngineLoadEvent(SoundEngine getEngine) implements RecordEvent, SoundEvent {
public static final EventBus<SoundEngineLoadEvent> BUS = EventBus.create(SoundEngineLoadEvent.class);
/** @deprecated {@link SoundEngineLoadEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<SoundEngineLoadEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -16,9 +16,16 @@ import java.util.Collection;
/**
* A small helper class to aid Forge modders in migrating from EventBus 6 to the new EventBus 7.
* <br>
* Refer to the migration guide mentioned in the Forge 1.21.6 announcement or ask in the Forge Discord for help with
* migrating your mod to the new system.
* <p>
* Refer to the <a href="https://gist.github.com/PaintNinja/ad82c224aecee25efac1ea3e2cf19b91">migration guide</a>
* mentioned in the <a href="https://files.minecraftforge.net">Forge 1.21.6 changelog</a> or
* <a href="https://forums.minecraftforge.net/topic/159525-forge-581-minecraft-1218/">1.21.8 announcement</a> on the
* forums, or ask in <a href="https://discord.minecraftforge.net">the Forge Discord</a> for help with migrating your mod
* to the new system.
* </p>
* <p>
* You can also check the updated example code in <a href="https://files.minecraftforge.net">the MDK</a> for the MC
* version you're using.
*/
public final class EventBusMigrationHelper {
public static final EventBusMigrationHelper INSTANCE = new EventBusMigrationHelper(BusGroup.DEFAULT);
@@ -10,9 +10,12 @@ import net.minecraft.client.gui.screens.Screen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.IConfigSpec;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.network.DualStackUtils;
import net.minecraftforge.versions.forge.ForgeVersion;
@@ -27,10 +30,15 @@ import java.util.function.Supplier;
public class MinecraftForge {
/**
* The EventBus for all the Forge Events.
* A helper for partial source-level back-compat with the old event system used in 1.21.5 and older, that acts as
* a wrapper around {@link BusGroup#DEFAULT}.
*
* Events marked with {@link net.minecraftforge.fml.event.IModBusEvent}
* belong on the ModBus and not this bus
* <p>Please refer to the javadocs for {@link EventBusMigrationHelper} for further information and resources on how
* to properly migrate your mod to the new event system.</p>
*
* <p>Events marked with {@link IModBusEvent} belong on the
* {@linkplain FMLJavaModLoadingContext#getModBusGroup() mod BusGroup} and not on the
* {@linkplain BusGroup#DEFAULT default BusGroup}.</p>
*/
public static final EventBusMigrationHelper EVENT_BUS = EventBusMigrationHelper.INSTANCE;
@@ -54,7 +62,7 @@ public class MinecraftForge {
* @param screenFunction A function that takes the mods screen as an argument and returns your config screen to
* show when the player clicks the config button for your mod on the mods screen.
* <p>You should call {@link Minecraft#setScreen(Screen)} with the provided mods screen for the
* action of your close button, using {@link Screen#minecraft} to get the client instance.</p>
* action of your close button, using {@link Screen#getMinecraft()} to get the client instance.</p>
* @see ModLoadingContext#registerExtensionPoint(Class, Supplier)
* @see ModLoadingContext#registerConfig(ModConfig.Type, IConfigSpec)
*/
@@ -10,6 +10,7 @@ import java.util.Objects;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jspecify.annotations.NullMarked;
import org.objectweb.asm.Type;
@@ -24,17 +25,18 @@ import org.objectweb.asm.Type;
public record RegisterCapabilitiesEvent() implements RecordEvent {
public static final EventBus<RegisterCapabilitiesEvent> BUS = EventBus.create(RegisterCapabilitiesEvent.class);
/** @deprecated {@link RegisterCapabilitiesEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterCapabilitiesEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
/**
* Registers a capability to be consumed by others.
* APIs who define the capability should call this.
* This is meant to allow Capability consumers to have soft dependencies on the Capability type.
* But be automatically notified when the Class actually exists. Meaning it's safe to create their implementations.
*
* Registers a capability to be consumed by others.<br>
* APIs who define the capability should call this.<br>
* This is meant to allow Capability consumers to have soft dependencies on the Capability type.<br>
* But be automatically notified when the Class actually exists. Meaning it's safe to create their implementations.<br>
* <br>
* To retrieve the Capability instance, use the {@link CapabilityManager} gets functions.
*/
public <T> void register(Class<T> type) {
@@ -11,6 +11,7 @@ import net.minecraft.server.packs.repository.RepositorySource;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.event.IModBusEvent;
import java.util.function.Consumer;
@@ -22,6 +23,7 @@ import java.util.function.Consumer;
public record AddPackFindersEvent(PackType getPackType, Consumer<RepositorySource> sourceAdder) implements RecordEvent {
public static final EventBus<AddPackFindersEvent> BUS = EventBus.create(AddPackFindersEvent.class);
/** @deprecated {@link AddPackFindersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<AddPackFindersEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -15,6 +15,7 @@ import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -38,6 +39,7 @@ public record BuildCreativeModeTabContentsEvent(
) implements RecordEvent, CreativeModeTab.Output {
public static final EventBus<BuildCreativeModeTabContentsEvent> BUS = EventBus.create(BuildCreativeModeTabContentsEvent.class);
/** @deprecated {@link BuildCreativeModeTabContentsEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<BuildCreativeModeTabContentsEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -6,15 +6,13 @@
package net.minecraftforge.event;
import net.minecraft.world.Difficulty;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
/**
* DifficultyChangeEvent is fired when difficulty is changing. <br>
* <br>
* This event is fired via the {@link ForgeHooks#onDifficultyChange(Difficulty, Difficulty)}.<br>
* This event is fired via the {@link ForgeEventFactory#onDifficultyChange(Difficulty, Difficulty)}.<br>
*/
public record DifficultyChangeEvent(Difficulty getDifficulty, Difficulty getOldDifficulty) implements RecordEvent {
public static final EventBus<DifficultyChangeEvent> BUS = EventBus.create(DifficultyChangeEvent.class);
@@ -58,7 +58,7 @@ public abstract sealed class GrindstoneEvent extends MutableEvent implements Inh
}
/**
* This event is {@link Cancelable} <br>
* This event is {@link Cancellable} <br>
* {@link OnPlaceItem} is fired when the inputs to a grindstone are changed. <br>
*
* The following rules apply:
@@ -72,7 +72,7 @@ public abstract sealed class GrindstoneEvent extends MutableEvent implements Inh
* <li>Vanilla XP calculation logic will be used unless all of the following criterias are met:</li>
* <ul>
* <li>the amount of experience is greater than or equal to {@code 0};</li>
* <li>the event is not {@linkplain #isCanceled() canceled};</li>
* <li>the event is not {@linkplain Cancellable cancelled};</li>
* <li>the {@linkplain #getOutput() output} is not empty.</li>
* </ul>
* </ul>
@@ -108,7 +108,7 @@ public abstract sealed class GrindstoneEvent extends MutableEvent implements Inh
}
/**
* This event is {@link Cancelable} <br>
* This event is {@link Cancellable} <br>
* {@link OnTakeItem} is fired when the output in a grindstone are is taken. <br>
* It is called from {@link GrindstoneMenu#GrindstoneMenu(int, Inventory)}. <br>
* If the event is canceled, vanilla behavior will not run, and no inputs will be consumed. <br>
@@ -35,8 +35,7 @@ import java.util.stream.Stream;
* unsafe to access server or level information during handling of this event.
* </p>
*
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModBusGroup() mod BusGroup},
* on both {@linkplain LogicalSide logical sides}.</p>
*/
public final class ModMismatchEvent implements IModBusEvent {
@@ -141,8 +141,8 @@ public sealed class PlayLevelSoundEvent extends MutableEvent implements Cancella
* PlayLevelSoundEvent.AtEntity is fired when a sound is played on the {@link Level} at an {@link Entity Entity}'s position.
* This event is fired from {@link Level#playSound}, {@link Level#playSeededSound}, and {@link LocalPlayer#playSound}.
* <p>
* This event is {@link Cancelable cancelable}.
* If this event is canceled, the sound is not played.
* This event is {@link Cancellable cancellable}.
* If this event is cancelled, the sound is not played.
* <p>
* This event does not have a result.
* <p>
@@ -170,8 +170,8 @@ public sealed class PlayLevelSoundEvent extends MutableEvent implements Cancella
* PlayLevelSoundEvent.AtPosition is fired when a sound is played on the {@link Level} at a specific position.
* This event is fired from {@link Level#playSound} and {@link Level#playSeededSound}.
* <p>
* This event is {@link Cancelable cancelable}.
* If this event is canceled, the sound is not played.
* This event is {@link Cancellable cancellable}.
* If this event is cancelled, the sound is not played.
* <p>
* This event does not have a result.
* <p>
@@ -48,10 +48,8 @@ public sealed abstract class PotionBrewEvent extends MutableEvent implements Inh
* <br>
* {@link #stacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.<br>
* <br>
* This event is {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* If the event is not canceled, the vanilla brewing will take place instead of modded brewing.
* <br>
* This event does not have a result. {@link HasResult}<br>
* This event is {@link Cancellable}.<br>
* If the event is not cancelled, the vanilla brewing will take place instead of modded brewing.
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
* <br>
@@ -72,10 +70,6 @@ public sealed abstract class PotionBrewEvent extends MutableEvent implements Inh
* <br>
* {@link #stacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.<br>
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static final class Post extends PotionBrewEvent {
@@ -14,6 +14,7 @@ import net.minecraft.world.entity.ai.attributes.DefaultAttributes;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.fml.event.IModBusEvent;
/**
* EntityAttributeCreationEvent.<br>
@@ -23,6 +24,7 @@ import net.minecraftforge.eventbus.api.event.MutableEvent;
public final class EntityAttributeCreationEvent extends MutableEvent {
public static final EventBus<EntityAttributeCreationEvent> BUS = EventBus.create(EntityAttributeCreationEvent.class);
/** @deprecated {@link EntityAttributeCreationEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<EntityAttributeCreationEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -14,6 +14,7 @@ import net.minecraft.world.entity.ai.attributes.DefaultAttributes;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.List;
@@ -27,6 +28,7 @@ import java.util.Map;
public final class EntityAttributeModificationEvent extends MutableEvent {
public static final EventBus<EntityAttributeModificationEvent> BUS = EventBus.create(EntityAttributeModificationEvent.class);
/** @deprecated {@link EntityAttributeModificationEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<EntityAttributeModificationEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -11,7 +11,7 @@ import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
/**
* EntityEvent is fired when an event involving any Entity occurs.
* EntityEvent is a marker interface for when an event involving any Entity occurs.
*/
public interface EntityEvent {
/**
@@ -23,7 +23,7 @@ import net.minecraftforge.fml.LogicalSide;
* You will cause chunk loading deadlocks if you do not delay your world interactions.
* <p>
* This event is {@linkplain Cancellable cancellable}.
* If the event is canceled, the entity will not be added to the level.
* If the event is cancelled, the entity will not be added to the level.
* <p>
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
* on both logical sides.
@@ -20,6 +20,7 @@ import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.listener.Priority;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.ApiStatus;
@@ -41,6 +42,7 @@ import org.jetbrains.annotations.ApiStatus;
public final class SpawnPlacementRegisterEvent extends MutableEvent {
public static final EventBus<SpawnPlacementRegisterEvent> BUS = EventBus.create(SpawnPlacementRegisterEvent.class);
/** @deprecated {@link SpawnPlacementRegisterEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<SpawnPlacementRegisterEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -30,12 +30,10 @@ import org.jetbrains.annotations.Nullable;
* {@link #causedByPlayer} contains the player responsible for the breading (if applicable).<br>
* {@link #child} contains the child that will be spawned.<br>
* <br>
* This event is {@link Cancelable}.<br>
* If this event is canceled, the child Entity is not added to the world, and the parents <br>
* This event is {@link Cancellable}.<br>
* If this event is cancelled, the child Entity is not added to the world, and the parents <br>
* will no longer attempt to mate.
* <br>
* This event does not have a result. {@link HasResult}<br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
public final class BabyEntitySpawnEvent extends MutableEvent implements Cancellable {
@@ -22,7 +22,7 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
* This event is fired via the {@link ForgeHooks#onLivingAttack(LivingEntity, DamageSource, float)}.<br>
* <br>
* This event is {@linkplain Cancellable cancellable}.<br>
* If this event is canceled, the Entity does not take attack damage.
* If this event is cancelled, the Entity does not take attack damage.
*
* @param getSource the source of the attack
* @param getAmount the amount of damage dealt to the entity
@@ -20,7 +20,7 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
* This event is fired whenever an Entity dies and drops items in
* {@link LivingEntity#die(DamageSource)}.<br>
* <br>
* This event is fired via the {@link ForgeEventFactory#onLivingDrops(LivingEntity, DamageSource, Collection, int, boolean)} .<br>
* This event is fired via the {@link ForgeEventFactory#onLivingDrops(LivingEntity, DamageSource, Collection, boolean)}.<br>
* <br>
* @param getSource contains the DamageSource that caused the drop to occur.
* @param getDrops contains the ArrayList of EntityItems that will be dropped.
@@ -46,15 +46,16 @@ public sealed abstract class LivingEntityUseItemEvent extends MutableEvent imple
}
/**
* Fired when a player starts 'using' an item, typically when they hold right mouse.
* Fired when a player starts 'using' an item, typically when they hold right mouse.<br>
* Examples:
* Drawing a bow
* Eating Food
* Drinking Potions/Milk
* Guarding with a sword
*
* <ul>
* <li>Drawing a bow</li>
* <li>Eating food</li>
* <li>Drinking potions/milk</li>
* <li>Guarding with a sword</li>
* </ul>
* <p>
* Cancel the event, or set the duration or {@literal <} 0 to prevent it from processing.
*
*/
public static final class Start extends LivingEntityUseItemEvent implements Cancellable {
public static final CancellableEventBus<Start> BUS = CancellableEventBus.create(Start.class);
@@ -66,9 +67,8 @@ public sealed abstract class LivingEntityUseItemEvent extends MutableEvent imple
/**
* Fired every tick that a player is 'using' an item, see {@link Start} for info.
*
* <p>
* Cancel the event, or set the duration to {@literal <=} 0 to cause the player to stop using the item.
*
*/
public static final class Tick extends LivingEntityUseItemEvent implements Cancellable {
public static final CancellableEventBus<Tick> BUS = CancellableEventBus.create(Tick.class);
@@ -18,7 +18,7 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import org.jetbrains.annotations.Nullable;
/**
* LivingEvent is fired whenever an event involving a {@link LivingEntity} occurs.
* LivingEvent is a marker interface for whenever an event involving a {@link LivingEntity} occurs.
*/
public interface LivingEvent extends EntityEvent {
@Override
@@ -18,9 +18,9 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
* <br>
* This event is fired via the {@link net.minecraftforge.event.ForgeEventFactory#onLivingFall(LivingEntity, double, float)}.<br>
* <br>
* {@link #distance} contains the distance the Entity is to fall. If this event is canceled, this value is set to 0.0F.
* {@link #distance} contains the distance the Entity is to fall. If this event is cancelled, this value is set to 0.0F.
* <br>
* This event is {@linkplain Cancellable cancellable}. If this event is canceled, the Entity does not fall.
* This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the Entity does not fall.
**/
public final class LivingFallEvent extends MutableEvent implements Cancellable, LivingEvent {
public static final CancellableEventBus<LivingFallEvent> BUS = CancellableEventBus.create(LivingFallEvent.class);
@@ -69,12 +69,12 @@ public sealed interface MobEffectEvent extends LivingEvent, InheritableEvent {
/**
* This event is fired to check if a {@link MobEffectInstance} can be applied to an entity.
* This event is not {@link Cancelable}.
* This event {@link HasResult has a result}.
* <p>
* {@link Result#ALLOW ALLOW} will apply this mob effect.
* {@link Result#DENY DENY} will not apply this mob effect.
* {@link Result#DEFAULT DEFAULT} will run vanilla logic to determine if this mob effect is applicable in {@link LivingEntity#canBeAffected}.
* <p>This event {@link HasResult has a result}:</p>
* <ul>
* <li>{@link Result#ALLOW ALLOW} will apply this mob effect.</li>
* <li>{@link Result#DENY DENY} will not apply this mob effect.</li>
* <li>{@link Result#DEFAULT DEFAULT} will run vanilla logic to determine if this mob effect is applicable in {@link LivingEntity#canBeAffected}.</li>
* </ul>
*/
final class Applicable implements MobEffectEvent, HasResult {
public static final EventBus<Applicable> BUS = EventBus.create(Applicable.class);
@@ -39,22 +39,22 @@ public sealed abstract class ZombieEvent implements EntityEvent, InheritableEven
* SummonAidEvent is fired when a Zombie Entity is summoned.
* This event is fired whenever a Zombie Entity is summoned in
* {@code Zombie#actuallyHurt(DamageSource, float)}.
*
* <br>
* This event is fired via the {@link ForgeEventFactory#fireZombieSummonAid(Zombie, Level, int, int, int, LivingEntity, double)}.
*
* {@link #getCustomSummonedAid()} remains null, but can be populated with a custom EntityZombie which will be spawned.
* {@link #getLevel()} contains the world that this summoning is occurring in.
* {@link #getX()} contains the x-coordinate at which this summoning event is occurring.
* {@link #getY()} contains the y-coordinate at which this summoning event is occurring.
* {@link #getZ()} contains the z-coordinate at which this summoning event is occurring.
* {@link #getAttacker()} contains the living Entity that attacked and caused this event to fire.
* {@link #getSummonChance()} contains the likelihood that a Zombie would successfully be summoned.
*
* This event is not {@link Cancelable}.
*
* This event has a result. {@link HasResult}
* {@link Result#ALLOW} Zombie is summoned.
* {@link Result#DENY} Zombie is not summoned.
* <br>
* {@link #getCustomSummonedAid()} remains null, but can be populated with a custom EntityZombie which will be spawned.<br>
* {@link #getLevel()} contains the world that this summoning is occurring in.<br>
* {@link #getX()} contains the x-coordinate at which this summoning event is occurring.<br>
* {@link #getY()} contains the y-coordinate at which this summoning event is occurring.<br>
* {@link #getZ()} contains the z-coordinate at which this summoning event is occurring.<br>
* {@link #getAttacker()} contains the living Entity that attacked and caused this event to fire.<br>
* {@link #getSummonChance()} contains the likelihood that a Zombie would successfully be summoned.<br>
* <br>
* This event {@linkplain HasResult has a result}:
* <ul>
* <li>{@link Result#ALLOW} Zombie is summoned.</li>
* <li>{@link Result#DENY} Zombie is not summoned.</li>
* </ul>
*
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/
@@ -5,7 +5,6 @@
package net.minecraftforge.event.entity.player;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.world.entity.player.Player;
@@ -46,8 +45,8 @@ public sealed interface AdvancementEvent extends PlayerEvent {
* @param getProgressType the type of progress for the criterion in this event
*
* @see AdvancementEarnEvent
* @see net.minecraft.server.PlayerAdvancements#award(Advancement, String)
* @see net.minecraft.server.PlayerAdvancements#revoke(Advancement, String)
* @see net.minecraft.server.PlayerAdvancements#award(AdvancementHolder, String)
* @see net.minecraft.server.PlayerAdvancements#revoke(AdvancementHolder, String)
*/
record AdvancementProgressEvent(
Player getEntity,
@@ -16,7 +16,7 @@ import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
* This event is fired whenever a player attacks an Entity in
* {@link Player#attack(Entity)}.<br>
* <br>
* {@link #target} contains the Entity that was damaged by the player. <br>
* {@link #getTarget()} contains the Entity that was damaged by the player. <br>
* <br>
* This event is {@linkplain Cancellable cancellable}. If this event is cancelled, the player does not attack the Entity.
**/
@@ -16,10 +16,12 @@ import net.minecraftforge.eventbus.api.event.MutableEvent;
* This event is fired whenever a player attacks an Entity in
* EntityPlayer#attackTargetEntityWithCurrentItem(Entity).<br>
* <br>
* This event has a result. {@link HasResult}<br>
* DEFAULT: means the vanilla logic will determine if this a critical hit.<br>
* DENY: it will not be a critical hit but the player still will attack<br>
* ALLOW: this attack is forced to be critical
* This event {@linkplain HasResult has a result}:
* <ul>
* <li>{@link Result#DEFAULT}: means the vanilla logic will determine if this a critical hit.</li>
* <li>{@link Result#DENY}: it will not be a critical hit but the player still will attack</li>
* <li>{@link Result#ALLOW}: this attack is forced to be critical</li>
* </ul>
**/
public final class CriticalHitEvent extends MutableEvent implements PlayerEvent, HasResult {
public static final EventBus<CriticalHitEvent> BUS = EventBus.create(CriticalHitEvent.class);
@@ -9,12 +9,14 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.InheritableEvent;
import org.jspecify.annotations.NullMarked;
public sealed interface PlayerContainerEvent extends PlayerEvent, InheritableEvent {
EventBus<PlayerContainerEvent> BUS = EventBus.create(PlayerContainerEvent.class);
AbstractContainerMenu getContainer();
@NullMarked
record Open(Player getEntity, AbstractContainerMenu getContainer) implements PlayerContainerEvent {
public static final EventBus<Open> BUS = EventBus.create(Open.class);
}
@@ -32,10 +32,8 @@ import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
/**
* PlayerEvent is fired whenever an event involving a {@link Player} occurs. <br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
**/
* PlayerEvent is a marker interface for whenever an event involving a {@link Player} occurs.
*/
public interface PlayerEvent extends LivingEvent {
@Override
Player getEntity();
@@ -317,6 +315,7 @@ public interface PlayerEvent extends LivingEvent {
public static final EventBus<ItemSmeltedEvent> BUS = EventBus.create(ItemSmeltedEvent.class);
}
@NullMarked
record PlayerLoggedInEvent(Player getEntity) implements RecordEvent, PlayerEvent {
public static final EventBus<PlayerLoggedInEvent> BUS = EventBus.create(PlayerLoggedInEvent.class);
}
@@ -325,6 +324,7 @@ public interface PlayerEvent extends LivingEvent {
public static final EventBus<PlayerLoggedOutEvent> BUS = EventBus.create(PlayerLoggedOutEvent.class);
}
@NullMarked
record PlayerRespawnEvent(Player getEntity, boolean isEndConquered) implements RecordEvent, PlayerEvent {
public static final EventBus<PlayerRespawnEvent> BUS = EventBus.create(PlayerRespawnEvent.class);
@@ -9,25 +9,22 @@ import net.minecraft.world.entity.ExperienceOrb;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
import org.jspecify.annotations.NullMarked;
/**
* PlayerXpEvent is fired whenever an event involving player experience occurs. <br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
* PlayerXpEvent is fired whenever an event involving player experience occurs.
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
*/
@NullMarked
public sealed interface PlayerXpEvent extends PlayerEvent {
/**
* This event is fired after the player collides with an experience orb, but before the player has been given the experience.
* It can be cancelled, and no further processing will be done.
*/
@NullMarked
record PickupXp(Player getEntity, ExperienceOrb getOrb) implements Cancellable, PlayerXpEvent, RecordEvent {
public static final CancellableEventBus<PickupXp> BUS = CancellableEventBus.create(PickupXp.class);
}
@@ -36,7 +33,6 @@ public sealed interface PlayerXpEvent extends PlayerEvent {
* This event is fired when the player's experience changes through the {@link Player#giveExperiencePoints(int)} method.
* It can be cancelled, and no further processing will be done.
*/
@NullMarked
final class XpChange extends MutableEvent implements Cancellable, PlayerXpEvent {
public static final CancellableEventBus<XpChange> BUS = CancellableEventBus.create(XpChange.class);
@@ -66,7 +62,6 @@ public sealed interface PlayerXpEvent extends PlayerEvent {
* This event is fired when the player's experience level changes through the {@link Player#giveExperienceLevels(int)} method.
* It can be cancelled, and no further processing will be done.
*/
@NullMarked
final class LevelChange extends MutableEvent implements Cancellable, PlayerXpEvent {
public static final CancellableEventBus<LevelChange> BUS = CancellableEventBus.create(LevelChange.class);
@@ -21,10 +21,11 @@ import net.minecraftforge.eventbus.api.event.MutableEvent;
* This event is fired when game checks, if sleeping player should be still considered "in bed".<br>
* Failing this check will cause player to wake up.<br>
*
* This event has a result. {@link HasResult}<br>
*
* setResult(ALLOW) informs game that player is still "in bed"<br>
* setResult(DEFAULT) causes game to check {@link Block#isBed(BlockState, BlockGetter, BlockPos, Entity)} instead
* <p>This event {@linkplain HasResult has a result}:</p>
* <ul>
* <li>{@link Result#ALLOW}: informs game that player is still "in bed"</li>
* <li>{@link Result#DEFAULT}: causes game to check {@link Block#isBed(BlockState, BlockGetter, BlockPos, Entity)} instead</li>
* </ul>
*/
public final class SleepingLocationCheckEvent extends MutableEvent implements LivingEvent, HasResult {
public static final EventBus<SleepingLocationCheckEvent> BUS = EventBus.create(SleepingLocationCheckEvent.class);
@@ -33,6 +33,7 @@ public sealed interface DataPackRegistryEvent {
final class NewRegistry extends MutableEvent implements DataPackRegistryEvent {
public static final EventBus<NewRegistry> BUS = EventBus.create(NewRegistry.class);
/** @deprecated {@link DataPackRegistryEvent.NewRegistry} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<NewRegistry> getBus(BusGroup modBusGroup) {
return BUS;
@@ -17,6 +17,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
@@ -26,6 +27,7 @@ import org.slf4j.Logger;
public final class NewRegistryEvent extends MutableEvent {
public static final EventBus<NewRegistryEvent> BUS = EventBus.create(NewRegistryEvent.class);
/** @deprecated {@link NewRegistryEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<NewRegistryEvent> getBus(BusGroup modBusGroup) {
return BUS;
@@ -12,6 +12,7 @@ import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -21,7 +22,7 @@ import java.util.function.Supplier;
/**
* This event fires for each forge and vanilla registry when all registries are ready to have modded objects registered.
* <p>
* Fired on the {@link IModBusEvent mod bus}.
* Fired on the {@linkplain FMLJavaModLoadingContext#getModBusGroup() mod BusGroup}.
*
* @see #register(ResourceKey, ResourceLocation, Supplier)
* @see #register(ResourceKey, Consumer)