net.minecraft.block.BlockCrops类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中net.minecraft.block.BlockCrops类的一些代码示例,展示了BlockCrops类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockCrops类的具体详情如下:
包路径:net.minecraft.block.BlockCrops
类名称:BlockCrops

BlockCrops介绍

暂无

代码示例

代码示例来源:origin: SonarSonic/Calculator

@Override
public boolean canPlaceBlockAt(World world, BlockPos pos) {
  return this.greenhouseTier == 0 && super.canPlaceBlockAt(world, pos);
}

代码示例来源:origin: TeamLapen/Vampirism

@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
  return super.getDrops(world, pos, state, fortune - 1);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public int quantityDropped(Random random) {
 return super.quantityDropped(random) + 1;
}

代码示例来源:origin: WayofTime/BloodMagic

private static void addPamCrops() {
    if (!Loader.isModLoaded("harvestcraft"))
      return;

    try {
      Class<?> pamRegistry = Class.forName("com.pam.harvestcraft.blocks.CropRegistry");
      Field names = pamRegistry.getDeclaredField("cropNames");
      Method getCrop = pamRegistry.getMethod("getCrop", String.class);
      for (String name : (String[]) names.get(null)) {
        BlockCrops crop = (BlockCrops) getCrop.invoke(null, name);
        HarvestRegistry.registerStandardCrop(crop, crop.getMaxAge());
      }
    } catch (ClassNotFoundException e) {
      BMLog.DEFAULT.error("HarvestCraft integration cancelled; unable to find registry class");
    } catch (NoSuchMethodException | NoSuchFieldException e) {
      BMLog.DEFAULT.error("HarvestCraft integration cancelled; unable to find crop name mapper");
    } catch (IllegalAccessException | InvocationTargetException e) {
      BMLog.DEFAULT.error("HarvestCraft integration cancelled; crop name lookup broke");
    }
  }
}

代码示例来源:origin: ldtteam/minecolonies

if (crop.isMaxAge(state))
  crop.grow(world, position.up(), state);
  state = world.getBlockState(position.up());
  block = state.getBlock();
return crop.isMaxAge(state);

代码示例来源:origin: vadis365/TheErebus

@Override
protected boolean canEatBlock(IBlockState state) {
  Block block = state.getBlock();
  if (block == null)
    return false;
  else if (block == Blocks.TALLGRASS || state == ModBlocks.SMALL_PLANT.getDefaultState().withProperty(BlockSmallPlant.PLANT_TYPE, BlockSmallPlant.EnumSmallPlantType.FERN) || block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(state))
    return true;
  return false;
}

代码示例来源:origin: ForestryMC/Binnie

@Override
public void grow(World world, BlockPos pos, IBlockState state) {
  if (state.getValue(HALF) == HopsHalf.UP) {
    IBlockState stateDrown = world.getBlockState(pos.down());
    Block block = stateDrown.getBlock();
    if (block instanceof BlockHops) {
      ((BlockHops) block).grow(world, pos.down(), stateDrown);
    }
    return;
  }
  super.grow(world, pos, state);
}

代码示例来源:origin: ForestryMC/Binnie

@Override
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) {
  if (state.getValue(HALF) == HopsHalf.UP) {
    return worldIn.getBlockState(pos.down()).getBlock() == this;
  } else {
    IBlockState iblockstate = worldIn.getBlockState(pos.up());
    return iblockstate.getBlock() == this && super.canBlockStay(worldIn, pos, iblockstate);
  }
}

代码示例来源:origin: SleepyTrousers/EnderCore

resetState = mcblock.getDefaultState().withProperty(BlockBeetroot.BEETROOT_AGE, 0);
} else if (mcblock instanceof BlockCrops) {
 meta = ((BlockCrops) mcblock).getMaxAge();
 resetMeta = 0;
 grownState = mcblock.getDefaultState().withProperty(BlockCrops.AGE, ((BlockCrops) mcblock).getMaxAge());
 resetState = mcblock.getDefaultState().withProperty(BlockCrops.AGE, 0);
} else if (mcblock instanceof BlockNetherWart) {

代码示例来源:origin: Ellpeck/ActuallyAdditions

@Override
public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) {
  int use = 250;
  if (farmer.getEnergy() >= use) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    if (block instanceof BlockCrops) {
      if (((BlockCrops) block).isMaxAge(state)) { return doFarmerStuff(state, world, pos, farmer); }
    } else if ((BlockCrops.AGE).equals(block.getBlockState().getProperty("age"))) {
      if (state.getValue(BlockCrops.AGE) >= 7 && !(block instanceof BlockStem)) return doFarmerStuff(state, world, pos, farmer);
    }
  }
  return FarmerResult.FAIL;
}

代码示例来源:origin: TehNut/HWYLA

addMaturityTooltip(currenttip, accessor.getMetadata() / (float) ((BlockCrops) block).getMaxAge());
else if (block == melonStem || block == pumpkinStem)
  addMaturityTooltip(currenttip, accessor.getMetadata() / 7F);

代码示例来源:origin: Ellpeck/ActuallyAdditions

@Override
public int quantityDropped(IBlockState state, int fortune, Random random){
  return this.getMetaFromState(state) >= 7 ? random.nextInt(this.addDropAmount)+this.minDropAmount : super.quantityDropped(state, fortune, random);
}

代码示例来源:origin: ForestryMC/Binnie

public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
  return super.canPlaceBlockAt(worldIn, pos) && worldIn.isAirBlock(pos.up());
}

代码示例来源:origin: MatrexsVigil/harvestcraft

private static void harvestCrops(IBlockState blockState, EntityPlayer player, World world, BlockPos blockPos) {
  final BlockCrops crops = (BlockCrops) blockState.getBlock();
  final ItemStack stack = player.getHeldItemMainhand();
  final int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
  final List<ItemStack> drops = crops.getDrops(world, blockPos, blockState, fortune);
  // This removes exactly one seed from drops in order to make this more fair compared to vanilla
  // as one seed stays planted.
  final Item seedItem = crops.getItemDropped(blockState, world.rand, fortune);
  if(seedItem != null)
    for(Iterator<ItemStack> iterator = drops.iterator(); iterator.hasNext();) {
      final ItemStack drop = iterator.next();
      // Remove a seed, then break.
      if(!(drop.getItem() == seedItem) || crops instanceof BlockCarrot || crops instanceof BlockPotato) {
        iterator.remove();
        break;
      }
    }
  ForgeEventFactory.fireBlockHarvesting(drops, world, blockPos, blockState, fortune, 1f, false, player);
  // Reset growth level
  world.setBlockState(blockPos, crops.withAge(0));
  for(ItemStack drop : drops) {
    dropItem(drop, world, blockPos);
  }
  
}

代码示例来源:origin: ForestryMC/Binnie

int j = ((BlockCrops) this.cropTypeA).getMaxAge();
int k = j / 3;
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(MathHelper.getInt(randomIn, k, j)), 1, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeA.getStateFromMeta(MathHelper.getInt(randomIn, k, j)), 2, 1, i, structureBoundingBoxIn);
int l = ((BlockCrops) this.cropTypeB).getMaxAge();
int i1 = l / 3;
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(MathHelper.getInt(randomIn, i1, l)), 4, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeB.getStateFromMeta(MathHelper.getInt(randomIn, i1, l)), 5, 1, i, structureBoundingBoxIn);
int j1 = ((BlockCrops) this.cropTypeC).getMaxAge();
int k1 = j1 / 3;
this.setBlockState(worldIn, this.cropTypeC.getStateFromMeta(MathHelper.getInt(randomIn, k1, j1)), 7, 1, i, structureBoundingBoxIn);
this.setBlockState(worldIn, this.cropTypeC.getStateFromMeta(MathHelper.getInt(randomIn, k1, j1)), 8, 1, i, structureBoundingBoxIn);
int l1 = ((BlockCrops) this.cropTypeD).getMaxAge();
int i2 = l1 / 3;
this.setBlockState(worldIn, this.cropTypeD.getStateFromMeta(MathHelper.getInt(randomIn, i2, l1)), 10, 1, i, structureBoundingBoxIn);

相关文章