public class BoxScreen extends HandledScreen { // A path to the gui texture. In this example we use the texture from the dispenser private static final Identifier TEXTURE = Identifier.ofVanilla("textures/gui/container/dispenser.png"); // For versions before 1.21: // private static final Identifier TEXTURE = new Identifier("minecraft", "textures/gui/container/dispenser.png"); public BoxScreen(BoxScreenHandler handler, PlayerInventory inventory, Text title) { super(handler, inventory, title); } @Override protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, TEXTURE); int x = (width - backgroundWidth) / 2; int y = (height - backgroundHeight) / 2; context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight); } @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { renderBackground(context, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta); drawMouseoverTooltip(context, mouseX, mouseY); } @Override protected void init() { super.init(); // Center the title titleX = (backgroundWidth - textRenderer.getWidth(title)) / 2; } }