Minecraft renders Blocks in different ways depending on the type of the block (see diagram below).
- Standard blocks (full cubes) can all be drawn the same way -i.e. using a square texture for each of the six sides. More Info
- Unusual blocks in vanilla minecraft (eg doors, pistons, bed, etc) are rendered using the corresponding .renderBlock#### method in RenderBlocks, for example renderBlockBed().
- Forge has added a hook for rendering custom blocks. If you create a new type of Block which needs special rendering, you need to define a custom renderer class for it:
- Create a class MyRenderer which implements ISimpleBlockRenderingHandler.
- Assign it a myRenderID using RenderingRegistry.getNextAvailableRenderID()
- Register myRenderer with RenderingRegistry.registerBlockHandler().
- Ensure your myBlock.getRenderType() returns myRenderID.
- Put your custom rendering code in MyRenderer.renderWorldBlock().
One of the trickier parts of rendering custom blocks can be figuring out the folder where you need to place your custom icons. For block textures this is in your resources root folder under
assets/textures/blocks/{Icon name}.png
In my case, during development this was (eg)
C:\Documents and Settings\TheGreyGhost\My Documents\IDEAprojects\MyTestFolder\src\main\resources\assets\testitemrendering\textures\blocks\myIcon.pngA note about rendering animated Blocks:
When rendering Blocks, minecraft uses a 'cached renderlist' that is only refreshed when the block changes. So if you try to animate your Block using the Block rendering methods above, you won't see anything until the Block is changed or updated.If you want your Block to be animated, you need to either use an animated texture for your Block, or use a TileEntity with TileEntitySpecialRender.
This comment has been removed by the author.
ReplyDeleteThese tutorials are fantastic and exactly what I've been searching for! I do have a question, though, if you're willing to answer. This seems to be how it should work. I I've gotten it fine until I went to bind a texture. Calling the render engine in my render file binds the texture to my block just fine but seems to remove all other textures in the chunk. Have you ever seen this happen behore? Am I going about this the right way?
ReplyDeleteHi. There are a few things you might be doing wrong that could cause this, for example if you change the rendering engine to a new texture sheet and don't change it back to vanilla, or you introduce a translation and don't undo it again. Could you post your question and your code on
ReplyDeletehttp://www.minecraftforge.net/forum/index.php/board,73.0.html
You'll almost certainly get an answer pretty quickly since it is swarming with helpful folks...
I figured it out. :) When rendering with ISimpleBlockRenderingHandler, playing with the rendering engine at all seems like a bad idea. But simply registering my textures with IconRegister did the trick! Very different from using TileEntitySpecialRenderer for doing rendering.
ReplyDelete