Advertisement
mrkirby153

Untitled

Jan 31st, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. package me.mrkirby153.KCNerfer.playTime;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraft.nbt.NBTTagCompound;
  6. import net.minecraft.world.World;
  7. import net.minecraftforge.common.IExtendedEntityProperties;
  8.  
  9. public class PlayTimeData implements IExtendedEntityProperties {
  10.  
  11. public static final String EXT_RPOPERTY_NAME = "kc_PlayTime";
  12.  
  13. private final EntityPlayer player;
  14.  
  15. private double playedTicks;
  16.  
  17. public PlayTimeData(EntityPlayer player) {
  18. this.player = player;
  19. this.playedTicks = 0;
  20. }
  21.  
  22. public static void register(EntityPlayer player) {
  23. if (player.getExtendedProperties(EXT_RPOPERTY_NAME) == null)
  24. player.registerExtendedProperties(EXT_RPOPERTY_NAME, new PlayTimeData(player));
  25. }
  26.  
  27. public static PlayTimeData get(EntityPlayer player) {
  28. return (PlayTimeData) player.getExtendedProperties(EXT_RPOPERTY_NAME);
  29. }
  30.  
  31.  
  32. @Override
  33. public void saveNBTData(NBTTagCompound compound) {
  34. compound.setDouble("playTime", (this.playedTicks));
  35. }
  36.  
  37. @Override
  38. public void loadNBTData(NBTTagCompound compound) {
  39. playedTicks = compound.getDouble("playTime");
  40. }
  41.  
  42. @Override
  43. public void init(Entity entity, World world) {
  44.  
  45. }
  46.  
  47. public double getPlayedTicks() {
  48. return this.playedTicks;
  49. }
  50. public void update() {
  51. this.playedTicks += 1;
  52. System.out.println(this.player.getCommandSenderName() + " has played for " + this.playedTicks);
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement