Class EventHooks
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final WeightedRandomList
<MobSpawnSettings.SpawnerData> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionalterGround
(TreeDecorator.Context ctx, List<BlockPos> positions, AlterGroundEvent.StateProvider provider) Fires theAlterGroundEvent
and retrieves the resultingAlterGroundEvent.StateProvider
.static boolean
canCreateFluidSource
(Level level, BlockPos pos, BlockState state) Checks if a fluid is allowed to create a fluid source.static boolean
canEntityContinueSleeping
(LivingEntity sleeper, @Nullable Player.BedSleepingProblem problem) Checks if a sleeping entity can continue sleeping with the given sleeping problem.static boolean
canEntityGrief
(Level level, @Nullable Entity entity) Checks if an entity can perform a griefing action.static boolean
canLivingConvert
(LivingEntity entity, EntityType<? extends LivingEntity> outcome, Consumer<Integer> timer) static boolean
canMountEntity
(Entity entityMounting, Entity entityBeingMounted, boolean isMounting) static com.mojang.datafixers.util.Either
<Player.BedSleepingProblem, Unit> canPlayerStartSleeping
(ServerPlayer player, BlockPos pos, com.mojang.datafixers.util.Either<Player.BedSleepingProblem, Unit> vanillaResult) static boolean
checkMobDespawn
(Mob mob) FiresMobDespawnEvent
and returns true if the default logic should be ignored.static boolean
checkSpawnPlacements
(EntityType<?> entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) static boolean
checkSpawnPosition
(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType) Checks if the current position of the passed mob is valid for spawning, by firingMobSpawnEvent.PositionCheck
.
The default check is to perform the logical and ofMob.checkSpawnRules(net.minecraft.world.level.LevelAccessor, net.minecraft.world.entity.MobSpawnType)
andMob.checkSpawnObstruction(net.minecraft.world.level.LevelReader)
.static boolean
checkSpawnPositionSpawner
(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, SpawnData spawnData, BaseSpawner spawner) Specialized variant ofcheckSpawnPosition(net.minecraft.world.entity.Mob, net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.entity.MobSpawnType)
for spawners, as they have slightly different checks, and pass through theBaseSpawner
to the event.static boolean
doPlayerHarvestCheck
(Player player, BlockState state, BlockGetter level, BlockPos pos) static @Nullable SpawnGroupData
finalizeMobSpawn
(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnData) Finalizes the spawn of a mob by firing theFinalizeSpawnEvent
and callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
with the result.static FinalizeSpawnEvent
finalizeMobSpawnSpawner
(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnData, IOwnedSpawner spawner, boolean def) Finalizes the spawn of a mob by firing theFinalizeSpawnEvent
and callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
with the result.static BlockGrowFeatureEvent
fireBlockGrowFeature
(LevelAccessor level, RandomSource rand, BlockPos pos, @Nullable Holder<ConfiguredFeature<?, ?>> holder) Fires theBlockGrowFeatureEvent
and returns the event object.static BonemealEvent
fireBonemealEvent
(@Nullable Player player, Level level, BlockPos pos, BlockState state, ItemStack stack) Called when bone meal (or equivalent) is used on a block.static void
fireChunkSent
(ServerPlayer entity, LevelChunk chunk, ServerLevel level) static void
fireChunkTicketLevelUpdated
(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder) static void
fireChunkUnWatch
(ServerPlayer entity, ChunkPos chunkpos, ServerLevel level) static void
fireChunkWatch
(ServerPlayer entity, LevelChunk chunk, ServerLevel level) static void
fireEntityTickPost
(Entity entity) FiresEntityTickEvent.Post
.static EntityTickEvent.Pre
fireEntityTickPre
(Entity entity) FiresEntityTickEvent.Pre
.static BlockState
fireFluidPlaceBlockEvent
(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) static void
fireItemPickupPost
(ItemEntity itemEntity, Player player, ItemStack copy) Called inItemEntity.playerTouch(Player)
after an item was successfully picked up.static ItemEntityPickupEvent.Pre
fireItemPickupPre
(ItemEntity itemEntity, Player player) Called inItemEntity.playerTouch(Player)
before any other processing occurs.static void
fireLevelTickPost
(Level level, BooleanSupplier haveTime) FiresLevelTickEvent.Post
.static void
fireLevelTickPre
(Level level, BooleanSupplier haveTime) FiresLevelTickEvent.Pre
.static void
firePlayerChangedDimensionEvent
(Player player, ResourceKey<Level> fromDim, ResourceKey<Level> toDim) static void
firePlayerCraftingEvent
(Player player, ItemStack crafted, Container craftMatrix) static Gui.HeartType
firePlayerHeartTypeEvent
(Player player, Gui.HeartType heartType) Called byGui.HeartType.forPlayer(net.minecraft.world.entity.player.Player)
to allow for modification of the displayed heart type in the health bar.static void
firePlayerLoadingEvent
(Player player, File playerDirectory, String uuidString) static void
firePlayerLoadingEvent
(Player player, PlayerDataStorage playerFileData, String uuidString) static void
firePlayerLoggedIn
(Player player) static void
firePlayerLoggedOut
(Player player) static void
firePlayerRespawnEvent
(ServerPlayer player, boolean fromEndFight) Called byPlayerList.respawn(ServerPlayer, boolean)
after creating and initializing the newServerPlayer
.static PlayerRespawnPositionEvent
firePlayerRespawnPositionEvent
(ServerPlayer player, ServerLevel respawnLevel, float respawnAngle, @Nullable Vec3 respawnPosition, boolean fromEndFight) Called byPlayerList.respawn(ServerPlayer, boolean)
before creating the newServerPlayer
to fire thePlayerRespawnPositionEvent
static void
firePlayerSavingEvent
(Player player, File playerDirectory, String uuidString) static void
firePlayerSmeltedEvent
(Player player, ItemStack smelted) static PlayerSpawnPhantomsEvent
firePlayerSpawnPhantoms
(ServerPlayer player, ServerLevel level, BlockPos pos) Called fromPhantomSpawner.tick(net.minecraft.server.level.ServerLevel, boolean, boolean)
just before the spawn conditions for phantoms are evaluated.static void
firePlayerTickPost
(Player player) FiresPlayerTickEvent.Post
.static void
firePlayerTickPre
(Player player) FiresPlayerTickEvent.Pre
.static void
fireServerTickPost
(BooleanSupplier haveTime, MinecraftServer server) FiresServerTickEvent.Post
.static void
fireServerTickPre
(BooleanSupplier haveTime, MinecraftServer server) FiresServerTickEvent.Pre
.static float
getBreakSpeed
(Player player, BlockState state, float original, BlockPos pos) static ItemEnchantments
getEnchantmentLevel
(ItemEnchantments enchantments, ItemStack stack) FiresGetEnchantmentLevelEvent
and for all enchantments, returning the (possibly event-modified) enchantment map.static int
getEnchantmentLevelSpecific
(int level, ItemStack stack, Enchantment ench) FiresGetEnchantmentLevelEvent
and for a single enchantment, returning the (possibly event-modified) level.static EntityEvent.Size
getEntitySizeForge
(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) static EntityEvent.Size
getEntitySizeForge
(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight) static int
getExperienceDrop
(LivingEntity entity, Player attackingPlayer, int originalExperience) static Vec3
getExplosionKnockback
(Level level, Explosion explosion, Entity entity, Vec3 initialVelocity) To be called when an explosion has calculated the knockback velocity but has not yet added the knockback to the entity caught in blast.static int
getItemBurnTime
(ItemStack itemStack, int burnTime, @Nullable RecipeType<?> recipeType) static int
getMaxSpawnClusterSize
(Mob entity) FiresSpawnClusterSizeEvent
and returns the size as a result of the event.static Component
getPlayerDisplayName
(Player player, Component username) static Component
getPlayerTabListDisplayName
(Player player) getPotentialSpawns
(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList<MobSpawnSettings.SpawnerData> oldList) static LootTable
loadLootTable
(ResourceLocation name, LootTable table) static void
onAdvancementEarnedEvent
(Player player, AdvancementHolder earned) static void
onAdvancementProgressedEvent
(Player player, AdvancementHolder progressed, AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) static boolean
onAnimalTame
(Animal animal, Player tamer) static int
onArrowLoose
(ItemStack stack, Level level, Player player, int charge, boolean hasAmmo) static InteractionResultHolder
<ItemStack> onArrowNock
(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) static boolean
onBlockPlace
(@Nullable Entity entity, BlockSnapshot blockSnapshot, Direction direction) onChorusFruitTeleport
(LivingEntity entity, double targetX, double targetY, double targetZ) static void
onCommandRegister
(com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment, CommandBuildContext context) static boolean
onCreateWorldSpawn
(Level level, ServerLevelData settings) static void
onCreativeModeTabBuildContents
(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) Fires theBuildCreativeModeTabContentsEvent
.static boolean
onEffectRemoved
(LivingEntity entity, Holder<MobEffect> effect, @Nullable EffectCure cure) static boolean
onEffectRemoved
(LivingEntity entity, MobEffectInstance effectInstance, @Nullable EffectCure cure) static int
onEnchantmentLevelSet
(Level level, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int enchantmentLevel) onEnderPearlLand
(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult) onEnderTeleport
(LivingEntity entity, double targetX, double targetY, double targetZ) static boolean
onEntityDestroyBlock
(LivingEntity entity, BlockPos pos, BlockState state) static boolean
onEntityStruckByLightning
(Entity entity, LightningBolt bolt) onEntityTeleportCommand
(Entity entity, double targetX, double targetY, double targetZ) onEntityTeleportSpreadPlayersCommand
(Entity entity, double targetX, double targetY, double targetZ) static void
onExplosionDetonate
(Level level, Explosion explosion, List<Entity> list, double diameter) static boolean
onExplosionStart
(Level level, Explosion explosion) static int
onItemExpire
(ItemEntity entity, ItemStack item) static ItemTooltipEvent
onItemTooltip
(ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags, Item.TooltipContext context) static ItemStack
onItemUseFinish
(LivingEntity entity, ItemStack item, int duration, ItemStack result) static int
onItemUseStart
(LivingEntity entity, ItemStack item, int duration) static int
onItemUseTick
(LivingEntity entity, ItemStack item, int duration) static void
onLivingConvert
(LivingEntity entity, LivingEntity outcome) static float
onLivingHeal
(LivingEntity entity, float amount) static MobSplitEvent
onMobSplit
(Mob parent, List<Mob> children) Fires the mob split event.static boolean
onMultiBlockPlace
(@Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction) onNeighborNotify
(Level level, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate) static boolean
onPermissionChanged
(com.mojang.authlib.GameProfile gameProfile, int newLevel, PlayerList playerList) static void
onPistonMovePost
(Level level, BlockPos pos, Direction direction, boolean extending) static boolean
onPistonMovePre
(Level level, BlockPos pos, Direction direction, boolean extending) static void
onPlayerBrewedPotion
(Player player, ItemStack stack) static void
onPlayerClone
(Player player, Player oldPlayer, boolean wasDeath) static void
onPlayerDestroyItem
(Player player, ItemStack stack, @Nullable InteractionHand hand) static void
onPlayerFall
(Player player, float distance, float multiplier) static boolean
onPlayerSpawnSet
(Player player, ResourceKey<Level> levelKey, BlockPos pos, boolean forced) static void
onPlayerWakeup
(Player player, boolean wakeImmediately, boolean updateLevel) static PlayLevelSoundEvent.AtEntity
onPlaySoundAtEntity
(Entity entity, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) onPlaySoundAtPosition
(Level level, double x, double y, double z, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) static boolean
onPotionAttemptBrew
(NonNullList<ItemStack> stacks) static void
onPotionBrewed
(NonNullList<ItemStack> brewingItemStacks) static boolean
onProjectileImpact
(Projectile projectile, HitResult ray) static List
<PreparableReloadListener> onResourceReload
(ReloadableServerResources serverResources, RegistryAccess registryAccess) static long
onSleepFinished
(ServerLevel level, long newTime, long minTime) static void
onStartEntityTracking
(Entity entity, Player player) static StatAwardEvent
onStatAward
(Player player, Stat<?> stat, int value) static void
onStopEntityTracking
(Entity entity, Player player) static @Nullable BlockState
onToolUse
(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) static Optional
<PortalShape> onTrySpawnPortal
(LevelAccessor level, BlockPos pos, Optional<PortalShape> size) static boolean
onUseItemStop
(LivingEntity entity, ItemStack item, int duration)
-
Field Details
-
NO_SPAWNS
-
-
Constructor Details
-
EventHooks
public EventHooks()
-
-
Method Details
-
onMultiBlockPlace
public static boolean onMultiBlockPlace(@Nullable @Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction) -
onBlockPlace
public static boolean onBlockPlace(@Nullable @Nullable Entity entity, BlockSnapshot blockSnapshot, Direction direction) -
onNeighborNotify
public static BlockEvent.NeighborNotifyEvent onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate) -
doPlayerHarvestCheck
public static boolean doPlayerHarvestCheck(Player player, BlockState state, BlockGetter level, BlockPos pos) -
getBreakSpeed
-
onPlayerDestroyItem
public static void onPlayerDestroyItem(Player player, ItemStack stack, @Nullable @Nullable InteractionHand hand) -
checkSpawnPlacements
@Internal public static boolean checkSpawnPlacements(EntityType<?> entityType, ServerLevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) Internal, should only be called viaSpawnPlacements.checkSpawnRules(net.minecraft.world.entity.EntityType<T>, net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.entity.MobSpawnType, net.minecraft.core.BlockPos, net.minecraft.util.RandomSource)
.- See Also:
-
checkSpawnPosition
public static boolean checkSpawnPosition(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType) Checks if the current position of the passed mob is valid for spawning, by firingMobSpawnEvent.PositionCheck
.
The default check is to perform the logical and ofMob.checkSpawnRules(net.minecraft.world.level.LevelAccessor, net.minecraft.world.entity.MobSpawnType)
andMob.checkSpawnObstruction(net.minecraft.world.level.LevelReader)
.- Parameters:
mob
- The mob being spawned.level
- The level the mob will be added to, if successful.spawnType
- The spawn type of the spawn.- Returns:
- True, if the position is valid, as determined by the contract of
MobSpawnEvent.PositionCheck
. - See Also:
-
checkSpawnPositionSpawner
public static boolean checkSpawnPositionSpawner(Mob mob, ServerLevelAccessor level, MobSpawnType spawnType, SpawnData spawnData, BaseSpawner spawner) Specialized variant ofcheckSpawnPosition(net.minecraft.world.entity.Mob, net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.entity.MobSpawnType)
for spawners, as they have slightly different checks, and pass through theBaseSpawner
to the event.- See Also:
-
finalizeMobSpawn
@Nullable public static @Nullable SpawnGroupData finalizeMobSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable @Nullable SpawnGroupData spawnData) Finalizes the spawn of a mob by firing theFinalizeSpawnEvent
and callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
with the result.Mods should call this method in place of calling
Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
, unless calling super from within an override. Vanilla calls toMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
are replaced with calls to this method via coremod, so calls to this method will not show in an IDE.When interfacing with this event, write all code as normal, and replace the call to
Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
with a call to this method.As an example, the following code block:
var zombie = new Zombie(level); zombie.finalizeSpawn(level, difficulty, spawnType, spawnData); level.tryAddFreshEntityWithPassengers(zombie); if (zombie.isAddedToWorld()) { // Do stuff with your new zombie }
var zombie = new Zombie(level); EventHooks.finalizeMobSpawn(zombie, level, difficulty, spawnType, spawnData); level.tryAddFreshEntityWithPassengers(zombie); if (zombie.isAddedToWorld()) { // Do stuff with your new zombie }
Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
call.- Parameters:
mob
- The mob whose spawn is being finalizedlevel
- The level the mob will be spawned indifficulty
- The local difficulty at the position of the mobspawnType
- The type of spawn that is occuringspawnData
- Optional spawn data relevant to the mob being spawned- Returns:
- The SpawnGroupData from the finalize, or null if it was canceled. The return value of this method has no bearing on if the entity will be spawned
- See Also:
-
finalizeMobSpawnSpawner
public static FinalizeSpawnEvent finalizeMobSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable @Nullable SpawnGroupData spawnData, IOwnedSpawner spawner, boolean def) Finalizes the spawn of a mob by firing theFinalizeSpawnEvent
and callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)
with the result.This method is separate since mob spawners perform special finalizeSpawn handling when NBT data is present, but we still want to fire the event.
This overload is also the only way to pass through an
IOwnedSpawner
instance.- Parameters:
mob
- The mob whose spawn is being finalizedlevel
- The level the mob will be spawned indifficulty
- The local difficulty at the position of the mobspawnType
- The type of spawn that is occuringspawnData
- Optional spawn data relevant to the mob being spawnedspawner
- The spawner that is attempting to spawn the mobdef
- If the spawner would normally call finalizeSpawn, regardless of the event
-
firePlayerSpawnPhantoms
public static PlayerSpawnPhantomsEvent firePlayerSpawnPhantoms(ServerPlayer player, ServerLevel level, BlockPos pos) Called fromPhantomSpawner.tick(net.minecraft.server.level.ServerLevel, boolean, boolean)
just before the spawn conditions for phantoms are evaluated. Fires thePlayerSpawnPhantomsEvent
and returns the event.- Parameters:
player
- The player for whom a spawn attempt is being madelevel
- The level of the playerpos
- The block position of the player
-
checkMobDespawn
FiresMobDespawnEvent
and returns true if the default logic should be ignored.- Parameters:
entity
- The entity being despawned.- Returns:
- True if the event result is not
MobDespawnEvent.Result.DEFAULT
, and the vanilla logic should be ignored.
-
getItemBurnTime
public static int getItemBurnTime(ItemStack itemStack, int burnTime, @Nullable @Nullable RecipeType<?> recipeType) -
getExperienceDrop
public static int getExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) -
getMaxSpawnClusterSize
FiresSpawnClusterSizeEvent
and returns the size as a result of the event.Called in
NaturalSpawner.spawnCategoryForPosition(net.minecraft.world.entity.MobCategory, net.minecraft.server.level.ServerLevel, net.minecraft.core.BlockPos)
whereMob.getMaxSpawnClusterSize()
would normally be called.- Parameters:
entity
- The entity whose max spawn cluster size is being queried.- Returns:
- The new spawn cluster size.
-
getPlayerDisplayName
-
getPlayerTabListDisplayName
-
fireFluidPlaceBlockEvent
public static BlockState fireFluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) -
onItemTooltip
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags, Item.TooltipContext context) -
onEntityStruckByLightning
-
onItemUseStart
-
onItemUseTick
-
onUseItemStop
-
onItemUseFinish
public static ItemStack onItemUseFinish(LivingEntity entity, ItemStack item, int duration, ItemStack result) -
onStartEntityTracking
-
onStopEntityTracking
-
firePlayerLoadingEvent
-
firePlayerSavingEvent
-
firePlayerLoadingEvent
public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) -
onToolUse
@Nullable public static @Nullable BlockState onToolUse(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) -
fireBonemealEvent
public static BonemealEvent fireBonemealEvent(@Nullable @Nullable Player player, Level level, BlockPos pos, BlockState state, ItemStack stack) Called when bone meal (or equivalent) is used on a block. Fires theBonemealEvent
and returns the event.- Parameters:
player
- The player who used the item, if anylevel
- The levelpos
- The position of the target blockstate
- The state of the target blockstack
- The bone meal item stack- Returns:
- The event
-
onPlaySoundAtEntity
public static PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(Entity entity, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) -
onPlaySoundAtPosition
public static PlayLevelSoundEvent.AtPosition onPlaySoundAtPosition(Level level, double x, double y, double z, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) -
onItemExpire
-
fireItemPickupPre
Called inItemEntity.playerTouch(Player)
before any other processing occurs.Fires
ItemEntityPickupEvent.Pre
and returns the event.- Parameters:
itemEntity
- The item entity that a player collided withplayer
- The player that collided with the item entity
-
fireItemPickupPost
Called inItemEntity.playerTouch(Player)
after an item was successfully picked up.Fires
ItemEntityPickupEvent.Post
.- Parameters:
itemEntity
- The item entity that a player collided withplayer
- The player that collided with the item entitycopy
- A copy of the item entity's item stack before the pickup
-
canMountEntity
-
onAnimalTame
-
canPlayerStartSleeping
public static com.mojang.datafixers.util.Either<Player.BedSleepingProblem,Unit> canPlayerStartSleeping(ServerPlayer player, BlockPos pos, com.mojang.datafixers.util.Either<Player.BedSleepingProblem, Unit> vanillaResult) -
onPlayerWakeup
-
onPlayerFall
-
onPlayerSpawnSet
public static boolean onPlayerSpawnSet(Player player, ResourceKey<Level> levelKey, BlockPos pos, boolean forced) -
onPlayerClone
-
onExplosionStart
-
onExplosionDetonate
-
getExplosionKnockback
public static Vec3 getExplosionKnockback(Level level, Explosion explosion, Entity entity, Vec3 initialVelocity) To be called when an explosion has calculated the knockback velocity but has not yet added the knockback to the entity caught in blast.- Parameters:
level
- The level that the explosion is inexplosion
- Explosion that is happeningentity
- The entity caught in the explosion's blastinitialVelocity
- The explosion calculated velocity for the entity- Returns:
- The new explosion velocity to add to the entity's existing velocity
-
onCreateWorldSpawn
-
onLivingHeal
-
onPotionAttemptBrew
-
onPotionBrewed
-
onPlayerBrewedPotion
-
canEntityContinueSleeping
public static boolean canEntityContinueSleeping(LivingEntity sleeper, @Nullable @Nullable Player.BedSleepingProblem problem) Checks if a sleeping entity can continue sleeping with the given sleeping problem.- Returns:
- true if the entity may continue sleeping
-
onArrowNock
public static InteractionResultHolder<ItemStack> onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) -
onArrowLoose
-
onProjectileImpact
-
loadLootTable
-
canCreateFluidSource
Checks if a fluid is allowed to create a fluid source. This fires theCreateFluidSourceEvent
. By default, a fluid can create a source if it returns true toIFluidStateExtension.canConvertToSource(Level, BlockPos)
-
onTrySpawnPortal
public static Optional<PortalShape> onTrySpawnPortal(LevelAccessor level, BlockPos pos, Optional<PortalShape> size) -
onEnchantmentLevelSet
-
onEntityDestroyBlock
-
canEntityGrief
Checks if an entity can perform a griefing action.If an entity is provided, this method fires
EntityMobGriefingEvent
. If an entity is not provided, this method returns the value ofGameRules.RULE_MOBGRIEFING
.- Parameters:
level
- The level of the actionentity
- The entity performing the action, or null if unknown.- Returns:
-
fireBlockGrowFeature
public static BlockGrowFeatureEvent fireBlockGrowFeature(LevelAccessor level, RandomSource rand, BlockPos pos, @Nullable @Nullable Holder<ConfiguredFeature<?, ?>> holder) Fires theBlockGrowFeatureEvent
and returns the event object.- Parameters:
level
- The level the feature will be grown inrand
- The random sourcepos
- The position the feature will be grown atholder
- The feature to be grown, if any
-
alterGround
public static AlterGroundEvent.StateProvider alterGround(TreeDecorator.Context ctx, List<BlockPos> positions, AlterGroundEvent.StateProvider provider) Fires theAlterGroundEvent
and retrieves the resultingAlterGroundEvent.StateProvider
.- Parameters:
ctx
- The tree decoration context for the current alteration.positions
- The list of positions that are considered roots.provider
- The originalBlockStateProvider
from theAlterGroundDecorator
.- Returns:
- The (possibly event-modified)
AlterGroundEvent.StateProvider
to be used for ground alteration.
-
fireChunkTicketLevelUpdated
public static void fireChunkTicketLevelUpdated(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable @Nullable ChunkHolder chunkHolder) -
fireChunkWatch
-
fireChunkSent
-
fireChunkUnWatch
-
onPistonMovePre
-
onPistonMovePost
-
onSleepFinished
-
onResourceReload
public static List<PreparableReloadListener> onResourceReload(ReloadableServerResources serverResources, RegistryAccess registryAccess) -
onCommandRegister
public static void onCommandRegister(com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment, CommandBuildContext context) -
getEntitySizeForge
public static EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) -
getEntitySizeForge
public static EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight) -
canLivingConvert
public static boolean canLivingConvert(LivingEntity entity, EntityType<? extends LivingEntity> outcome, Consumer<Integer> timer) -
onLivingConvert
-
onEntityTeleportCommand
public static EntityTeleportEvent.TeleportCommand onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) -
onEntityTeleportSpreadPlayersCommand
public static EntityTeleportEvent.SpreadPlayersCommand onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) -
onEnderTeleport
public static EntityTeleportEvent.EnderEntity onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) -
onEnderPearlLand
@Internal public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult) -
onChorusFruitTeleport
public static EntityTeleportEvent.ChorusFruit onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) -
onPermissionChanged
public static boolean onPermissionChanged(com.mojang.authlib.GameProfile gameProfile, int newLevel, PlayerList playerList) -
firePlayerChangedDimensionEvent
public static void firePlayerChangedDimensionEvent(Player player, ResourceKey<Level> fromDim, ResourceKey<Level> toDim) -
firePlayerLoggedIn
-
firePlayerLoggedOut
-
firePlayerRespawnPositionEvent
public static PlayerRespawnPositionEvent firePlayerRespawnPositionEvent(ServerPlayer player, ServerLevel respawnLevel, float respawnAngle, @Nullable @Nullable Vec3 respawnPosition, boolean fromEndFight) Called byPlayerList.respawn(ServerPlayer, boolean)
before creating the newServerPlayer
to fire thePlayerRespawnPositionEvent
- Parameters:
player
- The oldServerPlayer
that is being respawnedrespawnLevel
- The default level the player will respawn intorespawnAngle
- The angle the player will face when they respawnrespawnPosition
- The position in the level the player will respawn atfromEndFight
- Whether the player is respawning because they jumped through the End return portal- Returns:
- The event
-
firePlayerRespawnEvent
Called byPlayerList.respawn(ServerPlayer, boolean)
after creating and initializing the newServerPlayer
.- Parameters:
player
- The new player instance created by the respawn processfromEndFight
- Whether the player is respawning because they jumped through the End return portal
-
firePlayerCraftingEvent
-
firePlayerSmeltedEvent
-
firePlayerHeartTypeEvent
Called byGui.HeartType.forPlayer(net.minecraft.world.entity.player.Player)
to allow for modification of the displayed heart type in the health bar.- Parameters:
player
- The localPlayer
heartType
- TheGui.HeartType
which would be displayed by vanilla- Returns:
- The heart type which should be displayed
-
fireEntityTickPre
FiresEntityTickEvent.Pre
. Called from the head ofLivingEntity.tick()
.- Parameters:
entity
- The entity being ticked- Returns:
- The event
-
fireEntityTickPost
FiresEntityTickEvent.Post
. Called from the tail ofLivingEntity.tick()
.- Parameters:
entity
- The entity being ticked
-
firePlayerTickPre
FiresPlayerTickEvent.Pre
. Called from the head ofPlayer.tick()
.- Parameters:
player
- The player being ticked
-
firePlayerTickPost
FiresPlayerTickEvent.Post
. Called from the tail ofPlayer.tick()
.- Parameters:
player
- The player being ticked
-
fireLevelTickPre
FiresLevelTickEvent.Pre
. Called fromMinecraft.tick()
andMinecraftServer.tickChildren(BooleanSupplier)
just before the try block for level tick is entered.- Parameters:
level
- The level being tickedhaveTime
- The time supplier, indicating if there is remaining time to do work in the current tick.
-
fireLevelTickPost
FiresLevelTickEvent.Post
. Called fromMinecraft.tick()
andMinecraftServer.tickChildren(BooleanSupplier)
just after the try block for level tick is exited.- Parameters:
level
- The level being tickedhaveTime
- The time supplier, indicating if there is remaining time to do work in the current tick.
-
fireServerTickPre
FiresServerTickEvent.Pre
. Called from the head ofMinecraftServer.tickServer(BooleanSupplier)
.- Parameters:
haveTime
- The time supplier, indicating if there is remaining time to do work in the current tick.server
- The current server
-
fireServerTickPost
FiresServerTickEvent.Post
. Called from the tail ofMinecraftServer.tickServer(BooleanSupplier)
.- Parameters:
haveTime
- The time supplier, indicating if there is remaining time to do work in the current tick.server
- The current server
-
getPotentialSpawns
public static WeightedRandomList<MobSpawnSettings.SpawnerData> getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList<MobSpawnSettings.SpawnerData> oldList) -
onStatAward
-
onAdvancementEarnedEvent
-
onAdvancementProgressedEvent
@Internal public static void onAdvancementProgressedEvent(Player player, AdvancementHolder progressed, AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) -
onEffectRemoved
public static boolean onEffectRemoved(LivingEntity entity, Holder<MobEffect> effect, @Nullable @Nullable EffectCure cure) -
onEffectRemoved
public static boolean onEffectRemoved(LivingEntity entity, MobEffectInstance effectInstance, @Nullable @Nullable EffectCure cure) -
getEnchantmentLevelSpecific
FiresGetEnchantmentLevelEvent
and for a single enchantment, returning the (possibly event-modified) level.- Parameters:
level
- The original level of the enchantment as provided by the Item.stack
- The stack being queried against.ench
- The enchantment being queried for.- Returns:
- The new level of the enchantment.
-
getEnchantmentLevel
FiresGetEnchantmentLevelEvent
and for all enchantments, returning the (possibly event-modified) enchantment map.- Parameters:
enchantments
- The original enchantment map as provided by the Item.stack
- The stack being queried against.- Returns:
- The new enchantment map.
-
onCreativeModeTabBuildContents
@Internal public static void onCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) Fires theBuildCreativeModeTabContentsEvent
.- Parameters:
tab
- The tab that contents are being collected for.tabKey
- The resource key of the tab.originalGenerator
- The display items generator that populates vanilla entries.params
- Display parameters, controlling if certain items are hidden.output
- The output acceptor.
-
onMobSplit
Fires the mob split event. Returns the event for cancellation checking.- Parameters:
parent
- The parent mob, which is in the process of being removed.children
- All child mobs that would have normally spawned.- Returns:
- The event object.
-