Jump to content

[SOLVED][1.11.2] Switch Block NullPointerException


IvanSteklow

Recommended Posts

Hi everyone, I started new mod, but got a problem:

Crash-report:

Spoiler

Unreported exception thrown!
java.lang.NullPointerException
	at ivansteklow.fmhammers.tools.ItemHammer.onBlockStartBreak(ItemHammer.java:35) ~[ItemHammer.class:?]
	at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDestroyBlock(PlayerControllerMP.java:146) ~[PlayerControllerMP.class:?]
	at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDamageBlock(PlayerControllerMP.java:339) ~[PlayerControllerMP.class:?]
	at net.minecraft.client.Minecraft.sendClickBlockToController(Minecraft.java:1504) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2290) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:407) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]

 

So, you can view this file at my GitHub: https://github.com/IvanSteklow/FMHammers/blob/master/src/main/java/ivansteklow/fmhammers/tools/ItemHammer.java

 

HELP ME PLS!!! & excuse me for my broken english

Edited by IvanSteklow
Solved
  • Like 1
Link to comment
Share on other sites

A Null Pointer Exception means you're treating a variable like an object, but it actually holds null (or "nothing") in it, so it doesn't have the methods you're trying to use. This error tells you the problem is in your ItemHammer.java file on line 35. So check there and see what variables you're trying to access, and then you can start thinking about why they might not have an actual object like you're expecting. Hint: Look at how many different constructors RayTraceResult has, and look at which one you're using. (Also, take V0idW1k3r's advice in general; but for the NPE, look at the constructors.)

Edited by IceMetalPunk

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

15 hours ago, IceMetalPunk said:

A Null Pointer Exception means you're treating a variable like an object, but it actually holds null (or "nothing") in it, so it doesn't have the methods you're trying to use. This error tells you the problem is in your ItemHammer.java file on line 35. So check there and see what variables you're trying to access, and then you can start thinking about why they might not have an actual object like you're expecting. Hint: Look at how many different constructors RayTraceResult has, and look at which one you're using. (Also, take V0idW1k3r's advice in general; but for the NPE, look at the constructors.)

 

15 hours ago, V0idWa1k3r said:

This is not how you raytrace anything. Items already have a built-in raytrace method conviniently called Item::rayTrace.

Thank you, I fixed it!

  • Like 1
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.