當前位置: 首頁>>代碼示例>>Java>>正文


Java Blocks.grass方法代碼示例

本文整理匯總了Java中net.minecraft.init.Blocks.grass方法的典型用法代碼示例。如果您正苦於以下問題:Java Blocks.grass方法的具體用法?Java Blocks.grass怎麽用?Java Blocks.grass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.init.Blocks的用法示例。


在下文中一共展示了Blocks.grass方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: func_175934_c

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:WorldGenMegaPineTree.java

示例2: func_175927_a

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:19,代碼來源:WorldGenHugeTrees.java

示例3: onPlayerInteract

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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);
					}
				}
		}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:17,代碼來源:GrassPath.java

示例4: isNotColliding

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:25,代碼來源:EntityOcelot.java

示例5: updateTick

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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());
				}
			}
		}
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:32,代碼來源:BlockStem.java

示例6: updateTask

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
/**
 * 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();
            }
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:38,代碼來源:EntityAIEatGrass.java

示例7: validTreeLocation

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
/**
 * 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;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:32,代碼來源:WorldGenBigTree.java

示例8: generate

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:WorldGenMelon.java

示例9: updateTick

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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());
                }
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:39,代碼來源:BlockStem.java

示例10: generate

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:WorldGenPumpkin.java

示例11: grow

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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;
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:52,代碼來源:BlockGrass.java

示例12: canPlaceBlockOn

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
/**
 * is the block grass, dirt or farmland
 */
protected boolean canPlaceBlockOn(Block ground)
{
    return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:8,代碼來源:BlockBush.java

示例13: generate

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:52,代碼來源:WorldGenBlockBlob.java

示例14: func_150523_a

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:6,代碼來源:WorldGenAbstractTree.java

示例15: func_175793_a

import net.minecraft.init.Blocks; //導入方法依賴的package包/類
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))))))));
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:5,代碼來源:MapGenCaves.java


注:本文中的net.minecraft.init.Blocks.grass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。