Package net.neoforged.neoforge.event
Class VanillaGameEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.VanillaGameEvent
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
public class VanillaGameEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.bus.api.ICancellableEvent
VanillaGameEvent is fired on the server whenever one of Vanilla's
This allows for listening to Vanilla's events in a more structured and global way that is not tied to needing a block entity listener.
This event is fired on the
Cancel this event to prevent Vanilla from posting the
GameEvents
fire. This allows for listening to Vanilla's events in a more structured and global way that is not tied to needing a block entity listener.
This event is fired on the
NeoForge.EVENT_BUS
. Cancel this event to prevent Vanilla from posting the
GameEvent
to all nearby GameEventListeners
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final net.minecraft.world.level.gameevent.GameEvent.Context
private final net.minecraft.world.level.Level
private final net.minecraft.world.phys.Vec3
private final net.minecraft.core.Holder
<net.minecraft.world.level.gameevent.GameEvent> -
Constructor Summary
ConstructorsConstructorDescriptionVanillaGameEvent
(net.minecraft.world.level.Level level, net.minecraft.core.Holder<net.minecraft.world.level.gameevent.GameEvent> vanillaEvent, net.minecraft.world.phys.Vec3 position, net.minecraft.world.level.gameevent.GameEvent.Context context) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
level
private final net.minecraft.world.level.Level level -
vanillaEvent
private final net.minecraft.core.Holder<net.minecraft.world.level.gameevent.GameEvent> vanillaEvent -
position
private final net.minecraft.world.phys.Vec3 position -
context
private final net.minecraft.world.level.gameevent.GameEvent.Context context
-
-
Constructor Details
-
VanillaGameEvent
public VanillaGameEvent(net.minecraft.world.level.Level level, net.minecraft.core.Holder<net.minecraft.world.level.gameevent.GameEvent> vanillaEvent, net.minecraft.world.phys.Vec3 position, net.minecraft.world.level.gameevent.GameEvent.Context context)
-
-
Method Details
-
getLevel
public net.minecraft.world.level.Level getLevel()- Returns:
- The level the Vanilla
GameEvent
occurred.
-
getCause
@Nullable public @Nullable net.minecraft.world.entity.Entity getCause()- Returns:
- The entity that was the source or "cause" of the
GameEvent
.
-
getVanillaEvent
public net.minecraft.core.Holder<net.minecraft.world.level.gameevent.GameEvent> getVanillaEvent()- Returns:
- The Vanilla event.
-
getEventPosition
public net.minecraft.world.phys.Vec3 getEventPosition()- Returns:
- The position the event took place at.
-
getContext
public net.minecraft.world.level.gameevent.GameEvent.Context getContext()- Returns:
- the context of the vanilla event
-