private static void setSelectedID(GuiListExtended list, int id) { Field field; try{ if(list instanceof GuiListWorldSelection) { field = GuiListWorldSelection.class.getDeclaredField("selectedIdx"); } else { field = GuiSlot.class.getDeclaredField("selectedElement"); } field.setAccessible(true); field.set(list, id); if(list instanceof GuiListWorldSelection) { ((GuiListWorldSelection) list).selectWorld(id); } } catch (Exception e) { throw new RuntimeException("Error accessing index field!", e); } }
private static boolean isSelected(GuiListExtended list, int id) { try { Method method = GuiSlot.class.getDeclaredMethod("isSelected", int.class); method.setAccessible(true); return (boolean) method.invoke(list, id); } catch (Exception e) { throw new RuntimeException("Error accessing getSize()-Method!", e); } }
private static int getListSize(GuiListExtended list) { try { Method method = GuiSlot.class.getDeclaredMethod("getSize"); method.setAccessible(true); return (int) method.invoke(list); } catch (Exception e) { throw new RuntimeException("Error accessing getSize()-Method!", e); } }
public SlotClicked(List<GuiButton> buttonList, GuiSlot slotClicked) { super(buttonList); this.slotClicked = slotClicked; }