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


Java ItemStack.getMaxItemUseDuration方法代码示例

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


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

示例1: getForce

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Get the initial velocity of the item
 */
public static double getForce(ItemStack itemStack) {
    double force = 0.D;
    switch (Item.getIdFromItem(itemStack.getItem())) {
        case 261: // bow
        {
            int duration = itemStack.getMaxItemUseDuration() - MC.player.getItemInUseCount();
            force = (double)duration / 20.0F;
            //   force = (force * force + force * 2.0F) / 3.0F;
            if (force > 1.0F)
                force = 1.0F;
            force *= 2d*1.5d;
            break;
        }
        case 332: // snowball
        case 344: // egg
        case 346: // fishing rod
        case 368: // ender pearl
            force = 1.5;
            break;
    }
    return force;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:26,代码来源:ProjectileUtils.java

示例2: setActiveHand

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void setActiveHand(EnumHand hand)
{
    ItemStack itemstack = this.getHeldItem(hand);

    if (!itemstack.func_190926_b() && !this.isHandActive())
    {
        this.activeItemStack = itemstack;
        this.activeItemStackUseCount = itemstack.getMaxItemUseDuration();

        if (!this.world.isRemote)
        {
            int i = 1;

            if (hand == EnumHand.OFF_HAND)
            {
                i |= 2;
            }

            this.dataManager.set(HAND_STATES, Byte.valueOf((byte)i));
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:EntityLivingBase.java

示例3: transformEatFirstPerson

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void transformEatFirstPerson(float p_187454_1_, EnumHandSide p_187454_2_, ItemStack p_187454_3_)
{
    float f = (float)this.mc.player.getItemInUseCount() - p_187454_1_ + 1.0F;
    float f1 = f / (float)p_187454_3_.getMaxItemUseDuration();

    if (f1 < 0.8F)
    {
        float f2 = MathHelper.abs(MathHelper.cos(f / 4.0F * (float)Math.PI) * 0.1F);
        GlStateManager.translate(0.0F, f2, 0.0F);
    }

    float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D);
    int i = p_187454_2_ == EnumHandSide.RIGHT ? 1 : -1;
    GlStateManager.translate(f3 * 0.6F * (float)i, f3 * -0.5F, f3 * 0.0F);
    GlStateManager.rotate((float)i * f3 * 90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(f3 * 10.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate((float)i * f3 * 30.0F, 0.0F, 0.0F, 1.0F);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:ItemRenderer.java

示例4: transformEatFirstPerson

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void transformEatFirstPerson(float p_187454_1_, EnumHandSide p_187454_2_, ItemStack p_187454_3_)
{
    float f = (float)this.mc.thePlayer.getItemInUseCount() - p_187454_1_ + 1.0F;
    float f1 = f / (float)p_187454_3_.getMaxItemUseDuration();

    if (f1 < 0.8F)
    {
        float f2 = MathHelper.abs(MathHelper.cos(f / 4.0F * (float)Math.PI) * 0.1F);
        GlStateManager.translate(0.0F, f2, 0.0F);
    }

    float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D);
    int i = p_187454_2_ == EnumHandSide.RIGHT ? 1 : -1;
    GlStateManager.translate(f3 * 0.6F * (float)i, f3 * -0.5F, f3 * 0.0F);
    GlStateManager.rotate((float)i * f3 * 90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(f3 * 10.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate((float)i * f3 * 30.0F, 0.0F, 0.0F, 1.0F);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:ItemRenderer.java

示例5: onActiveItemUseTick

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SubscribeEvent
public void onActiveItemUseTick(LivingEntityUseItemEvent.Tick event) {
    ItemStack stack = event.getItem();
    if (stack.getItem() == TrumpetSkeletonItems.TRUMPET) {
        if (event.getDuration() == stack.getMaxItemUseDuration() - 10) {
            EntityLivingBase user = event.getEntityLiving();
            World world = user.world;

            user.playSound(TrumpetSkeletonSoundEvents.ITEM_TRUMPET_USE, 1.0F, 0.9F + world.rand.nextFloat() * 0.2F);
            if (!world.isRemote) {
                List<EntityLivingBase> spookedEntities = world.getEntitiesWithinAABB(EntityLivingBase.class, user.getEntityBoundingBox().grow(10.0D));
                for (EntityLivingBase spookedEntity : spookedEntities) {
                    if (spookedEntity == user) continue;
                    double deltaX = user.posX - spookedEntity.posX;
                    double deltaZ = user.posZ - spookedEntity.posZ;
                    double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
                    if (distance > 0.25D) {
                        spookedEntity.knockBack(user, 0.5F, deltaX / distance, deltaZ / distance);
                    }
                    spookedEntity.setRevengeTarget(user);
                }
                stack.damageItem(1, user);
            }
        } else if (event.getDuration() <= stack.getMaxItemUseDuration() - 15) {
            event.setCanceled(true);
        }
    }
}
 
开发者ID:JamiesWhiteShirt,项目名称:trumpet-skeleton,代码行数:29,代码来源:TrumpetSkeleton.java

示例6: getIcon

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
   public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) 
{
	if(player.getItemInUse() == null) { return this.itemIcon; }
        
        int Pulling = stack.getMaxItemUseDuration() - useRemaining;	// Displaying the bow drawing animation based on the use state
       
        if (Pulling >= 18) { return this.pull_2; }
        else if (Pulling > 13) { return this.pull_1; }
        else if (Pulling > 0) { return this.pull_0; }              
        
        return itemIcon;
   }
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:14,代码来源:EnderBow.java

示例7: getIcon

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) 	// On hand display
{
	if(player.getItemInUse() == null) { return this.itemIcon; }

	int Pulling = stack.getMaxItemUseDuration() - useRemaining;	// Displaying the bow drawing animation based on the use state

	if (Pulling >= 18) { return this.pull_2; }
	else if (Pulling > 13) { return this.pull_1; }
	else if (Pulling > 0) { return this.pull_0; }

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

示例8: getIcon

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
       if (usingItem != null && usingItem.getItem() == this)
       {
           int j = usingItem.getMaxItemUseDuration() - useRemaining;
           float force = j / getUseSpeed(player);

		if (force >= 1.25) // Fully drawn
           {
			return getItemIconForUseDuration(3);
		}
		else if (force > 0.75)
           {
			return getItemIconForUseDuration(2);
           }
		else if (force > 0.25) // Minimum required force to fire
           {
               return getItemIconForUseDuration(1);
           }
		else if (force > 0)
           {
               return getItemIconForUseDuration(0);
           }
       }
       return getIcon(stack, renderPass);
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:28,代码来源:ItemSlingshot.java

示例9: processPlayerBlockPlacement

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Processes block placement and block activation (anvil, furnace, etc.)
 */
public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
    boolean flag = false;
    BlockPos blockpos = packetIn.getPosition();
    EnumFacing enumfacing = EnumFacing.getFront(packetIn.getPlacedBlockDirection());
    this.playerEntity.markPlayerActive();

    if (packetIn.getPlacedBlockDirection() == 255)
    {
        if (itemstack == null)
        {
            return;
        }

        this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack);
    }
    else if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ());
        }

        flag = true;
    }
    else
    {
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
        this.playerEntity.playerNetServerHandler.sendPacket(new S02PacketChat(chatcomponenttranslation));
        flag = true;
    }

    if (flag)
    {
        this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos));
        this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos.offset(enumfacing)));
    }

    itemstack = this.playerEntity.inventory.getCurrentItem();

    if (itemstack != null && itemstack.stackSize == 0)
    {
        this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = null;
        itemstack = null;
    }

    if (itemstack == null || itemstack.getMaxItemUseDuration() == 0)
    {
        this.playerEntity.isChangingQuantityOnly = true;
        this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack(this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]);
        Slot slot = this.playerEntity.openContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
        this.playerEntity.openContainer.detectAndSendChanges();
        this.playerEntity.isChangingQuantityOnly = false;

        if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack()))
        {
            this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:68,代码来源:NetHandlerPlayServer.java

示例10: tryUseItem

import net.minecraft.item.ItemStack; //导入方法依赖的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

示例11: renderItem

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
	TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
	ResourceLocation resource = textureManager.getResourceLocation(stack.getItemSpriteNumber());

	EntityPlayer player = Minecraft.getMinecraft().thePlayer;
	ItemStack usingItem = player.getItemInUse();
	int useRemaining = player.getItemInUseCount();

	ItemBow bow = (ItemBow) stack.getItem();

	IIcon icon = bow.getIcon(stack, 0);
	if (usingItem != null && usingItem == stack) {
		int charge = stack.getMaxItemUseDuration() - useRemaining;
		if (charge >= 18)
			icon = bow.getItemIconForUseDuration(2);
		else if (charge > 13)
			icon = bow.getItemIconForUseDuration(1);
		else if (charge > 0)
			icon = bow.getItemIconForUseDuration(0);
	}
	if (icon == null)
		icon = ((TextureMap) textureManager.getTexture(resource)).getAtlasSprite("missingno");

	OpenGLHelper.pushMatrix();
	textureManager.bindTexture(resource);

	OpenGLHelper.colour(bow.getColorFromItemStack(stack, 0));

	OpenGLHelper.disableLighting();
	OpenGLHelper.enableAlpha();
	OpenGLHelper.enableBlend();
	OpenGlHelper.glBlendFunc(770, 771, 1, 0);

	renderItem.renderIcon(0, 0, icon, 16, 16);

	OpenGLHelper.enableLighting();
	OpenGLHelper.disableAlpha();
	OpenGLHelper.disableBlend();

	if (stack.hasEffect(0))
		renderItem.renderEffect(textureManager, 0, 0);

	OpenGLHelper.popMatrix();
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:46,代码来源:ItemBowRenderer.java

示例12: processRightClick

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
    if (this.gameType == GameType.SPECTATOR)
    {
        return EnumActionResult.PASS;
    }
    else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
    {
        return EnumActionResult.PASS;
    }
    else
    {
        int i = stack.func_190916_E();
        int j = stack.getMetadata();
        ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
        ItemStack itemstack = (ItemStack)actionresult.getResult();

        if (itemstack == stack && itemstack.func_190916_E() == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
        {
            return actionresult.getType();
        }
        else if (actionresult.getType() == EnumActionResult.FAIL && itemstack.getMaxItemUseDuration() > 0 && !player.isHandActive())
        {
            return actionresult.getType();
        }
        else
        {
            player.setHeldItem(hand, itemstack);

            if (this.isCreative())
            {
                itemstack.func_190920_e(i);

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

            if (itemstack.func_190926_b())
            {
                player.setHeldItem(hand, ItemStack.field_190927_a);
            }

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

            return actionresult.getType();
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:54,代码来源:PlayerInteractionManager.java

示例13: processRightClick

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
    if (this.gameType == GameType.SPECTATOR)
    {
        return EnumActionResult.PASS;
    }
    else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
    {
        return EnumActionResult.PASS;
    }
    else
    {
        if (net.minecraftforge.common.ForgeHooks.onItemRightClick(player, hand, stack)) return net.minecraft.util.EnumActionResult.PASS;
        int i = stack.stackSize;
        int j = stack.getMetadata();
        ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
        ItemStack itemstack = (ItemStack)actionresult.getResult();

        if (itemstack == stack && itemstack.stackSize == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
        {
            return actionresult.getType();
        }
        else
        {
            player.setHeldItem(hand, itemstack);

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

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

            if (itemstack.stackSize == 0)
            {
                player.setHeldItem(hand, (ItemStack)null);
                net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand);
            }

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

            return actionresult.getType();
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:52,代码来源:PlayerInteractionManager.java


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