Jump to content

Forge 1.14: Using different wavefront models when rendering items in the inventory and when handheld.


ehaugw

Recommended Posts

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 :)

rendering.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.