Jump to content

[1.16.2] Item Rendered Inside Translucent Entity Not Visible


BlueMond

Recommended Posts

So I've made an entity that has a part of the model that is a translucent cube, and now I'm trying to render an item from the entity within that translucent cube. I can see that the item is rendering, since it peeks out of the cube a bit, but I can't see the item through the translucent cube. I'm not that great with rendering since I've only recently begun modding Minecraft, so I need a bit of help figuring out how to get the item to be visible through the translucent cube.

 

 

Here is what it looks like.

 

image.png.30254e29322c5800d701ca34bec63fb0.png

 

 

 

Here is the renderer class that it uses.

 

package me.bluemond.bluemagic.client.entity.renderer;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import me.bluemond.bluemagic.BlueMagic;
import me.bluemond.bluemagic.client.entity.model.EmpowermentEntityModel;
import me.bluemond.bluemagic.entities.EmpowermentEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.ResourceLocation;
import software.bernie.geckolib.render.IModelRenderer;

public class EmpowermentEntityRenderer extends EntityRenderer<EmpowermentEntity> implements IModelRenderer
{

    protected static final ResourceLocation TEXTURE = new ResourceLocation(BlueMagic.MOD_ID, "textures/entity/empowerment_entity.png");
    protected final EmpowermentEntityModel empowermentModel = new EmpowermentEntityModel();


    public EmpowermentEntityRenderer(EntityRendererManager renderManager) {

        super(renderManager);
        this.shadowSize = 0.5f;

    }

    @Override
    public void render(EmpowermentEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) {
        this.empowermentModel.setRotationAngles(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F);
        this.empowermentModel.setLivingAnimations(entityIn, 0, 0, partialTicks);

        IVertexBuilder iVertexBuilder = bufferIn.getBuffer(RenderType.getEntityTranslucent(this.getEntityTexture(entityIn)));
        this.empowermentModel.render(matrixStackIn, iVertexBuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
        super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);

        if(entityIn.getPotionStack() != null){
            matrixStackIn.push();
            matrixStackIn.translate(0, 1, 0);
            matrixStackIn.scale(0.5F, 0.5F, 0.5F);
            Minecraft.getInstance().getItemRenderer().renderItem(entityIn.getPotionStack(), ItemCameraTransforms.TransformType.FIXED, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn);
            matrixStackIn.pop();
        }
    }

    @Override
    public ResourceLocation getEntityTexture(EmpowermentEntity entity){
        return TEXTURE;
    }

    @Override
    public EntityModel getEntityModel()
    {
        return this.empowermentModel;
    }
}
Edited by BlueMond
Link to comment
Share on other sites

Two things I suggest, reverse the order of rendering so that the item renders first and then the entity. Other thing is change the graphics to fabulous. I think only one of these will work.

 

My theory though is that the item is being culled out from the ItemRenderer#renderItem as it uses a culling render layer. Since it's inside another block, it's being told that hey, you can't render here. So you'll probably need to make your own version that removes the culling feature from it rendering.

Link to comment
Share on other sites

8 hours ago, ChampionAsh5357 said:

Two things I suggest, reverse the order of rendering so that the item renders first and then the entity. Other thing is change the graphics to fabulous. I think only one of these will work.

 

My theory though is that the item is being culled out from the ItemRenderer#renderItem as it uses a culling render layer. Since it's inside another block, it's being told that hey, you can't render here. So you'll probably need to make your own version that removes the culling feature from it rendering.

Alright, I'll look into it.

 

EDIT: So I've looked into the item renderer and I dont see any special culling within the render function, but it does seem like whatever rendertype it is using for the buffer in the vertexbuilder could be affecting whether or not it is visible through the block.

 

EDIT 2: Now that I think of it, I might benefit from using the EntityItemRenderer, rather than the ItemRenderer. Item Entities seem to be able to be seen from within translucent blocks, for example, water.

 

EDIT 3: So I can't seem to find where and how an ItemEntity is rendered. Anyone know about that?

Edited by BlueMond
Link to comment
Share on other sites

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.