Class ForceOrderedBlockListComparator
java.lang.Object
net.rodofire.easierworldcreator.blockdata.blocklist.ordered.comparator.OrderedBlockListComparator<net.minecraft.block.BlockState>
net.rodofire.easierworldcreator.blockdata.blocklist.ordered.comparator.DefaultOrderedBlockListComparator
net.rodofire.easierworldcreator.blockdata.blocklist.ordered.comparator.ForceOrderedBlockListComparator
Class to manage an ordered list with force parameters.
This class uses a BiMap that connects each BlockState to a pair of Boolean and Set.
Force parameters works like that:
worldBlock : block at the blockPos
placeBlock : block to place at the blockPos
if force :
place placeBlock
else if worldBlock == air :
place placeBlock
else if worldBlock in forceBlock :
place placeBlock
else :
dont place
-
Field Summary
Fields inherited from class net.rodofire.easierworldcreator.blockdata.blocklist.ordered.comparator.OrderedBlockListComparator
posMap, statesMap -
Constructor Summary
ConstructorsConstructorDescriptioninit an empty comparatorForceOrderedBlockListComparator(Map<net.minecraft.block.BlockState, List<net.minecraft.util.math.BlockPos>> info) init a comparator based on a given mapForceOrderedBlockListComparator(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList) init a force ordered blockList comparatorForceOrderedBlockListComparator(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, boolean force, Set<net.minecraft.block.Block> blocksToForce) init a force ordered blockList comparator -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlocksToForce(net.minecraft.block.BlockState state, Set<net.minecraft.block.Block> blocksToForce) add a set of blocks to the setvoidaddBlocksToForce(net.minecraft.block.BlockState state, net.minecraft.block.Block block) add a block to the setSet<net.minecraft.block.Block> getBlocksToForce(net.minecraft.block.BlockState state) gives you the Set of every block that can be forcedcom.google.common.collect.BiMap<Short, net.minecraft.util.Pair<Boolean, Set<net.minecraft.block.Block>>> booleanisForce(net.minecraft.block.BlockState state) get if any block can be replaced by any BlockState of this BlockShapeManagerbooleanplaceFirstWithVerification(net.minecraft.world.StructureWorldAccess world) Method to place the first Block.booleanplaceFirstWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the first Block and deleting it.booleanplaceLastWithVerification(net.minecraft.world.StructureWorldAccess world) Method to place the last Block.booleanplaceLastWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the last Block of the comparator and removing it then.booleanplaceWithVerification(net.minecraft.world.StructureWorldAccess world, int index) Method to place the block related to the index.booleanplaceWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world, int index) Method to place the block with the deletion of the BlockPos The method also performs verification to know if the block can be placed.voidput(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, boolean force) Method to put some states and some blockpos in the comparatorvoidput(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, boolean force, Set<net.minecraft.block.Block> blocksToForce) Method to put some states and some blockpos in the comparatorvoidput(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, Set<net.minecraft.block.Block> blocksToForce) Method to put some states and some blockpos in the comparatorvoidput(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos, boolean force, Set<net.minecraft.block.Block> blocksToForce) Method to put some states and some blockpos in the comparatorvoidput(ForceOrderedBlockListComparator comparator) voidremoveBlocksToForce(net.minecraft.block.BlockState state, Set<net.minecraft.block.Block> blocksToForce) remove a set of blocks to the setvoidremoveBlocksToForce(net.minecraft.block.BlockState state, net.minecraft.block.Block block) remove a block to the setvoidsetBlocksToForce(net.minecraft.block.BlockState state, Set<net.minecraft.block.Block> blocksToForce) sets all the blocks that can be forced in the case force == falsevoidsetForce(net.minecraft.block.BlockState state, boolean force) sets if any block can be replaced by any BlockState of this BlockShapeManagerMethods inherited from class net.rodofire.easierworldcreator.blockdata.blocklist.ordered.comparator.DefaultOrderedBlockListComparator
getBlockState, getBlockStates, getFirstBlockState, getLastBlockState, place, placeFirst, placeFirstWithDeletion, placeLast, placeLastWithDeletion, placeWithDeletion, putMethods inherited from class net.rodofire.easierworldcreator.blockdata.blocklist.ordered.comparator.OrderedBlockListComparator
arePosEmpty, getBlockPos, getBlockPos, getBlockPos, getBlockPosSet, getFirstBlockPos, getFirstPosPair, getLastBlockPos, getLastPosPair, getPosList, getPosMap, getPosPair, getRandomBlockPos, getRandomBlockPos, getStateIndex, getStatesMap, getT, isPosEmpty, isPresent, isPresent, isStateEmpty, placeAll, placeAllWithDeletion, placeAllWithVerification, placeAllWithVerificationDeletion, posSize, put, put, put, putAll, removeAll, removeBlockPos, removeBlockPos, removeBlockPos, removeBlockPosPair, removeFirstBlockPos, removeFirstPos, removeLastBlockPosPair, removeLastPos, removeState, removeState, replaceState, setPosList, setPosMap, stateSize
-
Constructor Details
-
ForceOrderedBlockListComparator
public ForceOrderedBlockListComparator(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList) init a force 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
-
ForceOrderedBlockListComparator
public ForceOrderedBlockListComparator(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, boolean force, Set<net.minecraft.block.Block> blocksToForce) init a force ordered blockList comparator- Parameters:
state- the state that will be tested and put (in the case it doesn't exists)posList- the blockPos that will be put related to the given stateforce- set if the block should replace all blocks or noneblocksToForce- the set of blocks that the BlockState can still force
-
ForceOrderedBlockListComparator
public ForceOrderedBlockListComparator(Map<net.minecraft.block.BlockState, List<net.minecraft.util.math.BlockPos>> info) init a comparator based on a given map- Parameters:
info- the map that will serve to initialize the comparator
-
ForceOrderedBlockListComparator
public ForceOrderedBlockListComparator()init an empty comparator
-
-
Method Details
-
put
public void put(net.minecraft.block.BlockState state, net.minecraft.util.math.BlockPos pos, boolean force, Set<net.minecraft.block.Block> blocksToForce) Method to put some states and some blockpos in the comparator- Parameters:
state- the state that will be tested and put (in the case it doesn't exists)pos- the blockPos that will be put related to the given stateforce- set if the block should replace all blocks or noneblocksToForce- the set of blocks that the BlockState can still force
-
put
public void put(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, boolean force, Set<net.minecraft.block.Block> blocksToForce) Method to put some states and some blockpos in the comparator- Parameters:
state- the state that will be tested and put (in the case it doesn't exists)posList- the list of blockPos that will be put related to the given stateforce- set if the block should replace all blocks or noneblocksToForce- the set of blocks that the BlockState can still force
-
put
public void put(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, boolean force) Method to put some states and some blockpos in the comparator- Parameters:
state- the state that will be tested and put (in the case it doesn't exists)posList- the list of blockPos that will be put related to the given stateforce- set if the block should replace all blocks or none
-
put
public void put(net.minecraft.block.BlockState state, List<net.minecraft.util.math.BlockPos> posList, Set<net.minecraft.block.Block> blocksToForce) Method to put some states and some blockpos in the comparator- Parameters:
state- the state that will be tested and put (in the case it doesn't exists)posList- the list of blockPos that will be put related to the given stateblocksToForce- the set of blocks that the BlockState can still force
-
put
-
getBlocksToForce
gives you the Set of every block that can be forced- Returns:
- the set of the blocks that can be forced
-
getForceBlocks
-
setBlocksToForce
public void setBlocksToForce(net.minecraft.block.BlockState state, Set<net.minecraft.block.Block> blocksToForce) sets all the blocks that can be forced in the case force == false- Parameters:
blocksToForce- the set of blocks that can be forced
-
addBlocksToForce
public void addBlocksToForce(net.minecraft.block.BlockState state, net.minecraft.block.Block block) add a block to the set- Parameters:
block- the block added
-
addBlocksToForce
public void addBlocksToForce(net.minecraft.block.BlockState state, Set<net.minecraft.block.Block> blocksToForce) add a set of blocks to the set- Parameters:
blocksToForce- the set that will be added
-
removeBlocksToForce
public void removeBlocksToForce(net.minecraft.block.BlockState state, net.minecraft.block.Block block) remove a block to the set- Parameters:
block- the block removed
-
removeBlocksToForce
public void removeBlocksToForce(net.minecraft.block.BlockState state, Set<net.minecraft.block.Block> blocksToForce) remove a set of blocks to the set- Parameters:
blocksToForce- the set that will be removed
-
isForce
public boolean isForce(net.minecraft.block.BlockState state) get if any block can be replaced by any BlockState of this BlockShapeManager- Returns:
- the boolean related to it
-
setForce
public void setForce(net.minecraft.block.BlockState state, boolean force) sets if any block can be replaced by any BlockState of this BlockShapeManager- Parameters:
force- the boolean used
-
placeWithVerification
public boolean placeWithVerification(net.minecraft.world.StructureWorldAccess world, int index) Method to place the block related to the index. The method also performs verification to know if the block can be placed.- Overrides:
placeWithVerificationin classDefaultOrderedBlockListComparator- Parameters:
world- the world the block will be placedindex- the index of the block- Returns:
- true if the block was placed, false if not
-
placeWithVerificationDeletion
public boolean placeWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world, int index) Method to place the block with the deletion of the BlockPos The method also performs verification to know if the block can be placed.- Overrides:
placeWithVerificationDeletionin classDefaultOrderedBlockListComparator- Parameters:
world- the world the block will be placedindex- the index of the block- Returns:
- true if the block was placed, false if not
-
placeLastWithVerification
public boolean placeLastWithVerification(net.minecraft.world.StructureWorldAccess world) Method to place the last Block.- Overrides:
placeLastWithVerificationin classDefaultOrderedBlockListComparator- Parameters:
world- the world the last block will be placed The method also performs verification to know if the block can be placed.- Returns:
- true if the block was placed, false if not
-
placeLastWithVerificationDeletion
public boolean placeLastWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the last Block of the comparator and removing it then. The method also performs verification to know if the block can be placed. Consider using this method because it gives you better performance.- Overrides:
placeLastWithVerificationDeletionin classDefaultOrderedBlockListComparator- Parameters:
world- the world the last block will be placed- Returns:
- true if the block was placed, false if not
-
placeFirstWithVerification
public boolean placeFirstWithVerification(net.minecraft.world.StructureWorldAccess world) Method to place the first Block.The method also performs verification to know if the block can be placed.
- Overrides:
placeFirstWithVerificationin classDefaultOrderedBlockListComparator- Parameters:
world- the world where the block will be placed- Returns:
- true if the block was placed, false if not.
-
placeFirstWithVerificationDeletion
public boolean placeFirstWithVerificationDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the first Block and deleting it.
The method also performs verification to know if the block can be placed.
You shouldn't use this method in normal case since that the method is pretty costly O(n).
Use instead
placeLastWithDeletion()that is faster O(1).- Overrides:
placeFirstWithVerificationDeletionin classDefaultOrderedBlockListComparator- Parameters:
world- the world where the block will be placed- Returns:
- true if the block was placed, false if not.
-