mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
fix some custom recipe not working
This commit is contained in:
parent
3bb817aeca
commit
eb50bfcc01
3 changed files with 8 additions and 7 deletions
|
|
@ -214,10 +214,10 @@ class AnvilResultListener : Listener {
|
||||||
val recipe = result.recipe!!
|
val recipe = result.recipe!!
|
||||||
|
|
||||||
// We remove what should be removed
|
// We remove what should be removed
|
||||||
if (rightItem != null) {
|
if (!rightItem.isAir) {
|
||||||
if (recipe.rightItem == null) return false// in case it changed
|
if (recipe.rightItem.isAir) return false// in case it changed
|
||||||
|
|
||||||
rightItem.amount -= amount * recipe.rightItem!!.amount
|
rightItem!!.amount -= amount * recipe.rightItem!!.amount
|
||||||
view.setItem(ANVIL_INPUT_RIGHT, rightItem)
|
view.setItem(ANVIL_INPUT_RIGHT, rightItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,8 @@ class AnvilCustomRecipe(
|
||||||
CustomAnvil.verboseLog("Left item passed !")
|
CustomAnvil.verboseLog("Left item passed !")
|
||||||
|
|
||||||
// we don't know if right item can be
|
// we don't know if right item can be
|
||||||
if (rightItem == null) { // null test
|
if (rightItem.isAir) { // null test
|
||||||
if (item2 != null) return false
|
if (!item2.isAir) return false
|
||||||
} else {
|
} else {
|
||||||
val rightSimilar = rightItem!!.isSimilar(item2)
|
val rightSimilar = rightItem!!.isSimilar(item2)
|
||||||
CustomAnvil.verboseLog("Right similar: $rightSimilar")
|
CustomAnvil.verboseLog("Right similar: $rightSimilar")
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import io.delilaheve.CustomAnvil
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||||
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe
|
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe
|
||||||
|
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
object CustomRecipeUtil {
|
object CustomRecipeUtil {
|
||||||
|
|
@ -32,7 +33,7 @@ object CustomRecipeUtil {
|
||||||
return if(recipe.exactCount) {
|
return if(recipe.exactCount) {
|
||||||
if(leftItem.amount != recipe.leftItem!!.amount){
|
if(leftItem.amount != recipe.leftItem!!.amount){
|
||||||
0
|
0
|
||||||
}else if(rightItem != null && rightItem.amount != recipe.rightItem!!.amount){
|
}else if(!rightItem.isAir && rightItem!!.amount != recipe.rightItem!!.amount){
|
||||||
0
|
0
|
||||||
}else{
|
}else{
|
||||||
1
|
1
|
||||||
|
|
@ -43,7 +44,7 @@ object CustomRecipeUtil {
|
||||||
val resultItem = recipe.resultItem!! // we know exist as the recipe was returned to us
|
val resultItem = recipe.resultItem!! // we know exist as the recipe was returned to us
|
||||||
val maxResultAmount = resultItem.maxStackSize/resultItem.amount
|
val maxResultAmount = resultItem.maxStackSize/resultItem.amount
|
||||||
val maxLeftAmount = leftItem.amount/recipe.leftItem!!.amount
|
val maxLeftAmount = leftItem.amount/recipe.leftItem!!.amount
|
||||||
val maxRightAmount = if(rightItem == null){ maxLeftAmount } else{ rightItem.amount/recipe.rightItem!!.amount }
|
val maxRightAmount = if(rightItem.isAir){ maxLeftAmount } else{ rightItem!!.amount/recipe.rightItem!!.amount }
|
||||||
|
|
||||||
CustomAnvil.verboseLog("resultItem: $resultItem, maxResultAmount: $maxResultAmount, maxLeftAmount: $maxLeftAmount, maxRightAmount: $maxRightAmount")
|
CustomAnvil.verboseLog("resultItem: $resultItem, maxResultAmount: $maxResultAmount, maxLeftAmount: $maxLeftAmount, maxRightAmount: $maxRightAmount")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue