tcr/java/src/game/worldgen/foliage/WorldGenPumpkin.java
2025-03-12 18:13:11 +01:00

27 lines
951 B
Java
Executable file

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;
}
}