Jump to content

[1.10.2] Rendering TileEntity with 3D items : TileEntitySpecialRenderer or not ?


Major Squirrel

Recommended Posts

Good evening,

 

I have been searching some tutorials, sample codes and public GitHub repositories to learn how to render Minecraft items in 3D, in the "world". So I have found some useful links such as

or by experience the Bibliocraft mod (as you can see, potions and books are rendered on their shelves).

 

Replicate the same result wouldn't be a big challenge since the tutorial above is nice and well explained, but I've seen some topics such as this one highlighting that TileEntitySpecialRenderers should only be used for animating blocks. Yet, in both links I included above, there is no animation at all, only 3D items rendering alongwith blocks.

 

  • Is TileEntitySpecialRenderer the only way to render 3D items in the world with a TileEntity ?
  • I've also read that TileEntitySpecialRenderers were super greedy regarding gpu and rendering, why is that ?
  • Would it be "super risky" if about a hundred of TileEntities using a special renderer were placed all around the world ?

Squirrel ! Squirrel ! Squirrel !

Link to comment
Share on other sites

  • No it is not, you can use an IBakedModel and add the BakedQuads of the item you want to add to the rendering ones.
  • This is because TESRs draw themselves to the screen every single frame.
  • Only if they where placed close together, and not done efficiently.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1. I would say yes, especially if any item can be placed on the block. In that case you would need to generate immense amounts of baked models for every possible combination of up to about 32000 items when you wanted to use the baked model system. @Animefan you cannot change the position of a baked model without GL calls.

2. That's because a TESR is rerendered every frame and not only when a chunk is updated.

3. That mostly depends on how efficient your render code is.

Link to comment
Share on other sites

@Animefan you cannot change the position of a baked model without GL calls.

I swear I was once told by Diesieben there was a way to access the TE and there by the ItemStacks containing it (hasn't had to use the IBakedModel system yet).

 

Edit: I thought of a way it could be possible. But by god it might be a pain to implement. You could make the blockstate hold the x, y, z positions, of course this might cause a problem of having way to many possible combinations in the blockstate, but never fear if applying a custom state mapper and overriding the createBlockState method to return a custom BlocKStateContainer that doesn't load a blockstate or at least throws out those Properties, that problem can be averted. And then you can access the TE from Minecraft.getMinecraft().theWorld.getTileEntity(blockPos from state) and access the inventory. Though if I remember what Diesieben said correctly then this probably is not what he was talking about.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

You can use the ExtendedBlockState provided by forge to store whatever data structures you want in it. The problem is that if you want to change the transformation, rotation or scaling of a model you would need to rebake it. Also, accessing the world from an IBakedModel will cause a ConcurrentModificationException because Client Thread and Rendering are separate things since 1.8.

Diesieben also once tried to explain to me that this can be done with the baked model system but when it came to the question how to actually bake the models and access all the data needed, he had to pass.

Link to comment
Share on other sites

You can use the ExtendedBlockState provided by forge to store whatever data structures you want in it. The problem is that if you want to change the transformation, rotation or scaling of a model you would need to rebake it. Also, accessing the world from an IBakedModel will cause a ConcurrentModificationException because Client Thread and Rendering are separate things since 1.8.

Diesieben also once tried to explain to me that this can be done with the baked model system but when it came to the question how to actually bake the models and access all the data needed, he had to pass.

Maybe scheduling a task to get the world or just the ItemStacks.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Yes. But beware to make the code extremely efficient.

 

What do you mean by "extremely efficient" ? Regarding OpenGL code ?

You should only draw to the screen when you need to. Ie you need a boolean that determines when you need to re render the item(s).

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Kinda. Let's say you wanted to render a turbine with a rotating wheel, then you should make the rotation calculations in the tile entity and only access the values from the renderer instead of calculating them in there (bad example, I know).

 

@Animefan that won't work as a TESR is rendered directly and not stored in a DisplayList or anything similar until it needs to be rerendered.

Link to comment
Share on other sites

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.