Fix #853 Improve trees to have more branches and variations with height.

This commit is contained in:
mezz committed 2015-10-14 01:57:35 -07:00
1 parent 3684792a39
commit ad0fcc57b5
33 files changed
+515 -221

No files matched your search

@@ -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);
@@ -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<ChunkCoordinates> treeTops = generateTreeTrunk(world, height, girth, 0, leanDirection.forgeDirection, leanAmount);
if (height > 5 && world.rand.nextBoolean()) {
Direction branchDirection = Direction.getRandomOther(world.rand, leanDirection);
List<ChunkCoordinates> treeTops2 = generateTreeTrunk(world, Math.round(height * 0.66f), girth, 0, branchDirection.forgeDirection, leanAmount);
treeTops.addAll(treeTops2);
}
List<ChunkCoordinates> 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<ChunkCoordinates> 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);
}
}
@@ -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<Direction> 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<ChunkCoordinates> 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<ChunkCoordinates> generateTreeTrunk(World world, int height, int girth, float vinesChance) {
return generateTreeTrunk(world, height, girth, vinesChance, ForgeDirection.UNKNOWN, 0);
}
protected List<ChunkCoordinates> 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<ChunkCoordinates> generateTreeTrunk(World world, int height, int girth, int yStart, float vinesChance, ForgeDirection leanDirection, float leanAmount) {
List<ChunkCoordinates> 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<ChunkCoordinates> 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<ChunkCoordinates> 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<ChunkCoordinates> 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
@@ -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--;
}
@@ -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<ChunkCoordinates> 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;
@@ -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<ChunkCoordinates> 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++;
}
}
@@ -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<ChunkCoordinates> 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);
}
@@ -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<ChunkCoordinates> 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--;
}
@@ -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);
}
}
@@ -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);
}
@@ -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;
@@ -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<ChunkCoordinates> 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);
}
}
}
@@ -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<ChunkCoordinates> 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);
}
@@ -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<ChunkCoordinates> 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++) {
@@ -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);
}
}
@@ -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);
}
}
@@ -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<ChunkCoordinates> 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);
}
@@ -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<ChunkCoordinates> 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);
@@ -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<ChunkCoordinates> 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;
@@ -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<ChunkCoordinates> 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);
}
}
@@ -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<ChunkCoordinates> 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);
@@ -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);
}
@@ -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);
}
}
@@ -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<ChunkCoordinates> 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);
}
}
@@ -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<ChunkCoordinates> 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;
}
}
@@ -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<ChunkCoordinates> 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++;
}
}
}
@@ -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<ChunkCoordinates> 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);
}
@@ -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);
@@ -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<ChunkCoordinates> 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);
}
}
}
@@ -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<ChunkCoordinates> 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;
}
}
}
@@ -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);
}
@@ -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<ChunkCoordinates> 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++) {
@@ -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);
}
}