本文整理汇总了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;
}
}
}
示例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
}