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 final LazyValue<com.mojang.serialization.Codec<SimpleRegistry<Dimension>>>private static ThreadLocal<PlayerEntity>private static final Stringprivate static final Map<EntityType<? extends LivingEntity>,AttributeModifierMap> private static final org.apache.logging.log4j.Markerprivate static final org.apache.logging.log4j.Loggerprivate static ThreadLocal<Deque<ForgeHooks.LootTableContext>>private static final Stringprivate static final Map<IDataSerializer<?>,DataSerializerEntry> private static boolean(package private) static final Patternprivate static final Map<IRegistryDelegate<Item>,Integer> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanContinueUsing(ItemStack from, ItemStack to) static booleancanEntityDestroy(World world, BlockPos pos, LivingEntity entity) static intcanEntitySpawn(MobEntity entity, IWorld world, double x, double y, double z, AbstractSpawner spawner, SpawnReason spawnReason) static booleancanHarvestBlock(BlockState state, PlayerEntity player, IBlockReader world, BlockPos pos) static FluidAttributesstatic <T> voiddeserializeTagAdditions(List<ITag.ITagEntry> list, com.google.gson.JsonObject json, List<ITag.Proxy> allList) static BiomeenhanceBiome(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 voidfixNullStructureReferences(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 intgetBurnTime(ItemStack stack) Deprecated.static intgetBurnTime(ItemStack stack, IRecipeType<?> recipeType) Gets the burn time of this itemstack.static ItemStackgetContainerItem(ItemStack stack) static PlayerEntitystatic CriticalHitEventgetCriticalHit(PlayerEntity player, Entity target, boolean vanillaCritical, float damageModifier) static StringgetDefaultCreatorModId(ItemStack itemStack) Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.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 doublegetPlayerVisibilityDistance(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 intgetSerializerId(IDataSerializer<?> serializer, IntIdentityHashBiMap<IDataSerializer<?>> vanilla) (package private) static voidstatic booleanisLivingOnLadder(BlockState state, World world, BlockPos pos, LivingEntity entity) Deprecated.isLivingOnLadderPos(BlockState state, World world, BlockPos pos, LivingEntity entity) static booleanisToolEffective(IWorldReader world, BlockPos pos, ItemStack stack) static LootTableloadLootTable(com.google.gson.Gson gson, ResourceLocation name, com.google.gson.JsonElement data, boolean custom, LootTableManager lootTableManager) static voidDeprecated.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 ITextComponentnewChatWithLinks(String string) static ITextComponentnewChatWithLinks(String string, boolean allowMissingHeader) static voidonAdvancement(ServerPlayerEntity player, Advancement advancement) static booleanonAnvilChange(RepairContainer container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost) Deprecated.static booleanonAnvilChange(RepairContainer container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost, PlayerEntity player) static floatonAnvilRepair(PlayerEntity player, ItemStack output, ItemStack left, ItemStack right) static intonBlockBreakEvent(World world, GameType gameType, ServerPlayerEntity entityPlayer, BlockPos pos) static booleanonChangeGameMode(PlayerEntity player, GameType currentGameMode, GameType newGameMode) static voidonCropsGrowPost(World worldIn, BlockPos pos, BlockState state) static booleanonCropsGrowPre(World worldIn, BlockPos pos, BlockState state, boolean def) static voidonDifficultyChange(Difficulty difficulty, Difficulty oldDifficulty) static voidonEmptyClick(PlayerEntity player, Hand hand) static voidonEmptyLeftClick(PlayerEntity player) static booleanonFarmlandTrample(World world, BlockPos pos, BlockState state, float fallDistance, Entity entity) static ActionResultTypeonInteractEntity(PlayerEntity player, Entity entity, Hand hand) static ActionResultTypeonInteractEntityAt(PlayerEntity player, Entity entity, RayTraceResult ray, Hand hand) static ActionResultTypeonInteractEntityAt(PlayerEntity player, Entity entity, Vector3d vec3d, Hand hand) static ActionResultTypeonItemRightClick(PlayerEntity player, Hand hand) onLeftClickBlock(PlayerEntity 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(World world, BlockPos pos, BlockState state, int old, int _new) static booleanonPickBlock(RayTraceResult target, PlayerEntity player, World world) Called when a player uses 'pick block', calls new Entity and Block hooks.static ActionResultTypeonPlaceItemIntoWorld(ItemUseContext context) static booleanonPlayerAttack(LivingEntity entity, DamageSource src, float amount) static booleanonPlayerAttackTarget(PlayerEntity player, Entity target) static ItemEntityonPlayerTossEvent(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 ITextComponentonServerChatEvent(ServerPlayNetHandler net, String raw, ITextComponent comp) static booleanonTravelToDimension(Entity entity, RegistryKey<World> dimension) static AttributeModifierMapputAttributesOld(EntityType<? extends LivingEntity> type, AttributeModifierMap map) Deprecated.static StringreadLootEntryName(com.google.gson.JsonObject json, String type) static StringreadPoolName(com.google.gson.JsonObject json) static voidsetBlockToolSetter(org.apache.logging.log4j.util.TriConsumer<Block, ToolType, Integer> setter) static voidsetCraftingPlayer(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. TheLenientUnboundedMapCodecprevents 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.