xX_deadbush_Xx Posted April 9, 2020 Posted April 9, 2020 (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 April 10, 2020 by xX_deadbush_Xx Quote
TheGreyGhost Posted April 10, 2020 Posted April 10, 2020 Hi Probably you have not implemented all of the loading & saving functions correctly for your TileEntity. See this tutorial project for a working example https://github.com/TheGreyGhost/MinecraftByExample mbe20 and/or mbe21 -TGG 1 Quote
xX_deadbush_Xx Posted April 10, 2020 Author Posted April 10, 2020 (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 April 10, 2020 by xX_deadbush_Xx Quote
Recommended Posts
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.