Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

140M Downloads

[Forge 1.20.1][Help/Question] Rendering Item Json Models On Player

TheLightmare opened this issue ยท 3 comments

commented

my objective

I want to make a sword i made render in the back of the player when placed in the dedicated slot.

problem

The ICuriosRenderer class doesn't allow for layers, which in the vanilla code are used to render items on entities.

things i tried

making an entity model exactly identical to the item, but since the sword is made of details that are smaller than 1 pixel, the textures are messed up

i looked up every example i could find, but none of them did anything close to what i want to do. So any help is very welcome !

commented

Is that not adequate for your needs?

How would you render the JSON model normally (outside of Curios)?

commented

The ICuriosRenderer class doesn't allow for layers, which in the vanilla code are used to render items on entities.

I'm not sure what you mean by that. It doesn't allow for layers because it is itself called within another layer, CuriosLayer, defined by Curios natively.

Can you give an example? Or better, can you share your current rendering code and I can maybe see how it can be converted to the necessary code blocks?

commented

The idea is to render a json model instead of a Java class model (sorry i should have said that from the start). So for now i basically used the example code to render a model class :

public class GrashwandirCurioRenderer<L extends LivingEntity> implements ICurioRenderer {

    private static final ResourceLocation GRASHWANDIR_TEXTURE = new ResourceLocation(GrashwandirMod.MODID,
            "textures/item/grashwandir.png");
    private final GrashwandirBackModel model;

    public GrashwandirCurioRenderer() {
        this.model = new GrashwandirBackModel(
                Minecraft.getInstance().getEntityModels().bakeLayer(CuriosLayerDefinitions.GRASHWANDIR));
    }


    @Override
    public <T extends LivingEntity, M extends EntityModel<T>> void render(ItemStack stack,
                                                                          SlotContext slotContext,
                                                                          PoseStack matrixStack,
                                                                          RenderLayerParent<T, M> renderLayerParent,
                                                                          MultiBufferSource renderTypeBuffer,
                                                                          int light, float limbSwing,
                                                                          float limbSwingAmount,
                                                                          float partialTicks,
                                                                          float ageInTicks,
                                                                          float netHeadYaw,
                                                                          float headPitch) {
        // Render Grashwandir on the back of the player

        LivingEntity entity = slotContext.entity();

        this.model.prepareMobModel(entity, limbSwing, limbSwingAmount, partialTicks);

        this.model.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);

        ICurioRenderer.followBodyRotations(entity, this.model);

        VertexConsumer vertexconsumer = ItemRenderer
                .getArmorFoilBuffer(renderTypeBuffer, RenderType.armorCutoutNoCull(GRASHWANDIR_TEXTURE), false,
                        stack.hasFoil());
        this.model
                .renderToBuffer(matrixStack, vertexconsumer, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F,
                        1.0F, 1.0F);
    }