initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
35
java/src/game/worldgen/foliage/FeatureDoublePlant.java
Executable file
35
java/src/game/worldgen/foliage/FeatureDoublePlant.java
Executable file
|
@ -0,0 +1,35 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockDoublePlant;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class FeatureDoublePlant
|
||||
{
|
||||
private BlockDoublePlant.EnumPlantType type;
|
||||
|
||||
public void setPlantType(BlockDoublePlant.EnumPlantType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
boolean flag = false;
|
||||
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 254) && Blocks.double_plant.canPlaceBlockAt(worldIn, blockpos))
|
||||
{
|
||||
Blocks.double_plant.placeAt(worldIn, blockpos, this.type, 2);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
}
|
223
java/src/game/worldgen/foliage/WorldGenBigMushroom.java
Executable file
223
java/src/game/worldgen/foliage/WorldGenBigMushroom.java
Executable file
|
@ -0,0 +1,223 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockHugeMushroom;
|
||||
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 class WorldGenBigMushroom extends FeatureGenerator
|
||||
{
|
||||
/** The mushroom type. 0 for brown, 1 for red. */
|
||||
private Block mushroomType;
|
||||
|
||||
public WorldGenBigMushroom(Block p_i46449_1_)
|
||||
{
|
||||
super(true);
|
||||
this.mushroomType = p_i46449_1_;
|
||||
}
|
||||
|
||||
public WorldGenBigMushroom()
|
||||
{
|
||||
super(false);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
// if (this.mushroomType == null)
|
||||
// {
|
||||
this.mushroomType = rand.chance() ? Blocks.brown_mushroom_block : Blocks.red_mushroom_block;
|
||||
// }
|
||||
|
||||
int i = rand.zrange(3) + 4;
|
||||
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 = 3;
|
||||
|
||||
if (j <= position.getY() + 3)
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if (block1 != Blocks.dirt && block1 != Blocks.grass && block1 != Blocks.mycelium)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int k2 = position.getY() + i;
|
||||
|
||||
if (this.mushroomType == Blocks.red_mushroom_block)
|
||||
{
|
||||
k2 = position.getY() + i - 3;
|
||||
}
|
||||
|
||||
for (int l2 = k2; l2 <= position.getY() + i; ++l2)
|
||||
{
|
||||
int j3 = 1;
|
||||
|
||||
if (l2 < position.getY() + i)
|
||||
{
|
||||
++j3;
|
||||
}
|
||||
|
||||
if (this.mushroomType == Blocks.brown_mushroom_block)
|
||||
{
|
||||
j3 = 3;
|
||||
}
|
||||
|
||||
int k3 = position.getX() - j3;
|
||||
int l3 = position.getX() + j3;
|
||||
int j1 = position.getZ() - j3;
|
||||
int k1 = position.getZ() + j3;
|
||||
|
||||
for (int l1 = k3; l1 <= l3; ++l1)
|
||||
{
|
||||
for (int i2 = j1; i2 <= k1; ++i2)
|
||||
{
|
||||
int j2 = 5;
|
||||
|
||||
if (l1 == k3)
|
||||
{
|
||||
--j2;
|
||||
}
|
||||
else if (l1 == l3)
|
||||
{
|
||||
++j2;
|
||||
}
|
||||
|
||||
if (i2 == j1)
|
||||
{
|
||||
j2 -= 3;
|
||||
}
|
||||
else if (i2 == k1)
|
||||
{
|
||||
j2 += 3;
|
||||
}
|
||||
|
||||
BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
|
||||
|
||||
if (this.mushroomType == Blocks.brown_mushroom_block || l2 < position.getY() + i)
|
||||
{
|
||||
if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() - (j3 - 1) && i2 == j1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == k3 && i2 == position.getZ() - (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() + (j3 - 1) && i2 == j1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
|
||||
}
|
||||
|
||||
if (l1 == l3 && i2 == position.getZ() - (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() - (j3 - 1) && i2 == k1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == k3 && i2 == position.getZ() + (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() + (j3 - 1) && i2 == k1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
|
||||
}
|
||||
|
||||
if (l1 == l3 && i2 == position.getZ() + (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
|
||||
}
|
||||
}
|
||||
|
||||
if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
|
||||
}
|
||||
|
||||
if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(l1, l2, i2);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.mushroomType.getState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i3 = 0; i3 < i; ++i3)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(i3)).getBlock();
|
||||
|
||||
if (!block2.isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(i3), this.mushroomType.getState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
33
java/src/game/worldgen/foliage/WorldGenCactus.java
Executable file
33
java/src/game/worldgen/foliage/WorldGenCactus.java
Executable file
|
@ -0,0 +1,33 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenCactus extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos))
|
||||
{
|
||||
int j = 1 + rand.zrange(rand.zrange(3) + 1);
|
||||
|
||||
for (int k = 0; k < j; ++k)
|
||||
{
|
||||
if (Blocks.cactus.canBlockStay(worldIn, blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos.up(k), Blocks.cactus.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
34
java/src/game/worldgen/foliage/WorldGenDeadBush.java
Executable file
34
java/src/game/worldgen/foliage/WorldGenDeadBush.java
Executable file
|
@ -0,0 +1,34 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.Block;
|
||||
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 class WorldGenDeadBush extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
Block block;
|
||||
|
||||
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && Blocks.deadbush.canBlockStay(worldIn, blockpos, Blocks.deadbush.getState()))
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.deadbush.getState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
40
java/src/game/worldgen/foliage/WorldGenFlowers.java
Executable file
40
java/src/game/worldgen/foliage/WorldGenFlowers.java
Executable file
|
@ -0,0 +1,40 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockFlower;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenFlowers extends FeatureGenerator
|
||||
{
|
||||
private BlockFlower flower;
|
||||
private State field_175915_b;
|
||||
|
||||
public WorldGenFlowers(BlockFlower p_i45632_1_, BlockFlower.EnumFlowerType p_i45632_2_)
|
||||
{
|
||||
this.setGeneratedBlock(p_i45632_1_, p_i45632_2_);
|
||||
}
|
||||
|
||||
public void setGeneratedBlock(BlockFlower p_175914_1_, BlockFlower.EnumFlowerType p_175914_2_)
|
||||
{
|
||||
this.flower = p_175914_1_;
|
||||
this.field_175915_b = p_175914_1_.getState().withProperty(p_175914_1_.getTypeProperty(), p_175914_2_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.flower.canBlockStay(worldIn, blockpos, this.field_175915_b))
|
||||
{
|
||||
worldIn.setState(blockpos, this.field_175915_b, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
25
java/src/game/worldgen/foliage/WorldGenMelon.java
Executable file
25
java/src/game/worldgen/foliage/WorldGenMelon.java
Executable file
|
@ -0,0 +1,25 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenMelon extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (Blocks.melon_block.canPlaceBlockAt(worldIn, blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.melon_block.getState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
32
java/src/game/worldgen/foliage/WorldGenMushroom.java
Executable file
32
java/src/game/worldgen/foliage/WorldGenMushroom.java
Executable file
|
@ -0,0 +1,32 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockBush;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenMushroom extends FeatureGenerator
|
||||
{
|
||||
private BlockBush field_175908_a;
|
||||
|
||||
public WorldGenMushroom(BlockBush p_i45633_1_)
|
||||
{
|
||||
this.field_175908_a = p_i45633_1_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.field_175908_a.canBlockStay(worldIn, blockpos, this.field_175908_a.getState()))
|
||||
{
|
||||
worldIn.setState(blockpos, this.field_175908_a.getState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
27
java/src/game/worldgen/foliage/WorldGenPumpkin.java
Executable file
27
java/src/game/worldgen/foliage/WorldGenPumpkin.java
Executable file
|
@ -0,0 +1,27 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockPumpkin;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenPumpkin extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(worldIn, blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.pumpkin.getState().withProperty(BlockPumpkin.FACING, Facing.Plane.HORIZONTAL.random(rand)), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
39
java/src/game/worldgen/foliage/WorldGenReed.java
Executable file
39
java/src/game/worldgen/foliage/WorldGenReed.java
Executable file
|
@ -0,0 +1,39 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
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 class WorldGenReed extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(4) - rand.zrange(4), 0, rand.zrange(4) - rand.zrange(4));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos))
|
||||
{
|
||||
BlockPos blockpos1 = blockpos.down();
|
||||
|
||||
if (worldIn.getState(blockpos1.west()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.east()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.north()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.south()).getBlock().getMaterial() == Material.water)
|
||||
{
|
||||
int j = 2 + rand.zrange(rand.zrange(3) + 1);
|
||||
|
||||
for (int k = 0; k < j; ++k)
|
||||
{
|
||||
if (Blocks.reeds.canBlockStay(worldIn, blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos.up(k), Blocks.reeds.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
70
java/src/game/worldgen/foliage/WorldGenShrub.java
Executable file
70
java/src/game/worldgen/foliage/WorldGenShrub.java
Executable file
|
@ -0,0 +1,70 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
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;
|
||||
import game.worldgen.tree.WorldGenBaseTree;
|
||||
|
||||
public class WorldGenShrub extends WorldGenBaseTree
|
||||
{
|
||||
private final State leavesMetadata;
|
||||
private final State woodMetadata;
|
||||
|
||||
public WorldGenShrub(State log, State leaves)
|
||||
{
|
||||
super(false);
|
||||
this.woodMetadata = log;
|
||||
this.leavesMetadata = leaves.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
Block block;
|
||||
|
||||
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
Block block1 = worldIn.getState(position).getBlock();
|
||||
|
||||
if (block1 == Blocks.dirt || block1 == Blocks.grass)
|
||||
{
|
||||
position = position.up();
|
||||
this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);
|
||||
|
||||
for (int i = position.getY(); i <= position.getY() + 2; ++i)
|
||||
{
|
||||
int j = i - position.getY();
|
||||
int k = 2 - j;
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k; ++l)
|
||||
{
|
||||
int i1 = l - position.getX();
|
||||
|
||||
for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
|
||||
{
|
||||
int k1 = j1 - position.getZ();
|
||||
|
||||
if (Math.abs(i1) != k || Math.abs(k1) != k || rand.zrange(2) != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(l, i, j1);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
43
java/src/game/worldgen/foliage/WorldGenTallGrass.java
Executable file
43
java/src/game/worldgen/foliage/WorldGenTallGrass.java
Executable file
|
@ -0,0 +1,43 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockTallGrass;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenTallGrass extends FeatureGenerator
|
||||
{
|
||||
private final State tallGrassState;
|
||||
|
||||
public WorldGenTallGrass(BlockTallGrass.EnumType p_i45629_1_)
|
||||
{
|
||||
this.tallGrassState = Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, p_i45629_1_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
Block block;
|
||||
|
||||
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 128; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && Blocks.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState))
|
||||
{
|
||||
worldIn.setState(blockpos, this.tallGrassState, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
38
java/src/game/worldgen/foliage/WorldGenVines.java
Executable file
38
java/src/game/worldgen/foliage/WorldGenVines.java
Executable file
|
@ -0,0 +1,38 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenVines extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (; position.getY() < 128; position = position.up())
|
||||
{
|
||||
if (worldIn.isAirBlock(position))
|
||||
{
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL.facings())
|
||||
{
|
||||
if (Blocks.vine.canPlaceBlockOnSide(worldIn, position, enumfacing))
|
||||
{
|
||||
State iblockstate = Blocks.vine.getState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == Facing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == Facing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == Facing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == Facing.WEST));
|
||||
worldIn.setState(position, iblockstate, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
position = position.add(rand.zrange(4) - rand.zrange(4), 0, rand.zrange(4) - rand.zrange(4));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
29
java/src/game/worldgen/foliage/WorldGenWaterlily.java
Executable file
29
java/src/game/worldgen/foliage/WorldGenWaterlily.java
Executable file
|
@ -0,0 +1,29 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockDirectional;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenWaterlily extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
int j = position.getX() + rand.zrange(8) - rand.zrange(8);
|
||||
int k = position.getY() + rand.zrange(4) - rand.zrange(4);
|
||||
int l = position.getZ() + rand.zrange(8) - rand.zrange(8);
|
||||
|
||||
if (worldIn.isAirBlock(new BlockPos(j, k, l)) && Blocks.waterlily.canPlaceBlockAt(worldIn, new BlockPos(j, k, l)))
|
||||
{
|
||||
worldIn.setState(new BlockPos(j, k, l), Blocks.waterlily.getState().withProperty(BlockDirectional.FACING, Facing.randHorizontal(rand)), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue