Globox1997 / LevelZ

https://modrinth.com/mod/levelz
https://www.curseforge.com/minecraft/mc-mods/levelz
GNU General Public License v3.0
51 stars 50 forks source link

[Bug] Dispensers bypass player skills #141

Closed PaulZappia closed 2 years ago

PaulZappia commented 2 years ago

Was just testing out the mod and I found what seems to be a massive oversight with how armor restrictions are handled. Normally, if you try to wear an elytra or any piece of armor without the required defense/agility levels, the armor does not get equipped. However, if you simply use a dispenser to dispense armor onto the player, this system is completely bypassed, allowing players with no skill points to use high-level equipment.

The Solution

Instead of just preventing the player from equipping armor, prevent any armor being worn at all times if the player does not meet the requirements to wear it. This can be achieved by checking for changes in the player's armor slots, similar to how the game checks for diamond armor for the Cover Me with Diamonds advancement. When any change occurs, check to see if the armor being worn meets the players current stats. If they don't, take the item out of the player's inventory and drop it on the ground.

Doing this will prevent any kind of armor equipping method to bypass the stat check.

Globox1997 commented 2 years ago

hey PaulZappia, do you use the latest version of this mod? That shouldn't be possible except you are using some custom modded dispenser? If not then I will look into it, reference https://github.com/Globox1997/LevelZ/blob/1.18/src/main/java/net/levelz/mixin/item/ArmorItemMixin.java#L31

PaulZappia commented 2 years ago

Yeah, I'm using the latest version of the mod (1.3.2). I'm pretty much using a vanilla dispenser, although I do have a mod that allows dispensers to interact with cauldrons. I'll see if taking it out will fix the problem or not.

PaulZappia commented 2 years ago

Just tested it out, looks like that has been causing the issue. I've been able to replace it with carpet's dispensersUseCauldrons feature and the problem has been fixed. Sorry for the inconvenience.