Posted February 27, 201411 yr 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)
February 27, 201411 yr Author Will custom packets update as fast? Cos this needs to update at least once a second
February 27, 201411 yr Author Right, thanks for the pointer, is there any easy way of doing that or will it involve a new packet class, and all that crap?
February 27, 201411 yr 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. http://i.imgur.com/NdrFdld.png[/img]
February 27, 201411 yr Author 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?
February 27, 201411 yr Yes, show us your packet class. Depending on the maximum size of your integers, you could store them as bytes and write it directly to the stream using buffer.writeBytes(byte[]), or you could convert your integers to a byte array instead. What about your packet class isn't working? http://i.imgur.com/NdrFdld.png[/img]
February 27, 201411 yr Author 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?
February 27, 201411 yr 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.