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

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

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

Block.canHarvestBlock介绍

暂无

代码示例

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

public boolean basicHarvestBlockTest(
    World world,
    BlockPos pos,
    EntityPlayer player )
{
  return super.canHarvestBlock( world, pos, player );
}

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

public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, BlockPos pos,
                    Predicate<IBlockState> filter,
                    boolean dispose, boolean particles) {
  if(!world.isBlockLoaded(pos))
    return;
  IBlockState state = world.getBlockState(pos);
  Block block = state.getBlock();
  if(!world.isRemote && filter.test(state)
      && !block.isAir(state, world, pos) && state.getPlayerRelativeBlockHardness(player, world, pos) > 0
      && block.canHarvestBlock(player.world, pos, player)) {
    int exp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos);
    if(exp == -1)
      return;
    if(!player.capabilities.isCreativeMode) {
      TileEntity tile = world.getTileEntity(pos);
      if(block.removedByPlayer(state, world, pos, player, true)) {
        block.onPlayerDestroy(world, pos, state);
        if(!dispose || !ItemElementiumPick.isDisposable(block)) {
          block.harvestBlock(world, player, pos, state, tile, stack);
          block.dropXpOnBlockBreak(world, pos, exp);
        }
      }
      damageItem(stack, 1, player, 80);
    } else world.setBlockToAir(pos);
    if(particles && ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool)
      world.playEvent(2001, pos, Block.getStateId(state));
  }
}

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

@Override
public boolean canHarvestBlock(
    final IBlockAccess world,
    final BlockPos pos,
    final EntityPlayer player )
{
  if ( ChiselsAndBits.getConfig().enableToolHarvestLevels )
  {
    IBlockState state = actingAs.get();
    if ( state == null )
    {
      state = getPrimaryState( world, pos );
    }
    return state.getBlock().canHarvestBlock( new HarvestWorld( state ), pos, player );
  }
  return true;
}

代码示例来源:origin: McJtyMods/TheOneProbe

static void showCanBeHarvested(IProbeInfo probeInfo, World world, BlockPos pos, Block block, EntityPlayer player) {
  if (ModItems.isProbeInHand(player.getHeldItemMainhand())) {
    // If the player holds the probe there is no need to show harvestability information as the
    // probe cannot harvest anything. This is only supposed to work in off hand.
    return;
  }
  boolean harvestable = block.canHarvestBlock(world, pos, player) && world.getBlockState(pos).getBlockHardness(world, pos) >= 0;
  if (harvestable) {
    probeInfo.text(OK + "Harvestable");
  } else {
    probeInfo.text(WARNING + "Not harvestable");
  }
}

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

@Override
public boolean canHarvestBlock(IBlockAccess world, BlockPos blockPos, EntityPlayer player) {
  try {
    return getTile(world, blockPos).getInnerBlockState().getBlock().canHarvestBlock(world, blockPos, player);
  } catch (InvalidInnerBlocksTileException | IllegalArgumentException e) {
    return player.getHeldItemMainhand().getItem().canHarvestBlock(Blocks.STONE.getDefaultState());
  }
}

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

float numer = player.inventory.getStrVsBlock( state );
if ( !state.getBlock().canHarvestBlock( new HarvestWorld( state ), pos, player ) )

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

&& (isToolEffective(blockstate, item) || ForgeHooks.canHarvestBlock(block, player, world, target))) {
final int exp = ForgeHooks.onBlockBreakEvent(world, gameType, player, target);
if (exp != -1 && block.canHarvestBlock(world, target, player)) {
 if (block.removedByPlayer(blockstate, world, target, player, true)) {
  block.onBlockDestroyedByPlayer(world, target, blockstate);

代码示例来源:origin: OpenMods/OpenModsLib

boolean canHarvest = state.getBlock().canHarvestBlock(worldObj, blockPos, fakePlayer);
boolean isRemoved = removeBlock(fakePlayer, blockPos, state, canHarvest);
if (isRemoved && canHarvest) {

代码示例来源:origin: Glitchfiend/ToughAsNails

@SubscribeEvent
  public void onBlockBreak(BlockEvent.BreakEvent event)
  {
    World world = event.getWorld();
    EntityPlayer player = event.getPlayer();
    BlockPos pos = event.getPos();
    IBlockState state = event.getState();
    
    if (!world.isRemote && !player.isCreative())
    {
      boolean canHarvestBlock = state.getBlock().canHarvestBlock(world, pos, player);
      
      if (canHarvestBlock)
      {
        //The only part of this method that is new - the rest is recreating the surrounding circumstances in func_180237_b
        ThirstHandler thirstStats = (ThirstHandler)player.getCapability(TANCapabilities.THIRST, null);
        
        thirstStats.addExhaustion(0.025F);
      }
    }
  }
}

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

private boolean tryBreakRailBlock(IBlockState blockState, World world, BlockPos blockPos, EntityPlayer player) {
  if (world.canMineBlockBody(player, blockPos) && blockState.getBlock().canHarvestBlock(world, blockPos, player)) {
    for (ItemStack drops : blockState.getBlock().getDrops(world, blockPos, blockState, 0)) {
      Block.spawnAsEntity(world, blockPos, drops);
    }
    blockState.getBlock().onBlockDestroyedByPlayer(world, blockPos, blockState);
    blockState.getBlock().onBlockHarvested(world, blockPos, blockState, player);
    blockState.getBlock().breakBlock(world, blockPos, blockState);
    world.setBlockToAir(blockPos);
    return true;
  }
  return false;
}

代码示例来源:origin: McJtyMods/TheOneProbe

static void showHarvestInfo(IProbeInfo probeInfo, World world, BlockPos pos, Block block, IBlockState blockState, EntityPlayer player) {
  boolean harvestable = block.canHarvestBlock(world, pos, player) && world.getBlockState(pos).getBlockHardness(world, pos) >= 0;

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

Block block1 = state1.getBlock();
if (!block1.isToolEffective(((SteamTool) toolStack.getItem()).toolClass(), state1) ||
 !block1.canHarvestBlock(world, pos, player)) {
  continue;

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

testingChisel = true;
chiselSlot.swapWithWeapon();
final boolean canHarvest = blk.canHarvestBlock( world, pos, player );
chiselSlot.swapWithWeapon();
testingChisel = false;

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

if(canHarvest(world, pos, state)) {
  Block block = state.getBlock();
  if(block.canHarvestBlock(world, pos, player))
    block.harvestBlock(world, player, pos, state, world.getTileEntity(pos), stack);
  world.setBlockToAir(pos);

代码示例来源:origin: PenguinSquad/Harvest-Festival

if (!newPos.equals(startPos)) {
  if (!worldIn.isRemote) {
    if (state.getBlock().canHarvestBlock(worldIn, newPos, player)) {
      boolean flag = state.getBlock().removedByPlayer(state, worldIn, newPos, player, true);
      if (flag) {

相关文章

Block类方法