Interface BlockSelector
- 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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a single weightedBlockStatein aBlockSelector. -
Method Summary
Modifier and TypeMethodDescriptionentries()org.cloudburstmc.api.block.BlockStateget(int index)Gets theBlockStateat the given index.org.cloudburstmc.api.block.BlockStategetWeighted(int index)Gets theBlockStateat the given index, taking selection weights into account.org.cloudburstmc.api.block.BlockStateselect(@NonNull net.daporkchop.lib.random.PRandom random)Selects a randomBlockState.org.cloudburstmc.api.block.BlockStateselectWeighted(@NonNull net.daporkchop.lib.random.PRandom random)Selects a random block, taking selection weights into account.intsize()intStream<org.cloudburstmc.api.block.BlockState>states()
-
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 theBlockStateat the given index.- Parameters:
index- the index of theBlockStateto get- Returns:
- the
BlockStateat 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 randomBlockState.- Parameters:
random- the instance ofPRandomto 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 theBlockStateat the given index, taking selection weights into account.- Parameters:
index- the index of theBlockStateto get- Returns:
- the
BlockStateat 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 ofPRandomto use for generating random numbers- Returns:
- the selected
BlockState
-
entries
Stream<BlockSelector.Entry> entries()- Returns:
- all of the
BlockStates that this instance can select from, taking selection weights into account
-