Jump to content

[1.15.2] Render arbitrary model file


DARKHAWX

Recommended Posts

Hi there,


I know I can load an existing block model like:

 

        BlockRendererDispatcher blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
        IBakedModel bakedModel = blockRenderer.getBlockModelShapes().getModel(state);
        IModelData data = bakedModel.getModelData(world, pos, state, ModelDataManager.getModelData(world, pos));

        blockRenderer.getBlockModelRenderer().renderModel(world, bakedModel, state, pos, matrixStackIn, bufferIn.getBuffer(Atlases.getSolidBlockType()), false, new Random(), 42, combinedOverlayIn, data);

 

What I'm wondering is how I can load a model that doesn't have an associated item, block or entity?

No signature for you!

Link to comment
Share on other sites

1 minute ago, Turtledove said:

What is it you're trying to do? Is it going to be an entity, item, or what? You can load jsons, objs, b3ds, or if you've got it set up in a java class, that works well too. https://mcforge.readthedocs.io/en/latest/models/files/

It's for a TileEntityRenderer. I'd like to animate the position of this extra model.

 

Would I use modelLoader.getModelOrMissing() for this purpose?

 

I suppose something I could do is create "nothing" blocks that use the model and then load that using block state; but I'm not sure if that's a good way to go about it.

No signature for you!

Link to comment
Share on other sites

Hi

This example project might give you some inspiration (see mbe21)

https://github.com/TheGreyGhost/MinecraftByExample

 

If you want a block model, the easiest way is like you said to register a block with a model, let Forge load it and stitch the texture etc, then grab it using the code in your question.  The block associated with your TileEntity is probably the best spot.  If your tileentity block already has another model, you can add a blockstate property purely for the purposes of accessing the correct model.  Or create an entirely new, unused block.

 

However if you really don't like that idea, you can access the ModelRegistryEvent and ModelLoader.addSpecialModel() instead.

 

-TGG

Link to comment
Share on other sites

20 hours ago, TheGreyGhost said:

Hi

This example project might give you some inspiration (see mbe21)

https://github.com/TheGreyGhost/MinecraftByExample

 

If you want a block model, the easiest way is like you said to register a block with a model, let Forge load it and stitch the texture etc, then grab it using the code in your question.  The block associated with your TileEntity is probably the best spot.  If your tileentity block already has another model, you can add a blockstate property purely for the purposes of accessing the correct model.  Or create an entirely new, unused block.

 

However if you really don't like that idea, you can access the ModelRegistryEvent and ModelLoader.addSpecialModel() instead.

 

-TGG

Thanks for that.

 

I ended up just registering a block for it and loading the model like normal.

No signature for you!

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.

Announcements



×
×
  • Create New...

Important Information

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