Class LevelEvent.PotentialSpawns

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.level.LevelEvent
net.neoforged.neoforge.event.level.LevelEvent.PotentialSpawns
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
Enclosing class:
LevelEvent

public static class LevelEvent.PotentialSpawns extends LevelEvent implements net.neoforged.bus.api.ICancellableEvent
Fired when building a list of all possible entities that can spawn at the specified location.

If an entry is added to the list, it needs to be a globally unique instance.

The event is called in
invalid reference
net.minecraft.world.level.NaturalSpawner#mobsAt(ServerLevel, StructureManager, ChunkGenerator, MobCategory, RandomSource, BlockPos)
.

This event is cancellable, and does not

invalid reference
have a result
. Canceling the event will result in an empty list, meaning no entity will be spawned.

  • Nested Class Summary

    Nested classes/interfaces inherited from class net.neoforged.neoforge.event.level.LevelEvent

    LevelEvent.CreateSpawnPosition, LevelEvent.Load, LevelEvent.PotentialSpawns, LevelEvent.Save, LevelEvent.Unload
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private net.minecraft.util.random.WeightedList.Builder<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData>
     
    private final net.minecraft.world.entity.MobCategory
     
    private final net.minecraft.core.BlockPos
     
    private List<net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PotentialSpawns(net.minecraft.world.level.LevelAccessor level, net.minecraft.world.entity.MobCategory category, net.minecraft.core.BlockPos pos, net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> oldList)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addSpawnerData(net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> data)
    Appends a SpawnerData entry to the spawn list.
    net.minecraft.world.entity.MobCategory
    Returns the category of the mobs in the spawn list..
    net.minecraft.core.BlockPos
    Returns the block position where the chosen mob will be spawned..
    List<net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData>>
    Returns the list of mobs that can potentially be spawned..
    private void
     
    void
    removeSpawnerData(net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> data)
    Removes a SpawnerData entry from the spawn list.

    Methods inherited from class net.neoforged.neoforge.event.level.LevelEvent

    getLevel

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.neoforged.bus.api.ICancellableEvent

    isCanceled, setCanceled
  • Field Details

    • mobcategory

      private final net.minecraft.world.entity.MobCategory mobcategory
    • pos

      private final net.minecraft.core.BlockPos pos
    • list

      @Nullable private net.minecraft.util.random.WeightedList.Builder<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> list
    • view

      private List<net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData>> view
  • Constructor Details

    • PotentialSpawns

      public PotentialSpawns(net.minecraft.world.level.LevelAccessor level, net.minecraft.world.entity.MobCategory category, net.minecraft.core.BlockPos pos, net.minecraft.util.random.WeightedList<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> oldList)
  • Method Details

    • getMobCategory

      public net.minecraft.world.entity.MobCategory getMobCategory()
      Returns the category of the mobs in the spawn list..
      Returns:
      the category of the mobs in the spawn list.
    • getPos

      public net.minecraft.core.BlockPos getPos()
      Returns the block position where the chosen mob will be spawned..
      Returns:
      the block position where the chosen mob will be spawned.
    • getSpawnerDataList

      public List<net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData>> getSpawnerDataList()
      Returns the list of mobs that can potentially be spawned..
      Returns:
      the list of mobs that can potentially be spawned.
    • makeList

      private void makeList()
    • addSpawnerData

      public void addSpawnerData(net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> data)
      Appends a SpawnerData entry to the spawn list.
      Parameters:
      data - SpawnerData entry to be appended to the spawn list.
    • removeSpawnerData

      public void removeSpawnerData(net.minecraft.util.random.Weighted<net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData> data)
      Removes a SpawnerData entry from the spawn list.
      Parameters:
      data - SpawnerData entry to be removed from the spawn list.