Posted June 15, 201510 yr Here is a few questions that I dont quite understand: 1. How to IO tileEntity data on world IO? (Do I need to call read/write NBT at any position?) 2. TileEntities act strange when reloaded. It always execute client-side. Is this related to Question 1?
June 15, 201510 yr Read and write nbt is only for saving data, like when the game is shutting down. It gets called by Minecraft ,no need to do it manually. What exactly do you mean with acting strange? TE's execute on Server and client side
June 15, 201510 yr 1. ALWAYS post your code. 2. ALWAYS define exact problem and situation, not "are acting weird". 3. ITS GOOD TO write what you are after (exactly, not "if it's possible", but "what i want") (Trying to help in future ) As to problem - world calls NBT-saving automatically. Anything that has to be saved in TE, will be savedloaded if you put it in write/read NBT methods. As to why it's not saving? - When you want TileEntity to save, you need to mark it as "dirty" to inform world that chunk TE is in needs to be saved to disk. this.markDirty() in TE.class 1.7.10 is no longer supported by forge, you are on your own.
June 15, 201510 yr Author OK, I'll go clear this time: I want a TIleEntity that follows a block, and generates a counter per tick (or more). That TileEntity generates counters per ticks. Which is fine. When I load my world to see if it has any problems, it gave me this: java.lang.InstantiationException: com.wwy.mod.te.techno.TETechnoReplenisher Block class: http://pastebin.com/3rH3qXnh TE Class: http://pastebin.com/uipjaJ7U Interestingly, even the "heal and boost" ability does not activate, it still generates counters... EDIT: So, my objective is, when the counter (datum variable) reaches 1000, find a random player with lowest health, and then heal him ,and boost him.
June 15, 201510 yr Author OK, that Block instance is solved. BUT, problem is, updateEntity() does not go server-side after the world is reloaded... WorldObj#isRemote always return true after the world is reloaded.
June 15, 201510 yr Author a) But I need to acquire info from that specific tile entity. Do I use World#getTileEntity(Stuff) instead? b) No problem. I registered it.
June 15, 201510 yr Author Now, it is even more interesting: Block Class: http://pastebin.com/5jTBbcXt TE Class: http://pastebin.com/9jPebGpV Now, I have more amended parts. But, everytime I right click onto the block, It always say TileEntity#worldObj#isRemote is true, so, server never responded...?
June 15, 201510 yr Author Can anyone tell me what went wrong in the bottom of the TE class, when I am doing Nbt IO? I dont seem to b able to save any variable despite any changes!
June 16, 201510 yr Author Like, everything is reset when I rejoin world. "Datum" points get back to 0 instead of the value of the last load. EDIT: Now I got some debug outputs. It seems that NBT are read correctly, but somehow it is not properly processed in / into the TileENtity.
June 16, 201510 yr Try printing the datum field every time you changes the field. Then please post the console log with the value of datum field printed. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
June 16, 201510 yr Author Weird, man, server said I have more datum points, but client responded with less. http://pastebin.com/29nVSykc Do I need any kind of syncing?
June 16, 201510 yr Weird, man, server said I have more datum points, but client responded with less. http://pastebin.com/29nVSykc Do I need any kind of syncing? Ah that was the problem! As minecraft does not automatically sync your field, you should sync it yourself. @see TileEntity#onDataPacket(Receive) and TileEntity#getDescriptionPacket(Send) I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
June 16, 201510 yr Author Looks complicated.... Ah, can I call a method from the client TE to the Server TE through World class?
June 16, 201510 yr Author NetworkManager net, S35PacketUpdateTileEntity pkt I need help to understand these two arguments
June 16, 201510 yr Author NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("datum", this.datum); tag.setInteger("currentCooldown", this.currentCountdown); tag.setInteger("maxCountdown", this.maxCountdown); Alright. I have the code. And then? How to return a Packet in getDescriptionPacket?
June 16, 201510 yr Author It seems that that 'data' parameter can be anything? So, in onDataPacket i will be catching back that nbt again... What about that "NetworkManager net"? Anything related to IMessage? Do I need to check if getDescriptionPacket() is executed in server?
June 16, 201510 yr Author So,I guess the following meaningless function brings back that nbt and ends this topic right? ThatPacket#func_148857_g();
June 16, 201510 yr Author Yup. I bet the problem is solved thoroughly, I will take this as a template to build other TileEntities.
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.