-
Notifications
You must be signed in to change notification settings - Fork 56
Rendered Textures
Render an item, a block or anything else into a texture you can then draw as a flat image.
The game can only draw a block model in 3D. If you want a flat picture of one, on a label, a map, a sign, a GUI, there's no vanilla way to get it. This renders into an offscreen framebuffer once and hands you back a texture you use like any other.
FrameBufferBackedDynamicTexture texture =
RenderedTexturesManager.requestFlatItemTexture(Items.DIAMOND_BLOCK, 32, t -> {});
if (texture.isInitialized()) {
VertexConsumer vc = buffer.getBuffer(RenderType.entityCutout(texture.getTextureLocation()));
// draw it like any other texture
}The request is asynchronous, the texture fills in when it's rendered, so check isInitialized()
before using it. Textures are cached by id, so requesting the same one every frame is fine.
For anything more complex, request by your own id and draw into it yourself:
var texture = RenderedTexturesManager.requestTexture(MyMod.res("my_texture"), 64, t -> {
// draw into the texture here, see RenderedTexturesManager.drawTexture
}, true);Use TickableFrameBufferBackedDynamicTexture if the content has to update over time.
Example: RenderedTextureExample
Basics Platform Helpers Registration Networking Events Configs Config Screen
Resources Runtime Resource Packs Texture Manipulation Resource Helpers Block Set API
Client Custom Models Item Rendering Rendered Textures Post Shaders GUI Toolkit Colors
World Block and Item Interfaces Additional Item Placements Improved Entities Fake Levels World Data Dispenser Behaviors
Utilities Codec Utilities Misc Helpers Commands
Datapacks Villagers Soft Fluids Map Markers Spawn Boxes Global Datapack Folder