Class OrderedBlockListManager
java.lang.Object
net.rodofire.easierworldcreator.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(Map<net.minecraft.block.BlockState, List<net.minecraft.util.math.BlockPos>> info) init a comparatorOrderedBlockListManager(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList) init a default ordered blockList comparatorOrderedBlockListManager(BlockListManager manager) constructor to init aOrderedBlockListManager.constructor to init aOrderedBlockListManager. -
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.block.BlockStategetBlockState(short index) method to get the blockState related to the indexnet.minecraft.nbt.NbtCompoundgetCompound(short index) method to get the blockState related to the indexgetFirst()longRetrieves the first BlockPos in the position map.net.minecraft.block.BlockStateMethod to get the first BlockStatenet.minecraft.nbt.NbtCompoundgetFromPosIndex(int index) getLast()longRetrieves the last BlockPos in the position map.net.minecraft.block.BlockStateMethod to get the last BlockStatenet.minecraft.nbt.NbtCompoundgetPlacementRuleFromPosIndex(int index) List<it.unimi.dsi.fastutil.longs.LongShortImmutablePair> longRetrieves a random BlockPos from the position map.longgetRandomBlockPos(net.minecraft.util.math.random.Random random) Retrieves a random BlockPos from the position map using a provided random generator.voidinit(net.minecraft.world.StructureWorldAccess world) booleanmethod to know if no blockPos are presentbooleanmethod to know if no state is presentbooleanplace(net.minecraft.world.StructureWorldAccess world, int index) Method to place aBlockPosbased on the index.booleanplace(net.minecraft.world.StructureWorldAccess world, int index, int flag) booleanplaceAll(net.minecraft.world.StructureWorldAccess worldAccess) booleanplaceAllNDelete(net.minecraft.world.StructureWorldAccess worldAccess) booleanplaceFirst(net.minecraft.world.StructureWorldAccess world) booleanplaceLast(net.minecraft.world.StructureWorldAccess world) booleanplaceLastNDelete(net.minecraft.world.StructureWorldAccess world) booleanplaceNDelete(net.minecraft.world.StructureWorldAccess 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.put(net.minecraft.block.BlockState state, long pos) put(net.minecraft.block.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, long pos) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, it.unimi.dsi.fastutil.longs.LongArrayList posList) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, List<net.minecraft.util.math.BlockPos> posList) put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, net.minecraft.util.math.BlockPos pos) put(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos) voidput(OrderedBlockListManager comparator) longremoveBlockPos(int index) Removes the BlockPos at the specified index from the posList and posMap.net.minecraft.util.Pair<Long, net.minecraft.block.BlockState> removeBlockPosPair(int index) Removes the BlockPos at the specified index from the posList and retrieves its associated state.net.minecraft.util.Pair<Long, net.minecraft.block.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.net.minecraft.util.Pair<Long, net.minecraft.block.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.block.BlockState state, List<net.minecraft.util.math.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.block.BlockState, List<net.minecraft.util.math.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
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
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
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.math.random.Random 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.block.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.NbtCompound 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.block.BlockState getFirstBlockState()Method to get the first BlockState- Returns:
- the first BlockState
-
getFirst
-
getFirstCompound
public net.minecraft.nbt.NbtCompound getFirstCompound() -
getLastBlockState
public net.minecraft.block.BlockState getLastBlockState()Method to get the last BlockState- Returns:
- the last BlockState
-
getLast
-
getLastCompound
public net.minecraft.nbt.NbtCompound getLastCompound() -
setPosList
-
put
-
put
-
put
public OrderedBlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, it.unimi.dsi.fastutil.longs.LongArrayList posList) -
put
public OrderedBlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, long pos) -
put
public OrderedBlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, List<net.minecraft.util.math.BlockPos> posList) -
put
public OrderedBlockListManager put(net.minecraft.block.BlockState state, net.minecraft.nbt.NbtCompound tag, net.minecraft.util.math.BlockPos pos) -
put
public OrderedBlockListManager put(net.minecraft.block.BlockState state, it.unimi.dsi.fastutil.longs.LongArrayList pos) -
put
-
put
public OrderedBlockListManager put(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList) -
put
public OrderedBlockListManager put(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos) -
getFromPosIndex
-
getPlacementRuleFromPosIndex
-
placeLast
public boolean placeLast(net.minecraft.world.StructureWorldAccess world) -
placeFirst
public boolean placeFirst(net.minecraft.world.StructureWorldAccess world) -
placeAll
public boolean placeAll(net.minecraft.world.StructureWorldAccess worldAccess) -
placeLastNDelete
public boolean placeLastNDelete(net.minecraft.world.StructureWorldAccess world) -
placeNDelete
public boolean placeNDelete(net.minecraft.world.StructureWorldAccess 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.StructureWorldAccess worldAccess) -
place
public boolean place(net.minecraft.world.StructureWorldAccess world, int index) Method to place aBlockPosbased on the index. No placement flag is selected so the default took isBlock.FORCE_STATE. 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.StructureWorldAccess world, int index, int flag) -
init
public void init(net.minecraft.world.StructureWorldAccess world)
-