lizardman Posted June 3, 2016 Posted June 3, 2016 Hey all, first time poster. I'm just learning how to use Forge, so I'm trying to make a chest clone. I've copied over most of the Chest's code, with a bit of my own -- it's meant to ALWAYS be a double chest that can only store a certain type of item. So far, it works great - reliably creates the second dummy block, synchronized inventory between blocks, etc. But, when rendering it, the block renders off of the player's position rather than its own - causing it to (rather humorously) follow the player. Below is my code: Chest Block Tile Entity Tile Entity Renderer Frankly, I'm stumped. I'm fairly confident the root of the problem is in one of these three classes, but if need be I can provide the rest related to it. Any advice? Quote
Jedispencer21 Posted June 3, 2016 Posted June 3, 2016 I can see a few mistakes, and for the block moving with you, if you look in the TileEntityChestRenderer it has a few lines that you don't have which are: Reveal hidden contents GlStateManager.pushMatrix(); GlStateManager.enableRescaleNormal(); GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F); GlStateManager.scale(1.0F, -1.0F, -1.0F); GlStateManager.translate(0.5F, 0.5F, 0.5F); which is put before the rotation. Quote
Guest Posted June 3, 2016 Posted June 3, 2016 Your renderer should be spamming your log with GL errors because you are only doing a pushMatrix if the block is getting hit/destroyed. I would suggest you to try to understand the chest renderer and rewrite it for your needs. This code contains some stuff which is (from my limited knowledge) unneeded. Quote
lizardman Posted June 3, 2016 Author Posted June 3, 2016 Alright, thanks for the advice. Rendering is really the most confusing part for me right now - I've never really worked with anything like it in the past. I'll give those a shot after work. Quote
lizardman Posted June 4, 2016 Author Posted June 4, 2016 On 6/3/2016 at 8:13 AM, Jedispencer21 said: I can see a few mistakes, and for the block moving with you, if you look in the TileEntityChestRenderer it has a few lines that you don't have which are: Reveal hidden contents GlStateManager.pushMatrix(); GlStateManager.enableRescaleNormal(); GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F); GlStateManager.scale(1.0F, -1.0F, -1.0F); GlStateManager.translate(0.5F, 0.5F, 0.5F); which is put before the rotation. Tried this, and it worked like a charm! Now I guess it's time to find out why that works so this doesn't happen again. Thanks! 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.