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

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;
        }
    }

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.

  • 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.

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).

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.