Jump to content

Recommended Posts

Posted

You probably can't, since entity models rely on raw OpenGL instructions. You can probably render a regular baked model for the simple parts and then render the entity model from a

TESR

. The enchanting table does something like this: the base is a baked model, the book is rendered from the

TESR

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Crap, one of my friends made an entity model for me using .json, does this mean I just can't use it? It'd really bum him out if I couldn't put it in the game

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted

Oh, you have a JSON model that you want to render as an entity? I thought you had an entity model that you wanted to render as an item/block.

 

It's certainly possible to render baked models as entities, look at

RenderFallingBlock

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
                    IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(iblockstate, world, (BlockPos)null);
                    blockrendererdispatcher.getBlockModelRenderer().renderModel(world, ibakedmodel, iblockstate, blockpos, worldrenderer, false);

 

RenderFallingBlock requires for the model to already be on a block though. Making a new block for each piece of the model is an organization nightmare D:

 

I'm assuming that I can bypass most of the block requirements, but how do I get an IBakedModel from the .json?

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted

Ah, it looks like it's a bit tricky to render a baked model that isn't a

Block

or

Item

(since Minecraft rarely uses baked models for other things).

 

You should be able to subscribe to

ModelBakeEvent

, load the model into an

IModel

using

ModelLoader#getModel

, bake it using

IModel#bake

(look at how this is used in

ModelLoader#setupModelRegistry

) and then add it to the model registry with

IRegistry#putObject

. The

ModelLoader

and model registry are provided as fields of

ModelBakeEvent

.

 

Look at

RenderItemFrame#doRender

to see how you can render an

IBakedModel

that doesn't belong to a

Block

or

Item

.

 

I'm far from an expert in the model/rendering system, so I can't guarantee that this is correct.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Alright, so I got the models loading and rendering, but the problem is the texture is missing.

 

I can apply any texture I want using renderManager.renderEngine.bindTexture(location); but I want it to use the texture described in the .json .

 

Here's the relevant code:

 

Model Baking Code:

IModel cannonBase = event.modelLoader.getModel(RenderCannon.cannonBase);
Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>(){
       public TextureAtlasSprite apply(ResourceLocation location){
              return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
       }
}
RenderCannon.cannonBaseBaked = cannonBase.bake(cannonBase.getDefaultState(), DefaultVertexFormats.BLOCK, textureGetter);

 

Render Code:

BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBakedModel ibakedmodel = cannonBaseBaked;
renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F);		

 

And the .json model, textures and all of it:

{
    "__comment": "Cannon model - bracket only (for animation)",
    "textures": {
        "particle": "blocks/Rusty shaft",
        "0": "blocks/wood_spruce",
        "1": "blocks/Rusty shaft",
        "2": "blocks/Other metal thing"
    },
    "elements": [
        {
            "name": "Bracket base",
            "from": [ 4.0, 1.0, 4.0 ], 
            "to": [ 12.0, 2.0, 12.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 8.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 8.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 8.0, 8.0 ] }
            }
        },
        {
            "name": "Bracket left bottom",
            "from": [ 4.0, 2.0, 4.0 ], 
            "to": [ 5.0, 5.0, 12.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 3.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 13.0, 8.0, 16.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 3.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 13.0, 8.0, 16.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }
            }
        },
        {
            "name": "Bracket right bottom",
            "from": [ 11.0, 2.0, 4.0 ], 
            "to": [ 12.0, 5.0, 12.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 3.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 13.0, 8.0, 16.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 3.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 13.0, 8.0, 16.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 8.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }
            }
        },
        {
            "name": "Bracket left middle",
            "from": [ 4.0, 5.0, 5.0 ], 
            "to": [ 5.0, 7.0, 11.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 11.0, 6.0, 13.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 11.0, 6.0, 13.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 6.0 ] }
            }
        },
        {
            "name": "Bracket right middle",
            "from": [ 11.0, 5.0, 5.0 ], 
            "to": [ 12.0, 7.0, 11.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 11.0, 6.0, 13.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 2.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 11.0, 6.0, 13.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 6.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 6.0 ] }
            }
        },
        {
            "name": "Bracket left top",
            "from": [ 4.0, 7.0, 6.0 ], 
            "to": [ 5.0, 8.0, 10.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 10.0, 4.0, 11.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 10.0, 4.0, 11.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 4.0 ] }
            }
        },
        {
            "name": "Bracket right top",
            "from": [ 11.0, 7.0, 6.0 ], 
            "to": [ 12.0, 8.0, 10.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "east": { "texture": "#0", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
                "south": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 4.0, 1.0 ] },
                "up": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 4.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 4.0 ] }
            }
        }
    ]
}

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted

Do you have missing texture errors in the log? Your model's texture paths don't have a resource prefix, so it's trying to load them from the

minecraft

domain.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Start by following the docs to get a workspace setup: https://docs.minecraftforge.net/en/latest/gettingstarted/ Then poke around some of the tutorials, https://www.mcjty.eu/docs/1.20/ used to be the goto, but not sure if there are any updates for regular forge or not, but if you've brushed up on Java, it will be enough to get you started. Poke around the Minecraft and Forge sources to see how things are done. Read the FAQ for information on how to post code/logs when you run into issues. Share as much info on issues you have as possible. Use github to host projects, chances of someone helping are higher when they can actually see all your code and/or build it themselves. And finally, keep it on the forums, don't direct message people with questions, most people do not provide personal support like that. Also keep in mind forums posts are not always immediately answered, if you're looking for a quicker response, you can always try the Minecraft Forge discord server.
    • Hello, I have a Forge Minecraft sever (I host it at g-portal.com) which has always worked fine and I had no problems, but today it doesn't wanna work anymore. Today I started the server and the status said online, but after a few seconds it said this: "Start failed". And then out of nowhere it restarted itself and the same thing happened again and again and now it's in an infinite loop where it just keeps failing and then restarts. Here's the download link for the server logs: https://www.mediafire.com/file/sq30dgoonjevib1/2025-07-06-1.log/file Does anyone know how to fix this? If yes I would really appreciate help. Best wishes, Gabs1107
    • I'm experiencing a critical issue on a dedicated Arch Linux server running the latest Forge for Minecraft 1.20.1. When a player exits a Nether portal (not enters, and not via /tp) or teleports into the End via portal, the server completely freezes for 1–10 minutes. During this time, all commands are unresponsive, and the game world essentially locks up. This is with watchdog disabled. Environment: OS: Arch Linux (latest packages) Java: OpenJDK 17 (up to date) Forge Version: Latest 1.20.1 (tested multiple versions from the past ~3 months) Mods: None (issue occurs on a clean install) Server Type: Proxmox VM with: 4 virtual cores 64 GB RAM (63 GB allocated via -Xmx and -Xms flags) Observed Behavior: Observed Behavior: The server freezes for 1–10 minutes when: Exiting a Nether portal (entering does not trigger the issue) Entering or exiting the End using a portal Teleporting using commands (e.g., /tp) works only for the Nether; teleporting to the End via command also causes a freeze The issue occurs anywhere in the world, not tied to specific coordinates or builds During the freeze: The server becomes completely unresponsive to all commands and player actions No crash reports, no errors, and no warnings are logged CPU usage remains under 50%, and RAM usage stays around 6–14 GB After 1–10 minutes, the server recovers automatically and resumes normal operation
  • Topics

×
×
  • Create New...

Important Information

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