CreativeCore

CreativeCore

88M Downloads

ClassCastException from LittleTiles Calling PlayerUtils.getGameType

Exaxxion opened this issue ยท 19 comments

commented

An invalid cast is used between EntityPlayerSP and EntityPlayerMP. This seems to be occurring when the player launches an Advanced Rocketry rocket to change dimensions to Luna. I'm not sure why LittleTiles would be involved, but the offending code is in CreativeCore so opening this ticket here.

Relevant versions:

  • CreativeCore_v1.10.10_mc1.12.2.jar
  • LittleTiles_v1.5.0-pre199_19_mc1.12.2.jar
  • AdvancedRocketry-1.12.2-1.7.0-209-universal.jar

Stack trace:

java.lang.ClassCastException: net.minecraft.client.entity.EntityPlayerSP cannot be cast to net.minecraft.entity.player.EntityPlayerMP
	at com.creativemd.creativecore.common.utils.mc.PlayerUtils.getGameType(PlayerUtils.java:31)
	at com.creativemd.littletiles.common.action.LittleAction.canPlace(LittleAction.java:322)
	at com.creativemd.littletiles.client.render.overlay.PreviewRenderer.drawHighlight(PreviewRenderer.java:244)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_1512_PreviewRenderer_drawHighlight_DrawBlockHighlightEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(ForgeHooksClient.java:191)
	at net.minecraft.client.renderer.EntityRenderer.func_175068_a(EntityRenderer.java:1361)
	at net.minecraft.client.renderer.EntityRenderer.func_78471_a(EntityRenderer.java:1259)
	at net.minecraft.client.renderer.EntityRenderer.func_181560_a(EntityRenderer.java:1062)
	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1119)
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)
	at net.minecraft.client.main.Main.main(SourceFile:123)
	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 org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196)
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231)
	at org.multimc.EntryPoint.listen(EntryPoint.java:143)
	at org.multimc.EntryPoint.main(EntryPoint.java:34)

Full log is here: Nomifactory/Nomifactory#440 (comment)

commented

Can confirm this is still occurring as of LittleTiles v1.5.0-pre199_34 and CreativeCore v1.10.16 along with AR v1.12.2-1.7.0-209 (Enigmatica 2: Expert version).

Player was accessing Guidance Computer in AR to change destination when the crash occurred.

Crash report: https://pastebin.com/s57ivD3j

commented

@Exaxxion any idea?

commented

As far as I can tell, it sounds like the same cause and same result on the latest version. The code is making an unsafe assumption about the type of object it is receiving and is making an invalid class cast.

commented

Surely EntityPlayerSP, can exist on the logical server (where world.isRemote is false) when the player is in singleplayer?

commented

You may be right, it seems EntityPlayerSP is misnamed and actually just a client class. I don't see how isRemote could have gone wrong, given that it's final by default, and no mod would have reason to AT it, but you never know. However, given that you are casting, it would make more sense to do an instanceof check.

Also, including a buildscript in the repository would be nice.

commented

If world.isRemote = true stands for client side. I don't think there is anything wrong in my code. For some reason the world the player is currently in has a falsely set isRemote value. All players in a server world should be EntityPlayerMP.

commented

Sorry for not responding earlier, I have been quite busy. The problem is that if I do a instanceof check it will crash on the server. Still no idea how this issue could occur :( it must be caused by another mod, a singleplayer playerentity cannot be part of a server world.

commented
		if (!(player instanceof EntityPlayerMP))
			return getGameTypeClient(player);
		return ((EntityPlayerMP) player).interactionManager.getGameType();

?
or better, the other way around

		if (player instanceof EntityPlayerMP)
                        return ((EntityPlayerMP) player).interactionManager.getGameType();
	        return getGameTypeClient(player);
commented

Oh right, haven't thought about that. Thanks for the help. I will try to release it the next days (have to make sure it's stable enough first).

commented

New version is finally released. Really hope the issue is solved not, otherwise I will reopen the issue.

commented

Looks like the world of the player is somehow not remote:

	public static GameType getGameType(EntityPlayer player) {
		if (player.world.isRemote)
			return getGameTypeClient(player);
		return ((EntityPlayerMP) player).interactionManager.getGameType();
	}

In theory this should work, I could also do a cast check, but normally the player entity on the client should always be in a remote world.

commented

@Exaxxion any news?

commented

I'm not the player originally experiencing this problem: @profuseduck is. I escalated this to your tracker because it's a bug I figured you'd want to know about.

I have not personally encountered this error so I don't know what I could update you on.

commented

I too experienced this crash while playing OmniFactory. I have uploaded the full crash here: https://pastebin.com/Ur1ww8f2

commented

@ebmusicman84 Maybe update CreativeCore and LittleTiles? Would be curious if it still happens in the newest version.

commented

I'm facing this issue with FTB Interactions, the pack hasn't been updated on FTB for a long time and it's using LittleTiles_v1.5.0-pre199_34_mc1.12.2.jar and CreativeCore_v1.10.16_mc1.12.2.jar.

From an earlier issue I learned that AR uses

WorldDummy (where the client is temporarily when they open rocket-contained inventories so they can access them)

(see: Advanced-Rocketry/AdvancedRocketry#2028); maybe this explains why isRemote returns something other than expected.

Can someone let me know which version of CreativeCore was the release mentioned here? Sadly CurseForge doesn't go back beyond Sep 30, 2020; I'd like to prevent updating too far in case it causes conflicts with other outdated mods.

If we update to CreativeCore_v1.10.27_mc1.12.2.jar, can we continue to use LittleTiles_v1.5.0-pre199_34_mc1.12.2.jar or should we update that too?

commented

You can view all versions, just click on the button "view all", yes it's a bit weird unfortunately.
This version of LittleTiles is already quite old ... I would recommend to update to the newest versions.

commented

It's a big pack on a server, ideally the less change we do the better; I don't want to create a cascade of mods that need to get updated. I hadn't noticed "view all" - thanks :)

We'll try CreativeCore_v1.10.20_mc1.12.2.jar and LittleTiles_v1.5.0-pre199_44_mc1.12.2.jar (both from Sept. 1st 2020); hopefully these will be compatible.

Thanks for the reply.

commented

Can confirm that with CreativeCore_v1.10.20_mc1.12.2.jar the issue is resolved.