Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)

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

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