Advertisement
MightyDanp

Untitled

Jul 15th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. package com.mightydanp.eot.core.entities.player;
  2.  
  3. import java.lang.ref.WeakReference;
  4.  
  5. import com.mightydanp.eot.core.gui.inventory.EotInventory;
  6. import com.mightydanp.eot.lib.References;
  7.  
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.entity.player.EntityPlayer;
  10. import net.minecraft.nbt.NBTTagCompound;
  11. import net.minecraft.world.World;
  12. import net.minecraftforge.common.IExtendedEntityProperties;
  13.  
  14. public class EotPlayerStats implements IExtendedEntityProperties
  15. {
  16. public final static String EXT_PROP_NAME = "ExtendedPlayer";
  17.  
  18. public final EotInventory inventory = new EotInventory();
  19.  
  20. private final EntityPlayer player;
  21.  
  22. public EotPlayerStats(EntityPlayer player) {
  23. this.player = player;
  24. }
  25.  
  26. /**
  27. * Used to register these extended properties for the player during EntityConstructing event
  28. */
  29. public static final void register(EntityPlayer player) {
  30. player.registerExtendedProperties(EotPlayerStats.EXT_PROP_NAME, new EotPlayerStats(player));
  31. }
  32.  
  33. /**
  34. * Returns ExtendedPlayer properties for player
  35. */
  36. public static final EotPlayerStats get(EntityPlayer player) {
  37. return (EotPlayerStats) player.getExtendedProperties(EXT_PROP_NAME);
  38. }
  39.  
  40. /**
  41. * Copies additional player data from the given ExtendedPlayer instance
  42. * Avoids NBT disk I/O overhead when cloning a player after respawn
  43. */
  44. public void copy(EotPlayerStats props) {}
  45.  
  46. @Override
  47. public final void saveNBTData(NBTTagCompound compound) {
  48. NBTTagCompound properties = new NBTTagCompound();
  49. compound.setTag(EXT_PROP_NAME, properties);
  50. this.inventory.writeToNBT(properties);
  51. }
  52.  
  53. @Override
  54. public final void loadNBTData(NBTTagCompound compound) {
  55. NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
  56. this.inventory.readFromNBT(properties);
  57. }
  58.  
  59. @Override
  60. public void init(Entity entity, World world) {}
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement