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
Oak tree, and superclass for other types.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final BlockStateDelegate
protected int
protected static final Set<org.bukkit.Material>
protected org.bukkit.Material
protected org.bukkit.Material
protected Collection<org.bukkit.Material>
Fields inherited from interface net.glowstone.generator.objects.TerrainObject
PLANT_TYPES
-
Constructor Summary
ConstructorDescriptionGenericTree
(Random random, BlockStateDelegate delegate) Initializes this tree with a random height, preparing it to attempt to generate. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.bukkit.Material
blockTypeAt
(int x, int y, int z, org.bukkit.World world) Returns the block type at the given coordinates.boolean
canHeightFit
(int baseHeight) Checks whether this tree fits under the upper world limit.protected boolean
cannotGenerateAt
(int baseX, int baseY, int baseZ, org.bukkit.World world) Returns whether any ofcanHeightFit(int)
,canPlace(int, int, int, World)
orcanPlaceOn(BlockState)
prevent this tree from generating.boolean
canPlace
(int baseX, int baseY, int baseZ, org.bukkit.World world) Checks whether this tree has enough space to grow.boolean
canPlaceOn
(org.bukkit.block.BlockState soil) Checks whether this tree can grow on top of the given block.boolean
generate
(org.bukkit.Location loc) Deprecated.boolean
Generates this feature.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.protected final void
setHeight
(int height) protected final void
setOverridables
(org.bukkit.Material... overridables) protected final void
setTypes
(org.bukkit.Material logType, org.bukkit.Material leavesType) Sets the block data values for this tree's blocks.
-
Field Details
-
LEAF_TYPES
-
delegate
-
height
protected int height -
logType
protected org.bukkit.Material logType -
leavesType
protected org.bukkit.Material leavesType -
overridables
-
-
Constructor Details
-
GenericTree
Initializes this tree with a random height, preparing it to attempt to generate.- Parameters:
random
- the PRNGdelegate
- 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 trunkbaseY
- the Y coordinate of the base of the trunkbaseZ
- the Z coordinate of the base of the trunkworld
- the world to grow in- Returns:
- true if this tree has space to grow; false otherwise
-
generate
Deprecated.Attempts to grow this tree at its current location. If successful, the associatedBlockStateDelegate
is instructed to set blocks to wood and leaves.- Parameters:
loc
- the base of the trunk- Returns:
- true if successfully grown; false otherwise
-
generate
Description copied from interface:TerrainObject
Generates this feature.- Specified by:
generate
in interfaceTerrainObject
- Parameters:
world
- the world to generate inrandom
- the PRNG that will choose the size and a few details of the shapeblockX
- the base X coordinateblockY
- the base Y coordinateblockZ
- 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 ofcanHeightFit(int)
,canPlace(int, int, int, World)
orcanPlaceOn(BlockState)
prevent this tree from generating.- Parameters:
baseX
- the X coordinate of the base of the trunkbaseY
- the Y coordinate of the base of the trunkbaseZ
- the Z coordinate of the base of the trunkworld
- 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 coordinatey
- the y coordinatez
- the z coordinatenewMaterial
- the new block typeworld
- 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 coordinatey
- the y coordinatez
- the z coordinateworld
- the world we are generating in- Returns:
- the block type
-
generate(World, Random, int, int, int)