Kloonder Posted August 8, 2015 Posted August 8, 2015 I used this tutorial from CoolAlias, taht one with the Extended Player Properties, but it seems like the event is fired, but it doesn't save the NBT, and I can't figure out why public class PlayerProperties implements IExtendedEntityProperties { public final static String EXT_PROP_NAME = "IntektorsProperties"; private final EntityPlayer player; public int researchState; public PlayerProperties(EntityPlayer player) { this.player = player; } public static final void register(EntityPlayer player) { player.registerExtendedProperties(PlayerProperties.EXT_PROP_NAME, new PlayerProperties(player)); } public static final PlayerProperties get(EntityPlayer player) { return (PlayerProperties) player.getExtendedProperties(EXT_PROP_NAME); } @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.getInteger("Research"); compound.setTag(EXT_PROP_NAME, properties); } @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.researchState = properties.getInteger("Research"); } @Override public void init(Entity entity, World world) { } } The event is fireds, I checked this, but it creates the Properties every time again @SubscribeEvent public void onEntityContructionEvent(EntityConstructing event){ if(event.entity instanceof EntityPlayer && PlayerProperties.get((EntityPlayer) event.entity) == null){ PlayerProperties.register((EntityPlayer) event.entity); } } Quote Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
Ernio Posted August 8, 2015 Posted August 8, 2015 @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.getInteger("Research"); compound.setTag(EXT_PROP_NAME, properties); } @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.researchState = properties.getInteger("Research"); } } properties.getInteger("Research"); VVV properties.setInteger("Research", this.researchState); Quote 1.7.10 is no longer supported by forge, you are on your own.
Kloonder Posted August 8, 2015 Author Posted August 8, 2015 What exactly makes you think it is not saved? How do you check it? Also how is "researchState modified? First of all, this line of code PlayerProperties.get((EntityPlayer) event.entity) == null should make sure to only create a new instance of the properties, if there isn't already one, shouldn't it? Also, when I use my update method @Override public void updateEntity() { if(theUser != null){ finishedNBT.setBoolean(theUser.getDisplayName(), true); System.out.println(PlayerProperties.get(theUser).researchState + "" + FMLCommonHandler.instance().getEffectiveSide()); } } it prints 0 on both Client and Server, although PlayerProperties.get(theUser).researchState++; ModArmMod.network.sendToServer(new ClientToServerMessage(7, new int[]{tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord})); in my gui if(message.ID == 7){ TileEntityArmorModifier tileEntity = (TileEntityArmorModifier) ctx.getServerHandler().playerEntity.getEntityWorld().getTileEntity(message.extra[0], message.extra[1], message.extra[2]); PlayerProperties.get(tileEntity.theUser).researchState++; } and thats it Quote Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
Kloonder Posted August 8, 2015 Author Posted August 8, 2015 @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.getInteger("Research"); compound.setTag(EXT_PROP_NAME, properties); } @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.researchState = properties.getInteger("Research"); } } properties.getInteger("Research"); #setInteger thanks, but it won't cfhange anything if there is every time a new instance created Quote Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
Kloonder Posted August 8, 2015 Author Posted August 8, 2015 There is a new instance created when the player is created, there is nothing wrong with that. hm ok, but why the hell is it 0 then Quote Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
Recommended Posts
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.