// Path: src/main/java/com/nauktis/core/block/icon/IBlockIconHandler.java
// public interface IBlockIconHandler {
//     IIcon getIcon(int pSide, int pMetadata);
// 
//     IIcon getIcon(IBlockAccess pBlockAccess, int pX, int pY, int pZ, int pSide);
// 
//     void registerBlockIcons(IIconRegister pIconRegister);
// }
// 
// Path: src/main/java/com/nauktis/core/utility/Utils.java
// public final class Utils {
//     public static final Random RANDOM = new Random();
// 
//     /**
//      * Utility class, no public constructor.
//      */
//     private Utils() {
// 
//     }
// 
//     /**
//      * Returns true for server side world.
//      */
//     public static boolean isServer(World pWorld) {
//         return !pWorld.isRemote;
//     }
// 
//     /**
//      * Returns true for client side world.
//      */
//     public static boolean isClient(World pWorld) {
//         return pWorld.isRemote;
//     }
// 
//     /**
//      * Returns true if the player has a usable wrench equipped.
//      */
//     public static boolean hasUsableWrench(EntityPlayer pPlayer, int pX, int pY, int pZ) {
//         ItemStack tool = pPlayer.getCurrentEquippedItem();
//         if (tool != null) {
//             if (ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool.getItem() instanceof IToolWrench && ((IToolWrench) tool.getItem())
//                     .canWrench(pPlayer, pX, pY, pZ)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     /**
//      * Spawns an ItemStack in the World. No motion in X and Z axis.
//      */
//     public static void spawnItemStack(World pWorld, int pX, int pY, int pZ, ItemStack pItemStack) {
//         EntityItem entityItem = new EntityItem(pWorld, pX + 0.5, pY + 0.5, pZ + 0.5, pItemStack);
//         entityItem.motionX = 0;
//         entityItem.motionZ = 0;
//         pWorld.spawnEntityInWorld(entityItem);
//     }
// 
//     /**
//      * Returns true if the two ItemStacks contains exactly the same item without taking stack size into account.
//      * Credit to Pahimar.
//      */
//     public static boolean itemStacksEqualIgnoreStackSize(ItemStack pItemStack1, ItemStack pItemStack2) {
//         if (pItemStack1 != null && pItemStack2 != null) {
//             // Compare itemID
//             if (Item.getIdFromItem(pItemStack1.getItem()) - Item.getIdFromItem(pItemStack2.getItem()) == 0) {
//                 // Compare item
//                 if (pItemStack1.getItem() == pItemStack2.getItem()) {
//                     // Compare meta
//                     if (pItemStack1.getItemDamage() == pItemStack2.getItemDamage()) {
//                         // Compare NBT presence
//                         if (pItemStack1.hasTagCompound() && pItemStack2.hasTagCompound()) {
//                             // Compare NBT
//                             if (ItemStack.areItemStackTagsEqual(pItemStack1, pItemStack2)) {
//                                 return true;
//                             }
//                         } else if (!pItemStack1.hasTagCompound() && !pItemStack2.hasTagCompound()) {
//                             return true;
//                         }
//                     }
//                 }
//             }
//         }
//         return false;
//     }
// 
//     public static boolean isShiftKeyDown() {
//         return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
//     }
// }


import com.nauktis.core.block.icon.IBlockIconHandler;
import com.nauktis.core.utility.Utils;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
package com.nauktis.core.block;


public abstract class BaseModBlockWithTileEntity extends BaseModBlock implements ITileEntityProvider {
    public BaseModBlockWithTileEntity(String pModId, String pName, IBlockIconHandler pBlockIconHandler) {
        super(pModId, pName, pBlockIconHandler);
        isBlockContainer = true;
    }

    @Override
    public void breakBlock(World pWorld, int pX, int pY, int pZ, Block pBlock, int pMeta) {
        dropInventory(pWorld, pX, pY, pZ);
        super.breakBlock(pWorld, pX, pY, pZ, pBlock, pMeta);
    }

    @Override
    public boolean onBlockEventReceived(World pWorld, int pX, int pY, int pZ, int pEventNumber, int pEventArgument) {
        super.onBlockEventReceived(pWorld, pX, pY, pZ, pEventNumber, pEventArgument);
        TileEntity tileentity = pWorld.getTileEntity(pX, pY, pZ);
        if (tileentity != null) {
            return tileentity.receiveClientEvent(pEventNumber, pEventArgument);
        }
        return false;
    }

    /**
     * If the block has a TileEntity that has an inventory, this method will drop all of its content.
     */
    protected void dropInventory(World pWorld, int pX, int pY, int pZ) {
        TileEntity tileEntity = pWorld.getTileEntity(pX, pY, pZ);
        if (tileEntity instanceof IInventory) {
            IInventory inventory = (IInventory) tileEntity;
            for (int i = 0; i < inventory.getSizeInventory(); i++) {
                ItemStack itemStack = inventory.getStackInSlot(i);
                if (itemStack != null && itemStack.stackSize > 0) {
// Path: src/main/java/com/nauktis/core/block/icon/IBlockIconHandler.java
// public interface IBlockIconHandler {
//     IIcon getIcon(int pSide, int pMetadata);
// 
//     IIcon getIcon(IBlockAccess pBlockAccess, int pX, int pY, int pZ, int pSide);
// 
//     void registerBlockIcons(IIconRegister pIconRegister);
// }
// 
// Path: src/main/java/com/nauktis/core/utility/Utils.java
// public final class Utils {
//     public static final Random RANDOM = new Random();
// 
//     /**
//      * Utility class, no public constructor.
//      */
//     private Utils() {
// 
//     }
// 
//     /**
//      * Returns true for server side world.
//      */
//     public static boolean isServer(World pWorld) {
//         return !pWorld.isRemote;
//     }
// 
//     /**
//      * Returns true for client side world.
//      */
//     public static boolean isClient(World pWorld) {
//         return pWorld.isRemote;
//     }
// 
//     /**
//      * Returns true if the player has a usable wrench equipped.
//      */
//     public static boolean hasUsableWrench(EntityPlayer pPlayer, int pX, int pY, int pZ) {
//         ItemStack tool = pPlayer.getCurrentEquippedItem();
//         if (tool != null) {
//             if (ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool.getItem() instanceof IToolWrench && ((IToolWrench) tool.getItem())
//                     .canWrench(pPlayer, pX, pY, pZ)) {
//                 return true;
//             }
//         }
//         return false;
//     }
// 
//     /**
//      * Spawns an ItemStack in the World. No motion in X and Z axis.
//      */
//     public static void spawnItemStack(World pWorld, int pX, int pY, int pZ, ItemStack pItemStack) {
//         EntityItem entityItem = new EntityItem(pWorld, pX + 0.5, pY + 0.5, pZ + 0.5, pItemStack);
//         entityItem.motionX = 0;
//         entityItem.motionZ = 0;
//         pWorld.spawnEntityInWorld(entityItem);
//     }
// 
//     /**
//      * Returns true if the two ItemStacks contains exactly the same item without taking stack size into account.
//      * Credit to Pahimar.
//      */
//     public static boolean itemStacksEqualIgnoreStackSize(ItemStack pItemStack1, ItemStack pItemStack2) {
//         if (pItemStack1 != null && pItemStack2 != null) {
//             // Compare itemID
//             if (Item.getIdFromItem(pItemStack1.getItem()) - Item.getIdFromItem(pItemStack2.getItem()) == 0) {
//                 // Compare item
//                 if (pItemStack1.getItem() == pItemStack2.getItem()) {
//                     // Compare meta
//                     if (pItemStack1.getItemDamage() == pItemStack2.getItemDamage()) {
//                         // Compare NBT presence
//                         if (pItemStack1.hasTagCompound() && pItemStack2.hasTagCompound()) {
//                             // Compare NBT
//                             if (ItemStack.areItemStackTagsEqual(pItemStack1, pItemStack2)) {
//                                 return true;
//                             }
//                         } else if (!pItemStack1.hasTagCompound() && !pItemStack2.hasTagCompound()) {
//                             return true;
//                         }
//                     }
//                 }
//             }
//         }
//         return false;
//     }
// 
//     public static boolean isShiftKeyDown() {
//         return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
//     }
// }


// Path: src/main/java/com/nauktis/core/block/BaseModBlockWithTileEntity.java
import com.nauktis.core.block.icon.IBlockIconHandler;
import com.nauktis.core.utility.Utils;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

package com.nauktis.core.block;


public abstract class BaseModBlockWithTileEntity extends BaseModBlock implements ITileEntityProvider {
    public BaseModBlockWithTileEntity(String pModId, String pName, IBlockIconHandler pBlockIconHandler) {
        super(pModId, pName, pBlockIconHandler);
        isBlockContainer = true;
    }

    @Override
    public void breakBlock(World pWorld, int pX, int pY, int pZ, Block pBlock, int pMeta) {
        dropInventory(pWorld, pX, pY, pZ);
        super.breakBlock(pWorld, pX, pY, pZ, pBlock, pMeta);
    }

    @Override
    public boolean onBlockEventReceived(World pWorld, int pX, int pY, int pZ, int pEventNumber, int pEventArgument) {
        super.onBlockEventReceived(pWorld, pX, pY, pZ, pEventNumber, pEventArgument);
        TileEntity tileentity = pWorld.getTileEntity(pX, pY, pZ);
        if (tileentity != null) {
            return tileentity.receiveClientEvent(pEventNumber, pEventArgument);
        }
        return false;
    }

    /**
     * If the block has a TileEntity that has an inventory, this method will drop all of its content.
     */
    protected void dropInventory(World pWorld, int pX, int pY, int pZ) {
        TileEntity tileEntity = pWorld.getTileEntity(pX, pY, pZ);
        if (tileEntity instanceof IInventory) {
            IInventory inventory = (IInventory) tileEntity;
            for (int i = 0; i < inventory.getSizeInventory(); i++) {
                ItemStack itemStack = inventory.getStackInSlot(i);
                if (itemStack != null && itemStack.stackSize > 0) {
                    Utils.spawnItemStack(pWorld, pX, pY, pZ, itemStack.copy());