Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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);
            }
        }
    }
}

 

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.