Skip to content

Basic Window Settings

OxideWaveLength edited this page Mar 16, 2020 · 1 revision

Introduction

In this guide it will be shown how to set a custom name for the window and a custom window icon!

Setting the window's name

To set the window's name you can use Display.setTitle(String). Here is an example:

Display.setTitle("BaseClient - Custom Window Name!");

Setting the window's icon

To set the window icon you would normally have to change the two PNGs located in the "assets/icons" folder called "icon16x16.png" and "icon32x32.png", but that would mean you have to export the icon within the jar, so I found a way that doesn't require that. Base64 encoding! Here is how it works:

Through this website you can upload an image and receive back a text, that is (believe it or not) the base64 encoded version of that image! In Java a Base64 String can be decoded into a byte array and then into an InputStream... Or more easily, into what Minecraft (and lwgjl, the library used by Minecraft) needs to set the window icon! So here's a little example from the BaseClient class

/** Both 16x16 and 32x32 version encoded in Base64 */
String icon16x16 = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6J...";
String icon32x32 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6J...";

/** Calling the #setWindowIcon() method with the two encoded icons */
Minecraft.getMinecraft().setWindowIcon(icon16x16, icon32x32);
Clone this wiki locally