Jump to content

Recommended Posts

Posted

I am messing around with custom block rendering and such, I have gotten the block to render correctly in world. But the block in my Inventory is a flat square not a block with the wrong texture, not stone overlaid with for now glass.

 

Renderer Code

The things I tried with "renderInventoryBlock" didn't make any difference.

Setting "shouldRender3DInInventory" to true makes the item invisible

 

  Reveal hidden contents

 

Posted
  On 5/7/2014 at 8:44 AM, shadoskill said:

Sorry for bumping the thread but still at a loss on how to fix this. :/

 

It renders nothing when you return true in shouldRender3DInInventory because you don't have anything in your method renderInventoryBlock

You need to return true, but also do your own render inside inventories with renderInventoryBlock

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 5/7/2014 at 8:54 AM, SanAndreasP said:

  Quote

Sorry for bumping the thread but still at a loss on how to fix this. :/

 

It renders nothing when you return true in shouldRender3DInInventory because you don't have anything in your method renderInventoryBlock

You need to return true, but also do your own render inside inventories with renderInventoryBlock

So just going out on a limb here and ask, is there a simple way to make it render like a vanilla block does in inventory or do I have to go learn about Tessellator and GL11?

Posted

You can reuse your code in renderWorldBlock, but instead of using renderStandardBlock, use renderBlockAsItem (with appropriate parameters, Block, metadata, colorMultiplier)

But please note, if the block which is rendered by that method has a custom render ID as well, you need to render it directly.

Here's an example, where the code needed (except line 25) is marked yellow:

https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/RenderBlockGlowOverlay.java#L24-L61

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 5/7/2014 at 10:35 AM, SanAndreasP said:

You can reuse your code in renderWorldBlock, but instead of using renderStandardBlock, use renderBlockAsItem (with appropriate parameters, Block, metadata, colorMultiplier)

But please note, if the block which is rendered by that method has a custom render ID as well, you need to render it directly.

Here's an example, where the code needed (except line 25) is marked yellow:

https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/RenderBlockGlowOverlay.java#L24-L61

Thanks! I actually understood that easier than I thought, took me a bit to figure out what did what.

Posted
  On 5/7/2014 at 12:52 PM, shadoskill said:

  Quote

You can reuse your code in renderWorldBlock, but instead of using renderStandardBlock, use renderBlockAsItem (with appropriate parameters, Block, metadata, colorMultiplier)

But please note, if the block which is rendered by that method has a custom render ID as well, you need to render it directly.

Here's an example, where the code needed (except line 25) is marked yellow:

https://github.com/SanAndreasP/SAPManagerPack/blob/master/java/de/sanandrew/core/manpack/util/client/RenderBlockGlowOverlay.java#L24-L61

Thanks! I actually understood that easier than I thought, took me a bit to figure out what did what.

 

I am not sure why but I am now getting a crash it seems when my overlayed blocks are generated now, it all worked before I changed the blocks.

Spawning them in creative superflat they seem to be working, but default world type crash on world load, and disabling my generation code stopped it.

I am loading the Renderer code before all of the world stuff.

 

Crash report.

 

  Reveal hidden contents

 

Posted

Can you give us the new code you're using?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

In your render file, you do

        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));

 

Do not call the method twice at the same time, basically you setup the tessellator, set the normal, add the vertices (that's what renderFaceYNeg and the like do) and then draw.

If you add too many vertices (like you do by calling the method one after another) with the currently selected drawing method it throws this exception.

Basically, what you have to do is a construct like this:

        tess.startDrawingQuads();
        tess.setNormal(0.0F, -1.0F, 0.0F);
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        tess.draw();
        tess.startDrawingQuads();
        // no need to set the normal again if you call the same render face method
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));
        tess.draw();

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 5/8/2014 at 6:08 AM, SanAndreasP said:

In your render file, you do

        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));

 

Do not call the method twice at the same time, basically you setup the tessellator, set the normal, add the vertices (that's what renderFaceYNeg and the like do) and then draw.

If you add too many vertices (like you do by calling the method one after another) with the currently selected drawing method it throws this exception.

Basically, what you have to do is a construct like this:

        tess.startDrawingQuads();
        tess.setNormal(0.0F, -1.0F, 0.0F);
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, Blocks.stone.getBlockTextureFromSide(0));
        tess.draw();
        tess.startDrawingQuads();
        // no need to set the normal again if you call the same render face method
        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSide(block, 0));
        tess.draw();

 

 

So I managed to fix the crash by removing "renderer.renderStandardBlock" and doing all the faces separately.

Now the only last issue is its dark in my hand, and this its real wonky in world.

 

https://dl.dropboxusercontent.com/u/21990361/16d6c8294246cdc5273d0e647d6045f4.gif

https://dl.dropboxusercontent.com/u/21990361/ed7c1ff2defea1f3018a8f1e6419dd94.gif

 

I can fix this by putting "Tessellator.instance.setBrightness(255);" but then that makes the ore stand out in darkness.

Posted

In your renderInventoryBlock, use the tess.setBrightness(240) before rendering

In your renderWorldBlock use tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)) before drawing.

For that light-shining-through issue, use block.setLightOpacity(255) when you construct your block.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 5/8/2014 at 8:54 AM, SanAndreasP said:

In your renderInventoryBlock, use the tess.setBrightness(240) before rendering

In your renderWorldBlock use tess.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)) before drawing.

For that light-shining-through issue, use block.setLightOpacity(255) when you construct your block.

Thanks for that, didn't even notice the LightOpacity in the gif lol. But it turns out setting that made the blocks ignore light and stay dark. So thats not really a issue leaving them were light can pass. Its no were near perfect brightness slightly off still in direct sunlight but I can live with that.

 

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.