本文整理匯總了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;
}
示例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;
}
示例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));
}
}
示例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);
}
}
示例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;
}
}
}
示例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
}
示例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());
}
}
}
}
}
示例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());
}
}
}
}
}
示例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;
}
示例10: canPlaceBlockOn
import net.minecraft.init.Blocks; //導入方法依賴的package包/類
/**
* is the block grass, dirt or farmland
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground == Blocks.farmland;
}
示例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;
}