Jikoo / OpenInv

Open anyone's inventory as a chest, real-time!
GNU General Public License v3.0
119 stars 36 forks source link

Improve player inventory handling #209

Closed Jikoo closed 2 months ago

Jikoo commented 2 months ago

Improve compatibility/reduce risk of breakages by creating an entirely new inventory implementation wrapping internals.

If anyone is interested in testing this out, I believe it is currently very stable. Builds are available from Actions runs. Note that earlier builds of 1.21 that have an abstract class InventoryView are probably unsupported.

TODO:

Subsequent PRs will cover the ender chest and feature configuration/management. Feature configuration will in turn enable advanced resource pack usage for increased inventory legibility.

Closes #200 Closes lishid#172 Closes lishid#92

Jikoo commented 2 months ago

Pretty happy with how things are coming along: image image I'm hoping to do pretty placeholders for functional slots so it's clearer what's what, and then I will likely shift the new slots around a little more. I like the armor in the bottom left and the off hand adjacent to the chest, and the new buffers make it a little clearer where the normal inventory ends, so that much is set at least. I was debating trying to set up custom model data but I think it makes more sense to leave that to translations - it would require a custom resource pack either way.

Per checklist, still buggy though. Logging in while someone has your inventory open results in the inventory desyncing and becoming un-editable. Only the main inventory slots, not the armor, which is odd because they're handled exactly the same way. It's probably one tiny mistake somewhere, but I've been thinking way too much about serious important things like how to make everything pretty. Once the inventories look beautiful we can worry about silly little things like not actually being able to edit them.

Jikoo commented 2 months ago

I'm really excited about placeholders! All of the fake items in the inventory are now fake clientside items that the server knows about and keeps in sync. Even if an inventory sorting plugin is improperly sorting our container (which very carefully reports its slots as what they are, check InventoryView#getSlotType!), it can't add copies of our placeholders to other inventory slots.

I've squashed all of the bugs I could locate, so ideally the only things left to do are cosmetics and backporting. I'm marking the PR ready for review to indicate that I believe the current build is safe to use. If anyone does have feedback please let me know what you think. If you have layout suggestions, now is the time - once I settle on something and it goes live, I am unlikely to reorganize.

Jikoo commented 2 months ago

Tried a lot of various options for placeholders for armor. Iron is too common as real armor. Leather looks a bit weird, but making it #C8C8C8 does make the majority of it #8B8B8B like the inventory background. A friend recommended chain, but the new textures look jarringly bright to me. Maybe I'm just a Minecraft boomer.

After that I got with someone who I used to administrate with and we talked about layout. I had already been tossing around the idea of setting up a resource pack that would use a custom font with placeholders disabled, so we talked through a bunch of ideas and settled on this as a layout: full The crafting result will be added for clarity, but will be read-only, hence the red output.

The non-resource-pack placeholder-based one will be a little messier, but ideally still comprehensible (old layout, but you get the idea): image

Jikoo commented 2 months ago

All righty, new layout is done and about as pretty as I think I can make it without a resource pack. image Opening self only allows access to equipment and drop slots - the only real reason to open yourself is to put non-equippable stuff on your armor slots.

I don't think I want to bother backporting this - testing on older versions is gross and boring, and I'm having fun. Honestly, I might just drop 1.20.4/1.20.6 because otherwise they both stay until 1.22, 1.20.6 was a pretty large and short-lived update.

Jikoo commented 2 months ago

Got the resource pack working with custom model data. It would look cleaner with fonts as well, but I believe that results in missing character textures for clients without the pack installed. It might be possible with a custom font and a translation that defaults to blank, but right now I'm happy with how pretty it currently is. Honestly, anything is way better than "just know what everything is," and since it took me an hour to figure out how to fix the result slot recolor rendering very dark, perhaps I will leave it at that. image

Resource pack capability will come with a future PR I think - it will have to be customizable so that people can edit it to their liking.