package pokefenn.totemic.handler;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import pokefenn.totemic.init.ModBlocks;
import pokefenn.totemic.init.ModItems;
import pokefenn.totemic.item.equipment.ItemTotemWhittlingKnife;
import pokefenn.totemic.network.NetworkHandler;
import pokefenn.totemic.network.client.PacketMouseWheel;

public class PlayerInteract
{
    @SubscribeEvent
    @SideOnly(Side.CLIENT)
    public void onMouse(MouseEvent event)
    {
        if(event.isCanceled())
            return;

        if(event.getDwheel() != 0)
        {
            EntityPlayer player = Minecraft.getMinecraft().player;
            if(player.isSneaking() && player.getHeldItemMainhand().getItem() == ModItems.totem_whittling_knife)
            {
                boolean direction = (event.getDwheel() > 0);
                NetworkHandler.sendToServer(new PacketMouseWheel(direction));
                player.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemTotemWhittlingKnife.changeIndex(player.getHeldItemMainhand(), direction));
                event.setCanceled(true);
            }
        }
    }

    @SubscribeEvent
    public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event)
    {
        //Workaround to make left-clicking the Totem Base with a Totemic Staff work in creative mode
        if(!event.getWorld().isRemote && event.getEntityPlayer().isCreative() && event.getUseBlock() != Result.DENY)
        {
            if(event.getItemStack().getItem() == ModItems.totemic_staff && event.getWorld().getBlockState(event.getPos()).getBlock() == ModBlocks.totem_base)
            {
                ModBlocks.totem_base.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer());
            }
        }
    }
}

@@ -28,16 +28,50 @@
 ndler;%0A%0A
+import net.minecraft.block.Block;%0A
 import n
@@ -1687,217 +1687,534 @@
     
-//Workaround to make left-clicking the Totem Base with a Totemic Staff work in creative mode%0A        if(!event.getWorld().isRemote && event.getEntityPlayer().isCreative() && event.getUseBlock() != Result.DENY)
+if(event.getEntityPlayer().isCreative() && event.getUseBlock() != Result.DENY)%0A        %7B%0A            Block block = event.getWorld().getBlockState(event.getPos()).getBlock();%0A            if(event.getEntityPlayer().isSneaking() && (block == ModBlocks.drum %7C%7C block == ModBlocks.wind_chime))%0A            %7B%0A                //Enable using sneak+left click to select ceremonies in Creative mode%0A                event.setCanceled(true);%0A                block.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer());
 %0A   
@@ -2210,33 +2210,37 @@
 yer());%0A        
-%7B
+    %7D
 %0A            if(
@@ -2228,35 +2228,70 @@
   %7D%0A            
-if(
+else if(!event.getWorld().isRemote && 
 event.getItemSta
@@ -2338,65 +2338,13 @@
  && 
-event.getWorld().getBlockState(event.getPos()).getBlock()
+block
  == 
@@ -2395,36 +2395,130 @@
         
-ModBlocks.t
+//Workaround to make left-clicking the T
 otem
-_b
+ B
 ase
+ with a Totemic Staff work in creative mode%0A                block
 .onBlock

Enable sneak+left click on Drum and Wind Chime in creative mode