mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
Compare commits
No commits in common. "b2567f9176eb469c4d2314147f62e645c5a50bc2" and "845bb4d94aec68350214bd60acab0447c939fe94" have entirely different histories.
b2567f9176
...
845bb4d94a
4 changed files with 9 additions and 17 deletions
|
|
@ -55,7 +55,7 @@ dependencies {
|
|||
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
||||
|
||||
// fast stats
|
||||
implementation("dev.faststats.metrics:bukkit:0.29.0")
|
||||
implementation("dev.faststats.metrics:bukkit:0.27.2")
|
||||
|
||||
// minimessage
|
||||
implementation("net.kyori:adventure-text-minimessage:4.25.0")
|
||||
|
|
|
|||
|
|
@ -216,10 +216,10 @@ class AnvilResultListener : Listener {
|
|||
val recipe = result.recipe!!
|
||||
|
||||
// We remove what should be removed
|
||||
if (!rightItem.isAir) {
|
||||
if (recipe.rightItem.isAir) return false// in case it changed
|
||||
if (rightItem != null) {
|
||||
if (recipe.rightItem == null) return false// in case it changed
|
||||
|
||||
rightItem!!.amount -= amount * recipe.rightItem!!.amount
|
||||
rightItem.amount -= amount * recipe.rightItem!!.amount
|
||||
inventory.setItem(ANVIL_INPUT_RIGHT, rightItem)
|
||||
}
|
||||
|
||||
|
|
@ -247,8 +247,6 @@ class AnvilResultListener : Listener {
|
|||
|
||||
player.updateInventory()
|
||||
}
|
||||
|
||||
handleAnvilMechanic(player, inventory)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +359,7 @@ class AnvilResultListener : Listener {
|
|||
}
|
||||
|
||||
if (event.click != ClickType.MIDDLE)
|
||||
handleAnvilMechanic(player, inventory)
|
||||
handleAnvilMechanic(player, inventory, player.gameMode != GameMode.CREATIVE)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
@ -390,11 +388,6 @@ class AnvilResultListener : Listener {
|
|||
}
|
||||
}
|
||||
|
||||
// Process both sound & degradation
|
||||
private fun handleAnvilMechanic(player: HumanEntity, inventory: AnvilInventory) {
|
||||
return handleAnvilMechanic(player, inventory, player.gameMode != GameMode.CREATIVE)
|
||||
}
|
||||
|
||||
// Process both sound & degradation
|
||||
private fun handleAnvilMechanic(player: HumanEntity, inventory: AnvilInventory, canDegrade: Boolean) {
|
||||
// ok so we do not provide a getLocation on view ?
|
||||
|
|
|
|||
|
|
@ -176,8 +176,8 @@ class AnvilCustomRecipe(
|
|||
CustomAnvil.verboseLog("Left item passed !")
|
||||
|
||||
// we don't know if right item can be
|
||||
if (rightItem.isAir) { // null test
|
||||
if (!item2.isAir) return false
|
||||
if (rightItem == null) { // null test
|
||||
if (item2 != null) return false
|
||||
} else {
|
||||
val rightSimilar = rightItem!!.isSimilar(item2)
|
||||
CustomAnvil.verboseLog("Right similar: $rightSimilar")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ 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 {
|
||||
|
|
@ -33,7 +32,7 @@ object CustomRecipeUtil {
|
|||
return if(recipe.exactCount) {
|
||||
if(leftItem.amount != recipe.leftItem!!.amount){
|
||||
0
|
||||
}else if(!rightItem.isAir && rightItem!!.amount != recipe.rightItem!!.amount){
|
||||
}else if(rightItem != null && rightItem.amount != recipe.rightItem!!.amount){
|
||||
0
|
||||
}else{
|
||||
1
|
||||
|
|
@ -44,7 +43,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.isAir){ maxLeftAmount } else{ rightItem!!.amount/recipe.rightItem!!.amount }
|
||||
val maxRightAmount = if(rightItem == null){ maxLeftAmount } else{ rightItem.amount/recipe.rightItem!!.amount }
|
||||
|
||||
CustomAnvil.verboseLog("resultItem: $resultItem, maxResultAmount: $maxResultAmount, maxLeftAmount: $maxLeftAmount, maxRightAmount: $maxRightAmount")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue