Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.mrkirby153.KCNerfer.playTime;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.world.World;
- import net.minecraftforge.common.IExtendedEntityProperties;
- public class PlayTimeData implements IExtendedEntityProperties {
- public static final String EXT_RPOPERTY_NAME = "kc_PlayTime";
- private final EntityPlayer player;
- private double playedTicks;
- public PlayTimeData(EntityPlayer player) {
- this.player = player;
- this.playedTicks = 0;
- }
- public static void register(EntityPlayer player) {
- if (player.getExtendedProperties(EXT_RPOPERTY_NAME) == null)
- player.registerExtendedProperties(EXT_RPOPERTY_NAME, new PlayTimeData(player));
- }
- public static PlayTimeData get(EntityPlayer player) {
- return (PlayTimeData) player.getExtendedProperties(EXT_RPOPERTY_NAME);
- }
- @Override
- public void saveNBTData(NBTTagCompound compound) {
- compound.setDouble("playTime", (this.playedTicks));
- }
- @Override
- public void loadNBTData(NBTTagCompound compound) {
- playedTicks = compound.getDouble("playTime");
- }
- @Override
- public void init(Entity entity, World world) {
- }
- public double getPlayedTicks() {
- return this.playedTicks;
- }
- public void update() {
- this.playedTicks += 1;
- System.out.println(this.player.getCommandSenderName() + " has played for " + this.playedTicks);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement