Java Code Examples for net.minecraft.init.Blocks.grass()

The following are Jave code examples for showing how to use grass() of the net.minecraft.init.Blocks class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: WorldGenMegaPineTree.java   View Source Code Vote up 6 votes
private void func_175934_c(World worldIn, BlockPos p_175934_2_)
{
    for (int i = 2; i >= -3; --i)
    {
        BlockPos blockpos = p_175934_2_.up(i);
        Block block = worldIn.getBlockState(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;
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: WorldGenHugeTrees.java   View Source Code Vote up 6 votes
private boolean func_175927_a(BlockPos p_175927_1_, World worldIn)
{
    BlockPos blockpos = p_175927_1_.down();
    Block block = worldIn.getBlockState(blockpos).getBlock();

    if ((block == Blocks.grass || block == Blocks.dirt) && p_175927_1_.getY() >= 2)
    {
        this.func_175921_a(worldIn, blockpos);
        this.func_175921_a(worldIn, blockpos.east());
        this.func_175921_a(worldIn, blockpos.south());
        this.func_175921_a(worldIn, blockpos.south().east());
        return true;
    }
    else
    {
        return false;
    }
}
 
Example 3
Project: connor41-etfuturum2   File: GrassPath.java   View Source Code Vote up 6 votes
public static void onPlayerInteract(PlayerInteractEvent event) {
	if (EtFuturum.enableGrassPath)
		if (event.entityPlayer != null) {
			World world = event.entityPlayer.worldObj;
			if (event.action == Action.RIGHT_CLICK_BLOCK)
				if (world.getBlock(event.x, event.y, event.z) == Blocks.grass) {
					ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
					if (stack != null && (stack.getItem() instanceof ItemSpade || isTinkersShovel(stack))) {
						world.setBlock(event.x, event.y, event.z, ModBlocks.grass_path);
						event.entityPlayer.swingItem();
						stack.damageItem(1, event.entityPlayer);
						world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F);
					}
				}
		}
}
 
Example 4
Project: BaseClient   File: EntityOcelot.java   View Source Code Vote up 6 votes
/**
 * Checks that the entity is not colliding with any blocks / liquids
 */
public boolean isNotColliding()
{
    if (this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(this.getEntityBoundingBox()))
    {
        BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ);

        if (blockpos.getY() < this.worldObj.func_181545_F())
        {
            return false;
        }

        Block block = this.worldObj.getBlockState(blockpos.down()).getBlock();

        if (block == Blocks.grass || block.getMaterial() == Material.leaves)
        {
            return true;
        }
    }

    return false;
}
 
Example 5
Project: BaseClient   File: BlockStem.java   View Source Code Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	super.updateTick(worldIn, pos, state, rand);

	if (worldIn.getLightFromNeighbors(pos.up()) >= 9) {
		float f = BlockCrops.getGrowthChance(this, worldIn, pos);

		if (rand.nextInt((int) (25.0F / f) + 1) == 0) {
			int i = ((Integer) state.getValue(AGE)).intValue();

			if (i < 7) {
				state = state.withProperty(AGE, Integer.valueOf(i + 1));
				worldIn.setBlockState(pos, state, 2);
			} else {
				for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL) {
					EnumFacing enumfacing = (EnumFacing) enumfacing0;
					if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() == this.crop) {
						return;
					}
				}

				pos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(rand));
				Block block = worldIn.getBlockState(pos.down()).getBlock();

				if (worldIn.getBlockState(pos).getBlock().blockMaterial == Material.air
						&& (block == Blocks.farmland || block == Blocks.dirt || block == Blocks.grass)) {
					worldIn.setBlockState(pos, this.crop.getDefaultState());
				}
			}
		}
	}
}
 
Example 6
Project: BaseClient   File: EntityAIEatGrass.java   View Source Code Vote up 5 votes
/**
 * Updates the task
 */
public void updateTask()
{
    this.eatingGrassTimer = Math.max(0, this.eatingGrassTimer - 1);

    if (this.eatingGrassTimer == 4)
    {
        BlockPos blockpos = new BlockPos(this.grassEaterEntity.posX, this.grassEaterEntity.posY, this.grassEaterEntity.posZ);

        if (field_179505_b.apply(this.entityWorld.getBlockState(blockpos)))
        {
            if (this.entityWorld.getGameRules().getBoolean("mobGriefing"))
            {
                this.entityWorld.destroyBlock(blockpos, false);
            }

            this.grassEaterEntity.eatGrassBonus();
        }
        else
        {
            BlockPos blockpos1 = blockpos.down();

            if (this.entityWorld.getBlockState(blockpos1).getBlock() == Blocks.grass)
            {
                if (this.entityWorld.getGameRules().getBoolean("mobGriefing"))
                {
                    this.entityWorld.playAuxSFX(2001, blockpos1, Block.getIdFromBlock(Blocks.grass));
                    this.entityWorld.setBlockState(blockpos1, Blocks.dirt.getDefaultState(), 2);
                }

                this.grassEaterEntity.eatGrassBonus();
            }
        }
    }
}
 
Example 7
Project: DecompiledMinecraft   File: WorldGenBigTree.java   View Source Code Vote up 5 votes
/**
 * 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.getBlockState(this.basePos.down()).getBlock();

    if (block != Blocks.dirt && block != Blocks.grass && block != Blocks.farmland)
    {
        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;
        }
    }
}
 
Example 8
Project: BaseClient   File: WorldGenMelon.java   View Source Code Vote up 5 votes
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    for (int i = 0; i < 64; ++i)
    {
        BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

        if (Blocks.melon_block.canPlaceBlockAt(worldIn, blockpos) && worldIn.getBlockState(blockpos.down()).getBlock() == Blocks.grass)
        {
            worldIn.setBlockState(blockpos, Blocks.melon_block.getDefaultState(), 2);
        }
    }

    return true;
}
 
Example 9
Project: DecompiledMinecraft   File: BlockStem.java   View Source Code Vote up 5 votes
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    super.updateTick(worldIn, pos, state, rand);

    if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
    {
        float f = BlockCrops.getGrowthChance(this, worldIn, pos);

        if (rand.nextInt((int)(25.0F / f) + 1) == 0)
        {
            int i = ((Integer)state.getValue(AGE)).intValue();

            if (i < 7)
            {
                state = state.withProperty(AGE, Integer.valueOf(i + 1));
                worldIn.setBlockState(pos, state, 2);
            }
            else
            {
                for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
                {
                    if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() == this.crop)
                    {
                        return;
                    }
                }

                pos = pos.offset(EnumFacing.Plane.HORIZONTAL.random(rand));
                Block block = worldIn.getBlockState(pos.down()).getBlock();

                if (worldIn.getBlockState(pos).getBlock().blockMaterial == Material.air && (block == Blocks.farmland || block == Blocks.dirt || block == Blocks.grass))
                {
                    worldIn.setBlockState(pos, this.crop.getDefaultState());
                }
            }
        }
    }
}
 
Example 10
Project: BaseClient   File: WorldGenPumpkin.java   View Source Code Vote up 5 votes
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    for (int i = 0; i < 64; ++i)
    {
        BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

        if (worldIn.isAirBlock(blockpos) && worldIn.getBlockState(blockpos.down()).getBlock() == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(worldIn, blockpos))
        {
            worldIn.setBlockState(blockpos, Blocks.pumpkin.getDefaultState().withProperty(BlockPumpkin.FACING, EnumFacing.Plane.HORIZONTAL.random(rand)), 2);
        }
    }

    return true;
}
 
Example 11
Project: BaseClient   File: BlockGrass.java   View Source Code Vote up 4 votes
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
    BlockPos blockpos = pos.up();

    for (int i = 0; i < 128; ++i)
    {
        BlockPos blockpos1 = blockpos;
        int j = 0;

        while (true)
        {
            if (j >= i / 16)
            {
                if (worldIn.getBlockState(blockpos1).getBlock().blockMaterial == Material.air)
                {
                    if (rand.nextInt(8) == 0)
                    {
                        BlockFlower.EnumFlowerType blockflower$enumflowertype = worldIn.getBiomeGenForCoords(blockpos1).pickRandomFlower(rand, blockpos1);
                        BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
                        IBlockState iblockstate = blockflower.getDefaultState().withProperty(blockflower.getTypeProperty(), blockflower$enumflowertype);

                        if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate))
                        {
                            worldIn.setBlockState(blockpos1, iblockstate, 3);
                        }
                    }
                    else
                    {
                        IBlockState iblockstate1 = Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS);

                        if (Blocks.tallgrass.canBlockStay(worldIn, blockpos1, iblockstate1))
                        {
                            worldIn.setBlockState(blockpos1, iblockstate1, 3);
                        }
                    }
                }

                break;
            }

            blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1.down()).getBlock() != Blocks.grass || worldIn.getBlockState(blockpos1).getBlock().isNormalCube())
            {
                break;
            }

            ++j;
        }
    }
}
 
Example 12
Project: BaseClient   File: BlockBush.java   View Source Code Vote up 4 votes
/**
 * is the block grass, dirt or farmland
 */
protected boolean canPlaceBlockOn(Block ground)
{
    return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
}
 
Example 13
Project: BaseClient   File: WorldGenBlockBlob.java   View Source Code Vote up 4 votes
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    while (true)
    {
        label0:
        {
            if (position.getY() > 3)
            {
                if (worldIn.isAirBlock(position.down()))
                {
                    break label0;
                }

                Block block = worldIn.getBlockState(position.down()).getBlock();

                if (block != Blocks.grass && block != Blocks.dirt && block != Blocks.stone)
                {
                    break label0;
                }
            }

            if (position.getY() <= 3)
            {
                return false;
            }

            int i1 = this.field_150544_b;

            for (int i = 0; i1 >= 0 && i < 3; ++i)
            {
                int j = i1 + rand.nextInt(2);
                int k = i1 + rand.nextInt(2);
                int l = i1 + rand.nextInt(2);
                float f = (float)(j + k + l) * 0.333F + 0.5F;

                for (BlockPos blockpos : BlockPos.getAllInBox(position.add(-j, -k, -l), position.add(j, k, l)))
                {
                    if (blockpos.distanceSq(position) <= (double)(f * f))
                    {
                        worldIn.setBlockState(blockpos, this.field_150545_a.getDefaultState(), 4);
                    }
                }

                position = position.add(-(i1 + 1) + rand.nextInt(2 + i1 * 2), 0 - rand.nextInt(2), -(i1 + 1) + rand.nextInt(2 + i1 * 2));
            }

            return true;
        }
        position = position.down();
    }
}
 
Example 14
Project: BaseClient   File: WorldGenAbstractTree.java   View Source Code Vote up 4 votes
protected boolean func_150523_a(Block p_150523_1_)
{
    Material material = p_150523_1_.getMaterial();
    return material == Material.air || material == Material.leaves || p_150523_1_ == Blocks.grass || p_150523_1_ == Blocks.dirt || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.log2 || p_150523_1_ == Blocks.sapling || p_150523_1_ == Blocks.vine;
}
 
Example 15
Project: DecompiledMinecraft   File: MapGenCaves.java   View Source Code Vote up 4 votes
protected boolean func_175793_a(IBlockState p_175793_1_, IBlockState p_175793_2_)
{
    return p_175793_1_.getBlock() == Blocks.stone ? true : (p_175793_1_.getBlock() == Blocks.dirt ? true : (p_175793_1_.getBlock() == Blocks.grass ? true : (p_175793_1_.getBlock() == Blocks.hardened_clay ? true : (p_175793_1_.getBlock() == Blocks.stained_hardened_clay ? true : (p_175793_1_.getBlock() == Blocks.sandstone ? true : (p_175793_1_.getBlock() == Blocks.red_sandstone ? true : (p_175793_1_.getBlock() == Blocks.mycelium ? true : (p_175793_1_.getBlock() == Blocks.snow_layer ? true : (p_175793_1_.getBlock() == Blocks.sand || p_175793_1_.getBlock() == Blocks.gravel) && p_175793_2_.getBlock().getMaterial() != Material.water))))))));
}
 
Example 16
Project: BaseClient   File: BetterGrass.java   View Source Code Vote up 4 votes
public static List getFaceQuads(IBlockAccess p_getFaceQuads_0_, Block p_getFaceQuads_1_, BlockPos p_getFaceQuads_2_, EnumFacing p_getFaceQuads_3_, List p_getFaceQuads_4_)
{
    if (p_getFaceQuads_3_ != EnumFacing.UP && p_getFaceQuads_3_ != EnumFacing.DOWN)
    {
        if (p_getFaceQuads_1_ instanceof BlockMycelium)
        {
            return Config.isBetterGrassFancy() ? (getBlockAt(p_getFaceQuads_2_.down(), p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.mycelium ? modelCubeMycelium.getFaceQuads(p_getFaceQuads_3_) : p_getFaceQuads_4_) : modelCubeMycelium.getFaceQuads(p_getFaceQuads_3_);
        }
        else
        {
            if (p_getFaceQuads_1_ instanceof BlockGrass)
            {
                Block block = p_getFaceQuads_0_.getBlockState(p_getFaceQuads_2_.up()).getBlock();
                boolean flag = block == Blocks.snow || block == Blocks.snow_layer;

                if (!Config.isBetterGrassFancy())
                {
                    if (flag)
                    {
                        return modelCubeGrassSnowy.getFaceQuads(p_getFaceQuads_3_);
                    }

                    return modelCubeGrass.getFaceQuads(p_getFaceQuads_3_);
                }

                if (flag)
                {
                    if (getBlockAt(p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.snow_layer)
                    {
                        return modelCubeGrassSnowy.getFaceQuads(p_getFaceQuads_3_);
                    }
                }
                else if (getBlockAt(p_getFaceQuads_2_.down(), p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.grass)
                {
                    return modelCubeGrass.getFaceQuads(p_getFaceQuads_3_);
                }
            }

            return p_getFaceQuads_4_;
        }
    }
    else
    {
        return p_getFaceQuads_4_;
    }
}
 
Example 17
Project: DecompiledMinecraft   File: WorldGenBlockBlob.java   View Source Code Vote up 4 votes
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    while (true)
    {
        label0:
        {
            if (position.getY() > 3)
            {
                if (worldIn.isAirBlock(position.down()))
                {
                    break label0;
                }

                Block block = worldIn.getBlockState(position.down()).getBlock();

                if (block != Blocks.grass && block != Blocks.dirt && block != Blocks.stone)
                {
                    break label0;
                }
            }

            if (position.getY() <= 3)
            {
                return false;
            }

            int i1 = this.field_150544_b;

            for (int i = 0; i1 >= 0 && i < 3; ++i)
            {
                int j = i1 + rand.nextInt(2);
                int k = i1 + rand.nextInt(2);
                int l = i1 + rand.nextInt(2);
                float f = (float)(j + k + l) * 0.333F + 0.5F;

                for (BlockPos blockpos : BlockPos.getAllInBox(position.add(-j, -k, -l), position.add(j, k, l)))
                {
                    if (blockpos.distanceSq(position) <= (double)(f * f))
                    {
                        worldIn.setBlockState(blockpos, this.field_150545_a.getDefaultState(), 4);
                    }
                }

                position = position.add(-(i1 + 1) + rand.nextInt(2 + i1 * 2), 0 - rand.nextInt(2), -(i1 + 1) + rand.nextInt(2 + i1 * 2));
            }

            return true;
        }
        position = position.down();
    }
}
 
Example 18
Project: DecompiledMinecraft   File: BlockGrass.java   View Source Code Vote up 4 votes
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
    BlockPos blockpos = pos.up();

    for (int i = 0; i < 128; ++i)
    {
        BlockPos blockpos1 = blockpos;
        int j = 0;

        while (true)
        {
            if (j >= i / 16)
            {
                if (worldIn.getBlockState(blockpos1).getBlock().blockMaterial == Material.air)
                {
                    if (rand.nextInt(8) == 0)
                    {
                        BlockFlower.EnumFlowerType blockflower$enumflowertype = worldIn.getBiomeGenForCoords(blockpos1).pickRandomFlower(rand, blockpos1);
                        BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
                        IBlockState iblockstate = blockflower.getDefaultState().withProperty(blockflower.getTypeProperty(), blockflower$enumflowertype);

                        if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate))
                        {
                            worldIn.setBlockState(blockpos1, iblockstate, 3);
                        }
                    }
                    else
                    {
                        IBlockState iblockstate1 = Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS);

                        if (Blocks.tallgrass.canBlockStay(worldIn, blockpos1, iblockstate1))
                        {
                            worldIn.setBlockState(blockpos1, iblockstate1, 3);
                        }
                    }
                }

                break;
            }

            blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);

            if (worldIn.getBlockState(blockpos1.down()).getBlock() != Blocks.grass || worldIn.getBlockState(blockpos1).getBlock().isNormalCube())
            {
                break;
            }

            ++j;
        }
    }
}
 
Example 19
Project: BaseClient   File: MapGenCaves.java   View Source Code Vote up 4 votes
protected boolean func_175793_a(IBlockState p_175793_1_, IBlockState p_175793_2_)
{
    return p_175793_1_.getBlock() == Blocks.stone ? true : (p_175793_1_.getBlock() == Blocks.dirt ? true : (p_175793_1_.getBlock() == Blocks.grass ? true : (p_175793_1_.getBlock() == Blocks.hardened_clay ? true : (p_175793_1_.getBlock() == Blocks.stained_hardened_clay ? true : (p_175793_1_.getBlock() == Blocks.sandstone ? true : (p_175793_1_.getBlock() == Blocks.red_sandstone ? true : (p_175793_1_.getBlock() == Blocks.mycelium ? true : (p_175793_1_.getBlock() == Blocks.snow_layer ? true : (p_175793_1_.getBlock() == Blocks.sand || p_175793_1_.getBlock() == Blocks.gravel) && p_175793_2_.getBlock().getMaterial() != Material.water))))))));
}
 
Example 20
Project: BaseClient   File: BetterGrass.java   View Source Code Vote up 4 votes
public static List getFaceQuads(IBlockAccess p_getFaceQuads_0_, Block p_getFaceQuads_1_, BlockPos p_getFaceQuads_2_, EnumFacing p_getFaceQuads_3_, List p_getFaceQuads_4_)
{
    if (p_getFaceQuads_3_ != EnumFacing.UP && p_getFaceQuads_3_ != EnumFacing.DOWN)
    {
        if (p_getFaceQuads_1_ instanceof BlockMycelium)
        {
            return Config.isBetterGrassFancy() ? (getBlockAt(p_getFaceQuads_2_.down(), p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.mycelium ? modelCubeMycelium.getFaceQuads(p_getFaceQuads_3_) : p_getFaceQuads_4_) : modelCubeMycelium.getFaceQuads(p_getFaceQuads_3_);
        }
        else
        {
            if (p_getFaceQuads_1_ instanceof BlockGrass)
            {
                Block block = p_getFaceQuads_0_.getBlockState(p_getFaceQuads_2_.up()).getBlock();
                boolean flag = block == Blocks.snow || block == Blocks.snow_layer;

                if (!Config.isBetterGrassFancy())
                {
                    if (flag)
                    {
                        return modelCubeGrassSnowy.getFaceQuads(p_getFaceQuads_3_);
                    }

                    return modelCubeGrass.getFaceQuads(p_getFaceQuads_3_);
                }

                if (flag)
                {
                    if (getBlockAt(p_getFaceQuads_2_, p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.snow_layer)
                    {
                        return modelCubeGrassSnowy.getFaceQuads(p_getFaceQuads_3_);
                    }
                }
                else if (getBlockAt(p_getFaceQuads_2_.down(), p_getFaceQuads_3_, p_getFaceQuads_0_) == Blocks.grass)
                {
                    return modelCubeGrass.getFaceQuads(p_getFaceQuads_3_);
                }
            }

            return p_getFaceQuads_4_;
        }
    }
    else
    {
        return p_getFaceQuads_4_;
    }
}