Jump to content

DuskFall

Members
  • Posts

    19
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

DuskFall's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I havent solved it, but i found a work around that suits me fine
  2. I call sendChatToPlayer(EntityPlayer player, String message) in er, almost everywhere, but the problem is in my "setSkill" method in my ExtendedEntityProperties. The method is : public void setSkill(Skill lookup, int i, EntityPlayer player) { Side side = FMLCommonHandler.instance().getEffectiveSide(); RSLogging.log(this.getClass(), "Increasing level"); if (side == Side.CLIENT) { RSLogging.log(this.getClass(), "So not doing anything"); } else { this.SkillAmounts[lookup.ordinal()] = i; this.ExpAmounts[lookup.ordinal()] = this.limits[i - 1]; RSChatMessageHandler.sendChatToPlayer(player, "Congratulations, you are now " + this.getSkill(lookup) +" " + lookup.name().toLowerCase()); } } (RSLogging.log takes the class and a message, and prints the class, effective side and message)
  3. I personally wasnt calling that, the player.addChatComponentMessage(new ChatComponentText(message)) calls it. As in, the function addChatComponentMessage is as follows : public void addChatComponentMessage(IChatComponent p_146105_1_) { this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_)); }
  4. So for some reason, i'm getting a npe in in my sendChatToPlayer function, but it was working previously. Here's all it is : public static void sendChatToPlayer(EntityPlayer player, String message) { player.addChatComponentMessage(new ChatComponentText(message)); } And the stacktrace is : Caused by: java.lang.NullPointerException at net.minecraft.entity.player.EntityPlayerMP.addChatComponentMessage(EntityPlayerMP.java:987) ~[EntityPlayerMP.class:?] at mymod.util.ChatMessageHandler.sendChatToPlayer(ChatMessageHandler.java:33) ~[ChatMessageHandler.class:?] The line it fails at is : this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_)); in the EntityPlayerMP class in the net.minecraft.blah.blah bit. Whats going wrong?
  5. I solved it now, but was away when i was doing it so couldnt update you all. Here's how it works for me : @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { RSLogging.log(this.getClass(), "Encoding Exp " + ExpAmount + " " + SkillAmount + " for " + theSkill.ordinal()); buffer.writeInt(ExpAmount); buffer.writeInt(SkillAmount); buffer.writeInt(theSkill.ordinal()); } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { this.ExpAmount = buffer.readInt(); this.SkillAmount = buffer.readInt(); this.theSkill = Skill.getValue(buffer.readInt()); Me.log(this.getClass(), "Decoding : Exp " + ExpAmount + " " + SkillAmount + " for " + theSkill); }
  6. You sir, are a life saver. Have all the upvotes/highfives/whatevers. Well, now what do i do with : readerIndex(4) + length(4) exceeds writerIndex(4)?
  7. Oh... (facepalm) Nowhere in all the tutorials i found said that... Hmm, how would i go about that?
  8. So i'm trying to synchronise these arrays between the client and server, except i cant even get an int to sync using packets (must be packets, not datawatcher). Here's my packet class : (Seriously, is there a problem with macs and that damn code button?) package mine.packethandling; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import mine.player.PlayerSkills; import mine.player.PlayerSkills.Skill; import mine.util.Me; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; public class PacketSyncProps extends AbstractPacket { int times; public PacketSyncProps(){} public PacketSyncProps(int times) { Me.log(this.getClass(),"When created, times = " + times); this.times = times; } @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { } @Override public void handleClientSide(EntityPlayer player) { Me.log(this.getClass(), "Client side syncing player with sent data"); Me.log(this.getClass(), "Existing data : Times : " + this.times); } @Override public void handleServerSide(EntityPlayer player) { Me.log(this.getClass(), "Why was this sent to server?"); Me.log(this.getClass(), "Fish level pre death " + PlayerStats(player).getSkill(Skill.ONE)); PlayerStats(player).incrementSkill(Skill.ONE, player); } } And that packet is created server-side with : Me.packetPipeline.sendTo(new PacketSyncProps(12), (EntityPlayerMP) player); (The Me.log spits out the class, the effective side and then the message, and everything is happeneing on the right side) Why does this.times say 0 when i set it to 12?
  9. 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?
  10. 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?
  11. 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?
  12. Will custom packets update as fast? Cos this needs to update at least once a second
  13. Resend the array, as in with packets? Cos i'll have to learn how to do that then
  14. 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)
  15. Is it possible? At least one of the values in the array will update frequently and theres no way to tell which, so i looked into DataWatcher but i couldnt see how to get it to work. Is there something obvious i'm missing?
×
×
  • Create New...

Important Information

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