@Override
 public void updateEntity() {
   if (!init) {
     init = true;
     AWLog.logDebug("scanning for controller...");
     for (TileEntity te :
         WorldTools.getTileEntitiesInArea(
             worldObj,
             xCoord - 16,
             yCoord - 4,
             zCoord - 16,
             xCoord + 16,
             yCoord + 4,
             zCoord + 16)) {
       if (te instanceof WorkSiteWarehouse) {
         WorkSiteWarehouse warehouse = (WorkSiteWarehouse) te;
         BlockPosition min = warehouse.getWorkBoundsMin();
         BlockPosition max = warehouse.getWorkBoundsMax();
         if (xCoord >= min.x
             && xCoord <= max.x
             && yCoord >= min.y
             && yCoord <= max.y
             && zCoord >= min.z
             && zCoord <= max.z) {
           warehouse.addInputBlock(this);
           controllerPosition =
               new BlockPosition(warehouse.xCoord, warehouse.yCoord, warehouse.zCoord);
           warehouse.onInputInventoryUpdated(this);
           break;
         }
       }
     }
   }
 }
 public void addStructureImage(String imageName, BufferedImage image) {
   AWLog.logDebug(
       "Received client side image of: "
           + imageName
           + " saving to image cache, and loading texture");
   String pathBase = "config/AWConfig/structures/image_cache/";
   File file;
   try {
     file = new File(pathBase + imageName);
     ImageIO.write(image, "png", file);
   } catch (IOException e) {
     e.printStackTrace();
   }
   loadTemplateImage(imageName);
 }
  private void loadTemplateImage(String imageName) {
    String pathBase = "config/AWConfig/structures/image_cache/";
    File file = new File(pathBase + imageName);
    ResourceLocation loc = new ResourceLocation("ancientwarfare", pathBase + imageName);

    if (!file.exists()) {
      BufferedImage image = StructureTemplateManager.instance().getTemplateImage(imageName);
      if (image != null) {
        Minecraft.getMinecraft().renderEngine.loadTexture(loc, new TextureImageBased(loc, image));
        String md5 = StructureTemplateManager.instance().getImageMD5(imageName);
        clientTemplateImages.put(imageName, loc);
        clientImageMD5s.put(imageName, md5);
      }
    } else {
      String md5;
      try {
        BufferedImage image = ImageIO.read(file);
        if (image.getWidth() == AWStructureStatics.structureImageWidth
            && image.getHeight() == AWStructureStatics.structureImageHeight) {
          Minecraft.getMinecraft().renderEngine.loadTexture(loc, new TextureImageBased(loc, image));
          md5 = getMD5(file);
          clientImageMD5s.put(imageName, md5);
          clientTemplateImages.put(imageName, loc);
        } else {
          AWLog.logError(
              "Error parsing image: "
                  + file.getName()
                  + " image was not of correct size. Found: "
                  + image.getWidth()
                  + "x"
                  + image.getHeight()
                  + "  Needed: "
                  + AWStructureStatics.structureImageWidth
                  + "x"
                  + AWStructureStatics.structureImageHeight);
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
 @Override
 public void setControllerPosition(BlockPosition position) {
   this.controllerPosition = position;
   AWLog.logDebug("set controller position to: " + position);
   this.init = this.controllerPosition != null;
 }