2013-09-14 10:16:39 +00:00
|
|
|
package biomesoplenty.worldgen.tree;
|
2013-05-03 13:00:44 +00:00
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
2013-09-29 10:50:35 +00:00
|
|
|
import net.minecraft.block.material.Material;
|
2013-05-03 13:00:44 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.gen.feature.WorldGenerator;
|
2013-05-29 01:05:27 +00:00
|
|
|
import biomesoplenty.api.Blocks;
|
2013-05-03 13:00:44 +00:00
|
|
|
|
|
|
|
public class WorldGenPalmTree3 extends WorldGenerator
|
|
|
|
{
|
2013-05-31 10:34:02 +00:00
|
|
|
@Override
|
|
|
|
public boolean generate(World var1, Random var2, int var3, int var4, int var5)
|
|
|
|
{
|
|
|
|
while (var1.isAirBlock(var3, var4, var5) && var4 > 2)
|
|
|
|
{
|
|
|
|
--var4;
|
|
|
|
}
|
|
|
|
|
|
|
|
int var6 = var1.getBlockId(var3, var4, var5);
|
|
|
|
|
|
|
|
if (var6 != Block.grass.blockID)
|
2013-09-29 10:50:35 +00:00
|
|
|
{
|
2013-05-31 10:34:02 +00:00
|
|
|
return false;
|
2013-09-29 10:50:35 +00:00
|
|
|
}
|
2013-05-31 10:34:02 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int var7 = -2; var7 <= 2; ++var7)
|
|
|
|
{
|
|
|
|
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))
|
2013-09-29 10:50:35 +00:00
|
|
|
{
|
2013-05-31 10:34:02 +00:00
|
|
|
return false;
|
2013-09-29 10:50:35 +00:00
|
|
|
}
|
2013-05-31 10:34:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-29 10:50:35 +00:00
|
|
|
|
|
|
|
//settings========
|
|
|
|
double strength = var2.nextInt(25) / 100D;
|
|
|
|
//================
|
|
|
|
|
|
|
|
double xoff = 0;
|
|
|
|
double yoff = 0;
|
|
|
|
int r = var2.nextInt(4);
|
|
|
|
if(r == 0) { xoff = strength; }
|
|
|
|
else if(r == 1) { xoff = -strength; }
|
|
|
|
else if(r == 2) { yoff = strength; }
|
|
|
|
else { yoff = -strength; }
|
|
|
|
|
|
|
|
int h = 1;
|
|
|
|
buildBlock(var1, var3, var4, var5, Block.dirt.blockID, 0);
|
|
|
|
for(int b = 0; b < 8; b++)
|
2013-05-13 09:33:12 +00:00
|
|
|
{
|
2013-09-29 10:50:35 +00:00
|
|
|
buildBlock(var1, var3 + ((int) Math.floor(xoff)), var4 + h, var5 + ((int) Math.floor(yoff)), Blocks.logs2.get().blockID, 3);
|
|
|
|
if(b == 7)
|
|
|
|
{
|
|
|
|
generateTop(var1, var3 + ((int) Math.floor(xoff)), var4 + h, var5 + ((int) Math.floor(yoff)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h++;
|
|
|
|
xoff *= 1.5D;
|
|
|
|
yoff *= 1.5D;
|
|
|
|
}
|
2013-05-13 09:33:12 +00:00
|
|
|
}
|
2013-05-31 10:34:02 +00:00
|
|
|
|
2013-05-13 09:33:12 +00:00
|
|
|
return true;
|
2013-05-31 10:34:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-29 10:50:35 +00:00
|
|
|
|
|
|
|
public void generateTop(World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
buildBlock(world, x + 2, y - 1, z, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x - 2, y - 1, z, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x, y - 1, z + 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x, y - 1, z - 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
|
|
|
|
buildBlock(world, x + 1, y, z, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x - 1, y, z, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x, y, z + 1, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x, y, z - 1, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x + 2, y, z + 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x - 2, y, z - 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x + 2, y, z - 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x - 2, y, z + 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
|
|
|
|
buildBlock(world, x + 1, y + 1, z - 1, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x - 1, y + 1, z + 1, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x + 1, y + 1, z + 1, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x - 1, y + 1, z - 1, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x, y + 1, z, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
|
|
|
|
buildBlock(world, x + 2, y + 2, z, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x - 2, y + 2, z, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x, y + 2, z + 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
buildBlock(world, x, y + 2, z - 2, Blocks.leavesColorized.get().blockID, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2013-05-03 13:00:44 +00:00
|
|
|
}
|