本文整理汇总了Java中net.minecraft.block.BlockCrops类的典型用法代码示例。如果您正苦于以下问题:Java BlockCrops类的具体用法?Java BlockCrops怎么用?Java BlockCrops使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockCrops类属于net.minecraft.block包,在下文中一共展示了BlockCrops类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldExecute
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
@Override
public boolean shouldExecute()
{
if (pos == null)
pos = robot.getBoundInventory();
if (robot.worldObj.isRemote)
return true;
if (target == null)
{
int range = robot.getChipset().getRange();
List<Vector3> result = WorldHelper.getBlocksWithinAABB(robot.worldObj, BlockCrops.class, AxisAlignedBB.getBoundingBox(pos.x - range / 2, pos.y - 1, pos.z - range / 2, pos.x + range / 2, pos.y + 1, pos.z + range / 2));
if (result.size() > 0)
{
for (Vector3 vec : result)
{
if (robot.worldObj.getBlockMetadata((int) vec.x, (int) vec.y, (int) vec.z) == 7)
{
target = vec;
break;
}
}
}
}
return true;
}
示例2: update
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
@Override
public void update() {
super.update();
if (!worldObj.isRemote && boundedRect != null && worldObj.getTotalWorldTime() % 20L == 0) {
if (currentCheckingVec == null)
currentCheckingVec = new Vector3<Integer>(boundedRect.min.x.intValue(), pos.getY(), boundedRect.min.y.intValue());
// ProjectZed.logHelper.info("boundedRect", boundedRect, "currentCheckingVec", currentCheckingVec, getCurrentFacing());
final Block currentBlock = BlockUtils.getBlock(worldObj, currentCheckingVec).getBlock();
final int currentMeta = BlockUtils.getBlockMetadata(worldObj, currentCheckingVec);
if (currentBlock instanceof BlockLog || (currentBlock instanceof BlockCrops && currentMeta >= 7)) {
// chopTree((BlockLog) currentBlock);
chopTree();
return;
}
incrementVector();
}
}
示例3: growCrop
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
@Override
public void growCrop(World world, int cropId, Vect pos) {
if (cropId == Block.sapling.blockID) {
((BlockSapling) Block.sapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
}
if (cropId == ForestryBlock.firsapling.blockID) {
((BlockFirSapling) ForestryBlock.firsapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
}
if (cropId == ForestryBlock.sapling.blockID) {
((BlockSaplings) ForestryBlock.sapling).growTree(world, pos.x, pos.y, pos.z, world.rand);
}
if (cropId == Block.crops.blockID) {
((BlockCrops) Block.crops).fertilize(world, pos.x, pos.y, pos.z);
}
if (cropId == Block.netherStalk.blockID) {
world.setBlockAndMetadataWithNotify(pos.x, pos.y, pos.z, Block.netherStalk.blockID, 3);
}
}
示例4: lookForFlowers
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
private void lookForFlowers() {
getArea().forEach(
pos -> {
final Block block = world.getBlockState(pos).getBlock();
if ((block instanceof BlockCrops) || block == Blocks.RED_FLOWER || block == Blocks.YELLOW_FLOWER) {
if (++flowerCount > 200) flowerCount = 200;
}
}
);
}
示例5: bonemealArea
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
private void bonemealArea() {
getArea().forEach(
pos -> {
final IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockCrops && world.rand.nextInt(400 - flowerCount) == 0) {
if (((BlockCrops) state.getBlock()).canGrow(world, pos, state, false)) {
((BlockCrops) state.getBlock()).grow(world, world.rand, pos, state);
}
}
}
);
}
示例6: safeImpact
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
int box = 1 + (int) ((float) amplifier / 2F);
BlockPos posI = pos.add(box, 1, box);
BlockPos posF = pos.add(-box, -1, -box);
Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
int chance = 10 + amplifier * 2;
int fortune = MathHelper.clamp(amplifier, 0, 5);
for (BlockPos spot : spots) {
IBlockState state = world.getBlockState(spot);
boolean place = amplifier > 1 || world.rand.nextBoolean();
if (place && state.getBlock() instanceof BlockCrops) {
BlockCrops crop = (BlockCrops) state.getBlock();
if (crop.isMaxAge(state)) {
crop.dropBlockAsItemWithChance(world, spot, state, chance, fortune);
world.setBlockToAir(spot);
}
}
}
}
示例7: shouldMoveTo
import net.minecraft.block.BlockCrops; //导入依赖的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;
}
示例8: isCorrectBlock
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
private boolean isCorrectBlock(BlockPos pos)
{
Block block = WBlock.getBlock(pos);
if(!(block instanceof IGrowable) || block instanceof BlockGrass
|| !((IGrowable)block).canGrow(WMinecraft.getWorld(), pos,
WBlock.getState(pos), false))
return false;
if(block instanceof BlockSapling)
return saplings.isChecked();
else if(block instanceof BlockCrops)
return crops.isChecked();
else if(block instanceof BlockStem)
return stems.isChecked();
else if(block instanceof BlockCocoa)
return cocoa.isChecked();
else
return other.isChecked();
}
示例9: updateTick
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if (getAge(state) < ((BlockCrops)state.getBlock()).getMaxAge()) {
Random rand1 = new Random(getAge(state) + rand.nextInt());
if (rand1.nextInt(100 * (getAge(state) + 1)) == 0 && world.rand.nextInt(2) == 0) {
world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(getAge(state) + 1));
}
}
}
示例10: checkHighplant
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
private void checkHighplant(World world, BlockPos pos, IBlockState state, int age) {
int chanceByHeight = Math.round(pos.getY() / 16);
if (world.getLightFromNeighbors(pos.up()) >= 9) {
if (age < ((BlockCrops)state.getBlock()).getMaxAge() && world.rand.nextInt(16 - chanceByHeight) == 0) {
world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(age + 1));
}
}
}
示例11: enderlilyTele
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
private void enderlilyTele(World world, BlockPos pos, IBlockState state, int age) {
if (world.getLightFromNeighbors(pos.up()) >= 9) {
if (age < ((BlockCrops)state.getBlock()).getMaxAge()) {
Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, 0, -4), pos.add(4, 0, 4));
Iterator it = getBox.iterator();
while (it.hasNext()) {
BlockPos looppos = (BlockPos)it.next();
Block loopblock = world.getBlockState(looppos).getBlock();
if (loopblock != null && (world.isAirBlock(looppos) || (loopblock instanceof IGrowable && loopblock != this))) {
IBlockState savestate = world.getBlockState(looppos);
if (world.getBlockState(looppos.add(0, -1, 0)).getBlock() == Blocks.FARMLAND && world.rand.nextInt(7) == 0)
{
world.setBlockState(looppos, ((BlockCrops)state.getBlock()).withAge(age + 1), 2);
world.setBlockState(pos, savestate);
UCPacketHandler.sendToNearbyPlayers(world, looppos, new PacketUCEffect(EnumParticleTypes.PORTAL, looppos.getX(), looppos.getY(), looppos.getZ(), 6));
UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.PORTAL, pos.getX(), pos.getY(), pos.getZ(), 6));
return;
}
}
}
}
}
}
示例12: canAccept
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
private boolean canAccept(World world, BlockPos pos) {
Block block = world.getBlockState(pos).getBlock();
if (block != null && block instanceof BlockCrops) {
return world.getBlockState(pos).getValue(BlockCrops.AGE) >= ((BlockCrops)block).getMaxAge();
}
return false;
}
示例13: onImpact
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
@Override
public void onImpact(RayTraceResult result) {
if (fallingTile == null) {
this.setDead();
return;
}
BlockPos pos = new BlockPos(result.hitVec);
if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
IBlockState state = worldObj.getBlockState(pos);
if (!(state.getBlock() instanceof BlockCrops)) {
worldObj.setBlockState(pos.offset(result.sideHit), fallingTile, 3);
this.setDead();
return;
}
}
else this.setDead();
}
示例14: onItemUse
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
Block crops = world.getBlockState(pos).getBlock();
if (crops != null && crops instanceof BlockCrops) {
if (crops != UCBlocks.cropMerlinia)
world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
else if (crops == UCBlocks.cropMerlinia)
((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
else if (crops instanceof BlockNetherWart)
((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
stack.stackSize--;
UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
return EnumActionResult.SUCCESS;
}
}
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
示例15: readStructureFromNBT
import net.minecraft.block.BlockCrops; //导入依赖的package包/类
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_)
{
super.readStructureFromNBT(tagCompound, p_143011_2_);
this.cropTypeA = Block.getBlockById(tagCompound.getInteger("CA"));
this.cropTypeB = Block.getBlockById(tagCompound.getInteger("CB"));
this.cropTypeC = Block.getBlockById(tagCompound.getInteger("CC"));
this.cropTypeD = Block.getBlockById(tagCompound.getInteger("CD"));
if (!(this.cropTypeA instanceof BlockCrops))
{
this.cropTypeA = Blocks.WHEAT;
}
if (!(this.cropTypeB instanceof BlockCrops))
{
this.cropTypeB = Blocks.CARROTS;
}
if (!(this.cropTypeC instanceof BlockCrops))
{
this.cropTypeC = Blocks.POTATOES;
}
if (!(this.cropTypeD instanceof BlockCrops))
{
this.cropTypeD = Blocks.BEETROOTS;
}
}