Jump to content

Faster Drawback on my bow


kenoba10

Recommended Posts

Looks like this is it ;)

When i change the value it just shoots nothing no difference in drawback:

public void onPlayerStoppedUsing(ItemStack itemStack, World world, EntityPlayer player, int par4) {

        int j = getMaxItemUseDuration(itemStack) - par4;

        ArrowLooseEvent event = new ArrowLooseEvent(player, itemStack, j);
        MinecraftForge.EVENT_BUS.post(event);
        
        if (event.isCanceled()) {
        	
            return;
            
        }
        
        j = event.charge;

        boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, itemStack) > 0;

        if (flag || player.inventory.hasItem(Item.arrow.itemID)) {
        	
            float f = (float)j / 20.0F;
            f = (f * f + f * 2.0F) / 3.0F;

            if ((double)f < 0.1D) {
            	
                return;
                
            }

            if (f > 1.0F) {
            	
                f = 1.0F;
                
            }

            EntityArrow entityArrow = new EntityArrow(world, player, f * 2.0F);

            if (f == 1.0F) {
            	
                entityArrow.setIsCritical(true);
                
            }

            int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, itemStack);

            if (k > 0) {
            	
                entityArrow.setDamage(entityArrow.getDamage() + (double)k * 0.5D + 0.5D);
                
            }

            int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, itemStack);

            if (l > 0) {
            	
                entityArrow.setKnockbackStrength(l);
                
            }

            if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, itemStack) > 0) {
            	
                entityArrow.setFire(100);
                
            }

            itemStack.damageItem(1, player);
            world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

            if (flag) {
            	
                entityArrow.canBePickedUp = 2;
                
            }
            else {
            	
                player.inventory.consumeInventoryItem(Item.arrow.itemID);
                
            }

            if (!world.isRemote) {
            	
                world.spawnEntityInWorld(entityArrow);
                
            }
            
        }
        
    }

Link to comment
Share on other sites

If you want the visibility of the bow to draw faster, try changing when the bow texture changes.

 

@SideOnly(Side.CLIENT)

    /**
     * Gets the Icon Index of the item currently held
     */
    public Icon getItemIcon(ItemStack par1ItemStack, int par2)
    {
        Icon icon = super.getItemIcon(par1ItemStack, par2);

        if (par1ItemStack.itemID == Item.fishingRod.itemID && this.fishEntity != null)
        {
            icon = Item.fishingRod.func_94597_g();
        }
        else
        {
            if (par1ItemStack.getItem().requiresMultipleRenderPasses())
            {
                return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
            }

            if (this.itemInUse != null && par1ItemStack.itemID == Item.bow.itemID)
            {
                int j = par1ItemStack.getMaxItemUseDuration() - this.itemInUseCount;

                if (j >= 18)
                {
                    return Item.bow.getItemIconForUseDuration(2);
                }

                if (j > 13)
                {
                    return Item.bow.getItemIconForUseDuration(1);
                }

                if (j > 0)
                {
                    return Item.bow.getItemIconForUseDuration(0);
                }
            }
            icon = par1ItemStack.getItem().getIcon(par1ItemStack, par2, this, itemInUse, itemInUseCount);
        }

        return icon;
    }

 

I found the above code in the EntityPlayer class. But that is not where you can edit it. Since you are wanting this for custom bows, that method should be like this:

@SideOnly(Side.CLIENT)

    /**
     * Gets the Icon Index of the item currently held
     */
    public Icon getItemIcon(ItemStack par1ItemStack, int par2)
    {
                int j = par1ItemStack.getMaxItemUseDuration() - this.itemInUseCount;

                if (j >= 18)
                {
                    return Item.bow.getItemIconForUseDuration(2);
                }

                if (j > 13)
                {
                    return Item.bow.getItemIconForUseDuration(1);
                }

                if (j > 0)
                {
                    return Item.bow.getItemIconForUseDuration(0);
                }
        return icon;
    }

 

Also, it would be a good idea to change it to the bowPull array directly, seeing as you can access it directly.

 

I hope you get the drift of what to do :D

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

If you want the visibility of the bow to draw faster, try changing when the bow texture changes.

 

@SideOnly(Side.CLIENT)

    /**
     * Gets the Icon Index of the item currently held
     */
    public Icon getItemIcon(ItemStack par1ItemStack, int par2)
    {
        Icon icon = super.getItemIcon(par1ItemStack, par2);

        if (par1ItemStack.itemID == Item.fishingRod.itemID && this.fishEntity != null)
        {
            icon = Item.fishingRod.func_94597_g();
        }
        else
        {
            if (par1ItemStack.getItem().requiresMultipleRenderPasses())
            {
                return par1ItemStack.getItem().getIcon(par1ItemStack, par2);
            }

            if (this.itemInUse != null && par1ItemStack.itemID == Item.bow.itemID)
            {
                int j = par1ItemStack.getMaxItemUseDuration() - this.itemInUseCount;

                if (j >= 18)
                {
                    return Item.bow.getItemIconForUseDuration(2);
                }

                if (j > 13)
                {
                    return Item.bow.getItemIconForUseDuration(1);
                }

                if (j > 0)
                {
                    return Item.bow.getItemIconForUseDuration(0);
                }
            }
            icon = par1ItemStack.getItem().getIcon(par1ItemStack, par2, this, itemInUse, itemInUseCount);
        }

        return icon;
    }

 

I found the above code in the EntityPlayer class. But that is not where you can edit it. Since you are wanting this for custom bows, that method should be like this:

@SideOnly(Side.CLIENT)

    /**
     * Gets the Icon Index of the item currently held
     */
    public Icon getItemIcon(ItemStack par1ItemStack, int par2)
    {
                int j = par1ItemStack.getMaxItemUseDuration() - this.itemInUseCount;

                if (j >= 18)
                {
                    return Item.bow.getItemIconForUseDuration(2);
                }

                if (j > 13)
                {
                    return Item.bow.getItemIconForUseDuration(1);
                }

                if (j > 0)
                {
                    return Item.bow.getItemIconForUseDuration(0);
                }
        return icon;
    }

 

Also, it would be a good idea to change it to the bowPull array directly, seeing as you can access it directly.

 

I hope you get the drift of what to do :D

I've done this and thats not exactly what im talking about. I decided to give up on this because I think its a value that can't be changed

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.