Hello dear modders,
I started to do stuff with tilentities and guis. My problem is, that i can't access the data on my tileentities from the gui, because it is not the same tile entity as the block i clicked on to open the gui.
I have coordinates stored in an nbt integer array in a controller block and i want to display how many coordiantes i have stored on the gui. I created a `int ID` which is set in the constructor to check if it gets instantiated more than I would want, and I was right about that.
Any idea why that is happening?
In my screen class:
@Override
protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int mouseX, int mouseY) {
GateControllerContainer container = getContainer();
GateControllerTileEntity tileEntity = container.tileEntity;
int placerCount = tileEntity.getPlacerCount();
font.drawString(matrixStack, title.getString(), 8.0f, 6.0f, 4210752);
font.drawString(matrixStack, "Bound to " + placerCount + " placers", 8.0f, 50.0f, 4210752);
font.drawString(matrixStack, playerInventory.getDisplayName().getString(), 8.0f, 70.0f, 4210752);
}
I set the tileEntitiy variable in my container class in its constructor
And in my TileEntities class:
@Override
protected Container createMenu(int id, PlayerInventory player) {
return new GateControllerContainer(id, player, this);
}
Thanks in advance for your tips