Class ForgeHooks

java.lang.Object
net.minecraftforge.common.ForgeHooks

@Internal public final class ForgeHooks extends Object
FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY
  • Field Details Link icon

  • Constructor Details Link icon

    • ForgeHooks Link icon

      private ForgeHooks()
  • Method Details Link icon

    • canContinueUsing Link icon

      public static boolean canContinueUsing(@NotNull @NotNull ItemStack from, @NotNull @NotNull ItemStack to)
    • isCorrectToolForDrops Link icon

      public static boolean isCorrectToolForDrops(@NotNull @NotNull BlockState state, @NotNull @NotNull Player player)
    • onLivingMakeBrain Link icon

      public static Brain<?> onLivingMakeBrain(LivingEntity entity, Brain<?> originalBrain, com.mojang.serialization.Dynamic<?> dynamic)
    • onLivingAttack Link icon

      public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount)
    • onPlayerAttack Link icon

      public static boolean onPlayerAttack(LivingEntity entity, DamageSource src, float amount)
    • onLivingUseTotem Link icon

      public static boolean onLivingUseTotem(LivingEntity entity, DamageSource damageSource, ItemStack totem, InteractionHand hand)
    • onLivingHurt Link icon

      public static float onLivingHurt(LivingEntity entity, DamageSource src, float amount)
    • onLivingDamage Link icon

      public static float onLivingDamage(LivingEntity entity, DamageSource src, float amount)
    • onInteractEntityAt Link icon

      public static InteractionResult onInteractEntityAt(Entity entity, Player player, Vec3 vec3d, InteractionHand hand)
    • getLootingLevel Link icon

      public static int getLootingLevel(Entity target, @Nullable @Nullable Entity killer, @Nullable @Nullable DamageSource cause)
    • getLootingLevel Link icon

      public static int getLootingLevel(LivingEntity target, @Nullable @Nullable DamageSource cause, int level)
    • getEntityVisibilityMultiplier Link icon

      public static double getEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier)
    • isLivingOnLadder Link icon

      public static Optional<BlockPos> isLivingOnLadder(@NotNull @NotNull BlockState state, @NotNull @NotNull Level level, @NotNull @NotNull BlockPos pos, @NotNull @NotNull LivingEntity entity)
    • onLivingJump Link icon

      public static void onLivingJump(LivingEntity entity)
    • onPlayerTossEvent Link icon

      @Nullable public static @Nullable ItemEntity onPlayerTossEvent(@NotNull @NotNull Player player, @NotNull @NotNull ItemStack item, boolean includeName)
    • onServerChatSubmittedEvent Link icon

      @Nullable public static @Nullable Component onServerChatSubmittedEvent(ServerPlayer player, Component message)
    • newChatWithLinks Link icon

      public static Component newChatWithLinks(String string)
    • newChatWithLinks Link icon

      public static Component newChatWithLinks(String string, boolean allowMissingHeader)
    • dropXpForBlock Link icon

      public static void dropXpForBlock(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack)
    • onBlockBreakEvent Link icon

      public static int onBlockBreakEvent(Level level, GameType gameType, ServerPlayer entityPlayer, BlockPos pos)
    • onPlaceItemIntoWorld Link icon

      public static InteractionResult onPlaceItemIntoWorld(@NotNull @NotNull UseOnContext context)
    • onAnvilChange Link icon

      public static boolean onAnvilChange(AnvilMenu container, @NotNull @NotNull ItemStack left, @NotNull @NotNull ItemStack right, Container outputSlot, String name, long baseCost, Player player)
    • onGrindstoneTake Link icon

      public static boolean onGrindstoneTake(Container inputSlots, ContainerLevelAccess access, Function<Level,Integer> xpFunction)
    • setCraftingPlayer Link icon

      public static void setCraftingPlayer(Player player)
    • getCraftingPlayer Link icon

      public static Player getCraftingPlayer()
    • getCraftingRemainingItem Link icon

      @NotNull public static @NotNull ItemStack getCraftingRemainingItem(@NotNull @NotNull ItemStack stack)
    • onPlayerAttackTarget Link icon

      public static boolean onPlayerAttackTarget(Player player, Entity target)
    • onItemRightClick Link icon

      public static InteractionResult onItemRightClick(Player player, InteractionHand hand)
    • onChangeGameType Link icon

      public static GameType onChangeGameType(Player player, GameType currentGameType, GameType newGameType)
    • createLootTablePoolCodec Link icon

      public static <E extends LootPool> com.mojang.serialization.Codec<List<E>> createLootTablePoolCodec(com.mojang.serialization.Codec<E> vanilla)
    • getVanillaFluidType Link icon

      public static FluidType getVanillaFluidType(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
    • onCropsGrowPre Link icon

      public static boolean onCropsGrowPre(Level level, BlockPos pos, BlockState state, boolean def)
    • onCropsGrowPost Link icon

      public static void onCropsGrowPost(Level level, BlockPos pos, BlockState state)
    • getCriticalHit Link icon

      @Nullable public static @Nullable CriticalHitEvent getCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier)
    • getProjectile Link icon

      public static ItemStack getProjectile(LivingEntity entity, ItemStack projectileWeaponItem, ItemStack projectile)
      Hook to fire LivingGetProjectileEvent. Returns the ammo to be used.
    • getDefaultCreatorModId Link icon

      @Nullable public static @Nullable String getDefaultCreatorModId(@NotNull @NotNull ItemStack itemStack)
      Used as the default implementation of IForgeItem.getCreatorModId(net.minecraft.world.item.ItemStack). Call that method instead.
    • onFarmlandTrample Link icon

      public static boolean onFarmlandTrample(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity)
    • onNoteChange Link icon

      public static int onNoteChange(Level level, BlockPos pos, BlockState state, int old, int _new)
    • hasNoElements Link icon

      public static boolean hasNoElements(Ingredient ingredient)
    • getSerializer Link icon

      @Nullable public static @Nullable EntityDataSerializer<?> getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla)
    • getSerializerId Link icon

      public static int getSerializerId(EntityDataSerializer<?> serializer, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla)
    • canEntityDestroy Link icon

      public static boolean canEntityDestroy(Level level, BlockPos pos, LivingEntity entity)
    • getBurnTime Link icon

      public static int getBurnTime(ItemStack stack, @Nullable @Nullable RecipeType<?> recipeType)
      Gets the burn time of this itemstack.
    • updateBurns Link icon

      public static void updateBurns()
    • modifyLoot Link icon

      public static it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> modifyLoot(ResourceLocation lootTableId, it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> generatedLoot, 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
      API Note:
      The given context will be modified by this method to also store the ID of the loot table being queried.
    • getModPacks Link icon

      public static List<String> getModPacks()
    • getModPacksWithVanilla Link icon

      public static List<String> getModPacksWithVanilla()
    • getAttributesView Link icon

      @Deprecated public static Map<EntityType<? extends LivingEntity>,AttributeSupplier> getAttributesView()
      Deprecated.
    • modifyAttributes Link icon

      @Deprecated public static void modifyAttributes()
      Deprecated.
    • writeAdditionalLevelSaveData Link icon

      public static void writeAdditionalLevelSaveData(WorldData worldData, CompoundTag levelTag)
    • readAdditionalLevelSaveData Link icon

      @Internal public static void readAdditionalLevelSaveData(LevelStorageSource.LevelStorageAccess access, LevelStorageSource.LevelDirectory levelDirectory)
    • encodeLifecycle Link icon

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

      public static com.mojang.serialization.Lifecycle parseLifecycle(String lifecycle)
    • shouldSuppressEnderManAnger Link icon

      public static boolean shouldSuppressEnderManAnger(EnderMan enderMan, Player player, ItemStack mask)
    • prefixNamespace Link icon

      public static String prefixNamespace(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 Link icon

      public static boolean canUseEntitySelectors(SharedSuggestionProvider provider)
    • wrapRegistryLookup Link icon

      @Internal public static <T> HolderLookup.RegistryLookup<T> wrapRegistryLookup(HolderLookup.RegistryLookup<T> lookup)
    • onLivingBreathe Link icon

      public static void onLivingBreathe(LivingEntity entity, int consumeAirAmount, int refillAirAmount)
      Handles living entities being under water. 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 under water it will dismount if
      invalid reference
      IForgeEntity#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
      Implementation Note:
      This method needs to closely replicate the logic found right after the call site in LivingEntity.baseTick() as it overrides it.
    • onCreativeModeTabBuildContents Link icon

      public static void onCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output)
    • getCustomPayloadCodec Link icon

      @Internal public static <B extends FriendlyByteBuf> StreamCodec<B,? extends CustomPacketPayload> getCustomPayloadCodec(ResourceLocation id, int max)
    • onCustomPayload Link icon

      @Internal public static boolean onCustomPayload(CustomPacketPayload payload, Connection connection)
    • onCustomPayload Link icon

      @Internal public static boolean onCustomPayload(ClientboundCustomQueryPacket packet, Connection connection)
    • onCustomPayload Link icon

      @Internal public static boolean onCustomPayload(ServerboundCustomQueryAnswerPacket packet, Connection connection)
    • onCustomPayload Link icon

      @Internal public static boolean onCustomPayload(CustomPayloadEvent event)
    • handleClientConfigurationComplete Link icon

      @Internal public static void handleClientConfigurationComplete(Connection connection)
    • getEntitySpawnPacket Link icon

      @Internal public static Packet<ClientGamePacketListener> getEntitySpawnPacket(Entity entity)
    • readAndTestCondition Link icon

      @Internal public static boolean readAndTestCondition(RegistryOps<com.google.gson.JsonElement> ops, com.google.gson.JsonObject json)
    • writeCondition Link icon

      @Internal public static void writeCondition(ICondition condition, com.google.gson.JsonObject out)
    • readConditionalAdvancement Link icon

      @Nullable @Internal public static @Nullable com.google.gson.JsonObject readConditionalAdvancement(RegistryOps<com.google.gson.JsonElement> context, com.google.gson.JsonObject json)
    • enhanceIngredientCodec Link icon

      @Internal public static com.mojang.serialization.Codec<Ingredient> enhanceIngredientCodec(com.mojang.serialization.Codec<Ingredient> vanilla)
    • ingredientStreamCodec Link icon

      public static StreamCodec<RegistryFriendlyByteBuf,Ingredient> ingredientStreamCodec()
    • getDyeColorFromItemStack Link icon

      @Nullable public static @Nullable DyeColor getDyeColorFromItemStack(ItemStack stack)
    • gatherItemComponents Link icon

      public static DataComponentMap gatherItemComponents(Item item, DataComponentMap dataComponents)