@SubscribeEvent
  @SideOnly(Side.CLIENT)
  public void renderCeramicsSelection(DrawBlockHighlightEvent event) {
    if (event.target.subHit == -1) {
      return;
    }
    Coord c = Coord.fromMop(event.player.worldObj, event.target);
    TileEntityGreenware clay = c.getTE(TileEntityGreenware.class);
    if (clay == null) {
      return;
    }
    if (event.target.subHit < 0 || event.target.subHit >= clay.parts.size()) {
      return;
    }
    event.setCanceled(true);
    EntityPlayer player = event.player;
    double partial = event.partialTicks;
    ClayLump lump = clay.parts.get(event.target.subHit);
    Block block = new Block(Material.rock);
    lump.toRotatedBlockBounds(clay, block);
    double widen = 0.002;
    double oX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partial;
    double oY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partial;
    double oZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partial;
    AxisAlignedBB bb =
        block
            .getSelectedBoundingBox(c.w, c.toBlockPos())
            .expand(widen, widen, widen)
            .offset(-oX, -oY, -oZ);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(false);
    float r = 0xFF;
    GL11.glLineWidth(2.0F);
    GL11.glColor4f(0, 0, 0, 0.4F);
    // GL11.glColor4f(0x4D/r, 0x34/r, 0x7C/r, 0.8F); //#4D347C
    RenderGlobal.drawSelectionBoundingBox(bb);
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);

    // TODO: If the rotation tool is selected, may draw the axis?
    // Oooooh, we could also draw the offset position for *EVERY* tool...
  }
 @SubscribeEvent
 public void onDrawBlockHighlight(DrawBlockHighlightEvent event) {
   if (!event.getTarget().typeOfHit.equals(RayTraceResult.Type.BLOCK)) return;
   Minecraft mc = Minecraft.getMinecraft();
   if (ItemRecordWire.connection != null) {
     float dx =
         (float)
             (mc.thePlayer.prevPosX
                 + (mc.thePlayer.posX - mc.thePlayer.prevPosX) * event.getPartialTicks());
     float dy =
         (float)
             (mc.thePlayer.prevPosY
                 + (mc.thePlayer.posY - mc.thePlayer.prevPosY) * event.getPartialTicks());
     float dz =
         (float)
             (mc.thePlayer.prevPosZ
                 + (mc.thePlayer.posZ - mc.thePlayer.prevPosZ) * event.getPartialTicks());
     float x1 =
         -(float)
             (event.getTarget().getBlockPos().getX()
                 - (ItemRecordWire.connection.fromHome
                     ? ItemRecordWire.connection.x1
                     : ItemRecordWire.connection.x2));
     float y1 =
         -(float)
             (event.getTarget().getBlockPos().getY()
                 - (ItemRecordWire.connection.fromHome
                     ? ItemRecordWire.connection.y1
                     : ItemRecordWire.connection.y2));
     float z1 =
         -(float)
             (event.getTarget().getBlockPos().getZ()
                 - (ItemRecordWire.connection.fromHome
                     ? ItemRecordWire.connection.z1
                     : ItemRecordWire.connection.z2));
     GL11.glEnable(GL11.GL_BLEND);
     GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
     GL11.glLineWidth(2F);
     GL11.glDisable(GL11.GL_TEXTURE_2D);
     GL11.glDepthMask(false);
     Block j =
         mc.theWorld
             .getBlockState(
                 new BlockPos(
                     event.getTarget().getBlockPos().getX(),
                     event.getTarget().getBlockPos().getY(),
                     event.getTarget().getBlockPos().getZ()))
             .getBlock();
     // TODO
     // j.setBlockBoundsBasedOnState(mc.theWorld, new
     // BlockPos(event.getTarget().getBlockPos().getX(), event.getTarget().getBlockPos().getY(),
     // event.getTarget().getBlockPos().getZ()));
     TileEntity t =
         mc.theWorld.getTileEntity(
             new BlockPos(
                 event.getTarget().getBlockPos().getX(),
                 event.getTarget().getBlockPos().getY(),
                 event.getTarget().getBlockPos().getZ()));
     // RenderGlobal.drawOutlinedBoundingBox(j.getSelectedBoundingBoxFromPool(mc.theWorld,
     // event.getTarget().blockX, event.getTarget().blockY,
     // event.getTarget().blockZ).expand(0.002D, 0.002D, 0.002D).getOffsetBoundingBox(-dx, -dy,
     // -dz), ((t instanceof IRecordWire ? (ItemRecordWire.connection.fromHome ? t instanceof
     // IRecordWireHome : !(t instanceof IRecordWireHome)) : false) || Math.sqrt(Math.pow(x1, 2) +
     // Math.pow(y1, 2) + Math.pow(z1, 2)) > 7) ? 0xFF0000 : (t instanceof IRecordWire ? 0x00FF00 :
     // 0xFFFF00));
     GL11.glDepthMask(true);
     GL11.glEnable(GL11.GL_TEXTURE_2D);
     GL11.glDisable(GL11.GL_BLEND);
     event.setCanceled(true);
   }
 }
  //	public static ArrayListMultimap<ChunkCoordinates, AxisAlignedBB> additionalBlockBounds =
  // ArrayListMultimap.create();
  //	public static void addAdditionalBlockBounds(ChunkCoordinates cc, AxisAlignedBB aabb)
  //	{
  //		for(AxisAlignedBB aabb1 : additionalBlockBounds.get(cc))
  //			if(aabb1.toString().equals(aabb.toString()))
  //				return;
  //		additionalBlockBounds.put(cc, aabb);
  //	}
  @SubscribeEvent()
  public void renderAdditionalBlockBounds(DrawBlockHighlightEvent event) {
    if (event.subID == 0 && event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
      float f1 = 0.002F;
      double d0 =
          event.player.lastTickPosX
              + (event.player.posX - event.player.lastTickPosX) * (double) event.partialTicks;
      double d1 =
          event.player.lastTickPosY
              + (event.player.posY - event.player.lastTickPosY) * (double) event.partialTicks;
      double d2 =
          event.player.lastTickPosZ
              + (event.player.posZ - event.player.lastTickPosZ) * (double) event.partialTicks;
      //			if(additionalBlockBounds.containsKey(new
      // ChunkCoordinates(event.target.blockX,event.target.blockY,event.target.blockZ)))
      if (event.player.worldObj.getBlock(
              event.target.blockX, event.target.blockY, event.target.blockZ)
          instanceof IEBlockInterfaces.ICustomBoundingboxes) {
        ChunkCoordinates cc =
            new ChunkCoordinates(event.target.blockX, event.target.blockY, event.target.blockZ);
        IEBlockInterfaces.ICustomBoundingboxes block =
            (IEBlockInterfaces.ICustomBoundingboxes)
                event.player.worldObj.getBlock(
                    event.target.blockX, event.target.blockY, event.target.blockZ);
        Set<AxisAlignedBB> set =
            block.addCustomSelectionBoxesToList(
                event.player.worldObj, cc.posX, cc.posY, cc.posZ, event.player);
        if (!set.isEmpty()) {
          //
          //	if(!(event.player.worldObj.getTileEntity(event.target.blockX,event.target.blockY,event.target.blockZ) instanceof IEBlockInterfaces.ICustomBoundingboxes))
          //				{
          //					additionalBlockBounds.removeAll(cc);
          //					return;
          //				}
          GL11.glEnable(GL11.GL_BLEND);
          OpenGlHelper.glBlendFunc(770, 771, 1, 0);
          GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
          GL11.glLineWidth(2.0F);
          GL11.glDisable(GL11.GL_TEXTURE_2D);
          GL11.glDepthMask(false);
          for (AxisAlignedBB aabb : set)
            //				for(AxisAlignedBB aabb : additionalBlockBounds.get(cc))
            if (aabb != null)
              RenderGlobal.drawOutlinedBoundingBox(
                  aabb.getOffsetBoundingBox(cc.posX, cc.posY, cc.posZ)
                      .expand((double) f1, (double) f1, (double) f1)
                      .getOffsetBoundingBox(-d0, -d1, -d2),
                  -1);

          GL11.glDepthMask(true);
          GL11.glEnable(GL11.GL_TEXTURE_2D);
          GL11.glDisable(GL11.GL_BLEND);
          event.setCanceled(true);
        }
      }

      ItemStack stack = event.player.getCurrentEquippedItem();
      World world = event.player.worldObj;
      if (stack != null
          && stack.getItem() instanceof ItemDrill
          && ((ItemDrill) stack.getItem())
              .isEffective(
                  world
                      .getBlock(event.target.blockX, event.target.blockY, event.target.blockZ)
                      .getMaterial())) {
        ItemStack head = ((ItemDrill) stack.getItem()).getHead(stack);
        if (head != null) {
          int side = event.target.sideHit;
          int diameter =
              ((IDrillHead) head.getItem()).getMiningSize(head)
                  + ((ItemDrill) stack.getItem()).getUpgrades(stack).getInteger("size");
          int depth =
              ((IDrillHead) head.getItem()).getMiningDepth(head)
                  + ((ItemDrill) stack.getItem()).getUpgrades(stack).getInteger("depth");

          int startX = event.target.blockX;
          int startY = event.target.blockY;
          int startZ = event.target.blockZ;
          if (diameter % 2 == 0) // even numbers
          {
            float hx = (float) event.target.hitVec.xCoord - event.target.blockX;
            float hy = (float) event.target.hitVec.yCoord - event.target.blockY;
            float hz = (float) event.target.hitVec.zCoord - event.target.blockZ;
            if ((side < 2 && hx < .5) || (side < 4 && hx < .5)) startX -= diameter / 2;
            if (side > 1 && hy < .5) startY -= diameter / 2;
            if ((side < 2 && hz < .5) || (side > 3 && hz < .5)) startZ -= diameter / 2;
          } else // odd numbers
          {
            startX -= (side == 4 || side == 5 ? 0 : diameter / 2);
            startY -= (side == 0 || side == 1 ? 0 : diameter / 2);
            startZ -= (side == 2 || side == 3 ? 0 : diameter / 2);
          }

          GL11.glColor4f(0.1F, 0.1F, 0.1F, 0.4F);
          GL11.glLineWidth(1F);
          GL11.glDisable(GL11.GL_TEXTURE_2D);

          //					AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(startX,startY,startZ,
          // startX+(side==4||side==5?1:diameter),startY+(side==0||side==1?1:diameter),startZ+(side==2||side==3?1: diameter));
          //					RenderGlobal.drawOutlinedBoundingBox(aabb.expand((double)f1, (double)f1,
          // (double)f1).getOffsetBoundingBox(-d0, -d1, -d2), -1);
          for (int dd = 0; dd < depth; dd++)
            for (int dw = 0; dw < diameter; dw++)
              for (int dh = 0; dh < diameter; dh++) {
                int x = startX + (side == 4 || side == 5 ? dd : dw);
                int y = startY + (side == 0 || side == 1 ? dd : dh);
                int z = startZ + (side == 0 || side == 1 ? dh : side == 4 || side == 5 ? dw : dd);
                Block block = event.player.worldObj.getBlock(x, y, z);
                if (block != null
                    && !block.isAir(world, x, y, z)
                    && block.getPlayerRelativeBlockHardness(event.player, world, x, y, z) != 0) {
                  if (!((ItemDrill) stack.getItem())
                      .canBreakExtraBlock(
                          world,
                          block,
                          x,
                          y,
                          z,
                          world.getBlockMetadata(x, y, z),
                          event.player,
                          stack,
                          head,
                          false)) continue;
                  AxisAlignedBB aabb =
                      block.getSelectedBoundingBoxFromPool(event.player.worldObj, x, y, z);
                  if (aabb != null) {
                    RenderGlobal.drawOutlinedBoundingBox(
                        aabb.expand((double) f1, (double) f1, (double) f1)
                            .getOffsetBoundingBox(-d0, -d1, -d2),
                        -1);
                  }
                }
              }
          GL11.glDepthMask(true);
          GL11.glEnable(GL11.GL_TEXTURE_2D);
          GL11.glDisable(GL11.GL_BLEND);
        }
      }
    }
  }