Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

What I have:

1) a block and tile entity used for storage, like a chest

2) a block that will act as a 'top' for block #1

 

What I am trying to do:

The container/gui for the storage block has a special slot that is used to store block #2. When the player drops block #2 into this slot I want block #1 to render both blocks at the same coordinates, essentially combining the two models together.

 

Both blocks have their own .json model file and I would like to use these if this is possible.

 

It seems that the solution should be implemented in the renderTileEntityAt() method of the TESR for block #1, but I have yet to see an example anywhere of how to do this.

 

An alternative (and preferred) solution would be to dynamically change one of the textures in the storage block based on the contents of the special gui slot. Is this possible?

 

Any help would be greatly appreciated.

Hi

 

It should be possible, in your TileEntitySpecialRenderer, to retrieve the IBakedModel for both blocks using

      Minecraft mc = Minecraft.getMinecraft();

      BlockRendererDispatcher blockRendererDispatcher = mc.getBlockRendererDispatcher();

      BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes();

      IBakedModel ibakedmodel = blockModelShapes.getModelForState(iBlockState);

 

and then render the appropriate face(s) of that.  The hardest part will be setting up the rendering settings correctly.  You could look at RenderItemFrame for inspiration.

 

You could also use ISmartBlockModel to combine the two models together without using TESR at all.

For example see here

https://github.com/TheGreyGhost/MinecraftByExample

(examples MBE04 and MBE05)

 

Alternatively, if you set up a custom model for #1 with its own DynamicTexture and use the Tessellator to draw the top face, you could dynamically modify the texture as you suggested.  That's probably harder though.

If you are thinking of going that route, this class might be useful:

https://github.com/TheGreyGhost/SpeedyTools/blob/master/src/main/java/speedytools/clientside/selections/SelectionBlockTextures.java

This class is used to capture the texture of all sides of a given block and store them in a DynamicTexture.  Other classes then bind the dynamic texture and use the Tessellator to render a cube in mid-air.  RenderFallingBlock.doRender() shows some vanilla code which does something similar.

It might also be possible, using the same technique, to use OpenGL to render your new texture directly to the blocks texture sheet TextureMap.locationBlocksTexture.

 

If you're just learning Minecraft and/or OpenGL I think it will be a steep learning curve... :)

 

-TGG

 

 

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.