当前位置: 首页>>代码示例>>Java>>正文


Java Blocks.farmland方法代码示例

本文整理汇总了Java中net.minecraft.init.Blocks.farmland方法的典型用法代码示例。如果您正苦于以下问题:Java Blocks.farmland方法的具体用法?Java Blocks.farmland怎么用?Java Blocks.farmland使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.init.Blocks的用法示例。


在下文中一共展示了Blocks.farmland方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldMoveTo

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
/**
 * Return true to set given position as destination
 */
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
        {
            this.field_179501_f = 0;
            return true;
        }

        if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
        {
            this.field_179501_f = 1;
            return true;
        }
    }

    return false;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:EntityAIHarvestFarmland.java

示例2: shouldMoveTo

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
    Block block = worldIn.getBlockState(pos).getBlock();

    if (block == Blocks.farmland)
    {
        pos = pos.up();
        IBlockState iblockstate = worldIn.getBlockState(pos);
        block = iblockstate.getBlock();

        if (block instanceof BlockCarrot && ((Integer)iblockstate.getValue(BlockCarrot.AGE)).intValue() == 7 && this.field_179498_d && !this.field_179499_e)
        {
            this.field_179499_e = true;
            return true;
        }
    }

    return false;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntityRabbit.java

示例3: BeetrootSeeds

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public BeetrootSeeds() {
	super(ModBlocks.beetroot, Blocks.farmland);
	setTextureName("beetroot_seeds");
	setUnlocalizedName(Utils.getUnlocalisedName("beetroot_seeds"));
	setCreativeTab(EtFuturum.enableBeetroot ? EtFuturum.creativeTab : null);

	if (EtFuturum.enableBeetroot) {
		ChestGenHooks.addItem(ChestGenHooks.MINESHAFT_CORRIDOR, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CORRIDOR, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_LIBRARY, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CROSSING, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:17,代码来源:BeetrootSeeds.java

示例4: shouldSideBeRendered

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
    switch (side)
    {
        case UP:
            return true;

        case NORTH:
        case SOUTH:
        case WEST:
        case EAST:
            Block block = worldIn.getBlockState(pos).getBlock();
            return !block.isOpaqueCube() && block != Blocks.farmland;

        default:
            return super.shouldSideBeRendered(worldIn, pos, side);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:19,代码来源:BlockFarmland.java

示例5: 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

示例6: onImpact

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
@Override
public void onImpact(MovingObjectPosition target)
{
	if (target.entityHit != null) 
   	{
   		target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) this.damage);
   		
   		target.entityHit.hurtResistantTime = 0;	// No rest for the wicked

       }        
       else 
       {
       	// Hit the terrain        	
       	int x = target.blockX;
   		int y = target.blockY;
   		int z = target.blockZ;
   		
   		Block hitBlock = this.worldObj.getBlock(x, y, z);
   		Block aboveHitBlock = this.worldObj.getBlock(x, y + 1, z);
   		
   		// Glass breaking
   		Helper.tryBlockBreak(this.worldObj, this, target, 0);
   		
   		if (hitBlock == Blocks.farmland && aboveHitBlock.getMaterial() == Material.air)
   		{
   			// Hit a farmland block and the block above is free. Planting a melon seed now
   			this.worldObj.setBlock(x, y + 1, z, Blocks.melon_stem, 0, 3);
   		}
       }
   	
       this.worldObj.playSoundAtEntity(this, "random.click", 0.2F, 3.0F);
       this.setDead();		// We've hit something, so begone with the projectile
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:34,代码来源:Seed.java

示例7: 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

示例8: 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,代码行数:41,代码来源:BlockStem.java

示例9: getGrowthChance

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
{
    float f = 1.0F;
    BlockPos blockpos = pos.down();

    for (int i = -1; i <= 1; ++i)
    {
        for (int j = -1; j <= 1; ++j)
        {
            float f1 = 0.0F;
            IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

            if (iblockstate.getBlock() == Blocks.farmland)
            {
                f1 = 1.0F;

                if (((Integer)iblockstate.getValue(BlockFarmland.MOISTURE)).intValue() > 0)
                {
                    f1 = 3.0F;
                }
            }

            if (i != 0 || j != 0)
            {
                f1 /= 4.0F;
            }

            f += f1;
        }
    }

    BlockPos blockpos1 = pos.north();
    BlockPos blockpos2 = pos.south();
    BlockPos blockpos3 = pos.west();
    BlockPos blockpos4 = pos.east();
    boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
    boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();

    if (flag && flag1)
    {
        f /= 2.0F;
    }
    else
    {
        boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

        if (flag2)
        {
            f /= 2.0F;
        }
    }

    return f;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:55,代码来源:BlockCrops.java

示例10: canPlaceBlockOn

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
/**
 * is the block grass, dirt or farmland
 */
protected boolean canPlaceBlockOn(Block ground)
{
    return ground == Blocks.farmland;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:8,代码来源:BlockCrops.java

示例11: 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:Notoh,项目名称:DecompiledMinecraft,代码行数:8,代码来源:BlockBush.java


注:本文中的net.minecraft.init.Blocks.farmland方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。