mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 18:30:27 -04:00
Slightly reworked logic of crafting upgrade to also support repairing items, fixes #874. Doesn't appear to break everything else.
This commit is contained in:
parent
fb8cca23ab
commit
d870d376aa
@ -39,15 +39,12 @@ class UpgradeCrafting(val host: EnvironmentHost with Robot) extends prefab.Manag
|
||||
|
||||
def craft(wantedCount: Int): Seq[_] = {
|
||||
load()
|
||||
CraftingManager.getInstance.getRecipeList.find {
|
||||
case recipe: IRecipe => recipe.matches(CraftingInventory, host.world)
|
||||
case _ => false // Shouldn't ever happen, but...
|
||||
} match {
|
||||
case Some(recipe: IRecipe) =>
|
||||
val cm = CraftingManager.getInstance
|
||||
var countCrafted = 0
|
||||
val canCraft = cm.findMatchingRecipe(CraftingInventory, host.world) != null
|
||||
breakable {
|
||||
while (countCrafted < wantedCount && recipe.matches(this, host.world)) {
|
||||
val result = recipe.getCraftingResult(CraftingInventory)
|
||||
while (countCrafted < wantedCount) {
|
||||
val result = cm.findMatchingRecipe(CraftingInventory, host.world)
|
||||
if (result == null || result.stackSize < 1) break()
|
||||
countCrafted += result.stackSize
|
||||
FMLCommonHandler.instance.firePlayerCraftingEvent(host.player, result, this)
|
||||
@ -80,9 +77,7 @@ class UpgradeCrafting(val host: EnvironmentHost with Robot) extends prefab.Manag
|
||||
load()
|
||||
}
|
||||
}
|
||||
Seq(true, countCrafted)
|
||||
case _ => Seq(false, 0)
|
||||
}
|
||||
Seq(canCraft, countCrafted)
|
||||
}
|
||||
|
||||
def load() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user