package com.gmail.nuclearcat1337.snitch_master.handlers;

import com.gmail.nuclearcat1337.snitch_master.SnitchMaster;
import com.gmail.nuclearcat1337.snitch_master.snitches.Snitch;
import com.gmail.nuclearcat1337.snitch_master.snitches.SnitchList;
import com.gmail.nuclearcat1337.snitch_master.util.Color;
import com.gmail.nuclearcat1337.snitch_master.util.Location;
import com.gmail.nuclearcat1337.snitch_master.util.PointLocation;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

/**
 * Created by Mr_Little_Kitty on 9/8/2016.
 * Handles misc events related to Snitches.
 */
public class SnitchListeners
{
    private final SnitchMaster snitchMaster;

    public SnitchListeners(SnitchMaster snitchMaster)
    {
        this.snitchMaster = snitchMaster;
    }

    /**
     * Event that handles when a Snitch is right clicked.
     */
    @SubscribeEvent
    public void onSnitchPlace(PlayerInteractEvent event)
    {
        if (event instanceof PlayerInteractEvent.RightClickBlock)
        {
            if (event.getItemStack() != null)
            {
                PlayerInteractEvent.RightClickBlock event1 = (PlayerInteractEvent.RightClickBlock) event;
                BlockPos pos = event1.getPos();
                if (pos != null)
                {
                    IBlockState state = event1.getWorld().getBlockState(pos);
//                    if (state.getBlock().equals(Blocks.SPONGE))
//                    {
//                        block = new Block(pos.getX(), pos.getY(), pos.getZ(), 10, new Color(0.86, 0.08, 0.24, 0.25));
//                    }
                    if (state.getBlock().equals(Blocks.JUKEBOX) || state.getBlock().equals(Blocks.NOTEBLOCK))
                    {
                        Location loc = new Location(pos.getX(),pos.getY(),pos.getZ(),snitchMaster.getCurrentWorld());
                        Snitch snitch = new Snitch(loc,"manual");

                        snitchMaster.submitSnitch(snitch);
                    }
                }
            }
        }
    }
}

@@ -1251,72 +1251,8 @@
   %7B%0A
-            if (event.getItemStack() != null)%0A            %7B%0A    
     
@@ -1361,20 +1361,16 @@
         
-    
 BlockPos
@@ -1401,28 +1401,24 @@
             
- 
-   
 if (pos != n
@@ -1430,32 +1430,26 @@
             
-    %7B%0A  
+%7B%0A
             
@@ -1452,18 +1452,16 @@
         
-  
 IBlockSt
@@ -1520,36 +1520,32 @@
                 
-    
 if (state.getBlo
@@ -1594,20 +1594,12 @@
     
-   
- 
 %7B%0A//
-    
     
@@ -1722,34 +1722,26 @@
             
-    %7D%0A    
+%7D%0A
             
@@ -1834,20 +1834,16 @@
 BLOCK))%0A
-    
         
@@ -1872,20 +1872,16 @@
         
-    
 Location
@@ -1986,20 +1986,16 @@
         
-    
 Snitch s
@@ -2049,20 +2049,16 @@
         
-    
 snitchMa
@@ -2088,30 +2088,8 @@
 h);%0A
-                    %7D%0A
     

allow adding snitches by right-clicking with empty hand