Jump to content

Recommended Posts

Posted

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)

Posted

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?

Posted

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?

Posted

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.

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.

×
×
  • Create New...

Important Information

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