-
Notifications
You must be signed in to change notification settings - Fork 0
Hot Reload
TesseraUI supports hot-reloading HTML and CSS templates from disk during development, eliminating the need to restart Minecraft after every UI change.
The fastest way to reload templates is the /tessera reload command, available in-game:
/tessera reload
This clears the template cache. The next time any TesseraUI screen is opened, its template is re-read from disk.
Workflow:
- Open the screen with
/tessera test-v23(or your own screen) - Edit the HTML or CSS file
- Run
/tessera reloadin chat - Close and re-open the screen — changes appear instantly
For hands-free reloading, call TesseraHotReload.enable() early in your mod's client initialization:
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientSetup {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
if (FMLEnvironment.dist == Dist.CLIENT) {
TesseraHotReload.enable();
}
}
}With hot-reload enabled, TesseraUI watches template files for changes and invalidates the cache automatically. Reopen the screen to see the updates.
Warning: Do not call
TesseraHotReload.enable()in production builds. It adds a file-watcher thread and uses disk I/O on every screen open.
You can also invalidate the cache programmatically:
// Invalidate everything
TesseraHotReload.invalidateAll();
// Invalidate a specific template
TesseraHotReload.invalidate("yourmod:ui/my_screen");Then call rebuild() in your screen's init() method to re-render.
@Override
protected void init() {
// Always rebuild on init so pressing F3+T re-loads the screen too
rebuild();
}
private void rebuild() {
TesseraHotReload.invalidateAll(); // only in dev builds
root = TesseraTemplateRenderer.build(
TesseraTemplate.load("yourmod:ui/my_screen"),
model, handlers,
px, py, pw, ph
);
}