Random pine trees

This commit is contained in:
ted80-PC 2013-09-29 11:16:32 +02:00
parent 9b97f207ca
commit 2e6207e73d

View file

@ -3,6 +3,7 @@ package biomesoplenty.worldgen.tree;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraft.world.gen.feature.WorldGenerator;
import biomesoplenty.api.Blocks; import biomesoplenty.api.Blocks;
@ -20,7 +21,9 @@ public class WorldGenPineTree extends WorldGenerator
int var6 = var1.getBlockId(var3, var4, var5); int var6 = var1.getBlockId(var3, var4, var5);
if (var6 != Block.grass.blockID && var6 != Blocks.hardDirt.get().blockID && var6 != Block.stone.blockID && var6 != Block.dirt.blockID) if (var6 != Block.grass.blockID && var6 != Blocks.hardDirt.get().blockID && var6 != Block.stone.blockID && var6 != Block.dirt.blockID)
{
return false; return false;
}
else else
{ {
for (int var7 = -2; var7 <= 2; ++var7) for (int var7 = -2; var7 <= 2; ++var7)
@ -28,137 +31,96 @@ public class WorldGenPineTree extends WorldGenerator
for (int var8 = -2; var8 <= 2; ++var8) for (int var8 = -2; var8 <= 2; ++var8)
{ {
if (var1.isAirBlock(var3 + var7, var4 - 1, var5 + var8) && var1.isAirBlock(var3 + var7, var4 - 2, var5 + var8) && !var1.isAirBlock(var3 + var7, var4, var5 + var8)) if (var1.isAirBlock(var3 + var7, var4 - 1, var5 + var8) && var1.isAirBlock(var3 + var7, var4 - 2, var5 + var8) && !var1.isAirBlock(var3 + var7, var4, var5 + var8))
{
return false; return false;
} }
} }
int var99 = var2.nextInt(2);
if (var99 == 0)
{
var1.setBlock(var3, var4, var5, Block.dirt.blockID);
var1.setBlock(var3, var4 + 1, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 2, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 3, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 4, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 5, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 6, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 7, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 8, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 9, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 10, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3 + 1, var4 + 6, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 6, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 6, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 6, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 8, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 8, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 10, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 10, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 10, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 10, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 10, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 10, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 10, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 10, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 11, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 11, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 11, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 11, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 12, var5, Blocks.leavesColorized.get().blockID, 5, 2);
} }
if (var99 == 1) //settings========
int baselength = 4 + var2.nextInt(4);
int branches = 1 + var2.nextInt(3);
//================
int h = 1;
buildBlock(var1, var3, var4, var5, Block.dirt.blockID, 0);
for(int b = 0; b < baselength; b++)
{ {
var1.setBlock(var3, var4, var5, Block.dirt.blockID); buildBlock(var1, var3, var4 + h, var5, Blocks.logs4.get().blockID, 0);
var1.setBlock(var3, var4 + 1, var5, Blocks.logs4.get().blockID, 0, 2); h++;
var1.setBlock(var3, var4 + 2, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 3, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 4, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 5, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 6, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 7, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 8, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 9, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3, var4 + 10, var5, Blocks.logs4.get().blockID, 0, 2);
var1.setBlock(var3 + 1, var4 + 6, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 6, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 6, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 6, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 6, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 6, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 6, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 8, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 8, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 2, var4 + 8, var5 - 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 8, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 8, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 2, var4 + 8, var5 + 2, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 10, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 10, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 10, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 10, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 10, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 10, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 10, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 10, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 + 1, var4 + 11, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3 - 1, var4 + 11, var5, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 11, var5 + 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 11, var5 - 1, Blocks.leavesColorized.get().blockID, 5, 2);
var1.setBlock(var3, var4 + 12, var5, Blocks.leavesColorized.get().blockID, 5, 2);
} }
int c = 1;
for(int r = 0; r < branches; r++)
{
generateBranch(var1, var2, var3, var4 + h, var5, c);
c++;
h+=2;
}
generateTop(var1, var3, var4 + h, var5);
return true; return true;
} }
} }
public void generateTop(World world, int x, int y, int z)
{
for(int i = -1; i < 2; i++)
{
for(int j = -1; j < 2; j++)
{
buildBlock(world, x + i, y, z + j, Blocks.leavesColorized.get().blockID, 5);
}
}
buildBlock(world, x, y, z, Blocks.logs4.get().blockID, 0);
buildBlock(world, x + 1, y + 1, z, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x, y + 1, z - 1, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x, y + 1, z + 1, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x - 1, y + 1, z, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x, y + 2, z, Blocks.leavesColorized.get().blockID, 5);
}
public void generateBranch(World world, Random rand, int x, int y, int z, int n)
{
for(int i = -1; i < 2; i++)
{
for(int j = -1; j < 2; j++)
{
buildBlock(world, x + i, y, z + j, Blocks.leavesColorized.get().blockID, 5);
}
}
if(n % 2 == 0)
{
buildBlock(world, x + 1, y, z - 2, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x + 2, y, z - 2, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x + 2, y, z - 1, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x - 2, y, z + 1, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x - 2, y, z + 2, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x - 1, y, z + 2, Blocks.leavesColorized.get().blockID, 5);
}
else
{
buildBlock(world, x + 2, y, z + 1, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x + 2, y, z + 2, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x + 1, y, z + 2, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x - 1, y, z - 2, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x - 2, y, z - 2, Blocks.leavesColorized.get().blockID, 5);
buildBlock(world, x - 2, y, z - 1, Blocks.leavesColorized.get().blockID, 5);
}
buildBlock(world, x, y, z, Blocks.logs4.get().blockID, 0);
buildBlock(world, x, y + 1, z, Blocks.logs4.get().blockID, 0);
}
public void buildBlock(World world, int x, int y, int z, int id, int meta)
{
Material m = world.getBlockMaterial(x, y, z);
if(m == Material.air || m == Material.leaves)
{
world.setBlock(x, y, z, id, meta, 2);
}
}
} }