From 09295df82fce2a691c4eba6798e827cd15b2017e Mon Sep 17 00:00:00 2001 From: AshuraV1 Date: Wed, 2 Sep 2026 16:10:48 +0300 Subject: [PATCH 1/2] feat: extract suspicious stew effects --- .../com/steelextractor/SteelExtractor.kt | 2 + .../extractors/SuspiciousStewEffects.kt | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt diff --git a/src/main/kotlin/com/steelextractor/SteelExtractor.kt b/src/main/kotlin/com/steelextractor/SteelExtractor.kt index 8c6e07f..6075f27 100644 --- a/src/main/kotlin/com/steelextractor/SteelExtractor.kt +++ b/src/main/kotlin/com/steelextractor/SteelExtractor.kt @@ -42,6 +42,7 @@ import com.steelextractor.extractors.PoiTypesExtractor import com.steelextractor.extractors.Potions import com.steelextractor.extractors.StatTypeRegistryExtractor import com.steelextractor.extractors.StructureStarts +import com.steelextractor.extractors.SuspiciousStewEffects import com.steelextractor.extractors.Tags import com.steelextractor.extractors.Waxables import kotlinx.io.IOException @@ -218,6 +219,7 @@ object SteelExtractor : ModInitializer { addUnlessDisabled("BLOCK_ENTITIES") { BlockEntities() } addUnlessDisabled("DATA_COMPONENTS") { DataComponents() } addUnlessDisabled("ITEMS") { Items() } + addUnlessDisabled("SUSPICIOUS_STEW_EFFECTS") { SuspiciousStewEffects() } addUnlessDisabled("PARTICLE_TYPES") { ParticleTypeRegistryExtractor() } addUnlessDisabled("POSITION_SOURCE_TYPES") { PositionSourceTypeRegistryExtractor() } addUnlessDisabled("VILLAGER_TYPES") { VillagerTypeRegistryExtractor() } diff --git a/src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt b/src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt new file mode 100644 index 0000000..ceeb608 --- /dev/null +++ b/src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt @@ -0,0 +1,43 @@ +package com.steelextractor.extractors + +import com.google.gson.JsonArray +import com.google.gson.JsonElement +import com.google.gson.JsonObject +import com.steelextractor.SteelExtractor +import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.server.MinecraftServer +import net.minecraft.world.level.block.SuspiciousEffectHolder + +/** Extracts the effect lists returned by vanilla `SuspiciousEffectHolder` items. */ +class SuspiciousStewEffects : SteelExtractor.Extractor { + override fun fileName(): String { + return "steel-registry/build_assets/suspicious_stew_effects.json" + } + + override fun extract(server: MinecraftServer): JsonElement { + val holders = JsonArray() + + for (item in BuiltInRegistries.ITEM) { + val effects = SuspiciousEffectHolder.tryGet(item) ?: continue + val itemKey = BuiltInRegistries.ITEM.getKey(item) + val holderJson = JsonObject() + holderJson.addProperty("item", itemKey.toString()) + + val effectJson = JsonArray() + for (entry in effects.suspiciousEffects.effects()) { + val effectKey = entry.effect() + .unwrapKey() + .orElseThrow { IllegalStateException("suspicious stew effect has no registry key") } + .identifier() + val entryJson = JsonObject() + entryJson.addProperty("effect", effectKey.toString()) + entryJson.addProperty("duration", entry.duration()) + effectJson.add(entryJson) + } + holderJson.add("effects", effectJson) + holders.add(holderJson) + } + + return holders + } +} From 1f01ff06aea04de21b8b20fa0f0a66a410cc83b1 Mon Sep 17 00:00:00 2001 From: AshuraV1 Date: Thu, 10 Sep 2026 14:47:39 +0300 Subject: [PATCH 2/2] refactor: use Vanilla SuspiciousStewEffects.CODEC for serialization --- .../extractors/SuspiciousStewEffects.kt | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt b/src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt index ceeb608..2d7ab2e 100644 --- a/src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt +++ b/src/main/kotlin/com/steelextractor/extractors/SuspiciousStewEffects.kt @@ -3,9 +3,12 @@ package com.steelextractor.extractors import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonObject +import com.mojang.serialization.JsonOps import com.steelextractor.SteelExtractor import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.resources.RegistryOps import net.minecraft.server.MinecraftServer +import net.minecraft.world.item.component.SuspiciousStewEffects as VanillaSuspiciousStewEffects import net.minecraft.world.level.block.SuspiciousEffectHolder /** Extracts the effect lists returned by vanilla `SuspiciousEffectHolder` items. */ @@ -15,26 +18,20 @@ class SuspiciousStewEffects : SteelExtractor.Extractor { } override fun extract(server: MinecraftServer): JsonElement { + val registryOps = RegistryOps.create(JsonOps.INSTANCE, server.registryAccess()) val holders = JsonArray() for (item in BuiltInRegistries.ITEM) { - val effects = SuspiciousEffectHolder.tryGet(item) ?: continue + val effectHolder = SuspiciousEffectHolder.tryGet(item) ?: continue val itemKey = BuiltInRegistries.ITEM.getKey(item) val holderJson = JsonObject() holderJson.addProperty("item", itemKey.toString()) - val effectJson = JsonArray() - for (entry in effects.suspiciousEffects.effects()) { - val effectKey = entry.effect() - .unwrapKey() - .orElseThrow { IllegalStateException("suspicious stew effect has no registry key") } - .identifier() - val entryJson = JsonObject() - entryJson.addProperty("effect", effectKey.toString()) - entryJson.addProperty("duration", entry.duration()) - effectJson.add(entryJson) - } - holderJson.add("effects", effectJson) + val effectsJson = VanillaSuspiciousStewEffects.CODEC + .encodeStart(registryOps, effectHolder.suspiciousEffects) + .getOrThrow() + + holderJson.add("effects", effectsJson) holders.add(holderJson) }