// Path: src/main/java/com/corwinjv/mobtotems/blocks/ModBlocks.java
// @Mod.EventBusSubscriber(modid = Reference.MOD_ID)
// public class ModBlocks {
//     public static final HashSet<ItemBlock> ITEM_BLOCKS = new HashSet<>();
// 
//     public static final String TOTEM_WOOD_NAME = "totem_wood";
//     public static final String SACRED_LIGHT_NAME = "sacred_light";
//     public static final String INCENSE_KINDLING_BOX_NAME = "incense_kindling_box";
//     public static final String OFFERING_BOX_NAME = "offering_box";
// 
//     public static final Block TOTEM_WOOD = new TotemWoodBlock().setUnlocalizedName(TOTEM_WOOD_NAME).setRegistryName(Reference.MOD_ID, TOTEM_WOOD_NAME);
//     public static final Block SACRED_LIGHT = new SacredLightBlock().setUnlocalizedName(SACRED_LIGHT_NAME).setRegistryName(Reference.MOD_ID, SACRED_LIGHT_NAME);
//     public static final Block INCENSE_KINDLING_BOX = new IncenseKindlingBox().setUnlocalizedName(INCENSE_KINDLING_BOX_NAME).setRegistryName(Reference.MOD_ID, INCENSE_KINDLING_BOX_NAME);
//     public static final Block OFFERING_BOX = new OfferingBox().setUnlocalizedName(OFFERING_BOX_NAME).setRegistryName(Reference.MOD_ID, OFFERING_BOX_NAME);
// 
//     public static void init() {
//     }
// 
//     @SubscribeEvent
//     public static void registerBlocks(RegistryEvent.Register<Block> e) {
//         final IForgeRegistry<Block> registry = e.getRegistry();
//         final Block[] blocks = {
//                 TOTEM_WOOD,
//                 SACRED_LIGHT,
//                 INCENSE_KINDLING_BOX,
//                 OFFERING_BOX
//         };
// 
//         registry.registerAll(blocks);
//     }
// 
//     @SubscribeEvent
//     public static void registerItemBlocks(RegistryEvent.Register<Item> e) {
//         final IForgeRegistry<Item> registry = e.getRegistry();
// 
//         final ItemBlock[] items = {
//                 new TotemWoodItemBlock(TOTEM_WOOD),
//                 new ItemBlock(SACRED_LIGHT),
//                 new ItemBlock(INCENSE_KINDLING_BOX),
//                 new ItemBlock(OFFERING_BOX),
//         };
// 
//         for(final ItemBlock item : items)
//         {
//             final Block block = item.getBlock();
//             final ResourceLocation registryName = Preconditions.checkNotNull(block.getRegistryName(), "Block %s has null registry name", block);
//             registry.register(item.setRegistryName(registryName));
//             ITEM_BLOCKS.add(item);
//         }
// 
//         registerTileEntities();
//     }
// 
//     private static void registerTileEntities()
//     {
//         GameRegistry.registerTileEntity(TotemTileEntity.class, Reference.RESOURCE_PREFIX + TOTEM_WOOD_NAME);
//         GameRegistry.registerTileEntity(SacredLightTileEntity.class, Reference.RESOURCE_PREFIX + SACRED_LIGHT_NAME);
//         GameRegistry.registerTileEntity(IncenseKindlingBoxTileEntity.class, Reference.RESOURCE_PREFIX + INCENSE_KINDLING_BOX_NAME);
//         GameRegistry.registerTileEntity(OfferingBoxTileEntity.class, Reference.RESOURCE_PREFIX + OFFERING_BOX_NAME);
//     }
// 
//     @SubscribeEvent
//     public static void registerRenders(ModelRegistryEvent e) {
//         for (int i = 0; i < TotemType.values().length; i++) {
//             Item item = Item.getItemFromBlock(TOTEM_WOOD);
//             ModelResourceLocation modelResourceLocation = new ModelResourceLocation(Reference.RESOURCE_PREFIX + TOTEM_WOOD_NAME, "totem_type=" + TotemType.fromMeta(i).getName());
//             ModelLoader.setCustomModelResourceLocation(item, i, modelResourceLocation);
//         }
// 
//         registerRender(SACRED_LIGHT, SACRED_LIGHT_NAME);
//         registerRender(INCENSE_KINDLING_BOX, INCENSE_KINDLING_BOX_NAME);
//         registerRender(OFFERING_BOX, OFFERING_BOX_NAME);
//     }
// 
//     private static void registerRender(Block block, String key) {
//         Item item = Item.getItemFromBlock(block);
//         ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(Reference.RESOURCE_PREFIX + key, "inventory"));
//     }
// }
// 
// Path: src/main/java/com/corwinjv/mobtotems/utils/BlockUtils.java
// public class BlockUtils {
//     // Returns an instance of the block at the given position in the given world
//     public static Block getBlock(World world, BlockPos pos) {
//         Block targetBlock = null;
//         if (pos != null) {
//             targetBlock = world.getBlockState(pos).getBlock();
//         }
//         return targetBlock;
//     }
// 
//     public static boolean isAreaSolid(EntityPlayer player, BlockPos centerPos) {
//         for (double x = centerPos.getX() - 1; x <= centerPos.getX() + 1; x++) {
//             for (double z = centerPos.getZ() - 1; z <= centerPos.getZ() + 1; z++) {
//                 IBlockState blockState = player.world.getBlockState(new BlockPos(x, player.posY, z));
//                 if (blockState.getMaterial().isSolid()) {
//                     return true;
//                 }
//             }
//         }
//         return false;
//     }
// }


import com.corwinjv.mobtotems.blocks.ModBlocks;
import com.corwinjv.mobtotems.utils.BlockUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
package com.corwinjv.mobtotems.items;



/**
 * Created by CorwinJV on 2/17/2016.
 */
public class TotemicFocus extends ModItem {
    @Nonnull
    @Override
    public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand enumHand, EnumFacing side, float hitX, float hitY, float hitZ) {
        if (!world.isRemote) {
            Block targetBlock = BlockUtils.getBlock(world, pos);
            if (targetBlock != null
                    && targetBlock instanceof BlockLog) {
                world.destroyBlock(pos, false);
// Path: src/main/java/com/corwinjv/mobtotems/blocks/ModBlocks.java
// @Mod.EventBusSubscriber(modid = Reference.MOD_ID)
// public class ModBlocks {
//     public static final HashSet<ItemBlock> ITEM_BLOCKS = new HashSet<>();
// 
//     public static final String TOTEM_WOOD_NAME = "totem_wood";
//     public static final String SACRED_LIGHT_NAME = "sacred_light";
//     public static final String INCENSE_KINDLING_BOX_NAME = "incense_kindling_box";
//     public static final String OFFERING_BOX_NAME = "offering_box";
// 
//     public static final Block TOTEM_WOOD = new TotemWoodBlock().setUnlocalizedName(TOTEM_WOOD_NAME).setRegistryName(Reference.MOD_ID, TOTEM_WOOD_NAME);
//     public static final Block SACRED_LIGHT = new SacredLightBlock().setUnlocalizedName(SACRED_LIGHT_NAME).setRegistryName(Reference.MOD_ID, SACRED_LIGHT_NAME);
//     public static final Block INCENSE_KINDLING_BOX = new IncenseKindlingBox().setUnlocalizedName(INCENSE_KINDLING_BOX_NAME).setRegistryName(Reference.MOD_ID, INCENSE_KINDLING_BOX_NAME);
//     public static final Block OFFERING_BOX = new OfferingBox().setUnlocalizedName(OFFERING_BOX_NAME).setRegistryName(Reference.MOD_ID, OFFERING_BOX_NAME);
// 
//     public static void init() {
//     }
// 
//     @SubscribeEvent
//     public static void registerBlocks(RegistryEvent.Register<Block> e) {
//         final IForgeRegistry<Block> registry = e.getRegistry();
//         final Block[] blocks = {
//                 TOTEM_WOOD,
//                 SACRED_LIGHT,
//                 INCENSE_KINDLING_BOX,
//                 OFFERING_BOX
//         };
// 
//         registry.registerAll(blocks);
//     }
// 
//     @SubscribeEvent
//     public static void registerItemBlocks(RegistryEvent.Register<Item> e) {
//         final IForgeRegistry<Item> registry = e.getRegistry();
// 
//         final ItemBlock[] items = {
//                 new TotemWoodItemBlock(TOTEM_WOOD),
//                 new ItemBlock(SACRED_LIGHT),
//                 new ItemBlock(INCENSE_KINDLING_BOX),
//                 new ItemBlock(OFFERING_BOX),
//         };
// 
//         for(final ItemBlock item : items)
//         {
//             final Block block = item.getBlock();
//             final ResourceLocation registryName = Preconditions.checkNotNull(block.getRegistryName(), "Block %s has null registry name", block);
//             registry.register(item.setRegistryName(registryName));
//             ITEM_BLOCKS.add(item);
//         }
// 
//         registerTileEntities();
//     }
// 
//     private static void registerTileEntities()
//     {
//         GameRegistry.registerTileEntity(TotemTileEntity.class, Reference.RESOURCE_PREFIX + TOTEM_WOOD_NAME);
//         GameRegistry.registerTileEntity(SacredLightTileEntity.class, Reference.RESOURCE_PREFIX + SACRED_LIGHT_NAME);
//         GameRegistry.registerTileEntity(IncenseKindlingBoxTileEntity.class, Reference.RESOURCE_PREFIX + INCENSE_KINDLING_BOX_NAME);
//         GameRegistry.registerTileEntity(OfferingBoxTileEntity.class, Reference.RESOURCE_PREFIX + OFFERING_BOX_NAME);
//     }
// 
//     @SubscribeEvent
//     public static void registerRenders(ModelRegistryEvent e) {
//         for (int i = 0; i < TotemType.values().length; i++) {
//             Item item = Item.getItemFromBlock(TOTEM_WOOD);
//             ModelResourceLocation modelResourceLocation = new ModelResourceLocation(Reference.RESOURCE_PREFIX + TOTEM_WOOD_NAME, "totem_type=" + TotemType.fromMeta(i).getName());
//             ModelLoader.setCustomModelResourceLocation(item, i, modelResourceLocation);
//         }
// 
//         registerRender(SACRED_LIGHT, SACRED_LIGHT_NAME);
//         registerRender(INCENSE_KINDLING_BOX, INCENSE_KINDLING_BOX_NAME);
//         registerRender(OFFERING_BOX, OFFERING_BOX_NAME);
//     }
// 
//     private static void registerRender(Block block, String key) {
//         Item item = Item.getItemFromBlock(block);
//         ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(Reference.RESOURCE_PREFIX + key, "inventory"));
//     }
// }
// 
// Path: src/main/java/com/corwinjv/mobtotems/utils/BlockUtils.java
// public class BlockUtils {
//     // Returns an instance of the block at the given position in the given world
//     public static Block getBlock(World world, BlockPos pos) {
//         Block targetBlock = null;
//         if (pos != null) {
//             targetBlock = world.getBlockState(pos).getBlock();
//         }
//         return targetBlock;
//     }
// 
//     public static boolean isAreaSolid(EntityPlayer player, BlockPos centerPos) {
//         for (double x = centerPos.getX() - 1; x <= centerPos.getX() + 1; x++) {
//             for (double z = centerPos.getZ() - 1; z <= centerPos.getZ() + 1; z++) {
//                 IBlockState blockState = player.world.getBlockState(new BlockPos(x, player.posY, z));
//                 if (blockState.getMaterial().isSolid()) {
//                     return true;
//                 }
//             }
//         }
//         return false;
//     }
// }


// Path: src/main/java/com/corwinjv/mobtotems/items/TotemicFocus.java
import com.corwinjv.mobtotems.blocks.ModBlocks;
import com.corwinjv.mobtotems.utils.BlockUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;

package com.corwinjv.mobtotems.items;



/**
 * Created by CorwinJV on 2/17/2016.
 */
public class TotemicFocus extends ModItem {
    @Nonnull
    @Override
    public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand enumHand, EnumFacing side, float hitX, float hitY, float hitZ) {
        if (!world.isRemote) {
            Block targetBlock = BlockUtils.getBlock(world, pos);
            if (targetBlock != null
                    && targetBlock instanceof BlockLog) {
                world.destroyBlock(pos, false);
                Block blockToPlace = ModBlocks.TOTEM_WOOD;