-
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.tryEnable(boolean devEnvironment) 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.tryEnable(FMLEnvironment.production == false);
}
}
}With hot-reload enabled, TesseraUI watches template files for changes and invalidates the cache automatically. This includes companion CSS files and CSS files referenced through <link rel="stylesheet" href="...">. Reopen the screen to see the updates.
Warning: Do not call
TesseraHotReload.tryEnable(true)in production builds. It adds a file-watcher thread and uses disk I/O on every screen open.
You can also invalidate the entire cache programmatically:
TesseraHotReload.invalidateAll();Then call rebuild() in your screen's init() method to re-render.
Resource IDs passed to TesseraHotReload.resolveHtml(), resolveCss(), and linked stylesheet resolution are validated against the assets/ directory. Any path that would escape assets/ (e.g. a resourceId containing ../) throws a SecurityException. This prevents accidental or malicious access to files outside the watched asset tree.
@Override
protected void init() {
// Always rebuild on init so pressing F3+T re-loads the screen too
rebuild();
}
private void rebuild() {
TesseraHotReload.invalidateAll(); // call only in dev builds
root = TesseraTemplateRenderer.build(
TesseraTemplate.load("yourmod:ui/my_screen"),
model, handlers,
px, py, pw, ph
);
}