Lightman's Currency

Lightman's Currency

331k Downloads

[Feature Request] Add entity loot config just for naturally spawned entities

HonzaVinCZ opened this issue · 7 comments

commented

I'd like to ask you to add config entry to allow coin loot only for naturally spawned entities, not spawned by spawner or other creative way. That way no unfair coin farms can be created.

I'm working on MP technic modpack and I couldn't find any config to disable loot for spawner spawned entities. I could change loot tables by other mod but I find this easier for everyone who will use your mod in future.

If there is a way how to configure that inside your config file, let me know please. Thank you!

lightmanscurrency-1.18-1.0.1.7

commented

I have attempted to do this once before, but as vanilla doesn't track whether the entity was spawned naturally vs. via a spawner I had given up on this. That said, now that I have more experience I may be able to add a data flag via a capability and flag spawner spawned entities such that they don't drop coins. That said this will only be able to block entities spawned by a spawner, not those spawned by other unnatural means, and won't prevent people from making a mob farm from naturally generated farms (although, they will still require player kills).

That said, most other entities that can be spawned unnaturally in some method other than a spawner, either require some form of admin powers (spawn eggs, etc.) or are so unique in that they can only be spawned unnaturally and thus can just be removed from the coin pool entirely.

As a side note, doing this will likely require changing how the config works, as I won't be able to embed the loot directly into their loot tables anymore as I'll need to check the spawner flag upon death, and thus the config will only be able to accept entity ids instead of either their entity id or their loot table entry. Shouldn't cause too many issues as long as the server owners update their config to just remove the "entities/" portion from the entity drops portion of the config (or if they're using the default values, just deleting the relevant options entirely to be auto-filled back in).

commented

I think it would be more than enough to have option to block spawner created entities from dropping coins. It just depends on each user, I personally prefer to not have coin farms possible and rather force players go and hunt zombies in the world so the coins still keep some value.

Also I personally don't see more into depth of minecraft code limits. I tried it few times to get into modding but even though I have some basic experience with C++, java was just overcomplicated to me and I gave up. That said, don't get me wrong I want too much.

commented

I might actually be able to upgrade it so that you can put a list of blacklisted "SpawnReason" values (there are 16 different vanilla SpawnReason types) to allow the disabling of multiple spawn types. This should allow for more user customization should someone want to disable coin drops from entities summoned by other entities, or spawn egg entities, etc. although I'll probably leave the spawner generated entities disabled by default, and of course have a list of valid values in the config comment.

commented

Unfortunately it doesn't look like it's possible to track all spawn reasons, as spawn events that include the spawn reason aren't run from most entity spawn sources (The only one consistently run is the EntityJoinWorld event that only includes the entity & world, not the entities spawn reason). It would appear that the SpawnReason flag is mainly used internally as a notifier to the entity itself when initializing the entities data (i.e. telling the chicken it was spawned as a jockey host to change it's AI, and prevent despawning). I can still track spawner spawns by the looks of it, but sadly the rest are out of the question. :(

commented

No worries, the spawner should be enough, at least for me! I already saw sponge/bukkit plugins that were giving money to players for killing mobs but not those created from spawners ( and I'm not sure if even from spawn eggs ). But it must work the way as you describe.

If you find time to implement that, I will be only happy for that and surely some other people find it useful as well!

commented

Copy that, I've still got some testing to do to make sure it works, etc. but it should be included in the next update.

commented

Implemented in v1.0.2.0.