diff --git a/src/main/java/com/progwml6/natura/common/config/Config.java b/src/main/java/com/progwml6/natura/common/config/Config.java index 44a159f4..5e248d54 100644 --- a/src/main/java/com/progwml6/natura/common/config/Config.java +++ b/src/main/java/com/progwml6/natura/common/config/Config.java @@ -173,15 +173,26 @@ public static boolean syncConfig() redwoodSpawnRarity = configFile.get(WORLDGEN, "Redwood Tree Spawn Rarity", redwoodSpawnRarity).getInt(redwoodSpawnRarity); mapleRarity = configFile.get(WORLDGEN, "Maple Tree Spawn Rarity", mapleRarity).getInt(mapleRarity); + mapleSpawnRange = configFile.get(WORLDGEN, "Maple Tree Spawn Range", mapleSpawnRange).getInt(mapleSpawnRange); + silverbellRarity = configFile.get(WORLDGEN, "Silverbell Tree Spawn Rarity", silverbellRarity).getInt(silverbellRarity); + silverbellSpawnRange = configFile.get(WORLDGEN, "Silverbell Tree Spawn Range", silverbellSpawnRange).getInt(silverbellSpawnRange); + amaranthRarity = configFile.get(WORLDGEN, "Amaranth Tree Spawn Rarity", amaranthRarity).getInt(amaranthRarity); + amaranthSpawnRange = configFile.get(WORLDGEN, "Amaranth Tree Spawn Range", amaranthSpawnRange).getInt(amaranthSpawnRange); + tigerRarity = configFile.get(WORLDGEN, "Tigerwood Tree Spawn Rarity", tigerRarity).getInt(tigerRarity); + tigerSpawnRange = configFile.get(WORLDGEN, "Tigerwood Tree Spawn Range", tigerSpawnRange).getInt(tigerSpawnRange); willowRarity = configFile.get(WORLDGEN, "Willow Tree Spawn Rarity", willowRarity).getInt(willowRarity); + willowSpawnRange = configFile.get(WORLDGEN, "Willow Tree Spawn Range", willowSpawnRange).getInt(willowSpawnRange); + eucalyptusSpawnRarity = configFile.get(WORLDGEN, "Eucalyptus Tree Spawn Rarity", eucalyptusSpawnRarity).getInt(eucalyptusSpawnRarity); eucalyptusSpawnRange = configFile.get(WORLDGEN, "Eucalyptus Tree Spawn Range", eucalyptusSpawnRange).getInt(eucalyptusSpawnRange); + hopseedSpawnRarity = configFile.get(WORLDGEN, "Hopseed Tree Spawn Rarity", hopseedSpawnRarity).getInt(hopseedSpawnRarity); hopseedSpawnRange = configFile.get(WORLDGEN, "Hopseed Tree Spawn Range", hopseedSpawnRange).getInt(hopseedSpawnRange); + sakuraSpawnRarity = configFile.get(WORLDGEN, "Sakura Tree Spawn Rarity", sakuraSpawnRarity).getInt(sakuraSpawnRarity); sakuraSpawnRange = configFile.get(WORLDGEN, "Sakura Tree Spawn Range", sakuraSpawnRange).getInt(sakuraSpawnRange); @@ -192,6 +203,7 @@ public static boolean syncConfig() // Trees End saguaroSpawnRarity = configFile.get(WORLDGEN, "Saguaro Cactus Spawn Rarity", saguaroSpawnRarity).getInt(saguaroSpawnRarity); + saguaroSpawnRange = configFile.get(WORLDGEN, "Saguaro Cactus Spawn Range", saguaroSpawnRange).getInt(saguaroSpawnRange); // Berries Start raspberrySpawnRarity = configFile.get(WORLDGEN, "Raspberry Spawn Rarity", raspberrySpawnRarity).getInt(raspberrySpawnRarity); @@ -323,7 +335,7 @@ public static boolean syncConfig() public static boolean canRespawnInNether = true; // Trees Start - public static boolean generateRedwood = false; + public static boolean generateRedwood = true; public static boolean generateMaple = true; public static boolean generateSilverbell = true; public static boolean generateAmaranth = true; @@ -340,19 +352,25 @@ public static boolean syncConfig() public static boolean generateGhostwood = true; public static int redwoodSpawnRarity = 150; + public static int redwoodSpawnRange = 16; public static int mapleRarity = 10; - public static int silverbellRarity = 70; - public static int amaranthRarity = 1; - public static int tigerRarity = 30; + public static int mapleSpawnRange = 48; + public static int silverbellRarity = 10; + public static int silverbellSpawnRange = 48; + public static int amaranthRarity = 10; + public static int amaranthSpawnRange = 48; + public static int tigerRarity = 10; + public static int tigerSpawnRange = 48; public static int willowRarity = 10; + public static int willowSpawnRange = 16; public static int eucalyptusSpawnRarity = 30; public static int eucalyptusSpawnRange = 32; public static int hopseedSpawnRarity = 10; - public static int hopseedSpawnRange = 20; - public static int sakuraSpawnRarity = 50; + public static int hopseedSpawnRange = 32; + public static int sakuraSpawnRarity = 30; public static int sakuraSpawnRange = 32; - public static int appleSpawnRarity = 40; - public static int appleSpawnRange = 32; + public static int appleSpawnRarity = 20; + public static int appleSpawnRange = 48; public static int bloodwoodSpawnRarity = 14; public static int darkwoodSpawnRarity = 10; @@ -413,6 +431,7 @@ public static boolean syncConfig() public static boolean generateGlowshroomtree = true; public static int saguaroSpawnRarity = 5; + public static int saguaroSpawnRange = 16; public static int thornSpawnRarity = 40; diff --git a/src/main/java/com/progwml6/natura/world/worldgen/OverworldTreesGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/OverworldTreesGenerator.java index 0e8555ec..bae7e65e 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/OverworldTreesGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/OverworldTreesGenerator.java @@ -1,17 +1,6 @@ package com.progwml6.natura.world.worldgen; import java.util.Random; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.IChunkGenerator; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.BiomeDictionary.Type; -import net.minecraftforge.fml.common.IWorldGenerator; - import com.progwml6.natura.common.config.Config; import com.progwml6.natura.overworld.NaturaOverworld; import com.progwml6.natura.overworld.block.leaves.BlockAppleLeaves; @@ -21,7 +10,22 @@ import com.progwml6.natura.overworld.block.logs.BlockOverworldLog2; import com.progwml6.natura.overworld.block.logs.BlockRedwoodLog; import com.progwml6.natura.world.worldgen.saguaro.SaguaroGenerator; -import com.progwml6.natura.world.worldgen.trees.overworld.*; +import com.progwml6.natura.world.worldgen.trees.overworld.AppleTreeGenerator; +import com.progwml6.natura.world.worldgen.trees.overworld.EucalyptusTreeGenerator; +import com.progwml6.natura.world.worldgen.trees.overworld.HopseedTreeGenerator; +import com.progwml6.natura.world.worldgen.trees.overworld.OverworldTreeGenerator; +import com.progwml6.natura.world.worldgen.trees.overworld.RedwoodTreeGenerator; +import com.progwml6.natura.world.worldgen.trees.overworld.SakuraTreeGenerator; +import com.progwml6.natura.world.worldgen.trees.overworld.WillowTreeGenerator; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.IChunkGenerator; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; +import net.minecraftforge.fml.common.IWorldGenerator; public class OverworldTreesGenerator implements IWorldGenerator { @@ -87,6 +91,7 @@ public void retroGen(Random random, int chunkX, int chunkZ, World world) world.getChunk(chunkX, chunkZ).markDirty(); } + // TODO: Rework tree generation to use DecorateBiomeEvent.Decorate.EventType.TREE, might have to scrap retro-gen public void generateOverworld(Random random, int chunkX, int chunkZ, World world, boolean retroGen) { int xSpawn; @@ -108,21 +113,18 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world { if (Config.generateSakura && random.nextInt(Config.sakuraSpawnRarity) == 0) { - for (int iter = 0; iter < 3; iter++) - { - xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.sakuraSpawnRange) + Config.seaLevel; - zSpawn = zPos + random.nextInt(16); - position = new BlockPos(xSpawn, ySpawn, zSpawn); + xSpawn = xPos + random.nextInt(16); + ySpawn = Config.sakuraSpawnRange + Config.seaLevel; + zSpawn = zPos + random.nextInt(16); + position = new BlockPos(xSpawn, ySpawn, zSpawn); - this.sakuraTreeGen.generateTree(random, world, position); - } + this.sakuraTreeGen.generateTree(random, world, position); } if (Config.generateEucalyptus && random.nextInt(Config.eucalyptusSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.eucalyptusSpawnRange) + Config.seaLevel; + ySpawn = Config.eucalyptusSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -132,7 +134,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateMaple && random.nextInt(Config.mapleRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + 48; + ySpawn = Config.mapleSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -142,7 +144,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateSilverbell && random.nextInt(Config.silverbellRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + 48; + ySpawn = Config.silverbellSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -152,7 +154,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateTiger && random.nextInt(Config.tigerRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + 48; + ySpawn = Config.tigerSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -162,7 +164,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateApple && random.nextInt(Config.appleSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.appleSpawnRange) + Config.seaLevel; + ySpawn = Config.appleSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -175,7 +177,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (!retroGen && Config.generateRedwood && random.nextInt(Config.redwoodSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + 16; + ySpawn = Config.redwoodSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -185,7 +187,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateEucalyptus && random.nextInt(Config.eucalyptusSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.eucalyptusSpawnRange) + Config.seaLevel; + ySpawn = Config.eucalyptusSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -195,7 +197,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateApple && random.nextInt(Config.appleSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.appleSpawnRange) + Config.seaLevel; + ySpawn = Config.appleSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -208,7 +210,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateHopseed && random.nextInt(Config.hopseedSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.hopseedSpawnRange) + Config.seaLevel; + ySpawn = Config.hopseedSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -218,7 +220,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateEucalyptus && random.nextInt(Config.eucalyptusSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.eucalyptusSpawnRange) + Config.seaLevel; + ySpawn = Config.eucalyptusSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -230,21 +232,18 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world { if (Config.generateSakura && random.nextInt(Config.sakuraSpawnRarity) == 0) { - for (int iter = 0; iter < 3; iter++) - { - xSpawn = xPos + random.nextInt(16); - ySpawn = random.nextInt(Config.sakuraSpawnRange) + Config.seaLevel; - zSpawn = zPos + random.nextInt(16); - position = new BlockPos(xSpawn, ySpawn, zSpawn); + xSpawn = xPos + random.nextInt(16); + ySpawn = Config.sakuraSpawnRange + Config.seaLevel; + zSpawn = zPos + random.nextInt(16); + position = new BlockPos(xSpawn, ySpawn, zSpawn); - this.sakuraTreeGen.generateTree(random, world, position); - } + this.sakuraTreeGen.generateTree(random, world, position); } if (Config.generateWillow && random.nextInt(Config.willowRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + 16; + ySpawn = Config.willowSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -253,11 +252,24 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world } if (BiomeDictionary.hasType(biome, Type.JUNGLE)) + { + if (Config.generateAmaranth) + { + xSpawn = xPos + random.nextInt(16); + ySpawn = Config.amaranthSpawnRange + Config.seaLevel; + zSpawn = zPos + random.nextInt(16); + position = new BlockPos(xSpawn, ySpawn, zSpawn); + + this.amaranthTreeGen.generateTree(random, world, position); + } + } + + if (BiomeDictionary.hasType(biome, Type.SAVANNA)) { if (Config.generateAmaranth && random.nextInt(Config.amaranthRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + 48; + ySpawn = Config.amaranthSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -272,7 +284,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world for (int i = 0; i < 3; i++) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + 16; + ySpawn = Config.amaranthSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -286,7 +298,7 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world if (Config.generateSaguaro && random.nextInt(Config.saguaroSpawnRarity) == 0) { xSpawn = xPos + random.nextInt(16); - ySpawn = Config.seaLevel + random.nextInt(16); + ySpawn = Config.saguaroSpawnRange + Config.seaLevel; zSpawn = zPos + random.nextInt(16); position = new BlockPos(xSpawn, ySpawn, zSpawn); @@ -308,5 +320,4 @@ public boolean shouldGenerateInDimension(int dimension) return true; } - } diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/BaseTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/BaseTreeGenerator.java index 0b90adaf..7ccd82b6 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/BaseTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/BaseTreeGenerator.java @@ -1,7 +1,6 @@ package com.progwml6.natura.world.worldgen.trees; import java.util.Random; - import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/BloodwoodTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/BloodwoodTreeGenerator.java index 72d7c3a1..c4d90947 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/BloodwoodTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/BloodwoodTreeGenerator.java @@ -1,16 +1,14 @@ package com.progwml6.natura.world.worldgen.trees.nether; import java.util.Random; - +import com.progwml6.natura.nether.NaturaNether; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import com.progwml6.natura.nether.NaturaNether; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class BloodwoodTreeGenerator extends BaseTreeGenerator { public final IBlockState full; diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/DarkwoodTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/DarkwoodTreeGenerator.java index 6af4b239..288c27d6 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/DarkwoodTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/DarkwoodTreeGenerator.java @@ -1,7 +1,8 @@ package com.progwml6.natura.world.worldgen.trees.nether; import java.util.Random; - +import com.progwml6.natura.nether.NaturaNether; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -9,9 +10,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import com.progwml6.natura.nether.NaturaNether; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class DarkwoodTreeGenerator extends BaseTreeGenerator { public final int minTreeHeight; @@ -133,7 +131,7 @@ protected IBlockState getRandomizedLeaves(Random random) return (random.nextInt(25) == 0 ? this.fruiting : random.nextInt(15) == 0 ? this.flowering : this.leaves); } - BlockPos findGround(World world, BlockPos pos) + protected BlockPos findGround(World world, BlockPos pos) { boolean foundGround = false; int height = pos.getY(); diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/FusewoodTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/FusewoodTreeGenerator.java index 6fb2d09e..38421efe 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/FusewoodTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/FusewoodTreeGenerator.java @@ -1,7 +1,8 @@ package com.progwml6.natura.world.worldgen.trees.nether; import java.util.Random; - +import com.progwml6.natura.nether.NaturaNether; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; @@ -9,9 +10,6 @@ import net.minecraft.util.math.BlockPos.MutableBlockPos; import net.minecraft.world.World; -import com.progwml6.natura.nether.NaturaNether; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class FusewoodTreeGenerator extends BaseTreeGenerator { public final int minTreeHeight; @@ -126,7 +124,7 @@ protected void placeTrunk(World worldIn, BlockPos position, int height) } } - BlockPos findGround(World world, BlockPos pos) + protected BlockPos findGround(World world, BlockPos pos) { int returnHeight = 0; diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/GhostwoodTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/GhostwoodTreeGenerator.java index e3b7761f..6001b5f8 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/GhostwoodTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/nether/GhostwoodTreeGenerator.java @@ -2,8 +2,10 @@ import java.util.List; import java.util.Random; - import com.google.common.collect.Lists; +import com.progwml6.natura.common.block.BlockEnumLog; +import com.progwml6.natura.nether.NaturaNether; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -12,10 +14,6 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import com.progwml6.natura.common.block.BlockEnumLog; -import com.progwml6.natura.nether.NaturaNether; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class GhostwoodTreeGenerator extends BaseTreeGenerator { public final IBlockState log; @@ -101,6 +99,27 @@ protected void setBlockAndMetadata(World world, BlockPos pos, IBlockState stateN } } + protected BlockPos findGround(World world, BlockPos pos) + { + boolean foundGround = false; + int height = pos.getY(); + + BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); + + do + { + position = position.down(); + Block underBlock = world.getBlockState(position).getBlock(); + + if (underBlock == Blocks.NETHERRACK || underBlock == Blocks.SOUL_SAND || underBlock == NaturaNether.netherTaintedSoil || position.getY() < 0) + { + foundGround = true; + } + } while (!foundGround); + + return position.up(); + } + /** * Generates a list of leaf nodes for the tree, to be populated by generateLeaves. */ @@ -321,27 +340,6 @@ int checkBlockLine(BlockPos posOne, BlockPos posTwo) return -1; } - BlockPos findGround(World world, BlockPos pos) - { - boolean foundGround = false; - int height = pos.getY(); - - BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); - - do - { - position = position.down(); - Block underBlock = world.getBlockState(position).getBlock(); - - if (underBlock == Blocks.NETHERRACK || underBlock == Blocks.SOUL_SAND || underBlock == NaturaNether.netherTaintedSoil || position.getY() < 0) - { - foundGround = true; - } - } while (!foundGround); - - return position.up(); - } - /** * Returns the absolute greatest distance in the BlockPos object. */ diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/AppleTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/AppleTreeGenerator.java index c9495b27..09ec0806 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/AppleTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/AppleTreeGenerator.java @@ -1,19 +1,11 @@ package com.progwml6.natura.world.worldgen.trees.overworld; import java.util.Random; - -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.WorldType; - -import com.progwml6.natura.common.config.Config; -import com.progwml6.natura.overworld.NaturaOverworld; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; -public class AppleTreeGenerator extends BaseTreeGenerator +public class AppleTreeGenerator extends OverworldTreeGenerator { public final int minTreeHeight; @@ -35,6 +27,7 @@ public class AppleTreeGenerator extends BaseTreeGenerator public AppleTreeGenerator(int treeHeight, int treeRange, IBlockState log, IBlockState leaves, IBlockState flowering, IBlockState fruiting, IBlockState fruitingGolden, boolean seekHeight, boolean isSapling) { + super(treeHeight, treeRange, log, leaves, seekHeight, isSapling); this.minTreeHeight = treeHeight; this.treeHeightRange = treeRange; this.log = log; @@ -52,40 +45,6 @@ public AppleTreeGenerator(int treeHeight, int treeRange, IBlockState log, IBlock } @Override - public void generateTree(Random rand, World worldIn, BlockPos position) - { - int heightRange = rand.nextInt(this.treeHeightRange) + this.minTreeHeight; - - if (this.seekHeight) - { - position = this.findGround(worldIn, position); - - if (position.getY() < 0) - { - return; - } - } - - if (position.getY() >= 1 && position.getY() + heightRange + 1 <= 256) - { - IBlockState state = worldIn.getBlockState(position.down()); - Block soil = state.getBlock(); - boolean isSoil = soil.canSustainPlant(state, worldIn, position.down(), EnumFacing.UP, NaturaOverworld.appleSapling); - - if (isSoil) - { - if (!this.checkIfCanGrow(position, heightRange, worldIn)) - { - return; - } - - soil.onPlantGrow(state, worldIn, position.down(), position); - this.placeCanopy(worldIn, rand, position, heightRange); - this.placeTrunk(worldIn, position, heightRange); - } - } - } - protected void placeCanopy(World world, Random random, BlockPos pos, int height) { for (int y = pos.getY() - 3 + height; y <= pos.getY() + height; ++y) @@ -116,21 +75,6 @@ protected void placeCanopy(World world, Random random, BlockPos pos, int height) } } - protected void placeTrunk(World world, BlockPos pos, int height) - { - for (int localHeight = 0; localHeight < height; ++localHeight) - { - BlockPos blockpos = new BlockPos(pos.getX(), pos.getY() + localHeight, pos.getZ()); - IBlockState state = world.getBlockState(blockpos); - Block block = state.getBlock(); - - if (block.isAir(state, world, blockpos) || block.isLeaves(state, world, blockpos) || block.isReplaceable(world, blockpos)) - { - world.setBlockState(blockpos, this.log, 2); - } - } - } - protected IBlockState getRandomizedLeaves(Random random) { int chance = random.nextInt(200); @@ -152,100 +96,4 @@ else if (chance < 40) return this.leaves; } } - - BlockPos findGround(World world, BlockPos pos) - { - int returnHeight = 0; - - int height = pos.getY(); - - if (world.getWorldType() == WorldType.FLAT && this.isSapling) - { - do - { - BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); - IBlockState state = world.getBlockState(position); - Block block = state.getBlock(); - boolean isSoil = block.canSustainPlant(state, world, position, EnumFacing.UP, NaturaOverworld.appleSapling); - - if (isSoil && !world.getBlockState(position.up()).isFullBlock()) - { - returnHeight = height + 1; - break; - } - - height--; - } while (height > Config.flatSeaLevel); - } - else - { - do - { - BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); - IBlockState state = world.getBlockState(position); - Block block = state.getBlock(); - boolean isSoil = block.canSustainPlant(state, world, position, EnumFacing.UP, NaturaOverworld.appleSapling); - - if (isSoil && !world.getBlockState(position.up()).isFullBlock()) - { - returnHeight = height + 1; - break; - } - - height--; - } while (height > Config.seaLevel); - - } - return new BlockPos(pos.getX(), returnHeight, pos.getZ()); - } - - private boolean checkIfCanGrow(BlockPos position, int heightRange, World worldIn) - { - boolean canGrowTree = false; - - BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(position.getX(), position.getY(), position.getZ()); - - byte range; - int z; - - for (int y = position.getY(); y <= position.getY() + 1 + heightRange; ++y) - { - range = 1; - - if (y == position.getY()) - { - range = 0; - } - - if (y >= position.getY() + 1 + heightRange - 2) - { - range = 2; - } - - for (int x = position.getX() - range; x <= position.getX() + range; ++x) - { - for (z = position.getZ() - range; z <= position.getZ() + range; ++z) - { - if (y >= 0 && y < worldIn.getActualHeight()) - { - pos.setPos(x, y, z); - - IBlockState state = worldIn.getBlockState(pos); - Block block = state.getBlock(); - - if (block != NaturaOverworld.appleSapling || !block.isLeaves(state, worldIn, pos)) - { - canGrowTree = true; - } - } - else - { - canGrowTree = true; - } - } - } - } - - return canGrowTree; - } } diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/EucalyptusTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/EucalyptusTreeGenerator.java index 410f127b..0584bc0d 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/EucalyptusTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/EucalyptusTreeGenerator.java @@ -1,16 +1,14 @@ package com.progwml6.natura.world.worldgen.trees.overworld; import java.util.Random; - +import com.progwml6.natura.overworld.NaturaOverworld; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import com.progwml6.natura.overworld.NaturaOverworld; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class EucalyptusTreeGenerator extends BaseTreeGenerator { public final int minTreeHeight; @@ -77,7 +75,7 @@ public void generateTree(Random random, World world, BlockPos pos) { IBlockState iblockstate = world.getBlockState(mutableBlockPos.setPos(l, j, i1)); - if (!iblockstate.getBlock().isAir(iblockstate, world, mutableBlockPos.setPos(l, j, i1)) && !iblockstate.getBlock().isLeaves(iblockstate, world, mutableBlockPos.setPos(l, j, i1))) + if (!iblockstate.getBlock().isAir(iblockstate, world, mutableBlockPos.setPos(l, j, i1))) { flag = false; } @@ -173,7 +171,7 @@ protected void placeTrunk(World world, BlockPos pos, int height) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); - if (block.isAir(state, world, pos) || block.isReplaceable(world, pos) || block.isLeaves(state, world, pos)) + if (block.isAir(state, world, pos)) { this.setBlockAndMetadata(world, pos, this.log); } @@ -193,7 +191,7 @@ protected void setBlockAndMetadata(World world, BlockPos pos, IBlockState stateN } } - BlockPos findGround(World world, BlockPos pos) + protected BlockPos findGround(World world, BlockPos pos) { int returnHeight = 0; BlockPos posDown = pos.down(); diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/HopseedTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/HopseedTreeGenerator.java index 12bb3530..730da642 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/HopseedTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/HopseedTreeGenerator.java @@ -1,7 +1,8 @@ package com.progwml6.natura.world.worldgen.trees.overworld; import java.util.Random; - +import com.progwml6.natura.overworld.NaturaOverworld; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -10,9 +11,6 @@ import net.minecraft.util.math.BlockPos.MutableBlockPos; import net.minecraft.world.World; -import com.progwml6.natura.overworld.NaturaOverworld; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class HopseedTreeGenerator extends BaseTreeGenerator { public final int minTreeHeight; @@ -49,7 +47,7 @@ public void generateTree(Random random, World worldIn, BlockPos position) if (this.seekHeight) { - while (position.getY() > 1 && worldIn.isAirBlock(position) || worldIn.getBlockState(position).getBlock().isLeaves(worldIn.getBlockState(position), worldIn, position)) + while (position.getY() > 1 && worldIn.isAirBlock(position)) { position = position.down(); } @@ -134,7 +132,7 @@ public void generateTree(Random random, World worldIn, BlockPos position) IBlockState newState = worldIn.getBlockState(blockpos); - if (newState.getBlock() == Blocks.AIR || newState.getBlock().isLeaves(newState, worldIn, blockpos)) + if (newState.getBlock() == Blocks.AIR) { worldIn.setBlockState(blockpos, this.log, 0); } @@ -145,7 +143,7 @@ public void generateTree(Random random, World worldIn, BlockPos position) newState = worldIn.getBlockState(blockpos); - if (newState.getBlock() == Blocks.AIR || newState.getBlock().isLeaves(newState, worldIn, blockpos)) + if (newState.getBlock() == Blocks.AIR) { worldIn.setBlockState(blockpos, this.log, 0); } @@ -154,7 +152,7 @@ public void generateTree(Random random, World worldIn, BlockPos position) newState = worldIn.getBlockState(blockpos); - if (newState.getBlock() == Blocks.AIR || newState.getBlock().isLeaves(newState, worldIn, blockpos)) + if (newState.getBlock() == Blocks.AIR) { worldIn.setBlockState(blockpos, this.log, 0); } @@ -163,7 +161,7 @@ public void generateTree(Random random, World worldIn, BlockPos position) newState = worldIn.getBlockState(blockpos); - if (newState.getBlock() == Blocks.AIR || newState.getBlock().isLeaves(newState, worldIn, blockpos)) + if (newState.getBlock() == Blocks.AIR) { worldIn.setBlockState(blockpos, this.log, 0); } @@ -178,7 +176,7 @@ public boolean isReplaceable(World worldIn, BlockPos positionIn) { IBlockState state = worldIn.getBlockState(positionIn); - return state.getBlock().isAir(state, worldIn, positionIn) || state.getBlock().isLeaves(state, worldIn, positionIn) || state.getBlock().isWood(worldIn, positionIn); + return state.getBlock().isAir(state, worldIn, positionIn); } protected void growLeaves(World worldIn, Random random, BlockPos positionIn, int height) diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/OverworldTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/OverworldTreeGenerator.java index af9e802e..e648b546 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/OverworldTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/OverworldTreeGenerator.java @@ -1,7 +1,9 @@ package com.progwml6.natura.world.worldgen.trees.overworld; import java.util.Random; - +import com.progwml6.natura.common.config.Config; +import com.progwml6.natura.overworld.NaturaOverworld; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; @@ -9,10 +11,6 @@ import net.minecraft.world.World; import net.minecraft.world.WorldType; -import com.progwml6.natura.common.config.Config; -import com.progwml6.natura.overworld.NaturaOverworld; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class OverworldTreeGenerator extends BaseTreeGenerator { public final int minTreeHeight; @@ -115,14 +113,14 @@ protected void placeTrunk(World world, BlockPos pos, int height) IBlockState state = world.getBlockState(blockpos); Block block = state.getBlock(); - if (block.isAir(state, world, blockpos) || block.isLeaves(state, world, blockpos) || block.isReplaceable(world, blockpos)) + if (block.isAir(state, world, blockpos)) { world.setBlockState(blockpos, this.log, 2); } } } - BlockPos findGround(World world, BlockPos pos) + protected BlockPos findGround(World world, BlockPos pos) { int returnHeight = 0; @@ -168,14 +166,10 @@ BlockPos findGround(World world, BlockPos pos) return new BlockPos(pos.getX(), returnHeight, pos.getZ()); } - private boolean checkIfCanGrow(BlockPos position, int heightRange, World worldIn) + protected boolean checkIfCanGrow(BlockPos position, int heightRange, World world) { - boolean canGrowTree = false; - - BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(position.getX(), position.getY(), position.getZ()); - - byte range; - int z; + boolean canGrowTree = true; + int range; for (int y = position.getY(); y <= position.getY() + 1 + heightRange; ++y) { @@ -191,26 +185,13 @@ private boolean checkIfCanGrow(BlockPos position, int heightRange, World worldIn range = 2; } - for (int x = position.getX() - range; x <= position.getX() + range; ++x) + BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); + + for (int x = position.getX() - range; x <= position.getX() + range && canGrowTree; ++x) { - for (z = position.getZ() - range; z <= position.getZ() + range; ++z) + for (int z = position.getZ() - range; z <= position.getZ() + range && canGrowTree; ++z) { - if (y >= 0 && y < worldIn.getActualHeight()) - { - pos.setPos(x, y, z); - - IBlockState state = worldIn.getBlockState(pos); - Block block = state.getBlock(); - - if (block != NaturaOverworld.overworldSapling || !block.isLeaves(state, worldIn, pos)) - { - canGrowTree = true; - } - } - else - { - canGrowTree = true; - } + canGrowTree = world.isAirBlock(blockPos.setPos(x, y, z)); } } } diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/RedwoodTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/RedwoodTreeGenerator.java index 8f0b1ae2..6c7e3504 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/RedwoodTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/RedwoodTreeGenerator.java @@ -2,8 +2,10 @@ import java.util.List; import java.util.Random; - import com.google.common.collect.Lists; +import com.progwml6.natura.common.config.Config; +import com.progwml6.natura.overworld.NaturaOverworld; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -14,10 +16,6 @@ import net.minecraft.world.World; import net.minecraft.world.WorldType; -import com.progwml6.natura.common.config.Config; -import com.progwml6.natura.overworld.NaturaOverworld; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class RedwoodTreeGenerator extends BaseTreeGenerator { public final IBlockState bark; @@ -1945,6 +1943,56 @@ protected boolean canGrowInto(Block blockType) return material == Material.AIR || material == Material.LEAVES || blockType == Blocks.GRASS || blockType == Blocks.DIRT || blockType == Blocks.LOG || blockType == Blocks.LOG2 || blockType == Blocks.SAPLING || blockType == Blocks.VINE; } + protected BlockPos findGround(World world, BlockPos pos) + { + if (world.getWorldType() == WorldType.FLAT && this.isSapling) + { + boolean foundGround = false; + + int height = Config.flatSeaLevel + 64; + + do + { + height--; + + BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); + IBlockState underState = world.getBlockState(position); + Block underBlock = underState.getBlock(); + boolean isSoil = underBlock.canSustainPlant(underState, world, position, EnumFacing.UP, NaturaOverworld.redwoodSapling); + + if (isSoil || height < Config.flatSeaLevel) + { + foundGround = true; + } + } while (!foundGround); + + return new BlockPos(pos.getX(), height, pos.getZ()); + } + else + { + boolean foundGround = false; + + int height = Config.seaLevel + 64; + + do + { + height--; + + BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); + IBlockState underState = world.getBlockState(position); + Block underBlock = underState.getBlock(); + boolean isSoil = underBlock.canSustainPlant(underState, world, position, EnumFacing.UP, NaturaOverworld.redwoodSapling); + + if (isSoil || height < Config.seaLevel) + { + foundGround = true; + } + } while (!foundGround); + + return new BlockPos(pos.getX(), height, pos.getZ()); + } + } + /** * Generates a list of leaf nodes for the tree, to be populated by generateLeaves. */ @@ -2002,7 +2050,7 @@ void generateLeafNodeList() } } - void crosSection(BlockPos pos, float size, IBlockState state) + void crossSection(BlockPos pos, float size, IBlockState state) { int i = (int) (size + 0.618D); @@ -2064,7 +2112,7 @@ void generateLeafNode(BlockPos pos) { for (int i = 0; i < this.leafDistanceLimit; ++i) { - this.crosSection(pos.up(i), this.leafSize(i), this.leaves); + this.crossSection(pos.up(i), this.leafSize(i), this.leaves); } } @@ -2146,56 +2194,6 @@ int checkBlockLine(BlockPos posOne, BlockPos posTwo) return -1; } - BlockPos findGround(World world, BlockPos pos) - { - if (world.getWorldType() == WorldType.FLAT && this.isSapling) - { - boolean foundGround = false; - - int height = Config.flatSeaLevel + 64; - - do - { - height--; - - BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); - IBlockState underState = world.getBlockState(position); - Block underBlock = underState.getBlock(); - boolean isSoil = underBlock.canSustainPlant(underState, world, position, EnumFacing.UP, NaturaOverworld.redwoodSapling); - - if (isSoil || height < Config.flatSeaLevel) - { - foundGround = true; - } - } while (!foundGround); - - return new BlockPos(pos.getX(), height, pos.getZ()); - } - else - { - boolean foundGround = false; - - int height = Config.seaLevel + 64; - - do - { - height--; - - BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); - IBlockState underState = world.getBlockState(position); - Block underBlock = underState.getBlock(); - boolean isSoil = underBlock.canSustainPlant(underState, world, position, EnumFacing.UP, NaturaOverworld.redwoodSapling); - - if (isSoil || height < Config.seaLevel) - { - foundGround = true; - } - } while (!foundGround); - - return new BlockPos(pos.getX(), height, pos.getZ()); - } - } - /** * Returns the absolute greatest distance in the BlockPos object. */ diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/SakuraTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/SakuraTreeGenerator.java index 130cf6dd..b876d05a 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/SakuraTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/SakuraTreeGenerator.java @@ -2,8 +2,11 @@ import java.util.List; import java.util.Random; - import com.google.common.collect.Lists; +import com.progwml6.natura.common.block.BlockEnumLog; +import com.progwml6.natura.common.config.Config; +import com.progwml6.natura.overworld.NaturaOverworld; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; @@ -12,11 +15,6 @@ import net.minecraft.world.World; import net.minecraft.world.WorldType; -import com.progwml6.natura.common.block.BlockEnumLog; -import com.progwml6.natura.common.config.Config; -import com.progwml6.natura.overworld.NaturaOverworld; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class SakuraTreeGenerator extends BaseTreeGenerator { public final IBlockState log; @@ -50,8 +48,8 @@ public SakuraTreeGenerator(IBlockState log, IBlockState leaves, boolean findGrou public boolean isReplaceable(World world, BlockPos pos) { - net.minecraft.block.state.IBlockState state = world.getBlockState(pos); - return state.getBlock().isAir(state, world, pos) || state.getBlock().isLeaves(state, world, pos); + IBlockState state = world.getBlockState(pos); + return state.getBlock().isAir(state, world, pos); } @Override @@ -96,6 +94,54 @@ protected void setBlockAndMetadata(World world, BlockPos pos, IBlockState stateN } } + protected BlockPos findGround(World world, BlockPos pos) + { + if (world.getWorldType() == WorldType.FLAT && this.isSapling) + { + boolean foundGround = false; + + int height = Config.flatSeaLevel + 64; + + do + { + height--; + BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); + IBlockState underBlockState = world.getBlockState(position); + Block underBlock = underBlockState.getBlock(); + boolean isSoil = underBlock.canSustainPlant(underBlockState, world, position, EnumFacing.UP, NaturaOverworld.overworldSapling); + + if (isSoil || height < Config.flatSeaLevel) + { + foundGround = true; + } + } while (!foundGround); + + return new BlockPos(pos.getX(), height + 1, pos.getZ()); + } + else + { + boolean foundGround = false; + + int height = Config.seaLevel + 64; + + do + { + height--; + BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); + IBlockState underState = world.getBlockState(position); + Block underBlock = underState.getBlock(); + boolean isSoil = underBlock.canSustainPlant(underState, world, position, EnumFacing.UP, NaturaOverworld.overworldSapling); + + if (isSoil || height < Config.seaLevel) + { + foundGround = true; + } + } while (!foundGround); + + return new BlockPos(pos.getX(), height + 1, pos.getZ()); + } + } + /** * Generates a list of leaf nodes for the tree, to be populated by generateLeaves. */ @@ -153,7 +199,7 @@ void generateLeafNodeList() } } - void crosSection(BlockPos pos, float p_181631_2_, IBlockState p_181631_3_) + void crossSection(BlockPos pos, float p_181631_2_, IBlockState p_181631_3_) { int i = (int) (p_181631_2_ + 0.618D); @@ -215,7 +261,7 @@ void generateLeafNode(BlockPos pos) { for (int i = 0; i < this.leafDistanceLimit; ++i) { - this.crosSection(pos.up(i), this.leafSize(i), this.leaves); + this.crossSection(pos.up(i), this.leafSize(i), this.leaves); } } @@ -317,54 +363,6 @@ int checkBlockLine(BlockPos posOne, BlockPos posTwo) return -1; } - BlockPos findGround(World world, BlockPos pos) - { - if (world.getWorldType() == WorldType.FLAT && this.isSapling) - { - boolean foundGround = false; - - int height = Config.flatSeaLevel + 64; - - do - { - height--; - BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); - IBlockState underBlockState = world.getBlockState(position); - Block underBlock = underBlockState.getBlock(); - boolean isSoil = underBlock.canSustainPlant(underBlockState, world, position, EnumFacing.UP, NaturaOverworld.overworldSapling); - - if (isSoil || height < Config.flatSeaLevel) - { - foundGround = true; - } - } while (!foundGround); - - return new BlockPos(pos.getX(), height + 1, pos.getZ()); - } - else - { - boolean foundGround = false; - - int height = Config.seaLevel + 64; - - do - { - height--; - BlockPos position = new BlockPos(pos.getX(), height, pos.getZ()); - IBlockState underState = world.getBlockState(position); - Block underBlock = underState.getBlock(); - boolean isSoil = underBlock.canSustainPlant(underState, world, position, EnumFacing.UP, NaturaOverworld.overworldSapling); - - if (isSoil || height < Config.seaLevel) - { - foundGround = true; - } - } while (!foundGround); - - return new BlockPos(pos.getX(), height + 1, pos.getZ()); - } - } - /** * Returns the absolute greatest distance in the BlockPos object. */ diff --git a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/WillowTreeGenerator.java b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/WillowTreeGenerator.java index 7a79005c..56d445fe 100644 --- a/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/WillowTreeGenerator.java +++ b/src/main/java/com/progwml6/natura/world/worldgen/trees/overworld/WillowTreeGenerator.java @@ -1,7 +1,9 @@ package com.progwml6.natura.world.worldgen.trees.overworld; import java.util.Random; - +import com.progwml6.natura.common.config.Config; +import com.progwml6.natura.overworld.NaturaOverworld; +import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -11,10 +13,6 @@ import net.minecraft.world.World; import net.minecraft.world.WorldType; -import com.progwml6.natura.common.config.Config; -import com.progwml6.natura.overworld.NaturaOverworld; -import com.progwml6.natura.world.worldgen.trees.BaseTreeGenerator; - public class WillowTreeGenerator extends BaseTreeGenerator { public final int minTreeHeight; @@ -90,7 +88,7 @@ public void generateTree(Random random, World worldIn, BlockPos position) IBlockState iblockstate = worldIn.getBlockState(mutableBlockPos.setPos(l, j, i1)); Block block = iblockstate.getBlock(); - if (!iblockstate.getBlock().isAir(iblockstate, worldIn, mutableBlockPos.setPos(l, j, i1)) && !iblockstate.getBlock().isLeaves(iblockstate, worldIn, mutableBlockPos.setPos(l, j, i1))) + if (!iblockstate.getBlock().isAir(iblockstate, worldIn, mutableBlockPos.setPos(l, j, i1))) { if (block != Blocks.WATER && block != Blocks.FLOWING_WATER) { @@ -216,7 +214,7 @@ protected void setBlockAndMetadata(World world, BlockPos pos, IBlockState stateN } } - BlockPos findGround(World world, BlockPos pos) + protected BlockPos findGround(World world, BlockPos pos) { int returnHeight = 0;