Class ForgeEventFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SaplingGrowTreeEventblockGrowFeature(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder<ConfiguredFeature<?, ?>> holder) static booleancanCreateFluidSource(Level level, BlockPos pos, BlockState state, boolean def) static net.minecraftforge.eventbus.api.Event.ResultcanEntityDespawn(Mob entity, ServerLevelAccessor level) static booleancanLivingConvert(LivingEntity entity, EntityType<? extends LivingEntity> outcome, Consumer<Integer> timer) static booleancanMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting) static booleandoPlayerHarvestCheck(Player player, BlockState state, boolean success) static voidfireChunkTicketLevelUpdated(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable ChunkHolder chunkHolder) static voidfireChunkUnWatch(ServerPlayer entity, ChunkPos chunkpos, ServerLevel level) static voidfireChunkWatch(ServerPlayer entity, LevelChunk chunk, ServerLevel level) static BlockStatefireFluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) static voidfirePlayerChangedDimensionEvent(Player player, ResourceKey<Level> fromDim, ResourceKey<Level> toDim) static voidfirePlayerCraftingEvent(Player player, ItemStack crafted, Container craftMatrix) static voidfirePlayerItemPickupEvent(Player player, ItemEntity item, ItemStack clone) static voidfirePlayerLoadingEvent(Player player, File playerDirectory, String uuidString) static voidfirePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) static voidfirePlayerLoggedIn(Player player) static voidfirePlayerLoggedOut(Player player) static voidfirePlayerRespawnEvent(Player player, boolean endConquered) static voidfirePlayerSavingEvent(Player player, File playerDirectory, String uuidString) static voidfirePlayerSmeltedEvent(Player player, ItemStack smelted) static booleanfireSleepingLocationCheck(LivingEntity player, BlockPos sleepingLocation) static booleanfireSleepingTimeCheck(Player player, Optional<BlockPos> sleepingLocation) static ZombieEvent.SummonAidEventfireZombieSummonAid(Zombie zombie, Level level, int x, int y, int z, LivingEntity attacker, double summonChance) static <T extends ICapabilityProvider>
@Nullable CapabilityDispatchergatherCapabilities(Class<? extends T> type, T provider) static <T extends ICapabilityProvider>
@Nullable CapabilityDispatchergatherCapabilities(Class<? extends T> type, T provider, @Nullable ICapabilityProvider parent) private static @Nullable CapabilityDispatchergatherCapabilities(AttachCapabilitiesEvent<?> event, @Nullable ICapabilityProvider parent) static floatgetBreakSpeed(Player player, BlockState state, float original, BlockPos pos) static EntityEvent.SizegetEntitySizeForge(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) static EntityEvent.SizegetEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight) static intgetExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) static intgetItemBurnTime(@NotNull ItemStack itemStack, int burnTime, @Nullable RecipeType<?> recipeType) static intgetMaxSpawnPackSize(Mob entity) static booleangetMobGriefingEvent(Level level, @Nullable Entity entity) static ComponentgetPlayerDisplayName(Player player, Component username) static ComponentgetPlayerTabListDisplayName(Player player) getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList<MobSpawnSettings.SpawnerData> oldList) static LootTableloadLootTable(ResourceLocation name, LootTable table, LootTables lootTableManager) static voidonAdvancementEarnedEvent(Player player, Advancement earned) static voidonAdvancementProgressedEvent(Player player, Advancement progressed, AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType) static booleanonAnimalTame(Animal animal, Player tamer) static intonApplyBonemeal(@NotNull Player player, @NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ItemStack stack) static intonArrowLoose(ItemStack stack, Level level, Player player, int charge, boolean hasAmmo) static InteractionResultHolder<ItemStack>onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) static booleanonBlockPlace(@Nullable Entity entity, @NotNull BlockSnapshot blockSnapshot, @NotNull Direction direction) static @Nullable InteractionResultHolder<ItemStack>onBucketUse(@NotNull Player player, @NotNull Level level, @NotNull ItemStack stack, @Nullable HitResult target) onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) static voidonCommandRegister(com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment, CommandBuildContext context) static booleanonCreateWorldSpawn(Level level, ServerLevelData settings) static intonEnchantmentLevelSet(Level level, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int enchantmentLevel) onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage) Deprecated, for removal: This API element is subject to removal in a future version.Use the hit result-sensitive version.onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, @Nullable HitResult hitResult) onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) static booleanonEntityDestroyBlock(LivingEntity entity, BlockPos pos, BlockState state) static booleanonEntityStruckByLightning(Entity entity, LightningBolt bolt) onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) static voidonExplosionDetonate(Level level, Explosion explosion, List<Entity> list, double diameter) static booleanonExplosionStart(Level level, Explosion explosion) static @Nullable SpawnGroupDataonFinalizeSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag) Vanilla calls toMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag)are replaced with calls to this method via coremod.
Mods should call this method in place of callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag).static MobSpawnEvent.FinalizeSpawnonFinalizeSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag spawnTag, BaseSpawner spawner) Returns the FinalizeSpawn event instance, or null if it was canceled.
This is separate since mob spawners perform special finalizeSpawn handling when NBT data is present, but we still want to fire the event.
This overload is also the only way to pass through aBaseSpawnerinstance.static intonItemExpire(ItemEntity entity, @NotNull ItemStack item) static intonItemPickup(ItemEntity entityItem, Player player) static ItemTooltipEventonItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags) static ItemStackonItemUseFinish(LivingEntity entity, ItemStack item, int duration, ItemStack result) static intonItemUseStart(LivingEntity entity, ItemStack item, int duration) static intonItemUseTick(LivingEntity entity, ItemStack item, int duration) static voidonLivingConvert(LivingEntity entity, LivingEntity outcome) static floatonLivingHeal(LivingEntity entity, float amount) static booleanonMultiBlockPlace(@Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction) onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate) static booleanonPermissionChanged(com.mojang.authlib.GameProfile gameProfile, int newLevel, PlayerList playerList) static booleanonPistonMovePost(Level level, BlockPos pos, Direction direction, boolean extending) static booleanonPistonMovePre(Level level, BlockPos pos, Direction direction, boolean extending) static voidonPlayerBrewedPotion(Player player, ItemStack stack) static voidonPlayerClone(Player player, Player oldPlayer, boolean wasDeath) static voidonPlayerDestroyItem(Player player, @NotNull ItemStack stack, @Nullable InteractionHand hand) static voidonPlayerFall(Player player, float distance, float multiplier) static voidonPlayerPostTick(Player player) static voidonPlayerPreTick(Player player) static Player.BedSleepingProblemonPlayerSleepInBed(Player player, Optional<BlockPos> pos) static booleanonPlayerSpawnSet(Player player, ResourceKey<Level> levelKey, BlockPos pos, boolean forced) static voidonPlayerWakeup(Player player, boolean wakeImmediately, boolean updateLevel) static PlayLevelSoundEvent.AtEntityonPlaySoundAtEntity(Entity entity, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) onPlaySoundAtPosition(Level level, double x, double y, double z, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) static voidstatic voidonPostLevelTick(Level level, BooleanSupplier haveTime) static voidonPostServerTick(BooleanSupplier haveTime, MinecraftServer server) static booleanonPotionAttemptBrew(NonNullList<ItemStack> stacks) static voidonPotionBrewed(NonNullList<ItemStack> brewingItemStacks) static voidstatic voidonPreLevelTick(Level level, BooleanSupplier haveTime) static voidonPreServerTick(BooleanSupplier haveTime, MinecraftServer server) static booleanonProjectileImpact(Projectile projectile, HitResult ray) static voidonRenderTickEnd(float timer) static voidonRenderTickStart(float timer) static List<PreparableReloadListener>onResourceReload(ReloadableServerResources serverResources) static longonSleepFinished(ServerLevel level, long newTime, long minTime) static voidonStartEntityTracking(Entity entity, Player player) static voidonStopEntityTracking(Entity entity, Player player) static @Nullable BlockStateonToolUse(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) static Optional<PortalShape>onTrySpawnPortal(LevelAccessor level, BlockPos pos, Optional<PortalShape> size) static booleanonUseItemStop(LivingEntity entity, ItemStack item, int duration) static booleansaplingGrowTree(LevelAccessor level, RandomSource randomSource, BlockPos pos) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
ForgeEventFactory
public ForgeEventFactory()
-
-
Method Details
-
onMultiBlockPlace
public static boolean onMultiBlockPlace(@Nullable @Nullable Entity entity, List<BlockSnapshot> blockSnapshots, Direction direction) -
onBlockPlace
public static boolean onBlockPlace(@Nullable @Nullable Entity entity, @NotNull @NotNull BlockSnapshot blockSnapshot, @NotNull @NotNull Direction direction) -
onNeighborNotify
public static BlockEvent.NeighborNotifyEvent onNeighborNotify(Level level, BlockPos pos, BlockState state, EnumSet<Direction> notifiedSides, boolean forceRedstoneUpdate) -
doPlayerHarvestCheck
-
getBreakSpeed
-
onPlayerDestroyItem
public static void onPlayerDestroyItem(Player player, @NotNull @NotNull ItemStack stack, @Nullable @Nullable InteractionHand hand) -
onFinalizeSpawn
@Nullable public static @Nullable SpawnGroupData onFinalizeSpawn(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable @Nullable SpawnGroupData spawnData, @Nullable @Nullable CompoundTag spawnTag) Vanilla calls toMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag)are replaced with calls to this method via coremod.
Mods should call this method in place of callingMob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag). Super calls (from within overrides) should not be wrapped.When interfacing with this event, write all code as normal, and replace the call to
Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag)with a call to this method.As an example, the following code block:
Would become:var zombie = new Zombie(level); zombie.finalizeSpawn(level, difficulty, spawnType, spawnData, spawnTag); level.tryAddFreshEntityWithPassengers(zombie); if (zombie.isAddedToWorld()) { // Do stuff with your new zombie }The only code that changes is thevar zombie = new Zombie(level); ForgeEventFactory.onFinalizeSpawn(zombie, level, difficulty, spawnType, spawnData, spawnTag); level.tryAddFreshEntityWithPassengers(zombie); if (zombie.isAddedToWorld()) { // Do stuff with your new zombie }Mob.finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag)call.- Returns:
- The SpawnGroupData from this event, or null if it was canceled. The return value of this method has no bearing on if the entity will be spawned.
- See Also:
- API Note:
- Callers do not need to check if the entity's spawn was cancelled, as the spawn will be blocked by Forge.
- Implementation Note:
- Changes to the signature of this method must be reflected in the method redirector coremod.
-
onFinalizeSpawnSpawner
@Nullable public static MobSpawnEvent.FinalizeSpawn onFinalizeSpawnSpawner(Mob mob, ServerLevelAccessor level, DifficultyInstance difficulty, @Nullable @Nullable SpawnGroupData spawnData, @Nullable @Nullable CompoundTag spawnTag, BaseSpawner spawner) Returns the FinalizeSpawn event instance, or null if it was canceled.
This is separate since mob spawners perform special finalizeSpawn handling when NBT data is present, but we still want to fire the event.
This overload is also the only way to pass through aBaseSpawnerinstance.- See Also:
-
canEntityDespawn
public static net.minecraftforge.eventbus.api.Event.Result canEntityDespawn(Mob entity, ServerLevelAccessor level) -
getItemBurnTime
public static int getItemBurnTime(@NotNull @NotNull ItemStack itemStack, int burnTime, @Nullable @Nullable RecipeType<?> recipeType) -
getExperienceDrop
public static int getExperienceDrop(LivingEntity entity, Player attackingPlayer, int originalExperience) -
getMaxSpawnPackSize
-
getPlayerDisplayName
-
getPlayerTabListDisplayName
-
fireFluidPlaceBlockEvent
public static BlockState fireFluidPlaceBlockEvent(LevelAccessor level, BlockPos pos, BlockPos liquidPos, BlockState state) -
onItemTooltip
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags) -
fireZombieSummonAid
public static ZombieEvent.SummonAidEvent fireZombieSummonAid(Zombie zombie, Level level, int x, int y, int z, LivingEntity attacker, double summonChance) -
onEntityStruckByLightning
-
onItemUseStart
-
onItemUseTick
-
onUseItemStop
-
onItemUseFinish
public static ItemStack onItemUseFinish(LivingEntity entity, ItemStack item, int duration, ItemStack result) -
onStartEntityTracking
-
onStopEntityTracking
-
firePlayerLoadingEvent
-
firePlayerSavingEvent
-
firePlayerLoadingEvent
public static void firePlayerLoadingEvent(Player player, PlayerDataStorage playerFileData, String uuidString) -
onToolUse
@Nullable public static @Nullable BlockState onToolUse(BlockState originalState, UseOnContext context, ToolAction toolAction, boolean simulate) -
onApplyBonemeal
public static int onApplyBonemeal(@NotNull @NotNull Player player, @NotNull @NotNull Level level, @NotNull @NotNull BlockPos pos, @NotNull @NotNull BlockState state, @NotNull @NotNull ItemStack stack) -
onBucketUse
-
onPlaySoundAtEntity
public static PlayLevelSoundEvent.AtEntity onPlaySoundAtEntity(Entity entity, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) -
onPlaySoundAtPosition
public static PlayLevelSoundEvent.AtPosition onPlaySoundAtPosition(Level level, double x, double y, double z, Holder<SoundEvent> name, SoundSource category, float volume, float pitch) -
onItemExpire
-
onItemPickup
-
canMountEntity
-
onAnimalTame
-
onPlayerSleepInBed
-
onPlayerWakeup
-
onPlayerFall
-
onPlayerSpawnSet
public static boolean onPlayerSpawnSet(Player player, ResourceKey<Level> levelKey, BlockPos pos, boolean forced) -
onPlayerClone
-
onExplosionStart
-
onExplosionDetonate
-
onCreateWorldSpawn
-
onLivingHeal
-
onPotionAttemptBrew
-
onPotionBrewed
-
onPlayerBrewedPotion
-
gatherCapabilities
@Nullable public static <T extends ICapabilityProvider> @Nullable CapabilityDispatcher gatherCapabilities(Class<? extends T> type, T provider) -
gatherCapabilities
@Nullable public static <T extends ICapabilityProvider> @Nullable CapabilityDispatcher gatherCapabilities(Class<? extends T> type, T provider, @Nullable @Nullable ICapabilityProvider parent) -
gatherCapabilities
@Nullable private static @Nullable CapabilityDispatcher gatherCapabilities(AttachCapabilitiesEvent<?> event, @Nullable @Nullable ICapabilityProvider parent) -
fireSleepingLocationCheck
-
fireSleepingTimeCheck
-
onArrowNock
public static InteractionResultHolder<ItemStack> onArrowNock(ItemStack item, Level level, Player player, InteractionHand hand, boolean hasAmmo) -
onArrowLoose
-
onProjectileImpact
-
loadLootTable
public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTables lootTableManager) -
canCreateFluidSource
public static boolean canCreateFluidSource(Level level, BlockPos pos, BlockState state, boolean def) -
onTrySpawnPortal
public static Optional<PortalShape> onTrySpawnPortal(LevelAccessor level, BlockPos pos, Optional<PortalShape> size) -
onEnchantmentLevelSet
-
onEntityDestroyBlock
-
getMobGriefingEvent
-
saplingGrowTree
@Deprecated(forRemoval=true, since="1.19.2") public static boolean saplingGrowTree(LevelAccessor level, RandomSource randomSource, BlockPos pos) Deprecated, for removal: This API element is subject to removal in a future version. -
blockGrowFeature
public static SaplingGrowTreeEvent blockGrowFeature(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable @Nullable Holder<ConfiguredFeature<?, ?>> holder) -
fireChunkTicketLevelUpdated
public static void fireChunkTicketLevelUpdated(ServerLevel level, long chunkPos, int oldTicketLevel, int newTicketLevel, @Nullable @Nullable ChunkHolder chunkHolder) -
fireChunkWatch
-
fireChunkUnWatch
-
onPistonMovePre
-
onPistonMovePost
-
onSleepFinished
-
onResourceReload
public static List<PreparableReloadListener> onResourceReload(ReloadableServerResources serverResources) -
onCommandRegister
public static void onCommandRegister(com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment, CommandBuildContext context) -
getEntitySizeForge
public static EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions size, float eyeHeight) -
getEntitySizeForge
public static EntityEvent.Size getEntitySizeForge(Entity entity, Pose pose, EntityDimensions oldSize, EntityDimensions newSize, float newEyeHeight) -
canLivingConvert
public static boolean canLivingConvert(LivingEntity entity, EntityType<? extends LivingEntity> outcome, Consumer<Integer> timer) -
onLivingConvert
-
onEntityTeleportCommand
public static EntityTeleportEvent.TeleportCommand onEntityTeleportCommand(Entity entity, double targetX, double targetY, double targetZ) -
onEntityTeleportSpreadPlayersCommand
public static EntityTeleportEvent.SpreadPlayersCommand onEntityTeleportSpreadPlayersCommand(Entity entity, double targetX, double targetY, double targetZ) -
onEnderTeleport
public static EntityTeleportEvent.EnderEntity onEnderTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) -
onEnderPearlLand
@Internal @Deprecated(forRemoval=true, since="1.19.2") public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage) Deprecated, for removal: This API element is subject to removal in a future version. -
onEnderPearlLand
@Internal public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, @Nullable @Nullable HitResult hitResult) -
onChorusFruitTeleport
public static EntityTeleportEvent.ChorusFruit onChorusFruitTeleport(LivingEntity entity, double targetX, double targetY, double targetZ) -
onPermissionChanged
public static boolean onPermissionChanged(com.mojang.authlib.GameProfile gameProfile, int newLevel, PlayerList playerList) -
firePlayerChangedDimensionEvent
public static void firePlayerChangedDimensionEvent(Player player, ResourceKey<Level> fromDim, ResourceKey<Level> toDim) -
firePlayerLoggedIn
-
firePlayerLoggedOut
-
firePlayerRespawnEvent
-
firePlayerItemPickupEvent
-
firePlayerCraftingEvent
-
firePlayerSmeltedEvent
-
onRenderTickStart
public static void onRenderTickStart(float timer) -
onRenderTickEnd
public static void onRenderTickEnd(float timer) -
onPlayerPreTick
-
onPlayerPostTick
-
onPreLevelTick
-
onPostLevelTick
-
onPreClientTick
public static void onPreClientTick() -
onPostClientTick
public static void onPostClientTick() -
onPreServerTick
-
onPostServerTick
-
getPotentialSpawns
public static WeightedRandomList<MobSpawnSettings.SpawnerData> getPotentialSpawns(LevelAccessor level, MobCategory category, BlockPos pos, WeightedRandomList<MobSpawnSettings.SpawnerData> oldList) -
onAdvancementEarnedEvent
-
onAdvancementProgressedEvent
@Internal public static void onAdvancementProgressedEvent(Player player, Advancement progressed, AdvancementProgress advancementProgress, String criterion, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType)
-