use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.
the class WorldGenWaterGrass method generate.
public boolean generate(World world, Random rand, int x, int y, int z) {
while (y > 0) {
if (!world.isAirBlock(new BlockPos(x, y, z)) || world.getBlockState(new BlockPos(x, y, z)).getBlock().isLeaves(world.getBlockState(new BlockPos(x, y, z)), world, new BlockPos(x, y, z))) {
break;
}
if (y < varMinHeight) {
return false;
}
y--;
}
Block b;
if (blockData == Blocks.DOUBLE_PLANT) {
int i1, j1, k1;
for (int l = 0; l < 32; ++l) {
i1 = x + rand.nextInt(8) - rand.nextInt(8);
j1 = y + rand.nextInt(2) - rand.nextInt(2);
k1 = z + rand.nextInt(8) - rand.nextInt(8);
b = world.getBlockState(new BlockPos(i1, j1 - 1, k1)).getBlock();
if (((b == Blocks.WATER && world.getBlockState(new BlockPos(i1, j1 - 2, k1)).getBlock() == Blocks.SAND) || b == Blocks.SAND) && world.getBlockState(new BlockPos(i1, j1, k1)).getBlock() == Blocks.AIR) {
world.setBlockState(new BlockPos(i1, j1 - 1, k1), Blocks.GRASS.getDefaultState(), 0);
}
if (world.isAirBlock(new BlockPos(i1, j1, k1)) && j1 < 254 && Blocks.DOUBLE_PLANT.canPlaceBlockAt(world, new BlockPos(i1, j1, k1))) {
world.setBlockState(new BlockPos(i1, j1, k1), Blocks.DOUBLE_PLANT.getStateFromMeta(varMetadata));
}
}
} else if (blockData == Blocks.LEAVES) {
for (int l = 0; l < 64; ++l) {
int i1 = x + rand.nextInt(8) - rand.nextInt(8);
int j1 = y + rand.nextInt(4) - rand.nextInt(4);
int k1 = z + rand.nextInt(8) - rand.nextInt(8);
b = world.getBlockState(new BlockPos(i1, j1 - 1, k1)).getBlock();
if (((b == Blocks.WATER && world.getBlockState(new BlockPos(i1, j1 - 2, k1)).getBlock() == Blocks.SAND) || b == Blocks.SAND) && world.getBlockState(new BlockPos(i1, j1, k1)).getBlock() == Blocks.AIR) {
world.setBlockState(new BlockPos(i1, j1 - 1, k1), Blocks.GRASS.getDefaultState(), 0);
}
if (world.isAirBlock(new BlockPos(i1, j1, k1)) && world.getBlockState(new BlockPos(i1, j1 - 1, k1)).getBlock() == Blocks.GRASS) {
world.setBlockState(new BlockPos(i1, j1, k1), BlockUtil.getStateLeaf(varMetadata), 0);
}
}
} else {
for (int l = 0; l < 128; ++l) {
int i1 = x + rand.nextInt(8) - rand.nextInt(8);
int j1 = y + rand.nextInt(4) - rand.nextInt(4);
int k1 = z + rand.nextInt(8) - rand.nextInt(8);
b = world.getBlockState(new BlockPos(i1, j1 - 1, k1)).getBlock();
if (((b == Blocks.WATER && world.getBlockState(new BlockPos(i1, j1 - 2, k1)).getBlock() == Blocks.SAND) || b == Blocks.SAND) && world.getBlockState(new BlockPos(i1, j1, k1)).getBlock() == Blocks.AIR) {
world.setBlockState(new BlockPos(i1, j1 - 1, k1), Blocks.GRASS.getDefaultState(), 0);
}
if (world.isAirBlock(new BlockPos(i1, j1, k1))) //TODO replace this
// && block.canBlockStay(world, new BlockPos(i1, j1, k1))
{
world.setBlockState(new BlockPos(i1, j1, k1), blockData.getStateFromMeta(varMetadata), 0);
}
}
}
return true;
}
use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.
the class TreeRTGRhizophoraMucronata method generateBranch.
/*
* horDir = number between -180D and 180D
* verDir = number between 1F (horizontal) and 0F (vertical)
*/
public void generateBranch(World world, Random rand, float x, float y, float z, double horDir, float verDir, float length, float speed, boolean isTrunk) {
if (verDir < 0f) {
verDir = -verDir;
}
float c = 0f;
float velY = 1f - verDir;
if (verDir > 1f) {
verDir = 1f - (verDir - 1f);
}
float velX = (float) Math.cos(horDir * Math.PI / 180D) * verDir;
float velZ = (float) Math.sin(horDir * Math.PI / 180D) * verDir;
while (c < length) {
if (isTrunk) {
this.placeLogBlock(world, new BlockPos((int) x, (int) y, (int) z), this.trunkLog, this.generateFlag);
} else {
this.placeLogBlock(world, new BlockPos((int) x, (int) y, (int) z), this.logBlock, this.generateFlag);
}
x += velX;
y += velY;
z += velZ;
c += speed;
}
}
use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.
the class TreeRTGRhizophoraMucronata method generateLeaves.
public void generateLeaves(World world, Random rand, int x, int y, int z, float size, float width) {
float dist;
int i, j, k, s = (int) (size - 1f), w = (int) ((size - 1f) * width);
for (i = -w; i <= w; i++) {
for (j = -s; j <= s; j++) {
for (k = -w; k <= w; k++) {
dist = Math.abs((float) i / width) + (float) Math.abs(j) + Math.abs((float) k / width);
if (dist <= size - 0.5f || (dist <= size && rand.nextBoolean())) {
if (dist < 0.6f) {
this.placeLogBlock(world, new BlockPos(x + i, y + j, z + k), this.logBlock, this.generateFlag);
}
if (!this.noLeaves) {
this.placeLeavesBlock(world, new BlockPos(x + i, y + j, z + k), this.leavesBlock, this.generateFlag);
}
}
}
}
}
}
use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.
the class TreeRTGCeibaPentandra method generateBranch.
/*
* horDir = number between -180D and 180D
* verDir = number between 1F (horizontal) and 0F (vertical)
*/
public void generateBranch(World world, Random rand, float x, float y, float z, double horDir, float verDir, float length, float speed, boolean isTrunk) {
if (verDir < 0f) {
verDir = -verDir;
}
float c = 0f;
float velY = 1f - verDir;
if (verDir > 1f) {
verDir = 1f - (verDir - 1f);
}
float velX = (float) Math.cos(horDir * Math.PI / 180D) * verDir;
float velZ = (float) Math.sin(horDir * Math.PI / 180D) * verDir;
while (c < length) {
if (isTrunk) {
this.placeLogBlock(world, new BlockPos((int) x, (int) y, (int) z), this.trunkLog, this.generateFlag);
} else {
this.placeLogBlock(world, new BlockPos((int) x, (int) y, (int) z), this.logBlock, this.generateFlag);
}
x += velX;
y += velY;
z += velZ;
c += speed;
}
}
use of net.minecraft.util.math.BlockPos in project Realistic-Terrain-Generation by Team-RTG.
the class TreeRTGCeibaRosea method generateBranch.
/*
* horDir = number between -180D and 180D
* verDir = number between 1F (horizontal) and 0F (vertical)
*/
public void generateBranch(World world, Random rand, float x, float y, float z, double horDir, float verDir, float length, float speed, boolean isTrunk) {
if (verDir < 0f) {
verDir = -verDir;
}
float c = 0f;
float velY = 1f - verDir;
if (verDir > 1f) {
verDir = 1f - (verDir - 1f);
}
float velX = (float) Math.cos(horDir * Math.PI / 180D) * verDir;
float velZ = (float) Math.sin(horDir * Math.PI / 180D) * verDir;
while (c < length) {
if (isTrunk) {
this.placeLogBlock(world, new BlockPos((int) x, (int) y, (int) z), this.trunkLog, this.generateFlag);
} else {
this.placeLogBlock(world, new BlockPos((int) x, (int) y, (int) z), this.logBlock, this.generateFlag);
}
x += velX;
y += velY;
z += velZ;
c += speed;
}
}
Aggregations