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

Hey guys,

I'm trying to make a block that stores a single Itemstack using nbt. If an Item is stored it gets displayed above the block.  Itemstacks can be placed in the block by clicking. This works fine and the block also maintains the item when I rejoin the world. For some reason the item is not rendered anymore when you rejoin. When the block that should have an item inside is clicked you get the item back so it seems like it was stored properly... But why doesnt it render?

 

Here is my Tile entity class: https://pastebin.com/JYJagNnN

 

The render function in my tile entity renderer looks roughly like this:

 

    @Override
    public void render(DeadbushAltarPedestalTileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
        if(tileEntityIn.hasItem()) {
            long time = System.currentTimeMillis();
            Quaternion rotation = Vector3f.YP.rotationDegrees((time/20)%360);
            
            matrixStackIn.push();
            matrixStackIn.translate(0.5, 1.3, 0.5);
            matrixStackIn.scale(0.6f, 0.6f, 0.6f);
            matrixStackIn.rotate(rotation);
            
            ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
            ItemStack stack = tileEntityIn.getPedestalItems();
            IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(stack, tileEntityIn.getWorld(), null);
            itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, true, matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn, ibakedmodel);
            
            matrixStackIn.pop();
        }
    }

  I have checked the values of most variables in that class when the game is running and stack from the render function is always air (the default value). To me this means that getPedestalItems doesnt return the correct value... I have no idea why this is happening only after you rejoin the world. if you place a new item onto the pedestal it works fine...

I would be very happy if someone could help :)

Edited by xX_deadbush_Xx

  • Author

Thank you very much, I have looked into the example classes and I was missing all of the tag and packet methods!

I dont really understand what the difference between them is and when I need them but I put them all in and it worked!

Edited by xX_deadbush_Xx

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.