Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mojang.minecraft.world.gen.impl;
- import java.util.Random;
- /**
- * A world generator which generates tall grass.
- * @author Ryan Greene
- *
- */
- public class TallGrassWorldGenerator extends WorldGenerator {
- /**
- * The id of the grass block which is being generated.
- */
- private final int grassBlockId;
- /**
- * The metadata of the grass block which is being generated.
- */
- private final int grassMetadata;
- /**
- * Constructs a new tall grass world generator with the specified grass id and metadata.
- * @param grassBlockId The id of the grass block which is being generated
- * @param grassMetadata The metadata of the grass block which is being generated
- */
- public TallGrassWorldGenerator(final int grassBlockId, final int grassMetadata) {
- this.grassBlockId = grassBlockId;
- this.grassMetadata = grassMetadata;
- }
- @Override
- public boolean generate(final World world, final Random random, final int x, int y, final int z) {
- for (int attempt = 0; attempt < 128; attempt++) {
- final int grassX = x + random.nextInt(8) - random.nextInt(8);
- final int grassY = y + random.nextInt(4) - random.nextInt(4);
- final int grassZ = z + random.nextInt(8) - random.nextInt(8);
- if (world.isAirBlock(grassX, grassY, grassZ) && ((BlockFlower) Block.blocksList[grassBlockId]).canBlockStay(world, grassX, grassY, grassZ)) {
- world.setBlockAndMetadata(grassX, grassY, grassZ, grassBlockId, grassMetadata);
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement