Class OrderedBlockListManager
java.lang.Object
fr.rodofire.ewc.blockdata.blocklist.OrderedBlockListManager
OrderedBlockListManager class.
It allows you to sort the positions no matter the
BlockData.
It represents a final state of the BlockListManager,
meaning that no modifications can be done after putting BlockData.
For example, you cannot change a state related to a blockPos.
You cannot get The BlockPos related to a `BlockData`.
If you want to do something like this, use a BlockListManager.
While you can combine and put other Ordered / Base BlockListManager, it is not recommended as it has some important performance. You should combine BlockListManager then convert it to ordered.
-
Constructor Summary
ConstructorsConstructorDescriptioninit an empty comparatorOrderedBlockListManager(BlockListManager manager) constructor to init aOrderedBlockListManager.constructor to init aOrderedBlockListManager.OrderedBlockListManager(Map<net.minecraft.world.level.block.state.BlockState, List<net.minecraft.core.BlockPos>> info) init a comparatorOrderedBlockListManager(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList) init a default ordered blockList comparator -
Method Summary
Modifier and TypeMethodDescriptionbooleanMethod to know if no BlockPos are present in theposMapvoidclear()Clears all elements from posList, posMap, and statesMap.get(int index) longgetBlockPos(int index) Retrieves the BlockPos at a specified index.net.minecraft.world.level.block.state.BlockStategetBlockState(short index) method to get the blockState related to the indexnet.minecraft.nbt.CompoundTaggetCompound(short index) method to get the blockState related to the indexgetFirst()longRetrieves the first BlockPos in the position map.net.minecraft.world.level.block.state.BlockStateMethod to get the first BlockStatenet.minecraft.nbt.CompoundTaggetFromPosIndex(int index) getLast()longRetrieves the last BlockPos in the position map.net.minecraft.world.level.block.state.BlockStateMethod to get the last BlockStatenet.minecraft.nbt.CompoundTaggetPlacementRuleFromPosIndex(int index) List<it.unimi.dsi.fastutil.longs.LongShortImmutablePair> longRetrieves a random BlockPos from the position map.longgetRandomBlockPos(net.minecraft.util.RandomSource random) Retrieves a random BlockPos from the position map using a provided random generator.voidinit(net.minecraft.world.level.WorldGenLevel world) booleanmethod to know if no blockPos are presentbooleanmethod to know if no state is presentbooleanplace(net.minecraft.world.level.WorldGenLevel world, int index) Method to place aBlockPosbased on the index.booleanplace(net.minecraft.world.level.WorldGenLevel world, int index, int flag) booleanplaceAll(net.minecraft.world.level.WorldGenLevel worldAccess) booleanplaceAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess) booleanplaceFirst(net.minecraft.world.level.WorldGenLevel world) booleanplaceLast(net.minecraft.world.level.WorldGenLevel world) booleanplaceLastNDelete(net.minecraft.world.level.WorldGenLevel world) booleanplaceNDelete(net.minecraft.world.level.WorldGenLevel world, int index) for the most performance, it is recommended to not use this method whereplaceLastNDelete()can be appliedintposSize()Retrieves the number of entries in the position map.voidput(OrderedBlockListManager comparator) put(net.minecraft.world.level.block.state.BlockState state, long pos) put(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) put(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, it.unimi.dsi.fastutil.longs.LongArrayList posList) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList) put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos) longremoveBlockPos(int index) Removes the BlockPos at the specified index from the posList and posMap.com.mojang.datafixers.util.Pair<Long, net.minecraft.world.level.block.state.BlockState> removeBlockPosPair(int index) Removes the BlockPos at the specified index from the posList and retrieves its associated state.com.mojang.datafixers.util.Pair<Long, net.minecraft.world.level.block.state.BlockState> Removes and returns the first BlockPos and its associated state from the posList.longRemoves and returns the first BlockPos from the posList and posMap.com.mojang.datafixers.util.Pair<Long, net.minecraft.world.level.block.state.BlockState> Removes and returns the last BlockPos and its associated state from the posList.longRemoves and returns the last BlockPos from the posList and posMap.voidsetPosList(List<it.unimi.dsi.fastutil.longs.LongShortImmutablePair> posList) intmethod to get the size of the stateMap
-
Constructor Details
-
OrderedBlockListManager
constructor to init aOrderedBlockListManager.- Parameters:
manager- the manager to be fused
-
OrderedBlockListManager
constructor to init aOrderedBlockListManager.- Parameters:
manager- the manager to be fused
-
OrderedBlockListManager
public OrderedBlockListManager(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList) init a default ordered blockList comparator- Parameters:
state- the state that will be tested and put (in the case it doesn't exist)posList- the blockPos that will be put related to the given state
-
OrderedBlockListManager
public OrderedBlockListManager(Map<net.minecraft.world.level.block.state.BlockState, List<net.minecraft.core.BlockPos>> info) init a comparator- Parameters:
info- the map that will be used to init the comparator
-
OrderedBlockListManager
public OrderedBlockListManager()init an empty comparator
-
-
Method Details
-
arePosEmpty
public boolean arePosEmpty()Method to know if no BlockPos are present in theposMap- Returns:
-true if no BlockPos are present in the map.
-false if at least one BlockPos is present.
-
removeBlockPos
public long removeBlockPos(int index) Removes the BlockPos at the specified index from the posList and posMap.- Parameters:
index- the index of the BlockPos to remove.- Returns:
- the removed BlockPos.
- Throws:
IndexOutOfBoundsException- if the index is out of range.
-
removeBlockPosPair
public com.mojang.datafixers.util.Pair<Long,net.minecraft.world.level.block.state.BlockState> removeBlockPosPair(int index) Removes the BlockPos at the specified index from the posList and retrieves its associated state.- Parameters:
index- the index of the BlockPos to remove.- Returns:
- a Pair containing the removed BlockPos and its associated state.
- Throws:
IndexOutOfBoundsException- if the index is out of range.
-
removeFirstPos
public long removeFirstPos()Removes and returns the first BlockPos from the posList and posMap.- Returns:
- the first BlockPos that was removed.
- Throws:
IndexOutOfBoundsException- if the list is empty.
-
removeLastPos
public long removeLastPos()Removes and returns the last BlockPos from the posList and posMap.- Returns:
- the first BlockPos that was removed.
- Throws:
IndexOutOfBoundsException- if the list is empty.
-
removeFirstBlockPos
public com.mojang.datafixers.util.Pair<Long,net.minecraft.world.level.block.state.BlockState> removeFirstBlockPos()Removes and returns the first BlockPos and its associated state from the posList.- Returns:
- a Pair containing the first BlockPos and its associated state.
- Throws:
IndexOutOfBoundsException- if the list is empty.
-
removeLastBlockPosPair
public com.mojang.datafixers.util.Pair<Long,net.minecraft.world.level.block.state.BlockState> removeLastBlockPosPair()Removes and returns the last BlockPos and its associated state from the posList.- Returns:
- a Pair containing the last BlockPos and its associated state.
- Throws:
IndexOutOfBoundsException- if the list is empty.
-
clear
public void clear()Clears all elements from posList, posMap, and statesMap. After this operation, all structures will be empty. -
getPosList
-
getBlockPos
public long getBlockPos(int index) Retrieves the BlockPos at a specified index.- Parameters:
index- the index of the BlockPos to retrieve- Returns:
- the BlockPos at the specified index
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
getFirstBlockPos
public long getFirstBlockPos()Retrieves the first BlockPos in the position map.- Returns:
- the first BlockPos
- Throws:
NoSuchElementException- if the position map is empty
-
getLastBlockPos
public long getLastBlockPos()Retrieves the last BlockPos in the position map.- Returns:
- the last BlockPos
- Throws:
NoSuchElementException- if the position map is empty
-
getRandomBlockPos
public long getRandomBlockPos()Retrieves a random BlockPos from the position map.- Returns:
- a random BlockPos
- Throws:
IllegalStateException- if the position map is empty
-
getRandomBlockPos
public long getRandomBlockPos(net.minecraft.util.RandomSource random) Retrieves a random BlockPos from the position map using a provided random generator.- Parameters:
random- the Random object to use for generating random indices- Returns:
- a random BlockPos
- Throws:
IllegalStateException- if the position map is empty
-
posSize
public int posSize()Retrieves the number of entries in the position map.- Returns:
- the size of the position map
-
stateSize
public int stateSize()method to get the size of the stateMap- Returns:
- the size of the state map
-
isPosEmpty
public boolean isPosEmpty()method to know if no blockPos are present- Returns:
- true is no blockPos are present, false if not
-
isStateEmpty
public boolean isStateEmpty()method to know if no state is present- Returns:
- true is no blockPos are present, false if not
-
getBlockState
public net.minecraft.world.level.block.state.BlockState getBlockState(short index) method to get the blockState related to the index- Parameters:
index- the index of the BlockState- Returns:
- the blockState related to the index
-
get
-
getCompound
public net.minecraft.nbt.CompoundTag getCompound(short index) method to get the blockState related to the index- Parameters:
index- the index of the BlockState- Returns:
- the blockState related to the index
-
getFirstBlockState
public net.minecraft.world.level.block.state.BlockState getFirstBlockState()Method to get the first BlockState- Returns:
- the first BlockState
-
getFirst
-
getFirstCompound
public net.minecraft.nbt.CompoundTag getFirstCompound() -
getLastBlockState
public net.minecraft.world.level.block.state.BlockState getLastBlockState()Method to get the last BlockState- Returns:
- the last BlockState
-
getLast
-
getLastCompound
public net.minecraft.nbt.CompoundTag getLastCompound() -
setPosList
-
put
-
put
-
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, it.unimi.dsi.fastutil.longs.LongArrayList posList) -
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, long pos) -
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, List<net.minecraft.core.BlockPos> posList) -
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag tag, net.minecraft.core.BlockPos pos) -
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) -
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, long pos) -
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, List<net.minecraft.core.BlockPos> posList) -
put
public OrderedBlockListManager put(net.minecraft.world.level.block.state.BlockState state, net.minecraft.core.BlockPos pos) -
getFromPosIndex
-
getPlacementRuleFromPosIndex
-
placeLast
public boolean placeLast(net.minecraft.world.level.WorldGenLevel world) -
placeFirst
public boolean placeFirst(net.minecraft.world.level.WorldGenLevel world) -
placeAll
public boolean placeAll(net.minecraft.world.level.WorldGenLevel worldAccess) -
placeLastNDelete
public boolean placeLastNDelete(net.minecraft.world.level.WorldGenLevel world) -
placeNDelete
public boolean placeNDelete(net.minecraft.world.level.WorldGenLevel world, int index) for the most performance, it is recommended to not use this method whereplaceLastNDelete()can be applied -
placeAllNDelete
public boolean placeAllNDelete(net.minecraft.world.level.WorldGenLevel worldAccess) -
place
public boolean place(net.minecraft.world.level.WorldGenLevel world, int index) Method to place aBlockPosbased on the index. No placement flag is selected so the default took isBlock.UPDATE_KNOWN_SHAPE. No block updates are performed except for the client rendering, allowing for a huge gain in performance.- Parameters:
world- the world where the block will be placedindex- the index of the list of theBlockPos- Returns:
- true if it was placed
- false else
-
place
public boolean place(net.minecraft.world.level.WorldGenLevel world, int index, int flag) -
init
public void init(net.minecraft.world.level.WorldGenLevel world)
-