10paktimbits Posted April 25, 2015 Posted April 25, 2015 What I have: 1) a block and tile entity used for storage, like a chest 2) a block that will act as a 'top' for block #1 What I am trying to do: The container/gui for the storage block has a special slot that is used to store block #2. When the player drops block #2 into this slot I want block #1 to render both blocks at the same coordinates, essentially combining the two models together. Both blocks have their own .json model file and I would like to use these if this is possible. It seems that the solution should be implemented in the renderTileEntityAt() method of the TESR for block #1, but I have yet to see an example anywhere of how to do this. An alternative (and preferred) solution would be to dynamically change one of the textures in the storage block based on the contents of the special gui slot. Is this possible? Any help would be greatly appreciated. Quote
TheGreyGhost Posted April 26, 2015 Posted April 26, 2015 Hi It should be possible, in your TileEntitySpecialRenderer, to retrieve the IBakedModel for both blocks using Minecraft mc = Minecraft.getMinecraft(); BlockRendererDispatcher blockRendererDispatcher = mc.getBlockRendererDispatcher(); BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes(); IBakedModel ibakedmodel = blockModelShapes.getModelForState(iBlockState); and then render the appropriate face(s) of that. The hardest part will be setting up the rendering settings correctly. You could look at RenderItemFrame for inspiration. You could also use ISmartBlockModel to combine the two models together without using TESR at all. For example see here https://github.com/TheGreyGhost/MinecraftByExample (examples MBE04 and MBE05) Alternatively, if you set up a custom model for #1 with its own DynamicTexture and use the Tessellator to draw the top face, you could dynamically modify the texture as you suggested. That's probably harder though. If you are thinking of going that route, this class might be useful: https://github.com/TheGreyGhost/SpeedyTools/blob/master/src/main/java/speedytools/clientside/selections/SelectionBlockTextures.java This class is used to capture the texture of all sides of a given block and store them in a DynamicTexture. Other classes then bind the dynamic texture and use the Tessellator to render a cube in mid-air. RenderFallingBlock.doRender() shows some vanilla code which does something similar. It might also be possible, using the same technique, to use OpenGL to render your new texture directly to the blocks texture sheet TextureMap.locationBlocksTexture. If you're just learning Minecraft and/or OpenGL I think it will be a steep learning curve... -TGG Quote
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.