Class EventHooks
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalterGround(TreeDecorator.Context ctx, List<BlockPos> positions, AlterGroundEvent.StateProvider provider) Fires theAlterGroundEventand retrieves the resultingAlterGroundEvent.StateProvider.static booleancanCreateFluidSource(ServerLevel level, BlockPos pos, BlockState state) Checks if a fluid is allowed to create a fluid source.static booleancanEntityContinueSleeping(LivingEntity sleeper, @Nullable Player.BedSleepingProblem problem) Checks if a sleeping entity can continue sleeping with the given sleeping problem.static booleancanEntityGrief(ServerLevel level, @Nullable Entity entity) Checks if an entity can perform a griefing action.static booleancanLivingConvert(LivingEntity entity, EntityType<? extends LivingEntity> outcome, Consumer<Integer> timer) static booleancanMountEntity(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 booleancheckMobDespawn(Mob mob) FiresMobDespawnEventand returns true if the default logic should be ignored.static booleancheckSpawnPlacements(EntityType<?> entityType, ServerLevelAccessor level, EntitySpawnReason spawnType, BlockPos pos, RandomSource random, boolean defaultResult) static booleancheckSpawnPosition(Mob mob, ServerLevelAccessor level, EntitySpawnReason 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.EntitySpawnReason)andMob.checkSpawnObstruction(net.minecraft.world.level.LevelReader).static booleancheckSpawnPositionSpawner(Mob mob, ServerLevelAccessor level, EntitySpawnReason spawnType, SpawnData spawnData, BaseSpawner spawner) Specialized variant ofcheckSpawnPosition(net.minecraft.world.entity.Mob, net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.entity.EntitySpawnReason)for spawners, as they have slightly different checks, and pass through theBaseSpawnerto the event.static booleandoPlayerHarvestCheck(Player player, BlockState state, BlockGetter level, BlockPos pos) static @Nullable SpawnGroupDatafinalizeMobSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnType, @Nullable SpawnGroupData spawnData) Finalizes the spawn of a mob by firing theFinalizeSpawnEventand callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.EntitySpawnReason, net.minecraft.world.entity.SpawnGroupData)with the result.static FinalizeSpawnEventfinalizeMobSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnType, @Nullable SpawnGroupData spawnData, IOwnedSpawner spawner, boolean def) Finalizes the spawn of a mob by firing theFinalizeSpawnEventand callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.EntitySpawnReason, net.minecraft.world.entity.SpawnGroupData)with the result.static BlockGrowFeatureEventfireBlockGrowFeature(LevelAccessor level, RandomSource rand, BlockPos pos, @Nullable Holder<ConfiguredFeature<?, ?>> holder) Fires theBlockGrowFeatureEventand returns the event object.static BonemealEventfireBonemealEvent(@Nullable Player player, Level level, BlockPos pos, BlockState state, ItemStack stack) Called when bone meal (or equivalent) is used on a block.static voidfireChunkSent(ServerPlayer entity, LevelChunk chunk, ServerLevel level) static voidfireChunkTicketLevelUpdated(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder) static voidfireChunkUnWatch(ServerPlayer entity, ChunkPos chunkpos, ServerLevel level) static voidfireChunkWatch(ServerPlayer entity, LevelChunk chunk, ServerLevel level) static voidfireEntityTickPost(Entity entity) FiresEntityTickEvent.Post.static EntityTickEvent.PrefireEntityTickPre(Entity entity) FiresEntityTickEvent.Pre.static BlockStatefireFluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) static voidfireItemPickupPost(ItemEntity itemEntity, Player player, ItemStack copy) Called inItemEntity.playerTouch(Player)after an item was successfully picked up.static ItemEntityPickupEvent.PrefireItemPickupPre(ItemEntity itemEntity, Player player) Called inItemEntity.playerTouch(Player)before any other processing occurs.static voidfireLevelTickPost(Level level, BooleanSupplier haveTime) FiresLevelTickEvent.Post.static voidfireLevelTickPre(Level level, BooleanSupplier haveTime) FiresLevelTickEvent.Pre.static voidfirePlayerChangedDimensionEvent(Player player, ResourceKey<Level> fromDim, ResourceKey<Level> toDim) static voidfirePlayerCraftingEvent(Player player, ItemStack crafted, Container craftMatrix) static voidfirePlayerLoadingEvent(Player player, PlayerList playerList, String uuidString) static voidfirePlayerLoggedIn(Player player) static voidfirePlayerLoggedOut(Player player) static voidfirePlayerRespawnEvent(ServerPlayer player, boolean fromEndFight) Called byafter creating and initializing the newinvalid reference
PlayerList#respawn(ServerPlayer, boolean)ServerPlayer.static PlayerRespawnPositionEventfirePlayerRespawnPositionEvent(ServerPlayer player, TeleportTransition teleportTransition, boolean fromEndFight) Called bybefore creating the newinvalid reference
PlayerList#respawn(ServerPlayer, boolean)ServerPlayerto fire thePlayerRespawnPositionEventstatic voidfirePlayerSavingEvent(Player player, File playerDirectory, String uuidString) static voidfirePlayerSmeltedEvent(Player player, ItemStack smelted, int amountRemoved) static PlayerSpawnPhantomsEventfirePlayerSpawnPhantoms(ServerPlayer player, ServerLevel level, BlockPos pos) Called fromPhantomSpawner.tick(net.minecraft.server.level.ServerLevel, boolean)just before the spawn conditions for phantoms are evaluated.static voidfirePlayerTickPost(Player player) FiresPlayerTickEvent.Post.static voidfirePlayerTickPre(Player player) FiresPlayerTickEvent.Pre.static voidfireServerTickPost(BooleanSupplier haveTime, MinecraftServer server) FiresServerTickEvent.Post.static voidfireServerTickPre(BooleanSupplier haveTime, MinecraftServer server) FiresServerTickEvent.Pre.static ItemEnchantmentsgetAllEnchantmentLevels(ItemEnchantments enchantments, ItemStack stack, HolderLookup.RegistryLookup<Enchantment> lookup) FiresGetEnchantmentLevelEventand for all enchantments, returning the (possibly event-modified) enchantment map.static floatgetBreakSpeed(Player player, BlockState state, float original, BlockPos pos) static List<CustomSpawner> getCustomSpawners(ServerLevel serverLevel, List<CustomSpawner> customSpawners) Fires theModifyCustomSpawnersEvent.static intgetEnchantmentLevelSpecific(int level, ItemStack stack, Holder<Enchantment> ench) FiresGetEnchantmentLevelEventand for a single enchantment, returning the (possibly event-modified) level.static EntityEvent.SizegetEntitySizeForge(Entity entity, Pose pose, EntityDimensions size) static EntityEvent.SizegetEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize) static intgetExperienceDrop(LivingEntity entity, @Nullable Player attackingPlayer, int originalExperience) static Vec3getExplosionKnockback(Level level, ServerExplosion explosion, Entity entity, Vec3 initialVelocity, List<BlockPos> blocks) 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 intgetItemBurnTime(ItemStack itemStack, int burnTime, @Nullable RecipeType<?> recipeType, FuelValues fuelValues) static intgetMaxSpawnClusterSize(Mob entity) FiresSpawnClusterSizeEventand returns the size as a result of the event.static ComponentgetPlayerDisplayName(Player player, Component username) static ComponentgetPlayerTabListDisplayName(Player player) getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedList<MobSpawnSettings.SpawnerData> oldList) static @Nullable LootTableloadLootTable(HolderLookup.Provider registries, ResourceLocation name, LootTable table) Fires theLootTableLoadEventfor non-empty loot tables and returns the table if the event was not canceled and the table was not set toLootTable.EMPTYin the event.static voidonAdvancementEarnedEvent(Player player, AdvancementHolder earned) static voidonAdvancementProgressedEvent(Player player, AdvancementHolder progressed, AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) static booleanonAnimalTame(Animal animal, Player tamer) static intonArrowLoose(ItemStack stack, Level level, Player player, int charge, boolean hasAmmo) static InteractionResultonArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) static booleanonBlockPlace(@Nullable Entity entity, BlockSnapshot blockSnapshot, Direction direction) static voidonCommandRegister(com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment, CommandBuildContext context) static booleanonCreateWorldSpawn(Level level, ServerLevelData settings) static voidonCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) Fires theBuildCreativeModeTabContentsEvent.static booleanonEffectRemoved(LivingEntity entity, Holder<MobEffect> effect) static booleanonEffectRemoved(LivingEntity entity, MobEffectInstance effectInstance) static intonEnchantmentLevelSet(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 booleanonEntityDestroyBlock(LivingEntity entity, BlockPos pos, BlockState state) static booleanonEntityStruckByLightning(Entity entity, LightningBolt bolt) onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) static voidonExplosionDetonate(Level level, ServerExplosion explosion, List<Entity> entities, List<BlockPos> blocks) static booleanonExplosionStart(Level level, ServerExplosion explosion) onItemConsumptionTeleport(LivingEntity entity, ItemStack itemStack, double targetX, double targetY, double targetZ) static intonItemExpire(ItemEntity entity) static ItemTooltipEventonItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags, Item.TooltipContext context) static ItemStackonItemUseFinish(LivingEntity entity, ItemStack item, int duration, ItemStack result) static intonItemUseStart(LivingEntity entity, ItemStack item, InteractionHand hand, int duration) static intonItemUseTick(LivingEntity entity, ItemStack item, int duration) static voidonLivingConvert(LivingEntity entity, LivingEntity outcome) static floatonLivingHeal(LivingEntity entity, float amount) static MobSplitEventonMobSplit(Mob parent, List<Mob> children) Fires the mob split event.static booleanonMultiBlockPlace(@Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction) onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate) static booleanonPermissionChanged(NameAndId nameAndId, int newLevel, PlayerList playerList) static voidonPistonMovePost(Level level, BlockPos pos, Direction direction, boolean extending) static booleanonPistonMovePre(Level level, BlockPos pos, Direction direction, boolean extending) static voidonPlayerBrewedPotion(Player player, ItemStack stack) static voidonPlayerClone(Player player, Player oldPlayer, boolean wasDeath) static voidonPlayerDestroyItem(Player player, ItemStack stack, @Nullable InteractionHand hand) static voidonPlayerFall(Player player, float distance, float multiplier) static booleanonPlayerSpawnSet(Player player, ServerPlayer.RespawnConfig respawnConfig) static voidonPlayerWakeup(Player player, boolean wakeImmediately, boolean updateLevel) static PlayLevelSoundEvent.AtEntityonPlaySoundAtEntity(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 booleanonPotionAttemptBrew(NonNullList<ItemStack> stacks) static voidonPotionBrewed(NonNullList<ItemStack> brewingItemStacks) static booleanonProjectileImpact(Projectile projectile, HitResult ray) static List<PreparableReloadListener> onResourceReload(ReloadableServerResources serverResources, RegistryAccess registryAccess) Fires theAddServerReloadListenersEventand returns the sorted list of reload listeners.static longonSleepFinished(ServerLevel level, long newTime, long minTime) static voidonStartEntityTracking(Entity entity, Player player) static StatAwardEventonStatAward(Player player, Stat<?> stat, int value) static voidonStopEntityTracking(Entity entity, Player player) static @Nullable BlockStateonToolUse(BlockState originalState, UseOnContext context, ItemAbility itemAbility, boolean simulate) static Optional<PortalShape> onTrySpawnPortal(LevelAccessor level, BlockPos pos, Optional<PortalShape> size) static booleanonUseItemStop(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, EntitySpawnReason 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.EntitySpawnReason, net.minecraft.core.BlockPos, net.minecraft.util.RandomSource).- See Also:
-
checkSpawnPosition
public static boolean checkSpawnPosition(Mob mob, ServerLevelAccessor level, EntitySpawnReason 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.EntitySpawnReason)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, EntitySpawnReason spawnType, SpawnData spawnData, BaseSpawner spawner) Specialized variant ofcheckSpawnPosition(net.minecraft.world.entity.Mob, net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.entity.EntitySpawnReason)for spawners, as they have slightly different checks, and pass through theBaseSpawnerto the event.- See Also:
-
finalizeMobSpawn
@Nullable public static @Nullable SpawnGroupData finalizeMobSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnType, @Nullable @Nullable SpawnGroupData spawnData) Finalizes the spawn of a mob by firing theFinalizeSpawnEventand callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.EntitySpawnReason, 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.EntitySpawnReason, 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.EntitySpawnReason, 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.EntitySpawnReason, net.minecraft.world.entity.SpawnGroupData)with a call to this method.As an example, the following code block:
Would become:var zombie = new Zombie(level); zombie.finalizeSpawn(level, difficulty, spawnType, spawnData); level.tryAddFreshEntityWithPassengers(zombie); if (zombie.isAddedToLevel()) { // Do stuff with your new zombie }The only code that changes is thevar zombie = new Zombie(level); EventHooks.finalizeMobSpawn(zombie, level, difficulty, spawnType, spawnData); level.tryAddFreshEntityWithPassengers(zombie); if (zombie.isAddedToLevel()) { // Do stuff with your new zombie }Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.EntitySpawnReason, 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, EntitySpawnReason spawnType, @Nullable @Nullable SpawnGroupData spawnData, IOwnedSpawner spawner, boolean def) Finalizes the spawn of a mob by firing theFinalizeSpawnEventand callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.EntitySpawnReason, 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
IOwnedSpawnerinstance.- 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)just before the spawn conditions for phantoms are evaluated. Fires thePlayerSpawnPhantomsEventand 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
FiresMobDespawnEventand returns true if the default logic should be ignored.- Parameters:
mob- 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, FuelValues fuelValues) -
getExperienceDrop
public static int getExperienceDrop(LivingEntity entity, @Nullable @Nullable Player attackingPlayer, int originalExperience) -
getMaxSpawnClusterSize
FiresSpawnClusterSizeEventand 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
public static int onItemUseStart(LivingEntity entity, ItemStack item, InteractionHand hand, int duration) -
onItemUseTick
-
onUseItemStop
-
onItemUseFinish
public static ItemStack onItemUseFinish(LivingEntity entity, ItemStack item, int duration, ItemStack result) -
onStartEntityTracking
-
onStopEntityTracking
-
firePlayerLoadingEvent
-
firePlayerSavingEvent
-
onToolUse
@Nullable public static @Nullable BlockState onToolUse(BlockState originalState, UseOnContext context, ItemAbility itemAbility, 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 theBonemealEventand 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.Preand 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, @Nullable ServerPlayer.RespawnConfig respawnConfig) -
onPlayerClone
-
onExplosionStart
-
onExplosionDetonate
-
getExplosionKnockback
public static Vec3 getExplosionKnockback(Level level, ServerExplosion explosion, Entity entity, Vec3 initialVelocity, List<BlockPos> blocks) 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 InteractionResult onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) -
onArrowLoose
-
onProjectileImpact
-
loadLootTable
@Nullable @Internal public static @Nullable LootTable loadLootTable(HolderLookup.Provider registries, ResourceLocation name, LootTable table) Fires theLootTableLoadEventfor non-empty loot tables and returns the table if the event was not canceled and the table was not set toLootTable.EMPTYin the event. Otherwise returnsnullwhich maps to an emptyOptionalininvalid reference
LootDataType#deserialize(ResourceLocation, DynamicOps, Object) -
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 toinvalid reference
IFluidStateExtension#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 theBlockGrowFeatureEventand 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 theAlterGroundEventand 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 originalBlockStateProviderfrom theAlterGroundDecorator.- Returns:
- The (possibly event-modified)
AlterGroundEvent.StateProviderto 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) Fires theAddServerReloadListenersEventand returns the sorted list of reload listeners.- Parameters:
serverResources- The just-createdReloadableServerResourcesinstance.registryAccess- The registry access from theReloadableServerRegistries.LoadResult.- Returns:
- The sorted list of reload listeners.
- Throws:
IllegalArgumentException- ifReloadListenerSort.sort(SortedReloadListenerEvent)detects a cycle.
-
onCommandRegister
public static void onCommandRegister(com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment, CommandBuildContext context) -
getEntitySizeForge
-
getEntitySizeForge
public static EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize) -
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) -
onItemConsumptionTeleport
public static EntityTeleportEvent.ItemConsumption onItemConsumptionTeleport(LivingEntity entity, ItemStack itemStack, double targetX, double targetY, double targetZ) -
onPermissionChanged
-
firePlayerChangedDimensionEvent
public static void firePlayerChangedDimensionEvent(Player player, ResourceKey<Level> fromDim, ResourceKey<Level> toDim) -
firePlayerLoggedIn
-
firePlayerLoggedOut
-
firePlayerRespawnPositionEvent
public static PlayerRespawnPositionEvent firePlayerRespawnPositionEvent(ServerPlayer player, TeleportTransition teleportTransition, boolean fromEndFight) Called bybefore creating the newinvalid reference
PlayerList#respawn(ServerPlayer, boolean)ServerPlayerto fire thePlayerRespawnPositionEvent- Parameters:
player- The oldServerPlayerthat is being respawnedfromEndFight- Whether the player is respawning because they jumped through the End return portalrespawnLevel- 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 at- Returns:
- The event
-
firePlayerRespawnEvent
Called byafter creating and initializing the newinvalid reference
PlayerList#respawn(ServerPlayer, boolean)ServerPlayer.- 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
-
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 fromandinvalid reference
Minecraft#tick()MinecraftServer.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 fromandinvalid reference
Minecraft#tick()MinecraftServer.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 WeightedList<MobSpawnSettings.SpawnerData> getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedList<MobSpawnSettings.SpawnerData> oldList) -
onStatAward
-
onAdvancementEarnedEvent
-
onAdvancementProgressedEvent
@Internal public static void onAdvancementProgressedEvent(Player player, AdvancementHolder progressed, AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) -
onEffectRemoved
-
onEffectRemoved
-
getEnchantmentLevelSpecific
FiresGetEnchantmentLevelEventand 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.
-
getAllEnchantmentLevels
public static ItemEnchantments getAllEnchantmentLevels(ItemEnchantments enchantments, ItemStack stack, HolderLookup.RegistryLookup<Enchantment> lookup) FiresGetEnchantmentLevelEventand 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.
-
getCustomSpawners
public static List<CustomSpawner> getCustomSpawners(ServerLevel serverLevel, List<CustomSpawner> customSpawners) Fires theModifyCustomSpawnersEvent. Returns the custom spawners list.- Parameters:
serverLevel- The server level.customSpawners- The original custom spawners.- Returns:
- The new custom spawners list.
-