Jump to content

[SOLVED] Make modelPart renders as end portal via renderer


Sam__Wilde

Recommended Posts

Hello, I want to make it so that a certain part of my mob model is rendered as a portal to the end. Using the second layer I was able to render a second model with the portal effect, but I don't need the whole model. How to fix this?
(This is a test mob, I want to render its head as a portal).

Current code:

Constructor of Renderer
public MegovidRenderer(EntityRendererProvider.Context pContext) {
        super(pContext, new MegovidModel<>(pContext.bakeLayer(ModModelLayers.MEGOVID_LAYER)), 0.5f);
        this.addLayer(new MegovidHeadRenderer(this));
    }

 

Register renderer
@SubscribeEvent
        public static void onClientSetup(FMLClientSetupEvent event) {
            EntityRenderers.register(ModEntities.MEGOVID.get(), MegovidRenderer::new);
        }

 

HeadRenderer
public class MegovidHeadRenderer<T extends LivingEntity> extends RenderLayer<T, MegovidModel<T>> {
    private static final RenderType GATEWAY = RenderType.endGateway();

    public MegovidHeadRenderer(RenderLayerParent<T, MegovidModel<T>> pRenderer) {
        super(pRenderer);
    }

    @Override
    public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T t, float v, float v1, float v2, float v3, float v4, float v5) {
        poseStack.pushPose();
        poseStack.translate(0,-2,0);
        this.getParentModel().renderToBuffer(
                poseStack,
                multiBufferSource.getBuffer(this.renderType()),
                15728640,
                OverlayTexture.NO_OVERLAY,
                1.0F, 1.0F, 1.0F, 1.0F);
        poseStack.popPose();
    }

    private RenderType renderType() {
        return GATEWAY;
    }
}

 

Result:

spacer.png

Edited by Sam__Wilde
Solved
Link to comment
Share on other sites

I figured out how to solve this problem.
You need to make a custom renderToBuffer in the model file.

Current Code:

HeadRenderer

public class MegovidHeadRenderer<T extends LivingEntity> extends RenderLayer<T, MegovidModel<T>> {
    private static final RenderType GATEWAY = RenderType.endGateway();

    public MegovidHeadRenderer(RenderLayerParent<T, MegovidModel<T>> pRenderer) {
        super(pRenderer);
    }

    @Override
    public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T t, float v, float v1, float v2, float v3, float v4, float v5) {
        this.getParentModel().renderToBufferCUSTOM(
                poseStack,
                multiBufferSource.getBuffer(GATEWAY),
                15728640,
                OverlayTexture.NO_OVERLAY,
                1.0F, 1.0F, 1.0F, 1.0F);
    }
}

 

Model file

public void renderToBufferCUSTOM(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
		poseStack.translate(0,1.5,0);
		head.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
	}



Result:

spacer.png

Link to comment
Share on other sites

  • Sam__Wilde changed the title to [SOLVED] Make modelPart renders as end portal via renderer

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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