Posted May 2, 201510 yr I am confused. Why this gives me NullPointer? TileEntity tile = world.getTileEntity(x, y, z); I intend to check null the next line, but then it crashed at that line.
May 2, 201510 yr Author I made world as this.worldObj (This code is in a class extending from TileEntity)
May 2, 201510 yr You can use debugging mode in Eclipse to see what is going on. Or add a check for null with a console statement. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
May 2, 201510 yr Author I cant find the errors!!! I have all coordinates passing in legit. (That should work!!!)
May 2, 201510 yr AND add before print in to console of all args (world, x, y, z), and come back with log... Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
May 2, 201510 yr We cant help you if you dont show us anyhing. Just saiing. The chance that you get a NPE bc of forge isnt updated is really small.
May 2, 201510 yr Author K, here are more info: Problematic function: ("world" is set to "worldObj", to make life easier) (MultipleControllerException is a self-made Exception class. But I cant test its functionality because this code fails... and the Exception appear later in the code (which is not shown)) private void checkBound() throws MultipleControllerException { for (int i=0; i<6; i++) { ForgeDirection dir = ForgeDirection.getOrientation(i); int x = dir.offsetX + xCoord; int y = dir.offsetY + yCoord; int z = dir.offsetZ + zCoord; TileEntity tile; // DEBUG if (world.isRemote) { Minecraft.getMinecraft().thePlayer.sendChatMessage("X: " + x); Minecraft.getMinecraft().thePlayer.sendChatMessage("Y: " + y); Minecraft.getMinecraft().thePlayer.sendChatMessage("Z: " + z); Minecraft.getMinecraft().thePlayer.sendChatMessage("World: " + world); } tile = world.getTileEntity(x, y, z); } What the game printed: (What the game gave me:) can't even print anything. Conclusion: somehow the "world" variable failed. (BTW, nice Forge loading GUI!!!)
May 2, 201510 yr Author WEIRD, now that it gave me some more info now: [server thread/INFO]: <Player860> X: -225 [server thread/INFO]: <Player860> Y: 105 [server thread/INFO]: <Player860> Z: 237 [server thread/INFO]: <Player860> World: net.minecraft.client.multiplayer.WorldClient@59027d30 but still it crashed. K, even more info: public TEMCGController() { this.world = this.worldObj; } It is getting more crazy.
May 2, 201510 yr Author Oh, what... So where is the world initialised...? So it may just be a program style issue...
May 2, 201510 yr Author So it may be just a program code-writing style issue... Anyway it is kinda fixed for now.
May 2, 201510 yr So it may be just a program code-writing style issue... No, that is not a "coding style" issue, it is a coding error: you are trying to assign something at a time when the assignment is either bad or at least unpredictable. That is a logical mistake and therefore wrong no matter what your coding style is. Now it is understandable to make such a mistake -- when modding, the nuanced behavior of the Minecraft implementation is not always obvious. It reminds me of someone who was trying to use the entity position in the constructor. Similarly, the position is not asssigned at that point, so using it would be wrong. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.