Posted June 6, 201312 yr I'm not very good with nbt tags, so can someone tell me what I'm doing wrong. I'm trying to make my tile entity to store some values a liquid stack and an ItemStack. For testing reasons, I've omitted the liquidstack and itemstack. Here's the nbt stuff @Override public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); this.setType(data.getString("Type"), data.getInteger("Radius"), data.getInteger("Capacity")); } @Override public void writeToNBT(NBTTagCompound data) { super.writeToNBT(data); data.setDouble("energy", this.energy); data.setString("Type", this.type.getType()); data.setInteger("Radius", this.type.getRange()); data.setInteger("Capacity", this.type.getCapacity()); }
June 6, 201312 yr What error are you getting? BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 6, 201312 yr It's just not saving or loading, no error. It's because of a client-server disparity. You need to send a datapacket to all players with the information. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 6, 201312 yr Try adding something like this in your write to NBT data and wherever else you try to set NBT. if (stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); //insert NBT set thingies here } I know I had trouble whenever the stackTagCompound equaled null and I tried to read it the game would crash. I'm not sure if that's your problem, but it's worth a shot.
June 6, 201312 yr game would crash He is not having that problem and I know it is an unhelpful suggestion as the problem he is actually having I've dealt with before. The client can't load the data values from the save (because it's a client) but the server isn't sending the info because he hasn't told it to. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 7, 201312 yr So how exactly would you tell the server to send the info? "Thinking that coding is the nerdy IT guy at work rebooting your computer is like thinking that music is what happens when the piano tuner comes round." - Ed Rex
June 7, 201312 yr send packet? make PacketHandler and PacketTypeHandler.If you dont know how to make them,then go to EE GitHub and take them from it
June 7, 201312 yr it's even simpler than that, in my code i just do this: @Override public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { NBTTagCompound tag = pkt.customParam1; this.readFromNBT(tag); } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new Packet132TileEntityData(xCoord, yCoord, zCoord, 0, tag); } just put that into your TileEntity class, this gets called every time the block is marked for an update and automatically passes it from the server to the client. github
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.