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

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

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

Block.getExpDrop介绍

暂无

代码示例

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

@Override
public int getExpDrop(IBlockState state, IBlockAccess world, BlockPos pos, int fortune) {
  Random rand = world instanceof World ? ((World) world).rand : new Random();
  if (state.getValue(ORE_RESOURCES) == EnumResourceType.APATITE) {
    return MathHelper.getInt(rand, 1, 4);
  }
  return super.getExpDrop(state, world, pos, fortune);
}

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

@SubscribeEvent
public static void handleBlockBreak(BreakEvent event) {
 int level = getXPBoostLevel(event.getPlayer());
 if (level >= 0) {
  final @Nonnull IBlockState state = NullHelper.notnullF(event.getState(), "BreakEvent.getState()");
  final @Nonnull World world = NullHelper.notnullF(event.getWorld(), "BreakEvent.getWorld()");
  final @Nonnull BlockPos pos = NullHelper.notnullF(event.getPos(), "BreakEvent.getPos()");
  final int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, event.getPlayer().getHeldItemMainhand());
  final int xp = state.getBlock().getExpDrop(state, world, pos, fortune);
  if (xp > 0) {
   world.spawnEntity(new EntityXPOrb(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, getXPBoost(xp, level)));
  }
 }
}

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

@SubscribeEvent(priority = EventPriority.LOWEST)
public void onBreakEvent(BreakEvent event) {
 World world = event.getWorld();
 EntityPlayer player = event.getPlayer();
 if (player == null) {
  return;
 }
 BlockPos pos = event.getPos();
 int level = this.getCurrentLevelTool(player);
 if (level <= 0) {
  return;
 }
 Block block = event.getState().getBlock();
 int xpDropped = block.getExpDrop(event.getState(), world, pos, 0);
 int bonus = xpDropped * XP_PER_LVL * level;
 UtilExperience.incrementExp(player, bonus);
 //    dropExp(world, pos, xpDropped * XP_PER_LVL * level);
}

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

public static BreakEvent createBreakEvent(IBlockState state, EntityPlayer player, World world, BlockPos pos, ItemStack tool) {
  BreakEvent event = new BreakEvent(world, pos, state, player);
  if (state == null || !canHarvestBlock(state.getBlock(), player, world, pos, tool) ||
      (state.getBlock().canSilkHarvest(world, pos, world.getBlockState(pos), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0))
    event.setExpToDrop(0);
  else
    event.setExpToDrop(state.getBlock().getExpDrop(state, world, pos,
        EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, tool)));
  return event;
}

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

block.dropXpOnBlockBreak(world, targetPos, block.getExpDrop(targetState, world, targetPos, fortuneXp));
world.destroyBlock(targetPos, false);
wasHarvested.add(targetPos);

相关文章

Block类方法