diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/ShapedRecipeListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/ShapedRecipeListener.kt index 79dfa72a..734cd127 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/ShapedRecipeListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/ShapedRecipeListener.kt @@ -49,13 +49,15 @@ class ShapedRecipeListener : Listener { } isStackedRecipe = true } else if (inMatrix != null) { - val max = inMatrix.amount + val max = Math.floorDiv(inMatrix.amount, inRecipe.item.amount) if (max < upperBound) { upperBound = max } + isStackedRecipe = true } } + if (!isStackedRecipe) { return } @@ -66,8 +68,10 @@ class ShapedRecipeListener : Listener { upperBound-- } + val newMatrix = matrix; + for (i in 0..8) { - val inMatrix = event.inventory.matrix[i] + val inMatrix = matrix[i] val inRecipe = matched.parts[i] if (inRecipe is TestableStack) { @@ -76,13 +80,31 @@ class ShapedRecipeListener : Listener { for (j in 0..upperBound) { amount -= inRecipe.amount } - inMatrix.amount = amount + inMatrix.amount = amount; + newMatrix[i] = inMatrix + } else { inMatrix.amount = inMatrix.amount - (inRecipe.amount - 1) + newMatrix[i] = inMatrix + } + } else { + if (inMatrix == null) continue + if (event.isShiftClick) { + var amount = inMatrix.amount + 1 + for (j in 0..upperBound) { + amount -= inRecipe.item.amount + } + inMatrix.amount = amount; + newMatrix[i] = inMatrix + } else { + inMatrix.amount = inMatrix.amount - (inRecipe.item.amount - 1) + newMatrix[i] = inMatrix } } } + event.inventory.matrix = newMatrix; + if (event.isShiftClick) { val result = event.inventory.result ?: return