package com.InfinityRaider.AgriCraft.compatibility.waila;

import com.InfinityRaider.AgriCraft.blocks.BlockCrop;
import com.InfinityRaider.AgriCraft.init.Items;
import com.InfinityRaider.AgriCraft.tileentity.TileEntityCrop;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.block.Block;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.StatCollector;

import java.util.List;

public class AgriCraftCropDataProvider implements IWailaDataProvider {

    @Override
    public ItemStack getWailaStack(IWailaDataAccessor dataAccessor, IWailaConfigHandler configHandler) {
        Block block = dataAccessor.getBlock();
        if(block instanceof BlockCrop) {
            return new ItemStack(Items.crops, 1, 0);
        }
        return null;
    }

    @Override
    public List<String> getWailaHead(ItemStack itemStack, List<String> list, IWailaDataAccessor dataAccessor, IWailaConfigHandler configHandler) {
        return list;
    }

    @Override
    public List<String> getWailaBody(ItemStack itemStack, List<String> list, IWailaDataAccessor dataAccessor, IWailaConfigHandler configHandler) {
        Block block = dataAccessor.getBlock();
        TileEntity te = dataAccessor.getTileEntity();
        if(block!=null && block instanceof BlockCrop && te!=null && te instanceof TileEntityCrop) {
            TileEntityCrop crop = (TileEntityCrop) te;
            int growth = crop.growth;
            int gain = crop.gain;
            int strength = crop.strength;
            String seedName = ((ItemSeeds) crop.seed).getItemStackDisplayName(new ItemStack((ItemSeeds) crop.seed, 1, crop.seedMeta));
            list.add(StatCollector.translateToLocal("agricraft_tooltip.seed")+": "+seedName);
            list.add(" - "+ StatCollector.translateToLocal("agricraft_tooltip.growth")+": "+growth);
            list.add(" - "+ StatCollector.translateToLocal("agricraft_tooltip.gain")+": "+gain);
            list.add(" - "+ StatCollector.translateToLocal("agricraft_tooltip.strength")+": "+strength);
        }
        return list;
    }

    @Override
    public List<String> getWailaTail(ItemStack itemStack, List<String> list, IWailaDataAccessor dataAccessor, IWailaConfigHandler configHandler) {
        return list;
    }
}

@@ -1556,16 +1556,54 @@
 op) te;%0A
+            if(crop.hasPlant()) %7B%0A    
         
@@ -1640,24 +1640,28 @@
             
+    
 int gain = c
@@ -1670,16 +1670,20 @@
 p.gain;%0A
+    
         
@@ -1712,24 +1712,28 @@
 p.strength;%0A
+    
             
@@ -1859,32 +1859,36 @@
 ));%0A            
+    
 list.add(StatCol
@@ -1936,22 +1936,26 @@
 p.seed%22)
-+
+ + 
 %22: %22
-+
+ + 
 seedName
@@ -1957,16 +1957,20 @@
 dName);%0A
+    
         
@@ -1979,32 +1979,33 @@
   list.add(%22 - %22
+ 
 + StatCollector.
@@ -2048,22 +2048,26 @@
 growth%22)
-+
+ + 
 %22: %22
-+
+ + 
 growth);
@@ -2063,24 +2063,28 @@
  + growth);%0A
+    
             
@@ -2089,32 +2089,33 @@
   list.add(%22 - %22
+ 
 + StatCollector.
@@ -2160,21 +2160,29 @@
 in%22)
-+
+ + 
 %22: %22
-+
+ + 
 gain);%0A
+    
     
@@ -2203,16 +2203,17 @@
 dd(%22 - %22
+ 
 + StatCo
@@ -2270,14 +2270,18 @@
 th%22)
-+
+ + 
 %22: %22
-+
+ + 
 stre
@@ -2283,24 +2283,38 @@
  strength);%0A
+            %7D%0A
         %7D%0A  

fix Waila error