Fix loot disk and other recipes.

Closes #2345.
This commit is contained in:
Vexatos 2017-04-22 15:28:20 +02:00
parent a2791ae8a6
commit 31668c204d
5 changed files with 9 additions and 9 deletions

View File

@ -32,12 +32,12 @@ wrench {
}
lootdisks: [
{
name: "OpenComputers:openos"
name: "opencomputers:openos"
type: shapeless
input: ["oc:floppy", "oc:manual"]
},
{
name: "OpenComputers:oppm"
name: "opencomputers:oppm"
type: shapeless
input: ["oc:floppy", "oc:materialInterweb"]
}

View File

@ -22,7 +22,7 @@ class ColorizeRecipe(target: Item, source: Array[Item] = null) extends Container
override def matches(crafting: InventoryCrafting, world: World): Boolean = {
val stacks = (0 until crafting.getSizeInventory).flatMap(i => Option(crafting.getStackInSlot(i)))
val targets = stacks.filter(stack => sourceItems.contains(stack.getItem) || stack.getItem == targetItem)
val other = stacks.filterNot(targets.contains)
val other = stacks.filterNot(stack => stack.isEmpty || targets.contains(stack))
targets.size == 1 && other.nonEmpty && other.forall(Color.isDye)
}
@ -37,7 +37,7 @@ class ColorizeRecipe(target: Item, source: Array[Item] = null) extends Container
|| stack.getItem == targetItem) {
targetStack = stack.copy()
targetStack.setCount(1)
} else {
} else if(!stack.isEmpty) {
val dye = Color.findDye(stack)
if (dye.isEmpty)
return ItemStack.EMPTY

View File

@ -19,7 +19,7 @@ class DecolorizeRecipe(target: Item) extends ContainerItemAwareRecipe {
override def matches(crafting: InventoryCrafting, world: World): Boolean = {
val stacks = (0 until crafting.getSizeInventory).flatMap(i => Option(crafting.getStackInSlot(i)))
val targets = stacks.filter(stack => stack.getItem == targetItem)
val other = stacks.filterNot(targets.contains)
val other = stacks.filterNot(stack => stack.isEmpty || targets.contains(stack))
targets.size == 1 && other.size == 1 && other.forall(_.getItem == Items.WATER_BUCKET)
}
@ -30,7 +30,7 @@ class DecolorizeRecipe(target: Item) extends ContainerItemAwareRecipe {
if (stack.getItem == targetItem) {
targetStack = stack.copy()
targetStack.setCount(1)
} else if (stack.getItem != Items.WATER_BUCKET) {
} else if (!stack.isEmpty && stack.getItem != Items.WATER_BUCKET) {
return ItemStack.EMPTY
}
}

View File

@ -14,7 +14,7 @@ import scala.collection.immutable
class LootDiskCyclingRecipe extends IRecipe {
override def matches(crafting: InventoryCrafting, world: World): Boolean = {
val stacks = collectStacks(crafting).toArray
stacks.length == 2 && stacks.exists(Loot.isLootDisk) && stacks.exists(Wrench.isWrench)
stacks.count(!_.isEmpty) == 2 && stacks.exists(Loot.isLootDisk) && stacks.exists(Wrench.isWrench)
}
override def getCraftingResult(crafting: InventoryCrafting): ItemStack = {

View File

@ -169,8 +169,8 @@ object Recipes {
}
// Register all unknown recipes. Well. Loot disk recipes.
if (recipes.hasPath("lootDisks")) try {
val lootRecipes = recipes.getConfigList("lootDisks")
if (recipes.hasPath("lootdisks")) try {
val lootRecipes = recipes.getConfigList("lootdisks")
val lootStacks = Loot.globalDisks.map(_._1)
for (recipe <- lootRecipes) {
val name = recipe.getString("name")