mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -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[_] = {
|
def craft(wantedCount: Int): Seq[_] = {
|
||||||
load()
|
load()
|
||||||
CraftingManager.getInstance.getRecipeList.find {
|
val cm = CraftingManager.getInstance
|
||||||
case recipe: IRecipe => recipe.matches(CraftingInventory, host.world)
|
|
||||||
case _ => false // Shouldn't ever happen, but...
|
|
||||||
} match {
|
|
||||||
case Some(recipe: IRecipe) =>
|
|
||||||
var countCrafted = 0
|
var countCrafted = 0
|
||||||
|
val canCraft = cm.findMatchingRecipe(CraftingInventory, host.world) != null
|
||||||
breakable {
|
breakable {
|
||||||
while (countCrafted < wantedCount && recipe.matches(this, host.world)) {
|
while (countCrafted < wantedCount) {
|
||||||
val result = recipe.getCraftingResult(CraftingInventory)
|
val result = cm.findMatchingRecipe(CraftingInventory, host.world)
|
||||||
if (result == null || result.stackSize < 1) break()
|
if (result == null || result.stackSize < 1) break()
|
||||||
countCrafted += result.stackSize
|
countCrafted += result.stackSize
|
||||||
FMLCommonHandler.instance.firePlayerCraftingEvent(host.player, result, this)
|
FMLCommonHandler.instance.firePlayerCraftingEvent(host.player, result, this)
|
||||||
@ -80,9 +77,7 @@ class UpgradeCrafting(val host: EnvironmentHost with Robot) extends prefab.Manag
|
|||||||
load()
|
load()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Seq(true, countCrafted)
|
Seq(canCraft, countCrafted)
|
||||||
case _ => Seq(false, 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def load() {
|
def load() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user