Hello guys!
I just managed to render wavefront models instead of the 2d textures for items in forge 1.14. Here is how I did it:
@SubscribeEvent
public static void onModelBakeEvent(ModelBakeEvent event) {
registerModel(event, "minecraft:wooden_sword", "rolecraft:item/wooden_sword.obj");
}
private static void registerModel(ModelBakeEvent event, String itemName, String modelPathWithFileType) {
try {
// Try to load an OBJ model (placed in src/main/resources/assets/examplemod/models/) REMEMBER *.obj
IUnbakedModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(modelPathWithFileType));
if (model instanceof OBJModel) {
// If loading OBJ model succeeds, bake the model and replace stick's model with the baked model
IBakedModel bakedModel = model.bake(event.getModelLoader(), ModelLoader.defaultTextureGetter(), new BasicState(model.getDefaultState(), false), DefaultVertexFormats.ITEM);
event.getModelRegistry().put(new ModelResourceLocation(itemName, "inventory"), bakedModel);
}
} catch (Exception e) {
e.printStackTrace();
}
}
While this looks great in-game, there are some problems with the GUIs. The item is rendered in a very unfortunate way in the GUI and in item frames, as you can see in the attached image. I want to rotate the sword 90 degrees around the z-axis when the sword is not rendered in an entity's hand. How do you suggest I do this?
Thanks in advance for your help