Posted March 13, 20205 yr I have a TE that stores a List, i'm using a ListNBT with CompoundNBT to store the block position and the list beloging to the TE, it works perfectly on client, but it does not load/save on server. This are probably the useful errors: Client Quote [Render thread/ERROR] [ne.mi.fm.ne.si.IndexedMessageCodec/SIMPLENET]: Received empty payload on channel fml:handshake [Netty Client IO #0/ERROR] [minecraft/ArgumentTypes]: Could not deserialize minecraft: [Netty Client IO #0/ERROR] [minecraft/ArgumentTypes]: Could not deserialize minecraft: Server: Quote [Netty Server IO #1/ERROR] [minecraft/ArgumentTypes]: Could not serialize net.minecraftforge.server.command.ModIdArgument@37225730 (class net.minecraftforge.server.command.ModIdArgument) - will not be sent to client! [Netty Server IO #1/ERROR] [minecraft/ArgumentTypes]: Could not serialize net.minecraftforge.server.command.EnumArgument@1d34fe74 (class net.minecraftforge.server.command.EnumArgument) - will not be sent to client! And this is the write/read functions: Quote @Nonnull @Override public CompoundNBT write(CompoundNBT compound) { ListNBT mList = new ListNBT(); Map<BlockPos, Set<ResourceLocation>> mPos = SMBlock.getMap(); if (mPos != null) { mPos.forEach((pos, rec) -> { if (rec.size() > 0) { CompoundNBT map = new CompoundNBT(); map.putString(pos.toString(), rec.toString()); mList.add(map); } }); } compound.put("mComp", mList); return super.write(compound); } @Override public void read(CompoundNBT compound) { Set<ResourceLocation> mPos = new HashSet<>(); ListNBT mList = compound.getList("mComp", 10); for (int i = 0; i < mList.size(); i++) { CompoundNBT mCompound = mList.getCompound(i); BlockPos position = getPosition(mCompound.keySet().toString()); String sArray = mCompound.getString(position.toString()); if (SMBlock.getPositions().contains(position)) return; SMBlock.setPosition(position); if (!sArray.equals("")) { for (String s : sArray.split(", ")) { sList.add(new ResourceLocation(s.replaceAll("]\\[", ""))); } } SMBlock.setMap(position, rec); sArray.clear(); } super.read(compound); } Obviously i am missing something, can anyone help me?
March 14, 20205 yr Howdy The only thing that leaps out at me on your existing code - try putting your calls to super as the first statement in your method (might not help but worth a try) eg public CompoundNBT write(CompoundNBT compound) { super.write(compound); ListNBT mList = new ListNBT(); Map<BlockPos, Set<ResourceLocation>> mPos = SMBlock.getMap(); if (mPos != null) { mPos.forEach((pos, rec) -> { if (rec.size() > 0) { CompoundNBT map = new CompoundNBT(); map.putString(pos.toString(), rec.toString()); mList.add(map); } }); } compound.put("mComp", mList); return compound; } Do you have the other sync methods defined properly? getUpdatePacket() and onDataPacket() -- for single TileEntity updates getUpdateTag() and handleUpdateTag() -- for sending as part of a chunk update packet eg see here https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe20_tileentity_data and here https://mcforge.readthedocs.io/en/latest/tileentities/tileentity/ -TGG
March 14, 20205 yr Author Certainly i was missing getUpdatePacket() , but still it is not working, it seems that the server can't access to the list i am saving, i put a print in the write/read functions and it prints empty while the client prints correctly, i assume i have to use a custom network for this?
March 14, 20205 yr Hi No you shouldn't need to use a custom network, NBTList transmit fine just using vanilla. If you haven't already I'd suggest you use your debugger to step through what your code is doing, it should become more obvious then. BTW this also looks wrong: if (SMBlock.getPositions().contains(position)) return; Cheers TGG
March 15, 20205 yr Author I basically have a gui with buttons, if you press a button, its name is added to the list. The problem seems to be that the server can't access that list, or maybe it access a different one, so when the nbt is saved, the position is ok but the list is empty.
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.