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


Java EntityPlayer.isUsingItem方法代码示例

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


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

示例1: tryUseItem

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Attempts to right-click use an item by the given EntityPlayer in the given World
 */
public boolean tryUseItem(EntityPlayer player, World worldIn, ItemStack stack)
{
    if (this.gameType == WorldSettings.GameType.SPECTATOR)
    {
        return false;
    }
    else
    {
        int i = stack.stackSize;
        int j = stack.getMetadata();
        ItemStack itemstack = stack.useItemRightClick(worldIn, player);

        if (itemstack != stack || itemstack != null && (itemstack.stackSize != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getMetadata() != j))
        {
            player.inventory.mainInventory[player.inventory.currentItem] = itemstack;

            if (this.isCreative())
            {
                itemstack.stackSize = i;

                if (itemstack.isItemStackDamageable())
                {
                    itemstack.setItemDamage(j);
                }
            }

            if (itemstack.stackSize == 0)
            {
                player.inventory.mainInventory[player.inventory.currentItem] = null;
            }

            if (!player.isUsingItem())
            {
                ((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
            }

            return true;
        }
        else
        {
            return false;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:48,代码来源:ItemInWorldManager.java

示例2: onUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) 
{		
	if (stack.stackTagCompound == null) 
	{
		stack.stackTagCompound = new NBTTagCompound();
		
		stack.stackTagCompound.setBoolean("isZoomed", false);
		stack.stackTagCompound.setInteger("defaultFOV", 0);	// FOV is now using full numbers. We're recording the current default FOV here
	}

	// let's check zoom here
	if (entity instanceof EntityPlayer) 	// Step 1, is this a player?
       {
		EntityPlayer entityplayer = (EntityPlayer)entity;

		if (entityplayer.inventory.getCurrentItem() != null && entityplayer.inventory.getCurrentItem() == stack)	// Step 2, are they holding the bow?
		{
			if (entityplayer.isUsingItem()) // step 3, are they using the bow?
			{
				this.setCurrentZoom(stack, true); // We need to zoom in!
				
				if (world.isRemote)
				{ 
					//System.out.println("[ENDER BOW] Current FOV: " + Minecraft.getMinecraft().gameSettings.fovSetting);
			    	
			    	// We're gonna zoom in each tick. Is it bigger than the max zoom? Then keep zooming.
			    	if (Minecraft.getMinecraft().gameSettings.fovSetting > ZoomMax) 
			    	{
			    		// FOV is now using full numbers. 70 is 70, 120 is 120. Nice of them.
			    		Minecraft.getMinecraft().gameSettings.fovSetting -= 2;	// 2 less, until we've reached zoomMax
			    	}
				}	
				// else, server side. Has no deal with game settings
				
			}
			else // Not using this item currently
			{
				if (this.isCurrentlyZoomed(stack)) 			// Are we currently zoomed in?
				{
					this.setCurrentZoom(stack, false);
					if (world.isRemote) { this.restoreFOV(stack); }	// Begone with that then
				}
				// else, not zoomed in currently
			}
		}
		else // Not holding the bow
		{
			if (this.isCurrentlyZoomed(stack)) 				// Are we currently zoomed in?
			{
				this.setCurrentZoom(stack, false);
				if (world.isRemote) { this.restoreFOV(stack); } 	// Begone with that then
					
			}
		}
		
		// step 0, recording the current zoom level, if we're not zoomed in. Need to do this AFTER we reset
		if (!this.isCurrentlyZoomed(stack))	// Not zoomed in currently
		{				
			if (world.isRemote) { this.recordCurrentFOV(stack); } // Client side only
		}
	}
	// else, not a player holding this thing
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:65,代码来源:EnderBow.java


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