Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So I am making a mod for Minecraft 1.6.4 running Forge #965 and i encountered the following problem:

In my Gui class im sending packets to the server to save changed settings. I've tested it and it ONLY sends 1 packet, but my packethandler receives always 2 packets. The 2 received packets seem to have the excact same data and all the values of the variables are the same. I think it automatically sends 2 packets to ensure that atleast 1 arrives, but how can I detect which packets are unneeded, cause the first ones arrived? Please help! :/

 

PacketHandlerASI.java:

<code>

@Override

public void onPacketData(INetworkManager parNetwordManager, Packet250CustomPayload parPacket, Player parPlayer) {

if(parPacket.channel != PACKET_CHANNEL) return;

EntityPlayer player = (EntityPlayer)parPlayer;

boolean isClient = player.worldObj.isRemote;

 

DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(parPacket.data));

try {

byte packetID = inputStream.readByte();

if(packetID == PACKET_ID.OBJECTSORTER_GUI_SET.ID) {

handlePacketObjectSorterGuiSet(parNetwordManager, parPacket, parPlayer, player, inputStream, isClient);

}

else if(packetID == PACKET_ID.OBJECTSORTER_REQUEST.ID) {

handlePacketObjectSorterRequest(parNetwordManager, parPacket, parPlayer, player, inputStream, isClient);

}

}

catch(Exception e) {

e.printStackTrace();

System.err.println("An exception occured while processing the packet!");

}

}

</code>

 

GuiObjectSorter.java:

<code>

public void sendRequestToServer(int parType, int parSide) {

Packet250CustomPayload packet = new Packet250CustomPayload();

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

DataOutputStream packetOutput = new DataOutputStream(byteArrayOutputStream);

 

try {

packetOutput.writeByte(PacketHandlerASI.PACKET_ID.OBJECTSORTER_REQUEST.ID);

packetOutput.writeInt(tileEntity.xCoord);

packetOutput.writeInt(tileEntity.yCoord);

packetOutput.writeInt(tileEntity.zCoord);

packetOutput.writeByte((byte)((parType & 0xf) | ((parSide << 4) & 0xf0)));

}

catch(IOException e) {

e.printStackTrace();

}

 

packet.channel = PacketHandlerASI.PACKET_CHANNEL;

packet.data = byteArrayOutputStream.toByteArray();

packet.length = packet.data.length;

 

System.out.println("GuiObjectSorter.actionPerformed() > Sent packet to server!");

PacketDispatcher.sendPacketToServer(packet);

}

</code>

I don't have the answer to your question, but please update to 1.7.

Packet Handling is much simpler!

  • Author

I cant because im making an addon for ComputerCraft for the FTB Monster Pack which is 1.6.4

Update to 1.7.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.