Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable head drops on mobs spawned from spawners config option #77

Open
TerdyTheTerd opened this issue Feb 15, 2021 · 9 comments
Open
Labels
enhancement New feature or request fix-submitted A potential fix was added for this issue, and is pending testing or verification.
Milestone

Comments

@TerdyTheTerd
Copy link

Describe the solution you'd like
Add a config option to not drop mob heads from mobs that were spawned from a mob spawner. This is to prevent mob heads from losing rarity easily with mob spawner farms, especially when using SilkSpawners or other such plugins.

Additional context
CreatureSpawnEvent store PersistentData via PersistentDataContainer class from Spigot-API if spawn reason is SPAWNER.
EntityDeathEvent check for PersistentData key that was set, return if set

I was implementing this myself, but I honestly cannot for the LIFE of me, get maven to behave and get spigot api added correctly. Build always fails because it cannot find the methods used in the above mentioned class.

@crashdemons
Copy link
Owner

crashdemons commented Feb 15, 2021

Regarding maven difficulties, you may want to check if one of the dependencies is transitively including an older version of bukkit or spigot-api which is interfering wiith your own dependency.

It should be noted that before a certain version, PDH/PDC methods did not exist and we had (for a while) PersistentMetadata methods, but I'm not sure if PMD existed back into 1.8 (I misremembered). If it doesn't, then you would get into adding hacky NBT tags in 1.8 and I try to avoid NBT manipulation, personally.

This plugin maintains support for 1.8-1.16.5 so, any version-specific code should be present soley in a/the compatibility support module that is relevant to it and a version-agnostic interface should be added to CompatibilityProvider to expose those version-specific implementations of the same feature.
A few of the other modules (like Core) compile under one version and test under another.


That aside, I will consider this feature, but the possibility of it only working on some versions and not on others doesn't thrill me.

@crashdemons
Copy link
Owner

crashdemons commented Feb 15, 2021

Added In Deprecated In Name Persistent? Works with
1.14 N/A PersistentDataContainer Yes Entities, Items
1.13.2 1.14 CustomItemTagContainer Yes Items*
1.10.2 N/A Scoreboard Tags Yes Entities
1.7.10? N/A Metadatable No Entities, Items
1.2.1** N/A Custom NBT Yes Entities, Items

looks like this is what we have to work with for setting tags on mobs in each version unless we keep an offline record of entity UUIDs

(*items, but you could abuse mob inventory to tag a mob - not recommended since you may want other items in those slots)
(**not officially supported by bukkit/spigot, needs reflection - incompatible with Glowstone).

@TerdyTheTerd
Copy link
Author

Ahh I didn't realize the plugin was aiming for such a large range of version support.

@TerdyTheTerd
Copy link
Author

I'm unsure if you are willing to help, but the code itself took less than 10 minutes, yet I've been fighting the project for well over 4 hours trying to get it to just compile a jar for my server. No matter what I do, when ever I run maven to generate the jar file it ALWAYS reverts back and reimports bukkit over spigot for the Core module, throwing a compilation error due to bukkit not have the persistent data container.

Are there specific build configurations in this project to generate just a modern spigot 1.16.5 build. Is there something I am missing that keeps bringing bukkit back in over spigot in the pom? I am new to maven, and so far its been a nightmare, why on earth do none of the tools let me simple click on a dependency and remove from build...

@crashdemons
Copy link
Owner

crashdemons commented Feb 15, 2021

For the Core, if you open the pom.xml (PlayerHeads-core/pom.xml), you can edit the versions used
image
You can update the depdendency for Core by either:

  • replacing the second dendency with a org.spigotmc / spigot-api dependency but still for compile OR
  • remove the second dependency and remove the "scope" qualifier from the first dependency - this means 1.16.5 will be used for both compile/test

This project is not your typical single-POM project, but the main POM provides defaults for all of the module projects.
Each module project has its own POM and dependencies it sets. This is how I'm able to compile code for different versions into one plugin.

@TerdyTheTerd
Copy link
Author

TerdyTheTerd commented Feb 16, 2021

Some combination of importing and resetting seems to have done the trick. Thanks a bunch! My server has been waiting on this update for several days so I can enable SilkSpawners and let players use their rare mob head drops to change spawners they collect to the respective mob type, but I needed mobs spawned from spawners to not drop additional heads to prevent the mob heads from losing their value.

@crashdemons
Copy link
Owner

crashdemons commented Feb 16, 2021

I'm not sure what you mean, if you mvn clean compile package install (clean install might be enough) the parent project, it should build and produce a properly shaded JAR.

can you post your build log and the resulting JAR?

@crashdemons
Copy link
Owner

crashdemons commented Feb 16, 2021

You might try this dev build to see if it has the same affect https://ci.meme.tips/job/PlayerHeads-5.x/1136/ [once it is finished]
I haven't tested it though so there could be bugs preventing it from working properly on the first pass.

There are two new configuration options:

  • trackspawnermobs (default: false) which tags entities with their spawnreason
  • spawnermobbehavior (default: ignore) which determines how PH interacts with the death/head drop

These will need to be applied from the config file and a /ph config reload will need to occur if you use Build 1134.
Build 1135 should support the new config option in /ph config set properly.

so for your case you would probably want to set trackspawnermobs to true, then spawnermobbehavior either to vanilla or block.
block will prevent all head drops for entities from spawners including vanilla head drops (wither skeletons, charged creepers)
vanilla will only prevent head drops added by PH for spawner mobs.

Compatibility note: in 1.14 and higher, spawnreason tagging should be persistent across restarts. Lower than that, at this time metadata is used which is not persistent.

@crashdemons crashdemons added this to the 5.2.15 milestone Feb 18, 2021
@TerdyTheTerd
Copy link
Author

Oh wow that was fast. I have actually been using the changes that I implemented and they work well, but I will probably look to update to an official build later anyways.

@crashdemons crashdemons added the fix-submitted A potential fix was added for this issue, and is pending testing or verification. label May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix-submitted A potential fix was added for this issue, and is pending testing or verification.
Projects
None yet
Development

No branches or pull requests

2 participants