Class GenericTree

java.lang.Object
net.glowstone.generator.objects.trees.GenericTree
All Implemented Interfaces:
TerrainObject
Direct Known Subclasses:
AcaciaTree, BigOakTree, BirchTree, BrownMushroomTree, DarkOakTree, JungleBush, JungleTree, MegaJungleTree, RedwoodTree

public class GenericTree extends Object implements TerrainObject
Oak tree, and superclass for other types.
  • Field Details

    • LEAF_TYPES

      protected static final Set<org.bukkit.Material> LEAF_TYPES
    • delegate

      protected final BlockStateDelegate delegate
    • height

      protected int height
    • logType

      protected org.bukkit.Material logType
    • leavesType

      protected org.bukkit.Material leavesType
    • overridables

      protected Collection<org.bukkit.Material> overridables
  • Constructor Details

    • GenericTree

      public GenericTree(Random random, BlockStateDelegate delegate)
      Initializes this tree with a random height, preparing it to attempt to generate.
      Parameters:
      random - the PRNG
      delegate - the BlockStateDelegate used to check for space and to fill in wood and leaves
  • Method Details

    • setOverridables

      protected final void setOverridables(org.bukkit.Material... overridables)
    • setHeight

      protected final void setHeight(int height)
    • setTypes

      protected final void setTypes(org.bukkit.Material logType, org.bukkit.Material leavesType)
      Sets the block data values for this tree's blocks.
      Parameters:
      logType - the species portion of the data value for wood blocks.
      leavesType - the species portion of the data value for leaf blocks.
    • canHeightFit

      public boolean canHeightFit(int baseHeight)
      Checks whether this tree fits under the upper world limit.
      Parameters:
      baseHeight - the height of the base of the trunk
      Returns:
      true if this tree can grow without exceeding block height 255; false otherwise.
    • canPlaceOn

      public boolean canPlaceOn(org.bukkit.block.BlockState soil)
      Checks whether this tree can grow on top of the given block.
      Parameters:
      soil - the block we're growing on
      Returns:
      true if this tree can grow on the type of block below it; false otherwise
    • canPlace

      public boolean canPlace(int baseX, int baseY, int baseZ, org.bukkit.World world)
      Checks whether this tree has enough space to grow.
      Parameters:
      baseX - the X coordinate of the base of the trunk
      baseY - the Y coordinate of the base of the trunk
      baseZ - the Z coordinate of the base of the trunk
      world - the world to grow in
      Returns:
      true if this tree has space to grow; false otherwise
    • generate

      @Deprecated public boolean generate(org.bukkit.Location loc)
      Attempts to grow this tree at its current location. If successful, the associated BlockStateDelegate is instructed to set blocks to wood and leaves.
      Parameters:
      loc - the base of the trunk
      Returns:
      true if successfully grown; false otherwise
    • generate

      public boolean generate(org.bukkit.World world, Random random, int blockX, int blockY, int blockZ)
      Description copied from interface: TerrainObject
      Generates this feature.
      Specified by:
      generate in interface TerrainObject
      Parameters:
      world - the world to generate in
      random - the PRNG that will choose the size and a few details of the shape
      blockX - the base X coordinate
      blockY - the base Y coordinate
      blockZ - the base Z coordinate
      Returns:
      true if successfully generated
    • cannotGenerateAt

      protected boolean cannotGenerateAt(int baseX, int baseY, int baseZ, org.bukkit.World world)
      Returns whether any of canHeightFit(int), canPlace(int, int, int, World) or canPlaceOn(BlockState) prevent this tree from generating.
      Parameters:
      baseX - the X coordinate of the base of the trunk
      baseY - the Y coordinate of the base of the trunk
      baseZ - the Z coordinate of the base of the trunk
      world - the world to grow in
      Returns:
      true if any of the checks prevent us from generating, false otherwise
    • replaceIfAirOrLeaves

      protected void replaceIfAirOrLeaves(int x, int y, int z, org.bukkit.Material newMaterial, org.bukkit.World world)
      Replaces the block at a location with the given new one, if it is air or leaves.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      newMaterial - the new block type
      world - the world we are generating in
    • blockTypeAt

      protected org.bukkit.Material blockTypeAt(int x, int y, int z, org.bukkit.World world)
      Returns the block type at the given coordinates.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      world - the world we are generating in
      Returns:
      the block type