Jump to content

[1.7.10][Kind of solved...]Weird NullPointer


BuddingDev

Recommended Posts

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!!!)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.