java.lang.Object
org.cloudburstmc.server.level.generator.standard.misc.ConstantBlock
All Implemented Interfaces:
Predicate<org.cloudburstmc.api.block.BlockState>, BlockFilter, BlockSelector, BlockSelector.Entry

public final class ConstantBlock extends Object implements BlockFilter, BlockSelector, BlockSelector.Entry
Represents a constant block configuration option.
Author:
DaPorkchop_
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.cloudburstmc.server.level.generator.standard.misc.selector.BlockSelector

    BlockSelector.Entry
  • Field Summary

    Fields inherited from interface org.cloudburstmc.server.level.generator.standard.misc.filter.BlockFilter

    AIR, REPLACEABLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ConstantBlock​(org.cloudburstmc.api.util.Identifier id, int meta)
     
  • 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​(net.daporkchop.lib.random.PRandom random)
    Selects a random BlockState.
    org.cloudburstmc.api.block.BlockState
    selectWeighted​(net.daporkchop.lib.random.PRandom random)
    Selects a random block, taking selection weights into account.
    int
     
    int
     
    org.cloudburstmc.api.block.BlockState
     
    Stream<org.cloudburstmc.api.block.BlockState>
     
    boolean
    test​(org.cloudburstmc.api.block.BlockState state)
     
    int
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.util.function.Predicate

    and, negate, or
  • Constructor Details

    • ConstantBlock

      public ConstantBlock(org.cloudburstmc.api.util.Identifier id, int meta)
    • ConstantBlock

      public ConstantBlock(String value)
  • Method Details

    • state

      public org.cloudburstmc.api.block.BlockState state()
      Specified by:
      state in interface BlockSelector.Entry
      Returns:
      the BlockState used by this entry
    • test

      public boolean test(org.cloudburstmc.api.block.BlockState state)
      Specified by:
      test in interface BlockFilter
      Specified by:
      test in interface Predicate<org.cloudburstmc.api.block.BlockState>
    • 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(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(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
    • weight

      public int weight()
      Specified by:
      weight in interface BlockSelector.Entry
      Returns:
      this entry's random selection weight