From 0708e533eb8ba114ba3830650ab5745bf4cf0e72 Mon Sep 17 00:00:00 2001 From: jhqwqmc Date: Sun, 17 May 2026 22:21:54 +0800 Subject: [PATCH] Compatible with the latest version of CraftEngine --- system/build.gradle.kts | 4 ++-- .../system/products/recipe/RecipesBlock.kt | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/system/build.gradle.kts b/system/build.gradle.kts index 28f3231..54617c0 100644 --- a/system/build.gradle.kts +++ b/system/build.gradle.kts @@ -28,8 +28,8 @@ dependencies { //Plugins compileOnly("me.clip:placeholderapi:2.11.6") compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") - compileOnly("net.momirealms:craft-engine-core:0.0.67") - compileOnly("net.momirealms:craft-engine-bukkit:0.0.67") + compileOnly("net.momirealms:craft-engine-core:26.5") + compileOnly("net.momirealms:craft-engine-bukkit:26.5") //Dagger implementation("com.google.dagger:dagger:2.56.2") diff --git a/system/src/main/kotlin/com/mcmlr/system/products/recipe/RecipesBlock.kt b/system/src/main/kotlin/com/mcmlr/system/products/recipe/RecipesBlock.kt index 2eec0f7..48d87c3 100644 --- a/system/src/main/kotlin/com/mcmlr/system/products/recipe/RecipesBlock.kt +++ b/system/src/main/kotlin/com/mcmlr/system/products/recipe/RecipesBlock.kt @@ -10,8 +10,8 @@ import com.mcmlr.blocks.api.views.ViewContainer import com.mcmlr.blocks.core.bolden import com.mcmlr.blocks.core.fromMCItem import net.momirealms.craftengine.bukkit.api.CraftEngineItems +import net.momirealms.craftengine.bukkit.item.BukkitItemDefinition import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine -import net.momirealms.craftengine.core.item.CustomItem import net.momirealms.craftengine.core.item.recipe.CustomShapedRecipe import net.momirealms.craftengine.core.item.recipe.CustomShapelessRecipe import net.momirealms.craftengine.core.item.recipe.CustomSmithingTransformRecipe @@ -62,7 +62,7 @@ class RecipesViewController( val item = when { recipe.vanillaRecipe != null -> recipe.vanillaRecipe.result - recipe.craftEngineRecipe != null -> recipe.craftEngineRecipe.buildItemStack() + recipe.craftEngineRecipe != null -> recipe.craftEngineRecipe.buildBukkitItem() else -> null } @@ -279,16 +279,16 @@ class RecipesInteractor( } recipe.craftEngineRecipe != null -> { - val craftEngineRecipe = BukkitCraftEngine.instance().recipeManager().recipeById(recipe.craftEngineRecipe.id()).get() + val craftEngineRecipe = BukkitCraftEngine.instance().recipeManager().recipeById(recipe.craftEngineRecipe.id()).get() when(craftEngineRecipe) { - is CustomShapedRecipe<*> -> { + is CustomShapedRecipe -> { val ingredients = mutableMapOf() craftEngineRecipe.pattern().ingredients().forEach { val key = it.key val value = it.value val ingredient = if (value.items().isNotEmpty()) value.items().first() else value.minecraftItems().firstOrNull() ?: return@forEach - val item = BukkitCraftEngine.instance().itemManager().buildItemStack(ingredient.key(), null) ?: return@forEach + val item = CraftEngineItems.byId(ingredient.key())?.buildBukkitItem() ?: return@forEach ingredients[key] = item } @@ -296,11 +296,11 @@ class RecipesInteractor( presenter.setShapedRecipe(craftEngineRecipe.pattern().pattern(), ingredients) } - is CustomShapelessRecipe<*> -> { + is CustomShapelessRecipe -> { updateCraftEngineShapelessRecipe(craftEngineRecipe) } - is CustomSmithingTransformRecipe<*> -> { + is CustomSmithingTransformRecipe -> { // craftEngineRecipe.ingredientsInUse().forEach { // it.items().forEach { @@ -319,11 +319,11 @@ class RecipesInteractor( } } - private fun updateCraftEngineShapelessRecipe(recipe: net.momirealms.craftengine.core.item.recipe.Recipe<*>) { + private fun updateCraftEngineShapelessRecipe(recipe: net.momirealms.craftengine.core.item.recipe.Recipe) { val ingredients = mutableListOf() recipe.ingredientsInUse().forEach { val ingredient = if (it.items().isNotEmpty()) it.items().first() else it.minecraftItems().firstOrNull() ?: return@forEach - val item = CraftEngineItems.byId(ingredient.key())?.buildItemStack() ?: return@forEach + val item = CraftEngineItems.byId(ingredient.key())?.buildBukkitItem() ?: return@forEach ingredients.add(item) } @@ -375,4 +375,4 @@ class RecipesInteractor( } } -data class DudeRecipe(val vanillaRecipe: Recipe? = null, val craftEngineRecipe: CustomItem? = null) +data class DudeRecipe(val vanillaRecipe: Recipe? = null, val craftEngineRecipe: BukkitItemDefinition? = null)