Jump to content

[1.15.2] Render original item model in ItemStackTileEntityRenderer


XFactHD

Recommended Posts

I have a gun item that needs to have additional models like sights rendered on it. I got the ISTER to do "something", but I can't for the live of me figure out how to render the original item with its appropriate transforms.

I specifically have two problems:

  1. There seems to be no way to get the ItemCameraTransforms.TransformType the renderer was called for
  2. The call to IBakedModel::handlePerspective seems to have no influence

 

This is my render code:

public class RenderGun extends ItemStackTileEntityRenderer
{
    private EnumGun gun;
    private IBakedModel gunModel;
    private Random rand = new Random();
    private IModelData data = new ModelDataMap.Builder().build();

    public RenderGun() { }

    @Override
    public void render(ItemStack stack, MatrixStack mstack, IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay)
    {
        if (gun == null && stack.getItem() instanceof ItemGun) { gun = ((ItemGun)stack.getItem()).getGun(); }
        if (gun != null && gunModel == null) { gunModel = getGunModel(gun); }

        IVertexBuilder builder = buffer.getBuffer(RenderType.getCutoutMipped());

        if (gunModel != null)
        {
            //noinspection deprecation
            gunModel.handlePerspective(ItemCameraTransforms.TransformType.FIXED, mstack);
            for (BakedQuad quad : gunModel.getQuads(null, null, rand, data))
            {
                builder.addQuad(mstack.getLast(), quad, 1.0F, 1.0F, 1.0F, combinedLight, combinedOverlay);
            }
        }
    }
}

 

Link to comment
Share on other sites

I dug a little deeper into this and found a rather convoluted (in my opinion) way to fix this. The only way to get the ItemCameraTransform.TransformType the renderer was called with seems to be to save it in your custom IBakedModel implementation (which you need anyway for ISTERs to work at all) in IBakedModel::handlePerspective which gets called from the item renderer before calling your ISTER. This also makes the call to IBakedModel::handlePerspective in the ISTER obsolete.

 

Now that that works I have the problem that the models that are rendered do not have any shading whatsoever.

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.

Announcements



×
×
  • Create New...

Important Information

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