#How to imitate item frame rendering to render a blockstate that doesn't exist?

1 messages · Page 1 of 1 (latest)

noble wind
#

I'm currently trying to make an entity which renders two block models (one normally, the other tinted, as seen in second image using an entity model) referenced from a blockstate, in the same fashion that item frame entities render an imaginary item frame block with a blockstate of either map=true or map=false. However, the console reports that the blockstate referenced does not have the boolean property requested and the model is displayed as missing.

I know this could be resolved easily by just actually registering a block, but I want to achieve this in a fashion that doesn't add an unused block to the registry whilst still allowing resource packs to redefine what the entity looks like by modifying the block models.
https://github.com/Lyinginbedmon/Wheelchairs-2/blob/1.20/src/client/java/com/lying/wheelchairs/renderer/block/WHCSpecialModels.java#L25
https://gist.github.com/Lyinginbedmon/a22133d8fd9e08cdaf702ea988fbe15d#file-latest-txt-L86

noble wind
#

How to imitating item frame rendering to render a blockstate that doesn't exist?

#

How to imitate item frame rendering to render a blockstate that doesn't exist?

twin berry
#

You should instead use an item template with overrides. If the item used to place your block is supposed to have the same model as your block then you do not need to create a fake block.
I did something similar for an armor renderer.

// I get the item model
val mc=MinecraftClient.getInstance()
val root_model=mc.itemRenderer.models.getModel(stack)
val model=root_model.overrides.apply(root_model,stack,entity.world as? ClientWorld, entity, 0) ?: root_model
[...]

// I get the armor vertex consumer, you should use another one for your block entity
val vertexs = ItemRenderer.getArmorGlintConsumer(
    buffer, RenderLayer.getArmorCutoutNoCull(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE), false, stack.hasGlint()
)
matrices.push()
matrices.multiply(Quaternionf().rotateZYX(contextModel.head.roll, [...]// Some matrix transformation
val matrix=matrices.peek()
matrices.pop()

// I manually give the consumer the vertexs of the model.
val quads=model.getQuads(null, null, Random.create())
for(quad in quads){
    val quad_color=[...]
    vertexs.quad(
        matrix,
        quad,
        ColorHelper.Argb.getRed(quad_color)/255f,
        ColorHelper.Argb.getGreen(quad_color)/255f,
        ColorHelper.Argb.getBlue(quad_color)/255f,
        light,
        0
    )
}
noble wind
#

The placing item isn't meant to look like the chair however, it's meant to look like the entire wheelchair

noble wind
#

For illustration: There is no "seat" item, nor is there intended to be. The wheelchair is crafted using any two wheels, a material, and wool. Hence, the wheelchair is one item, with no intermediate crafting item to use to render the seat as part of the wheelchair.

#

And I'd still need two block models in order to render the tinted seat