package hmggirlfront.block.tile;
 
import java.util.List;

import hmggirlfront.mod_GirlFront;
import hmggirlfront.block.BaseBuilding;
import hmggirlfront.block.Block_HelpBuildingBase;
import hmggirlfront.entity.mob.EntityIBC01;
import hmggirlfront.network.GFClientMessageKeyPressed;
import hmggirlfront.network.GFPacketHandler;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
 
public class TileEntityHelpBuildingBase extends TileEntity implements ITickable
{
	public int id = 0;
    
	public boolean canbuilding = false;
	
	public int time = 400;
	
	public String txt;
	public int sizex = 16;
	public int sizez = 16;
	public int sizey = 16;
	public int offsety = 0;
	public boolean setair = false;
	public boolean setbed = false;
	
	@SideOnly(Side.CLIENT)
    public double getMaxRenderDistanceSquared()
    {
        return 65536.0D;
    }
	
    @Override
	public void update() {
    	Block block = this.world.getBlockState(this.pos).getBlock();
        
        int x = this.pos.getX();
        int y= this.pos.getY();
        int z = this.pos.getZ();
        if(block instanceof Block_HelpBuildingBase) {
        	Block_HelpBuildingBase building = (Block_HelpBuildingBase) block;
        	sizex = building.sizex;
        	sizey = building.sizey;
        	sizez = building.sizez;
        	offsety = building.offsety;
        	
        	 if(canbuilding &&  !this.world.isRemote) {
             	if(time == 400) {
             		if(FMLCommonHandler.instance().getMinecraftServerInstance() != null) {
         				for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers())
         	            {
         					player.sendMessage(new TextComponentTranslation("Start building...", new Object[0]));
         					player.sendMessage(new TextComponentTranslation("Please wait for 20 seconds...", new Object[0]));
         					player.sendMessage(new TextComponentTranslation("Stay away from the block!!!", new Object[0]));
         	            }
                     }
             	}
             	--time;
             	if(time <= 100) {
             		if(FMLCommonHandler.instance().getMinecraftServerInstance() != null) {
         				for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers())
         	            {
         					if(time == 100)player.sendMessage(new TextComponentTranslation("5", new Object[0]));
         					if(time == 80)player.sendMessage(new TextComponentTranslation("4", new Object[0]));
         					if(time == 60)player.sendMessage(new TextComponentTranslation("3", new Object[0]));
         					if(time == 40)player.sendMessage(new TextComponentTranslation("2", new Object[0]));
         					if(time == 20)player.sendMessage(new TextComponentTranslation("1", new Object[0]));
         	            }
                     }
             	}
             	if(time == 0) {
             		if(FMLCommonHandler.instance().getMinecraftServerInstance() != null) {
         				for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers())
         	            {
         					player.sendMessage(new TextComponentTranslation("Pay attention to the load...", new Object[0]));
         	            }
                     }
             	}
             	if(time <= 0) {
             		building.Building(this.world, pos, this.world.getBlockState(this.pos));
             	}
             }
        }
        
       
        
        
        
	}
	
    
    
    
}