@@ -59,7 +59,10 @@ private TriggerButtonManager() {
5959 private static @ Nullable AbstractContainerScreen <?> screen ;
6060
6161 private static final LinkedHashSet <TriggerButton > containerButtons = new LinkedHashSet <>();
62+ private static final LinkedHashSet <TriggerButton > visibleContainerButtons =
63+ new LinkedHashSet <>();
6264 private static final LinkedHashSet <TriggerButton > playerButtons = new LinkedHashSet <>();
65+ private static final LinkedHashSet <TriggerButton > visiblePlayerButtons = new LinkedHashSet <>();
6366
6467 public static @ Nullable AbstractContainerScreen <?> getScreen () {
6568 return screen ;
@@ -264,8 +267,10 @@ private static void generateSimpleButton(
264267 name
265268 );
266269 (isPlayerInv ? playerButtons : containerButtons ).add (button );
267- if (add )
270+ if (add ) {
271+ (isPlayerInv ? visiblePlayerButtons : visibleContainerButtons ).add (button );
268272 ((ScreenAccessor ) screen ).clientsort$addRenderableWidget (button );
273+ }
269274 }
270275
271276 private static void generateDirectionalButton (
@@ -344,8 +349,10 @@ private static void generateDirectionalButton(
344349 name
345350 );
346351 (isPlayerInv ? playerButtons : containerButtons ).add (button );
347- if (add )
352+ if (add ) {
353+ (isPlayerInv ? visiblePlayerButtons : visibleContainerButtons ).add (button );
348354 ((ScreenAccessor ) screen ).clientsort$addRenderableWidget (button );
355+ }
349356 }
350357
351358 /**
@@ -423,7 +430,7 @@ public ScoredContainer(Container container, int score) {
423430 */
424431 @ SuppressWarnings ("ConstantValue" )
425432 public static Vec2i getShiftedOffset (Vec2i offset , boolean isPlayerInv ) {
426- int index = (isPlayerInv ? playerButtons : containerButtons ).size ();
433+ int index = (isPlayerInv ? visiblePlayerButtons : visibleContainerButtons ).size ();
427434
428435 int x = offset .x () + BUTTON_SHIFT_X * (TriggerButton .WIDTH + BUTTON_SPACING ) * index ;
429436 int y = offset .y () + BUTTON_SHIFT_Y * (TriggerButton .HEIGHT + BUTTON_SPACING ) * index ;
0 commit comments