Jump to content

[1.11] EntityJoinedWorldEvent Ticking memory connection


Recommended Posts

Posted

Hey there,

 

I'm trying to sync a value when the player joins the game, however, using

EntityJoinedWorldEvent

seems to cause this on join:

// Why did you do that?

Time: 12/11/16 11:03 AM
Description: Ticking memory connection

java.lang.NullPointerException: Ticking memory connection
at com.lambda.plentifulmisc.magic.hud.ManaEvent.EntityJoinedWorldEvent(ManaEvent.java:60)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_ManaEvent_EntityJoinedWorldEvent_EntityJoinWorldEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
at net.minecraft.world.World.spawnEntityInWorld(World.java:1291)
at net.minecraft.world.WorldServer.spawnEntityInWorld(WorldServer.java:1124)
at net.minecraft.server.management.PlayerList.playerLoggedIn(PlayerList.java:386)
at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:169)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.completeServerSideConnection(NetworkDispatcher.java:265)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.access$100(NetworkDispatcher.java:73)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:214)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308)
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:817)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547)
at java.lang.Thread.run(Thread.java:745)


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

-- Head --
Thread: Client thread
Stacktrace:
at com.lambda.plentifulmisc.magic.hud.ManaEvent.EntityJoinedWorldEvent(ManaEvent.java:60)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_ManaEvent_EntityJoinedWorldEvent_EntityJoinWorldEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
at net.minecraft.world.World.spawnEntityInWorld(World.java:1291)
at net.minecraft.world.WorldServer.spawnEntityInWorld(WorldServer.java:1124)
at net.minecraft.server.management.PlayerList.playerLoggedIn(PlayerList.java:386)
at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:169)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.completeServerSideConnection(NetworkDispatcher.java:265)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.access$100(NetworkDispatcher.java:73)
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:214)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308)

-- Ticking connection --
Details:
Connection: net.minecraft.network.NetworkManager@4f6404d0
Stacktrace:
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:817)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547)
at java.lang.Thread.run(Thread.java:745)

 

Here is the event:

    @SubscribeEvent
    public static void EntityJoinedWorldEvent(EntityJoinWorldEvent event) {
        Minecraft mc = Minecraft.getMinecraft();
        if(event.getEntity() instanceof EntityPlayer) {
            if (mc.thePlayer.hasCapability(CapabilityMagic.MANA, null)) {
                CapabilityManaData cap = mc.thePlayer.getCapability(CapabilityMagic.MANA, null);
                if (!event.isCancelable()) {
                    PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(cap.getManaStored()), (EntityPlayerMP) cap.getEntity());
                }
            }
        }
    }

 

Thanks,

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

Why are you checking event.isCancelable() at all?

 

That said, why are you using Minecraft mc = Minecraft.getMinecraft(); on the server?  And why are you getting the player from the client side class rather than from the event? You check event.getEntity() to see if it's a player...

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.

Posted

Seriously?

 

if(event.getEntity() instanceof EntityPlayer) {
    EntityPlayer player = (EntityPlayer)event.getEntity();
}

 

Fuck.

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.

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.