package mod_ModernTech;

import mod_Rways.mod_Rways;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemPaintRollerColor extends Item{
    public ItemPaintRollerColor(int i, int t){
        super(i);
        paintcolor = t; //0 white, 1 red, 2 green, 3 blue
        maxStackSize = 1;
        setMaxDamage(64);
        this.setCreativeTab(CreativeTabs.tabTools);
    }
    @Override
	public String getTextureFile() {
		return "/resrources/mod_ModernTech/ModernTech.png";
	}
    @Override
    public boolean onItemUseFirst(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l){
    	int id = world.getBlockId(i, j, k);
    	int id2 = world.getBlockId(i, j+1, k);
    	if(world.isRemote){
    		return true;
    	}
    	System.out.println("Block ID: "+id);
    	if (id2==Block.waterStill.blockID || id2==Block.waterMoving.blockID){
    		itemstack.damageItem(65, entityplayer);
			entityplayer.dropItemWithOffset(mod_Rways.PaintRoller.shiftedIndex, 1, 1.0F);
    		return true;
    	}
    	if (id==mod_ModernTech.HorSiding.blockID || id==mod_ModernTech.VertSiding.blockID){
    		int md= world.getBlockMetadata(i, j, k);
    		if (md!=paintcolor){
    			world.setBlockMetadataWithNotify(i, j, k, paintcolor);
    			world.markBlocksDirty(i, j - 1, k, i, j, k);
    			if (itemstack.getItemDamage()==64)
    				entityplayer.dropItemWithOffset(mod_Rways.PaintRoller.shiftedIndex, 1, 1.0F);
    			itemstack.damageItem(1, entityplayer);
    			return true;
    		}
    	} 
    	return false;
    }
    @Override
    public boolean isFull3D(){
        return true;
    }
    public int paintcolor;
}
