Jump to content

[1.6.4][SOLVED] (Coremod) ClassCastException: EntityClientPlayerMP to Player


FlameAtronach93

Recommended Posts

Hello there.

 

My coremod's generating a fairly unrelated exception that I cannot find the cause of:

 

2014-05-11 22:57:58 [iNFO] [sTDERR] java.lang.ClassCastException: net.minecraft.client.entity.EntityClientPlayerMP cannot be cast to cpw.mods.fml.common.network.Player

2014-05-11 22:57:58 [iNFO] [sTDERR] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245)

2014-05-11 22:57:58 [iNFO] [sTDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:85)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.client.multiplayer.NetClientHandler.handleCustomPayload(NetClientHandler.java:1651)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1967)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:910)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:838)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.client.main.Main.main(Main.java:93)

2014-05-11 22:57:58 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2014-05-11 22:57:58 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

2014-05-11 22:57:58 [iNFO] [sTDERR] at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

 

I am not modifying either of the two classes, but several piston related classes. Without the mod, everything runs just fine. On a side note, I don't even exactly understand how it is possible to cast net.minecraft.client.entity.EntityClientPlayerMP to cpw.mods.fml.common.network.Player...

 

The exception arises when attempting to load an existing or create a new world. I am able to load up the main menu.

 

I recall that I had this error before, but I do not remember how I fixed it. What could be the cause of this?

Since I have no idea where the error originates in, I don't want to overflow this post with loads of source code. If you need any more information or code, feel free to ask.

 

Any leads are appreciated.

 

Sincerely

 

 

Update: Even with class transforming disabled (getASMTransformerClass() returning an empty array) I still get this error... On the strange side, another coremod I had developed earlier still works without any issues. The funny thing being that that coremod served as the basis of the current one, most files having been copied over, slightly changed and renamed.

 

 

Following is the crash log:

 

2014-05-11 22:57:58 [iNFO] [sTDOUT] ---- Minecraft Crash Report ----

2014-05-11 22:57:58 [iNFO] [sTDOUT] // On the bright side, I bought you a teddy bear!

2014-05-11 22:57:58 [iNFO] [sTDOUT]

2014-05-11 22:57:58 [iNFO] [sTDOUT] Time: 5/11/14 10:57 PM

2014-05-11 22:57:58 [iNFO] [sTDOUT] Description: Unexpected error

2014-05-11 22:57:58 [iNFO] [sTDOUT]

2014-05-11 22:57:58 [iNFO] [sTDOUT] java.lang.ClassCastException: net.minecraft.client.entity.EntityClientPlayerMP cannot be cast to cpw.mods.fml.common.network.Player

2014-05-11 22:57:58 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:85)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.multiplayer.NetClientHandler.handleCustomPayload(NetClientHandler.java:1651)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1967)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:910)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.run(Minecraft.java:838)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.main.Main.main(Main.java:93)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at java.lang.reflect.Method.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

2014-05-11 22:57:58 [iNFO] [sTDOUT]

2014-05-11 22:57:58 [iNFO] [sTDOUT]

2014-05-11 22:57:58 [iNFO] [sTDOUT] A detailed walkthrough of the error, its code path and all known details is as follows:

2014-05-11 22:57:58 [iNFO] [sTDOUT] ---------------------------------------------------------------------------------------

2014-05-11 22:57:58 [iNFO] [sTDOUT]

2014-05-11 22:57:58 [iNFO] [sTDOUT] -- Head --

2014-05-11 22:57:58 [iNFO] [sTDOUT] Stacktrace:

2014-05-11 22:57:58 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:85)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.multiplayer.NetClientHandler.handleCustomPayload(NetClientHandler.java:1651)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)

2014-05-11 22:57:58 [iNFO] [sTDOUT]

2014-05-11 22:57:58 [iNFO] [sTDOUT] -- Affected level --

2014-05-11 22:57:58 [iNFO] [sTDOUT] Details:

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level name: MpServer

2014-05-11 22:57:58 [iNFO] [sTDOUT] All players: 1 total; [EntityClientPlayerMP['Player843'/25, l='MpServer', x=8.50, y=66.62, z=8.50]]

2014-05-11 22:57:58 [iNFO] [sTDOUT] Chunk stats: MultiplayerChunkCache: 0

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level seed: 0

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level generator: ID 00 - default, ver 1. Features enabled: false

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level generator options:

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level spawn location: World: (8,64,8), Chunk: (at 8,4,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level time: 0 game time, 0 day time

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level dimension: 0

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level storage version: 0x00000 - Unknown?

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

2014-05-11 22:57:58 [iNFO] [sTDOUT] Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

2014-05-11 22:57:58 [iNFO] [sTDOUT] Forced entities: 1 total; [EntityClientPlayerMP['Player843'/25, l='MpServer', x=8.50, y=66.62, z=8.50]]

2014-05-11 22:57:58 [iNFO] [sTDOUT] Retry entities: 0 total; []

2014-05-11 22:57:58 [iNFO] [sTDOUT] Server brand: fml,forge

2014-05-11 22:57:58 [iNFO] [sTDOUT] Server type: Integrated singleplayer server

2014-05-11 22:57:58 [iNFO] [sTDOUT] Stacktrace:

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:440)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2312)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.run(Minecraft.java:863)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.client.main.Main.main(Main.java:93)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at java.lang.reflect.Method.invoke(Unknown Source)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

2014-05-11 22:57:58 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

2014-05-11 22:57:58 [iNFO] [sTDOUT]

2014-05-11 22:57:58 [iNFO] [sTDOUT] -- System Details --

2014-05-11 22:57:58 [iNFO] [sTDOUT] Details:

2014-05-11 22:57:58 [iNFO] [sTDOUT] Minecraft Version: 1.6.4

2014-05-11 22:57:58 [iNFO] [sTDOUT] Operating System: Windows 8 (amd64) version 6.2

2014-05-11 22:57:58 [iNFO] [sTDOUT] Java Version: 1.7.0_51, Oracle Corporation

2014-05-11 22:57:58 [iNFO] [sTDOUT] Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

2014-05-11 22:57:58 [iNFO] [sTDOUT] Memory: 931765728 bytes (888 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

2014-05-11 22:57:58 [iNFO] [sTDOUT] JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

2014-05-11 22:57:58 [iNFO] [sTDOUT] AABB Pool Size: 10817 (605752 bytes; 0 MB) allocated, 10817 (605752 bytes; 0 MB) used

2014-05-11 22:57:58 [iNFO] [sTDOUT] Suspicious classes: FML and Forge are installed

2014-05-11 22:57:58 [iNFO] [sTDOUT] IntCache: cache: 0, tcache: 0, allocated: 1, tallocated: 63

2014-05-11 22:57:58 [iNFO] [sTDOUT] FML: MCP v8.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 4 mods loaded, 4 mods active

2014-05-11 22:57:58 [iNFO] [sTDOUT] mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

2014-05-11 22:57:58 [iNFO] [sTDOUT] FML{6.4.45.953} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

2014-05-11 22:57:58 [iNFO] [sTDOUT] Forge{9.11.1.953} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

2014-05-11 22:57:58 [iNFO] [sTDOUT] myblocks{@@VERSION@@} [MyBlocks] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

2014-05-11 22:57:58 [iNFO] [sTDOUT] Launched Version: 1.6

2014-05-11 22:57:58 [iNFO] [sTDOUT] LWJGL: 2.9.0

2014-05-11 22:57:58 [iNFO] [sTDOUT] OpenGL: GeForce GTX 770/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation

2014-05-11 22:57:58 [iNFO] [sTDOUT] Is Modded: Definitely; Client brand changed to 'fml,forge'

2014-05-11 22:57:58 [iNFO] [sTDOUT] Type: Client (map_client.txt)

2014-05-11 22:57:58 [iNFO] [sTDOUT] Resource Pack: Default

2014-05-11 22:57:58 [iNFO] [sTDOUT] Current Language: English (US)

2014-05-11 22:57:58 [iNFO] [sTDOUT] Profiler Position: N/A (disabled)

2014-05-11 22:57:58 [iNFO] [sTDOUT] Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

 

 

 

Solution:

 

Due to runtime deobfuscation, do not attempt to load a Minecraft class ahead of time, not even for detecting whether you're in a deobfuscated development environment. Instead, use

Launch.blackboard.get("fml.deobfuscatedEnvironment")

.

 

Source:

Can't see anything too wrong, except your "debug-mode" detection. It's broken and will always detect being in debug mode, even if you're not. That is because FML deobfuscates classnames at runtime. Use

Launch.blackboard.get("fml.deobfuscatedEnvironment")

instead.

Loading the World class this early in the game launching process might cause some issues, so try and remove it.

Link to comment
Share on other sites

The exception is occurring in a custom packet 250; do you send any packets in your mod? If so, you may want to check that your packets and handling thereof.

 

I don't currently have Eclipse open, so this is just speculation, but if I remember correctly, cpw's Player class is used when sending a packet from the server to the client and is only ever cast from the server player entity (EntityPlayerMP), but somehow you have a packet that is trying to cast from the client player, as though you are trying to send a packet to the client from the client.

Link to comment
Share on other sites

The exception is occurring in a custom packet 250; do you send any packets in your mod? If so, you may want to check that your packets and handling thereof.

 

I don't currently have Eclipse open, so this is just speculation, but if I remember correctly, cpw's Player class is used when sending a packet from the server to the client and is only ever cast from the server player entity (EntityPlayerMP), but somehow you have a packet that is trying to cast from the client player, as though you are trying to send a packet to the client from the client.

 

While that may explain when cpw's Player is used, it still doesn't help me at all. The exception occurs even in the "purest" form of my mod, i.e. when everything is commented out. Moreover, the only thing I'm currently doing in the mod is make changes to several piston related classes, such as TileEntityPiston and BlockPistonBase. It has nothing to do with any packets yet. That's why I'm completely clueless as to why this exception even arises...

 

I'm going to try to rewrite the code. If I'm lucky, the error just simply disappears...

 

Thanks anyway. :)

Link to comment
Share on other sites

The Player interface is a so called "marker interface" which is applied by cpw's MarkerTransformer to the EntityPlayer class. The purpose is to allow to write code which doesn't need to interact with Minecraft code, but can still reference a player (for cross-version compatibility and easier updating).

 

So, somehow your code stops FML's transformer from being run at all, or run properly. Post some code maybe?

Thanks a lot for the deeper insight. I had figured it to happen like that.

 

As I said, I temporarily removed the ASM transformers and everything else... I previously had cpw and net.minecraftforge packages listed in transformer exclusions, so that can't be the reason. A new project with a rewritten Coremod and copied transformers seems to work. I suspect it to be some issue with the project setup...

 

I can upload all the code I have including the eclipse project to GitHub. Since I cannot quite tell where the error lies, this should be the best way. Although the "rewritten" project does work now, I'd still like to know where the error originates in so I know what to avoid in the future.

 

Here's the repo.

Link to comment
Share on other sites

Can't see anything too wrong, except your "debug-mode" detection. It's broken and will always detect being in debug mode, even if you're not. That is because FML deobfuscates classnames at runtime. Use

Launch.blackboard.get("fml.deobfuscatedEnvironment")

instead.

Loading the World class this early in the game launching process might cause some issues, so try and remove it.

 

I just happened to have verified that loading the World class this early indeed leads to issues. I noticed this exception which only occurred using this detection:

 

2014-05-12 15:31:43 [iNFO] [sTDERR] java.lang.NoSuchMethodException: net.minecraftforge.event.entity.EntityJoinWorldEvent.<init>()

2014-05-12 15:31:43 [iNFO] [sTDERR] at java.lang.Class.getConstructor0(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at java.lang.Class.getConstructor(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraftforge.event.EventBus.register(EventBus.java:74)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraftforge.event.EventBus.register(EventBus.java:58)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraftforge.common.MinecraftForge.initialize(MinecraftForge.java:211)

2014-05-12 15:31:43 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2014-05-12 15:31:43 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.callForgeMethod(FMLCommonHandler.java:222)

2014-05-12 15:31:43 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.beginLoading(FMLCommonHandler.java:99)

2014-05-12 15:31:43 [iNFO] [sTDERR] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:166)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:473)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:808)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraft.client.main.Main.main(Main.java:93)

2014-05-12 15:31:43 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2014-05-12 15:31:43 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

2014-05-12 15:31:43 [iNFO] [sTDERR] at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

 

What a coincidence that that class is a World event... Thank you a lot, removing this faulty detection resolved the error. :)

 

I know about the runtime deobfuscation. I actually had chosen that class as a dummy... I was going to replace it with a more suiting class later, but I'm going to stick to your proposal.

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.