Posted February 10, 201510 yr Hi all! I have creature entity. When player interacts with it then it gets and holds player entity. @Override public boolean interact(EntityPlayer playerEnt) { this.playerEnt = playerEnt; } When entity writes nbt it saves player UUID to nbt. @Override public void writeEntityToNBT(NBTTagCompound var1) { super.writeEntityToNBT(var1); var1.setString("playerId", playerEnt.getGameProfile().getId().toString()); } And when it reading nbt, it also reads a player UUID and tries to get player entity from UUID @Override public void readEntityFromNBT(NBTTagCompound var1) { super.readEntityFromNBT(var1); playerEnt = this.worldObj.func_152378_a(UUID.fromString(var1.getString("playerId"))); } My problem is that after save and load 'playerEnt' always is null Where I made a mistake?
February 10, 201510 yr Author Thanks for that, but maybe I can get a small example, how to do what If I not disturbing you.
February 10, 201510 yr And just so you know what exactly is a WeakReference, here is the Java Documentation for it: http://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html and an article about it https://weblogs.java.net/blog/2006/05/04/understanding-weak-references TL;DR: Garbage Collector Friendly Object I require Java, both the coffee and the code
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.