Update ControlItem#setGui to only accepts guis of the generic type

This commit is contained in:
NichtStudioCode 2023-04-06 18:44:25 +02:00
parent 24d9a3bbef
commit 1e0b42357a
2 changed files with 6 additions and 4 deletions

@ -451,6 +451,7 @@ public abstract class AbstractGui implements Gui, GuiParent {
}
}
@SuppressWarnings("unchecked")
@Override
public void setSlotElement(int index, SlotElement slotElement) {
SlotElement oldElement = slotElements[index];
@ -462,7 +463,7 @@ public abstract class AbstractGui implements Gui, GuiParent {
if (slotElement instanceof SlotElement.ItemSlotElement) {
Item item = ((SlotElement.ItemSlotElement) slotElement).getItem();
if (item instanceof ControlItem<?>)
((ControlItem<?>) item).setGui(this);
((ControlItem<Gui>) item).setGui(this);
}
// notify parents that a SlotElement has been changed

@ -25,9 +25,10 @@ public abstract class ControlItem<G extends Gui> extends AbstractItem {
return gui;
}
@SuppressWarnings("unchecked")
public void setGui(Object gui) {
if (this.gui == null) this.gui = (G) gui;
public void setGui(G gui) {
if (this.gui == null) {
this.gui = gui;
}
}
}