package com.techern.minecraft.pathomania.events;

import com.techern.minecraft.pathomania.blocks.BlockPath;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.BlockGrass;
import net.minecraft.item.ItemSpade;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

/**
 * A class containing {@link net.minecraftforge.event.entity.player.PlayerEvent}s
 *
 * @since 0.0.1
 */
public class PathomaniaPlayerEvents {

    /**
     * Called when an {@link net.minecraft.entity.player.EntityPlayer} interacts with a {@link Block}
     *
     * @param event The {@link PlayerInteractEvent} being referenced
     * @since 0.0.1
     */
    @SubscribeEvent
    public void playerInteracting(PlayerInteractEvent event) {
        if (event.action.equals(PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)) {
            if (event.entityPlayer.getHeldItem().getItem() instanceof ItemSpade) {
                //TODO: Automatically generate a map of fallback blocks and what to change them to
                Block block = event.world.getBlockState(event.pos).getBlock();

                if (block instanceof BlockGrass) {
                    event.world.setBlockState(event.pos, BlockPath.GRASS_PATH.getDefaultState());
                } else if (block instanceof BlockDirt) {
                    event.world.setBlockState(event.pos, BlockPath.DIRT_PATH.getDefaultState());
                }
            }
        }
    }
}

@@ -950,24 +950,88 @@
 K_BLOCK)) %7B%0A
+            if (event.entityPlayer.getHeldItem() != null) %7B%0A    
             
@@ -1097,24 +1097,28 @@
 temSpade) %7B%0A
+    
             
@@ -1220,16 +1220,20 @@
         
+ 
+   
 Block bl
@@ -1288,16 +1288,20 @@
 ock();%0A%0A
+    
         
@@ -1355,32 +1355,36 @@
                 
+    
 event.world.setB
@@ -1461,16 +1461,20 @@
         
+   
+ 
 %7D else i
@@ -1502,24 +1502,28 @@
 lockDirt) %7B%0A
+    
             
@@ -1599,32 +1599,54 @@
 efaultState());%0A
+                    %7D%0A
                 

Fix a bug with right clicking