Jump to content

[1.8] Error when trying to get Player's Ping


Trusak

Recommended Posts

Hello, I want my mod to show the Player's ping when he is on a server, but whenever I join a Server my Minecraft crashes with this error:

[spoiler=Error]

[12:38:54] [Client thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.client.event.RenderGameOverlayEvent$Text@651eefb3:
java.lang.NullPointerException
at Clean.Coins.CC.onRenderGameOverlay(CC.java:148) ~[CC.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_7_CC_onRenderGameOverlay_Text.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:669) [GuiIngameForge.class:?]
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:149) [GuiIngameForge.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1135) [EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_111]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_111]
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_111]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_111]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
[12:38:54] [Client thread/ERROR] [FML]: Index: 1 Listeners:
[12:38:54] [Client thread/ERROR] [FML]: 0: NORMAL
[12:38:54] [Client thread/ERROR] [FML]: 1: ASM: Clean.Coins.CC@109a28c8 onRenderGameOverlay(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$Text;)V
[12:38:55] [Client thread/INFO] [FML]: Applying holder lookups
[12:38:55] [Client thread/INFO] [FML]: Holder lookups applied
[12:38:56] [Client thread/FATAL]: Unreported exception thrown!
java.lang.NullPointerException
at Clean.Coins.CC.onRenderGameOverlay(CC.java:148) ~[CC.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_7_CC_onRenderGameOverlay_Text.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?]
at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:669) ~[GuiIngameForge.class:?]
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:149) ~[GuiIngameForge.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1135) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_111]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_111]
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_111]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_111]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_111]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
[12:38:56] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:612]: ---- Minecraft Crash Report ----
// I'm sorry, Dave.

Time: 11.12.16 12:38
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at Clean.Coins.CC.onRenderGameOverlay(CC.java:148)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_7_CC_onRenderGameOverlay_Text.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:669)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:149)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1135)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107)
at net.minecraft.client.Minecraft.run(Minecraft.java:380)
at net.minecraft.client.main.Main.main(Main.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at Clean.Coins.CC.onRenderGameOverlay(CC.java:148)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_7_CC_onRenderGameOverlay_Text.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:669)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:149)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityPlayerSP['Player749'/194085, l='MpServer', x=8,50, y=65,00, z=8,50]]
Chunk stats: MultiplayerChunkCache: 0, 0
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: -11,00,63,00,10,00 - World: (-11,63,10), Chunk: (at 5,3,10 in -1,0; contains blocks -16,0,0 to -1,255,15), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 0 game time, 0 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
Forced entities: 1 total; [EntityPlayerSP['Player749'/194085, l='MpServer', x=8,50, y=65,00, z=8,50]]
Retry entities: 0 total; []
Server brand: Spigot
Server type: Non-integrated multiplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:383)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2645)
at net.minecraft.client.Minecraft.run(Minecraft.java:409)
at net.minecraft.client.main.Main.main(Main.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
Minecraft Version: 1.8.9
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_111, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 685120176 bytes (653 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP 9.19 Powered by Forge 11.15.1.1902 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJA	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJA	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1902-1.8.9.jar) 
UCHIJA	Forge{11.15.1.1902} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1902-1.8.9.jar) 
UCHIJA	TruSP{1.0} [simplePixel] (bin) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 358.91' Renderer: 'GeForce GT 610/PCIe/SSE2'
Launched Version: 1.8.9
LWJGL: 2.9.4
OpenGL: GeForce GT 610/PCIe/SSE2 GL version 4.5.0 NVIDIA 358.91, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: No
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: TrusakPack.zip
Current Language: English (US)
Profiler Position: N/A (disabled)
CPU: 4x AMD A10-5800K APU with Radeon(tm) HD Graphics 
[12:38:56] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:612]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\trusa\Desktop\Mods\Test Mod D\run\.\crash-reports\crash-2016-12-11_12.38.56-client.txt
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

 

[spoiler=Code]

@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent.Text event){

	if(Minecraft.getMinecraft().thePlayer != null){
		int fps = Minecraft.getDebugFPS();

		Minecraft.getMinecraft().fontRendererObj.drawString("FPS: " + fps, 10, 10, Color.ORANGE.getRGB());

		/*if(!Minecraft.getMinecraft().isIntegratedServerRunning()){
			int ping = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(Minecraft.getMinecraft().thePlayer.getUniqueID()).getResponseTime();
			Minecraft.getMinecraft().fontRendererObj.drawString("Ping: " + ping, 10, 20, Color.CYAN.getRGB());	
		}*/
	}
}

 

Link to comment
Share on other sites

Is this line 148?

 

if(Minecraft.getMinecraft().thePlayer != null){

?

 

Minecraft.getMinecraft() should only work on the clientSide.

 

To be double sure with my event I did this:

 

@SideOnly(Side.CLIENT)

    @SubscribeEvent

    public void onDebugOverlay(final RenderGameOverlayEvent.Text event)

    {

        if (FMLCommonHandler.instance().getEffectiveSide().isClient())

        {

... Minecraft.getMinecraft()

Link to comment
Share on other sites

Is this line 148?

 

if(Minecraft.getMinecraft().thePlayer != null){

?

 

Minecraft.getMinecraft() should only work on the clientSide.

 

To be double sure with my event I did this:

 

@SideOnly(Side.CLIENT)

    @SubscribeEvent

    public void onDebugOverlay(final RenderGameOverlayEvent.Text event)

    {

        if (FMLCommonHandler.instance().getEffectiveSide().isClient())

        {

... Minecraft.getMinecraft()

Nope, that didn't fix it either :(

Link to comment
Share on other sites

Put a debug point where it crashes and then start the game in debug mode until it reaches that line and then set a watch on all variables which are involved in that line.

The game always crashes at

int ping = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(Minecraft.getMinecraft().thePlayer.getUniqueID()).getResponseTime();

if that is what you mean :o

Link to comment
Share on other sites

Just print out every item of the line:

 

Minecraft.getMinecraft().getNetHandler().getPlayerInfo(Minecraft.getMinecraft().thePlayer.getUniqueID()).getResponseTime();

 

before you call it to check which one of them is null.

 

Like Log.getLogger().info(getNetHandler() != null) etc for the playerinfo etc

Link to comment
Share on other sites

Just print out every item of the line:

 

Minecraft.getMinecraft().getNetHandler().getPlayerInfo(Minecraft.getMinecraft().thePlayer.getUniqueID()).getResponseTime();

 

before you call it to check which one of them is null.

 

Like Log.getLogger().info(getNetHandler() != null) etc for the playerinfo etc

Ok I tried it using

if (Minecraft.getMinecraft() != null){
					System.out.println("Minecraft");
				}
				if (Minecraft.getMinecraft().getNetHandler() != null){
					System.out.println("NetHandler");
				}
				if (Minecraft.getMinecraft().getNetHandler().getPlayerInfo(Minecraft.getMinecraft().thePlayer.getUniqueID()) != null){
					System.out.println("PlayerInfo");
				}

and everything but "PlayerInfo" printed out. I guess that is the error but I still don't know how to fix it :/.

Link to comment
Share on other sites

(you know....because they don't exist/aren't connected to a server...)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

The problem is not that there is not a player, the problem is that if you are not logged in with a Minecraft account in your dev environment, the random player generated each start doesn't get a UUID. Therefore the PlayerInfo is null. This is essentially the same behaviour as seen with cracked accounts.

Link to comment
Share on other sites

The problem is not that there is not a player, the problem is that if you are not logged in with a Minecraft account in your dev environment, the random player generated each start doesn't get a UUID. Therefore the PlayerInfo is null. This is essentially the same behaviour as seen with cracked accounts.

It doesn't work with my normal account either

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.