private boolean canOutputResult(EntityRef workstation, String resultObject) {
   EntityRef resultItem = createResultItem(resultObject);
   try {
     for (int outputSlot : WorkstationInventoryUtils.getAssignedSlots(workstation, "OUTPUT")) {
       if (InventoryUtils.canStackInto(
           resultItem, InventoryUtils.getItemAt(workstation, outputSlot))) {
         return true;
       }
     }
   } finally {
     resultItem.destroy();
   }
   return false;
 }
  @Override
  public boolean validateBeforeStart(
      EntityRef instigator, EntityRef workstation, EntityRef processEntity) {
    if (!workstation.hasComponent(WorkstationInventoryComponent.class)) {
      return false;
    }

    // Defer the heat calculation until it is actually needed
    Float heat = null;

    for (int slot : WorkstationInventoryUtils.getAssignedSlots(workstation, "INPUT")) {
      HeatProcessedComponent processed =
          InventoryUtils.getItemAt(workstation, slot).getComponent(HeatProcessedComponent.class);
      if (processed != null) {
        float heatRequired = processed.heatRequired;
        if (heat == null) {
          heat =
              HeatUtils.calculateHeatForEntity(
                  workstation, CoreRegistry.get(BlockEntityRegistry.class));
        }
        if (heatRequired <= heat) {
          final String result =
              processed.blockResult != null ? processed.blockResult : processed.itemResult;
          if (canOutputResult(workstation, result)) {
            processEntity.addComponent(new SpecificInputSlotComponent(slot));
            processEntity.addComponent(new OutputTypeComponent(result));
            return true;
          }
        }
      }
    }

    return false;
  }
  @Override
  public long getDuration(EntityRef instigator, EntityRef workstation, EntityRef processEntity) {
    SpecificInputSlotComponent input = processEntity.getComponent(SpecificInputSlotComponent.class);
    HeatProcessedComponent component =
        InventoryUtils.getItemAt(workstation, input.slot)
            .getComponent(HeatProcessedComponent.class);

    return component.processingTime;
  }
 @Override
 public void executeStart(EntityRef instigator, EntityRef workstation, EntityRef processEntity) {
   SpecificInputSlotComponent input = processEntity.getComponent(SpecificInputSlotComponent.class);
   EntityRef item = InventoryUtils.getItemAt(workstation, input.slot);
   CoreRegistry.get(InventoryManager.class).removeItem(workstation, instigator, item, true, 1);
 }