initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
257
java/src/game/worldgen/tree/WorldGenBaseTree.java
Executable file
257
java/src/game/worldgen/tree/WorldGenBaseTree.java
Executable file
|
@ -0,0 +1,257 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockCocoa;
|
||||
import game.block.BlockLeaves;
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.properties.PropertyBool;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenBaseTree extends WorldGenTree
|
||||
{
|
||||
private static final State defLog = Blocks.oak_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK);
|
||||
private static final State defLeaves = Blocks.oak_leaves.getState(); // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK);
|
||||
|
||||
private final int minTreeHeight;
|
||||
private final boolean vinesGrow;
|
||||
private final State metaWood;
|
||||
private final State metaLeaves;
|
||||
|
||||
public WorldGenBaseTree(boolean notify)
|
||||
{
|
||||
this(notify, 4, defLog, defLeaves, false);
|
||||
}
|
||||
|
||||
public WorldGenBaseTree(boolean notify, State log, State leaves)
|
||||
{
|
||||
this(notify, 4, log, leaves, false);
|
||||
}
|
||||
|
||||
public WorldGenBaseTree(boolean notify, int minHeight, State log, State leaves, boolean vines)
|
||||
{
|
||||
super(notify);
|
||||
this.minTreeHeight = minHeight;
|
||||
this.metaWood = log;
|
||||
this.metaLeaves = leaves.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
this.vinesGrow = vines;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + this.minTreeHeight;
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block1 == Blocks.grass || block1 == Blocks.dirt || block1 == Blocks.farmland || block1 == Blocks.tian_soil) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
int k2 = 3;
|
||||
int l2 = 0;
|
||||
|
||||
for (int i3 = position.getY() - k2 + i; i3 <= position.getY() + i; ++i3)
|
||||
{
|
||||
int i4 = i3 - (position.getY() + i);
|
||||
int j1 = l2 + 1 - i4 / 2;
|
||||
|
||||
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1)
|
||||
{
|
||||
int l1 = k1 - position.getX();
|
||||
|
||||
for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2)
|
||||
{
|
||||
int j2 = i2 - position.getZ();
|
||||
|
||||
if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.zrange(2) != 0 && i4 != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(k1, i3, i2);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves || block.getMaterial() == Material.vine)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j3 = 0; j3 < i; ++j3)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(j3)).getBlock();
|
||||
|
||||
if (block2.getMaterial() == Material.air || block2.getMaterial() == Material.leaves || block2.getMaterial() == Material.vine)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
|
||||
|
||||
if (this.vinesGrow && j3 > 0)
|
||||
{
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(-1, j3, 0)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(-1, j3, 0), BlockVine.EAST);
|
||||
}
|
||||
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(1, j3, 0)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(1, j3, 0), BlockVine.WEST);
|
||||
}
|
||||
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(0, j3, -1)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(0, j3, -1), BlockVine.SOUTH);
|
||||
}
|
||||
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(0, j3, 1)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(0, j3, 1), BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.vinesGrow)
|
||||
{
|
||||
for (int k3 = position.getY() - 3 + i; k3 <= position.getY() + i; ++k3)
|
||||
{
|
||||
int j4 = k3 - (position.getY() + i);
|
||||
int k4 = 2 - j4 / 2;
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l4 = position.getX() - k4; l4 <= position.getX() + k4; ++l4)
|
||||
{
|
||||
for (int i5 = position.getZ() - k4; i5 <= position.getZ() + k4; ++i5)
|
||||
{
|
||||
blockpos$mutableblockpos1.set(l4, k3, i5);
|
||||
|
||||
if (worldIn.getState(blockpos$mutableblockpos1).getBlock().getMaterial() == Material.leaves)
|
||||
{
|
||||
BlockPos blockpos2 = blockpos$mutableblockpos1.west();
|
||||
BlockPos blockpos3 = blockpos$mutableblockpos1.east();
|
||||
BlockPos blockpos4 = blockpos$mutableblockpos1.north();
|
||||
BlockPos blockpos1 = blockpos$mutableblockpos1.south();
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos2).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos2, BlockVine.EAST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos3).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos3, BlockVine.WEST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos4).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos4, BlockVine.SOUTH);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos1).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos1, BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.zrange(5) == 0 && i > 5)
|
||||
{
|
||||
for (int l3 = 0; l3 < 2; ++l3)
|
||||
{
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
|
||||
{
|
||||
if (rand.zrange(4 - l3) == 0)
|
||||
{
|
||||
Facing enumfacing1 = enumfacing.getOpposite();
|
||||
this.func_181652_a(worldIn, rand.zrange(3), position.add(enumfacing1.getFrontOffsetX(), i - 5 + l3, enumfacing1.getFrontOffsetZ()), enumfacing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181652_a(WorldServer p_181652_1_, int p_181652_2_, BlockPos p_181652_3_, Facing p_181652_4_)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181652_1_, p_181652_3_, Blocks.cocoa.getState().withProperty(BlockCocoa.AGE, p_181652_2_).withProperty(BlockCocoa.FACING, p_181652_4_));
|
||||
}
|
||||
|
||||
private void func_181651_a(WorldServer p_181651_1_, BlockPos p_181651_2_, PropertyBool p_181651_3_)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181651_1_, p_181651_2_, Blocks.vine.getState().withProperty(p_181651_3_, Boolean.valueOf(true)));
|
||||
}
|
||||
|
||||
private void func_181650_b(WorldServer p_181650_1_, BlockPos p_181650_2_, PropertyBool p_181650_3_)
|
||||
{
|
||||
this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_);
|
||||
int i = 4;
|
||||
|
||||
for (p_181650_2_ = p_181650_2_.down(); p_181650_1_.getState(p_181650_2_).getBlock().getMaterial() == Material.air && i > 0; --i)
|
||||
{
|
||||
this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_);
|
||||
p_181650_2_ = p_181650_2_.down();
|
||||
}
|
||||
}
|
||||
}
|
397
java/src/game/worldgen/tree/WorldGenBigTree.java
Executable file
397
java/src/game/worldgen/tree/WorldGenBigTree.java
Executable file
|
@ -0,0 +1,397 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.block.BlockLog;
|
||||
import game.collect.Lists;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenBigTree extends WorldGenTree
|
||||
{
|
||||
private final State leavesBase;
|
||||
private final State logBase;
|
||||
|
||||
private Random rand;
|
||||
private WorldServer world;
|
||||
private BlockPos basePos = BlockPos.ORIGIN;
|
||||
private int heightLimit;
|
||||
private int height;
|
||||
double heightAttenuation = 0.618D;
|
||||
double branchSlope = 0.381D;
|
||||
double scaleWidth = 1.0D;
|
||||
double leafDensity = 1.0D;
|
||||
private int trunkSize = 1;
|
||||
private int heightLimitLower = 5;
|
||||
private int heightLimitLimit = 16;
|
||||
private int leafDistanceLimit = 4;
|
||||
List<WorldGenBigTree.FoliageCoordinates> field_175948_j;
|
||||
|
||||
public WorldGenBigTree(boolean notify, State logBase, State leavesBase)
|
||||
{
|
||||
super(notify);
|
||||
this.leavesBase = leavesBase;
|
||||
this.logBase = logBase;
|
||||
}
|
||||
|
||||
public WorldGenBigTree(boolean notify)
|
||||
{
|
||||
this(notify, Blocks.oak_log.getState(), Blocks.oak_leaves.getState());
|
||||
}
|
||||
|
||||
public WorldGenBigTree setHeightLimit(int lower, int limit) {
|
||||
this.heightLimitLower = lower;
|
||||
this.heightLimitLimit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WorldGenBigTree setDistanceLimit(int limit) {
|
||||
this.leafDistanceLimit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a list of leaf nodes for the tree, to be populated by generateLeaves.
|
||||
*/
|
||||
void generateLeafNodeList()
|
||||
{
|
||||
this.height = (int)((double)this.heightLimit * this.heightAttenuation);
|
||||
|
||||
if (this.height >= this.heightLimit)
|
||||
{
|
||||
this.height = this.heightLimit - 1;
|
||||
}
|
||||
|
||||
int i = (int)(1.382D + Math.pow(this.leafDensity * (double)this.heightLimit / 13.0D, 2.0D));
|
||||
|
||||
if (i < 1)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
|
||||
int j = this.basePos.getY() + this.height;
|
||||
int k = this.heightLimit - this.leafDistanceLimit;
|
||||
this.field_175948_j = Lists.<WorldGenBigTree.FoliageCoordinates>newArrayList();
|
||||
this.field_175948_j.add(new WorldGenBigTree.FoliageCoordinates(this.basePos.up(k), j));
|
||||
|
||||
for (; k >= 0; --k)
|
||||
{
|
||||
float f = this.layerSize(k);
|
||||
|
||||
if (f >= 0.0F)
|
||||
{
|
||||
for (int l = 0; l < i; ++l)
|
||||
{
|
||||
double d0 = this.scaleWidth * (double)f * ((double)this.rand.floatv() + 0.328D);
|
||||
double d1 = (double)(this.rand.floatv() * 2.0F) * Math.PI;
|
||||
double d2 = d0 * Math.sin(d1) + 0.5D;
|
||||
double d3 = d0 * Math.cos(d1) + 0.5D;
|
||||
BlockPos blockpos = this.basePos.add(d2, (double)(k - 1), d3);
|
||||
BlockPos blockpos1 = blockpos.up(this.leafDistanceLimit);
|
||||
|
||||
if (this.checkBlockLine(blockpos, blockpos1) == -1)
|
||||
{
|
||||
int i1 = this.basePos.getX() - blockpos.getX();
|
||||
int j1 = this.basePos.getZ() - blockpos.getZ();
|
||||
double d4 = (double)blockpos.getY() - Math.sqrt((double)(i1 * i1 + j1 * j1)) * this.branchSlope;
|
||||
int k1 = d4 > (double)j ? j : (int)d4;
|
||||
BlockPos blockpos2 = new BlockPos(this.basePos.getX(), k1, this.basePos.getZ());
|
||||
|
||||
if (this.checkBlockLine(blockpos2, blockpos) == -1)
|
||||
{
|
||||
this.field_175948_j.add(new WorldGenBigTree.FoliageCoordinates(blockpos, blockpos2.getY()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_181631_a(BlockPos p_181631_1_, float p_181631_2_, State p_181631_3_)
|
||||
{
|
||||
int i = (int)((double)p_181631_2_ + 0.618D);
|
||||
|
||||
for (int j = -i; j <= i; ++j)
|
||||
{
|
||||
for (int k = -i; k <= i; ++k)
|
||||
{
|
||||
if (Math.pow((double)Math.abs(j) + 0.5D, 2.0D) + Math.pow((double)Math.abs(k) + 0.5D, 2.0D) <= (double)(p_181631_2_ * p_181631_2_))
|
||||
{
|
||||
BlockPos blockpos = p_181631_1_.add(j, 0, k);
|
||||
Material material = this.world.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(this.world, blockpos, p_181631_3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rough size of a layer of the tree.
|
||||
*/
|
||||
float layerSize(int p_76490_1_)
|
||||
{
|
||||
if ((float)p_76490_1_ < (float)this.heightLimit * 0.3F)
|
||||
{
|
||||
return -1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)this.heightLimit / 2.0F;
|
||||
float f1 = f - (float)p_76490_1_;
|
||||
float f2 = ExtMath.sqrtf(f * f - f1 * f1);
|
||||
|
||||
if (f1 == 0.0F)
|
||||
{
|
||||
f2 = f;
|
||||
}
|
||||
else if (Math.abs(f1) >= f)
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
return f2 * 0.5F;
|
||||
}
|
||||
}
|
||||
|
||||
float leafSize(int p_76495_1_)
|
||||
{
|
||||
return p_76495_1_ >= 0 && p_76495_1_ < this.leafDistanceLimit ? (p_76495_1_ != 0 && p_76495_1_ != this.leafDistanceLimit - 1 ? 3.0F : 2.0F) : -1.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the leaves surrounding an individual entry in the leafNodes list.
|
||||
*/
|
||||
void generateLeafNode(BlockPos pos)
|
||||
{
|
||||
for (int i = 0; i < this.leafDistanceLimit; ++i)
|
||||
{
|
||||
this.func_181631_a(pos.up(i), this.leafSize(i), this.leavesBase.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false))
|
||||
.withProperty(BlockLeaves.TYPE, this.world.getLeavesGen(pos.up(i))));
|
||||
}
|
||||
}
|
||||
|
||||
void func_175937_a(BlockPos p_175937_1_, BlockPos p_175937_2_)
|
||||
{
|
||||
BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ());
|
||||
int i = this.getGreatestDistance(blockpos);
|
||||
float f = (float)blockpos.getX() / (float)i;
|
||||
float f1 = (float)blockpos.getY() / (float)i;
|
||||
float f2 = (float)blockpos.getZ() / (float)i;
|
||||
|
||||
for (int j = 0; j <= i; ++j)
|
||||
{
|
||||
BlockPos blockpos1 = p_175937_1_.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));
|
||||
BlockLog.EnumAxis blocklog$enumaxis = this.func_175938_b(p_175937_1_, blockpos1);
|
||||
this.setBlockAndNotifyAdequately(this.world, blockpos1, this.logBase.withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute greatest distance in the BlockPos object.
|
||||
*/
|
||||
private int getGreatestDistance(BlockPos posIn)
|
||||
{
|
||||
int i = ExtMath.absi(posIn.getX());
|
||||
int j = ExtMath.absi(posIn.getY());
|
||||
int k = ExtMath.absi(posIn.getZ());
|
||||
return k > i && k > j ? k : (j > i ? j : i);
|
||||
}
|
||||
|
||||
private BlockLog.EnumAxis func_175938_b(BlockPos p_175938_1_, BlockPos p_175938_2_)
|
||||
{
|
||||
BlockLog.EnumAxis blocklog$enumaxis = BlockLog.EnumAxis.Y;
|
||||
int i = Math.abs(p_175938_2_.getX() - p_175938_1_.getX());
|
||||
int j = Math.abs(p_175938_2_.getZ() - p_175938_1_.getZ());
|
||||
int k = Math.max(i, j);
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
if (i == k)
|
||||
{
|
||||
blocklog$enumaxis = BlockLog.EnumAxis.X;
|
||||
}
|
||||
else if (j == k)
|
||||
{
|
||||
blocklog$enumaxis = BlockLog.EnumAxis.Z;
|
||||
}
|
||||
}
|
||||
|
||||
return blocklog$enumaxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the leaf portion of the tree as specified by the leafNodes list.
|
||||
*/
|
||||
void generateLeaves()
|
||||
{
|
||||
for (WorldGenBigTree.FoliageCoordinates worldgenbigtree$foliagecoordinates : this.field_175948_j)
|
||||
{
|
||||
this.generateLeafNode(worldgenbigtree$foliagecoordinates);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not a leaf node requires additional wood to be added to preserve integrity.
|
||||
*/
|
||||
boolean leafNodeNeedsBase(int p_76493_1_)
|
||||
{
|
||||
return (double)p_76493_1_ >= (double)this.heightLimit * 0.2D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the trunk for the big tree that is being generated. Able to generate double-sized trunks by changing a
|
||||
* field that is always 1 to 2.
|
||||
*/
|
||||
void generateTrunk()
|
||||
{
|
||||
BlockPos blockpos = this.basePos;
|
||||
BlockPos blockpos1 = this.basePos.up(this.height);
|
||||
this.func_175937_a(blockpos, blockpos1);
|
||||
|
||||
if (this.trunkSize == 2)
|
||||
{
|
||||
this.func_175937_a(blockpos.east(), blockpos1.east());
|
||||
this.func_175937_a(blockpos.east().south(), blockpos1.east().south());
|
||||
this.func_175937_a(blockpos.south(), blockpos1.south());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates additional wood blocks to fill out the bases of different leaf nodes that would otherwise degrade.
|
||||
*/
|
||||
void generateLeafNodeBases()
|
||||
{
|
||||
for (WorldGenBigTree.FoliageCoordinates worldgenbigtree$foliagecoordinates : this.field_175948_j)
|
||||
{
|
||||
int i = worldgenbigtree$foliagecoordinates.func_177999_q();
|
||||
BlockPos blockpos = new BlockPos(this.basePos.getX(), i, this.basePos.getZ());
|
||||
|
||||
if (!blockpos.equals(worldgenbigtree$foliagecoordinates) && this.leafNodeNeedsBase(i - this.basePos.getY()))
|
||||
{
|
||||
this.func_175937_a(blockpos, worldgenbigtree$foliagecoordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a line of blocks in the world from the first coordinate to triplet to the second, returning the distance
|
||||
* (in blocks) before a non-air, non-leaf block is encountered and/or the end is encountered.
|
||||
*/
|
||||
int checkBlockLine(BlockPos posOne, BlockPos posTwo)
|
||||
{
|
||||
BlockPos blockpos = posTwo.add(-posOne.getX(), -posOne.getY(), -posOne.getZ());
|
||||
int i = this.getGreatestDistance(blockpos);
|
||||
float f = (float)blockpos.getX() / (float)i;
|
||||
float f1 = (float)blockpos.getY() / (float)i;
|
||||
float f2 = (float)blockpos.getZ() / (float)i;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j <= i; ++j)
|
||||
{
|
||||
BlockPos blockpos1 = posOne.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));
|
||||
|
||||
if (!this.canBeReplaced(this.world.getState(blockpos1).getBlock()))
|
||||
{
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void prepare()
|
||||
{
|
||||
if(this.heightLimitLimit <= 16)
|
||||
this.leafDistanceLimit = 5;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
this.world = worldIn;
|
||||
this.basePos = position;
|
||||
this.rand = new Random(rand.longv());
|
||||
|
||||
if (this.heightLimit == 0)
|
||||
{
|
||||
this.heightLimit = this.rand.range(this.heightLimitLower, this.heightLimitLimit);
|
||||
}
|
||||
|
||||
if (!this.validTreeLocation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.generateLeafNodeList();
|
||||
this.generateLeaves();
|
||||
this.generateTrunk();
|
||||
this.generateLeafNodeBases();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether or not the current location for the tree, spanning basePos to to the height
|
||||
* limit, is valid.
|
||||
*/
|
||||
private boolean validTreeLocation()
|
||||
{
|
||||
Block block = this.world.getState(this.basePos.down()).getBlock();
|
||||
|
||||
if (block != Blocks.dirt && block != Blocks.grass && block != Blocks.farmland && block != Blocks.tian_soil)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = this.checkBlockLine(this.basePos, this.basePos.up(this.heightLimit - 1));
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (i < 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.heightLimit = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class FoliageCoordinates extends BlockPos
|
||||
{
|
||||
private final int field_178000_b;
|
||||
|
||||
public FoliageCoordinates(BlockPos p_i45635_1_, int p_i45635_2_)
|
||||
{
|
||||
super(p_i45635_1_.getX(), p_i45635_1_.getY(), p_i45635_1_.getZ());
|
||||
this.field_178000_b = p_i45635_2_;
|
||||
}
|
||||
|
||||
public int func_177999_q()
|
||||
{
|
||||
return this.field_178000_b;
|
||||
}
|
||||
}
|
||||
}
|
136
java/src/game/worldgen/tree/WorldGenBirch.java
Executable file
136
java/src/game/worldgen/tree/WorldGenBirch.java
Executable file
|
@ -0,0 +1,136 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenBirch extends WorldGenTree
|
||||
{
|
||||
private static final State logBlock = Blocks.birch_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.BIRCH);
|
||||
private static final State leavesBlock = Blocks.birch_leaves.getState()
|
||||
// .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.BIRCH)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
private boolean useExtraRandomHeight;
|
||||
|
||||
public WorldGenBirch(boolean notify, boolean extra)
|
||||
{
|
||||
super(notify);
|
||||
this.useExtraRandomHeight = extra;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + 5;
|
||||
|
||||
if (this.useExtraRandomHeight)
|
||||
{
|
||||
i += rand.zrange(7);
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block1 == Blocks.grass || block1 == Blocks.dirt || block1 == Blocks.farmland) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
|
||||
for (int i2 = position.getY() - 3 + i; i2 <= position.getY() + i; ++i2)
|
||||
{
|
||||
int k2 = i2 - (position.getY() + i);
|
||||
int l2 = 1 - k2 / 2;
|
||||
|
||||
for (int i3 = position.getX() - l2; i3 <= position.getX() + l2; ++i3)
|
||||
{
|
||||
int j1 = i3 - position.getX();
|
||||
|
||||
for (int k1 = position.getZ() - l2; k1 <= position.getZ() + l2; ++k1)
|
||||
{
|
||||
int l1 = k1 - position.getZ();
|
||||
|
||||
if (Math.abs(j1) != l2 || Math.abs(l1) != l2 || rand.zrange(2) != 0 && k2 != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(i3, i2, k1);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, leavesBlock.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j2 = 0; j2 < i; ++j2)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(j2)).getBlock();
|
||||
|
||||
if (block2.getMaterial() == Material.air || block2.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(j2), logBlock);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
218
java/src/game/worldgen/tree/WorldGenDarkOak.java
Executable file
218
java/src/game/worldgen/tree/WorldGenDarkOak.java
Executable file
|
@ -0,0 +1,218 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenDarkOak extends WorldGenTree
|
||||
{
|
||||
private static final State logBlock = Blocks.dark_oak_log.getState(); // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.DARK_OAK);
|
||||
private static final State leavesBlock = Blocks.dark_oak_leaves.getState()
|
||||
// .withProperty(BlockNewLeaf.VARIANT, BlockPlanks.EnumType.DARK_OAK)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenDarkOak(boolean notify)
|
||||
{
|
||||
super(notify);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + rand.zrange(2) + 6;
|
||||
int j = position.getX();
|
||||
int k = position.getY();
|
||||
int l = position.getZ();
|
||||
|
||||
if (k >= 1 && k + i + 1 < 512)
|
||||
{
|
||||
BlockPos blockpos = position.down();
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block != Blocks.grass && block != Blocks.dirt)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!this.func_181638_a(worldIn, position, i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBaseBlock(worldIn, blockpos);
|
||||
this.setBaseBlock(worldIn, blockpos.east());
|
||||
this.setBaseBlock(worldIn, blockpos.south());
|
||||
this.setBaseBlock(worldIn, blockpos.south().east());
|
||||
Facing enumfacing = Facing.Plane.HORIZONTAL.random(rand);
|
||||
int i1 = i - rand.zrange(4);
|
||||
int j1 = 2 - rand.zrange(3);
|
||||
int k1 = j;
|
||||
int l1 = l;
|
||||
int i2 = k + i - 1;
|
||||
|
||||
for (int j2 = 0; j2 < i; ++j2)
|
||||
{
|
||||
if (j2 >= i1 && j1 > 0)
|
||||
{
|
||||
k1 += enumfacing.getFrontOffsetX();
|
||||
l1 += enumfacing.getFrontOffsetZ();
|
||||
--j1;
|
||||
}
|
||||
|
||||
int k2 = k + j2;
|
||||
BlockPos blockpos1 = new BlockPos(k1, k2, l1);
|
||||
Material material = worldIn.getState(blockpos1).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.func_181639_b(worldIn, blockpos1);
|
||||
this.func_181639_b(worldIn, blockpos1.east());
|
||||
this.func_181639_b(worldIn, blockpos1.south());
|
||||
this.func_181639_b(worldIn, blockpos1.east().south());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i3 = -2; i3 <= 0; ++i3)
|
||||
{
|
||||
for (int l3 = -2; l3 <= 0; ++l3)
|
||||
{
|
||||
int k4 = -1;
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, 1 + l1 - l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, 1 + l1 - l3);
|
||||
|
||||
if ((i3 > -2 || l3 > -1) && (i3 != -1 || l3 != -2))
|
||||
{
|
||||
k4 = 1;
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, 1 + l1 - l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, 1 + l1 - l3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.chance())
|
||||
{
|
||||
this.func_150526_a(worldIn, k1, i2 + 2, l1);
|
||||
this.func_150526_a(worldIn, k1 + 1, i2 + 2, l1);
|
||||
this.func_150526_a(worldIn, k1 + 1, i2 + 2, l1 + 1);
|
||||
this.func_150526_a(worldIn, k1, i2 + 2, l1 + 1);
|
||||
}
|
||||
|
||||
for (int j3 = -3; j3 <= 4; ++j3)
|
||||
{
|
||||
for (int i4 = -3; i4 <= 4; ++i4)
|
||||
{
|
||||
if ((j3 != -3 || i4 != -3) && (j3 != -3 || i4 != 4) && (j3 != 4 || i4 != -3) && (j3 != 4 || i4 != 4) && (Math.abs(j3) < 3 || Math.abs(i4) < 3))
|
||||
{
|
||||
this.func_150526_a(worldIn, k1 + j3, i2, l1 + i4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int k3 = -1; k3 <= 2; ++k3)
|
||||
{
|
||||
for (int j4 = -1; j4 <= 2; ++j4)
|
||||
{
|
||||
if ((k3 < 0 || k3 > 1 || j4 < 0 || j4 > 1) && rand.zrange(3) <= 0)
|
||||
{
|
||||
int l4 = rand.zrange(3) + 2;
|
||||
|
||||
for (int i5 = 0; i5 < l4; ++i5)
|
||||
{
|
||||
this.func_181639_b(worldIn, new BlockPos(j + k3, i2 - i5 - 1, l + j4));
|
||||
}
|
||||
|
||||
for (int j5 = -1; j5 <= 1; ++j5)
|
||||
{
|
||||
for (int l2 = -1; l2 <= 1; ++l2)
|
||||
{
|
||||
this.func_150526_a(worldIn, k1 + k3 + j5, i2, l1 + j4 + l2);
|
||||
}
|
||||
}
|
||||
|
||||
for (int k5 = -2; k5 <= 2; ++k5)
|
||||
{
|
||||
for (int l5 = -2; l5 <= 2; ++l5)
|
||||
{
|
||||
if (Math.abs(k5) != 2 || Math.abs(l5) != 2)
|
||||
{
|
||||
this.func_150526_a(worldIn, k1 + k3 + k5, i2 - 1, l1 + j4 + l5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean func_181638_a(WorldServer p_181638_1_, BlockPos p_181638_2_, int p_181638_3_)
|
||||
{
|
||||
int i = p_181638_2_.getX();
|
||||
int j = p_181638_2_.getY();
|
||||
int k = p_181638_2_.getZ();
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = 0; l <= p_181638_3_ + 1; ++l)
|
||||
{
|
||||
int i1 = 1;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
i1 = 0;
|
||||
}
|
||||
|
||||
if (l >= p_181638_3_ - 1)
|
||||
{
|
||||
i1 = 2;
|
||||
}
|
||||
|
||||
for (int j1 = -i1; j1 <= i1; ++j1)
|
||||
{
|
||||
for (int k1 = -i1; k1 <= i1; ++k1)
|
||||
{
|
||||
if (!this.canBeReplaced(p_181638_1_.getState(blockpos$mutableblockpos.set(i + j1, j + l, k + k1)).getBlock()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void func_181639_b(WorldServer p_181639_1_, BlockPos p_181639_2_)
|
||||
{
|
||||
if (this.canBeReplaced(p_181639_1_.getState(p_181639_2_).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181639_1_, p_181639_2_, logBlock);
|
||||
}
|
||||
}
|
||||
|
||||
private void func_150526_a(WorldServer worldIn, int p_150526_2_, int p_150526_3_, int p_150526_4_)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(p_150526_2_, p_150526_3_, p_150526_4_);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, leavesBlock.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
154
java/src/game/worldgen/tree/WorldGenHugeTree.java
Executable file
154
java/src/game/worldgen/tree/WorldGenHugeTree.java
Executable file
|
@ -0,0 +1,154 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public abstract class WorldGenHugeTree extends WorldGenTree
|
||||
{
|
||||
/** The base height of the tree */
|
||||
protected final int baseHeight;
|
||||
|
||||
/** Sets the metadata for the wood blocks used */
|
||||
protected final State woodMetadata;
|
||||
|
||||
/** Sets the metadata for the leaves used in huge trees */
|
||||
protected final State leavesMetadata;
|
||||
protected int extraRandomHeight;
|
||||
|
||||
public WorldGenHugeTree(boolean notify, int base, int extra, State log, State leaves)
|
||||
{
|
||||
super(notify);
|
||||
this.baseHeight = base;
|
||||
this.extraRandomHeight = extra;
|
||||
this.woodMetadata = log;
|
||||
this.leavesMetadata = leaves.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
protected int func_150533_a(Random p_150533_1_)
|
||||
{
|
||||
int i = p_150533_1_.zrange(3) + this.baseHeight;
|
||||
|
||||
if (this.extraRandomHeight > 1)
|
||||
{
|
||||
i += p_150533_1_.zrange(this.extraRandomHeight);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private boolean func_175926_c(WorldServer worldIn, BlockPos p_175926_2_, int p_175926_3_)
|
||||
{
|
||||
boolean flag = true;
|
||||
|
||||
if (p_175926_2_.getY() >= 1 && p_175926_2_.getY() + p_175926_3_ + 1 <= 512)
|
||||
{
|
||||
for (int i = 0; i <= 1 + p_175926_3_; ++i)
|
||||
{
|
||||
int j = 2;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
j = 1;
|
||||
}
|
||||
else if (i >= 1 + p_175926_3_ - 2)
|
||||
{
|
||||
j = 2;
|
||||
}
|
||||
|
||||
for (int k = -j; k <= j && flag; ++k)
|
||||
{
|
||||
for (int l = -j; l <= j && flag; ++l)
|
||||
{
|
||||
if (p_175926_2_.getY() + i < 0 || p_175926_2_.getY() + i >= 512 || !this.canBeReplaced(worldIn.getState(p_175926_2_.add(k, i, l)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean func_175927_a(BlockPos p_175927_1_, WorldServer worldIn)
|
||||
{
|
||||
BlockPos blockpos = p_175927_1_.down();
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if ((block == Blocks.grass || block == Blocks.dirt) && p_175927_1_.getY() >= 2)
|
||||
{
|
||||
this.setBaseBlock(worldIn, blockpos);
|
||||
this.setBaseBlock(worldIn, blockpos.east());
|
||||
this.setBaseBlock(worldIn, blockpos.south());
|
||||
this.setBaseBlock(worldIn, blockpos.south().east());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean func_175929_a(WorldServer worldIn, Random p_175929_2_, BlockPos p_175929_3_, int p_175929_4_)
|
||||
{
|
||||
return this.func_175926_c(worldIn, p_175929_3_, p_175929_4_) && this.func_175927_a(p_175929_3_, worldIn);
|
||||
}
|
||||
|
||||
protected void func_175925_a(WorldServer worldIn, BlockPos p_175925_2_, int p_175925_3_)
|
||||
{
|
||||
int i = p_175925_3_ * p_175925_3_;
|
||||
|
||||
for (int j = -p_175925_3_; j <= p_175925_3_ + 1; ++j)
|
||||
{
|
||||
for (int k = -p_175925_3_; k <= p_175925_3_ + 1; ++k)
|
||||
{
|
||||
int l = j - 1;
|
||||
int i1 = k - 1;
|
||||
|
||||
if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
|
||||
{
|
||||
BlockPos blockpos = p_175925_2_.add(j, 0, k);
|
||||
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void func_175928_b(WorldServer worldIn, BlockPos p_175928_2_, int p_175928_3_)
|
||||
{
|
||||
int i = p_175928_3_ * p_175928_3_;
|
||||
|
||||
for (int j = -p_175928_3_; j <= p_175928_3_; ++j)
|
||||
{
|
||||
for (int k = -p_175928_3_; k <= p_175928_3_; ++k)
|
||||
{
|
||||
if (j * j + k * k <= i)
|
||||
{
|
||||
BlockPos blockpos = p_175928_2_.add(j, 0, k);
|
||||
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
java/src/game/worldgen/tree/WorldGenJungle.java
Executable file
133
java/src/game/worldgen/tree/WorldGenJungle.java
Executable file
|
@ -0,0 +1,133 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.properties.PropertyBool;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenJungle extends WorldGenHugeTree
|
||||
{
|
||||
public WorldGenJungle(boolean p_i46448_1_, int p_i46448_2_, int p_i46448_3_, State p_i46448_4_, State p_i46448_5_)
|
||||
{
|
||||
super(p_i46448_1_, p_i46448_2_, p_i46448_3_, p_i46448_4_, p_i46448_5_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = this.func_150533_a(rand);
|
||||
|
||||
if (!this.func_175929_a(worldIn, rand, position, i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_175930_c(worldIn, position.up(i), 2);
|
||||
|
||||
for (int j = position.getY() + i - 2 - rand.zrange(4); j > position.getY() + i / 2; j -= 2 + rand.zrange(4))
|
||||
{
|
||||
float f = rand.floatv() * (float)Math.PI * 2.0F;
|
||||
int k = position.getX() + (int)(0.5F + ExtMath.cos(f) * 4.0F);
|
||||
int l = position.getZ() + (int)(0.5F + ExtMath.sin(f) * 4.0F);
|
||||
|
||||
for (int i1 = 0; i1 < 5; ++i1)
|
||||
{
|
||||
k = position.getX() + (int)(1.5F + ExtMath.cos(f) * (float)i1);
|
||||
l = position.getZ() + (int)(1.5F + ExtMath.sin(f) * (float)i1);
|
||||
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(k, j - 3 + i1 / 2, l), this.woodMetadata);
|
||||
}
|
||||
|
||||
int j2 = 1 + rand.zrange(2);
|
||||
int j1 = j;
|
||||
|
||||
for (int k1 = j - j2; k1 <= j1; ++k1)
|
||||
{
|
||||
int l1 = k1 - j1;
|
||||
this.func_175928_b(worldIn, new BlockPos(k, k1, l), 1 - l1);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i2 = 0; i2 < i; ++i2)
|
||||
{
|
||||
BlockPos blockpos = position.up(i2);
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos.west(), BlockVine.EAST);
|
||||
this.func_181632_a(worldIn, rand, blockpos.north(), BlockVine.SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
if (i2 < i - 1)
|
||||
{
|
||||
BlockPos blockpos1 = blockpos.east();
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos1).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos1, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos1.east(), BlockVine.WEST);
|
||||
this.func_181632_a(worldIn, rand, blockpos1.north(), BlockVine.SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos blockpos2 = blockpos.south().east();
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos2).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos2, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos2.east(), BlockVine.WEST);
|
||||
this.func_181632_a(worldIn, rand, blockpos2.south(), BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos blockpos3 = blockpos.south();
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos3).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos3, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos3.west(), BlockVine.EAST);
|
||||
this.func_181632_a(worldIn, rand, blockpos3.south(), BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181632_a(WorldServer p_181632_1_, Random p_181632_2_, BlockPos p_181632_3_, PropertyBool p_181632_4_)
|
||||
{
|
||||
if (p_181632_2_.zrange(3) > 0 && p_181632_1_.isAirBlock(p_181632_3_))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181632_1_, p_181632_3_, Blocks.vine.getState().withProperty(p_181632_4_, Boolean.valueOf(true)));
|
||||
}
|
||||
}
|
||||
|
||||
private void func_175930_c(WorldServer worldIn, BlockPos p_175930_2_, int p_175930_3_)
|
||||
{
|
||||
int i = 2;
|
||||
|
||||
for (int j = -i; j <= 0; ++j)
|
||||
{
|
||||
this.func_175925_a(worldIn, p_175930_2_.up(j), p_175930_3_ + 1 - j);
|
||||
}
|
||||
}
|
||||
}
|
143
java/src/game/worldgen/tree/WorldGenPine.java
Executable file
143
java/src/game/worldgen/tree/WorldGenPine.java
Executable file
|
@ -0,0 +1,143 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.block.BlockDirt;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenPine extends WorldGenHugeTree
|
||||
{
|
||||
private static final State field_181633_e = Blocks.spruce_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
||||
private static final State field_181634_f = Blocks.spruce_leaves.getState(); // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE); // .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
|
||||
private static final State field_181635_g = Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL);
|
||||
private boolean useBaseHeight;
|
||||
|
||||
public WorldGenPine(boolean p_i45457_1_, boolean p_i45457_2_)
|
||||
{
|
||||
super(p_i45457_1_, 13, 15, field_181633_e, field_181634_f);
|
||||
this.useBaseHeight = p_i45457_2_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = this.func_150533_a(rand);
|
||||
|
||||
if (!this.func_175929_a(worldIn, rand, position, i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_150541_c(worldIn, position.getX(), position.getZ(), position.getY() + i, 0, rand);
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
Block block = worldIn.getState(position.up(j)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(j), this.woodMetadata);
|
||||
}
|
||||
|
||||
if (j < i - 1)
|
||||
{
|
||||
block = worldIn.getState(position.add(1, j, 0)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 0), this.woodMetadata);
|
||||
}
|
||||
|
||||
block = worldIn.getState(position.add(1, j, 1)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 1), this.woodMetadata);
|
||||
}
|
||||
|
||||
block = worldIn.getState(position.add(0, j, 1)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(0, j, 1), this.woodMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_150541_c(WorldServer worldIn, int p_150541_2_, int p_150541_3_, int p_150541_4_, int p_150541_5_, Random p_150541_6_)
|
||||
{
|
||||
int i = p_150541_6_.zrange(5) + (this.useBaseHeight ? this.baseHeight : 3);
|
||||
int j = 0;
|
||||
|
||||
for (int k = p_150541_4_ - i; k <= p_150541_4_; ++k)
|
||||
{
|
||||
int l = p_150541_4_ - k;
|
||||
int i1 = p_150541_5_ + ExtMath.floorf((float)l / (float)i * 3.5F);
|
||||
this.func_175925_a(worldIn, new BlockPos(p_150541_2_, k, p_150541_3_), i1 + (l > 0 && i1 == j && (k & 1) == 0 ? 1 : 0));
|
||||
j = i1;
|
||||
}
|
||||
}
|
||||
|
||||
public void finish(WorldServer worldIn, Random p_180711_2_, BlockPos p_180711_3_)
|
||||
{
|
||||
this.func_175933_b(worldIn, p_180711_3_.west().north());
|
||||
this.func_175933_b(worldIn, p_180711_3_.east(2).north());
|
||||
this.func_175933_b(worldIn, p_180711_3_.west().south(2));
|
||||
this.func_175933_b(worldIn, p_180711_3_.east(2).south(2));
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
int j = p_180711_2_.zrange(64);
|
||||
int k = j % 8;
|
||||
int l = j / 8;
|
||||
|
||||
if (k == 0 || k == 7 || l == 0 || l == 7)
|
||||
{
|
||||
this.func_175933_b(worldIn, p_180711_3_.add(-3 + k, 0, -3 + l));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_175933_b(WorldServer worldIn, BlockPos p_175933_2_)
|
||||
{
|
||||
for (int i = -2; i <= 2; ++i)
|
||||
{
|
||||
for (int j = -2; j <= 2; ++j)
|
||||
{
|
||||
if (Math.abs(i) != 2 || Math.abs(j) != 2)
|
||||
{
|
||||
this.func_175934_c(worldIn, p_175933_2_.add(i, 0, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_175934_c(WorldServer worldIn, BlockPos p_175934_2_)
|
||||
{
|
||||
for (int i = 2; i >= -3; --i)
|
||||
{
|
||||
BlockPos blockpos = p_175934_2_.up(i);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block == Blocks.grass || block == Blocks.dirt)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181635_g);
|
||||
break;
|
||||
}
|
||||
|
||||
if (block.getMaterial() != Material.air && i < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
219
java/src/game/worldgen/tree/WorldGenSavanna.java
Executable file
219
java/src/game/worldgen/tree/WorldGenSavanna.java
Executable file
|
@ -0,0 +1,219 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenSavanna extends WorldGenTree
|
||||
{
|
||||
private static final State field_181643_a = Blocks.acacia_log.getState();
|
||||
// .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.ACACIA);
|
||||
private static final State field_181644_b = Blocks.acacia_leaves.getState()
|
||||
// .withProperty(BlockNewLeaf.VARIANT, BlockPlanks.EnumType.ACACIA)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenSavanna(boolean p_i45463_1_)
|
||||
{
|
||||
super(p_i45463_1_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + rand.zrange(3) + 5;
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block == Blocks.grass || block == Blocks.dirt) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
Facing enumfacing = Facing.Plane.HORIZONTAL.random(rand);
|
||||
int k2 = i - rand.zrange(4) - 1;
|
||||
int l2 = 3 - rand.zrange(3);
|
||||
int i3 = position.getX();
|
||||
int j1 = position.getZ();
|
||||
int k1 = 0;
|
||||
|
||||
for (int l1 = 0; l1 < i; ++l1)
|
||||
{
|
||||
int i2 = position.getY() + l1;
|
||||
|
||||
if (l1 >= k2 && l2 > 0)
|
||||
{
|
||||
i3 += enumfacing.getFrontOffsetX();
|
||||
j1 += enumfacing.getFrontOffsetZ();
|
||||
--l2;
|
||||
}
|
||||
|
||||
BlockPos blockpos = new BlockPos(i3, i2, j1);
|
||||
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.func_181642_b(worldIn, blockpos);
|
||||
k1 = i2;
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos blockpos2 = new BlockPos(i3, k1, j1);
|
||||
|
||||
for (int j3 = -3; j3 <= 3; ++j3)
|
||||
{
|
||||
for (int i4 = -3; i4 <= 3; ++i4)
|
||||
{
|
||||
if (Math.abs(j3) != 3 || Math.abs(i4) != 3)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos2.add(j3, 0, i4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockpos2 = blockpos2.up();
|
||||
|
||||
for (int k3 = -1; k3 <= 1; ++k3)
|
||||
{
|
||||
for (int j4 = -1; j4 <= 1; ++j4)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos2.add(k3, 0, j4));
|
||||
}
|
||||
}
|
||||
|
||||
this.func_175924_b(worldIn, blockpos2.east(2));
|
||||
this.func_175924_b(worldIn, blockpos2.west(2));
|
||||
this.func_175924_b(worldIn, blockpos2.south(2));
|
||||
this.func_175924_b(worldIn, blockpos2.north(2));
|
||||
i3 = position.getX();
|
||||
j1 = position.getZ();
|
||||
Facing enumfacing1 = Facing.Plane.HORIZONTAL.random(rand);
|
||||
|
||||
if (enumfacing1 != enumfacing)
|
||||
{
|
||||
int l3 = k2 - rand.zrange(2) - 1;
|
||||
int k4 = 1 + rand.zrange(3);
|
||||
k1 = 0;
|
||||
|
||||
for (int l4 = l3; l4 < i && k4 > 0; --k4)
|
||||
{
|
||||
if (l4 >= 1)
|
||||
{
|
||||
int j2 = position.getY() + l4;
|
||||
i3 += enumfacing1.getFrontOffsetX();
|
||||
j1 += enumfacing1.getFrontOffsetZ();
|
||||
BlockPos blockpos1 = new BlockPos(i3, j2, j1);
|
||||
Material material1 = worldIn.getState(blockpos1).getBlock().getMaterial();
|
||||
|
||||
if (material1 == Material.air || material1 == Material.leaves)
|
||||
{
|
||||
this.func_181642_b(worldIn, blockpos1);
|
||||
k1 = j2;
|
||||
}
|
||||
}
|
||||
|
||||
++l4;
|
||||
}
|
||||
|
||||
if (k1 > 0)
|
||||
{
|
||||
BlockPos blockpos3 = new BlockPos(i3, k1, j1);
|
||||
|
||||
for (int i5 = -2; i5 <= 2; ++i5)
|
||||
{
|
||||
for (int k5 = -2; k5 <= 2; ++k5)
|
||||
{
|
||||
if (Math.abs(i5) != 2 || Math.abs(k5) != 2)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos3.add(i5, 0, k5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockpos3 = blockpos3.up();
|
||||
|
||||
for (int j5 = -1; j5 <= 1; ++j5)
|
||||
{
|
||||
for (int l5 = -1; l5 <= 1; ++l5)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos3.add(j5, 0, l5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181642_b(WorldServer p_181642_1_, BlockPos p_181642_2_)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181642_1_, p_181642_2_, field_181643_a);
|
||||
}
|
||||
|
||||
private void func_175924_b(WorldServer worldIn, BlockPos p_175924_2_)
|
||||
{
|
||||
Material material = worldIn.getState(p_175924_2_).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, p_175924_2_, field_181644_b.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(p_175924_2_)));
|
||||
}
|
||||
}
|
||||
}
|
201
java/src/game/worldgen/tree/WorldGenSwamp.java
Executable file
201
java/src/game/worldgen/tree/WorldGenSwamp.java
Executable file
|
@ -0,0 +1,201 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.properties.PropertyBool;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenSwamp extends WorldGenTree
|
||||
{
|
||||
private static final State field_181648_a = Blocks.oak_log.getState();
|
||||
// .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK);
|
||||
private static final State field_181649_b = Blocks.oak_leaves.getState()
|
||||
// .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenSwamp()
|
||||
{
|
||||
super(false);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = rand.zrange(4) + 5; worldIn.getState(position.down()).getBlock().getMaterial() == Material.water; position = position.down())
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 3;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
Block block = worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock();
|
||||
|
||||
if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves)
|
||||
{
|
||||
if (block != Blocks.water && block != Blocks.flowing_water)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else if (j > position.getY())
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block1 == Blocks.grass || block1 == Blocks.dirt) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
|
||||
for (int l1 = position.getY() - 3 + i; l1 <= position.getY() + i; ++l1)
|
||||
{
|
||||
int k2 = l1 - (position.getY() + i);
|
||||
int i3 = 2 - k2 / 2;
|
||||
|
||||
for (int k3 = position.getX() - i3; k3 <= position.getX() + i3; ++k3)
|
||||
{
|
||||
int l3 = k3 - position.getX();
|
||||
|
||||
for (int j1 = position.getZ() - i3; j1 <= position.getZ() + i3; ++j1)
|
||||
{
|
||||
int k1 = j1 - position.getZ();
|
||||
|
||||
if (Math.abs(l3) != i3 || Math.abs(k1) != i3 || rand.zrange(2) != 0 && k2 != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(k3, l1, j1);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181649_b.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i2 = 0; i2 < i; ++i2)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(i2)).getBlock();
|
||||
|
||||
if (block2.getMaterial() == Material.air || block2.getMaterial() == Material.leaves || block2 == Blocks.flowing_water || block2 == Blocks.water)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(i2), field_181648_a);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j2 = position.getY() - 3 + i; j2 <= position.getY() + i; ++j2)
|
||||
{
|
||||
int l2 = j2 - (position.getY() + i);
|
||||
int j3 = 2 - l2 / 2;
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int i4 = position.getX() - j3; i4 <= position.getX() + j3; ++i4)
|
||||
{
|
||||
for (int j4 = position.getZ() - j3; j4 <= position.getZ() + j3; ++j4)
|
||||
{
|
||||
blockpos$mutableblockpos1.set(i4, j2, j4);
|
||||
|
||||
if (worldIn.getState(blockpos$mutableblockpos1).getBlock().getMaterial() == Material.leaves)
|
||||
{
|
||||
BlockPos blockpos3 = blockpos$mutableblockpos1.west();
|
||||
BlockPos blockpos4 = blockpos$mutableblockpos1.east();
|
||||
BlockPos blockpos1 = blockpos$mutableblockpos1.north();
|
||||
BlockPos blockpos2 = blockpos$mutableblockpos1.south();
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos3).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos3, BlockVine.EAST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos4).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos4, BlockVine.WEST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos1).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos1, BlockVine.SOUTH);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos2).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos2, BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181647_a(WorldServer p_181647_1_, BlockPos p_181647_2_, PropertyBool p_181647_3_)
|
||||
{
|
||||
State iblockstate = Blocks.vine.getState().withProperty(p_181647_3_, Boolean.valueOf(true));
|
||||
this.setBlockAndNotifyAdequately(p_181647_1_, p_181647_2_, iblockstate);
|
||||
int i = 4;
|
||||
|
||||
for (p_181647_2_ = p_181647_2_.down(); p_181647_1_.getState(p_181647_2_).getBlock().getMaterial() == Material.air && i > 0; --i)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181647_1_, p_181647_2_, iblockstate);
|
||||
p_181647_2_ = p_181647_2_.down();
|
||||
}
|
||||
}
|
||||
}
|
137
java/src/game/worldgen/tree/WorldGenTaiga1.java
Executable file
137
java/src/game/worldgen/tree/WorldGenTaiga1.java
Executable file
|
@ -0,0 +1,137 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenTaiga1 extends WorldGenTree
|
||||
{
|
||||
private static final State field_181636_a = Blocks.spruce_log.getState();
|
||||
// .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
||||
private static final State field_181637_b = Blocks.spruce_leaves.getState()
|
||||
// .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenTaiga1()
|
||||
{
|
||||
super(false);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(5) + 7;
|
||||
int j = i - rand.zrange(2) - 3;
|
||||
int k = i - j;
|
||||
int l = 1 + rand.zrange(k + 1);
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int i1 = position.getY(); i1 <= position.getY() + 1 + i && flag; ++i1)
|
||||
{
|
||||
int j1 = 1;
|
||||
|
||||
if (i1 - position.getY() < j)
|
||||
{
|
||||
j1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
j1 = l;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1 && flag; ++k1)
|
||||
{
|
||||
for (int l1 = position.getZ() - j1; l1 <= position.getZ() + j1 && flag; ++l1)
|
||||
{
|
||||
if (i1 >= 0 && i1 < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(k1, i1, l1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block == Blocks.grass || block == Blocks.dirt) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
int k2 = 0;
|
||||
|
||||
for (int l2 = position.getY() + i; l2 >= position.getY() + j; --l2)
|
||||
{
|
||||
for (int j3 = position.getX() - k2; j3 <= position.getX() + k2; ++j3)
|
||||
{
|
||||
int k3 = j3 - position.getX();
|
||||
|
||||
for (int i2 = position.getZ() - k2; i2 <= position.getZ() + k2; ++i2)
|
||||
{
|
||||
int j2 = i2 - position.getZ();
|
||||
|
||||
if (Math.abs(k3) != k2 || Math.abs(j2) != k2 || k2 <= 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(j3, l2, i2);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181637_b.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k2 >= 1 && l2 == position.getY() + j + 1)
|
||||
{
|
||||
--k2;
|
||||
}
|
||||
else if (k2 < l)
|
||||
{
|
||||
++k2;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i3 = 0; i3 < i - 1; ++i3)
|
||||
{
|
||||
Block block1 = worldIn.getState(position.up(i3)).getBlock();
|
||||
|
||||
if (block1.getMaterial() == Material.air || block1.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(i3), field_181636_a);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
152
java/src/game/worldgen/tree/WorldGenTaiga2.java
Executable file
152
java/src/game/worldgen/tree/WorldGenTaiga2.java
Executable file
|
@ -0,0 +1,152 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenTaiga2 extends WorldGenTree
|
||||
{
|
||||
private static final State field_181645_a = Blocks.spruce_log.getState();
|
||||
// .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
||||
private static final State field_181646_b = Blocks.spruce_leaves.getState()
|
||||
// .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenTaiga2(boolean p_i2025_1_)
|
||||
{
|
||||
super(p_i2025_1_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(4) + 6;
|
||||
int j = 1 + rand.zrange(2);
|
||||
int k = i - j;
|
||||
int l = 2 + rand.zrange(2);
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int i1 = position.getY(); i1 <= position.getY() + 1 + i && flag; ++i1)
|
||||
{
|
||||
int j1 = 1;
|
||||
|
||||
if (i1 - position.getY() < j)
|
||||
{
|
||||
j1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
j1 = l;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1 && flag; ++k1)
|
||||
{
|
||||
for (int l1 = position.getZ() - j1; l1 <= position.getZ() + j1 && flag; ++l1)
|
||||
{
|
||||
if (i1 >= 0 && i1 < 512)
|
||||
{
|
||||
Block block = worldIn.getState(blockpos$mutableblockpos.set(k1, i1, l1)).getBlock();
|
||||
|
||||
if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block1 == Blocks.grass || block1 == Blocks.dirt || block1 == Blocks.farmland) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
int i3 = rand.zrange(2);
|
||||
int j3 = 1;
|
||||
int k3 = 0;
|
||||
|
||||
for (int l3 = 0; l3 <= k; ++l3)
|
||||
{
|
||||
int j4 = position.getY() + i - l3;
|
||||
|
||||
for (int i2 = position.getX() - i3; i2 <= position.getX() + i3; ++i2)
|
||||
{
|
||||
int j2 = i2 - position.getX();
|
||||
|
||||
for (int k2 = position.getZ() - i3; k2 <= position.getZ() + i3; ++k2)
|
||||
{
|
||||
int l2 = k2 - position.getZ();
|
||||
|
||||
if (Math.abs(j2) != i3 || Math.abs(l2) != i3 || i3 <= 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(i2, j4, k2);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181646_b.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i3 >= j3)
|
||||
{
|
||||
i3 = k3;
|
||||
k3 = 1;
|
||||
++j3;
|
||||
|
||||
if (j3 > l)
|
||||
{
|
||||
j3 = l;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++i3;
|
||||
}
|
||||
}
|
||||
|
||||
int i4 = rand.zrange(3);
|
||||
|
||||
for (int k4 = 0; k4 < i - i4; ++k4)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(k4)).getBlock();
|
||||
|
||||
if (block2.getMaterial() == Material.air || block2.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(k4), field_181645_a);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
41
java/src/game/worldgen/tree/WorldGenTree.java
Executable file
41
java/src/game/worldgen/tree/WorldGenTree.java
Executable file
|
@ -0,0 +1,41 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLog;
|
||||
import game.block.BlockSapling;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public abstract class WorldGenTree extends FeatureGenerator
|
||||
{
|
||||
public WorldGenTree(boolean notify)
|
||||
{
|
||||
super(notify);
|
||||
}
|
||||
|
||||
protected boolean canBeReplaced(Block block)
|
||||
{
|
||||
Material material = block.getMaterial();
|
||||
return material == Material.air || material == Material.leaves || block == Blocks.grass || block == Blocks.dirt || block instanceof BlockLog || block instanceof BlockSapling || block == Blocks.vine;
|
||||
}
|
||||
|
||||
public void prepare()
|
||||
{
|
||||
}
|
||||
|
||||
public void finish(WorldServer worldIn, Random random, BlockPos pos)
|
||||
{
|
||||
}
|
||||
|
||||
protected void setBaseBlock(WorldServer worldIn, BlockPos pos)
|
||||
{
|
||||
if (worldIn.getState(pos) != worldIn.dimension.getTop())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, pos, worldIn.dimension.getTop()); // Blocks.dirt.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue