package rocks.boltsandnuts.bbtweaks.command;

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import rocks.boltsandnuts.bbtweaks.items.ItemRegistry;

public class CommandBB extends CommandBase {

	private static final String NBTTagInt = null;


	@Override
	public String getCommandName() {
		return "bb";
	}

	@Override
	public String getCommandUsage(ICommandSender p_71518_1_) {

		return "/bb";
	}

	@Override
	public void processCommand(ICommandSender command, String[] p_71515_2_) {
		CommandBB.giveBreakBit(command);
		return;
	}

	
	public static void giveBreakBit(ICommandSender command){
			
		long time=0, curTime=0, last=0, timeUntil=0;
		String out;
		EntityPlayer e = command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName());
		NBTTagCompound tag = e.getEntityData();
		
		NBTBase modeTag = tag.getTag("lastBB");
		
		if (modeTag != null) {
			last =  ((NBTTagLong)modeTag).func_150291_c()/600000;
			}
		
		curTime = System.currentTimeMillis();
		time = curTime/600000;
		
		if ((time-last) < 24 && last != 0)
		{
			timeUntil = 24 - (time-last);
			out = "Try again in " + timeUntil + " Hours." + " result:" + (time-last);// + " Last: " + last + " Time: " + curTime;
			e.addChatMessage(new ChatComponentTranslation("You aren't eligible for another Breakbit yet."));
			e.addChatMessage(new ChatComponentTranslation(out));
			return;
		}
		
		ItemStack BB = new ItemStack(ItemRegistry.breakbit_invar);

		if (!e.inventory.addItemStackToInventory(BB)){
			e.addChatMessage(new ChatComponentTranslation("Not enough inventory Space."));
		}
		else{
			//out = "Try again in " + timeUntil + " Hours" + " result:" + (time/last) + " Last: " + last + " Time: " + time;
			//e.addChatMessage(new ChatComponentTranslation(out));
			e.addChatMessage(new ChatComponentTranslation("Granted your Daily Invar BreakBit!"));
			tag.setLong("lastBB", curTime);

		}
		

			
		return;
	}
	
}

@@ -39,16 +39,44 @@
 mmand;%0A%0A
+import java.util.Calendar;%0A%0A
 import n
@@ -1026,16 +1026,8 @@
 long
- time=0,
  cur
@@ -1034,16 +1034,17 @@
 Time=0, 
+L
 last=0, 
@@ -1056,16 +1056,36 @@
 ntil=0;%0A
+%09%09int time=0, last;%0A
 %09%09String
@@ -1231,16 +1231,53 @@
 Data();%0A
+%09%09Calendar c=Calendar.getInstance();%0A
 %09%09%0A%09%09NBT
@@ -1344,16 +1344,17 @@
 l) %7B%0A%09%09%09
+L
 last =  
@@ -1390,23 +1390,16 @@
 0291_c()
-/600000
 ;%0A%09%09%09%7D%0A%09
@@ -1446,29 +1446,176 @@
 ;%0A%09%09
-time = curTime/600000
+c.setTimeInMillis(curTime);%0A%09%09time=c.get(Calendar.HOUR);%0A%09%09c.setTimeInMillis(Llast);%0A%09%09last=c.get(Calendar.HOUR);%0A%09%09//out = %22TimeHours: %22 + time + %22 lasthours: %22 + last
 ;%0A%09%09
@@ -1737,16 +1737,19 @@
  Hours.%22
+;//
  + %22 res
@@ -1767,19 +1767,16 @@
 me-last)
-;//
  + %22 Las
@@ -1774,32 +1774,33 @@
 ) + %22 Last: %22 + 
+L
 last + %22 Time: %22

Switch to calendar object for bb