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.

[SOLVED][1.18.2] .getQuads(...) does not get quads for beds/chests/fluids/ext.

Featured Replies

Posted

When I try to get quads for beds/chests/fluids via this code

// Get level, where command is executed
ServerLevel level = source.getLevel();

// Get BlockState at position
BlockState block = level.getBlockState(levelPosition);

// We do not want to render air
if (!block.isAir()) {
	// Is used to get IBakedModel
	BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();

	// Is used in getQuads(...)
	Random rand = new Random();

	// Rendered block
    RenderedBlock renderedBlock = new RenderedBlock(regionPosition.getX(),
                                                    regionPosition.getY(),
                                                    regionPosition.getZ());

    // Block extra model data
    IModelData data = blockRenderer.getBlockModel(block).getModelData(level, levelPosition, block, EmptyModelData.INSTANCE);

    // Get model quads
    List<BakedQuad> quads = blockRenderer.getBlockModel(block).getQuads(block, null, rand, data);

   	// List of all possible directions
    ArrayList<Direction> directions = RenderCubeUtils.getAllPossibleDirections();

    // Through all directions
    for (Direction direction : directions) {
    	// Get model quads, corresponding to this direction
        List<BakedQuad> quadsTemp = blockRenderer.getBlockModel(block).getQuads(block, direction, rand, data);

        // Join lists of quads
        quads = Stream.concat(quads.stream(), quadsTemp.stream()).toList();
	}
}

I get empty 'quads' list. Why is this happening? How can I fix this?

Edited by Sireous
Question is solved

They don't use baked models. See for example BedRenderer.

The only thing they define in their models is the block break particle 🙂 

https://github.com/misode/mcmeta/blob/assets/assets/minecraft/models/block/bed.json

 

I've never tried to do it, but I guess If you want to draw something with a BlockEntityRenderer then you need to use the BlockEntityRendererDispatcher

BlockEntityWithoutLevelRenderer kind of does this, but it does it to draw them as items.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Thanks warjort. I was afraid, that this is because they are entities. Now I know where to dig.

But what about water, for example? I have checked via debug code, that there is no entity there (appropriate method return null). What is wrong with liquids?

BlockRenderDispatcher.renderLiquid()

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

By the way, I see a lot of renderers use VertexConsumer. Seems like all renderers use them to send verticies to graphics engine. Can I make such consumer and act as OpenGL to get rendered verticies in a block?

  • Guest changed the title to [SOLVED][1.18.2] .getQuads(...) does not get quads for beds/chests/fluids/ext.

Like I said, it's not something I've tried, but I would say probably not, it depends upon what you are trying to do.

 

Those renderers are not prebacked for a reason. Their rendering depends ad hocly upon the state of the world.

You could in principle call them with your own dummy consumers to capture the quads, but those quads could (likely will) be invalid once the state of the world changes.

This includes time where the rendering is animated.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.