Jump to content

Recommended Posts

Posted

I am trying to add a custom model to my block, but it crashes when placed in the world.

 

BlockEggStand:

 

  Reveal hidden contents

 

 

ClientProxy:

 

  Reveal hidden contents

 

 

BlockEggStandRenderer:

 

  Reveal hidden contents

 

 

crash report:

 

  Reveal hidden contents

 

 

 

 

 

Posted
  On 2/12/2014 at 3:40 AM, opssemnik said:

update for lastest forge

 

I updated to latest forge, updated obfuscations, and the crash is still happening.

I updated the code in the post and the crash report is also updated.

Posted
  On 2/12/2014 at 5:02 AM, opssemnik said:

i know can be a bit crazy but can you put a model = AdvancedModelLoader.loadModel(new ResourceLocation("strongholdcraft:models/eggStand.obj"));

on the 1st line of renderWorldBlock

?

Same crash happens

  • 3 weeks later...
Posted

Before ISimpleBlockRenderingHandler is called the tessellator is started, the model render commands attempt to start the tessellator.

This causes the crash.

 

By adding a tile entity to your block you can use TileEntitySpecialRenderer to solve the problem.

 

Or since your renderer is simple you can stop the tessellator before your code, and start it again after your code.

 

Tessellator.instance.draw();
GL11.glPushMatrix()
<your render code>
GL11.glPopMatrix()
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); // This is required or the textures will be messed up.
Tessellator.instance.startDrawingQuads();

 

This has drawbacks, GL11.glRotatef and GL11.glScalef do not work as expected, both of move the model instead.

 

There might be a better way to render models without tile entities but this is the only one I know of.

 

Bantasaurusrex is correct GL11.glPushMatrix() and GL11.glPopMatrix() are required, otherwise any models drawn after yours messes up.

Posted

Minecraft uses a special class to render, the Tessellator. When the tessellator is used, it has to be started with tessellator.startDrawing(drawmode), where the drawmode is a specific way of drawing specified in OpenGL. When you send a coodinate (a vertex) to the tessellator, it is pushed into an array. This array will continue expanding until you do tessellator.draw(). At that point, the array of vertices is sent to your graphics processor so that it may render it. If tessellator.startDrawing(drawmode) is called while it is already collecting vertices, the "Already tessellating" exception is thrown.

 

You get this problem because Forge's .obj renderer is designed to send its own vertices then draw them instantly. Therefore, it's calling tessellator.startDrawing(drawmode) and tessellator.draw() by itself, which must not be done during the block rendering phase. If you somehow were able to stop the model renderer from calling the suspected methods, there is still a potential problem. Blocks are rendered with the GL_QUADS drawmode, which means a square face will be drawn for every 4 vertices you send in. The model may not be rendered with this drawmode, which would completely mess up the rendering. The model renderer could even have several calls to both startDrawing and draw.

 

Encasing your model.renderAll with Tessellator.instance.draw() above and Tessellator.instance.startDrawingQuads() below in BlockEggStandRenderer.renderWorldBlock is not a viable solution. Because of technical reasons, this can mess up the rendering of the blocks surrounding this one.

 

It's fine to render your .obj model in renderInventoryBlock, but you need another solution for renderWorldBlock. You could try to render your block programmatically instead of using a model, or alternatively give the block a tile entity. Tile entity blocks can be rendered independently from other blocks, and their rendering does not suffer from the limitations of standard block rendering. Either solution should be covered by tutorials.

Posted

I use the implementation that @Glenn advises against, but have not noticed rendering errors. There may be something else at work there.

 

It should be noted that the frivolous use of tile entities is discouraged, so I would try to make it work by instructing the Tessellator instance to "draw" and "startDrawingQuads" at the beginning and end of your method respectively. After doing this, most rendering errors can be dealt with on a case by case basis. Having said that, rendering your block programmatically would be better, like Glenn Suggested, if inconvenient to your artistry.

 

Technical Reason [tek-ni-kuhl ree-zuh n] (noun): You probably can't be bothered. (Shame on you) :P

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



×
×
  • Create New...

Important Information

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