thebest108 Posted March 3, 2016 Posted March 3, 2016 How do I do it? Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
Choonster Posted March 3, 2016 Posted March 3, 2016 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 . Quote 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.
thebest108 Posted March 4, 2016 Author Posted March 4, 2016 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 Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
Choonster Posted March 5, 2016 Posted March 5, 2016 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 . Quote 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.
thebest108 Posted March 5, 2016 Author Posted March 5, 2016 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? Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
Choonster Posted March 5, 2016 Posted March 5, 2016 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. Quote 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.
thebest108 Posted March 7, 2016 Author Posted March 7, 2016 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 ] } } } ] } Quote "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
Choonster Posted March 7, 2016 Posted March 7, 2016 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. Quote 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.
Recommended Posts
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.