samolego / GolfIV

An anti-exploit attempt for Fabric
https://modrinth.com/mod/golfiv
MIT License
49 stars 13 forks source link

Creative inventories may get inadvertently sanitized by PatchItemKickExploit #41

Closed Ampflower closed 2 years ago

Ampflower commented 3 years ago

Description

Currently, with patchItemKickExploit set to true, creative inventories may have item NBT silently sanitized as the client resyncs the inventory with the server, even if nothing should be replaced or legalised to begin with. It's not a major problem when it's more patched out, but can still show through in certain scenarios, i.e. block or entity data stored in a block or spawn egg.

Do note, all other checks can be completely disabled and this will still occur.

Possible ways to reproduce the issue

All of the following will generally result in either reverts, or otherwise unobtainable glitched items. After each of the following, all that is needed to trigger this is to either relog or open another inventory.

Cause

As discussed at https://github.com/samolego/GolfIV/issues/39#issuecomment-858232842, this is caused primarily by the code below. https://github.com/samolego/GolfIV/blob/705f6a1a1cfbb9e3c92cd149eb0b1c4e2d826383/src/main/java/org/samo_lego/golfiv/event/S2CPacket/ItemInventoryKickPatch.java#L34-L45

Possible fixes