Package net.minecraftforge.common
Class ForgeHooks
java.lang.Object
net.minecraftforge.common.ForgeHooks
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
private static class
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final LazyValue<com.mojang.serialization.Codec<SimpleRegistry<Dimension>>>
private static ThreadLocal<PlayerEntity>
private static final String
private static final Map<EntityType<? extends LivingEntity>,
AttributeModifierMap> private static final org.apache.logging.log4j.Marker
private static final org.apache.logging.log4j.Logger
private static ThreadLocal<Deque<ForgeHooks.LootTableContext>>
private static final String
private static final Map<IDataSerializer<?>,
DataSerializerEntry> private static boolean
(package private) static final Pattern
private static final Map<IRegistryDelegate<Item>,
Integer> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canContinueUsing
(ItemStack from, ItemStack to) static boolean
canEntityDestroy
(World world, BlockPos pos, LivingEntity entity) static int
canEntitySpawn
(MobEntity entity, IWorld world, double x, double y, double z, AbstractSpawner spawner, SpawnReason spawnReason) static boolean
canHarvestBlock
(BlockState state, PlayerEntity player, IBlockReader world, BlockPos pos) static FluidAttributes
static <T> void
deserializeTagAdditions
(List<ITag.ITagEntry> list, com.google.gson.JsonObject json, List<ITag.Proxy> allList) static Biome
enhanceBiome
(ResourceLocation name, Biome.Climate climate, Biome.Category category, Float depth, Float scale, BiomeAmbience effects, BiomeGenerationSettings gen, MobSpawnInfo spawns, com.mojang.serialization.codecs.RecordCodecBuilder.Instance<Biome> codec, ForgeHooks.BiomeCallbackFunction callback) static void
fixNullStructureReferences
(IChunk chunk, Map<Structure<?>, 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, EquipmentSlotType equipmentSlot, com.google.common.collect.Multimap<Attribute, AttributeModifier> attributes) Hook to fireItemAttributeModifierEvent
.static Map<EntityType<? extends LivingEntity>,
AttributeModifierMap> Deprecated.static int
getBurnTime
(ItemStack stack) Deprecated.static int
getBurnTime
(ItemStack stack, IRecipeType<?> recipeType) Gets the burn time of this itemstack.static ItemStack
getContainerItem
(ItemStack stack) static PlayerEntity
static CriticalHitEvent
getCriticalHit
(PlayerEntity player, Entity target, boolean vanillaCritical, float damageModifier) static String
getDefaultCreatorModId
(ItemStack itemStack) Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.item.ItemStack)
.static String
static double
getEntityVisibilityMultiplier
(LivingEntity entity, Entity lookingEntity, double originalMultiplier) static int
getLootingLevel
(Entity target, Entity killer, DamageSource cause) static int
getLootingLevel
(LivingEntity target, DamageSource cause, int level) private static ForgeHooks.LootTableContext
static double
getPlayerVisibilityDistance
(PlayerEntity player, double xzDistance, double maxXZDistance) Deprecated.private static <T,
E> T getPrivateValue
(Class<? super E> classToAccess, E instance, int fieldIndex) static IDataSerializer<?>
getSerializer
(int id, IntIdentityHashBiMap<IDataSerializer<?>> vanilla) static int
getSerializerId
(IDataSerializer<?> serializer, IntIdentityHashBiMap<IDataSerializer<?>> vanilla) (package private) static void
static boolean
isLivingOnLadder
(BlockState state, World world, BlockPos pos, LivingEntity entity) Deprecated.isLivingOnLadderPos
(BlockState state, World world, BlockPos pos, LivingEntity entity) static boolean
isToolEffective
(IWorldReader world, BlockPos pos, ItemStack stack) static LootTable
loadLootTable
(com.google.gson.Gson gson, ResourceLocation name, com.google.gson.JsonElement data, boolean custom, LootTableManager lootTableManager) static void
Deprecated.modifyLoot
(List<ItemStack> list, LootContext context) Deprecated.UsemodifyLoot(ResourceLocation, List, LootContext)
instead.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 ITextComponent
newChatWithLinks
(String string) static ITextComponent
newChatWithLinks
(String string, boolean allowMissingHeader) static void
onAdvancement
(ServerPlayerEntity player, Advancement advancement) static boolean
onAnvilChange
(RepairContainer container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost) Deprecated.static boolean
onAnvilChange
(RepairContainer container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost, PlayerEntity player) static float
onAnvilRepair
(PlayerEntity player, ItemStack output, ItemStack left, ItemStack right) static int
onBlockBreakEvent
(World world, GameType gameType, ServerPlayerEntity entityPlayer, BlockPos pos) static boolean
onChangeGameMode
(PlayerEntity player, GameType currentGameMode, GameType newGameMode) static void
onCropsGrowPost
(World worldIn, BlockPos pos, BlockState state) static boolean
onCropsGrowPre
(World worldIn, BlockPos pos, BlockState state, boolean def) static void
onDifficultyChange
(Difficulty difficulty, Difficulty oldDifficulty) static void
onEmptyClick
(PlayerEntity player, Hand hand) static void
onEmptyLeftClick
(PlayerEntity player) static boolean
onFarmlandTrample
(World world, BlockPos pos, BlockState state, float fallDistance, Entity entity) static ActionResultType
onInteractEntity
(PlayerEntity player, Entity entity, Hand hand) static ActionResultType
onInteractEntityAt
(PlayerEntity player, Entity entity, RayTraceResult ray, Hand hand) static ActionResultType
onInteractEntityAt
(PlayerEntity player, Entity entity, Vector3d vec3d, Hand hand) static ActionResultType
onItemRightClick
(PlayerEntity player, Hand hand) onLeftClickBlock
(PlayerEntity player, BlockPos pos, Direction face) static boolean
onLivingAttack
(LivingEntity entity, DamageSource src, float amount) static float
onLivingDamage
(LivingEntity entity, DamageSource src, float amount) static boolean
onLivingDeath
(LivingEntity entity, DamageSource src) static boolean
onLivingDrops
(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) static float[]
onLivingFall
(LivingEntity entity, float distance, float damageMultiplier) static float
onLivingHurt
(LivingEntity entity, DamageSource src, float amount) static void
onLivingJump
(LivingEntity entity) static LivingKnockBackEvent
onLivingKnockBack
(LivingEntity target, float strength, double ratioX, double ratioZ) static void
onLivingSetAttackTarget
(LivingEntity entity, LivingEntity target) static boolean
onLivingUpdate
(LivingEntity entity) static int
onNoteChange
(World world, BlockPos pos, BlockState state, int old, int _new) static boolean
onPickBlock
(RayTraceResult target, PlayerEntity player, World world) Called when a player uses 'pick block', calls new Entity and Block hooks.static ActionResultType
onPlaceItemIntoWorld
(ItemUseContext context) static boolean
onPlayerAttack
(LivingEntity entity, DamageSource src, float amount) static boolean
onPlayerAttackTarget
(PlayerEntity player, Entity target) static ItemEntity
onPlayerTossEvent
(PlayerEntity player, ItemStack item, boolean includeName) onRightClickBlock
(PlayerEntity player, Hand hand, BlockPos pos, Direction face) Deprecated.onRightClickBlock
(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) static ITextComponent
onServerChatEvent
(ServerPlayNetHandler net, String raw, ITextComponent comp) static boolean
onTravelToDimension
(Entity entity, RegistryKey<World> dimension) static AttributeModifierMap
putAttributesOld
(EntityType<? extends LivingEntity> type, AttributeModifierMap map) Deprecated.static String
readLootEntryName
(com.google.gson.JsonObject json, String type) static String
readPoolName
(com.google.gson.JsonObject json) static void
setBlockToolSetter
(org.apache.logging.log4j.util.TriConsumer<Block, ToolType, Integer> setter) static void
setCraftingPlayer
(PlayerEntity 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 -
toolInit
private static boolean toolInit -
URL_PATTERN
-
craftingPlayer
-
lootContext
-
blockToolSetter
-
serializerEntries
-
VANILLA_BURNS
-
VANILLA_DIMS
-
DIMENSIONS_KEY
- See Also:
-
SEED_KEY
- See Also:
-
CODEC
-
FORGE_ATTRIBUTES
-
-
Constructor Details
-
ForgeHooks
public ForgeHooks()
-
-
Method Details
-
canContinueUsing
-
canHarvestBlock
public static boolean canHarvestBlock(@Nonnull BlockState state, @Nonnull PlayerEntity player, @Nonnull IBlockReader world, @Nonnull BlockPos pos) -
isToolEffective
-
initTools
static void initTools() -
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
-
getPlayerVisibilityDistance
@Deprecated public static double getPlayerVisibilityDistance(PlayerEntity player, double xzDistance, double maxXZDistance) Deprecated.TODO 1.17 remove Unused -
getEntityVisibilityMultiplier
public static double getEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier) -
isLivingOnLadder
@Deprecated public static boolean isLivingOnLadder(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) Deprecated.UseisLivingOnLadderPos(BlockState, World, BlockPos, LivingEntity)
instead in 1.16. -
isLivingOnLadderPos
public static Optional<BlockPos> isLivingOnLadderPos(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) -
onLivingJump
-
onPlayerTossEvent
@Nullable public static ItemEntity onPlayerTossEvent(@Nonnull PlayerEntity player, @Nonnull ItemStack item, boolean includeName) -
onServerChatEvent
@Nullable public static ITextComponent onServerChatEvent(ServerPlayNetHandler net, String raw, ITextComponent comp) -
newChatWithLinks
-
newChatWithLinks
-
onBlockBreakEvent
public static int onBlockBreakEvent(World world, GameType gameType, ServerPlayerEntity entityPlayer, BlockPos pos) -
onPlaceItemIntoWorld
-
onAnvilChange
@Deprecated public static boolean onAnvilChange(RepairContainer container, @Nonnull ItemStack left, @Nonnull ItemStack right, IInventory outputSlot, String name, int baseCost) Deprecated. -
onAnvilChange
public static boolean onAnvilChange(RepairContainer container, @Nonnull ItemStack left, @Nonnull ItemStack right, IInventory outputSlot, String name, int baseCost, PlayerEntity player) -
onAnvilRepair
public static float onAnvilRepair(PlayerEntity player, @Nonnull ItemStack output, @Nonnull ItemStack left, @Nonnull ItemStack right) -
setCraftingPlayer
-
getCraftingPlayer
-
getContainerItem
-
onPlayerAttackTarget
-
onTravelToDimension
-
onInteractEntityAt
public static ActionResultType onInteractEntityAt(PlayerEntity player, Entity entity, RayTraceResult ray, Hand hand) -
onInteractEntityAt
public static ActionResultType onInteractEntityAt(PlayerEntity player, Entity entity, Vector3d vec3d, Hand hand) -
onInteractEntity
-
onItemRightClick
-
onLeftClickBlock
public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(PlayerEntity player, BlockPos pos, Direction face) -
onRightClickBlock
@Deprecated public static PlayerInteractEvent.RightClickBlock onRightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face) Deprecated. -
onRightClickBlock
public static PlayerInteractEvent.RightClickBlock onRightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) -
onEmptyClick
-
onEmptyLeftClick
-
onChangeGameMode
public static boolean onChangeGameMode(PlayerEntity player, GameType currentGameMode, GameType newGameMode) -
getLootTableContext
-
loadLootTable
@Nullable public static LootTable loadLootTable(com.google.gson.Gson gson, ResourceLocation name, com.google.gson.JsonElement data, boolean custom, LootTableManager lootTableManager) -
createVanillaFluidAttributes
-
getDefaultWorldType
-
enhanceBiome
public static Biome enhanceBiome(@Nullable ResourceLocation name, Biome.Climate climate, Biome.Category category, Float depth, Float scale, BiomeAmbience effects, BiomeGenerationSettings gen, MobSpawnInfo spawns, com.mojang.serialization.codecs.RecordCodecBuilder.Instance<Biome> codec, ForgeHooks.BiomeCallbackFunction callback) -
readPoolName
-
readLootEntryName
-
onCropsGrowPre
-
onCropsGrowPost
-
getCriticalHit
@Nullable public static CriticalHitEvent getCriticalHit(PlayerEntity player, Entity target, boolean vanillaCritical, float damageModifier) -
onAdvancement
-
getAttributeModifiers
public static com.google.common.collect.Multimap<Attribute,AttributeModifier> getAttributeModifiers(ItemStack stack, EquipmentSlotType equipmentSlot, com.google.common.collect.Multimap<Attribute, AttributeModifier> attributes) Hook to fireItemAttributeModifierEvent
. Modders should useItemStack.getAttributeModifiers(EquipmentSlotType)
instead. -
getDefaultCreatorModId
Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.item.ItemStack)
. Call that method instead. -
onFarmlandTrample
public static boolean onFarmlandTrample(World world, BlockPos pos, BlockState state, float fallDistance, Entity entity) -
setBlockToolSetter
-
getPrivateValue
private static <T,E> T getPrivateValue(Class<? super E> classToAccess, @Nullable E instance, int fieldIndex) -
onNoteChange
-
canEntitySpawn
public static int canEntitySpawn(MobEntity entity, IWorld world, double x, double y, double z, AbstractSpawner spawner, SpawnReason spawnReason) -
deserializeTagAdditions
public static <T> void deserializeTagAdditions(List<ITag.ITagEntry> list, com.google.gson.JsonObject json, List<ITag.Proxy> allList) -
getSerializer
@Nullable public static IDataSerializer<?> getSerializer(int id, IntIdentityHashBiMap<IDataSerializer<?>> vanilla) -
getSerializerId
public static int getSerializerId(IDataSerializer<?> serializer, IntIdentityHashBiMap<IDataSerializer<?>> vanilla) -
canEntityDestroy
-
getBurnTime
Deprecated. -
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(IChunk chunk, Map<Structure<?>, 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. TheLenientUnboundedMapCodec
prevents this from happening, this is to fix any world from before the fix. -
getAttributesView
@Deprecated public static Map<EntityType<? extends LivingEntity>,AttributeModifierMap> getAttributesView()Deprecated.FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY -
putAttributesOld
@Deprecated public static AttributeModifierMap putAttributesOld(EntityType<? extends LivingEntity> type, AttributeModifierMap map) Deprecated.FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY ONLY EXISTS FOR LEGACY REASONS SHOULD BE REMOVED IN 1.17 -
modifyAttributes
Deprecated.FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY
-
isLivingOnLadderPos(BlockState, World, BlockPos, LivingEntity)
instead in 1.16.