SuperMartijn642 / SuperMartijn642sCoreLib

14 stars 2 forks source link

Fix inventory gui bugs in WidgetContainerScreen. #18

Closed AHilyard closed 1 year ago

AHilyard commented 1 year ago

I received a bug report regarding my mod, Legendary Tooltips (https://github.com/AHilyard/LegendaryTooltips/issues/54) where a component of item tooltips was misaligned, but only when viewed inside of a PackedUp backpack. In viewing the code where the core lib renders this GUI, I found that by modifying the pose stack given to that method instead of the RenderSystem's modelView stack, certain renderers will behave differently than vanilla Minecraft behavior.

This pull request changes the rendering functionality to more closely match that of the vanilla GUI rendering behavior to help alleviate these sorts of bugs. I also added a call up to the superclass's render method--for some reason REI would not work for me without this, though I have seen that it does work with other users. In any case, calling up to super fixes that bug as well.

SuperMartijn642 commented 1 year ago

Seems vanilla creates a local PoseStack variable which they set to RenderSystem#getModelViewStack, which is likely why I didn't realize they weren't translating the PoseStack passed into the render method 🤦‍♂️ Just translating the model view matrix solves so many problems where I had to awkwardly pass the gui offset when rendering models inside of guis.

I didn't run into any issues with REI, it seems to render fine even when not explicitly calling super.render().

I won't accept this PR, because I would prefer not to call super.render() and also so I can keep things a bit more similar between branches.

This is technically a breaking change, but since it simplifies things a lot when rendering models, I don't mind updating my other mods to accommodate for the changes. I added the changes in 7e0e6f5ea1e2e77250f8d592cd96e1443002d481. This should resolve the issue with Legendary Tooltips. Thanks a lot! This really removes a bunch of workarounds in my other mods 🙂