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

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

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

ActionResult.getType介绍

暂无

代码示例

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

public static boolean placeItemBlockRightClick(ItemStack stack, World world, BlockPos pos) {
  EntityPlayer owner = AWFakePlayer.get(world);
  owner.setPosition(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D);
  owner.setHeldItem(EnumHand.MAIN_HAND, stack);
  owner.rotationPitch = 90F % 360F;
  return stack.useItemRightClick(world, owner, EnumHand.MAIN_HAND).getType() == EnumActionResult.SUCCESS;
}

代码示例来源: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);
}

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

if (res == null || res.getType() != EnumActionResult.SUCCESS) {

相关文章

最新文章

更多