stop crafting when craft result changes

closes #2054
This commit is contained in:
payonel 2018-02-21 11:36:31 -08:00
parent 2e5cca8dbf
commit add65a0f65

View File

@ -56,11 +56,14 @@ class UpgradeCrafting(val host: EnvironmentHost with internal.Robot) extends pre
load() load()
val cm = CraftingManager.getInstance val cm = CraftingManager.getInstance
var countCrafted = 0 var countCrafted = 0
val canCraft = cm.findMatchingRecipe(CraftingInventory, host.world) != null val originalCraft = cm.findMatchingRecipe(CraftingInventory, host.world)
breakable { breakable {
while (countCrafted < wantedCount) { while (countCrafted < wantedCount) {
val result = cm.findMatchingRecipe(CraftingInventory, host.world) val result = cm.findMatchingRecipe(CraftingInventory, host.world)
if (result == null || result.stackSize < 1) break() if (result == null || result.stackSize < 1) break()
if (!originalCraft.isItemEqual(result)) {
break()
}
countCrafted += result.stackSize countCrafted += result.stackSize
FMLCommonHandler.instance.firePlayerCraftingEvent(host.player, result, this) FMLCommonHandler.instance.firePlayerCraftingEvent(host.player, result, this)
val surplus = mutable.ArrayBuffer.empty[ItemStack] val surplus = mutable.ArrayBuffer.empty[ItemStack]
@ -91,7 +94,7 @@ class UpgradeCrafting(val host: EnvironmentHost with internal.Robot) extends pre
load() load()
} }
} }
Seq(canCraft, countCrafted) Seq(originalCraft != null, countCrafted)
} }
def load() { def load() {