Jump to content

Prevent Loot Table and Exp Drop on Entity Death


JayZX535

Recommended Posts

Hello,

I'm trying to figure out how to approach a feature I'd like to include in a mod (I don't have code to show for it yet because it doesn't exist yet, I'm still determining how to go about it in the first place).  In essence, I want to cancel the loot and exp drops specifically, not the entire drop event as a whole.  This is conditional per entity in a way I'm pretty sure the loot tables themselves can't detect, so I can't just replace the loot table for all entities.  Redirecting it to a blank one would be an acceptable solution if I can do so from within the mod.  I also can't just cancel drops as a whole because I want entities with gear to still be able to drop it, nor can I override based on a list of specific predefined entities because I'd like to make this as flexible as possible.  So the basic outcome I'm looking for is...

Death/Drops Event is intercepted and if the entity matches the criteria--
-It will NOT drop exp
-It will NOT drop its normal loot table drops
-It WILL drop any gear that has been equipped to it

Does this seem like something that would be possible to do, and if so, could someone point me toward some resources/examples on how I might be able to pull it off?  I'm mostly not sure what events I would even need to look at, or how to catch and alter what loot table it's pulling from.

Thank you for your time.

Link to comment
Share on other sites

LivingExperienceDropsEvent

LivingDropsEvent

The latter does NOT differentiate the source of the drops, it just gives you a collection of ItemEntitys.

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Thank you!  And ooooh hm, alright, well that's a start... at the very least sounds like that's my EXP issue solved.

Is there a way to get the possible list of drops from a loot table in code?  And how would I go about getting the loot table from an entity?  At the very least, it seems like that could give me a slightly dirty solution of killing anything that matches up with the loot table.  It's not perfect because if the entity is carrying an item it can also drop, it would still get destroyed.  But that would cover most cases...

Link to comment
Share on other sites

See LivingEntity.dropFromLootTable()

But I don't see how that helps you? Loot tables contain random drops/custom LootItemConditions.

No 2 calls of that code will give the same items in the general case.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Well, right, the exact drops each time are random, but if I can get the list of what items are possible then I can compare that to the ItemStacks given in the drop event to see what to rule out as a probable natural drop.

But thank you!  I'll take a look at it and see what I can do.

Link to comment
Share on other sites

Ok, you certainly get a list of possible drops if you ignore that a custom LootItemCondition can do things you can't simulate, e.g. only drop an item the first time a player kills an entity.

But a modded entity is allowed to override that method, so it isn't necessarily the logic that is being used for all entities.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.