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

    • Hello , when I try to launch the forge installer it just crash with a message for 0,5 secondes. I'm using java 17 to launch it. Here's the link of the error :https://cdn.corenexis.com/view/?img=d/ma24/qs7u4U.jpg  
    • You will find the crash-report or log in your minecraft directory (crash-report or logs folder)
    • Use a modpack which is using these 2 mods as working base:   https://www.curseforge.com/minecraft/modpacks/life-in-the-village-3
    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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