43 lines
1.3 KiB
Java
Executable file
43 lines
1.3 KiB
Java
Executable file
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;
|
|
}
|
|
}
|