Jump to content

Recommended Posts

Posted

I am wanting to render a block (currently held item) as if it had been placed in the world at a certain location *without* actually placing it in the world.

 

I have no problem with the currently held item and setting the location I'm just unsure the proper way to get the block's renderer?

 

I've looked at MinecraftForgeClient.getItemRenderer but there doesn't seem to be a suitable render type and I'm not too sure how to get the require data params.

I've also looked at RenderBlocks but I'm not clear on how to get the correct instance of it.

Posted

For the rendering I would try RenderBlocks.renderBlockByRenderType(...)

 

Access to the RenderBlocks instance you could get either via a CustomBlockRenderer (you would have to place a block where you would like to render stuff)

RenderingRegistry.registerBlockHandler(...);

 

Or you could try it with the RenderWorldLastEvent (access to RenderBlocks)

 

Or try this:

http://www.minecraftforge.net/forum/index.php?topic=1882.0

Posted

I'm trying RenderBlock.renderBlockByRenderType inside of a RenderWorldLastEvent but nothing renders.

 

I can't seem to see a RenderBlocks instance in RenderWorldLastEvent, I only see RenderGlobal instance?

Posted

I'm trying RenderBlock.renderBlockByRenderType inside of a RenderWorldLastEvent but nothing renders.

 

I can't seem to see a RenderBlocks instance in RenderWorldLastEvent, I only see RenderGlobal instance?

 

Sorry didn't see that

renderGlobal.renderBlocksRg

is a private field...

 

I am really not sure how you SHOULD do this but maybe hook a RenderTickEvent or RenderWorldLastEvent and then make renderBlocksRg public via reflection or something :P

I definitely think there's a different way...

Posted

I am looking at the source for WorldRenderer.updateRenderer in the hopes to shine some light on the subject.

 

It just creates a new renderer blocks with the current chunk being rendered. Some I'm pretty sure I should be okay just doing:

 

RenderBlocks renderer = new RenderBlocks(/* get player's worldobj*/);

 

Looking through it does some setting up, then calls RenderBlocks.renderBlockByRenderType. I'm going to see if I can at least imitate drawing a stone block then expand from there.

Posted

Looking through it does some setting up, then calls RenderBlocks.renderBlockByRenderType. I'm going to see if I can at least imitate drawing a stone block then expand from there.

 

Would be nice if you post your solution here, for others to see :) (including me)

Posted

Okay to my understanding what I'm intending to do it not currently possible in the current implementation of Forge.

 

It all dissolves down to ISimpleBlockRenderingHandler.renderWorldBlock for custom blocks or RenderBlocks.renderXXX for vanilla blocks.

 

These expect the block to exist at the passed position in the given IBlockAccess as they do things like world.getBlockMetadata(x, y, z). The problem with that is when the block doesn't actually exist you're not going to fetch relevant metadata.

 

I toyed with the idea of creating a fake world and setting the block at the position to the block that's wanting to be imitated so that it can get any relevant information it wants but I don't like the idea of duplicating the world.

 

I thought about making the fake world a wrapper for the real world that checks if the block being accessed is a "fake block" and so we don't duplicate the world just trick the accessor into believing the block actually exists.

 

Ultimately I'm going to stop here because a lot of the rendering code I've looked at sets textures and colours inside it's rendering method which will prevent me from doing what I wanted to do. I was hoping for a way to just get a block to populate the tessellator with vertices.

Posted

Look at the RenderFallingSand code and how it did it.

 

You can adopt the code with some changes in your block renderer.

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

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

That uses an Entity and uses the block info of the block that's being made to fall.

 

Like I said the block doesn't exist in the world so I can't rely on renderXXX

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.