Class Tree
java.lang.Object
com.minecolonies.core.entity.ai.workers.util.Tree
Custom class for Trees. Used by lumberjack
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckIfInColony(net.minecraft.core.BlockPos pos, IColony colony, net.minecraft.world.level.LevelReader world, boolean allowInsideBuilding) Calculates with a colony if the position is inside the colony and optionally if it is inside a building.static booleancheckTree(@NotNull net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, List<ItemStorage> treesToNotCut, int dyntreesize) For use in PathJobFindTree.booleanOverridden equals method checks if the location of the both trees are equal.voidfillTreeStumps(int yLevel) Checks if the tree has been planted from more than 1 saplings.voidSearches all logs that belong to the tree.net.minecraft.core.BlockPosReturns the trees location.net.minecraft.world.item.ItemStackGets the trees saplingstatic List<net.minecraft.world.item.ItemStack>getSaplingsForLeaf(net.minecraft.server.level.ServerLevel world, net.minecraft.core.BlockPos position) Fills the list of drops for a leaf.@NotNull List<net.minecraft.core.BlockPos>All stump positions of a tree (A tree may have been planted with different saplings).net.minecraft.world.level.block.state.properties.Property<?>Get's the variant of a tree.inthashCode()Needed for the equals method.booleanCheck if the found tree has any leaves.booleanhasLogs()Check if the found tree has any logs.booleanbooleanbooleanbooleanisTree()Returns whether the Tree object actually is a tree.net.minecraft.core.BlockPosLooks up the next leaf block.net.minecraft.core.BlockPosLooks up the next log block.net.minecraft.core.BlockPosReturns the next leaf block.net.minecraft.core.BlockPosReturns the next log block.static @NotNull Treeread(@NotNull net.minecraft.nbt.CompoundTag compound) Reads the tree object from NBT.voidremoveStump(net.minecraft.core.BlockPos pos) Removes a stump from the stump list.voidwrite(@NotNull net.minecraft.nbt.CompoundTag compound) Writes the tree Object to NBT.
-
Constructor Details
-
Tree
public Tree(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos log, @Nullable @Nullable IColony colony) Creates a new tree Object for the lumberjack. Since the same type of variant of the block old log or new log do not match we have to separate them.- Parameters:
world- The world where the tree is in.log- the position of the found log.colony- the colony to search for buildings, or null if we don't care.
-
-
Method Details
-
getSaplingsForLeaf
public static List<net.minecraft.world.item.ItemStack> getSaplingsForLeaf(net.minecraft.server.level.ServerLevel world, net.minecraft.core.BlockPos position) Fills the list of drops for a leaf.- Parameters:
world- world referenceposition- position of the leaf- Returns:
- the list of saplings.
-
checkTree
public static boolean checkTree(@NotNull @NotNull net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, List<ItemStorage> treesToNotCut, int dyntreesize) For use in PathJobFindTree.- Parameters:
world- the world.pos- The coordinates.treesToNotCut- the trees the lumberjack is not supposed to cut.dyntreesize- the radius a dynamic tree must have in order to get cut down.- Returns:
- true if the log is part of a tree.
-
read
Reads the tree object from NBT.- Parameters:
compound- the compound of the tree.- Returns:
- a new tree object.
-
findLogs
public void findLogs(@NotNull @NotNull net.minecraft.world.level.Level world, @Nullable @Nullable IColony colony) Searches all logs that belong to the tree.- Parameters:
world- The world where the blocks are in.colony- the colony to search for buildings, or null if we don't care.
-
fillTreeStumps
public void fillTreeStumps(int yLevel) Checks if the tree has been planted from more than 1 saplings. Meaning that more than 1 log is on the lowest level.- Parameters:
yLevel- The base y.
-
pollNextLog
public net.minecraft.core.BlockPos pollNextLog()Returns the next log block.- Returns:
- the position.
-
getSapling
public net.minecraft.world.item.ItemStack getSapling()Gets the trees sapling- Returns:
- the sapling stack.
-
pollNextLeaf
public net.minecraft.core.BlockPos pollNextLeaf()Returns the next leaf block.- Returns:
- the position.
-
peekNextLog
public net.minecraft.core.BlockPos peekNextLog()Looks up the next log block.- Returns:
- the position.
-
peekNextLeaf
public net.minecraft.core.BlockPos peekNextLeaf()Looks up the next leaf block.- Returns:
- the position.
-
hasLeaves
public boolean hasLeaves()Check if the found tree has any leaves.- Returns:
- true if there are leaves associated with the tree.
-
hasLogs
public boolean hasLogs()Check if the found tree has any logs.- Returns:
- true if there are wood blocks associated with the tree.
-
isSlimeTree
public boolean isSlimeTree()- Returns:
- if tree is slime tree.
-
isDynamicTree
public boolean isDynamicTree()- Returns:
- if tree is dynamic tree
-
isNetherTree
public boolean isNetherTree()- Returns:
- if tree is nether tree
-
getStumpLocations
All stump positions of a tree (A tree may have been planted with different saplings).- Returns:
- an Arraylist of the positions.
-
removeStump
public void removeStump(net.minecraft.core.BlockPos pos) Removes a stump from the stump list.- Parameters:
pos- the position of the stump.
-
getVariant
public net.minecraft.world.level.block.state.properties.Property<?> getVariant()Get's the variant of a tree. A tree may only have 1 variant.- Returns:
- the EnumType variant.
-
getLocation
public net.minecraft.core.BlockPos getLocation()Returns the trees location.- Returns:
- the position.
-
hashCode
public int hashCode()Needed for the equals method. -
equals
Overridden equals method checks if the location of the both trees are equal. -
write
public void write(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Writes the tree Object to NBT.- Parameters:
compound- the compound of the tree.
-
isTree
public boolean isTree()Returns whether the Tree object actually is a tree.- Returns:
- isTree
-
checkIfInColony
public static boolean checkIfInColony(net.minecraft.core.BlockPos pos, IColony colony, net.minecraft.world.level.LevelReader world, boolean allowInsideBuilding) Calculates with a colony if the position is inside the colony and optionally if it is inside a building. Accessed off-thread by pathfinding- Parameters:
pos- the position.colony- the colony.world- the world to useallowInsideBuilding- if false, also checks that the tree is not inside a building.- Returns:
- return false if not inside the colony or optionally if inside a building.
-