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 have itemstacks stored inside of the player's NBTTagCompound on the server side, but I want to render the items on the client side. As far as I know, the player's NBTTagCompound isn't synced automatically, so my issue is how to send the NBTTagCompound or ItemStacks to the client from the server.

 

I've tried looking online for solutions, but I only found articles regarding the old Packet system using CompressedStreamTools. I'm currently using the SimpleNetworkWrapper with classes implementing IMessage; is there anyway to input the ByteBuf as a stream object that can be used with CompressedStreamTools?

 

Another solution I tried was finding a way to compress an NBTTagCompound or a NonNullList into a byte array, but I haven't found any methods yet.

 

I'm not sure how to provide code for this, but here's how I'm storing the ItemStacks on the server:

 

        ...

        NBTTagCompound nbt = player.getEntityData();
        NBTTagCompound isNBT = nbt.getCompoundTag(QuickConsume.KEY);
        NonNullList<ItemStack> items = NonNullList.<ItemStack> withSize(3, ItemStack.EMPTY);
        ItemStackHelper.loadAllItems(isNBT, items);

        ...
        ItemStackHelper.saveAllItems(isNBT, items);
        nbt.setTag(QuickConsume.KEY, isNBT);

Edited by TLHPoE

Kain

  • Author
51 minutes ago, diesieben07 said:

First of all, stop using getEntityData. It has been replaced by  better system twice over already. First IExtendedEntityProperties, now capabilities.

Both allow you to actually store stuff attached to the player and don't force you to constantly serialize to and from NBT.

Ok, I've switched over to the capability system. Is there a way of synchronizing the capabilities with the client? It doesn't seem to at the moment.

Kain

  • Author
5 minutes ago, diesieben07 said:

You send packets.

I realize this, but in the fromBytes and toBytes methods, how do I convert the ItemStacks to bytes? I asked this question in the original post as well.

Kain

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.