Class ForgeHooks
- 
Nested Class SummaryNested Classes
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate static ThreadLocal<Player>private static final Map<EntityType<? extends LivingEntity>,AttributeSupplier> private static final Lazy<Map<String,StructuresBecomeConfiguredFix.Conversion>> private static final org.apache.logging.log4j.Markerprivate static final org.apache.logging.log4j.Logger(package private) static final Patternprivate static final Map<Holder.Reference<Item>,Integer> private static final org.apache.logging.log4j.Marker
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic booleancanContinueUsing(@NotNull ItemStack from, @NotNull ItemStack to) static booleancanEntityDestroy(Level level, BlockPos pos, LivingEntity entity) static booleancreateLootTablePoolCodec(com.mojang.serialization.Codec<E> vanilla) static voiddropXpForBlock(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) static StringencodeLifecycle(com.mojang.serialization.Lifecycle lifecycle) static com.mojang.serialization.Codec<Ingredient>enhanceIngredientCodec(com.mojang.serialization.Codec<Ingredient> vanilla) 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, @Nullable RecipeType<?> recipeType) Gets the burn time of this itemstack.static Playerstatic @NotNull ItemStackgetCraftingRemainingItem(@NotNull ItemStack stack) static @Nullable CriticalHitEventgetCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier) static @Nullable StringgetDefaultCreatorModId(@NotNull ItemStack itemStack) Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.world.item.ItemStack).static Packet<ClientGamePacketListener>getEntitySpawnPacket(Entity entity) static doublegetEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier) static intgetLootingLevel(Entity target, @Nullable Entity killer, @Nullable DamageSource cause) static intgetLootingLevel(LivingEntity target, @Nullable DamageSource cause, int level) static ItemStackgetProjectile(LivingEntity entity, ItemStack projectileWeaponItem, ItemStack projectile) Hook to fireLivingGetProjectileEvent.static @Nullable EntityDataSerializer<?>getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) static intgetSerializerId(EntityDataSerializer<?> serializer, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) getTagFromVanillaTier(Tiers tier) static FluidTypegetVanillaFluidType(Fluid fluid) Returns a vanilla fluid type for the given fluid.static voidhandleClientConfigurationComplete(Connection connection) static booleanhasNoElements(Ingredient ingredient) static IngredientingredientFromNetwork(FriendlyByteBuf buffer) static <T extends Ingredient>
 booleaningredientToNetwork(FriendlyByteBuf buffer, T ingredient) static booleanisCorrectToolForDrops(@NotNull BlockState state, @NotNull Player player) isLivingOnLadder(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull LivingEntity entity) static voidDeprecated.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.static ComponentnewChatWithLinks(String string) static ComponentnewChatWithLinks(String string, boolean allowMissingHeader) static booleanonAnvilChange(AnvilMenu container, @NotNull ItemStack left, @NotNull ItemStack right, Container outputSlot, String name, int baseCost, Player player) static floatonAnvilRepair(Player player, @NotNull ItemStack output, @NotNull ItemStack left, @NotNull ItemStack right) static intonBlockBreakEvent(Level level, GameType gameType, ServerPlayer entityPlayer, BlockPos pos) static GameTypeonChangeGameType(Player player, GameType currentGameType, GameType newGameType) onClientMineHold(Player player, BlockPos pos, Direction face) static voidonCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) static voidonCropsGrowPost(Level level, BlockPos pos, BlockState state) static booleanonCropsGrowPre(Level level, BlockPos pos, BlockState state, boolean def) static booleanstatic booleanonCustomPayload(ICustomPacket<?> packet, Connection connection) static voidonDifficultyChange(Difficulty difficulty, Difficulty oldDifficulty) static voidonEmptyClick(Player player, InteractionHand hand) static voidonEmptyLeftClick(Player player) static booleanonFarmlandTrample(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity) static intonGrindstoneChange(@NotNull ItemStack top, @NotNull ItemStack bottom, Container outputSlot, int xp) static booleanonGrindstoneTake(Container inputSlots, ContainerLevelAccess access, Function<Level, Integer> xpFunction) 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) static booleanonItemStackedOn(ItemStack carriedItem, ItemStack stackedOnItem, Slot slot, ClickAction action, Player player, SlotAccess carriedSlotAccess) onLeftClickBlock(Player player, BlockPos pos, Direction face, ServerboundPlayerActionPacket.Action action) static booleanonLivingAttack(LivingEntity entity, DamageSource src, float amount) static voidonLivingBreathe(LivingEntity entity, int consumeAirAmount, int refillAirAmount) Handles living entities being under water.static LivingChangeTargetEventonLivingChangeTarget(LivingEntity entity, LivingEntity originalTarget, LivingChangeTargetEvent.ILivingTargetType targetType) 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 floatonLivingHurt(LivingEntity entity, DamageSource src, float amount) static voidonLivingJump(LivingEntity entity) static LivingKnockBackEventonLivingKnockBack(LivingEntity target, float strength, double ratioX, double ratioZ) static Brain<?>onLivingMakeBrain(LivingEntity entity, Brain<?> originalBrain, com.mojang.serialization.Dynamic<?> dynamic) static booleanonLivingTick(LivingEntity entity) static booleanonLivingUseTotem(LivingEntity entity, DamageSource damageSource, ItemStack totem, InteractionHand hand) static intonNoteChange(Level level, BlockPos pos, BlockState state, int old, int _new) static InteractionResultonPlaceItemIntoWorld(@NotNull UseOnContext context) static booleanonPlayerAttack(LivingEntity entity, DamageSource src, float amount) static booleanonPlayerAttackTarget(Player player, Entity target) static @Nullable ItemEntityonPlayerTossEvent(@NotNull Player player, @NotNull ItemStack item, boolean includeName) onRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec) static @Nullable ComponentonServerChatSubmittedEvent(ServerPlayer player, Component message) static booleanonVanillaGameEvent(Level level, GameEvent vanillaEvent, Vec3 pos, GameEvent.Context context) static com.mojang.serialization.LifecycleparseLifecycle(String lifecycle) static StringprefixNamespace(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 minecraftstatic voidreadAdditionalLevelSaveData(CompoundTag rootTag, LevelStorageSource.LevelDirectory levelDirectory) static booleanreadAndTestCondition(ICondition.IContext context, com.google.gson.JsonObject json) static @Nullable com.google.gson.JsonObjectreadConditionalAdvancement(ICondition.IContext context, com.google.gson.JsonObject json) static voidsetCraftingPlayer(Player player) static booleanshouldSuppressEnderManAnger(EnderMan enderMan, Player player, ItemStack mask) static voidstatic <T> HolderLookup.RegistryLookup<T>wrapRegistryLookup(HolderLookup.RegistryLookup<T> lookup) static voidwriteAdditionalLevelSaveData(WorldData worldData, CompoundTag levelTag) static voidwriteCondition(ICondition condition, com.google.gson.JsonObject out) 
- 
Field Details- 
LOGGERprivate static final org.apache.logging.log4j.Logger LOGGER
- 
FORGEHOOKSprivate static final org.apache.logging.log4j.Marker FORGEHOOKS
- 
WORLDPERSISTENCEprivate static final org.apache.logging.log4j.Marker WORLDPERSISTENCE
- 
URL_PATTERN
- 
craftingPlayer
- 
VANILLA_BURNS
- 
FORGE_ATTRIBUTES
- 
FORGE_CONVERSION_MAPprivate static final Lazy<Map<String,StructuresBecomeConfiguredFix.Conversion>> FORGE_CONVERSION_MAP
 
- 
- 
Constructor Details- 
ForgeHookspublic ForgeHooks()
 
- 
- 
Method Details- 
canContinueUsing
- 
isCorrectToolForDropspublic static boolean isCorrectToolForDrops(@NotNull @NotNull BlockState state, @NotNull @NotNull Player player) 
- 
onItemStackedOnpublic static boolean onItemStackedOn(ItemStack carriedItem, ItemStack stackedOnItem, Slot slot, ClickAction action, Player player, SlotAccess carriedSlotAccess) 
- 
onDifficultyChange
- 
onLivingChangeTargetpublic static LivingChangeTargetEvent onLivingChangeTarget(LivingEntity entity, LivingEntity originalTarget, LivingChangeTargetEvent.ILivingTargetType targetType) 
- 
onLivingMakeBrainpublic static Brain<?> onLivingMakeBrain(LivingEntity entity, Brain<?> originalBrain, com.mojang.serialization.Dynamic<?> dynamic) 
- 
onLivingTick
- 
onLivingAttack
- 
onPlayerAttack
- 
onLivingKnockBackpublic static LivingKnockBackEvent onLivingKnockBack(LivingEntity target, float strength, double ratioX, double ratioZ) 
- 
onLivingUseTotempublic static boolean onLivingUseTotem(LivingEntity entity, DamageSource damageSource, ItemStack totem, InteractionHand hand) 
- 
onLivingHurt
- 
onLivingDamage
- 
onLivingDeath
- 
onLivingDropspublic static boolean onLivingDrops(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) 
- 
getLootingLevelpublic static int getLootingLevel(Entity target, @Nullable @Nullable Entity killer, @Nullable @Nullable DamageSource cause) 
- 
getLootingLevelpublic static int getLootingLevel(LivingEntity target, @Nullable @Nullable DamageSource cause, int level) 
- 
getEntityVisibilityMultiplierpublic static double getEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier) 
- 
isLivingOnLadderpublic static Optional<BlockPos> isLivingOnLadder(@NotNull @NotNull BlockState state, @NotNull @NotNull Level level, @NotNull @NotNull BlockPos pos, @NotNull @NotNull LivingEntity entity) 
- 
onLivingJump
- 
onPlayerTossEvent@Nullable public static @Nullable ItemEntity onPlayerTossEvent(@NotNull @NotNull Player player, @NotNull @NotNull ItemStack item, boolean includeName) 
- 
onVanillaGameEventpublic static boolean onVanillaGameEvent(Level level, GameEvent vanillaEvent, Vec3 pos, GameEvent.Context context) 
- 
onServerChatSubmittedEvent@Nullable public static @Nullable Component onServerChatSubmittedEvent(ServerPlayer player, Component message) 
- 
newChatWithLinks
- 
newChatWithLinks
- 
dropXpForBlockpublic static void dropXpForBlock(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) 
- 
onBlockBreakEventpublic static int onBlockBreakEvent(Level level, GameType gameType, ServerPlayer entityPlayer, BlockPos pos) 
- 
onPlaceItemIntoWorld
- 
onAnvilChange
- 
onAnvilRepair
- 
onGrindstoneChange
- 
onGrindstoneTakepublic static boolean onGrindstoneTake(Container inputSlots, ContainerLevelAccess access, Function<Level, Integer> xpFunction) 
- 
setCraftingPlayer
- 
getCraftingPlayer
- 
getCraftingRemainingItem
- 
onPlayerAttackTarget
- 
onInteractEntityAtpublic static InteractionResult onInteractEntityAt(Player player, Entity entity, HitResult ray, InteractionHand hand) 
- 
onInteractEntityAtpublic static InteractionResult onInteractEntityAt(Player player, Entity entity, Vec3 vec3d, InteractionHand hand) 
- 
onInteractEntitypublic static InteractionResult onInteractEntity(Player player, Entity entity, InteractionHand hand) 
- 
onItemRightClick
- 
onLeftClickBlockpublic static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(Player player, BlockPos pos, Direction face, ServerboundPlayerActionPacket.Action action) 
- 
onClientMineHoldpublic static PlayerInteractEvent.LeftClickBlock onClientMineHold(Player player, BlockPos pos, Direction face) 
- 
onRightClickBlockpublic static PlayerInteractEvent.RightClickBlock onRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult hitVec) 
- 
onEmptyClick
- 
onEmptyLeftClick
- 
onChangeGameType
- 
createLootTablePoolCodec
- 
getVanillaFluidTypeReturns 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
 
- 
getTagFromVanillaTier
- 
onCropsGrowPre
- 
onCropsGrowPost
- 
getCriticalHit@Nullable public static @Nullable CriticalHitEvent getCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier) 
- 
getAttributeModifierspublic 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.
- 
getProjectilepublic static ItemStack getProjectile(LivingEntity entity, ItemStack projectileWeaponItem, ItemStack projectile) Hook to fireLivingGetProjectileEvent. Returns the ammo to be used.
- 
getDefaultCreatorModId@Nullable public static @Nullable String getDefaultCreatorModId(@NotNull @NotNull ItemStack itemStack) Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.world.item.ItemStack). Call that method instead.
- 
onFarmlandTramplepublic static boolean onFarmlandTrample(Level level, BlockPos pos, BlockState state, float fallDistance, Entity entity) 
- 
onNoteChange
- 
hasNoElements
- 
getSerializer@Nullable public static @Nullable EntityDataSerializer<?> getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) 
- 
getSerializerIdpublic static int getSerializerId(EntityDataSerializer<?> serializer, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) 
- 
canEntityDestroy
- 
getBurnTimeGets the burn time of this itemstack.
- 
updateBurnspublic static void updateBurns()
- 
modifyLootpublic 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
- 
getModPacksWithVanilla
- 
getAttributesView@Deprecated public static Map<EntityType<? extends LivingEntity>,AttributeSupplier> getAttributesView()Deprecated.
- 
modifyAttributesDeprecated.
- 
writeAdditionalLevelSaveData
- 
readAdditionalLevelSaveData@Internal public static void readAdditionalLevelSaveData(CompoundTag rootTag, LevelStorageSource.LevelDirectory levelDirectory) 
- 
encodeLifecycle
- 
parseLifecycle
- 
shouldSuppressEnderManAnger
- 
prefixNamespaceThis 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_cheeseadds a registry namedcheeses, but the modawesome_cheesealso adds a registry calledcheeses, they are going to have the same pathcheeses, just with different namespaces. Ifadditional_cheesewants to add additional cheese toawesome_cheese, but notfancy_cheese, it can not differentiate both. Both paths will look likedata/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 indata/<namespace>/fancy_cheese/cheesesandawesome_cheese's registry stores its elements indata/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"
 
- 
wrapRegistryLookup@Internal public static <T> HolderLookup.RegistryLookup<T> wrapRegistryLookup(HolderLookup.RegistryLookup<T> lookup) 
- 
onLivingBreatheHandles living entities being under water. This fires theLivingBreatheEventand if the entity's air supply is less than or equal to zero also theLivingDrownEvent. Additionally when the entity is under water it will dismount ifIForgeEntity#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.
 
- 
onCreativeModeTabBuildContentspublic static void onCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) 
- 
onCustomPayload
- 
onCustomPayload
- 
handleClientConfigurationComplete
- 
getEntitySpawnPacket
- 
readAndTestCondition@Internal public static boolean readAndTestCondition(ICondition.IContext context, com.google.gson.JsonObject json) 
- 
writeCondition
- 
readConditionalAdvancement@Nullable @Internal public static @Nullable com.google.gson.JsonObject readConditionalAdvancement(ICondition.IContext context, com.google.gson.JsonObject json) 
- 
enhanceIngredientCodec@Internal public static com.mojang.serialization.Codec<Ingredient> enhanceIngredientCodec(com.mojang.serialization.Codec<Ingredient> vanilla) 
- 
ingredientToNetwork@Internal public static <T extends Ingredient> boolean ingredientToNetwork(FriendlyByteBuf buffer, T ingredient) 
- 
ingredientFromNetwork
 
-