Fix gilded armor effect 1.19 (possibly other versions) #241
+4
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the player disconnected before the effect was recharged, on reconnect the armor chestplate item's NBT would be stuck in a state where the effect could not activate again because "activating_armor" tag was set to false and then "activating_armor_visuals" could not get deactivated anymore blocking the effect logic. By inverting the conditions order, when the player reconnects both conditions are executed in the first pass first by deactivating the "activating_armor_visuals" THEN "activating_armor" fully recharging the effect and preserving correct armor chestplate NBT state on player reconnect.
How to replicate the initial bug:
activating_armorfalse andactivating_armor_visualstrue and inability to benefit from the armor's effectAfter this fix, the bug scenario is no longer reproducible and the armor remains usable and the effect is fully recharged even when the player comes back after being offline (and inventoryTick not called during that time because the player was offline).
With this change, all armors which are already corrupted will remain corrupted, but new armors will not get corrupted. For me it's an acceptable solution, but you may want to add code that checks if
activating_armoris false then setactivating_armor_visualsto false as well to fix the armor's NBT.