Package net.minecraftforge.common
Class ForgeHooks
java.lang.Object
net.minecraftforge.common.ForgeHooks
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Supplier<com.mojang.serialization.Codec<MappedRegistry<LevelStem>>>private static ThreadLocal<Player>private static Stringprivate static Map<EntityType<? extends LivingEntity>,AttributeSupplier>private static org.apache.logging.log4j.Markerprivate static org.apache.logging.log4j.Loggerprivate static ThreadLocal<Deque<ForgeHooks.LootTableContext>>private static Stringprivate static Map<EntityDataSerializer<?>,DataSerializerEntry>(package private) static Patternprivate static Map<IRegistryDelegate<Item>,Integer> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanContinueUsing(ItemStack from, ItemStack to)static booleancanEntityDestroy(Level world, BlockPos pos, LivingEntity entity)static intcanEntitySpawn(Mob entity, LevelAccessor world, double x, double y, double z, BaseSpawner spawner, MobSpawnType spawnReason)static FluidAttributescreateVanillaFluidAttributes(Fluid fluid)static <T> voiddeserializeTagAdditions(List<Tag.Entry> list, com.google.gson.JsonObject json, List<Tag.BuilderEntry> allList)static BiomeenhanceBiome(ResourceLocation name, Biome.ClimateSettings climate, Biome.BiomeCategory category, Float depth, Float scale, BiomeSpecialEffects effects, BiomeGenerationSettings gen, MobSpawnSettings spawns, com.mojang.serialization.codecs.RecordCodecBuilder.Instance<Biome> codec, ForgeHooks.BiomeCallbackFunction callback)static voidfixNullStructureReferences(ChunkAccess chunk, Map<StructureFeature<?>,it.unimi.dsi.fastutil.longs.LongSet> structureReferences)Fixes MC-194811 When a structure mod is removed, this map may contain null keys.static <T> com.mojang.serialization.Dynamic<T>fixUpDimensionsData(com.mojang.serialization.Dynamic<T> data)Restores previously "deleted" dimensions to the world.static com.google.common.collect.Multimap<Attribute,AttributeModifier>getAttributeModifiers(ItemStack stack, EquipmentSlot equipmentSlot, com.google.common.collect.Multimap<Attribute,AttributeModifier> attributes)Hook to fireItemAttributeModifierEvent.static Map<EntityType<? extends LivingEntity>,AttributeSupplier>Deprecated.static intgetBurnTime(ItemStack stack, RecipeType<?> recipeType)Gets the burn time of this itemstack.static ItemStackgetContainerItem(ItemStack stack)static Playerstatic CriticalHitEventgetCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier)static StringgetDefaultCreatorModId(ItemStack itemStack)Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.world.item.ItemStack).static Stringstatic doublegetEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier)static intgetLootingLevel(Entity target, Entity killer, DamageSource cause)static intgetLootingLevel(LivingEntity target, DamageSource cause, int level)private static ForgeHooks.LootTableContextstatic EntityDataSerializer<?>getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla)static intgetSerializerId(EntityDataSerializer<?> serializer, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla)getTagFromVanillaTier(Tiers tier)static booleanisCorrectToolForDrops(BlockState state, Player player)static booleanisLivingOnLadder(BlockState state, Level world, BlockPos pos, LivingEntity entity)static LootTableloadLootTable(com.google.gson.Gson gson, ResourceLocation name, com.google.gson.JsonElement data, boolean custom, LootTables lootTableManager)static voidDeprecated.modifyLoot(List<ItemStack> list, LootContext context)Deprecated.modifyLoot(ResourceLocation lootTableId, List<ItemStack> generatedLoot, LootContext context)Handles the modification of loot table drops via the registered Global Loot Modifiers, so that custom effects can be processed.static ComponentnewChatWithLinks(String string)static ComponentnewChatWithLinks(String string, boolean allowMissingHeader)static voidonAdvancement(ServerPlayer player, Advancement advancement)static booleanonAnvilChange(AnvilMenu container, ItemStack left, ItemStack right, Container outputSlot, String name, int baseCost, Player player)static floatonAnvilRepair(Player player, ItemStack output, ItemStack left, ItemStack right)static intonBlockBreakEvent(Level world, GameType gameType, ServerPlayer entityPlayer, BlockPos pos)static booleanonChangeGameMode(Player player, GameType currentGameMode, GameType newGameMode)static voidonCropsGrowPost(Level worldIn, BlockPos pos, BlockState state)static booleanonCropsGrowPre(Level worldIn, BlockPos pos, BlockState state, boolean def)static voidonDifficultyChange(Difficulty difficulty, Difficulty oldDifficulty)static voidonEmptyClick(Player player, InteractionHand hand)static voidonEmptyLeftClick(Player player)static voidonEntityEnterSection(Entity entity, long packedOldPos, long packedNewPos)static booleanonFarmlandTrample(Level world, BlockPos pos, BlockState state, float fallDistance, Entity entity)static InteractionResultonInteractEntity(Player player, Entity entity, InteractionHand hand)static InteractionResultonInteractEntityAt(Player player, Entity entity, HitResult ray, InteractionHand hand)static InteractionResultonInteractEntityAt(Player player, Entity entity, Vec3 vec3d, InteractionHand hand)static InteractionResultonItemRightClick(Player player, InteractionHand hand)onLeftClickBlock(Player player, BlockPos pos, Direction face)static booleanonLivingAttack(LivingEntity entity, DamageSource src, float amount)static floatonLivingDamage(LivingEntity entity, DamageSource src, float amount)static booleanonLivingDeath(LivingEntity entity, DamageSource src)static booleanonLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit)static float[]onLivingFall(LivingEntity entity, float distance, float damageMultiplier)static floatonLivingHurt(LivingEntity entity, DamageSource src, float amount)static voidonLivingJump(LivingEntity entity)static LivingKnockBackEventonLivingKnockBack(LivingEntity target, float strength, double ratioX, double ratioZ)static voidonLivingSetAttackTarget(LivingEntity entity, LivingEntity target)static booleanonLivingUpdate(LivingEntity entity)static intonNoteChange(Level world, BlockPos pos, BlockState state, int old, int _new)static booleanonPickBlock(HitResult target, Player player, Level world)Called when a player uses 'pick block', calls new Entity and Block hooks.static InteractionResultonPlaceItemIntoWorld(UseOnContext context)static booleanonPlayerAttack(LivingEntity entity, DamageSource src, float amount)static booleanonPlayerAttackTarget(Player player, Entity target)static ItemEntityonPlayerTossEvent(Player player, ItemStack item, boolean includeName)onRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec)static ComponentonServerChatEvent(ServerGamePacketListenerImpl net, String raw, Component comp)static booleanonTravelToDimension(Entity entity, ResourceKey<Level> dimension)static StringreadLootEntryName(com.google.gson.JsonObject json, String type)static StringreadPoolName(com.google.gson.JsonObject json)static voidsetCraftingPlayer(Player player)static void
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
FORGEHOOKS
private static final org.apache.logging.log4j.Marker FORGEHOOKS -
URL_PATTERN
-
craftingPlayer
-
lootContext
-
serializerEntries
-
VANILLA_BURNS
-
VANILLA_DIMS
-
DIMENSIONS_KEY
- See Also:
- Constant Field Values
-
SEED_KEY
- See Also:
- Constant Field Values
-
CODEC
-
FORGE_ATTRIBUTES
-
-
Constructor Details
-
ForgeHooks
public ForgeHooks()
-
-
Method Details
-
canContinueUsing
-
isCorrectToolForDrops
-
onPickBlock
Called when a player uses 'pick block', calls new Entity and Block hooks. -
onDifficultyChange
-
onLivingSetAttackTarget
-
onLivingUpdate
-
onLivingAttack
-
onPlayerAttack
-
onLivingKnockBack
public static LivingKnockBackEvent onLivingKnockBack(LivingEntity target, float strength, double ratioX, double ratioZ) -
onLivingHurt
-
onLivingDamage
-
onLivingDeath
-
onLivingDrops
public static boolean onLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) -
onLivingFall
@Nullable public static float[] onLivingFall(LivingEntity entity, float distance, float damageMultiplier) -
getLootingLevel
-
getLootingLevel
-
getEntityVisibilityMultiplier
public static double getEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier) -
isLivingOnLadder
public static boolean isLivingOnLadder(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) -
onLivingJump
-
onPlayerTossEvent
@Nullable public static ItemEntity onPlayerTossEvent(@Nonnull Player player, @Nonnull ItemStack item, boolean includeName) -
onServerChatEvent
@Nullable public static Component onServerChatEvent(ServerGamePacketListenerImpl net, String raw, Component comp) -
newChatWithLinks
-
newChatWithLinks
-
onBlockBreakEvent
public static int onBlockBreakEvent(Level world, GameType gameType, ServerPlayer entityPlayer, BlockPos pos) -
onPlaceItemIntoWorld
-
onAnvilChange
-
onAnvilRepair
-
setCraftingPlayer
-
getCraftingPlayer
-
getContainerItem
-
onPlayerAttackTarget
-
onTravelToDimension
-
onInteractEntityAt
public static InteractionResult onInteractEntityAt(Player player, Entity entity, HitResult ray, InteractionHand hand) -
onInteractEntityAt
public static InteractionResult onInteractEntityAt(Player player, Entity entity, Vec3 vec3d, InteractionHand hand) -
onInteractEntity
public static InteractionResult onInteractEntity(Player player, Entity entity, InteractionHand hand) -
onItemRightClick
-
onLeftClickBlock
public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(Player player, BlockPos pos, Direction face) -
onRightClickBlock
public static PlayerInteractEvent.RightClickBlock onRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec) -
onEmptyClick
-
onEmptyLeftClick
-
onChangeGameMode
-
getLootTableContext
-
loadLootTable
@Nullable public static LootTable loadLootTable(com.google.gson.Gson gson, ResourceLocation name, com.google.gson.JsonElement data, boolean custom, LootTables lootTableManager) -
createVanillaFluidAttributes
-
getDefaultWorldType
-
getTagFromVanillaTier
-
enhanceBiome
public static Biome enhanceBiome(@Nullable ResourceLocation name, Biome.ClimateSettings climate, Biome.BiomeCategory category, Float depth, Float scale, BiomeSpecialEffects effects, BiomeGenerationSettings gen, MobSpawnSettings spawns, com.mojang.serialization.codecs.RecordCodecBuilder.Instance<Biome> codec, ForgeHooks.BiomeCallbackFunction callback) -
readPoolName
-
readLootEntryName
-
onCropsGrowPre
-
onCropsGrowPost
-
getCriticalHit
@Nullable public static CriticalHitEvent getCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier) -
onAdvancement
-
getAttributeModifiers
public static com.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers(ItemStack stack, EquipmentSlot equipmentSlot, com.google.common.collect.Multimap<Attribute,AttributeModifier> attributes)Hook to fireItemAttributeModifierEvent. Modders should useItemStack.getAttributeModifiers(EquipmentSlot)instead. -
getDefaultCreatorModId
Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.world.item.ItemStack). Call that method instead. -
onFarmlandTrample
public static boolean onFarmlandTrample(Level world, BlockPos pos, BlockState state, float fallDistance, Entity entity) -
onNoteChange
-
canEntitySpawn
public static int canEntitySpawn(Mob entity, LevelAccessor world, double x, double y, double z, BaseSpawner spawner, MobSpawnType spawnReason) -
deserializeTagAdditions
public static <T> void deserializeTagAdditions(List<Tag.Entry> list, com.google.gson.JsonObject json, List<Tag.BuilderEntry> allList) -
getSerializer
@Nullable public static EntityDataSerializer<?> getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) -
getSerializerId
public static int getSerializerId(EntityDataSerializer<?> serializer, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) -
canEntityDestroy
-
getBurnTime
Gets the burn time of this itemstack. -
updateBurns
public static void updateBurns() -
modifyLoot
Deprecated.UsemodifyLoot(ResourceLocation, List, LootContext)instead.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 generatedcontext- The loot context that generated that loot- Returns:
- The modified list
-
modifyLoot
public static List<ItemStack> modifyLoot(ResourceLocation lootTableId, List<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 queriedgeneratedLoot- The loot generated by the loot tablecontext- The loot context that generated the loot, unmodified- Returns:
- The modified list of drops
-
getModPacks
-
getModPacksWithVanilla
-
fixNullStructureReferences
public static void fixNullStructureReferences(ChunkAccess chunk, Map<StructureFeature<?>,it.unimi.dsi.fastutil.longs.LongSet> structureReferences)Fixes MC-194811 When a structure mod is removed, this map may contain null keys. This will make the world unable to save if this persists. If we remove a structure from the save data in this way, we then mark the chunk for saving -
fixUpDimensionsData
public static <T> com.mojang.serialization.Dynamic<T> fixUpDimensionsData(com.mojang.serialization.Dynamic<T> data)Restores previously "deleted" dimensions to the world. TheLenientUnboundedMapCodecprevents this from happening, this is to fix any world from before the fix. TODO: Remove in 1.18 -
getAttributesView
@Deprecated public static Map<EntityType<? extends LivingEntity>,AttributeSupplier> getAttributesView()Deprecated.FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY -
modifyAttributes
Deprecated.FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY -
onEntityEnterSection
-
modifyLoot(ResourceLocation, List, LootContext)instead.