diff --git a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java index e103a1dca..4476f6ab1 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java @@ -64,7 +64,6 @@ import forestry.arboriculture.worldgen.WorldGenJungle; import forestry.arboriculture.worldgen.WorldGenKapok; import forestry.arboriculture.worldgen.WorldGenLarch; import forestry.arboriculture.worldgen.WorldGenLemon; -import forestry.arboriculture.worldgen.WorldGenLime; import forestry.arboriculture.worldgen.WorldGenMahoe; import forestry.arboriculture.worldgen.WorldGenMahogany; import forestry.arboriculture.worldgen.WorldGenMaple; @@ -75,6 +74,7 @@ import forestry.arboriculture.worldgen.WorldGenPine; import forestry.arboriculture.worldgen.WorldGenPlum; import forestry.arboriculture.worldgen.WorldGenPoplar; import forestry.arboriculture.worldgen.WorldGenSequoia; +import forestry.arboriculture.worldgen.WorldGenSilverLime; import forestry.arboriculture.worldgen.WorldGenSpruce; import forestry.arboriculture.worldgen.WorldGenTeak; import forestry.arboriculture.worldgen.WorldGenWalnut; @@ -159,7 +159,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { Lime(TreeBranchDefinition.TILIA, "silverLime", "pendula", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0x5ea107).brighter(), EnumWoodType.LIME) { @Override public WorldGenerator getWorldGenerator(ITreeGenData tree) { - return new WorldGenLime(tree); + return new WorldGenSilverLime(tree); } @Override @@ -995,6 +995,17 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator { if (woodType == null) { Block vanillaWoodBlock = Block.getBlockFromItem(vanillaWood.getItem()); int vanillaWoodMeta = vanillaWood.getItemDamage(); + switch (facing) { + case NORTH: + case SOUTH: + vanillaWoodMeta |= 2 << 2; + break; + case EAST: + case WEST: + vanillaWoodMeta |= 1 << 2; + break; + } + world.setBlock(x, y, z, vanillaWoodBlock, vanillaWoodMeta, Constants.FLAG_BLOCK_SYNCH); } else { AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java index 9bf75104b..33807e323 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenAcacia.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -22,26 +26,38 @@ public class WorldGenAcacia extends WorldGenTree { @Override public void generate(World world) { - generateTreeTrunk(world, height, girth); + Direction leanDirection = Direction.getRandom(world.rand); + float leanAmount = height / 4.0f; - int leafSpawn = height + 1; - - float rnd = world.rand.nextFloat(); - int offset = 0; - if (rnd > 0.6f) { - offset = world.rand.nextInt(girth); - } else if (rnd > 0.3) { - offset = -world.rand.nextInt(girth); + List treeTops = generateTreeTrunk(world, height, girth, 0, leanDirection.forgeDirection, leanAmount); + if (height > 5 && world.rand.nextBoolean()) { + Direction branchDirection = Direction.getRandomOther(world.rand, leanDirection); + List treeTops2 = generateTreeTrunk(world, Math.round(height * 0.66f), girth, 0, branchDirection.forgeDirection, leanAmount); + treeTops.addAll(treeTops2); } + List branchLocations = new ArrayList<>(); - generateAdjustedCylinder(world, leafSpawn--, offset, 0, 1, leaf, EnumReplaceMode.NONE); - generateAdjustedCylinder(world, leafSpawn--, offset, 1.5f, 1, leaf, EnumReplaceMode.NONE); + for (ChunkCoordinates treeTop : treeTops) { + int xOffset = treeTop.posX; + int yOffset = treeTop.posY + 1; + int zOffset = treeTop.posZ; + float canopyMultiplier = (1.5f * height - yOffset + 2) / 4.0f; + int canopyThickness = Math.max(1, Math.round(yOffset / 10.0f)); - if (world.rand.nextBoolean()) { - generateAdjustedCylinder(world, leafSpawn--, offset, 3.9f, 1, leaf, EnumReplaceMode.NONE); - } else { - generateAdjustedCylinder(world, leafSpawn--, offset, 2.9f, 1, leaf, EnumReplaceMode.NONE); + generateAdjustedCylinder(world, yOffset--, xOffset, zOffset, canopyMultiplier, 1, leaf, EnumReplaceMode.NONE); + + float canopyWidth = world.rand.nextBoolean() ? 3.0f : 2.5f; + List branches = generateBranches(world, yOffset - canopyThickness, xOffset, zOffset, 0.0f, 0.1f, Math.round(canopyMultiplier * canopyWidth - 4), 2); + branchLocations.addAll(branches); + } + + for (ChunkCoordinates branchLocation : branchLocations) { + int leafSpawn = branchLocation.posY; + int canopyThickness = Math.max(1, Math.round(leafSpawn / 10.0f)); + float canopyMultiplier = (1.5f * height - leafSpawn + 2) / 4.0f; + float canopyWidth = world.rand.nextBoolean() ? 1.0f : 1.5f; + generateAdjustedCylinder(world, leafSpawn - canopyThickness + 1, branchLocation.posX, branchLocation.posZ, canopyMultiplier * canopyWidth, canopyThickness, leaf, EnumReplaceMode.NONE); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java index 02dedb4f3..2125ce16b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenArboriculture.java @@ -10,11 +10,19 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.Random; + import net.minecraft.init.Blocks; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import com.mojang.authlib.GameProfile; +import net.minecraftforge.common.util.ForgeDirection; + import forestry.api.world.ITreeGenData; import forestry.arboriculture.tiles.TileTreeContainer; import forestry.core.tiles.TileUtil; @@ -25,6 +33,30 @@ import forestry.core.worldgen.WorldGenBase; public abstract class WorldGenArboriculture extends WorldGenBase { + enum Direction { + NORTH(ForgeDirection.NORTH), + SOUTH(ForgeDirection.SOUTH), + WEST(ForgeDirection.WEST), + EAST(ForgeDirection.EAST); + + public final ForgeDirection forgeDirection; + + Direction(ForgeDirection forgeDirection) { + this.forgeDirection = forgeDirection; + } + + public static Direction getRandom(Random random) { + return values()[random.nextInt(values().length)]; + } + + public static Direction getRandomOther(Random random, Direction direction) { + EnumSet directions = EnumSet.allOf(Direction.class); + directions.remove(direction); + int size = directions.size(); + return directions.toArray(new Direction[size])[random.nextInt(size)]; + } + } + private static final ITreeBlockType vineNorth = new TreeBlockType(Blocks.vine, 1); private static final ITreeBlockType vineSouth = new TreeBlockType(Blocks.vine, 4); private static final ITreeBlockType vineWest = new TreeBlockType(Blocks.vine, 8); @@ -84,27 +116,64 @@ public abstract class WorldGenArboriculture extends WorldGenBase { protected abstract ITreeBlockType getWood(); - protected void generateTreeTrunk(World world, int height, int girth) { - generateTreeTrunk(world, height, girth, 0); + protected List generateTreeTrunk(World world, int height, int girth) { + return generateTreeTrunk(world, height, girth, 0); } - protected void generateTreeTrunk(World world, int height, int girth, float vines) { + protected List generateTreeTrunk(World world, int height, int girth, float vinesChance) { + return generateTreeTrunk(world, height, girth, vinesChance, ForgeDirection.UNKNOWN, 0); + } + + protected List generateTreeTrunk(World world, int height, int girth, float vinesChance, ForgeDirection leanDirection, float leanAmount) { + return generateTreeTrunk(world, height, girth, 0, vinesChance, leanDirection, leanAmount); + } + + /** Returns a list of trunk top coordinates */ + protected List generateTreeTrunk(World world, int height, int girth, int yStart, float vinesChance, ForgeDirection leanDirection, float leanAmount) { + List treeTops = new ArrayList<>(); + + final int leanStartY = (int) Math.floor(height * 0.33f); + int prevXOffset = 0; + int prevZOffset = 0; + int offset = (girth - 1) / 2; for (int x = 0; x < girth; x++) { for (int z = 0; z < girth; z++) { - for (int y = 0; y < height; y++) { - addWood(world, x - offset, y, z - offset, EnumReplaceMode.ALL); - addVines(world, x - offset, y, z - offset, vines); + for (int y = yStart; y < height; y++) { + float lean; + if (y < leanStartY) { + lean = 0; + } else { + lean = leanAmount * (y - leanStartY) / (height - leanStartY); + } + int xOffset = (int) Math.floor(leanDirection.offsetX * lean - offset); + int zOffset = (int) Math.floor(leanDirection.offsetZ * lean - offset); + + if (xOffset != prevXOffset || zOffset != prevZOffset) { + prevXOffset = xOffset; + prevZOffset = zOffset; + if (y > 0) { + wood.setDirection(leanDirection); + addWood(world, x + xOffset, y - 1, z + zOffset, EnumReplaceMode.ALL); + wood.setDirection(ForgeDirection.UP); + } + } + + addWood(world, x + xOffset, y, z + zOffset, EnumReplaceMode.ALL); + addVines(world, x + xOffset, y, z + zOffset, vinesChance); + + if (y + 1 == height) { + treeTops.add(new ChunkCoordinates(x + xOffset, y, z + zOffset)); + } } } } - if (!spawnPods) { - return; + if (spawnPods) { + generatePods(world, height, girth); } - generatePods(world, height, girth); - + return treeTops; } protected void generatePods(World world, int height, int girth) { @@ -116,32 +185,45 @@ public abstract class WorldGenArboriculture extends WorldGenBase { continue; } - tree.trySpawnFruitBlock(world, startX + x + 1, startY + y, startZ + z); - tree.trySpawnFruitBlock(world, startX + x - 1, startY + y, startZ + z); - tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z + 1); - tree.trySpawnFruitBlock(world, startX + x, startY + y, startZ + z - 1); + trySpawnFruitBlock(world, x + 1, y, z); + trySpawnFruitBlock(world, x - 1, y, z); + trySpawnFruitBlock(world, x, y, z + 1); + trySpawnFruitBlock(world, x, y, z - 1); } } } } + private void trySpawnFruitBlock(World world, int x, int y, int z) { + x += startX; + y += startY; + z += startZ; + if (BlockUtil.isReplaceableBlock(world, x, y, z) || world.isAirBlock(x, y, z)) { + tree.trySpawnFruitBlock(world, x, y, z); + } + } + protected void generateSupportStems(World world, int height, int girth, float chance, float maxHeight) { - int offset = 1; + int offset = (int) Math.ceil(girth / 2.0f); + int max = (int) Math.floor(girth / 2.0f) + offset; + if (girth % 2 == 0) { + max++; + } - for (int x = -offset; x < girth + offset; x++) { - for (int z = -offset; z < girth + offset; z++) { + for (int x = -offset; x < max; x++) { + for (int z = -offset; z < max; z++) { if (x == -offset && z == -offset) { continue; } - if (x == girth + offset && z == girth + offset) { + if (x == max && z == max) { continue; } - if (x == -offset && z == girth + offset) { + if (x == -offset && z == max) { continue; } - if (x == girth + offset && z == -offset) { + if (x == max && z == -offset) { continue; } @@ -153,7 +235,63 @@ public abstract class WorldGenArboriculture extends WorldGenBase { } } } + } + protected List generateBranches(World world, final int startY, int xOffset, int zOffset, float spreadY, float spreadXZ, int radius, int count) { + return generateBranches(world, startY, xOffset, zOffset, spreadY, spreadXZ, radius, count, 1.0f); + } + + protected List generateBranches(World world, final int startY, final int xOffset, final int zOffset, final float spreadY, final float spreadXZ, int radius, final int count, final float chance) { + List branchEnds = new ArrayList<>(); + if (radius < 1) { + radius = 1; + } + + for (Direction cardinalDirection : Direction.values()) { + ForgeDirection branchDirection = cardinalDirection.forgeDirection; + wood.setDirection(branchDirection); + for (int i = 0; i < count; i++) { + if (world.rand.nextFloat() > chance) { + continue; + } + int y = startY; + int x = xOffset; + int z = zOffset; + + for (int r = 0; r < radius; r++) { + if (world.rand.nextFloat() < spreadY) { + // make branches only spread up, not down + y++; + } else { + if (world.rand.nextFloat() < spreadXZ) { + if (branchDirection.offsetX == 0) { + if (world.rand.nextBoolean()) { + x++; + } else { + x--; + } + wood.setDirection(ForgeDirection.EAST); + } else if (branchDirection.offsetZ == 0) { + if (world.rand.nextBoolean()) { + z++; + } else { + z--; + } + wood.setDirection(ForgeDirection.SOUTH); + } + } else { + x += branchDirection.offsetX; + z += branchDirection.offsetZ; + wood.setDirection(branchDirection); + } + } + addWood(world, x, y, z, EnumReplaceMode.SOFT); + branchEnds.add(new ChunkCoordinates(x, y, z)); + } + } + } + + return branchEnds; } @Override diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java index 78c63f47b..e3ab7398b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java @@ -25,18 +25,19 @@ public class WorldGenBalsa extends WorldGenTree { generateTreeTrunk(world, height, girth); int leafSpawn = height; + float leafRadius = (girth - 1.0f) / 2.0f; addLeaf(world, 0, leafSpawn--, 0, EnumReplaceMode.NONE); - generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, leafRadius, 1, leaf); if (height > 10) { - generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, leafRadius, 1, leaf); } leafSpawn--; while (leafSpawn > 6) { - generateAdjustedCylinder(world, leafSpawn, 0, 1, leaf); + generateAdjustedCylinder(world, leafSpawn, leafRadius, 1, leaf); leafSpawn--; } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java index ced50a4ed..142e9ef87 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBaobab.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -24,10 +27,15 @@ public class WorldGenBaobab extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height - 1, girth); + List branchCoords = generateBranches(world, height, 0, 0, 0, 0.5f, 4, 6); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 0.0f, 2, leaf, EnumReplaceMode.NONE); + } + if (world.rand.nextFloat() < 0.3f) { - generateCylinder(world, new Vector(0, height - 1, 0), girth, 1, wood, EnumReplaceMode.NONE); + generateCylinder(world, new Vector(0, height - 1, 0), girth, 1, wood, EnumReplaceMode.SOFT); } else if (world.rand.nextBoolean()) { - generateCylinder(world, new Vector(0, height - 1, 0), girth - 1, 1, wood, EnumReplaceMode.NONE); + generateCylinder(world, new Vector(0, height - 1, 0), girth - 1, 1, wood, EnumReplaceMode.SOFT); } int leafSpawn = height + 1; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java index 848dd8e9a..c6a37e3dd 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCherry.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -25,12 +28,18 @@ public class WorldGenCherry extends WorldGenTree { generateTreeTrunk(world, height, girth); int leafSpawn = height + 1; - generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + + int branchWidth = height / 2; while (leafSpawn > 2) { - generateAdjustedCylinder(world, leafSpawn--, 2, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + int leafRadius = Math.min(4, branchWidth); + List branchCoords = generateBranches(world, leafSpawn, 0, 0, 0.2f, 0.5f, branchWidth, 1); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCircle(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, leafRadius, 3, 2, leaf, 1.0f, EnumReplaceMode.NONE); + } + leafSpawn -= 2; + branchWidth++; } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java index acd250bc0..30be01810 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenChestnut.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -35,7 +38,15 @@ public class WorldGenChestnut extends WorldGenTree { if (world.rand.nextBoolean()) { generateAdjustedCylinder(world, leafSpawn--, 2f, 1, leaf); } - generateAdjustedCylinder(world, leafSpawn--, 1.5f, 1, leaf); + + int branchRadius = height / 2; + + List branchCoords = generateBranches(world, leafSpawn, 0, 0, 0.5f, 0.5f, branchRadius, 2); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 1.0f, 2, leaf, EnumReplaceMode.NONE); + } + + generateAdjustedCylinder(world, leafSpawn, 1.5f, 1, leaf); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java index d9ba5dfa1..4665f3c54 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenCocobolo.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -22,11 +25,14 @@ public class WorldGenCocobolo extends WorldGenTree { @Override public void generate(World world) { - generateTreeTrunk(world, height, girth); + List treeTops = generateTreeTrunk(world, height, girth); int leafSpawn = height; - addLeaf(world, 0, leafSpawn--, 0, EnumReplaceMode.NONE); + for (ChunkCoordinates treeTop : treeTops) { + addLeaf(world, treeTop.posX, treeTop.posY + 1, treeTop.posZ, EnumReplaceMode.NONE); + } + leafSpawn--; generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); if (height > 10) { @@ -42,12 +48,12 @@ public class WorldGenCocobolo extends WorldGenTree { if (world.rand.nextBoolean()) { offset = -1; } - generateAdjustedCylinder(world, leafSpawn, offset, 2, 1, leaf, EnumReplaceMode.NONE); + generateAdjustedCylinder(world, leafSpawn, offset, offset, 2, 1, leaf, EnumReplaceMode.NONE); } else { if (world.rand.nextBoolean()) { offset = -1; } - generateAdjustedCylinder(world, leafSpawn, offset, 0, 1, leaf, EnumReplaceMode.NONE); + generateAdjustedCylinder(world, leafSpawn, offset, offset, 0, 1, leaf, EnumReplaceMode.NONE); } leafSpawn--; } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java deleted file mode 100644 index fb7a4d28d..000000000 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenCrescentia.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.arboriculture.worldgen; - -import net.minecraft.world.World; - -import forestry.api.world.ITreeGenData; - -public class WorldGenCrescentia extends WorldGenTree { - - public WorldGenCrescentia(ITreeGenData tree) { - super(tree, 6, 3); - } - - @Override - public void generate(World world) { - generateTreeTrunk(world, height, girth); - - int leafSpawn = height + 1; - - generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 0.5f, 1, leaf); - - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); - if (world.rand.nextBoolean()) { - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); - } - - generateAdjustedCylinder(world, leafSpawn--, 0.5f, 1, leaf); - - } - - @Override - protected void generateTreeTrunk(World world, int height, int girth) { - - int offset = (girth - 1) / 2; - - //Trunk generation - for (int x = 0; x < girth; x++) //offsets trunk in x direction - { - for (int z = 0; z < girth; z++) //offsets trunk in z direction - { - if (x == 0 || x == girth - 1) { //checks for edges in x direction - if (z == 0 || z == girth - 1) {//checks for corners - if (x == 0 && z == 0) { - }//xz corner - if (x == girth - 1 && z == 0) { - }//x-1z corner - if (x == 0 && z == girth - 1) { - }//xz-1 corner - if (x == girth - 1 && z == 0) { - } //x-1z-1 corner - } else { //these are the z only edges - if (x == 0) { - - } else if (x == girth - 1) { - - } - } - } else if (z == 0 || z == girth - 1) { //these are the x only edges - if (z == 0) { - - } else if (z == girth - 1) { - - } - } else { //these are center pieces - for (int i = 0; i < height; i++) { //grows trunk straight up in y direction to the correct height - addWood(world, x - offset, i, z - offset, EnumReplaceMode.ALL); - } - } - } - } - - //End trunk generation - - //Spawn pods - generatePods(world, height, girth); - } - -} diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java index 7d602654b..a9f9eec9f 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java @@ -26,9 +26,11 @@ public class WorldGenDate extends WorldGenTree { int leafSpawn = height + 1; - generateAdjustedCylinder(world, leafSpawn--, 2f, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 0.5f, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); + float radiusMultiplier = height / 6f; + + generateAdjustedCylinder(world, leafSpawn--, radiusMultiplier * 2f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, radiusMultiplier * 0.5f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn, 0, 1, leaf); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java index e7c0daf90..395e8eebb 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenGreenheart.java @@ -24,7 +24,7 @@ public class WorldGenGreenheart extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height, girth, 0.4f); - generateSupportStems(world, height, girth, 0.1f, 0.2f); + generateSupportStems(world, height, girth, 0.5f, 0.2f); int leafSpawn = height + 1; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java index f1513f6f8..07154b319 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenIpe.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -17,7 +21,7 @@ import forestry.api.world.ITreeGenData; public class WorldGenIpe extends WorldGenTree { public WorldGenIpe(ITreeGenData tree) { - super(tree, 8, 8); + super(tree, 6, 4); } @Override @@ -30,22 +34,17 @@ public class WorldGenIpe extends WorldGenTree { generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 0.2f * adjustedGirth, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 0.2f * adjustedGirth, 1, leaf); - - while (leafSpawn > 7) { - generateAdjustedCylinder(world, leafSpawn, (float) (1.25f * (adjustedGirth * .65)), 1, leaf); - leafSpawn--; - } - - generateAdjustedCylinder(world, leafSpawn--, 1.6f * adjustedGirth, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1.6f * adjustedGirth, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1.6f * adjustedGirth, 1, leaf); - - if (world.rand.nextBoolean()) { - generateAdjustedCylinder(world, leafSpawn--, 1.25f * adjustedGirth, 1, leaf); + + List branchCoords = new ArrayList<>(); + while (leafSpawn > 2) { + int radius = Math.round(adjustedGirth * (height - leafSpawn) / 1.5f); + branchCoords.addAll(generateBranches(world, leafSpawn, 0, 0, 0.25f, 0.25f, radius, 2)); + leafSpawn -= 2; } - generateAdjustedCylinder(world, leafSpawn--, 1f * adjustedGirth, 1, leaf); - + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 2.0f, 2, leaf, EnumReplaceMode.NONE); + } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java index 1873fcfb5..e1339bcd8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenJungle.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -25,16 +29,35 @@ public class WorldGenJungle extends WorldGenTreeVanilla { @Override public void generate(World world) { + float vinesChance = 0.0f; + if (girth >= 2) { + height *= 1.5f; + vinesChance = 0.8f; + } - generateTreeTrunk(world, height, girth); + generateTreeTrunk(world, height, girth, vinesChance); + + if (height > 10) { + List branchCoords = new ArrayList<>(); + int branchSpawn = 6; + while (branchSpawn < height - 2) { + branchCoords.addAll(generateBranches(world, branchSpawn, 0, 0, 0.5f, 0f, 2, 1, 0.25f)); + branchSpawn += world.rand.nextInt(4); + } + + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 0f, 1, leaf, EnumReplaceMode.NONE); + } + } int leafSpawn = height + 1; + float canopyRadiusMultiplier = height / 7.0f; generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 0.5f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, 0.5f * canopyRadiusMultiplier, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, 1.9f * canopyRadiusMultiplier, 1, leaf); + generateAdjustedCylinder(world, leafSpawn, 1.9f * canopyRadiusMultiplier, 1, leaf); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java index 2c80f0e90..4955939c8 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenKapok.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -24,7 +28,7 @@ public class WorldGenKapok extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height, girth, 0.6f); - generateSupportStems(world, height, girth, 0.2f, 0.2f); + generateSupportStems(world, height, girth, 0.8f, 0.4f); int leafSpawn = height + 1; @@ -33,10 +37,16 @@ public class WorldGenKapok extends WorldGenTree { generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); + List branchCoords = new ArrayList<>(); while (leafSpawn > height - 4) { - generateAdjustedCylinder(world, leafSpawn--, 2.5f, 1, leaf); + int radius = Math.round(girth * (height - leafSpawn) / 1.5f) + 6; + branchCoords.addAll(generateBranches(world, leafSpawn, 0, 0, 0.3f, 0.25f, radius, 6)); + leafSpawn -= 2; + } + + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY + 1, branchEnd.posX, branchEnd.posZ, 2.0f, 2, leaf, EnumReplaceMode.NONE); } - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); // Add some smaller twigs below for flavour for (int times = 0; times < height / 4; times++) { diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java index fa53c4464..f43597d17 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java @@ -26,12 +26,14 @@ public class WorldGenLarch extends WorldGenTree { int leafSpawn = height + 1; + float sizeMultiplier = Math.max(height / 8, 1.0f); + generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, sizeMultiplier, 1, leaf); while (leafSpawn > 2) { - generateAdjustedCylinder(world, leafSpawn--, 2, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, 2 * sizeMultiplier, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, sizeMultiplier, 1, leaf); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java index d5092ae6a..a06945d7f 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java @@ -26,8 +26,11 @@ public class WorldGenLemon extends WorldGenTree { int yCenter = height - girth; yCenter = yCenter > 2 ? yCenter : 3; - generateSphere(world, getCenteredAt(yCenter, 0), 2 + world.rand.nextInt(girth), leaf, EnumReplaceMode.NONE); - + int radius = Math.round((2 + world.rand.nextInt(girth)) * (height / 4.0f)); + if (radius > 4) { + radius = 4; + } + generateSphere(world, getCenteredAt(yCenter, 0, 0), radius, leaf, EnumReplaceMode.NONE); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java index 1cc8c7c87..4c63b5848 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahoe.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -24,9 +28,17 @@ public class WorldGenMahoe extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height, girth); + List branchCoords = new ArrayList<>(); + for (int yBranch = 2; yBranch < height - 1; yBranch++) { + branchCoords.addAll(generateBranches(world, yBranch, 0, 0, 0.15f, 0.25f, Math.round((height - yBranch) * 0.75f), 1, 0.25f)); + } + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 2, 2, leaf, EnumReplaceMode.NONE); + } + int yCenter = height - girth; yCenter = yCenter > 3 ? yCenter : 4; - generateSphere(world, getCenteredAt(yCenter, 0), 3 + world.rand.nextInt(girth), leaf, EnumReplaceMode.NONE); + generateSphere(world, getCenteredAt(yCenter, 0, 0), 3 + world.rand.nextInt(girth), leaf, EnumReplaceMode.NONE); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java index 67be5dd34..1290be99b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMahogany.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -25,6 +29,14 @@ public class WorldGenMahogany extends WorldGenTree { generateTreeTrunk(world, height, girth, 0.6f); generateSupportStems(world, height, girth, 0.4f, 0.4f); + List branchCoords = new ArrayList<>(); + for (int yBranch = height - 4; yBranch < height - 2; yBranch++) { + branchCoords.addAll(generateBranches(world, yBranch, 0, 0, 0.15f, 0.25f, Math.round((height - yBranch) * 0.5f), 1, 0.25f)); + } + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 2, 2, leaf, EnumReplaceMode.NONE); + } + int leafSpawn = height + 1; generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java index 4c5a5f24a..696678250 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenMaple.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -24,6 +28,14 @@ public class WorldGenMaple extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height, girth); + List branchCoords = new ArrayList<>(); + for (int yBranch = 2; yBranch < height - 2; yBranch++) { + branchCoords.addAll(generateBranches(world, yBranch, 0, 0, 0.15f, 0.25f, Math.round((height - yBranch) * 0.25f), 1, 0.25f)); + } + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 2, 2, leaf, EnumReplaceMode.NONE); + } + int leafSpawn = height + 1; float diameterchange = (float) 1 / height; int leafSpawned = 2; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java index da474a830..e6e6e2158 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPapaya.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -23,11 +26,15 @@ public class WorldGenPapaya extends WorldGenTree { @Override public void generate(World world) { generateTreeTrunk(world, height, girth); - + + List branchCoords = generateBranches(world, height, 0, 0, 0.15f, 0.25f, height / 4, 1, 0.25f); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 1, 1, leaf, EnumReplaceMode.NONE); + } + int yCenter = height - girth; yCenter = yCenter > 3 ? yCenter : 4; - generateSphere(world, getCenteredAt(yCenter, 0), 2 + world.rand.nextInt(girth), leaf, EnumReplaceMode.NONE); - + generateSphere(world, getCenteredAt(yCenter, 0, 0), Math.round((2 + world.rand.nextInt(girth)) * (height / 8.0f)), leaf, EnumReplaceMode.NONE); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java index 23d9efd65..e6bd7608b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPine.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -24,8 +28,16 @@ public class WorldGenPine extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height, girth); + List branchCoords = new ArrayList<>(); + for (int yBranch = 2; yBranch < height - 2; yBranch++) { + branchCoords.addAll(generateBranches(world, yBranch, 0, 0, 0.05f, 0.1f, Math.round((height - yBranch) * 0.25f), 1, 0.25f)); + } + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 2, 1, leaf, EnumReplaceMode.NONE); + } + int leafSpawn = height + 1; - float diameterchange = (float) 1 / height; + float diameterchange = 1.25f / height; int leafSpawned = 2; generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java index 5839b72f1..f67669e10 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java @@ -27,8 +27,11 @@ public class WorldGenPlum extends WorldGenTree { int yCenter = height - girth; yCenter = yCenter > 2 ? yCenter : 3; - Vector center = getCenteredAt(yCenter, 0); - int radius = 2 + world.rand.nextInt(girth); + Vector center = getCenteredAt(yCenter, 0, 0); + int radius = Math.round((2 + world.rand.nextInt(girth)) * (height / 4.0f)); + if (radius > 4) { + radius = 4; + } generateSphere(world, center, radius, leaf, EnumReplaceMode.NONE); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java index 1a316e753..3b12a9b6b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java @@ -25,9 +25,10 @@ public class WorldGenPoplar extends WorldGenTree { generateTreeTrunk(world, height, girth); int leafSpawn = height + 1; + float leafRadius = (girth - 1.0f) / 2.0f; while (leafSpawn > girth - 1) { - generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, leafRadius, 1, leaf); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java index 61660836b..d4137f9e3 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenSequoia.java @@ -10,6 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -27,10 +31,21 @@ public class WorldGenSequoia extends WorldGenTree { @Override public void generate(World world) { generateTreeTrunk(world, height, girth); + generateSupportStems(world, height, girth, 0.4f, 0.4f); - int topLength = height / 4; + int topHeight = (height / 3) + world.rand.nextInt(height / 6); - int topHeight = height - topLength + world.rand.nextInt(height / 4); + List branchCoords = new ArrayList<>(); + for (int yBranch = topHeight; yBranch < height; yBranch++) { + int branchLength = Math.round(height - yBranch) / 2; + if (branchLength > 4) { + branchLength = 4; + } + branchCoords.addAll(generateBranches(world, yBranch, 0, 0, 0.05f, 0.25f, branchLength, 1, 0.5f)); + } + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 1.0f, 1, leaf, EnumReplaceMode.NONE); + } int leafSpawn = height + 2; @@ -42,20 +57,7 @@ public class WorldGenSequoia extends WorldGenTree { generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); } - generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); - - for (int times = 0; times < height / 4; times++) { - int h = (height / 3) + world.rand.nextInt(height - (height / 3)); - if (world.rand.nextBoolean() && h < height / 3) { - h = height / 2 + world.rand.nextInt(height / 3); - } - int x_off = -1 + world.rand.nextInt(3); - int y_off = -1 + world.rand.nextInt(3); - - Vector center = new Vector(x_off, h, y_off); - int radius = 1 + world.rand.nextInt(2); - generateSphere(world, center, radius, leaf, EnumReplaceMode.NONE); - } + generateAdjustedCylinder(world, leafSpawn, 0, 1, leaf); } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenSilverLime.java old mode 100755 new mode 100644 similarity index 61% rename from src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java rename to src/main/java/forestry/arboriculture/worldgen/WorldGenSilverLime.java index b9c45213b..ed4a65d20 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLime.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenSilverLime.java @@ -10,26 +10,34 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; -public class WorldGenLime extends WorldGenTree { +public class WorldGenSilverLime extends WorldGenTree { - public WorldGenLime(ITreeGenData tree) { + public WorldGenSilverLime(ITreeGenData tree) { super(tree, 6, 4); } @Override public void generate(World world) { generateTreeTrunk(world, height, girth); + List branchCoords = generateBranches(world, 3 + world.rand.nextInt(1), 0, 0, 0.25f, 0.10f, Math.round(height * 0.25f), 2, 0.5f); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 0, 1, leaf, EnumReplaceMode.NONE); + } int leafSpawn = height + 1; generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + float radius = 1; while (leafSpawn > 1) { - generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, radius, 1, leaf); + radius += 0.25; } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java index 4c3c93f5c..d3177e48f 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenSpruce.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -29,11 +32,17 @@ public class WorldGenSpruce extends WorldGenTree { generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + int branchWidth = height / 4; while (leafSpawn > 2) { + int leafRadius = Math.min(4, branchWidth); + List branchCoords = generateBranches(world, leafSpawn, 0, 0, 0.2f, 0.5f, branchWidth, 1); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCircle(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, leafRadius, 3, 2, leaf, 1.0f, EnumReplaceMode.SOFT); + } generateAdjustedCylinder(world, leafSpawn--, 2, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 1, 1, leaf); + branchWidth++; } - } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java index c7c50239a..1798c952e 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTeak.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -24,18 +27,28 @@ public class WorldGenTeak extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height, girth); + float leafMultiplier = (height / 6.0f); + if (leafMultiplier > 2) { + leafMultiplier = 2; + } + int branchWidth = height / 3; + List branchCoords = generateBranches(world, height - 3, 0, 0, 0.2f, 0.5f, branchWidth, 1); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCircle(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 2, Math.round(3 * leafMultiplier), 2, leaf, 1.0f, EnumReplaceMode.NONE); + } + int leafSpawn = height + 1; generateAdjustedCylinder(world, leafSpawn--, 0, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 0.5f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, 0.5f * leafMultiplier, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, 1.9f * leafMultiplier, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, 1.9f * leafMultiplier, 1, leaf); if (world.rand.nextBoolean()) { - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn--, 1.9f * leafMultiplier, 1, leaf); } - generateAdjustedCylinder(world, leafSpawn--, 0.5f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn, 0.5f * leafMultiplier, 1, leaf); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java index d69fc1ec6..b1b670218 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenTree.java @@ -47,24 +47,29 @@ public abstract class WorldGenTree extends WorldGenArboriculture { generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf, EnumReplaceMode.NONE); } - protected Vector getCenteredAt(int yCenter, int offset) { + protected Vector getCenteredAt(int yCenter, int xOffset, int zOffset) { float cent = girth % 2 == 0 ? 0.5f : 0f; - return new Vector(cent + offset, yCenter, cent + offset); + return new Vector(cent + xOffset, yCenter, cent + zOffset); } protected void generateAdjustedCylinder(World world, int yCenter, float radius, int height, ITreeBlockType block) { - generateAdjustedCylinder(world, yCenter, 0, radius, height, block, EnumReplaceMode.SOFT); + generateAdjustedCylinder(world, yCenter, 0, 0, radius, height, block, EnumReplaceMode.SOFT); } protected void generateAdjustedCylinder(World world, int yCenter, float radius, int height, ITreeBlockType block, EnumReplaceMode replace) { - generateAdjustedCylinder(world, yCenter, 0, radius, height, block, replace); + generateAdjustedCylinder(world, yCenter, 0, 0, radius, height, block, replace); } - protected void generateAdjustedCylinder(World world, int yCenter, int offset, float radius, int height, ITreeBlockType block, EnumReplaceMode replace) { - Vector center = getCenteredAt(yCenter, offset); + protected void generateAdjustedCylinder(World world, int yCenter, int xOffset, int zOffset, float radius, int height, ITreeBlockType block, EnumReplaceMode replace) { + Vector center = getCenteredAt(yCenter, xOffset, zOffset); generateCylinder(world, center, radius + girth, height, block, replace); } + protected void generateAdjustedCircle(World world, int yCenter, int xOffset, int zOffset, float radius, int width, int height, ITreeBlockType block, float chance, EnumReplaceMode replace) { + Vector center = getCenteredAt(yCenter, xOffset, zOffset); + generateCircle(world, center, radius, width, height, block, chance, replace); + } + @Override public boolean canGrow(World world, int x, int y, int z) { return tree.canGrow(world, x, y, z, girth, height); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java index bfb4bbaf8..aada614ab 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWalnut.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -32,13 +35,16 @@ public class WorldGenWalnut extends WorldGenTree { generateAdjustedCylinder(world, leafSpawn--, 1.5f, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 2f, 1, leaf); - while (leafSpawn > 3) { - generateAdjustedCylinder(world, leafSpawn--, 3f, 1, leaf); + float branchSize = 2; + while (leafSpawn >= 3) { + int leafRadius = Math.min(4, (int) branchSize); + List branchCoords = generateBranches(world, leafSpawn, 0, 0, 0.2f, 0.2f, (int) branchSize, 1, 0.5f); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCircle(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, leafRadius, 2, 2, leaf, 1.0f, EnumReplaceMode.SOFT); + } + leafSpawn--; + branchSize += 0.25f; } - if (world.rand.nextBoolean()) { - generateAdjustedCylinder(world, leafSpawn--, 2f, 1, leaf); - } - } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java index 7ede29aed..1a1714c0d 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWenge.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -32,10 +35,17 @@ public class WorldGenWenge extends WorldGenTree { generateAdjustedCylinder(world, leafSpawn--, 1.5f, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 2f, 1, leaf); + float branchSize = 3; while (leafSpawn > 1) { generateAdjustedCylinder(world, leafSpawn--, 3f, 1, leaf); - } + List branchCoords = generateBranches(world, leafSpawn, 0, 0, 0.2f, 0.2f, (int) branchSize, 2, 0.75f); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCircle(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 3, 3, 2, leaf, 1.0f, EnumReplaceMode.SOFT); + } + leafSpawn--; + branchSize += 0.5f; + } } } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java index 0bae0cb5e..9e9caf93b 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenWillow.java @@ -22,7 +22,6 @@ public class WorldGenWillow extends WorldGenTree { @Override public void generate(World world) { - generateTreeTrunk(world, height, girth, 0.8f); generateSupportStems(world, height, girth, 0.2f, 0.2f); @@ -35,11 +34,15 @@ public class WorldGenWillow extends WorldGenTree { generateAdjustedCylinder(world, leafSpawn--, 3f, 1, leaf); generateAdjustedCylinder(world, leafSpawn--, 3f, 1, leaf); while (leafSpawn > 2) { + // support branches for tall willows, keeps the leaves from decaying immediately + if ((leafSpawn - 3) % 6 == 0) { + generateBranches(world, leafSpawn, 0, 0, 0, 0, 2, 1); + } generateCircle(world, new Vector(0f, leafSpawn--, 0f), 4f, 2, 1, leaf, EnumReplaceMode.NONE); } generateCircle(world, new Vector(0f, leafSpawn--, 0f), 4f, 1, 1, leaf, EnumReplaceMode.NONE); generateCircle(world, new Vector(0f, leafSpawn--, 0f), 4f, 1, 1, leaf, EnumReplaceMode.NONE); - generateCircle(world, new Vector(0f, leafSpawn--, 0f), 4f, 1, 1, leaf, 0.4f, EnumReplaceMode.NONE); + generateCircle(world, new Vector(0f, leafSpawn, 0f), 4f, 1, 1, leaf, 0.4f, EnumReplaceMode.NONE); } diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java index 1667c2186..5e23e6439 100644 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenZebrawood.java @@ -10,6 +10,9 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; +import java.util.List; + +import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import forestry.api.world.ITreeGenData; @@ -24,6 +27,12 @@ public class WorldGenZebrawood extends WorldGenTree { public void generate(World world) { generateTreeTrunk(world, height, girth); + generateSupportStems(world, height, girth, 0.8f, 0.3f); + + List branchCoords = generateBranches(world, height - 4, 0, 0, 0, 0.25f, 3, 2, 0.75f); + for (ChunkCoordinates branchEnd : branchCoords) { + generateAdjustedCylinder(world, branchEnd.posY, branchEnd.posX, branchEnd.posZ, 1.0f, 2, leaf, EnumReplaceMode.NONE); + } int leafSpawn = height + 1; @@ -35,7 +44,7 @@ public class WorldGenZebrawood extends WorldGenTree { while (leafSpawn > height - 4) { generateAdjustedCylinder(world, leafSpawn--, 2.5f, 1, leaf); } - generateAdjustedCylinder(world, leafSpawn--, 1.9f, 1, leaf); + generateAdjustedCylinder(world, leafSpawn, 1.9f, 1, leaf); // Add some smaller twigs below for flavour for (int times = 0; times < height / 4; times++) { diff --git a/src/main/java/forestry/core/worldgen/WorldGenBase.java b/src/main/java/forestry/core/worldgen/WorldGenBase.java index 19a8c6ec3..76764e222 100755 --- a/src/main/java/forestry/core/worldgen/WorldGenBase.java +++ b/src/main/java/forestry/core/worldgen/WorldGenBase.java @@ -15,6 +15,8 @@ import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.util.ForgeDirection; + import forestry.arboriculture.worldgen.ITreeBlockType; public abstract class WorldGenBase extends WorldGenerator { @@ -39,6 +41,20 @@ public abstract class WorldGenBase extends WorldGenerator { public static double distance(Vector a, Vector b) { return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2) + Math.pow(a.z - b.z, 2)); } + + public static ForgeDirection direction(Vector a, Vector b) { + int x = (int) Math.abs(a.x - b.x); + int y = (int) Math.abs(a.y - b.y); + int z = (int) Math.abs(a.z - b.z); + int max = Math.max(x, Math.max(y, z)); + if (max == x) { + return ForgeDirection.EAST; + } else if (max == z) { + return ForgeDirection.SOUTH; + } else { + return ForgeDirection.UP; + } + } } @Override @@ -71,7 +87,11 @@ public abstract class WorldGenBase extends WorldGenerator { for (int x = (int) start.x; x < (int) start.x + area.x; x++) { for (int y = (int) start.y; y < (int) start.y + area.y; y++) { for (int z = (int) start.z; z < (int) start.z + area.z; z++) { - if (Vector.distance(new Vector(x, y, z), new Vector(center.x, y, center.z)) <= (radius) + 0.01) { + Vector position = new Vector(x, y, z); + Vector treeCenter = new Vector(center.x, y, center.z); + if (Vector.distance(position, treeCenter) <= (radius) + 0.01) { + ForgeDirection direction = Vector.direction(position, treeCenter); + block.setDirection(direction); addBlock(world, x, y, z, block, replace); } }