Skip to content

Commit

Permalink
Added recipes for filters
Browse files Browse the repository at this point in the history
Added new item Ragi-Ticket
  • Loading branch information
Hiiragi283 committed Nov 18, 2024
1 parent d2a4224 commit d515ebb
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/main/generated/assets/ragium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"item.ragium.pulp": "Pulp",
"item.ragium.ragi_alloy_compound": "Ragi-Alloy Compound",
"item.ragium.ragi_crystal_processor": "Ragi-Crystal Processor",
"item.ragium.ragi_ticket": "Ragi-Ticket",
"item.ragium.refined_silicon": "Refined Silicon",
"item.ragium.residual_coke": "Residual Coke",
"item.ragium.silicon": "Silicon",
Expand Down
1 change: 1 addition & 0 deletions src/main/generated/assets/ragium/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"item.ragium.pulp": "パルプ",
"item.ragium.ragi_alloy_compound": "ラギ合金混合物",
"item.ragium.ragi_crystal_processor": "ラギクリスタリルプロセッサ",
"item.ragium.ragi_ticket": "らぎチケット",
"item.ragium.refined_silicon": "精製シリコン",
"item.ragium.residual_coke": "残渣油コークス",
"item.ragium.silicon": "シリコン",
Expand Down
6 changes: 6 additions & 0 deletions src/main/generated/assets/ragium/models/item/ragi_ticket.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "ragium:item/ragi_ticket"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_the_item": {
"conditions": {
"items": [
{
"items": "minecraft:paper"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "ragium:shapeless/fluid_filter"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_the_item"
]
],
"rewards": {
"recipes": [
"ragium:shapeless/fluid_filter"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_the_item": {
"conditions": {
"items": [
{
"items": "minecraft:paper"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "ragium:shapeless/item_filter"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_the_item"
]
],
"rewards": {
"recipes": [
"ragium:shapeless/item_filter"
]
}
}
19 changes: 19 additions & 0 deletions src/main/generated/data/ragium/recipe/shapeless/fluid_filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "minecraft:paper"
},
{
"tag": "c:dyes/light_blue"
},
{
"tag": "c:dusts/raginite"
}
],
"result": {
"count": 1,
"id": "ragium:fluid_filter"
}
}
19 changes: 19 additions & 0 deletions src/main/generated/data/ragium/recipe/shapeless/item_filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "minecraft:paper"
},
{
"tag": "c:dyes/orange"
},
{
"tag": "c:dusts/raginite"
}
],
"result": {
"count": 1,
"id": "ragium:item_filter"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ fun <T : Any> RegistryEntry<T>.isOf(value: T): Boolean = value() == value

operator fun <T : Any> RegistryEntryList<T>.contains(value: T): Boolean = any { it.isOf(value) }

fun <T : Any> RegistryEntryList<T>.asText(mapper: (T) -> Text): Text = storage.map(
{ it.name },
{ Texts.join(this.map(RegistryEntry<T>::value), mapper) },
)
fun <T : Any> RegistryEntryList<T>.asText(mapper: (T) -> Text): MutableText = storage
.map(
{ it.name },
{ Texts.join(this.map(RegistryEntry<T>::value), mapper) },
).copy()

// ScreenHandler //

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package hiiragi283.ragium.api.recipe

import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import hiiragi283.ragium.api.extension.contains
import hiiragi283.ragium.api.extension.isOf
import hiiragi283.ragium.api.extension.longRangeCodec
import hiiragi283.ragium.api.extension.useTransaction
import hiiragi283.ragium.api.extension.*
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil
Expand All @@ -23,6 +20,7 @@ import net.minecraft.registry.RegistryKeys
import net.minecraft.registry.entry.RegistryEntry
import net.minecraft.registry.entry.RegistryEntryList
import net.minecraft.registry.tag.TagKey
import net.minecraft.text.MutableText
import java.util.function.BiPredicate

class HTFluidIngredient private constructor(private val entryList: RegistryEntryList<Fluid>, val amount: Long) : BiPredicate<Fluid, Long> {
Expand Down Expand Up @@ -69,6 +67,9 @@ class HTFluidIngredient private constructor(private val entryList: RegistryEntry

fun <T : Any> map(transform: (RegistryEntry<Fluid>, Long) -> T): List<T> = entryList.map { transform(it, amount) }

val text: MutableText
get() = entryList.asText(Fluid::name)

val firstEntry: RegistryEntry<Fluid>?
get() = entryList.firstOrNull()

Expand Down Expand Up @@ -101,4 +102,6 @@ class HTFluidIngredient private constructor(private val entryList: RegistryEntry
}
}
}

override fun toString(): String = "HTFluidIngredient[entryList=${text.string},amount=$amount]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import net.minecraft.registry.RegistryKeys
import net.minecraft.registry.entry.RegistryEntry
import net.minecraft.registry.entry.RegistryEntryList
import net.minecraft.registry.tag.TagKey
import net.minecraft.text.MutableText
import net.minecraft.util.StringIdentifiable
import java.util.function.Predicate

Expand Down Expand Up @@ -75,6 +76,9 @@ class HTItemIngredient private constructor(private val entryList: RegistryEntryL

fun <T : Any> map(transform: (RegistryEntry<Item>, Int) -> T): List<T> = entryList.map { transform(it, count) }

val text: MutableText
get() = entryList.asText(Item::getName)

val firstEntry: RegistryEntry<Item>?
get() = entryList.firstOrNull()

Expand All @@ -83,6 +87,9 @@ class HTItemIngredient private constructor(private val entryList: RegistryEntryL
val valueMap: Map<Item, Int>
get() = entryMap.mapKeys { it.key.value() }

val matchingStacks: List<ItemStack>
get() = valueMap.map { (item: Item, count: Int) -> ItemStack(item, count) }

override fun test(stack: ItemStack): Boolean = when (stack.isEmpty) {
true -> this.isEmpty
false -> stack.isIn(entryList) && stack.count >= count
Expand All @@ -103,7 +110,7 @@ class HTItemIngredient private constructor(private val entryList: RegistryEntryL
}
}

override fun toString(): String = "HTItemIngredient[entryList=${entryList.asText(Item::getName)},count=$count]"
override fun toString(): String = "HTItemIngredient[entryList=${text.string},count=$count]"

// ConsumeType //

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class HTExporterBlockEntity(pos: BlockPos, state: BlockState) :
this.tier = tier
}

private var fluidFilter: RegistryEntryList<Fluid> = RegistryEntryList.empty()
private var itemFilter: RegistryEntryList<Item> = RegistryEntryList.empty()
var fluidFilter: RegistryEntryList<Fluid> = RegistryEntryList.empty()
var itemFilter: RegistryEntryList<Item> = RegistryEntryList.empty()

override fun writeNbt(nbt: NbtCompound, wrapperLookup: RegistryWrapper.WrapperLookup) {
super.writeNbt(nbt, wrapperLookup)
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/hiiragi283/ragium/common/init/RagiumItems.kt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ object RagiumItems {
@JvmField
val RAGI_CRYSTAL_PROCESSOR: Item = Item(itemSettings())

@JvmField
val RAGI_TICKET: Item = Item(itemSettings().rarity(Rarity.EPIC))

@JvmField
val REFINED_SILICON: Item = Item(itemSettings())

Expand Down Expand Up @@ -387,6 +390,7 @@ object RagiumItems {
PROCESSOR_SOCKET,
RAGI_ALLOY_COMPOUND,
RAGI_CRYSTAL_PROCESSOR,
RAGI_TICKET,
REFINED_SILICON,
RESIDUAL_COKE,
SILICON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ internal object RagiumContentRegister {
registerItem("processor_socket", RagiumItems.PROCESSOR_SOCKET)
registerItem("ragi_alloy_compound", RagiumItems.RAGI_ALLOY_COMPOUND)
registerItem("ragi_crystal_processor", RagiumItems.RAGI_CRYSTAL_PROCESSOR)
registerItem("ragi_ticket", RagiumItems.RAGI_TICKET)
registerItem("refined_silicon", RagiumItems.REFINED_SILICON)
registerItem("residual_coke", RagiumItems.RESIDUAL_COKE)
registerItem("silicon", RagiumItems.SILICON)
Expand Down
34 changes: 18 additions & 16 deletions src/main/kotlin/hiiragi283/ragium/data/RagiumLangProviders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ object RagiumLangProviders {
builder.add(RagiumItems.PROCESSOR_SOCKET, "Processor Socket")
builder.add(RagiumItems.RAGI_ALLOY_COMPOUND, "Ragi-Alloy Compound")
builder.add(RagiumItems.RAGI_CRYSTAL_PROCESSOR, "Ragi-Crystal Processor")
builder.add(RagiumItems.RAGI_TICKET, "Ragi-Ticket")
builder.add(RagiumItems.REFINED_SILICON, "Refined Silicon")
builder.add(RagiumItems.RESIDUAL_COKE, "Residual Coke")
builder.add(RagiumItems.SILICON, "Silicon")
Expand Down Expand Up @@ -468,22 +469,6 @@ object RagiumLangProviders {
builder.add(RagiumBlocks.TELEPORT_ANCHOR, "テレポートアンカー")
builder.add(RagiumBlocks.TRASH_BOX, "ゴミ箱")

builder.add(RagiumItems.STEEL_HELMET, "スチールのヘルメット")
builder.add(RagiumItems.STEEL_CHESTPLATE, "スチールのチェストプレート")
builder.add(RagiumItems.STEEL_LEGGINGS, "スチールのレギンス")
builder.add(RagiumItems.STEEL_BOOTS, "スチールのブーツ")
builder.add(RagiumItems.STELLA_GOGGLE, "S.T.E.L.L.A.ゴーグル")
builder.add(RagiumItems.STELLA_JACKET, "S.T.E.L.L.A.ジャケット")
builder.add(RagiumItems.STELLA_LEGGINGS, "S.T.E.L.L.A.レギンス")
builder.add(RagiumItems.STELLA_BOOTS, "S.T.E.L.L.A.ブーツ")

builder.add(RagiumItems.STEEL_AXE, "スチールの斧")
builder.add(RagiumItems.STEEL_HOE, "スチールのクワ")
builder.add(RagiumItems.STEEL_PICKAXE, "スチールのツルハシ")
builder.add(RagiumItems.STEEL_SHOVEL, "スチールのショベル")
builder.add(RagiumItems.STEEL_SWORD, "スチールの剣")
builder.add(RagiumItems.BUJIN, "武刃")

builder.add(RagiumContents.Pipes.IRON, "鉄パイプ")
builder.add(RagiumContents.Pipes.WOODEN, "木製パイプ")
builder.add(RagiumContents.Pipes.STEEL, "鋼鉄パイプ")
Expand All @@ -504,6 +489,22 @@ object RagiumLangProviders {
builder.add(RagiumEnchantments.SLEDGE_HAMMER, "粉砕")
builder.add(RagiumEnchantments.BUZZ_SAW, "製材")
// Items
builder.add(RagiumItems.STEEL_HELMET, "スチールのヘルメット")
builder.add(RagiumItems.STEEL_CHESTPLATE, "スチールのチェストプレート")
builder.add(RagiumItems.STEEL_LEGGINGS, "スチールのレギンス")
builder.add(RagiumItems.STEEL_BOOTS, "スチールのブーツ")
builder.add(RagiumItems.STELLA_GOGGLE, "S.T.E.L.L.A.ゴーグル")
builder.add(RagiumItems.STELLA_JACKET, "S.T.E.L.L.A.ジャケット")
builder.add(RagiumItems.STELLA_LEGGINGS, "S.T.E.L.L.A.レギンス")
builder.add(RagiumItems.STELLA_BOOTS, "S.T.E.L.L.A.ブーツ")

builder.add(RagiumItems.STEEL_AXE, "スチールの斧")
builder.add(RagiumItems.STEEL_HOE, "スチールのクワ")
builder.add(RagiumItems.STEEL_PICKAXE, "スチールのツルハシ")
builder.add(RagiumItems.STEEL_SHOVEL, "スチールのショベル")
builder.add(RagiumItems.STEEL_SWORD, "スチールの剣")
builder.add(RagiumItems.BUJIN, "武刃")

builder.add(RagiumItems.BEE_WAX, "蜜蠟")
builder.add(RagiumItems.BUTTER, "バター")
builder.add(RagiumItems.CARAMEL, "キャラメル")
Expand Down Expand Up @@ -535,6 +536,7 @@ object RagiumLangProviders {
builder.add(RagiumItems.PROCESSOR_SOCKET, "プロセッサソケット")
builder.add(RagiumItems.RAGI_ALLOY_COMPOUND, "ラギ合金混合物")
builder.add(RagiumItems.RAGI_CRYSTAL_PROCESSOR, "ラギクリスタリルプロセッサ")
builder.add(RagiumItems.RAGI_TICKET, "らぎチケット")
builder.add(RagiumItems.REFINED_SILICON, "精製シリコン")
builder.add(RagiumItems.RESIDUAL_COKE, "残渣油コークス")
builder.add(RagiumItems.SILICON, "シリコン")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ class RagiumVanillaRecipeProvider(output: FabricDataOutput, registriesFuture: Co
.input('B', ConventionalItemTags.WOODEN_RODS)
.unlockedBy(RagiumContents.Gems.RAGIUM)
.offerTo(exporter)
// filter
HTShapelessRecipeJsonBuilder
.create(RagiumItems.FLUID_FILTER)
.input(Items.PAPER)
.input(ConventionalItemTags.LIGHT_BLUE_DYES)
.input(RagiumContents.Dusts.RAGINITE)
.unlockedBy(Items.PAPER)
.offerTo(exporter)

HTShapelessRecipeJsonBuilder
.create(RagiumItems.ITEM_FILTER)
.input(Items.PAPER)
.input(ConventionalItemTags.ORANGE_DYES)
.input(RagiumContents.Dusts.RAGINITE)
.unlockedBy(Items.PAPER)
.offerTo(exporter)
// steel
HTShapedRecipeJsonBuilder
.create(RagiumItems.STEEL_SWORD)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d515ebb

Please sign in to comment.