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

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

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

Block.onPlayerDestroy介绍

暂无

代码示例

代码示例来源: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: PrinceOfAmber/Cyclic

private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) {
  int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face);
  if (random.nextInt(chance) < i && worldIn.isAirBlock(pos)) {//safe fire: only set fire if air
   IBlockState iblockstate = worldIn.getBlockState(pos);
   if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) {
    int j = age + random.nextInt(5) / 4;
    if (j > 15) {
     j = 15;
    }
    worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
   }
   if (iblockstate.getBlock() == Blocks.TNT) {
    Blocks.TNT.onPlayerDestroy(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
   }
  }
 }
}

代码示例来源:origin: TeamWizardry/Wizardry

block.onPlayerDestroy(world, pos, oldState);
block.harvestBlock(world, playerMP, pos, oldState, tile, ItemStack.EMPTY);

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

block.onPlayerDestroy(world, pos, state);
block.onPlayerDestroy(world, pos, state);
block.harvestBlock(world, player, pos, state, tileEntity, stack);
block.dropXpOnBlockBreak(world, pos, xp);
block.onPlayerDestroy(world, pos, state);

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

world.playEvent(2001, posCurrent, Block.getStateId(bsCurrent));
if (blockCurrent.removedByPlayer(bsCurrent, world, posCurrent, player, true)) {
 blockCurrent.onPlayerDestroy(world, posCurrent, bsCurrent);
 if (blockCurrent.removedByPlayer(bsCurrent, world, posCurrent, player, true)) {
  TileEntity tile = world.getTileEntity(posCurrent);
  blockCurrent.onPlayerDestroy(world, posCurrent, bsCurrent);
  blockCurrent.harvestBlock(world, player, posCurrent, bsCurrent, tile, stack);
  blockCurrent.dropXpOnBlockBreak(world, posCurrent, xpGivenOnDrop);

代码示例来源:origin: SquidDev-CC/plethora

block.onPlayerDestroy(world, position, blockState);
block.harvestBlock(world, player, position, blockState, te, ItemStack.EMPTY);

相关文章

Block类方法