Class EventHooks

java.lang.Object
net.neoforged.neoforge.event.EventHooks

public class EventHooks extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    alterGround(net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator.Context ctx, List<net.minecraft.core.BlockPos> positions, AlterGroundEvent.StateProvider provider)
    Fires the AlterGroundEvent and retrieves the resulting AlterGroundEvent.StateProvider.
    static boolean
    canCreateFluidSource(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    Checks if a fluid is allowed to create a fluid source.
    static boolean
    canEntityContinueSleeping(net.minecraft.world.entity.LivingEntity sleeper, @Nullable net.minecraft.world.entity.player.Player.BedSleepingProblem problem)
    Checks if a sleeping entity can continue sleeping with the given sleeping problem.
    static boolean
    canEntityGrief(net.minecraft.server.level.ServerLevel level, @Nullable net.minecraft.world.entity.Entity entity)
    Checks if an entity can perform a griefing action.
    static boolean
    canLivingConvert(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity> outcome, Consumer<Integer> timer)
     
    static boolean
    canMountEntity(net.minecraft.world.entity.Entity entityMounting, net.minecraft.world.entity.Entity entityBeingMounted, boolean isMounting)
     
    static com.mojang.datafixers.util.Either<net.minecraft.world.entity.player.Player.BedSleepingProblem,net.minecraft.util.Unit>
    canPlayerStartSleeping(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, com.mojang.datafixers.util.Either<net.minecraft.world.entity.player.Player.BedSleepingProblem,net.minecraft.util.Unit> vanillaResult)
     
    static boolean
    checkMobDespawn(net.minecraft.world.entity.Mob mob)
    Fires MobDespawnEvent and returns true if the default logic should be ignored.
    static boolean
    checkSpawnPlacements(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.entity.EntitySpawnReason spawnType, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random, boolean defaultResult)
    Internal, should only be called via SpawnPlacements.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).
    static boolean
    checkSpawnPosition(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.entity.EntitySpawnReason spawnType)
    Checks if the current position of the passed mob is valid for spawning, by firing MobSpawnEvent.PositionCheck.
    The default check is to perform the logical and of Mob.checkSpawnRules(net.minecraft.world.level.LevelAccessor, net.minecraft.world.entity.EntitySpawnReason) and Mob.checkSpawnObstruction(net.minecraft.world.level.LevelReader).
    static boolean
    checkSpawnPositionSpawner(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.entity.EntitySpawnReason spawnType, net.minecraft.world.level.SpawnData spawnData, net.minecraft.world.level.BaseSpawner spawner)
    Specialized variant of checkSpawnPosition(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 the BaseSpawner to the event.
    static boolean
    doPlayerHarvestCheck(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
     
    static @Nullable net.minecraft.world.entity.SpawnGroupData
    finalizeMobSpawn(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.DifficultyInstance difficulty, net.minecraft.world.entity.EntitySpawnReason spawnType, @Nullable net.minecraft.world.entity.SpawnGroupData spawnData)
    Finalizes the spawn of a mob by firing the FinalizeSpawnEvent and calling Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.EntitySpawnReason, net.minecraft.world.entity.SpawnGroupData) with the result.
    finalizeMobSpawnSpawner(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.DifficultyInstance difficulty, net.minecraft.world.entity.EntitySpawnReason spawnType, @Nullable net.minecraft.world.entity.SpawnGroupData spawnData, IOwnedSpawner spawner, boolean def)
    Finalizes the spawn of a mob by firing the FinalizeSpawnEvent and calling Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.EntitySpawnReason, net.minecraft.world.entity.SpawnGroupData) with the result.
    fireBlockGrowFeature(net.minecraft.world.level.LevelAccessor level, net.minecraft.util.RandomSource rand, net.minecraft.core.BlockPos pos, @Nullable net.minecraft.core.Holder<net.minecraft.world.level.levelgen.feature.ConfiguredFeature<?,?>> holder)
    Fires the BlockGrowFeatureEvent and returns the event object.
    fireBonemealEvent(@Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.item.ItemStack stack)
    Called when bone meal (or equivalent) is used on a block.
    static void
    fireChunkSent(net.minecraft.server.level.ServerPlayer entity, net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.server.level.ServerLevel level)
     
    static void
    fireChunkTicketLevelUpdated(net.minecraft.server.level.ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable net.minecraft.server.level.ChunkHolder chunkHolder)
     
    static void
    fireChunkUnWatch(net.minecraft.server.level.ServerPlayer entity, net.minecraft.world.level.ChunkPos chunkpos, net.minecraft.server.level.ServerLevel level)
     
    static void
    fireChunkWatch(net.minecraft.server.level.ServerPlayer entity, net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.server.level.ServerLevel level)
     
    static void
    fireEntityTickPost(net.minecraft.world.entity.Entity entity)
    fireEntityTickPre(net.minecraft.world.entity.Entity entity)
    static net.minecraft.world.level.block.state.BlockState
    fireFluidPlaceBlockEvent(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos liquidPos, net.minecraft.world.level.block.state.BlockState state)
     
    static void
    fireItemPickupPost(net.minecraft.world.entity.item.ItemEntity itemEntity, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack copy)
    Called in ItemEntity.playerTouch(Player) after an item was successfully picked up.
    fireItemPickupPre(net.minecraft.world.entity.item.ItemEntity itemEntity, net.minecraft.world.entity.player.Player player)
    Called in ItemEntity.playerTouch(Player) before any other processing occurs.
    static void
    fireLevelTickPost(net.minecraft.world.level.Level level, BooleanSupplier haveTime)
    static void
    fireLevelTickPre(net.minecraft.world.level.Level level, BooleanSupplier haveTime)
    static void
    firePlayerChangedDimensionEvent(net.minecraft.world.entity.player.Player player, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> fromDim, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> toDim)
     
    static void
    firePlayerCraftingEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack crafted, net.minecraft.world.Container craftMatrix)
     
    static void
    firePlayerLoadingEvent(net.minecraft.world.entity.player.Player player, File playerDirectory, String uuidString)
     
    static void
    firePlayerLoadingEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.storage.PlayerDataStorage playerFileData, String uuidString)
     
    static void
    firePlayerLoggedIn(net.minecraft.world.entity.player.Player player)
     
    static void
    firePlayerLoggedOut(net.minecraft.world.entity.player.Player player)
     
    static void
    firePlayerRespawnEvent(net.minecraft.server.level.ServerPlayer player, boolean fromEndFight)
    Called by
    invalid reference
    PlayerList#respawn(ServerPlayer, boolean)
    after creating and initializing the new ServerPlayer.
    firePlayerRespawnPositionEvent(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.level.portal.TeleportTransition teleportTransition, boolean fromEndFight)
    Called by
    invalid reference
    PlayerList#respawn(ServerPlayer, boolean)
    before creating the new ServerPlayer to fire the PlayerRespawnPositionEvent
    static void
    firePlayerSavingEvent(net.minecraft.world.entity.player.Player player, File playerDirectory, String uuidString)
     
    static void
    firePlayerSmeltedEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack smelted, int amountRemoved)
     
    firePlayerSpawnPhantoms(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
    Called from PhantomSpawner.tick(net.minecraft.server.level.ServerLevel, boolean, boolean) just before the spawn conditions for phantoms are evaluated.
    static void
    firePlayerTickPost(net.minecraft.world.entity.player.Player player)
    static void
    firePlayerTickPre(net.minecraft.world.entity.player.Player player)
    static void
    fireServerTickPost(BooleanSupplier haveTime, net.minecraft.server.MinecraftServer server)
    static void
    fireServerTickPre(BooleanSupplier haveTime, net.minecraft.server.MinecraftServer server)
    static net.minecraft.world.item.enchantment.ItemEnchantments
    getAllEnchantmentLevels(net.minecraft.world.item.enchantment.ItemEnchantments enchantments, net.minecraft.world.item.ItemStack stack, net.minecraft.core.HolderLookup.RegistryLookup<net.minecraft.world.item.enchantment.Enchantment> lookup)
    Fires GetEnchantmentLevelEvent and for all enchantments, returning the (possibly event-modified) enchantment map.
    static float
    getBreakSpeed(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.block.state.BlockState state, float original, net.minecraft.core.BlockPos pos)
     
    static List<net.minecraft.world.level.CustomSpawner>
    getCustomSpawners(net.minecraft.server.level.ServerLevel serverLevel, List<net.minecraft.world.level.CustomSpawner> customSpawners)
    static int
    getEnchantmentLevelSpecific(int level, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> ench)
    Fires GetEnchantmentLevelEvent and for a single enchantment, returning the (possibly event-modified) level.
    getEntitySizeForge(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.Pose pose, net.minecraft.world.entity.EntityDimensions size)
     
    getEntitySizeForge(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.Pose pose, net.minecraft.world.entity.EntityDimensions oldSize, net.minecraft.world.entity.EntityDimensions newSize)
     
    static int
    getExperienceDrop(net.minecraft.world.entity.LivingEntity entity, @Nullable net.minecraft.world.entity.player.Player attackingPlayer, int originalExperience)
     
    static net.minecraft.world.phys.Vec3
    getExplosionKnockback(net.minecraft.world.level.Level level, net.minecraft.world.level.ServerExplosion explosion, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 initialVelocity, List<net.minecraft.core.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 int
    getItemBurnTime(net.minecraft.world.item.ItemStack itemStack, int burnTime, @Nullable net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.level.block.entity.FuelValues fuelValues)
     
    static int
    getMaxSpawnClusterSize(net.minecraft.world.entity.Mob entity)
    Fires SpawnClusterSizeEvent and returns the size as a result of the event.
    static net.minecraft.network.chat.Component
    getPlayerDisplayName(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component username)
     
    static net.minecraft.network.chat.Component
    getPlayerTabListDisplayName(net.minecraft.world.entity.player.Player player)
     
    static net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData>
    getPotentialSpawns(net.minecraft.world.level.LevelAccessor level, net.minecraft.world.entity.MobCategory category, net.minecraft.core.BlockPos pos, net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> oldList)
     
    static @Nullable net.minecraft.world.level.storage.loot.LootTable
    loadLootTable(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.resources.ResourceLocation name, net.minecraft.world.level.storage.loot.LootTable table)
    Fires the LootTableLoadEvent for non-empty loot tables and returns the table if the event was not canceled and the table was not set to LootTable.EMPTY in the event.
    static void
    onAdvancementEarnedEvent(net.minecraft.world.entity.player.Player player, net.minecraft.advancements.AdvancementHolder earned)
     
    static void
    onAdvancementProgressedEvent(net.minecraft.world.entity.player.Player player, net.minecraft.advancements.AdvancementHolder progressed, net.minecraft.advancements.AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType)
     
    static boolean
    onAnimalTame(net.minecraft.world.entity.animal.Animal animal, net.minecraft.world.entity.player.Player tamer)
     
    static int
    onArrowLoose(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, int charge, boolean hasAmmo)
     
    static net.minecraft.world.InteractionResult
    onArrowNock(net.minecraft.world.item.ItemStack item, net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, boolean hasAmmo)
     
    static boolean
    onBlockPlace(@Nullable net.minecraft.world.entity.Entity entity, BlockSnapshot blockSnapshot, net.minecraft.core.Direction direction)
     
    static void
    onCommandRegister(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> dispatcher, net.minecraft.commands.Commands.CommandSelection environment, net.minecraft.commands.CommandBuildContext context)
     
    static boolean
    onCreateWorldSpawn(net.minecraft.world.level.Level level, net.minecraft.world.level.storage.ServerLevelData settings)
     
    static void
    onCreativeModeTabBuildContents(net.minecraft.world.item.CreativeModeTab tab, net.minecraft.resources.ResourceKey<net.minecraft.world.item.CreativeModeTab> tabKey, net.minecraft.world.item.CreativeModeTab.DisplayItemsGenerator originalGenerator, net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters params, net.minecraft.world.item.CreativeModeTab.Output output)
    static boolean
    onEffectRemoved(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect)
     
    static boolean
    onEffectRemoved(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.effect.MobEffectInstance effectInstance)
     
    static int
    onEnchantmentLevelSet(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int enchantRow, int power, net.minecraft.world.item.ItemStack itemStack, int enchantmentLevel)
     
    onEnderPearlLand(net.minecraft.server.level.ServerPlayer entity, double targetX, double targetY, double targetZ, net.minecraft.world.entity.projectile.ThrownEnderpearl pearlEntity, float attackDamage, net.minecraft.world.phys.HitResult hitResult)
     
    onEnderTeleport(net.minecraft.world.entity.LivingEntity entity, double targetX, double targetY, double targetZ)
     
    static boolean
    onEntityDestroyBlock(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
    static boolean
    onEntityStruckByLightning(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.LightningBolt bolt)
     
    onEntityTeleportCommand(net.minecraft.world.entity.Entity entity, double targetX, double targetY, double targetZ)
     
    onEntityTeleportSpreadPlayersCommand(net.minecraft.world.entity.Entity entity, double targetX, double targetY, double targetZ)
     
    static void
    onExplosionDetonate(net.minecraft.world.level.Level level, net.minecraft.world.level.ServerExplosion explosion, List<net.minecraft.world.entity.Entity> entities, List<net.minecraft.core.BlockPos> blocks)
     
    static boolean
    onExplosionStart(net.minecraft.world.level.Level level, net.minecraft.world.level.ServerExplosion explosion)
     
    onItemConsumptionTeleport(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack itemStack, double targetX, double targetY, double targetZ)
     
    static int
    onItemExpire(net.minecraft.world.entity.item.ItemEntity entity)
     
    onItemTooltip(net.minecraft.world.item.ItemStack itemStack, @Nullable net.minecraft.world.entity.player.Player entityPlayer, List<net.minecraft.network.chat.Component> list, net.minecraft.world.item.TooltipFlag flags, net.minecraft.world.item.Item.TooltipContext context)
     
    static net.minecraft.world.item.ItemStack
    onItemUseFinish(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration, net.minecraft.world.item.ItemStack result)
     
    static int
    onItemUseStart(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use the hand sensitive version as this version provides wrong hand information
    static int
    onItemUseStart(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, net.minecraft.world.InteractionHand hand, int duration)
     
    static int
    onItemUseTick(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration)
     
    static void
    onLivingConvert(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.LivingEntity outcome)
     
    static float
    onLivingHeal(net.minecraft.world.entity.LivingEntity entity, float amount)
     
    onMobSplit(net.minecraft.world.entity.Mob parent, List<net.minecraft.world.entity.Mob> children)
    Fires the mob split event.
    static boolean
    onMultiBlockPlace(@Nullable net.minecraft.world.entity.Entity entity, List<BlockSnapshot> blockSnapshots, net.minecraft.core.Direction direction)
     
    onNeighborNotify(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, EnumSet<net.minecraft.core.Direction> notifiedSides, boolean forceRedstoneUpdate)
     
    static boolean
    onPermissionChanged(com.mojang.authlib.GameProfile gameProfile, int newLevel, net.minecraft.server.players.PlayerList playerList)
     
    static void
    onPistonMovePost(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction direction, boolean extending)
     
    static boolean
    onPistonMovePre(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction direction, boolean extending)
     
    static void
    onPlayerBrewedPotion(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
     
    static void
    onPlayerClone(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.player.Player oldPlayer, boolean wasDeath)
     
    static void
    onPlayerDestroyItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.world.InteractionHand hand)
     
    static void
    onPlayerFall(net.minecraft.world.entity.player.Player player, float distance, float multiplier)
     
    static boolean
    onPlayerSpawnSet(net.minecraft.world.entity.player.Player player, net.minecraft.server.level.ServerPlayer.RespawnConfig respawnConfig)
     
    static void
    onPlayerWakeup(net.minecraft.world.entity.player.Player player, boolean wakeImmediately, boolean updateLevel)
     
    onPlaySoundAtEntity(net.minecraft.world.entity.Entity entity, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> name, net.minecraft.sounds.SoundSource category, float volume, float pitch)
     
    onPlaySoundAtPosition(net.minecraft.world.level.Level level, double x, double y, double z, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> name, net.minecraft.sounds.SoundSource category, float volume, float pitch)
     
    static boolean
    onPotionAttemptBrew(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> stacks)
     
    static void
    onPotionBrewed(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> brewingItemStacks)
     
    static boolean
    onProjectileImpact(net.minecraft.world.entity.projectile.Projectile projectile, net.minecraft.world.phys.HitResult ray)
     
    static List<net.minecraft.server.packs.resources.PreparableReloadListener>
    onResourceReload(net.minecraft.server.ReloadableServerResources serverResources, net.minecraft.core.RegistryAccess registryAccess)
    Fires the AddServerReloadListenersEvent and returns the sorted list of reload listeners.
    static long
    onSleepFinished(net.minecraft.server.level.ServerLevel level, long newTime, long minTime)
     
    static void
    onStartEntityTracking(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player)
     
    onStatAward(net.minecraft.world.entity.player.Player player, net.minecraft.stats.Stat<?> stat, int value)
     
    static void
    onStopEntityTracking(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player)
     
    static @Nullable net.minecraft.world.level.block.state.BlockState
    onToolUse(net.minecraft.world.level.block.state.BlockState originalState, net.minecraft.world.item.context.UseOnContext context, ItemAbility itemAbility, boolean simulate)
     
    static Optional<net.minecraft.world.level.portal.PortalShape>
    onTrySpawnPortal(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, Optional<net.minecraft.world.level.portal.PortalShape> size)
     
    static boolean
    onUseItemStop(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NO_SPAWNS

      private static final net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> NO_SPAWNS
  • Constructor Details

    • EventHooks

      public EventHooks()
  • Method Details

    • onMultiBlockPlace

      public static boolean onMultiBlockPlace(@Nullable @Nullable net.minecraft.world.entity.Entity entity, List<BlockSnapshot> blockSnapshots, net.minecraft.core.Direction direction)
    • onBlockPlace

      public static boolean onBlockPlace(@Nullable @Nullable net.minecraft.world.entity.Entity entity, BlockSnapshot blockSnapshot, net.minecraft.core.Direction direction)
    • onNeighborNotify

      public static BlockEvent.NeighborNotifyEvent onNeighborNotify(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, EnumSet<net.minecraft.core.Direction> notifiedSides, boolean forceRedstoneUpdate)
    • doPlayerHarvestCheck

      public static boolean doPlayerHarvestCheck(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
    • getBreakSpeed

      public static float getBreakSpeed(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.block.state.BlockState state, float original, net.minecraft.core.BlockPos pos)
    • onPlayerDestroyItem

      public static void onPlayerDestroyItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.world.InteractionHand hand)
    • checkSpawnPlacements

      @Internal public static boolean checkSpawnPlacements(net.minecraft.world.entity.EntityType<?> entityType, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.entity.EntitySpawnReason spawnType, net.minecraft.core.BlockPos pos, net.minecraft.util.RandomSource random, boolean defaultResult)
      Internal, should only be called via SpawnPlacements.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(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.entity.EntitySpawnReason spawnType)
      Checks if the current position of the passed mob is valid for spawning, by firing MobSpawnEvent.PositionCheck.
      The default check is to perform the logical and of Mob.checkSpawnRules(net.minecraft.world.level.LevelAccessor, net.minecraft.world.entity.EntitySpawnReason) and Mob.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(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.entity.EntitySpawnReason spawnType, net.minecraft.world.level.SpawnData spawnData, net.minecraft.world.level.BaseSpawner spawner)
      Specialized variant of checkSpawnPosition(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 the BaseSpawner to the event.
      See Also:
    • finalizeMobSpawn

      @Nullable public static @Nullable net.minecraft.world.entity.SpawnGroupData finalizeMobSpawn(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.DifficultyInstance difficulty, net.minecraft.world.entity.EntitySpawnReason spawnType, @Nullable @Nullable net.minecraft.world.entity.SpawnGroupData spawnData)
      Finalizes the spawn of a mob by firing the FinalizeSpawnEvent and calling Mob.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 to Mob.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:

       var zombie = new Zombie(level);
       zombie.finalizeSpawn(level, difficulty, spawnType, spawnData);
       level.tryAddFreshEntityWithPassengers(zombie);
       if (zombie.isAddedToLevel()) {
           // Do stuff with your new zombie
       }
       
      Would become:
       var zombie = new Zombie(level);
       EventHooks.finalizeMobSpawn(zombie, level, difficulty, spawnType, spawnData);
       level.tryAddFreshEntityWithPassengers(zombie);
       if (zombie.isAddedToLevel()) {
           // Do stuff with your new zombie
       }
       
      The only code that changes is the 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 finalized
      level - The level the mob will be spawned in
      difficulty - The local difficulty at the position of the mob
      spawnType - The type of spawn that is occuring
      spawnData - 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:
      • FinalizeSpawnEvent
      • Mob.finalizeSpawn(ServerLevelAccessor, DifficultyInstance, EntitySpawnReason, SpawnGroupData)
    • finalizeMobSpawnSpawner

      public static FinalizeSpawnEvent finalizeMobSpawnSpawner(net.minecraft.world.entity.Mob mob, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.world.DifficultyInstance difficulty, net.minecraft.world.entity.EntitySpawnReason spawnType, @Nullable @Nullable net.minecraft.world.entity.SpawnGroupData spawnData, IOwnedSpawner spawner, boolean def)
      Finalizes the spawn of a mob by firing the FinalizeSpawnEvent and calling Mob.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 IOwnedSpawner instance.

      Parameters:
      mob - The mob whose spawn is being finalized
      level - The level the mob will be spawned in
      difficulty - The local difficulty at the position of the mob
      spawnType - The type of spawn that is occuring
      spawnData - Optional spawn data relevant to the mob being spawned
      spawner - The spawner that is attempting to spawn the mob
      def - If the spawner would normally call finalizeSpawn, regardless of the event
    • firePlayerSpawnPhantoms

      public static PlayerSpawnPhantomsEvent firePlayerSpawnPhantoms(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
      Called from PhantomSpawner.tick(net.minecraft.server.level.ServerLevel, boolean, boolean) just before the spawn conditions for phantoms are evaluated. Fires the PlayerSpawnPhantomsEvent and returns the event.
      Parameters:
      player - The player for whom a spawn attempt is being made
      level - The level of the player
      pos - The block position of the player
    • checkMobDespawn

      public static boolean checkMobDespawn(net.minecraft.world.entity.Mob mob)
      Fires MobDespawnEvent and 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(net.minecraft.world.item.ItemStack itemStack, int burnTime, @Nullable @Nullable net.minecraft.world.item.crafting.RecipeType<?> recipeType, net.minecraft.world.level.block.entity.FuelValues fuelValues)
    • getExperienceDrop

      public static int getExperienceDrop(net.minecraft.world.entity.LivingEntity entity, @Nullable @Nullable net.minecraft.world.entity.player.Player attackingPlayer, int originalExperience)
    • getMaxSpawnClusterSize

      public static int getMaxSpawnClusterSize(net.minecraft.world.entity.Mob entity)
      Fires SpawnClusterSizeEvent 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) where Mob.getMaxSpawnClusterSize() would normally be called.

      Parameters:
      entity - The entity whose max spawn cluster size is being queried.
      Returns:
      The new spawn cluster size.
    • getPlayerDisplayName

      public static net.minecraft.network.chat.Component getPlayerDisplayName(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component username)
    • getPlayerTabListDisplayName

      public static net.minecraft.network.chat.Component getPlayerTabListDisplayName(net.minecraft.world.entity.player.Player player)
    • fireFluidPlaceBlockEvent

      public static net.minecraft.world.level.block.state.BlockState fireFluidPlaceBlockEvent(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos liquidPos, net.minecraft.world.level.block.state.BlockState state)
    • onItemTooltip

      public static ItemTooltipEvent onItemTooltip(net.minecraft.world.item.ItemStack itemStack, @Nullable @Nullable net.minecraft.world.entity.player.Player entityPlayer, List<net.minecraft.network.chat.Component> list, net.minecraft.world.item.TooltipFlag flags, net.minecraft.world.item.Item.TooltipContext context)
    • onEntityStruckByLightning

      public static boolean onEntityStruckByLightning(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.LightningBolt bolt)
    • onItemUseStart

      @Deprecated(since="1.21.5", forRemoval=true) public static int onItemUseStart(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use the hand sensitive version as this version provides wrong hand information
    • onItemUseStart

      public static int onItemUseStart(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, net.minecraft.world.InteractionHand hand, int duration)
    • onItemUseTick

      public static int onItemUseTick(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration)
    • onUseItemStop

      public static boolean onUseItemStop(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration)
    • onItemUseFinish

      public static net.minecraft.world.item.ItemStack onItemUseFinish(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack item, int duration, net.minecraft.world.item.ItemStack result)
    • onStartEntityTracking

      public static void onStartEntityTracking(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player)
    • onStopEntityTracking

      public static void onStopEntityTracking(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.player.Player player)
    • firePlayerLoadingEvent

      public static void firePlayerLoadingEvent(net.minecraft.world.entity.player.Player player, File playerDirectory, String uuidString)
    • firePlayerSavingEvent

      public static void firePlayerSavingEvent(net.minecraft.world.entity.player.Player player, File playerDirectory, String uuidString)
    • firePlayerLoadingEvent

      public static void firePlayerLoadingEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.storage.PlayerDataStorage playerFileData, String uuidString)
    • onToolUse

      @Nullable public static @Nullable net.minecraft.world.level.block.state.BlockState onToolUse(net.minecraft.world.level.block.state.BlockState originalState, net.minecraft.world.item.context.UseOnContext context, ItemAbility itemAbility, boolean simulate)
    • fireBonemealEvent

      public static BonemealEvent fireBonemealEvent(@Nullable @Nullable net.minecraft.world.entity.player.Player player, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.item.ItemStack stack)
      Called when bone meal (or equivalent) is used on a block. Fires the BonemealEvent and returns the event.
      Parameters:
      player - The player who used the item, if any
      level - The level
      pos - The position of the target block
      state - The state of the target block
      stack - The bone meal item stack
      Returns:
      The event
    • onPlaySoundAtEntity

      public static PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(net.minecraft.world.entity.Entity entity, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> name, net.minecraft.sounds.SoundSource category, float volume, float pitch)
    • onPlaySoundAtPosition

      public static PlayLevelSoundEvent.AtPosition onPlaySoundAtPosition(net.minecraft.world.level.Level level, double x, double y, double z, net.minecraft.core.Holder<net.minecraft.sounds.SoundEvent> name, net.minecraft.sounds.SoundSource category, float volume, float pitch)
    • onItemExpire

      public static int onItemExpire(net.minecraft.world.entity.item.ItemEntity entity)
    • fireItemPickupPre

      public static ItemEntityPickupEvent.Pre fireItemPickupPre(net.minecraft.world.entity.item.ItemEntity itemEntity, net.minecraft.world.entity.player.Player player)
      Called in ItemEntity.playerTouch(Player) before any other processing occurs.

      Fires ItemEntityPickupEvent.Pre and returns the event.

      Parameters:
      itemEntity - The item entity that a player collided with
      player - The player that collided with the item entity
    • fireItemPickupPost

      public static void fireItemPickupPost(net.minecraft.world.entity.item.ItemEntity itemEntity, net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack copy)
      Called in ItemEntity.playerTouch(Player) after an item was successfully picked up.

      Fires ItemEntityPickupEvent.Post.

      Parameters:
      itemEntity - The item entity that a player collided with
      player - The player that collided with the item entity
      copy - A copy of the item entity's item stack before the pickup
    • canMountEntity

      public static boolean canMountEntity(net.minecraft.world.entity.Entity entityMounting, net.minecraft.world.entity.Entity entityBeingMounted, boolean isMounting)
    • onAnimalTame

      public static boolean onAnimalTame(net.minecraft.world.entity.animal.Animal animal, net.minecraft.world.entity.player.Player tamer)
    • canPlayerStartSleeping

      public static com.mojang.datafixers.util.Either<net.minecraft.world.entity.player.Player.BedSleepingProblem,net.minecraft.util.Unit> canPlayerStartSleeping(net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, com.mojang.datafixers.util.Either<net.minecraft.world.entity.player.Player.BedSleepingProblem,net.minecraft.util.Unit> vanillaResult)
    • onPlayerWakeup

      public static void onPlayerWakeup(net.minecraft.world.entity.player.Player player, boolean wakeImmediately, boolean updateLevel)
    • onPlayerFall

      public static void onPlayerFall(net.minecraft.world.entity.player.Player player, float distance, float multiplier)
    • onPlayerSpawnSet

      public static boolean onPlayerSpawnSet(net.minecraft.world.entity.player.Player player, @Nullable net.minecraft.server.level.ServerPlayer.RespawnConfig respawnConfig)
    • onPlayerClone

      public static void onPlayerClone(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.player.Player oldPlayer, boolean wasDeath)
    • onExplosionStart

      public static boolean onExplosionStart(net.minecraft.world.level.Level level, net.minecraft.world.level.ServerExplosion explosion)
    • onExplosionDetonate

      public static void onExplosionDetonate(net.minecraft.world.level.Level level, net.minecraft.world.level.ServerExplosion explosion, List<net.minecraft.world.entity.Entity> entities, List<net.minecraft.core.BlockPos> blocks)
    • getExplosionKnockback

      public static net.minecraft.world.phys.Vec3 getExplosionKnockback(net.minecraft.world.level.Level level, net.minecraft.world.level.ServerExplosion explosion, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 initialVelocity, List<net.minecraft.core.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 in
      explosion - Explosion that is happening
      entity - The entity caught in the explosion's blast
      initialVelocity - The explosion calculated velocity for the entity
      Returns:
      The new explosion velocity to add to the entity's existing velocity
    • onCreateWorldSpawn

      public static boolean onCreateWorldSpawn(net.minecraft.world.level.Level level, net.minecraft.world.level.storage.ServerLevelData settings)
    • onLivingHeal

      public static float onLivingHeal(net.minecraft.world.entity.LivingEntity entity, float amount)
    • onPotionAttemptBrew

      public static boolean onPotionAttemptBrew(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> stacks)
    • onPotionBrewed

      public static void onPotionBrewed(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> brewingItemStacks)
    • onPlayerBrewedPotion

      public static void onPlayerBrewedPotion(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
    • canEntityContinueSleeping

      public static boolean canEntityContinueSleeping(net.minecraft.world.entity.LivingEntity sleeper, @Nullable @Nullable net.minecraft.world.entity.player.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 net.minecraft.world.InteractionResult onArrowNock(net.minecraft.world.item.ItemStack item, net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, boolean hasAmmo)
    • onArrowLoose

      public static int onArrowLoose(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player, int charge, boolean hasAmmo)
    • onProjectileImpact

      public static boolean onProjectileImpact(net.minecraft.world.entity.projectile.Projectile projectile, net.minecraft.world.phys.HitResult ray)
    • loadLootTable

      @Nullable @Internal public static @Nullable net.minecraft.world.level.storage.loot.LootTable loadLootTable(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.resources.ResourceLocation name, net.minecraft.world.level.storage.loot.LootTable table)
      Fires the LootTableLoadEvent for non-empty loot tables and returns the table if the event was not canceled and the table was not set to LootTable.EMPTY in the event. Otherwise returns null which maps to an empty Optional in
      invalid reference
      LootDataType#deserialize(ResourceLocation, DynamicOps, Object)
    • canCreateFluidSource

      public static boolean canCreateFluidSource(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Checks if a fluid is allowed to create a fluid source. This fires the CreateFluidSourceEvent. By default, a fluid can create a source if it returns true to
      invalid reference
      IFluidStateExtension#canConvertToSource(Level, BlockPos)
    • onTrySpawnPortal

      public static Optional<net.minecraft.world.level.portal.PortalShape> onTrySpawnPortal(net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos, Optional<net.minecraft.world.level.portal.PortalShape> size)
    • onEnchantmentLevelSet

      public static int onEnchantmentLevelSet(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int enchantRow, int power, net.minecraft.world.item.ItemStack itemStack, int enchantmentLevel)
    • onEntityDestroyBlock

      public static boolean onEntityDestroyBlock(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    • canEntityGrief

      public static boolean canEntityGrief(net.minecraft.server.level.ServerLevel level, @Nullable @Nullable net.minecraft.world.entity.Entity entity)
      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 of GameRules.RULE_MOBGRIEFING.

      Parameters:
      level - The level of the action
      entity - The entity performing the action, or null if unknown.
      Returns:
    • fireBlockGrowFeature

      public static BlockGrowFeatureEvent fireBlockGrowFeature(net.minecraft.world.level.LevelAccessor level, net.minecraft.util.RandomSource rand, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.core.Holder<net.minecraft.world.level.levelgen.feature.ConfiguredFeature<?,?>> holder)
      Fires the BlockGrowFeatureEvent and returns the event object.
      Parameters:
      level - The level the feature will be grown in
      rand - The random source
      pos - The position the feature will be grown at
      holder - The feature to be grown, if any
    • alterGround

      public static AlterGroundEvent.StateProvider alterGround(net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator.Context ctx, List<net.minecraft.core.BlockPos> positions, AlterGroundEvent.StateProvider provider)
      Fires the AlterGroundEvent and retrieves the resulting AlterGroundEvent.StateProvider.
      Parameters:
      ctx - The tree decoration context for the current alteration.
      positions - The list of positions that are considered roots.
      provider - The original BlockStateProvider from the AlterGroundDecorator.
      Returns:
      The (possibly event-modified) AlterGroundEvent.StateProvider to be used for ground alteration.
    • fireChunkTicketLevelUpdated

      public static void fireChunkTicketLevelUpdated(net.minecraft.server.level.ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable @Nullable net.minecraft.server.level.ChunkHolder chunkHolder)
    • fireChunkWatch

      public static void fireChunkWatch(net.minecraft.server.level.ServerPlayer entity, net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.server.level.ServerLevel level)
    • fireChunkSent

      public static void fireChunkSent(net.minecraft.server.level.ServerPlayer entity, net.minecraft.world.level.chunk.LevelChunk chunk, net.minecraft.server.level.ServerLevel level)
    • fireChunkUnWatch

      public static void fireChunkUnWatch(net.minecraft.server.level.ServerPlayer entity, net.minecraft.world.level.ChunkPos chunkpos, net.minecraft.server.level.ServerLevel level)
    • onPistonMovePre

      public static boolean onPistonMovePre(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction direction, boolean extending)
    • onPistonMovePost

      public static void onPistonMovePost(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction direction, boolean extending)
    • onSleepFinished

      public static long onSleepFinished(net.minecraft.server.level.ServerLevel level, long newTime, long minTime)
    • onResourceReload

      public static List<net.minecraft.server.packs.resources.PreparableReloadListener> onResourceReload(net.minecraft.server.ReloadableServerResources serverResources, net.minecraft.core.RegistryAccess registryAccess)
      Fires the AddServerReloadListenersEvent and returns the sorted list of reload listeners.
      Parameters:
      serverResources - The just-created ReloadableServerResources instance.
      registryAccess - The registry access from the ReloadableServerRegistries.LoadResult.
      Returns:
      The sorted list of reload listeners.
      Throws:
      IllegalArgumentException - if ReloadListenerSort.sort(SortedReloadListenerEvent) detects a cycle.
    • onCommandRegister

      public static void onCommandRegister(com.mojang.brigadier.CommandDispatcher<net.minecraft.commands.CommandSourceStack> dispatcher, net.minecraft.commands.Commands.CommandSelection environment, net.minecraft.commands.CommandBuildContext context)
    • getEntitySizeForge

      public static EntityEvent.Size getEntitySizeForge(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.Pose pose, net.minecraft.world.entity.EntityDimensions size)
    • getEntitySizeForge

      public static EntityEvent.Size getEntitySizeForge(net.minecraft.world.entity.Entity entity, net.minecraft.world.entity.Pose pose, net.minecraft.world.entity.EntityDimensions oldSize, net.minecraft.world.entity.EntityDimensions newSize)
    • canLivingConvert

      public static boolean canLivingConvert(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity> outcome, Consumer<Integer> timer)
    • onLivingConvert

      public static void onLivingConvert(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.LivingEntity outcome)
    • onEntityTeleportCommand

      public static EntityTeleportEvent.TeleportCommand onEntityTeleportCommand(net.minecraft.world.entity.Entity entity, double targetX, double targetY, double targetZ)
    • onEntityTeleportSpreadPlayersCommand

      public static EntityTeleportEvent.SpreadPlayersCommand onEntityTeleportSpreadPlayersCommand(net.minecraft.world.entity.Entity entity, double targetX, double targetY, double targetZ)
    • onEnderTeleport

      public static EntityTeleportEvent.EnderEntity onEnderTeleport(net.minecraft.world.entity.LivingEntity entity, double targetX, double targetY, double targetZ)
    • onEnderPearlLand

      @Internal public static EntityTeleportEvent.EnderPearl onEnderPearlLand(net.minecraft.server.level.ServerPlayer entity, double targetX, double targetY, double targetZ, net.minecraft.world.entity.projectile.ThrownEnderpearl pearlEntity, float attackDamage, net.minecraft.world.phys.HitResult hitResult)
    • onItemConsumptionTeleport

      public static EntityTeleportEvent.ItemConsumption onItemConsumptionTeleport(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack itemStack, double targetX, double targetY, double targetZ)
    • onPermissionChanged

      public static boolean onPermissionChanged(com.mojang.authlib.GameProfile gameProfile, int newLevel, net.minecraft.server.players.PlayerList playerList)
    • firePlayerChangedDimensionEvent

      public static void firePlayerChangedDimensionEvent(net.minecraft.world.entity.player.Player player, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> fromDim, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> toDim)
    • firePlayerLoggedIn

      public static void firePlayerLoggedIn(net.minecraft.world.entity.player.Player player)
    • firePlayerLoggedOut

      public static void firePlayerLoggedOut(net.minecraft.world.entity.player.Player player)
    • firePlayerRespawnPositionEvent

      public static PlayerRespawnPositionEvent firePlayerRespawnPositionEvent(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.level.portal.TeleportTransition teleportTransition, boolean fromEndFight)
      Called by
      invalid reference
      PlayerList#respawn(ServerPlayer, boolean)
      before creating the new ServerPlayer to fire the PlayerRespawnPositionEvent
      Parameters:
      player - The old ServerPlayer that is being respawned
      fromEndFight - Whether the player is respawning because they jumped through the End return portal
      respawnLevel - The default level the player will respawn into
      respawnAngle - The angle the player will face when they respawn
      respawnPosition - The position in the level the player will respawn at
      Returns:
      The event
    • firePlayerRespawnEvent

      public static void firePlayerRespawnEvent(net.minecraft.server.level.ServerPlayer player, boolean fromEndFight)
      Called by
      invalid reference
      PlayerList#respawn(ServerPlayer, boolean)
      after creating and initializing the new ServerPlayer.
      Parameters:
      player - The new player instance created by the respawn process
      fromEndFight - Whether the player is respawning because they jumped through the End return portal
    • firePlayerCraftingEvent

      public static void firePlayerCraftingEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack crafted, net.minecraft.world.Container craftMatrix)
    • firePlayerSmeltedEvent

      public static void firePlayerSmeltedEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack smelted, int amountRemoved)
    • fireEntityTickPre

      public static EntityTickEvent.Pre fireEntityTickPre(net.minecraft.world.entity.Entity entity)
      Fires EntityTickEvent.Pre. Called from the head of LivingEntity.tick().
      Parameters:
      entity - The entity being ticked
      Returns:
      The event
    • fireEntityTickPost

      public static void fireEntityTickPost(net.minecraft.world.entity.Entity entity)
      Fires EntityTickEvent.Post. Called from the tail of LivingEntity.tick().
      Parameters:
      entity - The entity being ticked
    • firePlayerTickPre

      public static void firePlayerTickPre(net.minecraft.world.entity.player.Player player)
      Fires PlayerTickEvent.Pre. Called from the head of Player.tick().
      Parameters:
      player - The player being ticked
    • firePlayerTickPost

      public static void firePlayerTickPost(net.minecraft.world.entity.player.Player player)
      Fires PlayerTickEvent.Post. Called from the tail of Player.tick().
      Parameters:
      player - The player being ticked
    • fireLevelTickPre

      public static void fireLevelTickPre(net.minecraft.world.level.Level level, BooleanSupplier haveTime)
      Fires LevelTickEvent.Pre. Called from
      invalid reference
      Minecraft#tick()
      and MinecraftServer.tickChildren(BooleanSupplier) just before the try block for level tick is entered.
      Parameters:
      level - The level being ticked
      haveTime - The time supplier, indicating if there is remaining time to do work in the current tick.
    • fireLevelTickPost

      public static void fireLevelTickPost(net.minecraft.world.level.Level level, BooleanSupplier haveTime)
      Fires LevelTickEvent.Post. Called from
      invalid reference
      Minecraft#tick()
      and MinecraftServer.tickChildren(BooleanSupplier) just after the try block for level tick is exited.
      Parameters:
      level - The level being ticked
      haveTime - The time supplier, indicating if there is remaining time to do work in the current tick.
    • fireServerTickPre

      public static void fireServerTickPre(BooleanSupplier haveTime, net.minecraft.server.MinecraftServer server)
      Fires ServerTickEvent.Pre. Called from the head of MinecraftServer.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

      public static void fireServerTickPost(BooleanSupplier haveTime, net.minecraft.server.MinecraftServer server)
      Fires ServerTickEvent.Post. Called from the tail of MinecraftServer.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 net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> getPotentialSpawns(net.minecraft.world.level.LevelAccessor level, net.minecraft.world.entity.MobCategory category, net.minecraft.core.BlockPos pos, net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> oldList)
    • onStatAward

      public static StatAwardEvent onStatAward(net.minecraft.world.entity.player.Player player, net.minecraft.stats.Stat<?> stat, int value)
    • onAdvancementEarnedEvent

      @Internal public static void onAdvancementEarnedEvent(net.minecraft.world.entity.player.Player player, net.minecraft.advancements.AdvancementHolder earned)
    • onAdvancementProgressedEvent

      @Internal public static void onAdvancementProgressedEvent(net.minecraft.world.entity.player.Player player, net.minecraft.advancements.AdvancementHolder progressed, net.minecraft.advancements.AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType)
    • onEffectRemoved

      public static boolean onEffectRemoved(net.minecraft.world.entity.LivingEntity entity, net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect)
    • onEffectRemoved

      public static boolean onEffectRemoved(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.effect.MobEffectInstance effectInstance)
    • getEnchantmentLevelSpecific

      public static int getEnchantmentLevelSpecific(int level, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> ench)
      Fires GetEnchantmentLevelEvent 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.
    • getAllEnchantmentLevels

      public static net.minecraft.world.item.enchantment.ItemEnchantments getAllEnchantmentLevels(net.minecraft.world.item.enchantment.ItemEnchantments enchantments, net.minecraft.world.item.ItemStack stack, net.minecraft.core.HolderLookup.RegistryLookup<net.minecraft.world.item.enchantment.Enchantment> lookup)
      Fires GetEnchantmentLevelEvent 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(net.minecraft.world.item.CreativeModeTab tab, net.minecraft.resources.ResourceKey<net.minecraft.world.item.CreativeModeTab> tabKey, net.minecraft.world.item.CreativeModeTab.DisplayItemsGenerator originalGenerator, net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters params, net.minecraft.world.item.CreativeModeTab.Output output)
      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

      public static MobSplitEvent onMobSplit(net.minecraft.world.entity.Mob parent, List<net.minecraft.world.entity.Mob> children)
      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<net.minecraft.world.level.CustomSpawner> getCustomSpawners(net.minecraft.server.level.ServerLevel serverLevel, List<net.minecraft.world.level.CustomSpawner> customSpawners)
      Fires the ModifyCustomSpawnersEvent. Returns the custom spawners list.
      Parameters:
      serverLevel - The server level.
      customSpawners - The original custom spawners.
      Returns:
      The new custom spawners list.