当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.setItemInUse方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.setItemInUse方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.setItemInUse方法的具体用法?Java EntityPlayer.setItemInUse怎么用?Java EntityPlayer.setItemInUse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.setItemInUse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (isSplash(itemStackIn.getMetadata()))
    {
        if (!playerIn.capabilities.isCreativeMode)
        {
            --itemStackIn.stackSize;
        }

        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(new EntityPotion(worldIn, playerIn, itemStackIn));
        }

        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
        return itemStackIn;
    }
    else
    {
        playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
        return itemStackIn;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:29,代码来源:ItemPotion.java

示例2: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player)
{
	ArrowNockEvent event = new ArrowNockEvent(player, is);
	MinecraftForge.EVENT_BUS.post(event);
	if (event.isCanceled())
		return event.result;

	if (player.capabilities.isCreativeMode || player.inventory.hasItem(ModItems.itemSharpStone) || player.inventory.hasItem(ModItems.itemHardStone) || player.inventory.hasItem(ModItems.itemSoftStone) )
		player.setItemInUse(is, this.getMaxItemUseDuration(is));

	return is;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:14,代码来源:ItemSlingshot.java

示例3: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.canEat(this.alwaysEdible))
    {
        playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
    }

    return itemStackIn;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:13,代码来源:ItemFood.java

示例4: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.capabilities.isCreativeMode || playerIn.inventory.hasItem(Items.arrow))
    {
        playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
    }

    return itemStackIn;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:13,代码来源:ItemBow.java

示例5: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
    ArrowNockEvent event = new ArrowNockEvent(player, stack);
    MinecraftForge.EVENT_BUS.post(event);
    if (event.isCanceled()) { return event.result; }

    if (player.capabilities.isCreativeMode || player.inventory.hasItemStack( new ItemStack(Items.arrow) ) )
    {
    	player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); 
    	this.playerName = player.getDisplayName();	// Recording the player name here, so only they can see the projectile
    }
    
    return stack;
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:16,代码来源:EnderBow.java

示例6: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
    return itemStackIn;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:9,代码来源:ItemSword.java

示例7: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
	ArrowNockEvent event = new ArrowNockEvent(player, stack);
	MinecraftForge.EVENT_BUS.post(event);
	if (event.isCanceled()) { return event.result; }

	// Are there any arrows in the quiver?
	if (this.getDamage(stack) < this.getMaxDamage()) {	player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); }

	return stack;
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:13,代码来源:QuiverBow.java


注:本文中的net.minecraft.entity.player.EntityPlayer.setItemInUse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。