Class EventHooks
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final WeightedRandomList<MobSpawnSettings.SpawnerData> -
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(Level 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(Level 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, MobSpawnType spawnType, BlockPos pos, RandomSource random, boolean defaultResult) static booleancheckSpawnPosition(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 booleancheckSpawnPositionSpawner(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 theBaseSpawnerto the event.static booleandoPlayerHarvestCheck(Player player, BlockState state, BlockGetter level, BlockPos pos) static @Nullable SpawnGroupDatafinalizeMobSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType 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.MobSpawnType, net.minecraft.world.entity.SpawnGroupData)with the result.static FinalizeSpawnEventfinalizeMobSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType 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.MobSpawnType, 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 Gui.HeartTypefirePlayerHeartTypeEvent(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 voidfirePlayerLoadingEvent(Player player, File playerDirectory, String uuidString) static voidfirePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) static voidfirePlayerLoggedIn(Player player) static voidfirePlayerLoggedOut(Player player) static voidfirePlayerRespawnEvent(ServerPlayer player, boolean fromEndFight) Called byPlayerList.respawn(ServerPlayer, boolean)after creating and initializing the newServerPlayer.static PlayerRespawnPositionEventfirePlayerRespawnPositionEvent(ServerPlayer player, ServerLevel respawnLevel, float respawnAngle, @Nullable Vec3 respawnPosition, boolean fromEndFight) Called byPlayerList.respawn(ServerPlayer, boolean)before creating the newServerPlayerto fire thePlayerRespawnPositionEventstatic voidfirePlayerSavingEvent(Player player, File playerDirectory, String uuidString) static voidfirePlayerSmeltedEvent(Player player, ItemStack smelted) static PlayerSpawnPhantomsEventfirePlayerSpawnPhantoms(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 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 floatgetBreakSpeed(Player player, BlockState state, float original, BlockPos pos) static ItemEnchantmentsgetEnchantmentLevel(ItemEnchantments enchantments, ItemStack stack) FiresGetEnchantmentLevelEventand for all enchantments, returning the (possibly event-modified) enchantment map.static intgetEnchantmentLevelSpecific(int level, ItemStack stack, Enchantment ench) FiresGetEnchantmentLevelEventand for a single enchantment, returning the (possibly event-modified) level.static EntityEvent.SizegetEntitySizeForge(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) static EntityEvent.SizegetEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight) static intgetExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) static Vec3getExplosionKnockback(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 intgetItemBurnTime(ItemStack itemStack, int burnTime, @Nullable RecipeType<?> recipeType) 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, WeightedRandomList<MobSpawnSettings.SpawnerData> oldList) static LootTableloadLootTable(ResourceLocation name, LootTable table) 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 InteractionResultHolder<ItemStack> onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) static booleanonBlockPlace(@Nullable Entity entity, BlockSnapshot blockSnapshot, Direction direction) onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) 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, @Nullable EffectCure cure) static booleanonEffectRemoved(LivingEntity entity, MobEffectInstance effectInstance, @Nullable EffectCure cure) 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, Explosion explosion, List<Entity> list, double diameter) static booleanonExplosionStart(Level level, Explosion explosion) static intonItemExpire(ItemEntity entity, ItemStack item) 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, 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(com.mojang.authlib.GameProfile gameProfile, 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, ResourceKey<Level> levelKey, BlockPos pos, boolean forced) 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) 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, ToolAction toolAction, 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, 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 theBaseSpawnerto 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 theFinalizeSpawnEventand 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:
Would become:var zombie = new Zombie(level); zombie.finalizeSpawn(level, difficulty, spawnType, spawnData); level.tryAddFreshEntityWithPassengers(zombie); if (zombie.isAddedToWorld()) { // 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.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 theFinalizeSpawnEventand 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
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, 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:
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
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
-
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 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, 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 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) -
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 newServerPlayerto fire thePlayerRespawnPositionEvent- Parameters:
player- The oldServerPlayerthat 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 localPlayerheartType- TheGui.HeartTypewhich 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
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.
-
getEnchantmentLevel
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.
-