Posted February 4, 20178 yr 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 February 4, 20178 yr by TLHPoE Kain
February 4, 20178 yr 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
February 4, 20178 yr 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.