Jump to content

Recommended Posts

Posted

Hi everyone, I've recently started getting into Minecraft modding. I've followed a couple of tutorials on the wiki and Youtube, and I think I have a basic understanding of how Forge works (hooks and whatnot).

What I'm trying to do now is to render a custom block (really simple, just a table made of five boxes), and I've read on the wiki that the correct way to do this is by implementing ISimpleBlockRenderingHandler in a custom renderer. The problem is, I haven't found any documentation on how to do it, and even trying by myself didn't give positive results.

This is briefly what I have right now:

 

mod_Minesona.java

 

  Reveal hidden contents

 

 

MinesonaClientProxy.java

 

  Reveal hidden contents

 

 

BlockVelvetTable.java

 

  Reveal hidden contents

 

 

RendererVelvetTable.java

 

  Reveal hidden contents

 

 

ModelVelvetTable.java

 

  Reveal hidden contents

 

 

(There's more, obviously, like gui handler, tile entity and so on, but I don't think they are quite useful in this case.)

 

The model class has been automatically generated by Techne, I've only removed some parts to make it simpler, but it didn't work even before doing that.

 

Using this code, I get this error when trying to place the block:

 

2012-11-14 13:06:53 [iNFO] [sTDERR] java.lang.IllegalStateException: Already tesselating!
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.Tessellator.startDrawing(Tessellator.java:343)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.Tessellator.startDrawingQuads(Tessellator.java:333)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.TexturedQuad.draw(TexturedQuad.java:48)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.ModelBox.render(ModelBox.java:102)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.ModelRenderer.compileDisplayList(ModelRenderer.java:298)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.ModelRenderer.render(ModelRenderer.java:131)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at narrakan.minesona.client.ModelVelvetTable.render(ModelVelvetTable.java:48)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at narrakan.minesona.client.RendererVelvetTable.renderWorldBlock(RendererVelvetTable.java:33)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at cpw.mods.fml.client.registry.RenderingRegistry.renderWorldBlock(RenderingRegistry.java:145)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.FMLRenderAccessLibrary.renderWorldBlock(FMLRenderAccessLibrary.java:78)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:510)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.WorldRenderer.updateRenderer(WorldRenderer.java:218)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.RenderGlobal.updateRenderers(RenderGlobal.java:1457)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.EntityRenderer.renderWorld(EntityRenderer.java:1075)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:947)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:888)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:783)
2012-11-14 13:06:53 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)

 

But if I remove the line

modelVelvetTable.render(0.025F);

from renderWorldBlock in my renderer, everything works fine (the block is obviously transparent), and if I change it to

renderer.renderStandardBlock(mod_Minesona.velvetTable, x, y, z);

it works just fine, rendering a simple block.

 

Am I missing something?

 

PS: I am more than willing to update the wiki with any information provided in this thread, if it helps solving the problem.

Posted

What I suggest is, since your using a tile entity, to use a custom tile entity renderer instead of the block renderer.

 

Like so:

 

In your Client Proxy:

 

ClientRegistry.bindTileEntitySpecialRenderer(MyTileEntity.class, new MyTileEntityRenderer());

 

From there, you'd just need to render the model in the renderer, something like this:

 

    MyModel model = new MyModel();
    ...
    public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
    {			
	GL11.glPushMatrix();
	GL11.glTranslatef((float)d + 0.5F, (float)d1 - 0.5F, (float)d2 + 0.5F);
	GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
	GL11.glTranslatef(0.0F, -2.0F, 0.0F);								
	bindTextureByName(texturePathHere);			
	model.renderModelAsTileEntity(0.0625F); (or something like that)			
	GL11.glPopMatrix();		
    }

Posted

Thanks, after a bit of tweaking, it's now working fine using TileEntitySpecialRenderer.

 

However I'm still curious why it didn't work with my previous code. Oh well, I guess I'll stick to this anyway. ;D

  • 2 months later...

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.