Java 类net.minecraft.util.ActionResult 实例源码

项目:CustomWorldGen    文件:ItemSnowball.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
        entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitysnowball);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
项目:Firma    文件:PebbleItem.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
    ItemStack is = player.getHeldItem(handIn);
    if (player.getHeldItemMainhand().getCount() > 1) {
        if (worldIn.isRemote) {
            GuiKnapping.staticMaterial = CraftMat.STONE;
            GuiKnapping.staticMaterialSub = this.getSubName(is.getItemDamage());

        } else {
            PlayerData pd = PlayerData.getPlayerData(player.getUniqueID());
            pd.resetKnapCraft();
            pd.setItemStack(player.getHeldItemMainhand());
            pd.setCraftingMaterial(CraftMat.STONE);
        }
    }
    player.openGui(FirmaMod.instance, GuiHandler.GUI_KNAPPING, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
    return new ActionResult<ItemStack>(EnumActionResult.PASS, is);
}
项目:Backmemed    文件:ItemSplashPotion.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);
    ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!itemStackIn.isRemote)
    {
        EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
        entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entitypotion);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
项目:Bewitchment    文件:ItemTalisman.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
        for (int i = 0; i < baubles.getSlots(); i++)
            if (baubles.getStackInSlot(i).isEmpty() && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) {
                baubles.setStackInSlot(i, player.getHeldItem(hand).copy());
                if (!player.capabilities.isCreativeMode) {
                    player.setHeldItem(hand, ItemStack.EMPTY);
                }
                onEquipped(player.getHeldItem(hand), player);
                break;
            }
    }
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
项目:CustomWorldGen    文件:ItemLingeringPotion.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn);
        entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitypotion);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
项目:CustomWorldGen    文件:ItemElytra.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemStackIn);
    ItemStack itemstack = playerIn.getItemStackFromSlot(entityequipmentslot);

    if (itemstack == null)
    {
        playerIn.setItemStackToSlot(entityequipmentslot, itemStackIn.copy());
        itemStackIn.stackSize = 0;
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
    else
    {
        return new ActionResult(EnumActionResult.FAIL, itemStackIn);
    }
}
项目:Bewitchment    文件:ItemTriskelionAmulet.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
        for (int i = 0; i < baubles.getSlots(); i++)
            if (baubles.getStackInSlot(i).isEmpty() && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) {
                baubles.setStackInSlot(i, player.getHeldItem(hand).copy());
                if (!player.capabilities.isCreativeMode) {
                    player.setHeldItem(hand, ItemStack.EMPTY);
                }
                onEquipped(player.getHeldItem(hand), player);
                break;
            }
    }
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
项目:SimplyTea    文件:SimplyTea.java   
@Override
   public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn){
       ItemStack stack = playerIn.getHeldItem(handIn);
       if (stack.getMetadata() == 0){
        RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
        if (raytraceresult != null && raytraceresult.typeOfHit != null && raytraceresult.typeOfHit == Type.BLOCK){
            IBlockState state = worldIn.getBlockState(raytraceresult.getBlockPos());
            if (state.getBlock() == Blocks.WATER){
                stack.setItemDamage(1);
                playerIn.setHeldItem(handIn, stack);
                return new ActionResult<ItemStack>(EnumActionResult.SUCCESS,stack);
            }
        }
       }
    return new ActionResult<ItemStack>(EnumActionResult.FAIL,stack);
}
项目:CustomWorldGen    文件:ItemEnderPearl.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    playerIn.getCooldownTracker().setCooldown(this, 20);

    if (!worldIn.isRemote)
    {
        EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);
        entityenderpearl.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entityenderpearl);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
项目:RunicArcana    文件:ItemPaperScrap.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {

    if(worldIn.isRemote)
    {
        //check to make sure the player didn't just click on a chalk tile
        //it's a little hacky but it gets the job done eh?
        if (worldIn.getBlockState(playerIn.rayTrace(5.0f, 0).getBlockPos()).getBlock()!= ModBlocks.chalkBase) {

            //if the scrap has nbtdata for text, open it.  Otherwise open a blank scrap
            if (itemStackIn.getTagCompound() == null || !itemStackIn.getTagCompound().hasKey("text"))
                Minecraft.getMinecraft().displayGuiScreen(new GuiPaperScrap(""));
            else
                Minecraft.getMinecraft().displayGuiScreen(new GuiPaperScrap(itemStackIn.getTagCompound().getString("text")));
        }
    }


    return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
}
项目:SentinentAImod    文件:CoreItemEgg.java   
/**
 * Called when the equipped item is right clicked.
 */
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
    ItemStack itemstack = playerIn.getHeldItem(handIn);
        itemstack.shrink(1);

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
            EntityEgg entityegg = new CoreEntityEgg(worldIn, playerIn);
        entityegg.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntity(entityegg);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
项目:CustomWorldGen    文件:ItemArmor.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemStackIn);
    ItemStack itemstack = playerIn.getItemStackFromSlot(entityequipmentslot);

    if (itemstack == null)
    {
        playerIn.setItemStackToSlot(entityequipmentslot, itemStackIn.copy());
        itemStackIn.stackSize = 0;
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
    else
    {
        return new ActionResult(EnumActionResult.FAIL, itemStackIn);
    }
}
项目:WirelessRedstone    文件:ItemWirelessTracker.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemStack = player.getHeldItem(hand);
    if (player.isSneaking()) {
        return super.onItemRightClick(world, player, hand);
    }

    if (getItemFreq(itemStack) == 0)
        return new ActionResult<>(EnumActionResult.PASS, itemStack);

    if (!player.capabilities.isCreativeMode) {
        itemStack.shrink(1);
    }
    if (!world.isRemote) {
        world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
        EntityWirelessTracker tracker = new EntityWirelessTracker(world, getItemFreq(itemStack), player);
        world.spawnEntity(tracker);
        WRServerPH.sendThrowTracker(tracker, player);
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
项目:CustomWorldGen    文件:ItemCarrotOnAStick.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.getRidingEntity();

        if (itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7 && entitypig.boost())
        {
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.FISHING_ROD);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }

            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
项目:minecraft-territorialdealings    文件:FactionOverviewCard.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
    if (world.isRemote) { return new ActionResult(EnumActionResult.PASS, stack); }  // Not doing this on client side

    if (!player.capabilities.isCreativeMode) { return new ActionResult(EnumActionResult.PASS, stack); } // Creative mode only

    if (player.isSneaking())
    {
        this.toggleChunkProtection(player);
    }
    else
    {
        this.getFactionInfo(player);
    }

    return new ActionResult(EnumActionResult.PASS, stack);
}
项目:Mods    文件:TNTCannon.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World par2World, EntityPlayer player,
        EnumHand hand) {
    // System.out.println("lel "+stack.getTagCompound().getInteger("wait")+"
    // "+this.allowShot(player,stack, par2World));
    ItemStack stack=player.getHeldItem(hand);
    if (!(stack.hasTagCompound() && stack.getTagCompound().getInteger("wait") > 0)
            && this.allowShot(player, stack, par2World)) {
        if (!this.usesBowAnimation(stack))
            this.use(stack, par2World, player, 1.8f,
                    player.inventory.getStackInSlot(this.getSlotForUse(player, stack)), false);
        else
            // System.out.println("trying");
            player.setActiveHand(hand);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }
    return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
项目:Backmemed    文件:ItemEmptyMap.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = ItemMap.func_190906_a(itemStackIn, worldIn.posX, worldIn.posZ, (byte)0, true, false);
    ItemStack itemstack1 = worldIn.getHeldItem(playerIn);
    itemstack1.func_190918_g(1);

    if (itemstack1.func_190926_b())
    {
        return new ActionResult(EnumActionResult.SUCCESS, itemstack);
    }
    else
    {
        if (!worldIn.inventory.addItemStackToInventory(itemstack.copy()))
        {
            worldIn.dropItem(itemstack, false);
        }

        worldIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.SUCCESS, itemstack1);
    }
}
项目:PurificatiMagicae    文件:ItemPapyrus.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer p, EnumHand handIn)
{
    ItemStack stack = p.getHeldItem(handIn);
    if (!worldIn.isRemote)
    {
        IIfEntryStore store = p.getCapability(CapabilityRegistry.ENTRY_STORE_CAP, null);
        for (Pair<IfEntry, IRSReadPapyrus> pair : PurMag.INSTANCE.getIfRegistry().getAllResearchableSteps(IRSReadPapyrus.class, p, store))
        {
            if (pair.getRight().isSuitable(stack))
            {
                store.unlockStepAndSync(pair.getLeft().getId(), (EntityPlayerMP)p);
            }
        }
    }
    if (stack.hasTagCompound())
    {
        if (stack.getTagCompound().hasKey("papyrus_id"))
        {
            PurMag.proxy.openPapyrus(stack.getTagCompound().getString("papyrus_id"));
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, stack);
}
项目:PurificatiMagicae    文件:ItemGlove.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{

    ItemStack glove = playerIn.getHeldItem(handIn);
    if (handIn == EnumHand.OFF_HAND)
    {
        ItemStack shard = playerIn.getHeldItem(EnumHand.MAIN_HAND);
        if (shard.getItem() == ItemRegistry.crystal_shard)
        {
            int shrink = playerIn.isSneaking() ? shard.getCount() : 1;
            playerIn.playSound(SoundRegistry.GLASS, 1, 1);
            if (ItemSipAmulet.checkForAmulet(playerIn))
            {
                ItemStack amulet = ItemUtils.getBauble(playerIn, BaubleType.AMULET.getValidSlots()[0]);
                amulet.getCapability(CapabilityRegistry.SIP_STORE_CAP, null).add(SipUtils.getSipInStack(shard), shrink);
                ItemUtils.setBauble(playerIn, BaubleType.AMULET.getValidSlots()[0], amulet);
            }
            playerIn.getHeldItem(EnumHand.MAIN_HAND).shrink(shrink);
            return new ActionResult<>(EnumActionResult.SUCCESS, glove);
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, glove);
}
项目:minecraft-territorialdealings    文件:PaymentOrder.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
    if (world.isRemote) { return new ActionResult(EnumActionResult.PASS, stack); }  // Not doing this on client side

    // TODO: Change from damage to nbt, since damage directly affects the "model" apparently

    int amount = this.getDamage(stack);

    if (this.addUpkeepToFaction(amount, player))
    {
        stack.stackSize -= 1;   // Successful, so consuming it now
        //world.playAuxSFXAtEntity(player, "random.pop", 0.5f, 2.0f);   // SFX
    }

    return new ActionResult(EnumActionResult.PASS, stack);
}
项目:Halloween    文件:ItemCurseOrb.java   
@Override
    public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
    {
        ItemStack stack = player.getHeldItem(hand);

        if (!player.capabilities.isCreativeMode)
        {
            stack.shrink(1);
        }

        world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!world.isRemote)
        {
            EntityCurseOrb entity = new EntityCurseOrb(world, player);
            entity.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
            world.spawnEntity(entity);
        }

//      playerIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.SUCCESS, stack);
    }
项目:EndermanEvolution    文件:ItemFrienderPearl.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (!player.capabilities.isCreativeMode) {
        stack.shrink(1);
    }

    worldIn.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    player.getCooldownTracker().setCooldown(this, 20);

    if (!worldIn.isRemote) {
        EntityFrienderPearl entityenderpearl = new EntityFrienderPearl(worldIn, player);
        entityenderpearl.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
        EasyMappings.spawn(worldIn, entityenderpearl);
    }

    player.addStat(StatList.getObjectUseStats(this));
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
项目:CustomWorldGen    文件:ItemBow.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    boolean flag = this.findAmmo(playerIn) != null;

    ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemStackIn, worldIn, playerIn, hand, flag);
    if (ret != null) return ret;

    if (!playerIn.capabilities.isCreativeMode && !flag)
    {
        return !flag ? new ActionResult(EnumActionResult.FAIL, itemStackIn) : new ActionResult(EnumActionResult.PASS, itemStackIn);
    }
    else
    {
        playerIn.setActiveHand(hand);
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
}
项目:uniquecrops    文件:ItemEdibleMetal.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {

    ItemStack toConvert = convertEdibles(stack);
    if (!UniqueCrops.baublesLoaded) {
        if (!world.isRemote)
            player.setHeldItem(hand, toConvert);
        return ActionResult.newResult(EnumActionResult.PASS, toConvert);
    } else {
        ItemStack bauble = BaublesApi.getBaublesHandler(player).getStackInSlot(6);
        if (bauble == null || (bauble != null && bauble.getItem() != UCBaubles.emblemIronstomach)) {
            if (!world.isRemote) {
                player.setHeldItem(hand, toConvert);
            }
            return ActionResult.newResult(EnumActionResult.PASS, toConvert);
        }
    }
    return super.onItemRightClick(stack, world, player, hand);
   }
项目:Backmemed    文件:ItemArmor.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);
    EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);
    ItemStack itemstack1 = worldIn.getItemStackFromSlot(entityequipmentslot);

    if (itemstack1.func_190926_b())
    {
        worldIn.setItemStackToSlot(entityequipmentslot, itemstack.copy());
        itemstack.func_190920_e(0);
        return new ActionResult(EnumActionResult.SUCCESS, itemstack);
    }
    else
    {
        return new ActionResult(EnumActionResult.FAIL, itemstack);
    }
}
项目:Backmemed    文件:ItemEnderPearl.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (!worldIn.capabilities.isCreativeMode)
    {
        itemstack.func_190918_g(1);
    }

    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_ENDERPEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    worldIn.getCooldownTracker().setCooldown(this, 20);

    if (!itemStackIn.isRemote)
    {
        EntityEnderPearl entityenderpearl = new EntityEnderPearl(itemStackIn, worldIn);
        entityenderpearl.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entityenderpearl);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
项目:Backmemed    文件:ItemEgg.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (!worldIn.capabilities.isCreativeMode)
    {
        itemstack.func_190918_g(1);
    }

    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!itemStackIn.isRemote)
    {
        EntityEgg entityegg = new EntityEgg(itemStackIn, worldIn);
        entityegg.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entityegg);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
项目:Backmemed    文件:PlayerControllerMP.java   
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, EnumHand stack)
{
    if (this.currentGameType == GameType.SPECTATOR)
    {
        return EnumActionResult.PASS;
    }
    else
    {
        this.syncCurrentPlayItem();
        this.connection.sendPacket(new CPacketPlayerTryUseItem(stack));
        ItemStack itemstack = player.getHeldItem(stack);

        if (player.getCooldownTracker().hasCooldown(itemstack.getItem()))
        {
            return EnumActionResult.PASS;
        }
        else
        {
            int i = itemstack.func_190916_E();
            ActionResult<ItemStack> actionresult = itemstack.useItemRightClick(worldIn, player, stack);
            ItemStack itemstack1 = (ItemStack)actionresult.getResult();

            if (itemstack1 != itemstack || itemstack1.func_190916_E() != i)
            {
                player.setHeldItem(stack, itemstack1);
            }

            return actionresult.getType();
        }
    }
}
项目:MineCamera    文件:ItemFilm.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn,
        EnumHand hand) {
    // itemStackIn.getTagCompound().setString("pid",
    // "Player735_1510202549059");
    /*
     * NBTTagCompound filmdata=new NBTTagCompound();
     * filmdata.setString("id", "none"); NBTTagCompound nc=new
     * NBTTagCompound(); itemStackIn.writeToNBT(nc); nc.setTag("tag",
     * filmdata); itemStackIn.readFromNBT(nc);
     */
    System.out.println("0:" + hand);
    System.out.println("1:" + playerIn.getActiveHand());
    playerIn.setActiveHand(hand);
    if (playerIn instanceof EntityPlayerMP) {
        ((EntityPlayerMP) playerIn).setActiveHand(hand);
    }
    System.out.println("2:" + playerIn.getActiveHand());
    System.out.println(itemStackIn.hasTagCompound());
    // String id =itemStackIn.getTagCompound().getString("pid");
    // String user =itemStackIn.getTagCompound().getString("user");
    // System.out.println("pid="+id);
    // System.out.println("user="+user);
    // itemStackIn.getTagCompound().setString("pid", "123456");
    // itemStackIn.getTagCompound().setString("user", "PorPit");
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
项目:Mods    文件:ItemBonk.java   
@Override
public ActionResult<ItemStack> onItemRightClick( World worldIn, EntityPlayer playerIn,
        EnumHand hand) {
    ItemStack itemStackIn=playerIn.getHeldItem(hand);
    Integer value = playerIn.getCapability(TF2weapons.WEAPONS_CAP, null).effectsCool
            .get(getData(itemStackIn).getName());
    if (value == null || value <= 0) {
        playerIn.setActiveHand(hand);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
    }
    return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
项目:pnc-repressurized    文件:ItemRemote.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (handIn != EnumHand.MAIN_HAND) return ActionResult.newResult(EnumActionResult.PASS, stack);
    if (!world.isRemote) {
        openGui(player, stack);
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
项目:pnc-repressurized    文件:ItemLogisticsFrame.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand handIn) {
    ItemStack stack = player.getHeldItem(handIn);
    if (handIn != EnumHand.MAIN_HAND) return ActionResult.newResult(EnumActionResult.PASS, stack);
    if (!world.isRemote) {
        player.openGui(PneumaticCraftRepressurized.instance, ((SemiBlockLogistics) getSemiBlock(world, null, stack)).getGuiID().ordinal(), world, 0, 0, 0);
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
项目:minecraft-territorialdealings    文件:FactionLedger.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
    if (world.isRemote) { return new ActionResult(EnumActionResult.PASS, stack); }  // Not doing this on client side

    if (stack.hasTagCompound()) // Has been tagged by a leader, so displaying info about that faction now that you used it
    {
        this.displayFactionInfo(player, stack);
    }
    else
    {
        _Territory faction = TerritoryHandler.getFactionPlayerIsLeaderOf(player);

        if (faction != null)
        {
            stack.setTagCompound(new NBTTagCompound()); // Init
            stack.getTagCompound().setString("ownerName", player.getName());
            stack.getTagCompound().setString("playerUUID", player.getGameProfile().getId().toString()); // UUID of the faction leader
            stack.getTagCompound().setString("factionName", faction.getFactionName());                  // Name of the faction

            stack.setItemDamage(1);
        }
        else
        {
            Main.sendMessageToPlayer(player, "You don't seem to be the leader of any faction.");
        }
        // else, not the leader of any faction, so doesn't matter
    }

    return new ActionResult(EnumActionResult.PASS, stack);
}
项目:Minecoprocessors    文件:ItemBookCode.java   
@Override
public ActionResult<ItemStack> onItemRightClick(final World world, final EntityPlayer player, final EnumHand hand) {
  if (world.isRemote) {
    player.openGui(Minecoprocessors.INSTANCE, MinecoprocessorGuiHandler.MINECOPROCESSOR_BOOK_GUI, world, 0, 0, 0);
  }
  return super.onItemRightClick(world, player, hand);
}
项目:Backmemed    文件:ItemFood.java   
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (worldIn.canEat(this.alwaysEdible))
    {
        worldIn.setActiveHand(playerIn);
        return new ActionResult(EnumActionResult.SUCCESS, itemstack);
    }
    else
    {
        return new ActionResult(EnumActionResult.FAIL, itemstack);
    }
}
项目:Bewitchment    文件:ItemTarots.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    if (playerIn.isSneaking()) {
        ItemStack stack = playerIn.getHeldItem(handIn);
        if (!stack.hasTagCompound())
            stack.setTagCompound(new NBTTagCompound());
        stack.getTagCompound().setString("read_id", EntityPlayer.getUUID(playerIn.getGameProfile()).toString());
        stack.getTagCompound().setString("read_name", playerIn.getDisplayNameString());
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
    }
    return super.onItemRightClick(worldIn, playerIn, handIn);
}
项目:Bewitchment    文件:ItemTaglock.java   
@SuppressWarnings("ConstantConditions")
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
        RayTraceResult result = RayTraceHelper.rayTraceResult(player, RayTraceHelper.fromLookVec(player, 2), true, true);
        if (result != null && result.typeOfHit == ENTITY && result.entityHit instanceof EntityLivingBase) {
            setVictim(player.getHeldItem(hand), (EntityLivingBase) result.entityHit);
        }
    }
    return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
项目:Bewitchment    文件:ItemBrewLinger.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
    ItemStack itemstack = playerIn.getHeldItem(hand);
    ItemStack copy = playerIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
    playerIn.playSound(SoundEvents.ENTITY_LINGERINGPOTION_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote) {
        EntityBrew brew = new EntityBrew(worldIn, playerIn, copy, EntityBrew.BrewDispersion.LINGER);

        brew.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
        worldIn.spawnEntity(brew);
    }

    return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
项目:harshencastle    文件:BaseHarshenStaff.java   
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
    boolean flag = canItemBeUsed(worldIn, playerIn, handIn);
    if(flag && getMaxItemUseDuration(playerIn.getHeldItem(handIn)) > 0)
        playerIn.setActiveHand(handIn);
    if(getMaxItemUseDuration(playerIn.getHeldItem(handIn)) < 0)
        onItemUseFinish(playerIn.getHeldItem(handIn), worldIn, playerIn);
    return new ActionResult<ItemStack>(flag ? EnumActionResult.SUCCESS : EnumActionResult.PASS, playerIn.getHeldItem(handIn));
}
项目:minecraft-territorialdealings    文件:TerritoryMap.java   
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
   {
    if (this.isMapReady(stack))
    {
        // Is already a map, so nothing to be done here
    }
    else
    {
        // Initiating it now
        stack.setTagCompound(new NBTTagCompound());
        stack.getTagCompound().setBoolean("initiated", true);

        stack.setItemDamage(world.getUniqueDataId("map"));

        String uniqueName = "map_" + stack.getItemDamage();

        MapData mapdata = new MapData(uniqueName);
        world.setItemData(uniqueName, mapdata);

        mapdata.scale = 2;                  // Default scale
        int i = 128 * (1 << mapdata.scale);

        mapdata.xCenter = (int)(Math.round(player.posX / i) * i);
        mapdata.zCenter = (int)(Math.round(player.posZ / i) * i);
        mapdata.dimension = world.provider.getDimension();

        mapdata.markDirty();
    }

       return new ActionResult(EnumActionResult.PASS, stack);
   }