java.lang.Object
org.cloudburstmc.server.level.generator.standard.misc.selector.MultiBlockSelector
All Implemented Interfaces:
BlockSelector

public final class MultiBlockSelector extends Object implements BlockSelector
Implementation of BlockSelector which selects a block from a pool of options.
Author:
DaPorkchop_
  • Field Details

    • states

      protected final org.cloudburstmc.api.block.BlockState[] states
    • statesWeighted

      protected final org.cloudburstmc.api.block.BlockState[] statesWeighted
    • entries

      protected final BlockSelector.Entry[] entries
  • Constructor Details

    • MultiBlockSelector

      public MultiBlockSelector(@NonNull @NonNull BlockSelector.Entry[] entries)
  • Method Details

    • size

      public int size()
      Specified by:
      size in interface BlockSelector
      Returns:
      the total number of BlockStates that this block selector can choose from
    • get

      public org.cloudburstmc.api.block.BlockState get(int index)
      Description copied from interface: BlockSelector
      Gets the BlockState at the given index.
      Specified by:
      get in interface BlockSelector
      Parameters:
      index - the index of the BlockState to get
      Returns:
      the BlockState at the given index
    • select

      public org.cloudburstmc.api.block.BlockState select(@NonNull @NonNull net.daporkchop.lib.random.PRandom random)
      Description copied from interface: BlockSelector
      Selects a random BlockState.
      Specified by:
      select in interface BlockSelector
      Parameters:
      random - the instance of PRandom to use for generating random numbers
      Returns:
      the selected BlockState
    • states

      public Stream<org.cloudburstmc.api.block.BlockState> states()
      Specified by:
      states in interface BlockSelector
      Returns:
      all of the BlockStates that this instance can select from
    • sizeWeighted

      public int sizeWeighted()
      Specified by:
      sizeWeighted in interface BlockSelector
      Returns:
      the total number of BlockStates that this block selector can choose from, taking selection weights into account
    • getWeighted

      public org.cloudburstmc.api.block.BlockState getWeighted(int index)
      Description copied from interface: BlockSelector
      Gets the BlockState at the given index, taking selection weights into account.
      Specified by:
      getWeighted in interface BlockSelector
      Parameters:
      index - the index of the BlockState to get
      Returns:
      the BlockState at the given index
    • selectWeighted

      public org.cloudburstmc.api.block.BlockState selectWeighted(@NonNull @NonNull net.daporkchop.lib.random.PRandom random)
      Description copied from interface: BlockSelector
      Selects a random block, taking selection weights into account.
      Specified by:
      selectWeighted in interface BlockSelector
      Parameters:
      random - the instance of PRandom to use for generating random numbers
      Returns:
      the selected BlockState
    • entries

      public Stream<BlockSelector.Entry> entries()
      Specified by:
      entries in interface BlockSelector
      Returns:
      all of the BlockStates that this instance can select from, taking selection weights into account