Jump to content

[1.7.2]Unreported exception thrown in DataWatcher


DuskFall

Recommended Posts

So i'm trying to synchronise an int array between the client and server using Strings as a medium : As in, convert to string, set to watch it, convert back from string to read and modify before re-convertin to string to sync again. However, i get the above error and nothing else.

Heres my code for to-ing and fro-ing between string and int array :

private String pack(int[] a)

{

return Arrays.toString(a);

}

 

private int[] unpack(String a)

{

String[] items = a.replaceAll("\\[", "").replaceAll("\\]", "").replaceAll(" ","").split(",");

int[] results = new int[items.length];

 

for (int i = 0; i < items.length; i++) {

    try {

        results = Integer.parseInt(items);

    } catch (NumberFormatException nfe) {

    System.out.println("Something wrongificated");

    };

}

return results;

}

 

And here's my error log :

Unreported exception thrown!

java.lang.NullPointerException

at net.minecraft.entity.DataWatcher.updateObject(DataWatcher.java:157) ~[DataWatcher.class:?]

at gielinorcraft.player.RSPlayerSkills.setSkill(RSPlayerSkills.java:170) ~[RSPlayerSkills.class:?]

at gielinorcraft.player.RSPlayerSkills.<init>(RSPlayerSkills.java:43) ~[RSPlayerSkills.class:?]

at gielinorcraft.player.RSPlayerSkills.register(RSPlayerSkills.java:72) ~[RSPlayerSkills.class:?]

at gielinorcraft.player.EventRegister.onEntityConstruct(EventRegister.java:36) ~[EventRegister.class:?]

at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_EventRegister_onEntityConstruct_EntityConstructing.invoke(.dynamic) ~[?:?]

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) ~[ASMEventHandler.class:?]

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) ~[EventBus.class:?]

at net.minecraft.entity.Entity.<init>(Entity.java:290) ~[Entity.class:?]

at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:203) ~[EntityLivingBase.class:?]

at net.minecraft.entity.player.EntityPlayer.<init>(EntityPlayer.java:198) ~[EntityPlayer.class:?]

at net.minecraft.client.entity.AbstractClientPlayer.<init>(AbstractClientPlayer.java:29) ~[AbstractClientPlayer.class:?]

at net.minecraft.client.entity.EntityPlayerSP.<init>(EntityPlayerSP.java:93) ~[EntityPlayerSP.class:?]

at net.minecraft.client.entity.EntityClientPlayerMP.<init>(EntityClientPlayerMP.java:68) ~[EntityClientPlayerMP.class:?]

at net.minecraft.client.multiplayer.PlayerControllerMP.func_147493_a(PlayerControllerMP.java:474) ~[PlayerControllerMP.class:?]

-Blah blah minecraft stuff-

 

Line 170 is this : player.getDataWatcher().updateObject(20, this.pack(ExpAmounts));

 

Whats wrong with what i've done?

(Code tags werent working when i clicked the button, apologies)

Link to comment
Share on other sites

Yes, this tutorial was very handy in getting me going: it provides everything you need including the entire framework for handling packets, all you have to do is add your own packets and then use the provided structure to send them. Everything is handled directly in the packets.

 

You can see some examples of it in action here.

Link to comment
Share on other sites

coolAlias, i followed your guide for syncing the ExtendedProperties between client and server, thats how i arrived at all this, i literally copied it onto mine except its not working for me. Should i put up the whole packet class for you guys to look at?

Link to comment
Share on other sites

I honestly cant remember now, i made some changes then had to go somewhere and just got back. My problem now, it seems, is that i cant send packets to EntityPlayer, and cant EntityClientPlayerMP to EntityPlayerMP. Should i just open a new thread and close this one seeing as it no longer bears any relevance?

Link to comment
Share on other sites

Will custom packets update as fast? Cos this needs to update at least once a second

 

Internally datawatchers use packets.  Ergo yes.

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.