Offline Mode
Hudkit can run without a connection to Studio by using offline mode, this provides you total control over how Hudkit works inside your project. Offline mode works with a mock Studio server that allows you to set the XML of your HUD with a single function call.
Setting Up Offline Mode
Section titled “Setting Up Offline Mode”Create a HudManager with offline options:
val hudManager = HudManager( studioOptions = StudioOptions.offline(),)HudManager hudManager = new HudManager( StudioOptions.offline(), RenderOptions.defaults());In offline mode, you provide the HUD definition XML directly using setOfflineXML():
// Load XML from a fileval xml = File("hud.xml").readText()
// Set the XML definitionhudManager.setOfflineXML(xml)
// Load and process the definitionval definition = hudManager.loadDefinition().process()hudManager.definition = definition// Load XML from a fileString xml = Files.readString(Path.of("hud.xml"));
// Set the XML definitionhudManager.setOfflineXML(xml);
// Load and process the definitionProcessedHudDefinition definition = hudManager.loadDefinition().process();hudManager.setDefinition(definition;In offline mode, you cannot use uploadResourcepack(). You must host the resoucepack yourself. You can get access to the resourcepack from the processed defenition.
val definition = hudManager.loadDefinition()val resourcepack = definition.process().resourcepack
File("resourcepack.zip").writeBytes(resourcepack)
// ... host the resoucepack
hudManager.resourcepackUrl = "https://example.com/resourcepack.zip"
// Now you can send it to playershudManager.sendResourcepack(player)HudDefinition definition = hudManager.loadDefinition();byte[] resourcepack = definition.process().getResourcepack();
Files.write(Path.of("resourcepack.zip"), resourcepack);
// ... host the resource pack
hudManager.setResourcepackUrl("https://your-server.com/resourcepack.zip");
// Now you can send it to playershudManager.sendResourcepack(player);