Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions system/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -279,28 +279,28 @@ class RecipesInteractor(
}

recipe.craftEngineRecipe != null -> {
val craftEngineRecipe = BukkitCraftEngine.instance().recipeManager<ItemStack>().recipeById(recipe.craftEngineRecipe.id()).get()
val craftEngineRecipe = BukkitCraftEngine.instance().recipeManager().recipeById(recipe.craftEngineRecipe.id()).get()

when(craftEngineRecipe) {
is CustomShapedRecipe<*> -> {
is CustomShapedRecipe -> {
val ingredients = mutableMapOf<Char, ItemStack>()
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
}

presenter.setShapedRecipe(craftEngineRecipe.pattern().pattern(), ingredients)
}

is CustomShapelessRecipe<*> -> {
is CustomShapelessRecipe -> {
updateCraftEngineShapelessRecipe(craftEngineRecipe)
}

is CustomSmithingTransformRecipe<*> -> {
is CustomSmithingTransformRecipe -> {

// craftEngineRecipe.ingredientsInUse().forEach {
// it.items().forEach {
Expand All @@ -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<ItemStack>()
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)
}

Expand Down Expand Up @@ -375,4 +375,4 @@ class RecipesInteractor(
}
}

data class DudeRecipe(val vanillaRecipe: Recipe? = null, val craftEngineRecipe: CustomItem<ItemStack>? = null)
data class DudeRecipe(val vanillaRecipe: Recipe? = null, val craftEngineRecipe: BukkitItemDefinition? = null)