Open TheUnderTaker11 opened 1 year ago
FYI, I've got a private server I'll be running this on so I'll let you know if any problems arise, but again I've got dropAsBlockOnDeath=false in that config.
Also I guess it's worth noting that if a gravestone mod can't handle the extra items, that's the fault of the gravestone mod as there is already plenty of mods that add extra item slots to the player, such as baubles.
Also a potential edge case I just tested in case was dying with a backpack on but absolutely nothing in my inventory. The event was still called so it still worked as expected.
Thank you for the help! I've already stopped modding and I'm not sure if @ChloeDawn is still working on the port. If you'd like you could fork the project and such.
I looked at the code a bit, and other than naming some things differently, one thing that I might've done is use the existing WorldUtil
function to create the EntityItem
- just add an optional parameter for whether to actually spawn the item in-world?
I saw the player.dropItem
portion of that logic and figured I would leave it alone. I didn't care to try and investigate if that portion of the code tried to delete the stack from the players inventory or set it's size to 0 or something like that. Also it's pretty trivial to create an item entity anyways.
Though now that you mention it it would make much more sense to move the createItemToDropFromEntity
method I created over to the WorldUtil
class.
Previously the mod manually spawned the items into the world, completely bypassing/negating any gravestone mods.
Also split the "onDeath(EntityLivingBase entity, IBackpack backpack)" method of IBackpackType into 2 different methods, because calling it "onDeath" wasn't really specific enough anyways.
I haven't tested this super thoroughly or anything, but here is the current test cases I've done so far in dev.
These 5 test cases were all done with just this mod and Corpse mod installed, and all test had 3 stacks of orange wool in the backpack unless otherwise specified.
These 4 test cases were done with ONLY this mod installed. All 4 test had 3 stacks of orange wool in the backpack.
All test cases for both mod situations worked as expected. (With items either dropping on ground, or going into the corpse as they should). All test were done with dropAsBlockOnDeath=false, since my logic excludes anything special/different from your code from happening when that is true, and I don't feel like doing a bunch of testing again with that value being true.