All Known Implementing Classes:
ConstantBlock, MultiBlockSelector

public interface BlockSelector
Allows selecting a block from a pool of options.
Author:
DaPorkchop_
See Also:
ConstantBlock
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Represents a single weighted BlockState in a BlockSelector.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    org.cloudburstmc.api.block.BlockState
    get​(int index)
    Gets the BlockState at the given index.
    org.cloudburstmc.api.block.BlockState
    getWeighted​(int index)
    Gets the BlockState at the given index, taking selection weights into account.
    org.cloudburstmc.api.block.BlockState
    select​(@NonNull net.daporkchop.lib.random.PRandom random)
    Selects a random BlockState.
    org.cloudburstmc.api.block.BlockState
    selectWeighted​(@NonNull net.daporkchop.lib.random.PRandom random)
    Selects a random block, taking selection weights into account.
    int
     
    int
     
    Stream<org.cloudburstmc.api.block.BlockState>
     
  • Method Details

    • size

      int size()
      Returns:
      the total number of BlockStates that this block selector can choose from
    • get

      org.cloudburstmc.api.block.BlockState get(int index)
      Gets the BlockState at the given index.
      Parameters:
      index - the index of the BlockState to get
      Returns:
      the BlockState at the given index
      Throws:
      IndexOutOfBoundsException - if the given index is outside of the range [0-size())
    • select

      org.cloudburstmc.api.block.BlockState select(@NonNull @NonNull net.daporkchop.lib.random.PRandom random)
      Selects a random BlockState.
      Parameters:
      random - the instance of PRandom to use for generating random numbers
      Returns:
      the selected BlockState
    • states

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

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

      org.cloudburstmc.api.block.BlockState getWeighted(int index)
      Gets the BlockState at the given index, taking selection weights into account.
      Parameters:
      index - the index of the BlockState to get
      Returns:
      the BlockState at the given index
      Throws:
      IndexOutOfBoundsException - if the given index is outside of the range [0-sizeWeighted())
    • selectWeighted

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

      Returns:
      all of the BlockStates that this instance can select from, taking selection weights into account