-
-
Notifications
You must be signed in to change notification settings - Fork 992
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
Only use convert spawners tagged by the give command #3963
Conversation
6834515
to
bd673ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this code and (quite shockingly) this breaks the spawner convert feature. There's definitely a better way to go about fixing this.
I can explain this feature briefly since you're unfamiliar with it. In essence, it converts spawners being placed to their intended types when using Essentials commands to create them. It's probably easiest if I just give some example commands to reproduce the expected behavior.
If you run /i zombiespawner
you get a "zombie Spawner" (not sure why the z is lower case, that's probably a separate bug as in older versions it was upper). Upon placement, the spawner is "converted" to a zombie spawner. With this code nuked, that no longer works properly and you get left with a pig spawner.
This worked properly in older versions of Minecraft, but from brief testing this clearly doesn't work well with vanilla spawners. If you use the vanilla equivalent command, /minecraft:give @p minecraft:spawner{BlockEntityTag:{SpawnData:{id:"minecraft:zombie"},SpawnPotentials:[{Entity:{id:"minecraft:zombie"},Weight:1}]}} 64
, and place the spawner, you get a pig spawner because Essentials overreaches and tries to convert this instead of leaving it alone. PS: for the above command you will also need to be OP and in creative mode due to MC-105216.
Clearly this feature still needs an overhaul because it's not OK for it to do that. Ideally spawners made in Essentials should be the only ones touched by spawner conversion, and vanilla ones are left alone. This could probably be done by attaching a custom tag to the item stack on creation and checking for that before setting the spawned type (and of course, ignoring any that do not have the tag).
@pop4959 am now using an enchantment as a way to differentiate between EssX spawners and normal ones. This is the best solution due to PersistentDataContainer being a 1.14 thing |
To be honest that's a solution I'd not have thought of, but I still have some worries about using enchantments here, given that they're not really intended for storing data. On top of that, it seems likely to me that there can easily be some unnecessary plugin conflicts created by this, since quite a few plugins touch enchantments. The best solution in my opinion would be to leave the existing legacy handler as-is, and use PDC on the versions that support it. Of course that means that older versions would not receive the improvement, but these versions are not a priority and should not force us to use workarounds that create further maintenance burden. |
The only possible plugin conflicts would be extremely rare and only in 1.8-1.12 as starting with 1.13 it uses a plugin namespaced key.
I apply the same logic to the reason in favor of this fix |
Just was concerned because I'm not familiar with any other plugins handling metadata that way. If we're absolutely sure this won't cause problems or have any other side effects, then it might be OK. I'll try to take a closer look later this week. |
Yeah no problem. Basically the only way this can conflict is with the id based enchantment registration which only occurs on 1.8 thru 1.12. I picked an offset which is good enough and no other plugins should occupy considering that barely any plugins register enchantments in the first place, I'd say we're fine. As for side effects there are none I can find. |
Marking as draft as this pends providers from #4143 |
This PR itself does nothing on its own but creates the underlying backbone I need to make a less hacky solution in #3963 lmfao. This PR creates a provider which uses NBT on 1.8.8-1.13 to mimic the exact structure of a PersistentDataContainer on 1.14+ which will allow us make any possible upgrades (which don't die from the lack of DFU on >1.13) work as expected. Additionally, this does not use reflection on modern Minecraft versions and thus will not need to be maintained/updated on MC version updates. In the future, we will need to find a way to store data on tile entities (signs namely) so that we are able to store UUIDs on signs for future plans, but for now ItemStacks work to fix our spawner issues.
#4143 has now been merged - will review when marked ready |
1787820
to
04e3639
Compare
Marks all spawners made by EssentialsX with a special PDC tag that denotes if we should run "spawnerconvert" operations on it.
Tested on 1.8.8 & 1.16.5
Fixes #3811