Jump to content

Recommended Posts

Posted

[move]Hello there everyone![/move]

 

 

I am trying to create my own horse armor for my mod. I am quite experienced with Java and Minecraft Modding and I thought horse armor would fit well into the mod I was doing. I have had a look at the horse code and realised that the horse armor items are just default items. All of the code is in the EntityHorse class. Looking in this class revealed that there is an array of string with the horse armor textures. Just to see if that worked, i added my own armor texture to that array. Then I found a method called "getHorseArmorIndex(ItemStack)" that told it which texture to use in the array based on what item was placed in the GUI. I added my own code so it would recognise my custom item as a horse armor and load the texture. I tested it in the game, tamed a horse, opened the GUI and tried to drop the item on but nothing happened. What can I do and is it even possible? I would love to know.

 

Thanks!

Romejanic

Romejanic

 

Creator of Witch Hats, Explosive Chickens and Battlefield!

Posted

As far as we know, custom horse armor, as of now, is a no-go without either a crapload of ASM or base edits, either way, things would get ugly really fast :/

This is the creator of the Rareores mod! Be sure to check it out at

  • 8 months later...
Posted

There are some tantalizing openings in entity.horse. If we can change (I think) just the following three methods, then we can add mod armor types with textures and protection values.

 

1) Method private getHorseArmorIndex (ItemStack) translates an armor ItemStack into a horse armor index (e.g. 3 for diamond horse armor). If we can get inside this function, then we can inject indices above diamond's value of 3. Because we don't want  multiple mods to compete for number 4, I recommend that mods not use literal numbers. Instead, we would want a mod to call a registration function that returns the next available index.

 

2) The static final armor values are used only in public getTotalArmorValue(), which means we can use indices above 3 to inject mod values here.  A mod might even be able to detect and apply an effect for the basic "protection" enchantment here.

 

3) Similarly, the static final texture-path strings are used only in private setHorseTexturePaths(). If we can change that function (specifically the final two assignments at the end), then we can intercept mods' indices above 3 and use them to inject mod texture-file paths. The last mystery I saw was field_110273_bx[armorIndex], which appears to be a suffix being appended to a hashed resource label (meo, goo and dio look like metal-o, gold-o and diamond-o, where o might be legacy code for ore). I think that as long as we append any unique string for each armor index (like the index itself), then it will serve to put and get the resource object to and from its hash.

 

I think that's closure on horse armor modding. If I only I knew how to create "hooks" so that I could start the programming!

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Look at this:

http://www.minecraftforge.net/forum/index.php/topic,19692.msg99738.html#msg99738

 

It was a PITA to figure out everything, but it works quite well. I'll also do a PR when I get time.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Aha, so the horse's armor slot also needs to gain intelligence (to accept mod armor items).

 

Since horse armor would have been mostly a programming exercise for me (at the tail end of a new-ore mod), I can afford to wait to see your "hooks" when they get pulled. I've subscribed to the thread you linked, so please post here or there again when there's a forge upgrade with your horse-armor hooks in it.

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.