Fix #1222 Fix #980 Refactor and improve tree generation

This commit is contained in:
mezz committed 2016-05-21 16:41:22 -07:00
1 parent 4fdbaff7ad
commit edacde02e7
63 files changed
+1395 -1199

No files matched your search

@@ -9,6 +9,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
@@ -78,13 +79,11 @@ public interface IFruitProvider {
/**
* Tries to spawn a fruit block at the potential position when the tree generates.
* Spawning a fruit has a random chance of success based on {@link ITreeGenome#getSappiness()}
*
* @param genome
* @param world
* @param pos
* @return true if a fruit block was spawned, false otherwise.
*/
boolean trySpawnFruitBlock(ITreeGenome genome, World world, BlockPos pos);
boolean trySpawnFruitBlock(ITreeGenome genome, World world, Random rand, BlockPos pos);
@SideOnly(Side.CLIENT)
void registerSprites();
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.arboriculture;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -18,9 +20,10 @@ public interface IGrowthProvider {
* @param pos Coordinates to attempt growth at.
* @param expectedGirth Trunk size of the tree to generate.
* @param expectedHeight Height of the tree to generate.
* @return true if the tree can grow at the given coordinates, false otherwise.
* @return position that the tree can grow, null otherwise.
*/
boolean canGrow(ITreeGenome genome, World world, BlockPos pos, int expectedGirth, int expectedHeight);
@Nullable
BlockPos canGrow(ITreeGenome genome, World world, BlockPos pos, int expectedGirth, int expectedHeight);
EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, BlockPos pos);
@@ -5,9 +5,11 @@
******************************************************************************/
package forestry.api.arboriculture;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface ILeafTickHandler {
boolean onRandomLeafTick(ITree tree, World world, BlockPos pos, boolean isDestroyed);
boolean onRandomLeafTick(ITree tree, World world, Random rand, BlockPos pos, boolean isDestroyed);
}
@@ -6,6 +6,7 @@
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@@ -62,10 +63,12 @@ public interface ITree extends IIndividual, ITreeGenData {
boolean canStay(IBlockAccess world, BlockPos pos);
/**
* @return Boolean indicating whether a sapling at the given position can grow into a tree.
* @return Position that this tree can grow. May be different from pos if there are multiple saplings.
* Returns null if a sapling at the given position can not grow into a tree.
*/
@Override
boolean canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight);
@Nullable
BlockPos canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight);
/**
* @return Integer denoting the maturity (block ticks) required for a sapling to attempt to grow into a tree.
@@ -5,6 +5,9 @@
******************************************************************************/
package forestry.api.world;
import javax.annotation.Nullable;
import java.util.Random;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -19,7 +22,12 @@ public interface ITreeGenData {
float getHeightModifier();
boolean canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight);
/**
* @return Position that this tree can grow. May be different from pos if there are multiple saplings.
* Returns null if a sapling at the given position can not grow into a tree.
*/
@Nullable
BlockPos canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight);
boolean setLeaves(World world, GameProfile owner, BlockPos pos);
@@ -27,7 +35,7 @@ public interface ITreeGenData {
boolean allowsFruitBlocks();
boolean trySpawnFruitBlock(World world, BlockPos pos);
boolean trySpawnFruitBlock(World world, Random rand, BlockPos pos);
ITreeGenome getGenome();
}