Package erogenousbeef.bigreactors.api.data

Examples of erogenousbeef.bigreactors.api.data.SourceProductMapping


    }
   
    // If we have an output item, try to produce more of it, given its mapping
    if(outputItem != null) {
      // Find matching mapping
      SourceProductMapping mapping = Reactants.getSolidToReactant(outputItem);
      if(mapping == null || !reactantType.equals(mapping.getProduct())) {
        // Items are incompatible!
        return 0;
      }
     
      // We're using the original source item >> reactant mapping here
      // This means that source == item, and product == reactant
      int amtToProduce = mapping.getSourceAmount(amount);
      amtToProduce = Math.min(amtToProduce, getInventoryStackLimit() - outputItem.stackSize);
      if(amtToProduce <= 0) {  return 0; }
     
      // Do we actually produce any reactant at this reduced amount?
      int reactantToConsume = mapping.getProductAmount(amtToProduce);
      if(reactantToConsume <= 0) { return 0; }
     
      outputItem.stackSize += amtToProduce;
      onItemsReceived();
     
      return reactantToConsume;
    }

    // Ok, we have no items. We need to figure out candidate mappings.
    // Below here, we're using the reactant >> source mappings.
    // This means that source == reactant, and product == item.
    SourceProductMapping bestMapping = null;

    List<SourceProductMapping> mappings = Reactants.getReactantToSolids(reactantType);
    if(mappings != null) {
      int bestReactantAmount = 0;
      for(SourceProductMapping mapping: mappings) {
        // How much product can we produce?
        int potentialProducts = mapping.getProductAmount(amount);
       
        // And how much reactant will that consume?
        int potentialReactant = mapping.getSourceAmount(potentialProducts);

        if(bestMapping == null || bestReactantAmount < potentialReactant) {
          bestMapping = mapping;
          bestReactantAmount = potentialReactant;
        }
      }
    }

    if(bestMapping == null) {
      BRLog.warning("There are no mapped item types for reactant %s. Using cyanite instead.", reactantType);
      bestMapping = StandardReactants.cyaniteMapping;
    }

    int itemsToProduce = Math.min(bestMapping.getProductAmount(amount), getInventoryStackLimit());
    if(itemsToProduce <= 0) {
      // Can't produce even one ingot? Ok then.
      return 0;
    }

    // And clamp again in case we could produce more than 64 items
    int reactantConsumed = bestMapping.getSourceAmount(itemsToProduce);
    itemsToProduce = bestMapping.getProductAmount(reactantConsumed);

    ItemStack newItem = ItemHelper.getOre(bestMapping.getProduct());
    if(newItem == null) {
      BRLog.warning("Could not find item for oredict entry %s, using cyanite instead.", bestMapping.getSource());
      newItem = BigReactors.ingotGeneric.getItemStackForType("ingotCyanite");
    }
    else {
      newItem = newItem.copy(); // Don't stomp the oredict
    }
View Full Code Here

TOP

Related Classes of erogenousbeef.bigreactors.api.data.SourceProductMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.