Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Bow animations? [Solved & Explained by me][page 2]


xXRoboJackXx
 Share

Recommended Posts

Did you even read my post? You have NOT done anything that looks anywhere near what I have suggested. If you are just copy-pasting code (your code looks like that!) you need to go and learn java first. making a copy-paste mod is not a good idea.

 

Fixed it thanks for the help. Topic locked.

Link to comment
Share on other sites

  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

Topic Unlocked.

 

Well let me give the code and explain a bit of it.

 

Just a note the "Texture" from the code (a name I use) Can be anything like wibbly wobbaly or anything it's just a name that you give it, but if you call it something like bow then you'll need to write bow for all of them. Same with N and Time.

  @SideOnly(Side.CLIENT)
    
    private Icon[] Texture = new Icon[4];
    public void updateIcons(IconRegister iconRegister)
    
    {
    	
             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");
             for (int N = 0; N < 4; N++)
             {
                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);
                     
             }
    }
    public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
    {
             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;
             if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

What this:

    private Icon[] Texture= new Icon[4];

Is doing is registering what the Texture does so that code works.

 

This:

    public void updateIcons(IconRegister iconRegister)

Is the method.

 

This:

             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");

Is saying that the mod folder location is at blueeagle and the : is saying that it's going to find a texture in there.

The + getUnlocalizedName() is saying that the unlocalized name for this item is the first part of the texture (the name)

The .substring(5) gets rid of the "item." from the beginning of the string.

The +_0 is adding on a "_0" to the code of the texture. And then the for (int N = 0 < 4; N++) is saying that the number 0 = N and the can only be less then 4.

                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);

Which is saying this Icon[number] = the method iconRegisterIcon("Foldername:" and then it gets the name, takes off the item and adds on the _ and number of the image.

 

This:

    public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

Is the method that will be needed for the rest of the code.

 

This:

             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;

Is when the player is using the bow and int time is: stack.getMaxItemUseDuration() - useRemaining;

 

this:

  if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

This is saying that if time is greater then 18 (The time)

then it will = the return Texture[3]

which is the texture.

So this is going back to the method we write for the Texture which is the unlocalized name and the foldername with the _ and remember that the [N] will be a number so you write [3] in there which will make the code know that inside the [] is a number and this will make the code know now that the texture is located somewhere in the folder blueeagle (and my unlocalized name is AngelBow) it'll add a _ and the number which in this case is 3 so it's looking for the texture which is called

AngelBow_3

then I'm pretty sure you can work out what the else ifs mean.

 

and the return Texture[0] is the bow when not in use.

 

Hope I explained that well :)

Link to comment
Share on other sites

Topic Unlocked.

 

Well let me give the code and explain a bit of it.

 

Just a note the "Texture" from the code (a name I use) Can be anything like wibbly wobbaly or anything it's just a name that you give it, but if you call it something like bow then you'll need to write bow for all of them. Same with N and Time.

  @SideOnly(Side.CLIENT)
    
    private Icon[] Texture = new Icon[4];
    public void updateIcons(IconRegister iconRegister)
    
    {
    	
             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");
             for (int N = 0; N < 4; N++)
             {
                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);
                     
             }
    }
    public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
    {
             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;
             if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

What this:

    private Icon[] Texture= new Icon[4];

Is doing is registering what the Texture does so that code works.

 

This:

    public void updateIcons(IconRegister iconRegister)

Is the method.

 

This:

             iconIndex = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_0");

Is saying that the mod folder location is at blueeagle and the : is saying that it's going to find a texture in there.

The + getUnlocalizedName() is saying that the unlocalized name for this item is the first part of the texture (the name)

The .substring(5) gets rid of the "item." from the beginning of the string.

The +_0 is adding on a "_0" to the code of the texture. And then the for (int N = 0 < 4; N++) is saying that the number 0 = N and the can only be less then 4.

                     this.Texture[N] = iconRegister.registerIcon("blueeagle:" + this.getUnlocalizedName().substring(5) + "_" + N);

Which is saying this Icon[number] = the method iconRegisterIcon("Foldername:" and then it gets the name, takes off the item and adds on the _ and number of the image.

 

This:

    public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

Is the method that will be needed for the rest of the code.

 

This:

             if(player.getItemInUse() == null) return this.iconIndex;
             int time = stack.getMaxItemUseDuration() - useRemaining;

Is when the player is using the bow and int time is: stack.getMaxItemUseDuration() - useRemaining;

 

this:

  if (time >= 18)
             {
                     return Texture[3];
             }
             else if (time > 13)
             {
                     return Texture[2];
             }
             else if (time > 0)
             {
                     return Texture[1];
             }             
             return Texture[0];
             }
    }

This is saying that if time is greater then 18 (The time)

then it will = the return Texture[3]

which is the texture.

So this is going back to the method we write for the Texture which is the unlocalized name and the foldername with the _ and remember that the [N] will be a number so you write [3] in there which will make the code know that inside the [] is a number and this will make the code know now that the texture is located somewhere in the folder blueeagle (and my unlocalized name is AngelBow) it'll add a _ and the number which in this case is 3 so it's looking for the texture which is called

AngelBow_3

then I'm pretty sure you can work out what the else ifs mean.

 

and the return Texture[0] is the bow when not in use.

 

Hope I explained that well :)

Link to comment
Share on other sites

RoboJack, thanks for posting your solution once you figured it out. I've been struggling with the same thing, and that was really helpful.

 

Why did you pick the numbers 13 and 18 for the times? Is that the same timing for regular bows or your own timing?

Link to comment
Share on other sites

RoboJack, thanks for posting your solution once you figured it out. I've been struggling with the same thing, and that was really helpful.

 

Why did you pick the numbers 13 and 18 for the times? Is that the same timing for regular bows or your own timing?

 

It's the same timing as regular bows, glad I could help :)

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
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.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.