java.lang.Object
com.minecolonies.core.entity.ai.workers.util.Tree

public class Tree extends Object
Custom class for Trees. Used by lumberjack
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tree(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos log, @Nullable IColony colony)
    Creates a new tree Object for the lumberjack.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    static boolean
    checkTree(@NotNull net.minecraft.world.level.LevelReader world, net.minecraft.core.BlockPos pos, List<ItemStorage> treesToNotCut, int dyntreesize)
    For use in PathJobFindTree.
    boolean
    equals(@Nullable Object tree)
    Overridden equals method checks if the location of the both trees are equal.
    void
    fillTreeStumps(int yLevel)
    Checks if the tree has been planted from more than 1 saplings.
    void
    findLogs(@NotNull net.minecraft.world.level.Level world, @Nullable IColony colony)
    Searches all logs that belong to the tree.
    net.minecraft.core.BlockPos
    Returns the trees location.
    net.minecraft.world.item.ItemStack
    Gets the trees sapling
    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.
    @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.
    int
    Needed for the equals method.
    boolean
    Check if the found tree has any leaves.
    boolean
    Check if the found tree has any logs.
    boolean
     
    boolean
     
    boolean
     
    boolean
    Returns whether the Tree object actually is a tree.
    net.minecraft.core.BlockPos
    Looks up the next leaf block.
    net.minecraft.core.BlockPos
    Looks up the next log block.
    net.minecraft.core.BlockPos
    Returns the next leaf block.
    net.minecraft.core.BlockPos
    Returns the next log block.
    static @NotNull Tree
    read(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound)
    Reads the tree object from NBT.
    void
    removeStump(net.minecraft.core.BlockPos pos)
    Removes a stump from the stump list.
    void
    write(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound)
    Writes the tree Object to NBT.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • 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 reference
      position - 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

      @NotNull public static @NotNull Tree read(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      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

      @NotNull public @NotNull List<net.minecraft.core.BlockPos> 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.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of the location.
    • equals

      public boolean equals(@Nullable @Nullable Object tree)
      Overridden equals method checks if the location of the both trees are equal.
      Overrides:
      equals in class Object
      Parameters:
      tree - the object to compare.
      Returns:
      true if equal or false if not.
    • write

      public void write(@NotNull net.minecraft.core.HolderLookup.Provider provider, @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 use
      allowInsideBuilding - 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.