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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • If you’ve lost crypto to a scam, don’t let shame or fear keep you silent. There are real experts out there who know how to fight back. Dexdert Net Recovery did the impossible for me, and they can do it for others too. Contact Dexdet Net Recovery For Help Visa Information Below:    
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
  • 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.