diff --git a/assets/mods/basegame/crafting/blocks.json b/assets/mods/basegame/crafting/blocks.json index c99cada07..5480a0db0 100644 --- a/assets/mods/basegame/crafting/blocks.json +++ b/assets/mods/basegame/crafting/blocks.json @@ -2,31 +2,31 @@ "basegame:160": { "workbench": "", "ingredients": [ - [4, 2, "$ROCK"] + [2, 1, "$ROCK"] ] }, "basegame:161": { "workbench": "", "ingredients": [ - [4, 2, "basegame:48"] + [2, 1, "basegame:48"] ] }, "basegame:162": { "workbench": "", "ingredients": [ - [4, 2, "basegame:49"] + [2, 1, "basegame:49"] ] }, "basegame:163": { "workbench": "", "ingredients": [ - [4, 2, "basegame:50"] + [2, 1, "basegame:50"] ] }, "basegame:164": { "workbench": "", "ingredients": [ - [4, 2, "basegame:51"] + [2, 1, "basegame:51"] ] } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/itemproperties/CraftingCodex.kt b/src/net/torvald/terrarum/itemproperties/CraftingCodex.kt index 51b12366a..fe45e8ee8 100644 --- a/src/net/torvald/terrarum/itemproperties/CraftingCodex.kt +++ b/src/net/torvald/terrarum/itemproperties/CraftingCodex.kt @@ -12,6 +12,16 @@ class CraftingCodex { @Transient internal val props = HashMap>() // the key ItemID and value.product must be equal + fun addRecipe(recipe: CraftingRecipe) { + val product = recipe.product + if (props.containsKey(product)) { + props[product]?.add(recipe) + } + else { + props[product] = arrayListOf(recipe) + } + } + fun addFromJson(json: JsonValue, moduleName: String, fileName:String) { if (moduleName.filter { it.code in 33..127 } .length < 5) diff --git a/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt b/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt index 7a3eebe2a..6bafc6e54 100644 --- a/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt +++ b/src/net/torvald/terrarum/modulebasegame/EntryPoint.kt @@ -6,6 +6,7 @@ import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.blockproperties.BlockProp import net.torvald.terrarum.gameactors.ActorWithBody import net.torvald.terrarum.gameitems.GameItem +import net.torvald.terrarum.itemproperties.CraftingCodex import net.torvald.terrarum.modulebasegame.gameitems.BlockBase import net.torvald.terrarum.modulebasegame.imagefont.WatchFont import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack @@ -42,7 +43,7 @@ class EntryPoint : ModuleEntryPoint() { ModMgr.GameCraftingRecipeLoader.invoke(moduleName) println("Crafting Recipes: ") - Terrarum.craftingCodex.props.forEach { item, recipes -> + CraftingRecipeCodex.props.forEach { item, recipes -> println("$item ->") recipes.forEach { print(" ") @@ -71,6 +72,19 @@ class EntryPoint : ModuleEntryPoint() { } } + // crafting recipes: tile -> 2x wall + BlockCodex.getAll().filter { it.isWallable && it.isSolid && !it.isActorBlock }.forEach { tile -> + CraftingRecipeCodex.addRecipe(CraftingCodex.CraftingRecipe( + "", + arrayOf(CraftingCodex.CraftingIngredients( + tile.id, CraftingCodex.CraftingItemKeyMode.VERBATIM, 1 + )), + 2, + "wall@"+tile.id, + moduleName + )) + } + println("\n[Basegame.EntryPoint] Welcome back!") }