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

Adding drops to existing animals?


Meduax
 Share

Recommended Posts

I'd like to add new drops to existing animals like sheep, cows or whatever. For sheep it would be necessary to add the shearing drops, for the other animals the death drops. How would I do that (without editing base classes of course)? Sorry if this is in fact a dumb question but I'm pretty new to Forge.

Help would be greatly appreciated!

Link to comment
Share on other sites

I haven't had time to prepare a sample because I've been busy over the last few days, but I've been messing with some experimental hooks I created.

 

One is for adding code into Entity.onEntityUpdate(), so that changes can be easily applied to Entities that will affect ALL entities at once without requiring base edits. You can, of course, use the hook to target specific Entities of your choosing as well, via a simple if(Entity instanceof).

 

I also added one that lets me hook into EntityPlayer.onDeath(DamageSource) so that I have access to the player as they're dieing. It would probably be trivial for me to refactor this and move it into EntityLiving instead, which would provide direct access to any instance of EntityLiving (which should be basically all mobs) at its moment of death (meaning you can spawn an instance of EntityItem with the proper arguments into the world when the mob dies, or something similar).

 

I'll apply the alterations if you guys would like me to.

I accidentally the everything then NullPointerException.

Link to comment
Share on other sites

Just remember, the more generic the better, and it must have no cost when not used, and low to no cost when it is.

 

They all act basically identical to how the arrow hooks work, with the exception that I used primarily void methods because it made more sense to allow additional code without overriding the entire method.

Currently nothing I've added affects how the default acts unless explicitly changed by the modder, and shouldn't cause problems as long as we all use them responsibly.

 

Also as far as generic goes, I chose to allow hooking into Entity.onUpdate() because that's as generic as you can possibly get in that regard, and it provides a lot of possibilities.

 

I'll go move the death handler up the class tree to EntityLiving and perform testing to make sure it still does what I want it to do and also allows for the new functionality, then I'll get a sample ready and post it here.

I accidentally the everything then NullPointerException.

Link to comment
Share on other sites

Alright, as promised here is a .zip archive containing my modifications and proof of concept submission. Information you will need should be contained in README.txt. Alterations to Entity and EntityLiving will have to be applied manually due to legality, but I've supplied text files with copies of my edits labelled with line numbers.

 

File:

http://www.mediafire.com/?su2cya6zcv4g01p

I accidentally the everything then NullPointerException.

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.