Slimefun4 icon indicating copy to clipboard operation
Slimefun4 copied to clipboard

Fix rainbow armor recoloring other leather armor

Open iTwins opened this issue 2 years ago • 3 comments

Description

Due to a desync in SlimefunArmorTask and RainbowArmorTask other leather armor could be recolored.

Proposed changes

Compare against the item the player is currently wearing instead of the cached item.

Related Issues (if applicable)

Resolves https://github.com/Slimefun/Slimefun4/issues/3931

Checklist

  • [x] I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • [ ] I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • [x] I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*).
  • [x] I followed the existing code standards and didn't mess up the formatting.
  • [x] I did my best to add documentation to any public classes or methods I added.
  • [x] I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • [ ] I added sufficient Unit Tests to cover my code.

iTwins avatar Aug 05 '23 23:08 iTwins

Your Pull Request was automatically labelled as: "✨ Fix" Thank you for contributing to this project! ❤️

github-actions[bot] avatar Aug 05 '23 23:08 github-actions[bot]

Slimefun preview build

A Slimefun preview build is available for testing! Commit: 1c35e7ab

https://preview-builds.walshy.dev/download/Slimefun/3936/1c35e7ab

Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!

github-actions[bot] avatar Aug 05 '23 23:08 github-actions[bot]

Even though I changed this last week, I wanted to mention that RadiationTask runs SlimefunItem::getByItem for every item in the player's inventory and runs 3 times as often as RainbowArmorTask on default config. The 4 getByItem calls this would add on top of the 111 of the RadiationTask seem inconsequential to me. However I agree that the previous aproach could be optimized and that it is usually better to go for better performance.

iTwins avatar Aug 16 '23 16:08 iTwins