Everything posted by DuskFall
-
[1.7.2]Crash on player.addChatComponentMessage
I havent solved it, but i found a work around that suits me fine
-
[1.7.2]Crash on player.addChatComponentMessage
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)
-
[1.7.2]Crash on player.addChatComponentMessage
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_)); }
-
[1.7.2]Crash on player.addChatComponentMessage
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?
-
[1.7.2]Packet data not persisting
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); }
-
[1.7.2]Packet data not persisting
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)?
-
[1.7.2]Packet data not persisting
Oh... (facepalm) Nowhere in all the tutorials i found said that... Hmm, how would i go about that?
-
[1.7.2]Packet data not persisting
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?
-
[1.7.2]Unreported exception thrown in DataWatcher
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?
-
[1.7.2]Unreported exception thrown in DataWatcher
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?
-
[1.7.2]Unreported exception thrown in DataWatcher
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?
-
[1.7.2]Unreported exception thrown in DataWatcher
Will custom packets update as fast? Cos this needs to update at least once a second
-
[1.7.2]Synchronise float arrays between client and server
Resend the array, as in with packets? Cos i'll have to learn how to do that then
-
[1.7.2]Unreported exception thrown in DataWatcher
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)
-
[1.7.2]Synchronise float arrays between client and server
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?
-
Add a setBlockID(Block.nextIdAvailable()) sort of thing
Well, i did not know of either of those, thanks (What does 1.7 use instead then?)
-
Add a setBlockID(Block.nextIdAvailable()) sort of thing
Add some form of method that does that, because forge tracks the registered block IDs, so will know where there is a break. If waits until after the mod has declared all it's blocks/items, and then gives it an ID range that fits, for better use of the space there, because with lots of mods installed it becomes difficult to track.
-
[1.6.4]Overwrite GUI completely.
So i'm looking to overwrite the healthbar gui (well, remove the hearts and replace it with a number). How could i go around doing this? I was thinking the subscribing thing might work, but dont know.
IPS spam blocked by CleanTalk.