Jakemichie97 Posted October 19, 2012 Posted October 19, 2012 Okay, I've created a custom modelled block (Anvil) and I was using an item to place it, but now I want a full 3D block, so I tried to use a block rendering class which implemented ISimpleBlockRenderingHandler and ran minecraft, crashed, said something about my texture (crash log below). Code: TileEntityAnvilRenderer package jcm2606.te.client.tiles; import jcm2606.te.client.models.ModelAnvil; import jcm2606.te.common.tileentities.TileEntityAnvil; import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntitySpecialRenderer; import org.lwjgl.opengl.GL11; public class TileEntityAnvilRenderer extends TileEntitySpecialRenderer { public static TileEntityAnvilRenderer instance = new TileEntityAnvilRenderer(); public TileEntityAnvilRenderer() { aModel = new ModelAnvil(); } public void renderAModelAt(TileEntityAnvil tile, double d, double d1, double d2, float f) { int i = 0; if (tile.worldObj != null) { i = tile.getBlockMetadata(); } int j = 0; if (i == 0) { j = 0; } if (i == 1) { j = 90; } if (i == 2) { j = 180; } if (i == 3) { j = 270; } bindTextureByName("/jcm2606/te/modelAnvil.png"); //texture GL11.glPushMatrix(); //start GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); //size GL11.glRotatef(j, 0.0F, 1.0F, 0.0F); //rotate based on metadata GL11.glScalef(1.0F, -1F, -1F); //if you read this comment out this line and you can see what happens aModel.renderModel(0.0625F); //renders and yes 0.0625 is a random number GL11.glPopMatrix(); //end } public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f) { renderAModelAt((TileEntityAnvil)tileentity, d, d1, d2, f); } public static ModelAnvil aModel; } Block renderer package jcm2606.te.client.core; import jcm2606.te.client.tiles.TileEntityAnvilRenderer; import jcm2606.te.common.lib.RenderID; import jcm2606.te.common.tileentities.TileEntityAnvil; import net.minecraft.src.Block; import net.minecraft.src.IBlockAccess; import net.minecraft.src.RenderBlocks; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class InventoryRenderer implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { if(modelID == RenderID.ID_ANVIL_RENDER) { TileEntityAnvilRenderer.instance.renderTileEntityAt(new TileEntityAnvil(), 0.0D, 0.0D, 0.0D, 0.0F); } } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { // TODO Auto-generated method stub return false; } @Override public boolean shouldRender3DInInventory() { return true; } @Override public int getRenderId() { return RenderID.ID_ANVIL_RENDER; } } Eclipse crash log 9 22:53:19 [iNFO] [sTDERR] java.lang.NullPointerException 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.TileEntitySpecialRenderer.bindTextureByName(TileEntitySpecialRenderer.java:21) 2012-10-19 22:53:19 [iNFO] [sTDERR] at jcm2606.te.client.tiles.TileEntityAnvilRenderer.renderAModelAt(TileEntityAnvilRenderer.java:49) 2012-10-19 22:53:19 [iNFO] [sTDERR] at jcm2606.te.client.tiles.TileEntityAnvilRenderer.renderTileEntityAt(TileEntityAnvilRenderer.java:62) 2012-10-19 22:53:19 [iNFO] [sTDERR] at jcm2606.te.client.core.InventoryRenderer.renderInventoryBlock(InventoryRenderer.java:19) 2012-10-19 22:53:19 [iNFO] [sTDERR] at cpw.mods.fml.client.registry.RenderingRegistry.renderInventoryBlock(RenderingRegistry.java:150) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.FMLRenderAccessLibrary.renderInventoryBlock(FMLRenderAccessLibrary.java:84) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.RenderBlocks.renderBlockAsItem(RenderBlocks.java:6460) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.RenderItem.drawItemIntoGui(RenderItem.java:217) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.RenderItem.renderItemIntoGUI(RenderItem.java:281) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.GuiIngame.renderInventorySlot(GuiIngame.java:692) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.GuiIngame.renderGameOverlay(GuiIngame.java:325) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:898) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:882) 2012-10-19 22:53:19 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:775) 2012-10-19 22:53:19 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source) And the ForgeModLoader-client-0.log file says the same. Thanks to whomever be reading this and I hope you find something. Quote
Jakemichie97 Posted October 21, 2012 Author Posted October 21, 2012 I'd hate to do it but I have to, bump. Quote
Jakemichie97 Posted October 22, 2012 Author Posted October 22, 2012 Okay, can some one please help, I really need this as I don't want to have to use an item to place this block down. If it helps, I've narrowed it down the the bindTextureByName method. Yes I have the texture in the .jar (it works in the world, I have been able to test as it won't crash when I don't have the item in my inventory, once I do it crashes.), yes I have typed in the path correctly. Please, if someone knows, please reply... Quote
Jakemichie97 Posted October 22, 2012 Author Posted October 22, 2012 How about not bumping? I would stop but considering that this thread has been here for 3+ days with no replies and I really need the fix (Cannot find a single problem and I even have 3 other modders helping me) I am at the point were I have to... sorry though. Quote
gokiburi Posted October 22, 2012 Posted October 22, 2012 Sounds like a simple NPE. If this is the solution, you may want to look into basic programming tutorials. For now, I've gone through the steps one should take when they encounter a NPE. 1. 22:53:19 [sTDERR] java.lang.NullPointerException 2. 2012-10-19 22:53:19 [sTDERR] at net.minecraft.src.TileEntitySpecialRenderer.bindTextureByName(TileEntitySpecialRenderer.java:21) 3. 2012-10-19 22:53:19 [sTDERR] at jcm2606.te.client.tiles.TileEntityAnvilRenderer.renderAModelAt(TileEntityAnvilRenderer.java:49) 4. 2012-10-19 22:53:19 [sTDERR] at jcm2606.te.client.tiles.TileEntityAnvilRenderer.renderTileEntityAt(TileEntityAnvilRenderer.java:62) Your stack trace shows that your issue ends up in your class TileEntityAnvilRenderer. We know this thanks to lines 3 and 4. Following along the trace shows that the exception is actually thrown in the TileEntitySpecialRenderer.bindTextureByName function. It also shows the file and line number: TileEntitySpecialRenderer.java:21. Looking there, we find this section of code: ... 19. protected void bindTextureByName(String par1Str) 20. { 21. RenderEngine var2 = this.tileEntityRenderer.renderEngine; 22. 23. if (var2 != null) 24. { 25. var2.bindTexture(var2.getTexture(par1Str)); 26. } 27. } ... Line 21 shows that there are 3 possible null variables; this, this.tileEntityRenderer, and this.tileEntityRenderer.renderEngine. Looking at the TileEntitySpecialRenderer class we can see it does not set a tileEntityRenderer when created. ... 12. protected TileEntityRenderer tileEntityRenderer; ... There is a function to do so; ... 32. public void setTileEntityRenderer(TileEntityRenderer par1TileEntityRenderer) 33. { 34. this.tileEntityRenderer = par1TileEntityRenderer; 35. } ... We can also see that you never call this function in the code you provided. I can only assume that if you actually set the TileEntityRenderer and its renderEngine, the error would not be thrown. Quote http://www.minecraftforum.net/topic/1522738-132-forge-425-gokimods/
Jakemichie97 Posted October 22, 2012 Author Posted October 22, 2012 Quick question, that requires a TileEntityRenderer, which I have a TileEntitySpecialRenderer, incompatible types and would likely throw more errors if I create another one. And also if it were to be the error your describing, wouldn't that cause it to crash on world load, it doesn't as it works in the world, I can see the block clearly with the texture and all. Quote
gokiburi Posted October 22, 2012 Posted October 22, 2012 Trace out the values of this, this.tileEntityRenderer and this.tileEntityRenderer.renderEngine right before the crash line. Look for which is null and make that variable not null. I'm only explaining why the error is thrown, not giving you alternatives. If you don't want to set the tileEntityRenderer on your TileEntitySpecialRenderer to something not null, you could rewrite the bindTextureByName function to not use a TileEntityRenderer. I can't tell you how to do that though. To answer your questions; If they were incompatible types, the TileEntitySpecialRenderer wouldn't be asking to set a TileEntityRenderer and the bindTextureByName function wouldn't be looking for one. You need to use one or make one alongside your TileEntitySpecialRenderer, I suppose. Secondly, if it isn't crashing when you load the world, then no, the error I'm describing wouldn't cause the world to crash on load, because I'm describing your error, which doesn't cause the world to crash on load. Quote http://www.minecraftforum.net/topic/1522738-132-forge-425-gokimods/
Jakemichie97 Posted October 22, 2012 Author Posted October 22, 2012 Okay, thanks, I will try tomorrow as it is late. Quote
Jakemichie97 Posted October 24, 2012 Author Posted October 24, 2012 Okay, I think I know the cause, something that you had said, but not quite... since I'm using a TileEntitySpecialRenderer it should be taken as if it is a TileEntityRenderer (someone correct me if I'm wrong), what I think is causing this is the fact that I'm not creating a RenderEngine instance. I will try now and post me results. 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.