Posted July 28, 201411 yr I am remaking an old mod and I cannot figure out how to update this piece of code: public Packet getAuxillaryInfoPacket() { ByteArrayOutputStream var1 = new ByteArrayOutputStream(); DataOutputStream var2 = new DataOutputStream(var1); try { var2.writeByte(0); var2.writeInt(this.xCoord); var2.writeShort(this.yCoord); var2.writeInt(this.zCoord); for (int var3 = 0; var3 < 2; ++var3) { Packet.writeItemStack(this.switchBlocks[var3], var2); } var2.writeByte((byte)(this.switchBlockDirection | (this.editState ? 16 : 0))); var2.writeByte((byte)(this.lightLevel | (this.isLightMinimum ? 16 : 0) | (this.switchSound ? 32 : 0))); byte[] var5 = var1.toByteArray(); var2.close(); return new Packet250CustomPayload("SecretSwitches", var5); } catch (IOException var4) { var4.printStackTrace(); return null; } }
July 28, 201411 yr If that is for a TileEntity, then use the getDescriptionPacket method instead, and onDataPacket for receiving the packet; otherwise, I suggest you search around here for tutorials on SimpleNetworkWrapper or look at other implementations of Packet systems that you could adapt to your needs. http://i.imgur.com/NdrFdld.png[/img]
July 28, 201411 yr Author Which custompayload packet do I use? S3FPacketCustomPayload or S3FPacketCustomPayload. Also what do I change this line too? Packet.writeItemStack(this.switchBlocks[var3], var2); Sorry for being a nuisance, I am not very good with handling packets.
July 28, 201411 yr Author Here is a link to the class if it is needed. https://github.com/LogicTechCorp/SecretSwitch/blob/master/src/main/java/com/logictechcorp/secretswitch/tileentity/TileEntitySecretSwitch.java
July 28, 201411 yr First, forget about all that try/catch and the DataIn/OutputStreams - that whole paradigm is not really used anymore. Please search for updated packet tutorials like I mentioned earlier. EDIT: Just to be clear, I don't mean that try/catch is no longer used at all, I mean specifically in this context it is not needed anymore. For this particular case, you don't even need custom packets; use S35PacketUpdateTileEntity, which needs an NBTTagCompound - easy way is to just call your te's writeToNBT method and send that, but it's better to only send the data you need (i.e. write whatever you need to an NBTTagCompound, which you then send). http://i.imgur.com/NdrFdld.png[/img]
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.