Skip to content
2 changes: 1 addition & 1 deletion src/api/kotlin/hiiragi283/ragium/api/RagiumAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object RagiumAPI {
* 名前空間が`ragium`となる[ResourceLocation]を返します。
*/
@JvmStatic
fun id(prefix: String, suffix: String): ResourceLocation = id("$prefix/$suffix")
fun id(vararg path: String): ResourceLocation = MOD_ID.toId(*path)

/**
* 名前空間が`ragium`となる[ResourceLocation]を返します。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import hiiragi283.ragium.api.registry.impl.HTDeferredFluid
import hiiragi283.ragium.api.registry.impl.HTDeferredFluidType
import hiiragi283.ragium.api.registry.impl.HTDeferredItem
import hiiragi283.ragium.api.registry.impl.HTDeferredOnlyBlock
import hiiragi283.ragium.api.tag.createTagKey
import hiiragi283.ragium.api.tag.createCommonTag
import net.minecraft.core.registries.Registries
import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.TagKey
Expand Down Expand Up @@ -45,10 +45,10 @@ data class HTFluidContent<
type,
still,
flowing,
Registries.FLUID.createTagKey(commonId(still.id.path)),
Registries.FLUID.createCommonTag(still.id.path),
block,
bucket,
Registries.ITEM.createTagKey(commonId("buckets", still.id.path)),
Registries.ITEM.createCommonTag("buckets", still.id.path),
)

fun getType(): TYPE = type.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fun String.toId(path: String): ResourceLocation = ResourceLocation.fromNamespace
/**
* この文字列を名前空間として[ResourceLocation]を返します。
*/
fun String.toId(prefix: String, value: String): ResourceLocation = this.toId("$prefix/$value")
fun String.toId(vararg path: String): ResourceLocation = this.toId(path.joinToString(separator = "/"))

/**
* 名前空間が`minecraft`となる[ResourceLocation]を返します。
Expand All @@ -25,7 +25,7 @@ fun vanillaId(path: String): ResourceLocation = ResourceLocation.withDefaultName
/**
* 名前空間が`minecraft`となる[ResourceLocation]を返します。
*/
fun vanillaId(prefix: String, value: String): ResourceLocation = ResourceLocation.withDefaultNamespace("$prefix/$value")
fun vanillaId(vararg path: String): ResourceLocation = ResourceLocation.withDefaultNamespace(path.joinToString(separator = "/"))

/**
* 名前空間が`c`となる[ResourceLocation]を返します。
Expand All @@ -35,7 +35,7 @@ fun commonId(path: String): ResourceLocation = RagiumConst.COMMON.toId(path)
/**
* 名前空間が`c`となる[ResourceLocation]を返します。
*/
fun commonId(prefix: String, value: String): ResourceLocation = commonId("$prefix/$value")
fun commonId(vararg path: String): ResourceLocation = RagiumConst.COMMON.toId(*path)

/**
* この[ResourceKey]から翻訳キーに変換します。
Expand Down
9 changes: 6 additions & 3 deletions src/api/kotlin/hiiragi283/ragium/api/tag/RagiumCommonTags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ object RagiumCommonTags {
val COAL_COKE: TagKey<Item> = create("coal_coke")

@JvmField
val BREAD_SLICES_WHEAT: TagKey<Item> = create("bread_slices/wheat")
val BREAD_SLICES_WHEAT: TagKey<Item> = create("bread_slices", "wheat")

@JvmField
val FUELS_BIO: TagKey<Item> = create("fuels/bio")
val FUELS_BIO: TagKey<Item> = create("fuels", "bio")

@JvmField
val FUELS_BIO_BLOCK: TagKey<Item> = create("fuels/block/bio")
val FUELS_BIO_BLOCK: TagKey<Item> = create("fuels", "block", "bio")

@JvmField
val ORES_IN_GROUND_END_STONE: TagKey<Item> = create("ores_in_ground", "end_stone")
Expand All @@ -53,6 +53,9 @@ object RagiumCommonTags {
@JvmStatic
private fun create(path: String): TagKey<Item> = Registries.ITEM.createCommonTag(path)

@JvmStatic
private fun create(vararg path: String): TagKey<Item> = Registries.ITEM.createCommonTag(*path)

@JvmStatic
private fun create(prefix: String, value: String): TagKey<Item> = Registries.ITEM.createCommonTag(prefix, value)
}
Expand Down
3 changes: 0 additions & 3 deletions src/api/kotlin/hiiragi283/ragium/api/tag/RagiumModTags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ object RagiumModTags {
// Items //

object Items {
@JvmField
val BUDDING_AZURE_ACTIVATOR: TagKey<Item> = create("budding_azure_activator")

@JvmField
val BYPASS_MENU_VALIDATION: TagKey<Item> = create("bypass_menu_validation")

Expand Down
2 changes: 1 addition & 1 deletion src/api/kotlin/hiiragi283/ragium/api/tag/TagKeys.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fun <T : Any> RegistryKey<T>.createCommonTag(path: String): TagKey<T> = createTa
/**
* [RegistryKey]に基づいて名前空間が`c`となる[TagKey]に変換します。
*/
fun <T : Any> RegistryKey<T>.createCommonTag(prefix: String, value: String): TagKey<T> = createTagKey(commonId(prefix, value))
fun <T : Any> RegistryKey<T>.createCommonTag(vararg path: String): TagKey<T> = createTagKey(commonId(*path))

/**
* [TagKey]の名前を返します。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ enum class RagiumTranslation(type: String, vararg path: String) : HTTranslation

// Item Description
TOOLTIP_BLOCK_POS("tooltip", "block_pos"),
TOOLTIP_CHARGE_POWER("tooltip", "blast_power"),
TOOLTIP_DIMENSION("tooltip", "dimension"),
TOOLTIP_INTRINSIC_ENCHANTMENT("tooltip", "intrinsic_enchantment"),
TOOLTIP_LOOT_TABLE_ID("tooltip", "loot_table_id"),
TOOLTIP_BLAST_POWER("tooltip", "blast_power"),

TOOLTIP_SHOW_DESCRIPTION("tooltip", "show_description"),
TOOLTIP_SHOW_DETAILS("tooltip", "show_details"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import hiiragi283.ragium.common.material.MekanismMaterialPrefixes
import hiiragi283.ragium.common.material.VanillaMaterialKeys

object HTMaterialTranslations {
@JvmField
val DEFAULT_PREFIX_PATTERN = HTSimpleLangPattern("%s", "%s")

@JvmField
val PREFIX_MAP: Map<HTMaterialPrefix, HTLangPatternProvider> = buildMap {
fun register(prefix: HTPrefixLike, enPattern: String, jaPattern: String) {
Expand All @@ -26,7 +29,6 @@ object HTMaterialTranslations {
register(CommonMaterialPrefixes.RAW_STORAGE_BLOCK, "Block of Raw %s", "%sの原石ブロック")
// Item
register(CommonMaterialPrefixes.DUST, "%s Dust", "%sの粉")
register(CommonMaterialPrefixes.GEM, "%s", "%s")
register(CommonMaterialPrefixes.GEAR, "%s Gear", "%sの歯車")
register(CommonMaterialPrefixes.INGOT, "%s Ingot", "%sインゴット")
register(CommonMaterialPrefixes.NUGGET, "%s Nugget", "%sナゲット")
Expand Down Expand Up @@ -72,7 +74,7 @@ object HTMaterialTranslations {
if (customName != null) {
return customName.getTranslatedName(type)
} else {
val translation: HTLangPatternProvider = PREFIX_MAP[prefix] ?: return null
val translation: HTLangPatternProvider = PREFIX_MAP[prefix] ?: DEFAULT_PREFIX_PATTERN
val translatedName: HTLangName = getLangName(key) ?: return null
return translation.translate(type, translatedName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import hiiragi283.ragium.api.registry.toId
import hiiragi283.ragium.common.material.CommonMaterialPrefixes
import hiiragi283.ragium.common.material.VanillaMaterialKeys
import hiiragi283.ragium.common.recipe.HTClearComponentRecipe
import hiiragi283.ragium.common.tier.HTComponentTier
import hiiragi283.ragium.impl.data.recipe.HTComplexRecipeBuilder
import hiiragi283.ragium.impl.data.recipe.HTItemToChancedItemRecipeBuilder
import hiiragi283.ragium.impl.data.recipe.HTItemToObjRecipeBuilder
import hiiragi283.ragium.impl.data.recipe.HTItemWithCatalystRecipeBuilder
import hiiragi283.ragium.impl.data.recipe.HTItemWithFluidToChancedItemRecipeBuilder
import hiiragi283.ragium.impl.data.recipe.HTShapelessRecipeBuilder
import hiiragi283.ragium.impl.data.recipe.HTSmithingRecipeBuilder
import hiiragi283.ragium.setup.RagiumItems
import net.minecraft.advancements.Advancement
import net.minecraft.advancements.AdvancementHolder
import net.minecraft.core.HolderLookup
Expand All @@ -31,17 +30,32 @@ import net.minecraft.data.recipes.RecipeOutput
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.Items
import net.minecraft.world.item.crafting.CraftingBookCategory
import net.minecraft.world.item.crafting.Ingredient
import net.minecraft.world.item.crafting.Recipe
import net.minecraft.world.level.ItemLike
import net.neoforged.neoforge.common.conditions.ICondition
import net.neoforged.neoforge.common.conditions.ModLoadedCondition
import net.neoforged.neoforge.common.conditions.NotCondition
import net.neoforged.neoforge.common.conditions.OrCondition

/**
* Ragiumがレシピ生成で使用するクラス
* @see Direct
* @see Integration
*/
sealed class HTRecipeProvider {
companion object {
@JvmField
val FOOD_MOD_CONDITION: ICondition = NotCondition(
OrCondition(
listOf(
ModLoadedCondition(RagiumConst.FARMERS_DELIGHT),
ModLoadedCondition(RagiumConst.KALEIDO_COOKERY),
),
),
)
}

protected lateinit var provider: HolderLookup.Provider
private set
protected lateinit var output: RecipeOutput
Expand Down Expand Up @@ -111,10 +125,10 @@ sealed class HTRecipeProvider {
val namespace: String = id.namespace
return if (namespace in RagiumConst.BUILTIN_IDS) {
val path: List<String> = id.path.split("/", limit = 2)
return RagiumAPI.id(path[0] + "/$modid/" + path[1])
return RagiumAPI.id(path[0], modid, path[1])
} else {
val path: List<String> = id.path.split("/", limit = 2)
RagiumAPI.id(path[0] + "/$namespace/" + path[1])
RagiumAPI.id(path[0], namespace, path[1])
}
}

Expand Down Expand Up @@ -233,18 +247,6 @@ sealed class HTRecipeProvider {
.addIngredient(input)
.addIngredient(CommonMaterialPrefixes.INGOT, VanillaMaterialKeys.NETHERITE)

/**
* 指定された引数から鍛冶台での強化レシピのビルダーを返します。
* @param tier アップグレードにつかう構造体のティア
* @param output 強化後のアイテム
* @param input 強化前のアイテム
*/
protected fun createComponentUpgrade(tier: HTComponentTier, output: ItemLike, input: ItemLike): HTSmithingRecipeBuilder =
HTSmithingRecipeBuilder
.create(output)
.addIngredient(RagiumItems.getComponent(tier))
.addIngredient(input)

/**
* 指定された[HTWoodType]に基づいて,木材の製材レシピを追加します。
*/
Expand Down Expand Up @@ -282,6 +284,17 @@ sealed class HTRecipeProvider {
).saveModified(output, data.operator)
}

protected fun mixFromData(data: HTRecipeData) {
val builder: HTComplexRecipeBuilder = HTComplexRecipeBuilder.mixing()
// Inputs
data.getItemIngredients(itemCreator).forEach(builder::addIngredient)
data.getFluidIngredients(fluidCreator).forEach(builder::addIngredient)
// Outputs
builder.setResult(data.getItemResults().getOrNull(0)?.first)
builder.setResult(data.getFluidResults().getOrNull(0))
builder.saveModified(output, data.operator)
}

protected fun cropAndSeed(seed: ItemLike, crop: ItemLike, water: Int = 125) {
HTItemWithFluidToChancedItemRecipeBuilder
.planting(
Expand All @@ -305,4 +318,34 @@ sealed class HTRecipeProvider {
.addResult(resultHelper.item(sapling), 1 / 6f)
.save(output)
}

protected fun tree(
sapling: ItemLike,
log: ItemLike,
fruit: ItemLike,
fluid: HTFluidIngredient = fluidCreator.water(250),
) {
HTItemWithFluidToChancedItemRecipeBuilder
.planting(
itemCreator.fromItem(sapling),
fluid,
).addResult(resultHelper.item(log, 6))
.addResult(resultHelper.item(sapling), 1 / 6f)
.addResult(resultHelper.item(fruit), 1 / 6f)
.save(output)
}

protected fun cutAndCombine(hole: ItemLike, slice: ItemLike, count: Int) {
// Cutting
HTShapelessRecipeBuilder
.misc(slice, count)
.addIngredient(hole)
.addCondition(FOOD_MOD_CONDITION)
.saveSuffixed(output, "_from_hole")
// Combining
HTShapelessRecipeBuilder
.misc(hole)
.addIngredients(Ingredient.of(slice), count)
.saveSuffixed(output, "_from_pieces")
}
}
Loading