Class WorldgenRandom

java.lang.Object
net.minecraft.world.level.levelgen.LegacyRandomSource
net.minecraft.world.level.levelgen.WorldgenRandom
All Implemented Interfaces:
RandomSource, BitRandomSource

public class WorldgenRandom extends LegacyRandomSource
  • Field Details

    • randomSource

      private final RandomSource randomSource
    • count

      private int count
  • Constructor Details

    • WorldgenRandom

      public WorldgenRandom(RandomSource randomSource)
  • Method Details

    • getCount

      public int getCount()
    • fork

      public RandomSource fork()
      Specified by:
      fork in interface RandomSource
      Overrides:
      fork in class LegacyRandomSource
    • forkPositional

      public PositionalRandomFactory forkPositional()
      Specified by:
      forkPositional in interface RandomSource
      Overrides:
      forkPositional in class LegacyRandomSource
    • next

      public int next(int bits)
      Specified by:
      next in interface BitRandomSource
      Overrides:
      next in class LegacyRandomSource
    • setSeed

      public void setSeed(long seed)
      Specified by:
      setSeed in interface RandomSource
      Overrides:
      setSeed in class LegacyRandomSource
    • setDecorationSeed

      public long setDecorationSeed(long levelSeed, int minChunkBlockX, int minChunkBlockZ)
      Seeds the current random for chunk decoration, including spawning mobs and for use in feature placement. The coordinates correspond to the minimum block position within a given chunk.
    • setFeatureSeed

      public void setFeatureSeed(long decorationSeed, int index, int decorationStep)
      Seeds the current random for placing features. Each feature is seeded differently in order to seem more random. However, it does not do a good job of this, and issues can arise from the salt being small with features that have the same decoration step and are close together in the feature lists.
      Parameters:
      decorationSeed - The seed computed by setDecorationSeed(long, int, int)
      index - The cumulative index of the generating feature within the biome's list of features.
      decorationStep - The ordinal of the GenerationStep.Decoration of the generating feature.
    • setLargeFeatureSeed

      public void setLargeFeatureSeed(long baseSeed, int chunkX, int chunkZ)
      Seeds the current random for placing large features such as caves, strongholds, and mineshafts.
      Parameters:
      baseSeed - This is passed in as the level seed, or in some cases such as carvers, as an offset from the level seed unique to each carver .
    • setLargeFeatureWithSalt

      public void setLargeFeatureWithSalt(long levelSeed, int regionX, int regionZ, int salt)
      Seeds the current random for placing the starts of structure features. The region coordinates are the region which the target chunk lies in. For example, witch hut regions are 32x32 chunks, so all chunks within that region would be seeded identically. The size of the regions themselves are determined by the spacing of the structure settings.
      Parameters:
      salt - A salt unique to each structure.
    • seedSlimeChunk

      public static RandomSource seedSlimeChunk(int chunkX, int chunkZ, long levelSeed, long salt)
      Creates a new RandomSource, seeded for determining whether a chunk is a slime chunk or not.
      Parameters:
      salt - For vanilla slimes, this is always 987234911L