Hi,
I have a problem with a null pointer Exception. I have a method in my GameState. This method is called within the update()-method of the state with several parameters. Look at my update method:
@Override
public void update(float tpf) {
updatePermeableFilter();
updateVerticalForce(tpf);
updatePlayerPosition(tpf);
}
The method updatePlayerPosition() and updateVerticalForce() are calling
isUserInPermableBlock(Direction.TOP);
No problem. Works fine.
The method updatePermeableFilter() is calling
isUserInPermeableBlock(Direction.BOTTOM);
So, now let’s have a look at this method: (Yes, Direction.BOTTOM and Direction.TOP are int constants):
private boolean isUserInPermeableBlock(int direction) {
Vector3f loc = m_player.getLocalTranslation().clone();
if (direction == Direction.BOTTOM) {
loc.y -= Player.PLAYER_HEIGHT;
} else {
loc.y -= (Player.PLAYER_HEIGHT / 4.0f);
}
return Block.isPermeable(m_world.getBlockAt(loc));
}
In all ways, this method does not throw any exception but works fine. Even if I call it with the Paramater Direction.TOP. In this case, a new Quad with an unshaded material is created and put to the gui node.
Nothing like rocket science or so, but I got a NullPointerExcpetion:
java.lang.NullPointerException
at com.jme3.shader.Uniform.setValue(Uniform.java:184)
at com.jme3.material.Technique.updateUniformParam(Technique.java:151)
at com.jme3.material.MatParam.apply(MatParam.java:147)
at com.jme3.material.Material.render(Material.java:1088)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:523)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:322)
at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:371)
at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:788)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:719)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:983)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1035)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)
Normally I’d say that I made a mistake when adding the Quad to the gui node, but I don’t think so. If i delete the path for Direction.TOP in the above function usUserInPermableBlock(…), the quad is also set, just a little bittle later (if the player is deeper in the water). That means, the quad is set in qvery case, but if I have th little piece of code
loc.y -= (Player.PLAYER_HEIGHT / 4.0f);
than it won’t work and I get the exception.
Does anybody have an idea? Maybe it would also be helpfull if one of the core developers could tell me what the exception means (yes, something is null, I know, but what is interneally done, if the exception occurs? Seems to occur during rendering?!)