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

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

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

Block.dropBlockAsItem介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Override
public void simulateBlockMine(BlockVector3 position) {
  BlockPos pos = ForgeAdapter.toBlockPos(position);
  IBlockState state = getWorld().getBlockState(pos);
  state.getBlock().dropBlockAsItem(getWorld(), pos, state, 0);
  getWorld().setBlockToAir(pos);
}

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

((IHornHarvestable) block).harvestByHorn(world, currCoords, stack, type);
else {
  block.dropBlockAsItem(world, currCoords, state, 0);
  world.setBlockToAir(currCoords);
  if(ConfigHandler.blockBreakParticles)

代码示例来源:origin: amadornes/MCMultiPart

public default void dropPartAsItem(IPartInfo part, int fortune) {
    part.getState().getBlock().dropBlockAsItem(part.getActualWorld(), part.getPartPos(), part.getState(), fortune);
  }
}

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

IBlockState theState = world.getBlockState(theCoord);
theState.getBlock().dropBlockAsItem(world, theCoord, theState, 0);

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

@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
  world.setBlockToAir(pos);
  for (int i = 1; i < 3; i++) {
    BlockPos offset = pos.offset(EnumFacing.DOWN, i);
    IBlockState offsetState = world.getBlockState(offset);
    Block block = world.getBlockState(offset).getBlock();
    if (block == Calculator.scarecrow) {
      block.dropBlockAsItem(world, offset, offsetState, 0);
      world.setBlockToAir(offset);
    }
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private boolean placeProxyIfNotPresent(EntityGate gate, BlockPos pos, boolean openDefault) {
  IBlockState state = gate.world.getBlockState(pos);
  Block block = state.getBlock();
  if (block != AWStructureBlocks.GATE_PROXY) {
    if (!gate.world.isAirBlock(pos)) {
      block.dropBlockAsItem(gate.world, pos, state, 0);
    }
    gate.world.setBlockState(pos, AWStructureBlocks.GATE_PROXY.getDefaultState());
    WorldTools.getTile(gate.world, pos, TEGateProxy.class).ifPresent(t -> {
      t.setOwner(gate);
      t.setOpen(openDefault);
    });
    return true;
  }
  return false;
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

world.playEvent(2001, pos, Block.getStateId(state));
} else {
  state.getBlock().dropBlockAsItem(world, pos, state, 0);

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

@Nonnull
  @Override
  public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (!player.canPlayerEdit(pos, side, stack)) {
      return EnumActionResult.PASS;
    }
    Block block = world.getBlockState(pos).getBlock();
    if (block == Blocks.OBSIDIAN || block instanceof IObsidianDrop && ((IObsidianDrop) block).canKeyDrop(world, pos)) {
      block.dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
      world.setBlockToAir(pos);
      stack.damageItem(1, player);
    }

    return EnumActionResult.SUCCESS;
  }
}

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

private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level) {
  if (this.canFlowInto(state)) {
    if (state.getMaterial() != net.minecraft.block.material.Material.AIR) {
      if (state.getBlock() != Blocks.SNOW_LAYER) {
        state.getBlock().dropBlockAsItem(worldIn, pos, state, 0);
      }
    }
    worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState().withProperty(LEVEL, level), 3);
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

public static boolean breakBlock(World world, BlockPos pos, int fortune, boolean doDrop) {
  if (world.isRemote) {
    return false;
  }
  IBlockState state = world.getBlockState(pos);
  Block block = state.getBlock();
  if (world.isAirBlock(pos) || state.getBlockHardness(world, pos) < 0) {
    return false;
  }
  if (doDrop) {
    if (!canBreakBlock(world, pos, state)) {
      return false;
    }
    block.dropBlockAsItem(world, pos, state, fortune);
  }
  return world.setBlockToAir(pos);
}

代码示例来源:origin: CoFH/ThermalFoundation

protected void interactWithBlock(World world, BlockPos pos) {
  IBlockState state = world.getBlockState(pos);
  if (state.getBlock().isAir(state, world, pos) || state.getBlock() == this) {
    return;
  }
  if (extreme && state.getMaterial() == Material.ROCK && state.getBlock().getBlockHardness(state, world, pos) > 0) {
    state.getBlock().dropBlockAsItem(world, pos, state, 0);
    world.setBlockToAir(pos);
    triggerInteractionEffects(world, pos);
  } else if (hasInteraction(state)) {
    world.setBlockState(pos, getInteraction(state), 3);
  }
}

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

TileEntity i = world.getTileEntity(pos.add(X, -1, Z));
      Block bi = world.getBlockState(pos.add(X, -1, Z)).getBlock();
      bi.dropBlockAsItem(world, pos.add(X, -1, Z), state, 0);
      world.setBlockToAir(pos.add(X, -1, Z));
Block block = transmitter.getBlock();
if (block == Calculator.transmitter) {
  block.dropBlockAsItem(world, offset, state, 0);
  world.setBlockToAir(offset);

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

world.setBlockState(pos, state, flags);
world.setTileEntity(pos, tile);
block.dropBlockAsItem(world, pos, state, 0);
world.setBlockToAir(pos);
destroyed = true;

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

@SubscribeEvent
public void handleCropRightClick(RightClickBlock event) {
 if (!ConfigHandler.allowCropRC) {
  return;
 }
 if (event.getEntityPlayer().getHeldItemMainhand().isEmpty() || !event.getEntityPlayer().isSneaking()) {
  BlockPos pos = event.getPos();
  IBlockState blockState = event.getWorld().getBlockState(pos);
  for (IPlantInfo info : plants) {
   if (info.getGrownState() == blockState) {
    if (event.getWorld().isRemote) {
     event.getEntityPlayer().swingArm(EnumHand.MAIN_HAND);
    } else {
     currentPlant = info;
     blockState.getBlock().dropBlockAsItem(NullHelper.notnullF(event.getWorld(), "RightClickBlock.getWorld()"), pos, blockState, 0);
     currentPlant = null;
     IBlockState newBS = info.getResetState();
     event.getWorld().setBlockState(pos, newBS, 3);
     event.setCanceled(true);
    }
    break;
   }
  }
 }
}

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

if (state.getBlock() != null && state.getBlockHardness(player.getEntityWorld(), pos) <= 10F) {
  Utils.breakBlockWithParticles(player.getEntityWorld(), pos);
  state.getBlock().dropBlockAsItem(player.getEntityWorld(), pos, state, 0);

相关文章

Block类方法