net.minecraft.util.ActionResult.getResult()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(34)

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

ActionResult.getResult介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

p.posZ += dir.zOffset;
dispensedItem = tm.onItemRightClick( w, p, null ).getResult();

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

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
  ItemStack itemStack = player.getHeldItem(hand);
  RayTraceResult position = this.rayTrace(world, player, true);
  if(position != null && position.typeOfHit == RayTraceResult.Type.BLOCK) {
    Block block = world.getBlockState(position.getBlockPos()).getBlock();
    if(block == Blocks.WATER) {
      world.setBlockToAir(position.getBlockPos());
      return MinecraftHelpers.successAction(itemStack);
    }
  }
  ActionResult<ItemStack> result = super.onItemRightClick(world, player, hand);
  if(result.getResult() != null && result.getResult().getItem() == Items.BUCKET) return MinecraftHelpers.successAction(itemStack);
  return result;
}

代码示例来源:origin: gr8pefish/IronBackpacks

/**
   * Gets the backpack to open from a player's inventory.
   * Checks the selected slot first, then the offhand then the hotbar (left to right) then the main 3 inventory slots (left to right, top to bottom)
   *
   * @param player - the player to check
   * @param hand - the current selected hand
   * @return - an ItemStack containing the backpack, {@link ItemStack#EMPTY} if none found
   */
  @Nonnull
  public static ItemStack getNonequippedBackpackFromInventory(EntityPlayer player, EnumHand hand) {
    //check current item first
    ItemStack held = player.getHeldItem(hand);
    if (!held.isEmpty() && held.getItem() instanceof IBackpack) {
      return held;
    //loop through inventory second
    } else {
      //check offhand
      ItemStack offhand = player.getHeldItem(EnumHand.OFF_HAND);
      if (!offhand.isEmpty() && offhand.getItem() instanceof IBackpack)
        return offhand;

      //check main inventory (hotbar first left to right, then main inventory)
      return getBackpack(player).getResult();
    }
  }
}

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

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  ItemStack stack = player.getHeldItem(hand);
  ItemStack originalStack = stack.copy();
  for (IItemBehaviour behaviour : getBehaviours(stack)) {
    ActionResult<ItemStack> behaviourResult = behaviour.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
    stack = behaviourResult.getResult();
    if (behaviourResult.getType() != EnumActionResult.PASS) {
      if (!ItemStack.areItemStacksEqual(originalStack, stack))
        player.setHeldItem(hand, stack);
      return behaviourResult.getType();
    } else if (stack.isEmpty()) {
      player.setHeldItem(hand, ItemStack.EMPTY);
      return EnumActionResult.PASS;
    }
  }
  return EnumActionResult.PASS;
}

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

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
  ItemStack itemStack = player.getHeldItem(hand);
  for (IItemBehaviour behaviour : getBehaviours(itemStack)) {
    ActionResult<ItemStack> behaviourResult = behaviour.onItemRightClick(world, player, hand);
    itemStack = behaviourResult.getResult();
    if (behaviourResult.getType() != EnumActionResult.PASS) {
      return ActionResult.newResult(behaviourResult.getType(), itemStack);
    } else if (itemStack.isEmpty()) {
      return ActionResult.newResult(EnumActionResult.PASS, ItemStack.EMPTY);
    }
  }
  IItemUseManager useManager = getUseManager(itemStack);
  if (useManager != null && useManager.canStartUsing(itemStack, player)) {
    useManager.onItemUseStart(itemStack, player);
    player.setActiveHand(hand);
    return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
  }
  return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}

相关文章

最新文章

更多