类 ForgeHooks
java.lang.Object
net.minecraftforge.common.ForgeHooks
FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private static final 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.Marker
private static final org.apache.logging.log4j.Logger
(专用程序包) static final Pattern
private static final org.apache.logging.log4j.Marker
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static boolean
canContinueUsing
(@NotNull ItemStack from, @NotNull ItemStack to) static boolean
canEntityDestroy
(ServerLevel level, BlockPos pos, LivingEntity entity) static boolean
createLootTablePoolCodec
(com.mojang.serialization.Codec<E> vanilla) static void
dropXpForBlock
(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) static String
encodeLifecycle
(com.mojang.serialization.Lifecycle lifecycle) static DataComponentMap
gatherItemComponents
(Item item, DataComponentMap dataComponents) static Map
<EntityType<? extends LivingEntity>, AttributeSupplier> 已过时。static Player
static @NotNull ItemStack
getCraftingRemainingItem
(@NotNull ItemStack stack) static @Nullable CriticalHitEvent
getCriticalHit
(Player player, Entity target, boolean vanillaCritical, float damageModifier) static <B extends FriendlyByteBuf>
StreamCodec<B, ? extends CustomPacketPayload> getCustomPayloadCodec
(ResourceLocation id, int max) static @Nullable String
getDefaultCreatorModId
(@NotNull ItemStack itemStack) Used as the default implementation ofIForgeItem.getCreatorModId(net.minecraft.world.item.ItemStack)
.static @Nullable DyeColor
static Packet
<ClientGamePacketListener> getEntitySpawnPacket
(Entity entity) static double
getEntityVisibilityMultiplier
(LivingEntity entity, Entity lookingEntity, double originalMultiplier) static int
getLootingLevel
(Entity target, @Nullable Entity killer, @Nullable DamageSource cause) static ItemStack
getProjectile
(LivingEntity entity, ItemStack projectileWeaponItem, ItemStack projectile) Hook to fireLivingGetProjectileEvent
.static @Nullable EntityDataSerializer
<?> getSerializer
(int id, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) static int
getSerializerId
(EntityDataSerializer<?> serializer, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) static FluidType
getVanillaFluidType
(Fluid fluid) Returns a vanilla fluid type for the given fluid.static void
handleClientConfigurationComplete
(Connection connection) static com.mojang.serialization.Codec
<Ingredient> ingredientBaseCodec
(com.mojang.serialization.Codec<Ingredient> vanilla) static boolean
isCorrectToolForDrops
(@NotNull BlockState state, @NotNull Player player) isLivingOnLadder
(@NotNull BlockState state, @NotNull Level level, @NotNull BlockPos pos, @NotNull LivingEntity entity) static Predicate
<LivingEntity> isNotDisguised
(Monster monster) static void
已过时。static it.unimi.dsi.fastutil.objects.ObjectArrayList
<ItemStack> modifyLoot
(LootTable table, 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 Component
newChatWithLinks
(String string) static Component
newChatWithLinks
(String string, boolean allowMissingHeader) static boolean
onAnvilChange
(AnvilMenu container, @NotNull ItemStack left, @NotNull ItemStack right, Container outputSlot, String name, long baseCost, Player player) static int
onBlockBreakEvent
(Level level, GameType gameType, ServerPlayer entityPlayer, BlockPos pos) static GameType
onChangeGameType
(Player player, GameType currentGameType, GameType newGameType) static void
onCreativeModeTabBuildContents
(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) static void
onCropsGrowPost
(Level level, BlockPos pos, BlockState state) static boolean
onCropsGrowPre
(Level level, BlockPos pos, BlockState state, boolean def) static boolean
onCustomPayload
(CustomPacketPayload payload, Connection connection) static boolean
onCustomPayload
(ClientboundCustomQueryPacket packet, Connection connection) static boolean
onCustomPayload
(ServerboundCustomQueryAnswerPacket packet, Connection connection) static boolean
static boolean
onFarmlandTrample
(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) static boolean
onGrindstoneTake
(Container inputSlots, ContainerLevelAccess access, Function<Level, Integer> xpFunction) static InteractionResult
onInteractEntityAt
(Entity entity, Player player, Vec3 vec3d, InteractionHand hand) static InteractionResult
onItemRightClick
(Player player, InteractionHand hand) static <T> T
onJsonDataParsed
(com.mojang.serialization.Codec<T> codec, ResourceLocation key, T value) static boolean
onLivingAttack
(LivingEntity entity, DamageSource src, float amount) static void
onLivingBreathe
(LivingEntity entity, int consumeAirAmount, int refillAirAmount) Handles living entities being under water.static float
onLivingDamage
(LivingEntity entity, DamageSource src, float amount) static float
onLivingHurt
(LivingEntity entity, DamageSource src, float amount) static void
onLivingJump
(LivingEntity entity) static Brain
<?> onLivingMakeBrain
(LivingEntity entity, Brain<?> originalBrain, com.mojang.serialization.Dynamic<?> dynamic) static boolean
onLivingUseTotem
(LivingEntity entity, DamageSource damageSource, ItemStack totem, InteractionHand hand) static int
onNoteChange
(Level level, BlockPos pos, BlockState state, int old, int _new) static InteractionResult
onPlaceItemIntoWorld
(@NotNull UseOnContext context) static boolean
onPlayerAttack
(LivingEntity entity, DamageSource src, float amount) static boolean
onPlayerAttackTarget
(Player player, Entity target) static @Nullable ItemEntity
onPlayerTossEvent
(@NotNull Player player, @NotNull ItemStack item, boolean includeName) static @Nullable Component
onServerChatSubmittedEvent
(ServerPlayer player, Component message) static com.mojang.serialization.Lifecycle
parseLifecycle
(String lifecycle) static void
readAdditionalLevelSaveData
(LevelStorageSource.LevelStorageAccess access, LevelStorageSource.LevelDirectory levelDirectory) static boolean
readAndTestCondition
(com.mojang.serialization.DynamicOps<com.google.gson.JsonElement> ops, com.google.gson.JsonObject json) static @Nullable com.google.gson.JsonElement
readConditional
(com.mojang.serialization.DynamicOps<com.google.gson.JsonElement> context, com.google.gson.JsonElement json) static void
setCraftingPlayer
(Player player) static <T> HolderLookup.RegistryLookup
<T> wrapRegistryLookup
(HolderLookup.RegistryLookup<T> lookup) static void
writeAdditionalLevelSaveData
(WorldData worldData, CompoundTag levelTag) static void
writeCondition
(ICondition condition, com.google.gson.JsonObject out)
-
字段详细资料
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
FORGEHOOKS
private static final org.apache.logging.log4j.Marker FORGEHOOKS -
WORLDPERSISTENCE
private static final org.apache.logging.log4j.Marker WORLDPERSISTENCE -
URL_PATTERN
-
CRAFTING_PLAYER
-
FORGE_ATTRIBUTES
-
FORGE_CONVERSION_MAP
private static final Lazy<Map<String,StructuresBecomeConfiguredFix.Conversion>> FORGE_CONVERSION_MAP
-
-
构造器详细资料
-
ForgeHooks
private ForgeHooks()
-
-
方法详细资料
-
canContinueUsing
-
isCorrectToolForDrops
public static boolean isCorrectToolForDrops(@NotNull @NotNull BlockState state, @NotNull @NotNull Player player) -
onLivingMakeBrain
public static Brain<?> onLivingMakeBrain(LivingEntity entity, Brain<?> originalBrain, com.mojang.serialization.Dynamic<?> dynamic) -
onLivingAttack
-
onPlayerAttack
-
onLivingUseTotem
public static boolean onLivingUseTotem(LivingEntity entity, DamageSource damageSource, ItemStack totem, InteractionHand hand) -
onLivingHurt
-
onLivingDamage
-
onInteractEntityAt
public static InteractionResult onInteractEntityAt(Entity entity, Player player, Vec3 vec3d, InteractionHand hand) -
getLootingLevel
public static int getLootingLevel(Entity target, @Nullable @Nullable Entity killer, @Nullable @Nullable DamageSource cause) -
getEntityVisibilityMultiplier
public static double getEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier) -
isLivingOnLadder
public 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) -
onServerChatSubmittedEvent
@Nullable public static @Nullable Component onServerChatSubmittedEvent(ServerPlayer player, Component message) -
newChatWithLinks
-
newChatWithLinks
-
dropXpForBlock
public static void dropXpForBlock(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack) -
onBlockBreakEvent
public static int onBlockBreakEvent(Level level, GameType gameType, ServerPlayer entityPlayer, BlockPos pos) -
onPlaceItemIntoWorld
-
onAnvilChange
-
onGrindstoneTake
public static boolean onGrindstoneTake(Container inputSlots, ContainerLevelAccess access, Function<Level, Integer> xpFunction) -
setCraftingPlayer
-
getCraftingPlayer
-
getCraftingRemainingItem
-
onPlayerAttackTarget
-
onItemRightClick
-
onChangeGameType
-
createLootTablePoolCodec
-
getVanillaFluidType
Returns a vanilla fluid type for the given fluid.- 参数:
fluid
- the fluid looking for its type- 返回:
- the type of the fluid if vanilla
- 抛出:
RuntimeException
- if the fluid is not a vanilla one
-
onCropsGrowPre
-
onCropsGrowPost
-
getCriticalHit
@Nullable public static @Nullable CriticalHitEvent getCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier) -
getProjectile
public 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. -
onFarmlandTrample
public static boolean onFarmlandTrample(ServerLevel level, BlockPos pos, BlockState state, float fallDistance, Entity entity) -
onNoteChange
-
getSerializer
@Nullable public static @Nullable EntityDataSerializer<?> getSerializer(int id, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) -
getSerializerId
public static int getSerializerId(EntityDataSerializer<?> serializer, CrudeIncrementalIntIdentityHashBiMap<EntityDataSerializer<?>> vanilla) -
canEntityDestroy
-
modifyLoot
public static it.unimi.dsi.fastutil.objects.ObjectArrayList<ItemStack> modifyLoot(LootTable table, 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.
- 参数:
generatedLoot
- The loot generated by the loot tablecontext
- The loot context that generated the loot, unmodifiedlootTableId
- The ID of the loot table currently being queried- 返回:
- 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()已过时。 -
modifyAttributes
已过时。 -
writeAdditionalLevelSaveData
-
readAdditionalLevelSaveData
@Internal public static void readAdditionalLevelSaveData(LevelStorageSource.LevelStorageAccess access, LevelStorageSource.LevelDirectory levelDirectory) -
encodeLifecycle
-
parseLifecycle
-
isNotDisguised
-
wrapRegistryLookup
@Internal public static <T> HolderLookup.RegistryLookup<T> wrapRegistryLookup(HolderLookup.RegistryLookup<T> lookup) -
onLivingBreathe
Handles living entities being under water. This fires theLivingBreatheEvent
and 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 if引用无效
IForgeEntity#canBeRiddenUnderFluidType(FluidType, Entity)
- 参数:
entity
- The living entity which is currently updatedconsumeAirAmount
- The amount of air to consume when the entity is unable to breatherefillAirAmount
- 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
public static void onCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) -
getCustomPayloadCodec
@Internal public static <B extends FriendlyByteBuf> StreamCodec<B,? extends CustomPacketPayload> getCustomPayloadCodec(ResourceLocation id, int max) -
onCustomPayload
-
onCustomPayload
@Internal public static boolean onCustomPayload(ClientboundCustomQueryPacket packet, Connection connection) -
onCustomPayload
@Internal public static boolean onCustomPayload(ServerboundCustomQueryAnswerPacket packet, Connection connection) -
onCustomPayload
-
handleClientConfigurationComplete
-
getEntitySpawnPacket
-
readAndTestCondition
@Internal public static boolean readAndTestCondition(com.mojang.serialization.DynamicOps<com.google.gson.JsonElement> ops, com.google.gson.JsonObject json) -
writeCondition
-
readConditional
@Nullable @Internal public static @Nullable com.google.gson.JsonElement readConditional(com.mojang.serialization.DynamicOps<com.google.gson.JsonElement> context, com.google.gson.JsonElement json) -
ingredientBaseCodec
@Internal public static com.mojang.serialization.Codec<Ingredient> ingredientBaseCodec(com.mojang.serialization.Codec<Ingredient> vanilla) -
ingredientStreamCodec
-
getDyeColorFromItemStack
-
gatherItemComponents
-
onJsonDataParsed
public static <T> T onJsonDataParsed(com.mojang.serialization.Codec<T> codec, ResourceLocation key, T value)
-