Posted July 26, 20169 yr Hello i have object that is created when player joins world/server and i want to use it to create and sync variables per-player how i can make it save and how to sync it with server and with other clients?
July 26, 20169 yr Generally speaking: Packets. The real question is: Why are you creating an object to store player variables? Use Capabilities. 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.
July 26, 20169 yr Whole logic behind it: * EntityPlayer has Capability assigned. * Data is (on server) created fresh (1st join) or loaded from player's NBT (later joins). * Data is parsed into your "Object". * Use PlayerLoggedInEvent to send packet to player that will contain your serialized Object. * Client handles packet and deserializes it into "Object" on client and puts it in client's Capability of player. Points of interest: * Caps: http://mcforge.readthedocs.org/en/latest/datastorage/capabilities/ * Setting up Caps: https://github.com/MinecraftForge/MinecraftForge/tree/1.9/src/test/java/net/minecraftforge/test Note: One of them is NoBedTest. * Packets: http://www.minecraftforge.net/forum/index.php/topic,20135.0.html * In 1.8+: http://greyminecraftcoder.blogspot.com.au/2015/01/thread-safety-with-network-messages.html * Forge Events: @SubscribeEvent and registering (google). * PlayerLoggedInEvent * AttachCapabilityEvent.Entity (or similar name, lookL links before). * NBT de-/serialization (Capability storage). Other: This will take hours to write it well, and only if you know Java and had experience with some of it in past. 1.7.10 is no longer supported by forge, you are on your own.
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.