@Override
 protected boolean removedByPlayer(EntityPlayer player, boolean willHarvest) {
   if (player.worldObj.isRemote) {
     return false;
   }
   MovingObjectPosition hit = ItemSculptingTool.doRayTrace(player);
   if (hit == null || hit.subHit == -1 || parts.size() < 1) {
     return super.removedByPlayer(player, willHarvest);
   }
   Coord here = getCoord();
   ClayState state = getState();
   // If it's solid, break it.
   // If we're sneaking & creative, break it
   boolean shouldDestroy = player.isSneaking() || parts.size() == 1;
   if (player.capabilities.isCreativeMode) {
     if (shouldDestroy) {
       return super.removedByPlayer(player, willHarvest);
     } else {
       removeLump(hit.subHit);
       return true;
     }
   }
   shouldDestroy |= state != ClayState.WET;
   if (shouldDestroy) {
     InvUtil.spawnItemStack(here, getItem());
     here.setAir();
   } else {
     removeLump(hit.subHit);
     InvUtil.spawnItemStack(here, new ItemStack(Items.clay_ball));
   }
   return false;
 }
 @Override
 protected void onRemove() {
   super.onRemove();
   for (int x = -1; x <= 1; x++) {
     for (int y = -1; y <= 1; y++) {
       for (int z = -1; z <= 1; z++) {
         Coord c = getCoord().add(pos);
         TileEntityExtension tex = c.getTE(TileEntityExtension.class);
         if (tex != null && tex.getParent() == this) {
           c.setAir();
         }
       }
     }
   }
 }
  @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...
  }
  public boolean isValidLump(ClayLump lump) {
    // check volume
    if (!(Core.cheat)) {
      int wX = lump.maxX - lump.minX;
      int wY = lump.maxY - lump.minY;
      int wZ = lump.maxZ - lump.minZ;
      int area = wX * wY * wZ;
      int max_area = 16 * 16 * 16 /* / 4 */;
      if (!FzConfig.stretchy_clay) {
        max_area /= 4;
      }
      if (area <= 0 || area > max_area) {
        return false;
      }
    }

    // check bounds
    final int B = 16 * 3;
    if (lump.minX < 0) return false;
    if (lump.minY < 0) return false;
    if (lump.minZ < 0) return false;
    if (lump.maxX > B) return false;
    if (lump.maxY > B) return false;
    if (lump.maxZ > B) return false;

    // check for free space (needs to be last, as it can mutate the world)
    Block block = FzUtil.getTraceHelper();
    for (int dx = -1; dx <= 1; dx++) {
      for (int dy = -1; dy <= 1; dy++) {
        for (int dz = -1; dz <= 1; dz++) {
          AxisAlignedBB ab =
              new AxisAlignedBB(
                  pos.getX() + dx,
                  pos.getY() + dy,
                  pos.getZ() + dz,
                  pos.getX() + dx + 1,
                  pos.getY() + dy + 1,
                  pos.getZ() + dz + 1);
          Coord c = getCoord();
          c.x += dx;
          c.y += dy;
          c.z += dz;
          lump.toRotatedBlockBounds(this, block);
          AxisAlignedBB in = block.getCollisionBoundingBox(worldObj, pos, c.getState());
          if (in != null && ab.intersectsWith(in)) {
            // This block needs to be an Extension, or this
            if (c.isAir() || c.isReplacable()) {
              c.setId(Core.registry.legacy_factory_block);
              TileEntityExtension tex = new TileEntityExtension(this);
              c.setTE(tex);
              tex.getBlockClass().enforce(c);
              continue;
            }
            TileEntity te = c.getTE();
            if (te == this) {
              continue;
            }
            if (te instanceof TileEntityExtension) {
              TileEntityExtension tex = (TileEntityExtension) te;
              if (tex.getParent() == this) {
                continue;
              }
            }
            // We used to not allow this. We just make a bit of noise instead.
            // A notification will indicate that things will be a bit messed up here.
            // FIXME: Let block collision boxes go outside the block (Notch hard-coded for fences)
            new Notice(c, "!").sendToAll();
          }
        }
      }
    }
    return true;
  }