I was wondering how to remove an item from a slot in my GUI.
I currently have 2 slots, and I want to, when the user clicks a button in the GUI, to remove it from the slot and then place a different item into the second slot.
I have the button setup like this currently in the Screen class:
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
this.font.drawString(this.title.getFormattedText(), 51.0f, 6.0f, 4210752);
this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0f, 112.0f, 4210752);
this.addButton(new ImageButton(this.guiLeft + 77, this.guiTop + 24, 21, 20, 0, 208, 21, BACKGROUND_TEXTURE, (e) -> {
System.out.println("Hello");
}));
}
And the PlayerInventory, along with the two slots are initialised inside of the Container class constructor here:
this.addSlot(new Slot(tileEntity, 0, 16, 26));
this.addSlot(new Slot(tileEntity, 1, 52, 26));