Through some experimentation I found that it is possible to load entity models designed for use with post initialization. This is useful if the player were to join a server which sends the model information in a packet (normally you would need to trigger a full resource reload process).
Copy try {
RawGeoModel rawModel = Converter.fromJsonString(geo.toString());
if (rawModel.getFormatVersion() != FormatVersion.VERSION_1_12_0) {
throw new RuntimeException(identifier.getPath() + " : Wrong geometry json version, expected 1.12.0");
}
RawGeometryTree rawGeometryTree = RawGeometryTree.parseHierarchy(rawModel);
GeckoLibCache.getInstance().getGeoModels().put(identifier, GeoBuilder.constructGeoModel(rawGeometryTree));
} catch (IOException e) {
throw new RuntimeException(identifier.getPath() + " : Problem reading geo model.");
}
Copy AnimationFile animationFile = new AnimationFile();
for (Map.Entry<String, JsonElement> entry : JsonAnimationUtils.getAnimations(animation)) {
String animationName = entry.getKey();
Animation anim;
try {
anim = JsonAnimationUtils.deserializeJsonToAnimation(JsonAnimationUtils.getAnimation(animation, animationName), new MolangParser());
animationFile.putAnimation(animationName, anim);
} catch (ShaderParseException e) {
throw new RuntimeException("Could not load animation from quadcopter template: " + animationName);
}
}
GeckoLibCache.getInstance().getAnimations().put(identifier, animationFile);
Copy MinecraftClient.getInstance().getTextureManager()
.registerTexture(identifier, new ResourceTexture(identifier));