fix some custom recipe not working

This commit is contained in:
alexcrea 2026-08-03 14:10:23 +02:00
parent 845bb4d94a
commit d6af0e8b8f
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C
3 changed files with 8 additions and 7 deletions

View file

@ -216,10 +216,10 @@ class AnvilResultListener : Listener {
val recipe = result.recipe!!
// We remove what should be removed
if (rightItem != null) {
if (recipe.rightItem == null) return false// in case it changed
if (!rightItem.isAir) {
if (recipe.rightItem.isAir) return false// in case it changed
rightItem.amount -= amount * recipe.rightItem!!.amount
rightItem!!.amount -= amount * recipe.rightItem!!.amount
inventory.setItem(ANVIL_INPUT_RIGHT, rightItem)
}

View file

@ -176,8 +176,8 @@ class AnvilCustomRecipe(
CustomAnvil.verboseLog("Left item passed !")
// we don't know if right item can be
if (rightItem == null) { // null test
if (item2 != null) return false
if (rightItem.isAir) { // null test
if (!item2.isAir) return false
} else {
val rightSimilar = rightItem!!.isSimilar(item2)
CustomAnvil.verboseLog("Right similar: $rightSimilar")

View file

@ -4,6 +4,7 @@ import io.delilaheve.CustomAnvil
import org.bukkit.inventory.ItemStack
import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
import kotlin.math.min
object CustomRecipeUtil {
@ -32,7 +33,7 @@ object CustomRecipeUtil {
return if(recipe.exactCount) {
if(leftItem.amount != recipe.leftItem!!.amount){
0
}else if(rightItem != null && rightItem.amount != recipe.rightItem!!.amount){
}else if(!rightItem.isAir && rightItem!!.amount != recipe.rightItem!!.amount){
0
}else{
1
@ -43,7 +44,7 @@ object CustomRecipeUtil {
val resultItem = recipe.resultItem!! // we know exist as the recipe was returned to us
val maxResultAmount = resultItem.maxStackSize/resultItem.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")