net.minecraft.block.Block.isLeaves()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(205)

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

Block.isLeaves介绍

暂无

代码示例

代码示例来源:origin: SlimeKnights/TinkersConstruct

@Override
public void afterBlockBreak(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase player, int damage, boolean wasEffective) {
 // breaking leaves does not reduce durability
 if(state.getBlock().isLeaves(state, world, pos)) {
  damage = 0;
 }
 super.afterBlockBreak(stack, world, state, pos, player, damage, wasEffective);
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

protected void placeTrunk(World world, BlockPos pos, int height) {
 while(height >= 0) {
  IBlockState state = world.getBlockState(pos);
  Block block = state.getBlock();
  if(block.isAir(state, world, pos) || block.isReplaceable(world, pos) || block.isLeaves(state, world, pos)) {
   this.setBlockAndMetadata(world, pos, log);
  }
  pos = pos.up();
  height--;
 }
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

BlockPos leaf = pos.add(o + x, o + y, o + z);
IBlockState state = world.getBlockState(leaf);
if(state.getBlock().isLeaves(state, world, leaf)) {
 if(++leaves >= 5) {
  return true;

代码示例来源:origin: Vazkii/Botania

boolean isLeaf = block.isLeaves(world.getBlockState(adj), world, adj);

代码示例来源:origin: Vazkii/Botania

? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type)
      : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower)
      || stackDmg == 1 && block.isLeaves(world.getBlockState(pos), world, pos)
      || stackDmg == 2 && block == Blocks.SNOW_LAYER)
coords.add(pos);

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

private static boolean isBlockLeaves(World world, BlockPos blockPos) {
  IBlockState blockState = world.getBlockState(blockPos);
  final Block block = blockState.getBlock();
  return block.isLeaves(blockState, world, blockPos);
}

代码示例来源:origin: progwml6/Natura

public static boolean isTreeBlock(IBlockState blockState, World world, BlockPos pos)
{
  Block block = blockState.getBlock();
  return block.isLeaves(blockState, world, pos) || block.isWood(world, pos);
}

代码示例来源:origin: GregTechCE/GregTech

@Override
public int convertBlockDrops(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer harvester, List<ItemStack> drops, boolean recursive) {
  if (blockState.getBlock().isLeaves(blockState, world, blockPos)) {
    drops.clear(); //clear previous drops to avoid possible issues
    NonNullList<ItemStack> dropsNonNull = NonNullList.create();
    blockState.getBlock().getDrops(dropsNonNull, world, blockPos, blockState, 10);
    drops.addAll(dropsNonNull);
  }
  return 0;
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
@ModDependentMethod(modId = LPConstants.mcmpModID)
public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) {
  Block block = mcmpBlockAccess.getBlock();
  return block != null ? block.isLeaves(state, world, pos) : super.isLeaves(state, world, pos);
}

代码示例来源:origin: progwml6/Natura

public boolean isReplaceable(World world, BlockPos pos)
{
  IBlockState state = world.getBlockState(pos);
  return state.getBlock().isAir(state, world, pos) || state.getBlock().isLeaves(state, world, pos) || state.getBlock().isReplaceable(world, pos) || state.getBlock().isWood(world, pos) || this.canGrowInto(state.getBlock());
}

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

private static int getYForCocoon(World world, int x, int z) {
  int y = world.getHeight(new BlockPos(x, 0, z)).getY() - 1;
  BlockPos pos = new BlockPos(x, y, z);
  IBlockState blockState = world.getBlockState(pos);
  if (!blockState.getBlock().isLeaves(blockState, world, pos)) {
    return -1;
  }
  do {
    pos = pos.down();
    blockState = world.getBlockState(pos);
  } while (blockState.getBlock().isLeaves(blockState, world, pos));
  return y;
}

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

/**
 * Returns whether the block can be blown by the leaf blower.
 * @param block The block
 * @param world The world
 * @param pos The block's position
 * @return Whether the leaf blower should blow this block away.
 */
public static boolean isLeaves(Block block, World world, BlockPos pos) {
  IBlockState state = world.getBlockState(pos);
  return (OreDictHelper.listHasItem(OreDictHelper.leaves, Item.getItemFromBlock(block)) ||
   block.isLeaves(state, world, pos) || LEAF_MATERIALS.contains(block.getMaterial(state)));
}

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

@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
  IBlockState iblockstate = worldIn.getBlockState(pos.down());
  Block block = iblockstate.getBlock();
  if (block != Blocks.ICE && block != Blocks.PACKED_ICE && block != Blocks.BARRIER) {
    BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, pos.down(), EnumFacing.UP);
    return blockfaceshape == BlockFaceShape.SOLID || iblockstate.getBlock().isLeaves(iblockstate, worldIn, pos.down()) || block == this && ((Integer) iblockstate.getValue(LAYERS)).intValue() == 8;
  } else {
    return false;
  }
}

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

public static boolean isValidLocation(World world, BlockPos pos) {
    BlockPos posAbove = pos.up();
    IBlockState blockStateAbove = world.getBlockState(posAbove);
    Block blockAbove = blockStateAbove.getBlock();
    if (!blockAbove.isLeaves(blockStateAbove, world, posAbove)) {
      return false;
    }
    BlockPos posBelow = pos.down();
    IBlockState blockStateBelow = world.getBlockState(posBelow);
    return BlockUtil.canReplace(blockStateBelow, world, posBelow);
  }
}

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

public static boolean canPlaceTree(IBlockState blockState, World world, BlockPos pos) {
  BlockPos downPos = pos.down();
  Block block = world.getBlockState(downPos).getBlock();
  return !(block.isReplaceable(world, downPos) &&
    blockState.getMaterial().isLiquid()) &&
    !block.isLeaves(blockState, world, downPos) &&
    !block.isWood(world, downPos);
}

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

public boolean canConnectFenceTo(IBlockAccess world, BlockPos pos) {
  IBlockState state = world.getBlockState(pos);
  Block block = state.getBlock();
  return block == this || canConnectTo(world, pos) || block.isLeaves(state, world, pos) || (state.getMaterial().isOpaque() && state.isFullCube() && state.getMaterial() != Material.GOURD);
}

代码示例来源:origin: jabelar/ExampleMod-1.12

private void generateTrunk(World parWorld, BlockPos parBlockPos, int minHeight)
{
  for (int height = 0; height < minHeight; ++height)
  {
    BlockPos upN = parBlockPos.up(height);
    IBlockState state = parWorld.getBlockState(upN);
    if (state.getBlock().isAir(state, parWorld, upN) || state.getBlock().isLeaves(state, parWorld, upN))
    {
      setBlockAndNotifyAdequately(parWorld, parBlockPos.up(height), blockStateWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y));
    }
  }
}

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

@Override
public boolean canPlaceBlockAt(World world, BlockPos pos) {
  IBlockState state = world.getBlockState(pos.down());
  if (state.getBlock() == null)
    return false;
  if (state.getBlock() == this)
    return true;
  if (state.getBlock().isLeaves(state, world, pos.down()) && !state.isOpaqueCube())
    return false;
  return state.getMaterial().blocksMovement();
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);
if(iblockstate1.getBlock().isLeaves(iblockstate1, worldIn, blockpos1)) {
 iblockstate1.getBlock().beginLeavesDecay(iblockstate1, worldIn, blockpos1);

代码示例来源:origin: CyclopsMC/EvilCraft

@Override
public boolean canPlaceBlockAt(World world, BlockPos blockPos) {
  IBlockState blockState = world.getBlockState(blockPos.add(0, -1, 0));
  if (blockState == null) return false;
  if (blockState.getBlock() == this && (Integer) blockState.getValue(LAYERS) == 8) return true;
  return (blockState.getBlock().isLeaves(blockState, world, blockPos.add(0, -1, 0))
      || blockState.isOpaqueCube()) && blockState.getBlock().getMaterial(blockState).blocksMovement();
}

相关文章

Block类方法