Ipsis Posted January 31, 2016 Posted January 31, 2016 I'm trying to implement a new mob spawner that does not actually spawn entities in the world. To do this, I need access to the drops that a mob would drop if it was killed. Looking at the codebase the onDeath method is handling all the item generation with dropFewItems, dropEquipment and addRandomDrop doing the actual loot selection. However all this code involves actually spawning the item entities in the world which I dont want to do. So I came up with a few idea. 1) Use the LivingDropsEvent to analyze which mobs drop which loot and the looting level used. I can then gather that information and use it to generate the appropriate loot for a fake death. 2) Use a configuration file to define all the mob drops and looting chances. 3) ?? I'm trying to avoid 2 because I would like to handle drops from other mods installed. So 1 would seem to be the best idea, and I've already got an idea on how to fit that in with player progression. What I'd really like to to do create an instance of the entity, kill it and grab the loot information without spawning ANYTHING in the world, but I dont see any way of doing that. Can anyone suggest any other possible methods for doing this? Thanks Ipsis Quote
Choonster Posted January 31, 2016 Posted January 31, 2016 One option is to actually create the entity without spawning it in the world, then kill it using a custom DamageSource that stores the position of the spawner (or the spawner itself). Subscribe to LivingDropsEvent and check the DamageSource : if it's from your spawner, cancel the event and add the loot to the spawner (or do whatever it is that the spawner does with the loot). Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Ipsis Posted January 31, 2016 Author Posted January 31, 2016 Thanks for that Choonster, that worked out perfectly and avoided a LOT of tedious code. A quick test implementation showed all the drops information coming through which is exactly what I wanted. I'm going to try with a few other mods installed and put the event priority down to LOWEST to give other mods a chance to modify the drops before I get it. I'll have to do some more experiments to make sure that the creation/destruction of the entity does not have any unwanted side-effects. Hopefullly not. Thanks again. Quote
Recommended Posts
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.