Class CommonHooks

java.lang.Object
net.neoforged.neoforge.common.CommonHooks

public class CommonHooks extends Object
Class for various common (i.e. client and server-side) hooks.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Set<Class<?>>
     
    private static ThreadLocal<net.minecraft.world.entity.player.Player>
     
    private static final String
     
    private static final Map<net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>,net.minecraft.world.entity.ai.attributes.AttributeSupplier>
     
    private static final Lazy<Map<String,net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix.Conversion>>
     
    private static final org.apache.logging.log4j.Logger
     
    private static final String
     
    (package private) static final Pattern
     
    private static final Set<String>
     
    static final int
     
    private static final org.apache.logging.log4j.Marker
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Map<net.minecraft.world.inventory.RecipeBookType,com.mojang.datafixers.util.Pair<String,String>>
    buildRecipeBookTypeTagFields(Map<net.minecraft.world.inventory.RecipeBookType,com.mojang.datafixers.util.Pair<String,String>> vanillaMap)
     
    static boolean
    canContinueUsing(net.minecraft.world.item.ItemStack from, net.minecraft.world.item.ItemStack to)
     
    static boolean
    canCropGrow(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, boolean def)
    Checks if a crop can grow by firing CropGrowEvent.Pre.
    static boolean
    canEntityDestroy(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.LivingEntity entity)
     
    static boolean
    canMobEffectBeApplied(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.effect.MobEffectInstance effect)
    Checks if a mob effect can be applied to an entity by firing MobEffectEvent.Applicable.
    static boolean
    canUseEntitySelectors(net.minecraft.commands.SharedSuggestionProvider provider)
     
    static net.minecraft.world.item.component.ItemAttributeModifiers
    computeModifiedAttributes(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.component.ItemAttributeModifiers defaultModifiers)
    static net.minecraft.world.item.context.UseOnContext
    dispenseUseOnContext(net.minecraft.core.dispenser.BlockSource source, net.minecraft.world.item.ItemStack stack)
    Creates a UseOnContext for dispense behavior.
    static String
    encodeLifecycle(com.mojang.serialization.Lifecycle lifecycle)
     
    static net.minecraft.core.HolderLookup.Provider
    extractLookupProvider(net.minecraft.resources.RegistryOps<?> ops)
    Extracts a HolderLookup.Provider from the given ops, if possible.
    fireBlockBreak(net.minecraft.world.level.Level level, net.minecraft.world.level.GameType gameType, net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    Fires BlockEvent.BreakEvent, pre-emptively canceling the event based on the conditions that will cause the block to not be broken anyway.
    fireCriticalHit(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target, boolean vanillaCritical, float damageModifier)
    Fires the CriticalHitEvent and returns the resulting event.
    static void
    fireCropGrowPost(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
    fireSweepAttack(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target, boolean isVanillaSweep)
    Fires the SweepAttackEvent and returns the resulting event.
    static Map<net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>,net.minecraft.world.entity.ai.attributes.AttributeSupplier>
    Deprecated.
    static net.minecraft.world.entity.player.Player
     
    static net.minecraft.world.item.ItemStack
    getCraftingRemainder(net.minecraft.world.item.ItemStack stack)
     
    static @Nullable String
    getDefaultCreatorModId(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.world.item.ItemStack itemStack)
    static double
    getEntityVisibilityMultiplier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.Entity lookingEntity, double originalMultiplier)
     
    static List<String>
     
    static List<String>
     
    static net.minecraft.world.item.ItemStack
    getProjectile(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack projectileWeaponItem, net.minecraft.world.item.ItemStack projectile)
    private static String
    getRawText(net.minecraft.network.chat.Component message)
     
    static @Nullable net.minecraft.network.syncher.EntityDataSerializer<?>
    getSerializer(int id, net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap<net.minecraft.network.syncher.EntityDataSerializer<?>> vanilla)
     
    static int
    getSerializerId(net.minecraft.network.syncher.EntityDataSerializer<?> serializer, net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap<net.minecraft.network.syncher.EntityDataSerializer<?>> vanilla)
     
    static net.minecraft.network.chat.ChatDecorator
     
    static FluidType
    getVanillaFluidType(net.minecraft.world.level.material.Fluid fluid)
    Returns a vanilla fluid type for the given fluid.
    static void
    handleBlockDrops(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, List<net.minecraft.world.entity.item.ItemEntity> drops, @Nullable net.minecraft.world.entity.Entity breaker, net.minecraft.world.item.ItemStack tool)
    Fires the BlockDropsEvent when block drops (items and experience) are determined.
    static boolean
    isEntityInvulnerableTo(net.minecraft.world.entity.Entity entity, net.minecraft.world.damagesource.DamageSource source, boolean isInvul)
    Creates and posts an EntityInvulnerabilityCheckEvent.
    static Optional<net.minecraft.core.BlockPos>
    isLivingOnLadder(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.LivingEntity entity)
     
    private static boolean
     
    static @Nullable net.minecraft.world.effect.MobEffect
    loadMobEffect(net.minecraft.nbt.CompoundTag nbt, String key, @Nullable net.minecraft.world.effect.MobEffect fallback)
     
    static com.mojang.serialization.Codec<List<net.minecraft.world.level.storage.loot.LootPool>>
    lootPoolsCodec(BiConsumer<net.minecraft.world.level.storage.loot.LootPool,String> nameSetter)
     
    static void
    Marks a class as being safe to use as a data component.
    static void
    Deprecated.
    static List<net.minecraft.world.item.ItemStack>
    modifyLoot(List<net.minecraft.world.item.ItemStack> list, net.minecraft.world.level.storage.loot.LootContext context)
    static it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack>
    modifyLoot(net.minecraft.resources.ResourceLocation lootTableId, it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack> generatedLoot, net.minecraft.world.level.storage.loot.LootContext context)
    Handles the modification of loot table drops via the registered Global Loot Modifiers, so that custom effects can be processed.
    static net.minecraft.network.chat.Component
     
    static net.minecraft.network.chat.Component
    newChatWithLinks(String string, boolean allowMissingHeader)
     
    static boolean
    onAnvilChange(net.minecraft.world.inventory.AnvilMenu container, net.minecraft.world.item.ItemStack left, net.minecraft.world.item.ItemStack right, net.minecraft.world.Container outputSlot, String name, long baseCost, net.minecraft.world.entity.player.Player player)
     
    static float
    onAnvilRepair(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack output, net.minecraft.world.item.ItemStack left, net.minecraft.world.item.ItemStack right)
     
    static void
    onArmorHurt(net.minecraft.world.damagesource.DamageSource source, net.minecraft.world.entity.EquipmentSlot[] slots, float damage, net.minecraft.world.entity.LivingEntity armoredEntity)
    This is invoked in LivingEntity.doHurtEquipment(DamageSource, float, EquipmentSlot...) and replaces the existing item hurt and break logic with an event-sensitive version.
    static @Nullable net.minecraft.world.level.GameType
    onChangeGameType(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.GameType currentGameType, net.minecraft.world.level.GameType newGameType)
     
    static Collection<net.minecraft.world.item.CreativeModeTab>
    onCheckCreativeTabs(net.minecraft.world.item.CreativeModeTab... vanillaTabs)
     
    static void
    onChunkUnload(net.minecraft.world.entity.ai.village.poi.PoiManager poiManager, net.minecraft.world.level.chunk.ChunkAccess chunkAccess)
    The goal here is to fix the POI memory leak that happens due to SectionStorage.storage field never actually removing POIs long after they become irrelevant.
    onClientMineHold(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face)
     
    onDamageBlock(net.minecraft.world.entity.LivingEntity blocker, DamageContainer container, float blockedDamage, boolean originalBlocked)
    Creates, posts, and returns a LivingShieldBlockEvent.
    static void
    onDifficultyChange(net.minecraft.world.Difficulty difficulty, net.minecraft.world.Difficulty oldDifficulty)
     
    static void
    onEmptyClick(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
     
    static void
    onEmptyLeftClick(net.minecraft.world.entity.player.Player player)
     
    static void
    onEntityEnterSection(net.minecraft.world.entity.Entity entity, long packedOldPos, long packedNewPos)
     
    static boolean
    onEntityIncomingDamage(net.minecraft.world.entity.LivingEntity entity, DamageContainer container)
    Called after invulnerability checks in Entity.hurt(DamageSource, float), this method creates and posts the first event in the LivingEntity damage sequence, LivingIncomingDamageEvent.
    static boolean
    onFarmlandTrample(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, double fallDistance, net.minecraft.world.entity.Entity entity)
     
    static int
    onGrindstoneChange(net.minecraft.world.item.ItemStack top, net.minecraft.world.item.ItemStack bottom, net.minecraft.world.Container outputSlot, int xp)
     
    static boolean
    onGrindstoneTake(net.minecraft.world.Container inputSlots, net.minecraft.world.inventory.ContainerLevelAccess access, Function<net.minecraft.world.level.Level,Integer> xpFunction)
     
    static @Nullable net.minecraft.world.InteractionResult
    onInteractEntity(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity, net.minecraft.world.InteractionHand hand)
     
    static @Nullable net.minecraft.world.InteractionResult
    onInteractEntityAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.HitResult ray, net.minecraft.world.InteractionHand hand)
     
    static @Nullable net.minecraft.world.InteractionResult
    onInteractEntityAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.InteractionHand hand)
     
    static @Nullable net.minecraft.world.InteractionResult
    onItemRightClick(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
     
    static boolean
    onItemStackedOn(net.minecraft.world.item.ItemStack carriedItem, net.minecraft.world.item.ItemStack stackedOnItem, net.minecraft.world.inventory.Slot slot, net.minecraft.world.inventory.ClickAction action, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.SlotAccess carriedSlotAccess)
    Fires the ItemStackedOnOtherEvent, allowing items to handle custom behavior relating to being stacked together (i.e. how the bundle operates).
    onLeftClickBlock(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face, net.minecraft.network.protocol.game.ServerboundPlayerActionPacket.Action action)
     
    static void
    onLivingBreathe(net.minecraft.world.entity.LivingEntity entity, int consumeAirAmount, int refillAirAmount)
    Handles living entities being underwater.
    onLivingChangeTarget(net.minecraft.world.entity.LivingEntity entity, @Nullable net.minecraft.world.entity.LivingEntity originalTarget, LivingChangeTargetEvent.ILivingTargetType targetType)
     
    static void
    onLivingDamagePost(net.minecraft.world.entity.LivingEntity entity, DamageContainer container)
    Creates and posts a LivingDamageEvent.Post.
    static float
    onLivingDamagePre(net.minecraft.world.entity.LivingEntity entity, DamageContainer container)
    Creates and posts an LivingDamageEvent.Pre.
    static boolean
    onLivingDeath(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.damagesource.DamageSource src)
     
    static boolean
    onLivingDrops(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.damagesource.DamageSource source, Collection<net.minecraft.world.entity.item.ItemEntity> drops, boolean recentlyHit)
     
    onLivingFall(net.minecraft.world.entity.LivingEntity entity, double distance, float damageMultiplier)
     
    static void
    onLivingJump(net.minecraft.world.entity.LivingEntity entity)
     
    onLivingKnockBack(net.minecraft.world.entity.LivingEntity target, float strength, double ratioX, double ratioZ)
     
    onLivingSwapHandItems(net.minecraft.world.entity.LivingEntity livingEntity)
     
    static boolean
    onLivingUseTotem(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.damagesource.DamageSource damageSource, net.minecraft.world.item.ItemStack totem, net.minecraft.world.InteractionHand hand)
     
    static int
    onNoteChange(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int old, int _new)
     
    static net.minecraft.world.InteractionResult
    onPlaceItemIntoWorld(net.minecraft.world.item.context.UseOnContext context)
     
    static boolean
    onPlayerAttackTarget(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target)
     
    static void
    onPlayerEnchantItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, List<net.minecraft.world.item.enchantment.EnchantmentInstance> instances)
    Fires PlayerEnchantItemEvent in EnchantmentMenu.clickMenuButton(Player, int) after the enchants are applied to the item.
    static @Nullable net.minecraft.world.entity.item.ItemEntity
    onPlayerTossEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack item, boolean includeName)
     
    onRightClickBlock(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.BlockHitResult hitVec)
     
    static @Nullable net.minecraft.network.chat.Component
    onServerChatSubmittedEvent(net.minecraft.server.level.ServerPlayer player, String plain, net.minecraft.network.chat.Component decorated)
     
    static boolean
    onTravelToDimension(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
     
    static boolean
    onVanillaGameEvent(net.minecraft.world.level.Level level, net.minecraft.core.Holder<net.minecraft.world.level.gameevent.GameEvent> vanillaEvent, net.minecraft.world.phys.Vec3 pos, net.minecraft.world.level.gameevent.GameEvent.Context context)
     
    private static boolean
     
    static com.mojang.serialization.Lifecycle
     
    static String
    prefixNamespace(net.minecraft.resources.ResourceLocation registryKey)
    This method is used to prefix the path, where elements of the associated registry are stored, with their namespace, if it is not minecraft
    static void
    readAdditionalLevelSaveData(net.minecraft.nbt.CompoundTag rootTag, net.minecraft.world.level.storage.LevelStorageSource.LevelDirectory levelDirectory)
     
    static <T> @Nullable net.minecraft.core.HolderLookup.RegistryLookup<T>
    resolveLookup(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> key)
    Attempts to resolve a HolderLookup.RegistryLookup using the current global state.
    static void
    saveMobEffect(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.world.effect.MobEffect effect)
     
    static void
    sendRecipes(net.minecraft.server.level.ServerPlayer player, Set<net.minecraft.world.item.crafting.RecipeType<?>> recipeTypesToSend, net.minecraft.world.item.crafting.RecipeMap recipeMap)
    Determines whether the given players should be sent full recipe content or not and handles the sending.
    static void
    setCraftingPlayer(net.minecraft.world.entity.player.Player player)
     
    static boolean
    shouldSuppressEnderManAnger(net.minecraft.world.entity.monster.EnderMan enderMan, net.minecraft.world.entity.player.Player player)
     
    static boolean
    tryDispenseShearsHarvestBlock(net.minecraft.core.dispenser.BlockSource source, net.minecraft.world.item.ItemStack stack, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
    Attempts to modify target block using ItemAbilities.SHEARS_HARVEST in ShearsDispenseItemBehavior, consistent with vanilla beehive harvest behavior (also controlled by ItemAbilities.SHEARS_HARVEST).
    static void
    validateComponent(@Nullable Object dataComponent)
    Checks that all data components override equals and hashCode.
    static <T> net.minecraft.core.HolderLookup.RegistryLookup<T>
    wrapRegistryLookup(net.minecraft.core.HolderLookup.RegistryLookup<T> lookup)
     
    static void
    writeAdditionalLevelSaveData(net.minecraft.world.level.storage.WorldData worldData, net.minecraft.nbt.CompoundTag levelTag)
     

    Methods inherited from class java.lang.Object

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

    • LOGGER

      private static final org.apache.logging.log4j.Logger LOGGER
    • WORLDPERSISTENCE

      private static final org.apache.logging.log4j.Marker WORLDPERSISTENCE
    • URL_PATTERN

      static final Pattern URL_PATTERN
    • craftingPlayer

      private static ThreadLocal<net.minecraft.world.entity.player.Player> craftingPlayer
    • VANILLA_SERIALIZER_LIMIT

      public static final int VANILLA_SERIALIZER_LIMIT
      See Also:
    • VANILLA_DIMS

      private static final Set<String> VANILLA_DIMS
    • DIMENSIONS_KEY

      private static final String DIMENSIONS_KEY
      See Also:
    • SEED_KEY

      private static final String SEED_KEY
      See Also:
    • FORGE_ATTRIBUTES

      private static final Map<net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>,net.minecraft.world.entity.ai.attributes.AttributeSupplier> FORGE_ATTRIBUTES
    • FORGE_CONVERSION_MAP

      private static final Lazy<Map<String,net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix.Conversion>> FORGE_CONVERSION_MAP
    • checkedComponentClasses

      private static final Set<Class<?>> checkedComponentClasses
  • Constructor Details

    • CommonHooks

      public CommonHooks()
  • Method Details

    • canContinueUsing

      public static boolean canContinueUsing(net.minecraft.world.item.ItemStack from, net.minecraft.world.item.ItemStack to)
    • onItemStackedOn

      public static boolean onItemStackedOn(net.minecraft.world.item.ItemStack carriedItem, net.minecraft.world.item.ItemStack stackedOnItem, net.minecraft.world.inventory.Slot slot, net.minecraft.world.inventory.ClickAction action, net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.SlotAccess carriedSlotAccess)
      Fires the ItemStackedOnOtherEvent, allowing items to handle custom behavior relating to being stacked together (i.e. how the bundle operates).

      Called from AbstractContainerMenu.doClick(int, int, net.minecraft.world.inventory.ClickType, net.minecraft.world.entity.player.Player) in the utility method AbstractContainerMenu.tryItemClickBehaviourOverride(net.minecraft.world.entity.player.Player, net.minecraft.world.inventory.ClickAction, net.minecraft.world.inventory.Slot, net.minecraft.world.item.ItemStack, net.minecraft.world.item.ItemStack) before either ItemStack.overrideStackedOnOther(net.minecraft.world.inventory.Slot, net.minecraft.world.inventory.ClickAction, net.minecraft.world.entity.player.Player) or ItemStack.overrideOtherStackedOnMe(net.minecraft.world.item.ItemStack, net.minecraft.world.inventory.Slot, net.minecraft.world.inventory.ClickAction, net.minecraft.world.entity.player.Player, net.minecraft.world.entity.SlotAccess) is called.

      Parameters:
      carriedItem - The item currently held by the player, being clicked into the slot
      stackedOnItem - The item currently present in the clicked slot
      slot - The Slot being clicked
      action - The click action being performed
      player - The player who clicked the slot
      carriedSlotAccess - A slot access permitting changing the carried item.
      Returns:
      True if the event was cancelled, indicating that a mod has handled the click; false otherwise
    • onDifficultyChange

      public static void onDifficultyChange(net.minecraft.world.Difficulty difficulty, net.minecraft.world.Difficulty oldDifficulty)
    • onLivingChangeTarget

      public static LivingChangeTargetEvent onLivingChangeTarget(net.minecraft.world.entity.LivingEntity entity, @Nullable @Nullable net.minecraft.world.entity.LivingEntity originalTarget, LivingChangeTargetEvent.ILivingTargetType targetType)
    • isEntityInvulnerableTo

      public static boolean isEntityInvulnerableTo(net.minecraft.world.entity.Entity entity, net.minecraft.world.damagesource.DamageSource source, boolean isInvul)
      Creates and posts an EntityInvulnerabilityCheckEvent. This is invoked in Entity.isInvulnerableToBase(DamageSource) and returns a post-listener result to the invulnerability status of the entity to the damage source.
      Parameters:
      entity - the entity being checked for invulnerability
      source - the damage source being applied for this check
      isInvul - whether this entity is invulnerable according to preceding/vanilla logic
      Returns:
      if this entity is invulnerable
    • onEntityIncomingDamage

      public static boolean onEntityIncomingDamage(net.minecraft.world.entity.LivingEntity entity, DamageContainer container)
      Called after invulnerability checks in Entity.hurt(DamageSource, float), this method creates and posts the first event in the LivingEntity damage sequence, LivingIncomingDamageEvent.
      Parameters:
      entity - the entity to receive damage
      container - the newly instantiated container for damage to be dealt. Most properties of the container will be empty at this stage.
      Returns:
      if the event is cancelled and no damage will be applied to the entity
    • onLivingKnockBack

      public static LivingKnockBackEvent onLivingKnockBack(net.minecraft.world.entity.LivingEntity target, float strength, double ratioX, double ratioZ)
    • onLivingUseTotem

      public static boolean onLivingUseTotem(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.damagesource.DamageSource damageSource, net.minecraft.world.item.ItemStack totem, net.minecraft.world.InteractionHand hand)
    • onLivingDamagePre

      public static float onLivingDamagePre(net.minecraft.world.entity.LivingEntity entity, DamageContainer container)
      Creates and posts an LivingDamageEvent.Pre. This is invoked in
      invalid reference
      LivingEntity#actuallyHurt(DamageSource, float)
      and
      invalid reference
      Player#actuallyHurt(DamageSource, float)
      and requires access to the internal field LivingEntity.damageContainers as a parameter.
      Parameters:
      entity - the entity to receive damage
      container - the container object holding the final values of the damage pipeline while they are still mutable
      Returns:
      the current damage value to be applied to the entity's health
    • onLivingDamagePost

      public static void onLivingDamagePost(net.minecraft.world.entity.LivingEntity entity, DamageContainer container)
      Creates and posts a LivingDamageEvent.Post. This is invoked in
      invalid reference
      LivingEntity#actuallyHurt(DamageSource, float)
      and
      invalid reference
      Player#actuallyHurt(DamageSource, float)
      and requires access to the internal field LivingEntity.damageContainers as a parameter.
      Parameters:
      entity - the entity to receive damage
      container - the container object holding the truly final values of the damage pipeline. The values of this container and used to instantiate final fields in the event.
    • onArmorHurt

      public static void onArmorHurt(net.minecraft.world.damagesource.DamageSource source, net.minecraft.world.entity.EquipmentSlot[] slots, float damage, net.minecraft.world.entity.LivingEntity armoredEntity)
      This is invoked in LivingEntity.doHurtEquipment(DamageSource, float, EquipmentSlot...) and replaces the existing item hurt and break logic with an event-sensitive version.
      Each armor slot is collected and passed into a ArmorHurtEvent and posted. If not cancelled, the final durability loss values for each equipment item from the event will be applied.
      Parameters:
      source - the damage source applied to the entity and armor
      slots - an array of applicable slots for damage
      damage - the durability damage individual items will receive
      armoredEntity - the entity wearing the armor
    • onLivingDeath

      public static boolean onLivingDeath(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.damagesource.DamageSource src)
    • onLivingDrops

      public static boolean onLivingDrops(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.damagesource.DamageSource source, Collection<net.minecraft.world.entity.item.ItemEntity> drops, boolean recentlyHit)
    • onLivingFall

      public static LivingFallEvent onLivingFall(net.minecraft.world.entity.LivingEntity entity, double distance, float damageMultiplier)
    • getEntityVisibilityMultiplier

      public static double getEntityVisibilityMultiplier(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.Entity lookingEntity, double originalMultiplier)
    • isLivingOnLadder

      public static Optional<net.minecraft.core.BlockPos> isLivingOnLadder(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.LivingEntity entity)
    • onLivingJump

      public static void onLivingJump(net.minecraft.world.entity.LivingEntity entity)
    • onPlayerTossEvent

      @Nullable public static @Nullable net.minecraft.world.entity.item.ItemEntity onPlayerTossEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack item, boolean includeName)
    • onVanillaGameEvent

      public static boolean onVanillaGameEvent(net.minecraft.world.level.Level level, net.minecraft.core.Holder<net.minecraft.world.level.gameevent.GameEvent> vanillaEvent, net.minecraft.world.phys.Vec3 pos, net.minecraft.world.level.gameevent.GameEvent.Context context)
    • getRawText

      private static String getRawText(net.minecraft.network.chat.Component message)
    • onServerChatSubmittedEvent

      @Nullable public static @Nullable net.minecraft.network.chat.Component onServerChatSubmittedEvent(net.minecraft.server.level.ServerPlayer player, String plain, net.minecraft.network.chat.Component decorated)
    • getServerChatSubmittedDecorator

      public static net.minecraft.network.chat.ChatDecorator getServerChatSubmittedDecorator()
    • newChatWithLinks

      public static net.minecraft.network.chat.Component newChatWithLinks(String string)
    • newChatWithLinks

      public static net.minecraft.network.chat.Component newChatWithLinks(String string, boolean allowMissingHeader)
    • handleBlockDrops

      public static void handleBlockDrops(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, @Nullable @Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity, List<net.minecraft.world.entity.item.ItemEntity> drops, @Nullable @Nullable net.minecraft.world.entity.Entity breaker, net.minecraft.world.item.ItemStack tool)
      Fires the BlockDropsEvent when block drops (items and experience) are determined. If the event is not cancelled, all drops will be added to the world, and then BlockBehaviour.spawnAfterBreak(net.minecraft.world.level.block.state.BlockState, net.minecraft.server.level.ServerLevel, net.minecraft.core.BlockPos, net.minecraft.world.item.ItemStack, boolean) will be called.
      Parameters:
      level - The level
      pos - The broken block's position
      state - The broken block's state
      blockEntity - The block entity from the given position
      drops - The list of all items dropped by the block, captured from Block.getDrops(net.minecraft.world.level.block.state.BlockState, net.minecraft.server.level.ServerLevel, net.minecraft.core.BlockPos, net.minecraft.world.level.block.entity.BlockEntity)
      breaker - The entity who broke the block, or null if unknown
      tool - The tool used when breaking the block; may be empty
    • fireBlockBreak

      public static BlockEvent.BreakEvent fireBlockBreak(net.minecraft.world.level.Level level, net.minecraft.world.level.GameType gameType, net.minecraft.server.level.ServerPlayer player, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Fires BlockEvent.BreakEvent, pre-emptively canceling the event based on the conditions that will cause the block to not be broken anyway.

      Note that undoing the pre-cancel will not permit breaking the block, since the vanilla conditions will always be checked.

      Parameters:
      level - The level
      gameType - The game type of the breaking player
      player - The breaking player
      pos - The position of the block being broken
      state - The state of the block being broken
      Returns:
      The event
    • onPlaceItemIntoWorld

      public static net.minecraft.world.InteractionResult onPlaceItemIntoWorld(net.minecraft.world.item.context.UseOnContext context)
    • onPlayerEnchantItem

      public static void onPlayerEnchantItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, List<net.minecraft.world.item.enchantment.EnchantmentInstance> instances)
      Fires PlayerEnchantItemEvent in EnchantmentMenu.clickMenuButton(Player, int) after the enchants are applied to the item.
      Parameters:
      player - the player who clicked the menu button
      stack - the item enchanted
      instances - the specific enchantments that were applied to the item.
    • onAnvilChange

      public static boolean onAnvilChange(net.minecraft.world.inventory.AnvilMenu container, net.minecraft.world.item.ItemStack left, net.minecraft.world.item.ItemStack right, net.minecraft.world.Container outputSlot, String name, long baseCost, net.minecraft.world.entity.player.Player player)
    • onAnvilRepair

      public static float onAnvilRepair(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack output, net.minecraft.world.item.ItemStack left, net.minecraft.world.item.ItemStack right)
    • onGrindstoneChange

      public static int onGrindstoneChange(net.minecraft.world.item.ItemStack top, net.minecraft.world.item.ItemStack bottom, net.minecraft.world.Container outputSlot, int xp)
    • onGrindstoneTake

      public static boolean onGrindstoneTake(net.minecraft.world.Container inputSlots, net.minecraft.world.inventory.ContainerLevelAccess access, Function<net.minecraft.world.level.Level,Integer> xpFunction)
    • setCraftingPlayer

      public static void setCraftingPlayer(net.minecraft.world.entity.player.Player player)
    • getCraftingPlayer

      public static net.minecraft.world.entity.player.Player getCraftingPlayer()
    • getCraftingRemainder

      public static net.minecraft.world.item.ItemStack getCraftingRemainder(net.minecraft.world.item.ItemStack stack)
    • onPlayerAttackTarget

      public static boolean onPlayerAttackTarget(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target)
    • onTravelToDimension

      public static boolean onTravelToDimension(net.minecraft.world.entity.Entity entity, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
    • onInteractEntityAt

      @Nullable public static @Nullable net.minecraft.world.InteractionResult onInteractEntityAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.HitResult ray, net.minecraft.world.InteractionHand hand)
    • onInteractEntityAt

      @Nullable public static @Nullable net.minecraft.world.InteractionResult onInteractEntityAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity, net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.InteractionHand hand)
    • onInteractEntity

      @Nullable public static @Nullable net.minecraft.world.InteractionResult onInteractEntity(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity entity, net.minecraft.world.InteractionHand hand)
    • onItemRightClick

      @Nullable public static @Nullable net.minecraft.world.InteractionResult onItemRightClick(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
    • onLeftClickBlock

      public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face, net.minecraft.network.protocol.game.ServerboundPlayerActionPacket.Action action)
    • onClientMineHold

      public static PlayerInteractEvent.LeftClickBlock onClientMineHold(net.minecraft.world.entity.player.Player player, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction face)
    • onRightClickBlock

      public static PlayerInteractEvent.RightClickBlock onRightClickBlock(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.BlockHitResult hitVec)
    • onEmptyClick

      public static void onEmptyClick(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand)
    • onEmptyLeftClick

      public static void onEmptyLeftClick(net.minecraft.world.entity.player.Player player)
    • onChangeGameType

      @Nullable public static @Nullable net.minecraft.world.level.GameType onChangeGameType(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.GameType currentGameType, net.minecraft.world.level.GameType newGameType)
      Returns:
      null if game type should not be changed, desired new GameType otherwise
    • lootPoolsCodec

      @Internal public static com.mojang.serialization.Codec<List<net.minecraft.world.level.storage.loot.LootPool>> lootPoolsCodec(BiConsumer<net.minecraft.world.level.storage.loot.LootPool,String> nameSetter)
    • getVanillaFluidType

      public static FluidType getVanillaFluidType(net.minecraft.world.level.material.Fluid fluid)
      Returns a vanilla fluid type for the given fluid.
      Parameters:
      fluid - the fluid looking for its type
      Returns:
      the type of the fluid if vanilla
      Throws:
      RuntimeException - if the fluid is not a vanilla one
    • onCheckCreativeTabs

      public static Collection<net.minecraft.world.item.CreativeModeTab> onCheckCreativeTabs(net.minecraft.world.item.CreativeModeTab... vanillaTabs)
    • canCropGrow

      public static boolean canCropGrow(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, boolean def)
      Checks if a crop can grow by firing CropGrowEvent.Pre.
      Parameters:
      level - The level the crop is in
      pos - The position of the crop
      state - The state of the crop
      def - The result of the default checks performed by the crop.
      Returns:
      true if the crop can grow
    • fireCropGrowPost

      public static void fireCropGrowPost(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    • fireCriticalHit

      public static CriticalHitEvent fireCriticalHit(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target, boolean vanillaCritical, float damageModifier)
      Fires the CriticalHitEvent and returns the resulting event.
      Parameters:
      player - The attacking player
      target - The attack target
      vanillaCritical - If the attack would have been a critical hit by vanilla's rules in Player.attack(Entity).
      damageModifier - The base damage modifier. Vanilla critical hits have a damage modifier of 1.5.
    • fireSweepAttack

      public static SweepAttackEvent fireSweepAttack(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.Entity target, boolean isVanillaSweep)
      Fires the SweepAttackEvent and returns the resulting event.
      Parameters:
      player - The attacking player.
      target - The attack target.
      isVanillaSweep - If the attack would have been a sweep attack by vanilla's rules in Player.attack(Entity).
    • computeModifiedAttributes

      public static net.minecraft.world.item.component.ItemAttributeModifiers computeModifiedAttributes(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.component.ItemAttributeModifiers defaultModifiers)
      Hook to fire ItemAttributeModifierEvent. Modders should use ItemStack.forEachModifier(EquipmentSlot, BiConsumer) instead.
    • getProjectile

      public static net.minecraft.world.item.ItemStack getProjectile(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack projectileWeaponItem, net.minecraft.world.item.ItemStack projectile)
      Hook to fire LivingGetProjectileEvent. Returns the ammo to be used.
    • getDefaultCreatorModId

      @Nullable public static @Nullable String getDefaultCreatorModId(net.minecraft.core.HolderLookup.Provider registries, net.minecraft.world.item.ItemStack itemStack)
    • onFarmlandTrample

      public static boolean onFarmlandTrample(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, double fallDistance, net.minecraft.world.entity.Entity entity)
    • onNoteChange

      public static int onNoteChange(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int old, int _new)
    • getSerializer

      @Nullable public static @Nullable net.minecraft.network.syncher.EntityDataSerializer<?> getSerializer(int id, net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap<net.minecraft.network.syncher.EntityDataSerializer<?>> vanilla)
    • getSerializerId

      public static int getSerializerId(net.minecraft.network.syncher.EntityDataSerializer<?> serializer, net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap<net.minecraft.network.syncher.EntityDataSerializer<?>> vanilla)
    • canEntityDestroy

      public static boolean canEntityDestroy(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.LivingEntity entity)
    • modifyLoot

      @Deprecated public static List<net.minecraft.world.item.ItemStack> modifyLoot(List<net.minecraft.world.item.ItemStack> list, net.minecraft.world.level.storage.loot.LootContext context)
      All loot table drops should be passed to this function so that mod added effects (e.g. smelting enchantments) can be processed.
      Parameters:
      list - The loot generated
      context - The loot context that generated that loot
      Returns:
      The modified list
    • modifyLoot

      public static it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack> modifyLoot(net.minecraft.resources.ResourceLocation lootTableId, it.unimi.dsi.fastutil.objects.ObjectArrayList<net.minecraft.world.item.ItemStack> generatedLoot, net.minecraft.world.level.storage.loot.LootContext context)
      Handles the modification of loot table drops via the registered Global Loot Modifiers, so that custom effects can be processed.

      All loot-table generated loot should be passed to this function.

      Parameters:
      lootTableId - The ID of the loot table currently being queried
      generatedLoot - The loot generated by the loot table
      context - The loot context that generated the loot, unmodified
      Returns:
      The modified list of drops
    • getModDataPacks

      public static List<String> getModDataPacks()
    • getModDataPacksWithVanilla

      public static List<String> getModDataPacksWithVanilla()
    • getAttributesView

      @Deprecated public static Map<net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>,net.minecraft.world.entity.ai.attributes.AttributeSupplier> getAttributesView()
      Deprecated.
      FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY
    • modifyAttributes

      @Deprecated public static void modifyAttributes()
      Deprecated.
      FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY
    • onEntityEnterSection

      public static void onEntityEnterSection(net.minecraft.world.entity.Entity entity, long packedOldPos, long packedNewPos)
    • onDamageBlock

      public static LivingShieldBlockEvent onDamageBlock(net.minecraft.world.entity.LivingEntity blocker, DamageContainer container, float blockedDamage, boolean originalBlocked)
      Creates, posts, and returns a LivingShieldBlockEvent. This method is invoked in Entity.hurt(DamageSource, float) and requires internal access to the top entry in the protected field LivingEntity.damageContainers as a parameter.
      Parameters:
      blocker - the entity performing the block
      container - the entity's internal damage container for accessing current values in the damage pipeline at the time of this invocation.
      blockedDamage - the amount of damage that would be blocked
      originalBlocked - whether this entity is blocking according to preceding/vanilla logic
      Returns:
      the event object after event listeners have been invoked.
    • onLivingSwapHandItems

      public static LivingSwapItemsEvent.Hands onLivingSwapHandItems(net.minecraft.world.entity.LivingEntity livingEntity)
    • writeAdditionalLevelSaveData

      @Internal public static void writeAdditionalLevelSaveData(net.minecraft.world.level.storage.WorldData worldData, net.minecraft.nbt.CompoundTag levelTag)
    • readAdditionalLevelSaveData

      @Internal public static void readAdditionalLevelSaveData(net.minecraft.nbt.CompoundTag rootTag, net.minecraft.world.level.storage.LevelStorageSource.LevelDirectory levelDirectory)
      Parameters:
      rootTag - Level data file contents.
      levelDirectory - Level currently being loaded.
    • encodeLifecycle

      public static String encodeLifecycle(com.mojang.serialization.Lifecycle lifecycle)
    • parseLifecycle

      public static com.mojang.serialization.Lifecycle parseLifecycle(String lifecycle)
    • saveMobEffect

      public static void saveMobEffect(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.world.effect.MobEffect effect)
    • loadMobEffect

      @Nullable public static @Nullable net.minecraft.world.effect.MobEffect loadMobEffect(net.minecraft.nbt.CompoundTag nbt, String key, @Nullable @Nullable net.minecraft.world.effect.MobEffect fallback)
    • shouldSuppressEnderManAnger

      public static boolean shouldSuppressEnderManAnger(net.minecraft.world.entity.monster.EnderMan enderMan, net.minecraft.world.entity.player.Player player)
    • prefixNamespace

      public static String prefixNamespace(net.minecraft.resources.ResourceLocation registryKey)

      This method is used to prefix the path, where elements of the associated registry are stored, with their namespace, if it is not minecraft

      This rules conflicts with equal paths out. If for example the mod fancy_cheese adds a registry named cheeses, but the mod awesome_cheese also adds a registry called cheeses, they are going to have the same path cheeses, just with different namespaces. If additional_cheese wants to add additional cheese to awesome_cheese, but not fancy_cheese, it can not differentiate both. Both paths will look like data/additional_cheese/cheeses.

      The fix, which is applied here prefixes the path of the registry with the namespace, so fancy_cheese's registry stores its elements in data/<namespace>/fancy_cheese/cheeses and awesome_cheese's registry stores its elements in data/namespace/awesome_cheese/cheeses

      Parameters:
      registryKey - key of the registry
      Returns:
      path of the registry key. Prefixed with the namespace if it is not "minecraft"
    • canUseEntitySelectors

      public static boolean canUseEntitySelectors(net.minecraft.commands.SharedSuggestionProvider provider)
    • wrapRegistryLookup

      @Internal public static <T> net.minecraft.core.HolderLookup.RegistryLookup<T> wrapRegistryLookup(net.minecraft.core.HolderLookup.RegistryLookup<T> lookup)
    • onLivingBreathe

      public static void onLivingBreathe(net.minecraft.world.entity.LivingEntity entity, int consumeAirAmount, int refillAirAmount)
      Handles living entities being underwater. This fires the LivingBreatheEvent and if the entity's air supply is less than or equal to zero also the LivingDrownEvent. Additionally, when the entity is underwater it will dismount if IEntityExtension.canBeRiddenUnderFluidType(FluidType, Entity) returns false.
      Parameters:
      entity - The living entity which is currently updated
      consumeAirAmount - The amount of air to consume when the entity is unable to breathe
      refillAirAmount - The amount of air to refill when the entity is able to breathe
    • markComponentClassAsValid

      public static void markComponentClassAsValid(Class<?> clazz)
      Marks a class as being safe to use as a data component. Keep in mind that data components are compared with Object.equals(Object) and hashed with Object.hashCode(). They must also be immutable.

      Only call this method if the default implementations of Object.equals(Object) and Object.hashCode() are suitable for this class, and if instances of this class are immutable. Typically, this is only the case for singletons such as Block instances.

    • validateComponent

      @Internal public static void validateComponent(@Nullable @Nullable Object dataComponent)
      Checks that all data components override equals and hashCode.
    • isPotentialRegistryObject

      private static boolean isPotentialRegistryObject(Object value)
    • overridesEqualsAndHashCode

      private static boolean overridesEqualsAndHashCode(Class<?> clazz)
    • onChunkUnload

      public static void onChunkUnload(net.minecraft.world.entity.ai.village.poi.PoiManager poiManager, net.minecraft.world.level.chunk.ChunkAccess chunkAccess)
      The goal here is to fix the POI memory leak that happens due to SectionStorage.storage field never actually removing POIs long after they become irrelevant. We do it here in chunk unload event so that chunk that are fully unloaded now gets the POI removed from the POI cached storage map.
    • canMobEffectBeApplied

      public static boolean canMobEffectBeApplied(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.effect.MobEffectInstance effect)
      Checks if a mob effect can be applied to an entity by firing MobEffectEvent.Applicable.
      Parameters:
      entity - The target entity the mob effect is being applied to.
      effect - The mob effect being applied.
      Returns:
      True if the mob effect can be applied, otherwise false.
    • resolveLookup

      @Nullable public static <T> @Nullable net.minecraft.core.HolderLookup.RegistryLookup<T> resolveLookup(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> key)
      Attempts to resolve a HolderLookup.RegistryLookup using the current global state.

      Prioritizes the server's lookup, only attempting to retrieve it from the client if the server is unavailable.

      Type Parameters:
      T - The type of registry being looked up
      Parameters:
      key - The resource key for the target registry
      Returns:
      A registry access, if one was available.
    • extractLookupProvider

      public static net.minecraft.core.HolderLookup.Provider extractLookupProvider(net.minecraft.resources.RegistryOps<?> ops)
      Extracts a HolderLookup.Provider from the given ops, if possible.
      Throws:
      IllegalArgumentException - if the ops were not created using a HolderLookup.Provider
    • dispenseUseOnContext

      public static net.minecraft.world.item.context.UseOnContext dispenseUseOnContext(net.minecraft.core.dispenser.BlockSource source, net.minecraft.world.item.ItemStack stack)
      Creates a UseOnContext for dispense behavior.
      Parameters:
      source - the block source context of the dispense behavior
      stack - the dispensed item stack
      Returns:
      a UseOnContext representing the dispense behavior
    • tryDispenseShearsHarvestBlock

      public static boolean tryDispenseShearsHarvestBlock(net.minecraft.core.dispenser.BlockSource source, net.minecraft.world.item.ItemStack stack, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
      Attempts to modify target block using ItemAbilities.SHEARS_HARVEST in ShearsDispenseItemBehavior, consistent with vanilla beehive harvest behavior (also controlled by ItemAbilities.SHEARS_HARVEST).

      The beehive harvest behavior is not implemented by IBlockExtension.getToolModifiedState(BlockState, UseOnContext, ItemAbility, boolean) and thus will still be controlled by ShearsDispenseItemBehavior.tryShearBeehive(ServerLevel, BlockPos) by default.

      Mods may subscribe to BlockEvent.BlockToolModificationEvent to override vanilla beehive harvest behavior by setting a non-null BlockState result.

    • buildRecipeBookTypeTagFields

      public static Map<net.minecraft.world.inventory.RecipeBookType,com.mojang.datafixers.util.Pair<String,String>> buildRecipeBookTypeTagFields(Map<net.minecraft.world.inventory.RecipeBookType,com.mojang.datafixers.util.Pair<String,String>> vanillaMap)
    • sendRecipes

      public static void sendRecipes(net.minecraft.server.level.ServerPlayer player, Set<net.minecraft.world.item.crafting.RecipeType<?>> recipeTypesToSend, net.minecraft.world.item.crafting.RecipeMap recipeMap)
      Determines whether the given players should be sent full recipe content or not and handles the sending.