public void tickEnd(EntityPlayer player)
{
if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter)
{
ItemPortableTeleporter item = (ItemPortableTeleporter)player.getCurrentEquippedItem().getItem();
ItemStack itemstack = player.getCurrentEquippedItem();
Teleporter.Code teleCode = new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3));
if(Mekanism.teleporters.containsKey(teleCode))
{
if(Mekanism.teleporters.get(teleCode).size() > 0 && Mekanism.teleporters.get(teleCode).size() <= 2)
{
int energyNeeded = item.calculateEnergyCost(player, MekanismUtils.getClosestCoords(teleCode, player));
if(item.getEnergy(itemstack) < energyNeeded)
{
if(item.getStatus(itemstack) != 2)
{
item.setStatus(itemstack, 2);
Mekanism.packetHandler.sendTo(new StatusUpdateMessage(2), (EntityPlayerMP)player);
}
}
else {
if(item.getStatus(itemstack) != 1)
{
item.setStatus(itemstack, 1);
Mekanism.packetHandler.sendTo(new StatusUpdateMessage(1), (EntityPlayerMP)player);
}
}
}
else if(Mekanism.teleporters.get(teleCode).size() > 2)
{
if(item.getStatus(itemstack) != 3)
{
item.setStatus(itemstack, 3);
Mekanism.packetHandler.sendTo(new StatusUpdateMessage(3), (EntityPlayerMP)player);
}
}
else {
if(item.getStatus(itemstack) != 4)
{
item.setStatus(itemstack, 4);
Mekanism.packetHandler.sendTo(new StatusUpdateMessage(4), (EntityPlayerMP)player);
}
}
}
else {
if(item.getStatus(itemstack) != 4)
{
item.setStatus(itemstack, 4);
Mekanism.packetHandler.sendTo(new StatusUpdateMessage(4), (EntityPlayerMP)player);
}
}
}