Class DefaultBlockList
java.lang.Object
net.rodofire.easierworldcreator.blockdata.blocklist.basic.DefaultBlockList
- All Implemented Interfaces:
BlockListManager
- Direct Known Subclasses:
CompoundBlockList,ForceBlockList
Class used to connect BlockPos to a BlockState.
the class is composed of a List<BlockPos> related to a BlockState.
This means that all the BlockPos of the object are connected to the BlockState
this is an easier version of the StructureTemplate.StructureBlockInfo
It also allows for better manipulation of how blocks behave and allows to save memory since that there is no double blockStates.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultBlockList(List<net.minecraft.util.math.BlockPos> posList, net.minecraft.block.BlockState blockState) init a BlockShapeManagerDefaultBlockList(net.minecraft.util.math.BlockPos pos, net.minecraft.block.BlockState state) init a BlockShapeManager -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlockPos(List<net.minecraft.util.math.BlockPos> pos) allow you to add multiple BlockPos to the existing listvoidaddBlockPos(net.minecraft.util.math.BlockPos pos) allow you to add a BlockPos to the existing listnet.minecraft.block.BlockStateused to get the blockStatenet.minecraft.util.math.BlockPosmethod to get the first blockPos of the posListnet.minecraft.util.Pair<com.google.gson.JsonObject, com.google.gson.JsonArray> getJson(net.minecraft.util.math.BlockPos offset) net.minecraft.util.math.BlockPosmethod to get the last blockPos of the posListnet.minecraft.util.math.BlockPosgetPos(int index) method to get a certain pos from an index in the posListList<net.minecraft.util.math.BlockPos> used to get the list of blockPos related to a layernet.minecraft.util.math.BlockPosMethod to get a randomBlockPosin theposListby using a new minecraft Randomnet.minecraft.util.math.BlockPosgetRandomPos(net.minecraft.util.math.random.Random random) Method to get a randomBlockPosin theposListbased on a provided randomvoidplace(net.minecraft.world.StructureWorldAccess world, int index) method to place the Block related to the indexvoidplaceAll(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparatorvoidplaceAllWithDeletion(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparator and removing the BlockPosvoidplaceAllWithVerification(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparator with the BlockPos getting verifiedvoidplaceAllWithVerificationDeletion(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparator with the BlockPos getting verified and the getting deletedvoidplaceFirst(net.minecraft.world.StructureWorldAccess world) method to place the first BlockvoidplaceFirstWithDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the first Block and deleting it.booleanplaceFirstWithVerification(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.voidplaceLast(net.minecraft.world.StructureWorldAccess world) Method to place the last Block of the comparator.voidplaceLastWithDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the last Block of the comparator and removing it then.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.voidplaceWithDeletion(net.minecraft.world.StructureWorldAccess world, int index) method to place the block with the deletion of the BlockPosbooleanplaceWithVerification(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.voidClears all elements from posList, posMap, and statesMap.net.minecraft.util.math.BlockPosRemoves and returns the first BlockPos from the posList and posMap.net.minecraft.util.math.BlockPosRemoves and returns the last BlockPos from the posList and posMap.net.minecraft.util.math.BlockPosremovePos(int index) Removes the BlockPos at the specified index from the posList and posMap.voidallow you to remove a list of BlockPos to the existing listvoidremovePos(net.minecraft.util.math.BlockPos pos) allow you to remove a BlockPos to the existing listvoidreplacePos(net.minecraft.util.math.BlockPos oldPos, net.minecraft.util.math.BlockPos newPos) method to replace one blockPos to another onevoidsetBlockState(net.minecraft.block.BlockState blockState) change the blockState of the BlockShapeManagervoidsetPosList(List<net.minecraft.util.math.BlockPos> posList) It uses a list of blockPos to allow multiple BlockPos to have a BlockStateintsize()method to get the number ofBlockPospresent in the related BlockListvoidtoString()
-
Constructor Details
-
DefaultBlockList
public DefaultBlockList(List<net.minecraft.util.math.BlockPos> posList, net.minecraft.block.BlockState blockState) init a BlockShapeManager- Parameters:
posList- pos of the blockStateblockState- the blockState related to the pos list
-
DefaultBlockList
public DefaultBlockList(net.minecraft.util.math.BlockPos pos, net.minecraft.block.BlockState state) init a BlockShapeManager- Parameters:
pos- pos of the blockStatestate- the blockState related to the pos list
-
-
Method Details
-
getPosList
used to get the list of blockPos related to a layer- Specified by:
getPosListin interfaceBlockListManager- Returns:
- the list of BlockPos
-
setPosList
It uses a list of blockPos to allow multiple BlockPos to have a BlockState- Specified by:
setPosListin interfaceBlockListManager- Parameters:
posList- a list of BlockPos
-
addBlockPos
public void addBlockPos(net.minecraft.util.math.BlockPos pos) allow you to add a BlockPos to the existing list- Specified by:
addBlockPosin interfaceBlockListManager- Parameters:
pos- the pos added
-
addBlockPos
allow you to add multiple BlockPos to the existing list- Specified by:
addBlockPosin interfaceBlockListManager- Parameters:
pos- the pos list added
-
removePos
public void removePos(net.minecraft.util.math.BlockPos pos) allow you to remove a BlockPos to the existing list- Specified by:
removePosin interfaceBlockListManager- Parameters:
pos- the pos removed
-
removePos
allow you to remove a list of BlockPos to the existing list- Specified by:
removePosin interfaceBlockListManager- Parameters:
pos- the list pos removed
-
removePos
public net.minecraft.util.math.BlockPos removePos(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
-
removeFirstPos
public net.minecraft.util.math.BlockPos 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 net.minecraft.util.math.BlockPos removeLastPos()Removes and returns the last BlockPos from the posList and posMap.- Specified by:
removeLastPosin interfaceBlockListManager- Returns:
- the first BlockPos that was removed.
- Throws:
IndexOutOfBoundsException- if the list is empty.
-
removeAll
public void removeAll()Clears all elements from posList, posMap, and statesMap. After this operation, all structures will be empty. -
replacePos
public void replacePos(net.minecraft.util.math.BlockPos oldPos, net.minecraft.util.math.BlockPos newPos) method to replace one blockPos to another one- Specified by:
replacePosin interfaceBlockListManager- Parameters:
oldPos- the oldPos that will be replacednewPos- the newPos that will replace the other blockPos
-
getPos
public net.minecraft.util.math.BlockPos getPos(int index) method to get a certain pos from an index in the posList- Specified by:
getPosin interfaceBlockListManager- Parameters:
index- the index of the BlockPos- Returns:
- the BlockPos of the index
-
getLastPos
public net.minecraft.util.math.BlockPos getLastPos()method to get the last blockPos of the posList- Specified by:
getLastPosin interfaceBlockListManager- Returns:
- the last blockPos of the posList
-
getFirstPos
public net.minecraft.util.math.BlockPos getFirstPos()method to get the first blockPos of the posList- Specified by:
getFirstPosin interfaceBlockListManager- Returns:
- the first blockPos of the posList
-
getRandomPos
public net.minecraft.util.math.BlockPos getRandomPos()Method to get a randomBlockPosin theposListby using a new minecraft Random- Specified by:
getRandomPosin interfaceBlockListManager- Returns:
- a random
BlockPos
-
getRandomPos
public net.minecraft.util.math.BlockPos getRandomPos(net.minecraft.util.math.random.Random random) Method to get a randomBlockPosin theposListbased on a provided random- Specified by:
getRandomPosin interfaceBlockListManager- Parameters:
random- the random object that will be used to get the index- Returns:
- a random
BlockPos
-
getBlockState
public net.minecraft.block.BlockState getBlockState()used to get the blockState- Specified by:
getBlockStatein interfaceBlockListManager- Returns:
- the blockState of the BlockShapeManager
-
setBlockState
public void setBlockState(net.minecraft.block.BlockState blockState) change the blockState of the BlockShapeManager- Specified by:
setBlockStatein interfaceBlockListManager- Parameters:
blockState- the blockState related to the BlockPos list
-
size
public int size()method to get the number ofBlockPospresent in the related BlockList- Specified by:
sizein interfaceBlockListManager- Returns:
- the number of
BlockPos
-
placeAll
public void placeAll(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparator- Parameters:
worldAccess- the world where the blocks will be placed
-
placeAllWithVerification
public void placeAllWithVerification(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparator with the BlockPos getting verified- Parameters:
worldAccess- the world where the blocks will be placed
-
placeAllWithDeletion
public void placeAllWithDeletion(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparator and removing the BlockPos- Parameters:
worldAccess- the world where the blocks will be placed
-
placeAllWithVerificationDeletion
public void placeAllWithVerificationDeletion(net.minecraft.world.StructureWorldAccess worldAccess) Method to place all the blocks in the comparator with the BlockPos getting verified and the getting deleted- Parameters:
worldAccess- the world where the blocks will be placed
-
place
public void place(net.minecraft.world.StructureWorldAccess world, int index) method to place the Block related to the index- Parameters:
world- the world the block will be placedindex- the index of the BlockPos
-
placeWithDeletion
public void placeWithDeletion(net.minecraft.world.StructureWorldAccess world, int index) method to place the block with the deletion of the BlockPos- Parameters:
world- the world the block will be placedindex- the index of the block
-
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.- 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.- Parameters:
world- the world the block will be placedindex- the index of the block- Returns:
- true if the block was placed, false if not
-
placeFirst
public void placeFirst(net.minecraft.world.StructureWorldAccess world) method to place the first Block- Parameters:
world- the world the block will be placed
-
placeFirstWithDeletion
public void placeFirstWithDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the first Block and deleting it. You shouldn't use this method in normal case since that the method is pretty costly O(n). Use insteadplaceLastWithDeletion()that is faster O(1).- Parameters:
world- the world where the block will be placed
-
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.
- 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).- Parameters:
world- the world where the block will be placed- Returns:
- true if the block was placed, false if not.
-
placeLastWithDeletion
public void placeLastWithDeletion(net.minecraft.world.StructureWorldAccess world) Method to place the last Block of the comparator and removing it then. Consider using this method because it gives you better performance.- Parameters:
world- the world the last block will be placed
-
placeLast
public void placeLast(net.minecraft.world.StructureWorldAccess world) Method to place the last Block of the comparator.- Parameters:
world- the world the last block will be placed
-
placeLastWithVerification
public boolean placeLastWithVerification(net.minecraft.world.StructureWorldAccess world) Method to place the last Block.- 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.- Parameters:
world- the world the last block will be placed- Returns:
- true if the block was placed, false if not
-
toString
-
toJson
-
getJson
public net.minecraft.util.Pair<com.google.gson.JsonObject,com.google.gson.JsonArray> getJson(net.minecraft.util.math.BlockPos offset)
-