From ffbdb60ca465803cd6e5f61e8c1527be99de4555 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 2 Mar 2025 13:35:50 +0300 Subject: [PATCH 01/37] Update NodeNBTUtil: remove debug logging. --- .../org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt index 7a86fd1..3557ad0 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt @@ -28,7 +28,6 @@ object NodeNBTUtil { if (gasResourceLocation == "KelvinTemperature") continue val gasType = GasTypeRegistry.GAS_TYPES[ResourceLocation(gasResourceLocation)] ?: continue - println("$gasResourceLocation $gasType ${tag.getDouble(gasResourceLocation)}") network.modGasMass(pos,gasType,tag.getDouble(gasResourceLocation)) } network.modTemperature(pos, temperature) From 80d03dd48e98e17363247abae89f95b247498b3b Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 2 Mar 2025 14:28:09 +0300 Subject: [PATCH 02/37] Implement GasReaction Recipe and data loading --- .../org/valkyrienskies/kelvin/KelvinMod.kt | 8 +- .../valkyrienskies/kelvin/api/GasReaction.kt | 6 ++ .../kelvin/api/GasReactionRequirement.kt | 11 +++ .../kelvin/impl/DefaultKelvinRequirements.kt | 51 +++++++++++ .../kelvin/impl/KelvinReactionDataLoader.kt | 87 +++++++++++++++++++ .../impl/ReactionRequirementRegistry.kt | 30 +++++++ .../kelvin/kelvin_reactions/test_recipe.json | 12 +++ .../kelvin/fabric/KelvinModFabric.kt | 36 ++++++++ .../kelvin/forge/KelvinModForge.kt | 14 ++- 9 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/ReactionRequirementRegistry.kt create mode 100644 common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt index 332a646..ba5f6cf 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt @@ -5,19 +5,20 @@ import dev.architectury.event.events.client.ClientPlayerEvent import dev.architectury.event.events.client.ClientTickEvent import dev.architectury.event.events.common.ChunkEvent import dev.architectury.event.events.common.LifecycleEvent -import dev.architectury.event.events.common.PlayerEvent import dev.architectury.event.events.common.TickEvent import dev.architectury.networking.simple.SimpleNetworkManager import dev.architectury.platform.Platform import dev.architectury.utils.Env import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.nbt.CompoundTag +import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.chunk.ChunkAccess import org.valkyrienskies.kelvin.api.DuctNetwork import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.impl.DuctNetworkServer import org.valkyrienskies.kelvin.impl.GasTypeRegistry +import org.valkyrienskies.kelvin.impl.ReactionRequirementRegistry import org.valkyrienskies.kelvin.impl.client.DuctNetworkClient import org.valkyrienskies.kelvin.impl.logger import org.valkyrienskies.kelvin.networking.KelvinNetworking @@ -111,6 +112,7 @@ object KelvinMod { KELVINLOGGER.info("Registering gas types...") GasTypeRegistry.init() + ReactionRequirementRegistry.init() KELVINLOGGER.info("--- --- ---") KELVINLOGGER.info("Finished registering gas types. We have ${GasTypeRegistry.GAS_TYPES.size} gasses registered!") @@ -149,4 +151,8 @@ object KelvinMod { } return KelvinClient } + + fun asResouceLocation(string: String): ResourceLocation { + return ResourceLocation("${MOD_ID}:$string") + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt new file mode 100644 index 0000000..4a0000c --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt @@ -0,0 +1,6 @@ +package org.valkyrienskies.kelvin.api + +import com.google.gson.JsonElement + +data class GasReaction(val gasses : HashMap, val requirements: HashMap, val result: HashMap) + diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt new file mode 100644 index 0000000..0ea235b --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt @@ -0,0 +1,11 @@ +package org.valkyrienskies.kelvin.api + +import com.google.gson.JsonElement +import net.minecraft.resources.ResourceLocation +import java.util.logging.Level + +abstract class GasReactionRequirement(val resourceLocation: ResourceLocation) { + + abstract fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean + +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt new file mode 100644 index 0000000..62dbcbe --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt @@ -0,0 +1,51 @@ +package org.valkyrienskies.kelvin.impl + +import com.google.gson.JsonElement +import org.valkyrienskies.kelvin.KelvinMod +import org.valkyrienskies.kelvin.api.DuctNetwork +import org.valkyrienskies.kelvin.api.DuctNodePos +import org.valkyrienskies.kelvin.api.GasReactionRequirement +import java.util.logging.Level + +object DefaultKelvinRequirements { + val defaultRequirements = listOf(minTemperature, maxTemperature, minPressure, maxPressure) + + object minTemperature: GasReactionRequirement(KelvinMod.asResouceLocation("min_temperature")) { + override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + val doubleValue = value.asDouble + + val temperature = network.getTemperatureAt(ductNode) + return temperature >= doubleValue + } + } + + object maxTemperature: GasReactionRequirement(KelvinMod.asResouceLocation("max_temperature")) { + override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + val doubleValue = value.asDouble + + val temperature = network.getTemperatureAt(ductNode) + return temperature <= doubleValue + } + } + + object minPressure: GasReactionRequirement(KelvinMod.asResouceLocation("min_pressure")) { + override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + val doubleValue = value.asDouble + + val pressure = network.getPressureAt(ductNode) + return pressure >= doubleValue + } + } + + object maxPressure: GasReactionRequirement(KelvinMod.asResouceLocation("max_pressure")) { + override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + val doubleValue = value.asDouble + + val pressure = network.getPressureAt(ductNode) + return pressure <= doubleValue + } + } +} + + + diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt new file mode 100644 index 0000000..0c4d530 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt @@ -0,0 +1,87 @@ +package org.valkyrienskies.kelvin.impl + +import com.google.gson.Gson +import com.google.gson.JsonElement +import net.minecraft.resources.ResourceLocation +import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener +import net.minecraft.server.packs.resources.ResourceManager +import net.minecraft.util.profiling.ProfilerFiller +import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER +import org.valkyrienskies.kelvin.api.GasReaction +import org.valkyrienskies.kelvin.api.GasReactionRequirement +import org.valkyrienskies.kelvin.api.GasType + +object KelvinReactionDataLoader { + private val gas_reactions = hashMapOf() + val loader get() = KelvinReactionDataLoader() + + class KelvinReactionDataLoader : SimpleJsonResourceReloadListener(Gson(), "kelvin_reactions") { + + override fun apply( + objects: MutableMap, + resourceManager: ResourceManager, + profiler: ProfilerFiller + ) { + println("Applying Data loader") + gas_reactions.clear() + objects.forEach { (location, element) -> + try { + if (element.isJsonArray) { + element.asJsonArray.forEach { element1: JsonElement -> + parse(element1, location) + } + } else if (element.isJsonObject) { + parse(element, location) + } else throw IllegalArgumentException() + } catch (e: Exception) { + KELVINLOGGER.error(e) + } + } + } + + private fun parse(element: JsonElement, origin: ResourceLocation) { + val jObject = element.asJsonObject + + val gasses = HashMap() + val requirements = HashMap() + val result = HashMap() + + for (entry in jObject["gasses"].asJsonObject.entrySet()) { + val gasType = GasTypeRegistry.getGasType(ResourceLocation(entry.key)) ?: return KELVINLOGGER.error("Invalid gasType '${entry.key}' in gas reaction in file '$origin'. Ignoring reaction") + val gasParts: Int + try { + gasParts = entry.value.asInt + } catch (e: Exception) { + return KELVINLOGGER.error("Invalid gasType Int '${entry.value}' in gas reaction in file '$origin'. Ignoring reaction") + } + + gasses[gasType] = gasParts + } + + for (entry in jObject["requirements"].asJsonObject.entrySet()) { + val reactionRequirement = ReactionRequirementRegistry.getReactionRequirement(ResourceLocation(entry.key)) ?: return KELVINLOGGER.error("Invalid reaction requirement '${entry.key}' in in file '$origin'. Ignoring reaction") + + requirements[reactionRequirement] = entry.value + } + + for (entry in jObject["result"].asJsonObject.entrySet()) { + val gasType = GasTypeRegistry.getGasType(ResourceLocation(entry.key)) ?: return KELVINLOGGER.error("Invalid gasType result'${entry.key}' in gas reaction in file '$origin'. Ignoring reaction") + val gasParts: Int + try { + gasParts = entry.value.asInt + } catch (e: Exception) { + return KELVINLOGGER.error("Invalid gasType result Int '${entry.value}' in gas reaction in file '$origin'. Ignoring reaction") + } + + result[gasType] = gasParts + } + + val parsed_reaction = GasReaction(gasses, requirements, result) + println(parsed_reaction) + gas_reactions[origin] = parsed_reaction + + } + } + + +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/ReactionRequirementRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/ReactionRequirementRegistry.kt new file mode 100644 index 0000000..8d9f326 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/ReactionRequirementRegistry.kt @@ -0,0 +1,30 @@ +package org.valkyrienskies.kelvin.impl + +import net.minecraft.resources.ResourceLocation +import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER +import org.valkyrienskies.kelvin.api.GasReactionRequirement + +object ReactionRequirementRegistry { + val REACTION_REQUIREMENTS = mutableMapOf() + + fun registerReactionRequirement(resourceLocation: ResourceLocation, reactionRequirement: GasReactionRequirement) { + REACTION_REQUIREMENTS[resourceLocation] = reactionRequirement + } + + fun registerReactionRequirement(reactionRequirement: GasReactionRequirement) { + KELVINLOGGER.info("Registering reaction requirement ${reactionRequirement.resourceLocation}") + registerReactionRequirement(reactionRequirement.resourceLocation, reactionRequirement) + } + + fun getReactionRequirement(resourceLocation: ResourceLocation): GasReactionRequirement? { + return REACTION_REQUIREMENTS[resourceLocation] + } + + fun getReactionRequirement(modid: String, name: String): GasReactionRequirement? { + return getReactionRequirement(ResourceLocation(modid, name)) + } + + fun init () { + for (requirement in DefaultKelvinRequirements.defaultRequirements) registerReactionRequirement(requirement) + } +} \ No newline at end of file diff --git a/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json new file mode 100644 index 0000000..6f57753 --- /dev/null +++ b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json @@ -0,0 +1,12 @@ +{ + "gasses": { + "kelvin:methane": 1 + }, + "requirements": { + "kelvin:min_temperature": 800, + "kelvin:min_pressure": 1000 + }, + "result": { + "kelvin:air": 10 + } +} \ No newline at end of file diff --git a/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt b/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt index 3516a76..615b816 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt @@ -7,14 +7,26 @@ import net.fabricmc.api.EnvType import net.fabricmc.api.Environment import net.fabricmc.api.ModInitializer import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents +import net.fabricmc.fabric.api.resource.ResourceManagerHelper +import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod +import org.valkyrienskies.kelvin.impl.KelvinReactionDataLoader import org.valkyrienskies.kelvin.util.KelvinChunkPos +import net.minecraft.server.packs.PackType.SERVER_DATA +import net.minecraft.server.packs.resources.PreparableReloadListener +import java.util.concurrent.CompletableFuture +import net.minecraft.server.packs.resources.ResourceManager +import net.minecraft.util.profiling.ProfilerFiller +import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener +import java.util.concurrent.Executor + object KelvinModFabric: ModInitializer { override fun onInitialize() { init() + ServerChunkEvents.CHUNK_LOAD.register { serverWorld, chunk -> try { KelvinMod.getKelvin().markChunkLoaded(KelvinChunkPos(chunk.pos.x, chunk.pos.z, serverWorld.dimension().location())) @@ -32,8 +44,32 @@ object KelvinModFabric: ModInitializer { KelvinMod.KELVINLOGGER.error(e.stackTrace) } } + + + val loader = KelvinReactionDataLoader.loader // the get makes a new instance so get it only once + ResourceManagerHelper.get(SERVER_DATA) + .registerReloadListener(object : IdentifiableResourceReloadListener { + override fun getFabricId(): ResourceLocation { + return ResourceLocation(KelvinMod.MOD_ID, "kelvin_reactions") + } + + override fun reload( + stage: PreparableReloadListener.PreparationBarrier, + resourceManager: ResourceManager, + preparationsProfiler: ProfilerFiller, + reloadProfiler: ProfilerFiller, + backgroundExecutor: Executor, + gameExecutor: Executor + ): CompletableFuture { + return loader.reload( + stage, resourceManager, preparationsProfiler, reloadProfiler, + backgroundExecutor, gameExecutor + ) + } + }) } + @Environment(EnvType.CLIENT) class Client : ClientModInitializer { override fun onInitializeClient() { diff --git a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt index c1e4396..cf29922 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt @@ -1,6 +1,7 @@ package org.valkyrienskies.kelvin.forge import net.minecraft.server.level.ServerLevel +import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.common.Mod @@ -8,7 +9,9 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.init import org.valkyrienskies.kelvin.KelvinMod.initClient +import org.valkyrienskies.kelvin.impl.KelvinReactionDataLoader import org.valkyrienskies.kelvin.util.KelvinChunkPos +import thedarkcolour.kotlinforforge.forge.FORGE_BUS import thedarkcolour.kotlinforforge.forge.MOD_BUS @Mod(KelvinMod.MOD_ID) @@ -21,7 +24,7 @@ class KelvinModForge { } init() - MOD_BUS.addListener { event: ChunkEvent.Load -> + FORGE_BUS.addListener { event: ChunkEvent.Load -> if (!event.world.isClientSide) { try { KelvinMod.getKelvin().markChunkLoaded( @@ -38,7 +41,7 @@ class KelvinModForge { } } - MOD_BUS.addListener { event: ChunkEvent.Unload -> + FORGE_BUS.addListener { event: ChunkEvent.Unload -> if (!event.world.isClientSide) { try { KelvinMod.getKelvin().markChunkUnloaded( @@ -54,6 +57,13 @@ class KelvinModForge { } } } + + FORGE_BUS.addListener(::registerResourceManagers) + } + + private fun registerResourceManagers(event: AddReloadListenerEvent) { + event.addListener(KelvinReactionDataLoader.loader) + } private fun clientSetup(event: FMLClientSetupEvent?) { From ccd2a0980cf7ddce1fdc88d443d9293fbf3cdd55 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 2 Mar 2025 15:05:35 +0300 Subject: [PATCH 03/37] Implement recipe checking into tick function --- .../kelvin/api/GasReactionRequirement.kt | 5 +- .../kelvin/impl/DefaultKelvinRequirements.kt | 11 ++-- .../kelvin/impl/DuctNetworkServer.kt | 50 +++++++++++++++++-- .../kelvin/impl/KelvinReactionDataLoader.kt | 2 +- .../kelvin/kelvin_reactions/test_recipe.json | 3 +- 5 files changed, 59 insertions(+), 12 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt index 0ea235b..86140be 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt @@ -2,10 +2,11 @@ package org.valkyrienskies.kelvin.api import com.google.gson.JsonElement import net.minecraft.resources.ResourceLocation -import java.util.logging.Level +import net.minecraft.world.level.Level + abstract class GasReactionRequirement(val resourceLocation: ResourceLocation) { - abstract fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean + abstract fun apply_requirement(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean } \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt index 62dbcbe..fcaf48c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt @@ -1,26 +1,27 @@ package org.valkyrienskies.kelvin.impl import com.google.gson.JsonElement +import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.DuctNetwork import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.api.GasReactionRequirement -import java.util.logging.Level object DefaultKelvinRequirements { val defaultRequirements = listOf(minTemperature, maxTemperature, minPressure, maxPressure) object minTemperature: GasReactionRequirement(KelvinMod.asResouceLocation("min_temperature")) { - override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + override fun apply_requirement(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { val doubleValue = value.asDouble val temperature = network.getTemperatureAt(ductNode) return temperature >= doubleValue } + } object maxTemperature: GasReactionRequirement(KelvinMod.asResouceLocation("max_temperature")) { - override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + override fun apply_requirement(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { val doubleValue = value.asDouble val temperature = network.getTemperatureAt(ductNode) @@ -29,7 +30,7 @@ object DefaultKelvinRequirements { } object minPressure: GasReactionRequirement(KelvinMod.asResouceLocation("min_pressure")) { - override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + override fun apply_requirement(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { val doubleValue = value.asDouble val pressure = network.getPressureAt(ductNode) @@ -38,7 +39,7 @@ object DefaultKelvinRequirements { } object maxPressure: GasReactionRequirement(KelvinMod.asResouceLocation("max_pressure")) { - override fun apply(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { + override fun apply_requirement(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean { val doubleValue = value.asDouble val pressure = network.getPressureAt(ductNode) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index fbf53c2..db3b0f4 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -1,7 +1,6 @@ package org.valkyrienskies.kelvin.impl import net.minecraft.core.BlockPos -import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer @@ -15,9 +14,7 @@ import org.valkyrienskies.kelvin.api.DuctNetwork.Companion.idealGasConstant import org.valkyrienskies.kelvin.api.edges.* import org.valkyrienskies.kelvin.api.nodes.TankDuctNode import org.valkyrienskies.kelvin.impl.client.ClientKelvinInfo -import org.valkyrienskies.kelvin.networking.KelvinNetworking import org.valkyrienskies.kelvin.networking.KelvinSyncPacket -import org.valkyrienskies.kelvin.serialization.SerializableDuctNetwork import org.valkyrienskies.kelvin.util.* import org.valkyrienskies.kelvin.util.KelvinExtensions.toChunkPos import org.valkyrienskies.kelvin.util.KelvinExtensions.toMinecraft @@ -569,6 +566,53 @@ class DuctNetworkServer( val info = ClientKelvinInfo(HashMap(nodeInfo.filter { it.key.toChunkPos() == request.second })) sync(level, info, true, request.first) } + + + val reactions = KelvinReactionDataLoader.gas_reactions + // Process recipes + for (node in dimensionNodes) { + val gasMasses = getGasMassAt(node) + if (gasMasses.size == 0) continue + + for (reaction in reactions.values) { + var con = false + reaction.requirements.forEach {if (!it.key.apply_requirement(level, node, this, it.value)) { con = true + return@forEach + }} + if (con) continue + + + calcReaction(node, gasMasses, reaction.gasses, reaction.result) + } + } + } + + private fun calcReaction(ductNodePos: DuctNodePos, gasMasses: HashMap, inputGasses: HashMap, outputGasses: HashMap) { + var totalInputGas = 0 + var totalOutputGas = 0 + + for (gas in inputGasses) { + totalInputGas += gas.value + } + + for (gas in outputGasses) { + totalOutputGas += gas.value + } + + var possibleReaction = Double.MAX_VALUE + + for (gas in inputGasses) { + if (gas.key !in gasMasses) return + + val thisReaction = totalOutputGas * gasMasses[gas.key]!! * totalInputGas / gas.value + if (thisReaction < possibleReaction) possibleReaction = thisReaction + } + + for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-possibleReaction * totalInputGas / gas.value) + + + for (gas in outputGasses) modGasMass(ductNodePos,gas.key,possibleReaction * gas.value / totalOutputGas) + } /** diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt index 0c4d530..157eede 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt @@ -12,7 +12,7 @@ import org.valkyrienskies.kelvin.api.GasReactionRequirement import org.valkyrienskies.kelvin.api.GasType object KelvinReactionDataLoader { - private val gas_reactions = hashMapOf() + val gas_reactions = hashMapOf() val loader get() = KelvinReactionDataLoader() class KelvinReactionDataLoader : SimpleJsonResourceReloadListener(Gson(), "kelvin_reactions") { diff --git a/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json index 6f57753..18af6b0 100644 --- a/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json +++ b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json @@ -1,6 +1,7 @@ { "gasses": { - "kelvin:methane": 1 + "kelvin:methane": 1, + "kelvin:air": 2 }, "requirements": { "kelvin:min_temperature": 800, From 70266714babfa36b76c21fd4b61b468809684c99 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 2 Mar 2025 15:21:03 +0300 Subject: [PATCH 04/37] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 99222e0..e632b2e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M # Identity mod_name=Kelvin mod_id=kelvin -mod_version=0.1.1 +mod_version=0.1.4 mod_description=A dynamic gas framework for Minecraft. mod_license=Apache-2.0 mod_author=ThePlasticPotato, PriestOfFern From ecf8490aa6dabe364391e1f5f4e4ec0f94503e02 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 2 Mar 2025 15:34:40 +0300 Subject: [PATCH 05/37] redo formular for reaction calc --- .../kelvin/impl/DuctNetworkServer.kt | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index db3b0f4..fe812be 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -7,7 +7,6 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.util.Mth import net.minecraft.world.entity.player.Player import net.minecraft.world.level.Explosion -import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.api.* import org.valkyrienskies.kelvin.api.DuctNetwork.Companion.idealGasConstant @@ -588,30 +587,22 @@ class DuctNetworkServer( } private fun calcReaction(ductNodePos: DuctNodePos, gasMasses: HashMap, inputGasses: HashMap, outputGasses: HashMap) { - var totalInputGas = 0 - var totalOutputGas = 0 + val gasMoles = HashMap() - for (gas in inputGasses) { - totalInputGas += gas.value - } + for (gas in gasMasses) gasMoles[gas.key] = (gas.value/gas.key.density)/22.4 - for (gas in outputGasses) { - totalOutputGas += gas.value - } - - var possibleReaction = Double.MAX_VALUE + var possibleOutput = Double.MAX_VALUE for (gas in inputGasses) { - if (gas.key !in gasMasses) return + if (gas.key !in gasMoles) return - val thisReaction = totalOutputGas * gasMasses[gas.key]!! * totalInputGas / gas.value - if (thisReaction < possibleReaction) possibleReaction = thisReaction + val thisOutput = gasMoles[gas.key]!! / gas.value + if (thisOutput < possibleOutput) possibleOutput = thisOutput } - for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-possibleReaction * totalInputGas / gas.value) - + for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-possibleOutput * gas.value * gas.key.density * 22.4) - for (gas in outputGasses) modGasMass(ductNodePos,gas.key,possibleReaction * gas.value / totalOutputGas) + for (gas in outputGasses) modGasMass(ductNodePos,gas.key,possibleOutput * gas.value * gas.key.density * 22.4) } From 7a4045aebba76e0c523cfdabc5fd4987dca59ed0 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 2 Mar 2025 15:53:31 +0300 Subject: [PATCH 06/37] fix infinite gas generation from reaction --- .../valkyrienskies/kelvin/impl/DuctNetworkServer.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index fe812be..075f7b2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -591,18 +591,18 @@ class DuctNetworkServer( for (gas in gasMasses) gasMoles[gas.key] = (gas.value/gas.key.density)/22.4 - var possibleOutput = Double.MAX_VALUE + var reaction_moles = Double.MAX_VALUE for (gas in inputGasses) { - if (gas.key !in gasMoles) return + if (gas.key !in gasMoles || gasMoles[gas.key]!! < 0.001) return val thisOutput = gasMoles[gas.key]!! / gas.value - if (thisOutput < possibleOutput) possibleOutput = thisOutput + if (thisOutput < reaction_moles) reaction_moles = thisOutput } - for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-possibleOutput * gas.value * gas.key.density * 22.4) + for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-reaction_moles * gas.value * gas.key.density * 22.4) - for (gas in outputGasses) modGasMass(ductNodePos,gas.key,possibleOutput * gas.value * gas.key.density * 22.4) + for (gas in outputGasses) modGasMass(ductNodePos,gas.key,reaction_moles * gas.value * gas.key.density * 22.4) } From a467fa1153e5b53e484c1495959636c1e0d63375 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 2 Mar 2025 16:05:27 +0300 Subject: [PATCH 07/37] logging --- .../valkyrienskies/kelvin/impl/DuctNetworkServer.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index 075f7b2..ec78920 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -591,18 +591,20 @@ class DuctNetworkServer( for (gas in gasMasses) gasMoles[gas.key] = (gas.value/gas.key.density)/22.4 - var reaction_moles = Double.MAX_VALUE + var reactionMoles = Double.MAX_VALUE + + if (inputGasses.size == 0) return KELVINLOGGER.error("empty inputGasses in gas reaction.") for (gas in inputGasses) { if (gas.key !in gasMoles || gasMoles[gas.key]!! < 0.001) return val thisOutput = gasMoles[gas.key]!! / gas.value - if (thisOutput < reaction_moles) reaction_moles = thisOutput + if (thisOutput < reactionMoles) reactionMoles = thisOutput } - for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-reaction_moles * gas.value * gas.key.density * 22.4) + for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-reactionMoles * gas.value * gas.key.density * 22.4) - for (gas in outputGasses) modGasMass(ductNodePos,gas.key,reaction_moles * gas.value * gas.key.density * 22.4) + for (gas in outputGasses) modGasMass(ductNodePos,gas.key,reactionMoles * gas.value * gas.key.density * 22.4) } From 661413735d4bd37fea9248bbc386aa90dac394ac Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 16 Mar 2025 10:20:11 +0300 Subject: [PATCH 08/37] Add JEI to gradle --- common/build.gradle | 21 +++++++++++++++++++++ fabric/build.gradle | 22 ++++++++++++++++++++++ forge/build.gradle | 22 ++++++++++++++++++++++ gradle.properties | 1 + 4 files changed, 66 insertions(+) diff --git a/common/build.gradle b/common/build.gradle index da22eac..5a6f082 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -6,6 +6,24 @@ loom { accessWidenerPath = file("src/main/resources/kelvin.accesswidener") } +repositories { + maven { + // location of the maven that hosts JEI files before January 2023 + name = "Progwml6's maven" + url = "https://dvs1.progwml6.com/files/maven/" + } + maven { + // location of the maven that hosts JEI files since January 2023 + name = "Jared's maven" + url = "https://maven.blamejared.com/" + } + maven { + // location of a maven mirror for JEI files, as a fallback + name = "ModMaven" + url = "https://modmaven.dev" + } +} + dependencies { // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // Do NOT use other classes from fabric loader @@ -14,6 +32,9 @@ dependencies { // Architectury API modApi "dev.architectury:architectury:${rootProject.architectury_version}" + // JEI + modCompileOnly "mezz.jei:jei-${rootProject.minecraft_version}-common-api:${jei_version}" + api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10" api "org.jetbrains.kotlin:kotlin-reflect:1.9.10" } diff --git a/fabric/build.gradle b/fabric/build.gradle index e47ea49..f973548 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -23,6 +23,24 @@ configurations { developmentFabric.extendsFrom common } +repositories { + maven { + // location of the maven that hosts JEI files before January 2023 + name = "Progwml6's maven" + url = "https://dvs1.progwml6.com/files/maven/" + } + maven { + // location of the maven that hosts JEI files since January 2023 + name = "Jared's maven" + url = "https://maven.blamejared.com/" + } + maven { + // location of a maven mirror for JEI files, as a fallback + name = "ModMaven" + url = "https://modmaven.dev" + } +} + dependencies { modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" @@ -37,6 +55,10 @@ dependencies { // Architectury API include(modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}") + //JEI + modCompileOnly "mezz.jei:jei-${rootProject.minecraft_version}-fabric-api:${rootProject.jei_version}" + modRuntimeOnly "mezz.jei:jei-${rootProject.minecraft_version}-fabric:${rootProject.jei_version}" + // Mod menu modImplementation("com.terraformersmc:modmenu:3.2.3") modImplementation("me.shedaniel.cloth:cloth-config:${cloth_config_version}") { diff --git a/forge/build.gradle b/forge/build.gradle index 861138a..c038387 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -48,6 +48,10 @@ dependencies { // Architectury API include(modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}") + //JEI + modCompileOnly "mezz.jei:jei-${rootProject.minecraft_version}-forge-api:${rootProject.jei_version}" + modRuntimeOnly "mezz.jei:jei-${rootProject.minecraft_version}-forge:${rootProject.jei_version}" + common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } @@ -55,6 +59,24 @@ dependencies { implementation "thedarkcolour:kotlinforforge:$forge_kotlin_version" } +repositories { + maven { + // location of the maven that hosts JEI files before January 2023 + name = "Progwml6's maven" + url = "https://dvs1.progwml6.com/files/maven/" + } + maven { + // location of the maven that hosts JEI files since January 2023 + name = "Jared's maven" + url = "https://maven.blamejared.com/" + } + maven { + // location of a maven mirror for JEI files, as a fallback + name = "ModMaven" + url = "https://modmaven.dev" + } +} + processResources { inputs.property "version", project.version diff --git a/gradle.properties b/gradle.properties index e632b2e..9cbf6cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,6 +24,7 @@ forge_version=1.18.2-40.2.4 forge_kotlin_version=3.12.0 kotlin_version=1.9.10 cloth_config_version=6.4.90 +jei_version=10.2.1.1009 # Maven publishing vs_maven_url= vs_maven_username= From d2bdbe37b89059cab4b1e3a13d66d25395bcf06d Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 16 Mar 2025 10:51:42 +0300 Subject: [PATCH 09/37] Make KelvinJeiPlugin --- .../kelvin/integration/jei/KelvinJeiPlugin.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt new file mode 100644 index 0000000..d2675c0 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt @@ -0,0 +1,20 @@ +package org.valkyrienskies.kelvin.integration.jei + +import mezz.jei.api.IModPlugin +import mezz.jei.api.JeiPlugin +import mezz.jei.api.registration.IModIngredientRegistration +import net.minecraft.resources.ResourceLocation +import org.valkyrienskies.kelvin.KelvinMod +import org.valkyrienskies.kelvin.KelvinMod.MOD_ID + + +@JeiPlugin +class KelvinJeiPlugin: IModPlugin { + override fun getPluginUid(): ResourceLocation { + return KelvinMod.asResouceLocation("jei_plugin") + } + + override fun registerIngredients(registration: IModIngredientRegistration) { + + } +} \ No newline at end of file From bc63cf4c5d60b5b5c6a366dda1c6911e560bfabd Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 16 Mar 2025 12:25:03 +0300 Subject: [PATCH 10/37] implemented GasType JEI ingredient --- .../org/valkyrienskies/kelvin/api/GasType.kt | 2 +- .../kelvin/integration/jei/KelvinJeiPlugin.kt | 72 ++++++++++++++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt index 7e27a59..49d4957 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt @@ -22,6 +22,6 @@ data class GasType( ) { override fun toString(): String { val iconLoc = iconLocation?.toString() ?: "null" - return "$name, $density, $viscosity, $specificHeatCapacity, $thermalConductivity, $sutherlandConstant, $adiabaticIndex, $combustible, $calorificValue, $iconLoc" + return "{$name, $density, $viscosity, $specificHeatCapacity, $thermalConductivity, $sutherlandConstant, $adiabaticIndex, $combustible, $calorificValue, $iconLoc}" } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt index d2675c0..476cee6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt @@ -1,11 +1,25 @@ package org.valkyrienskies.kelvin.integration.jei +import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.IModPlugin import mezz.jei.api.JeiPlugin +import mezz.jei.api.ingredients.IIngredientHelper +import mezz.jei.api.ingredients.IIngredientRenderer +import mezz.jei.api.ingredients.IIngredientType +import mezz.jei.api.ingredients.IIngredientTypeWithSubtypes +import mezz.jei.api.ingredients.subtypes.UidContext import mezz.jei.api.registration.IModIngredientRegistration +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.TextComponent import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.TooltipFlag import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.MOD_ID +import org.valkyrienskies.kelvin.api.GasType +import org.valkyrienskies.kelvin.impl.GasTypeRegistry @JeiPlugin @@ -15,6 +29,62 @@ class KelvinJeiPlugin: IModPlugin { } override fun registerIngredients(registration: IModIngredientRegistration) { + val gasTypes = GasTypeRegistry.GAS_TYPES.values + + + registration.register(GasIngredientType(), gasTypes, GasIngredientHelper(), GasIngredientRenderer()) + } + + + + class GasIngredientType: IIngredientType { + override fun getIngredientClass(): Class { + return GasType::class.java + } + } + + class GasIngredientHelper: IIngredientHelper { + override fun getIngredientType(): IIngredientType { + return GasIngredientType() + } + + override fun getErrorInfo(ingredient: GasType?): String { + return ingredient?.toString() ?: "Null Kelvin GasType" + } + + override fun copyIngredient(ingredient: GasType): GasType { + return ingredient + } + + override fun getResourceId(ingredient: GasType): String { + return ingredient.resourceLocation.path + } + + override fun getModId(ingredient: GasType): String { + return MOD_ID + } + + override fun getUniqueId(ingredient: GasType, context: UidContext): String { + return "${ingredient.resourceLocation.namespace}/${ingredient.resourceLocation.path}" + } + + // TODO: Make this get lang + override fun getDisplayName(ingredient: GasType): String { + return ingredient.name + } + + } + + class GasIngredientRenderer: IIngredientRenderer { + override fun getTooltip(ingredient: GasType, tooltipFlag: TooltipFlag): MutableList { + return mutableListOf(TextComponent(ingredient.name).withStyle(ChatFormatting.GOLD)) + } + + override fun render(stack: PoseStack, ingredient: GasType) { + + super.render(stack, ingredient) + } } -} \ No newline at end of file +} + From 96b6c596a59dbd54d04dbb8ccf724e4f599299da Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 16 Mar 2025 18:59:06 +0300 Subject: [PATCH 11/37] the world's ugliest jei category --- .../kelvin/impl/GasTypeRegistry.kt | 8 +- .../kelvin/integration/jei/ImageDrawable.kt | 25 ++++++ .../integration/jei/KelvinGasIngredient.kt | 68 ++++++++++++++++ .../kelvin/integration/jei/KelvinJeiPlugin.kt | 75 ++++-------------- .../jei/KelvinReactionRecipeCategory.kt | 52 ++++++++++++ .../gui/gas_reaction_recipe_background.png | Bin 0 -> 1521 bytes .../assets/kelvin/textures/icons/air.png | Bin 0 -> 1040 bytes .../assets/kelvin/textures/icons/methane.png | Bin 0 -> 927 bytes 8 files changed, 167 insertions(+), 61 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt create mode 100644 common/src/main/resources/assets/kelvin/textures/gui/gas_reaction_recipe_background.png create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/air.png create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/methane.png diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt index a22ff80..2a937c3 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt @@ -30,12 +30,16 @@ object GasTypeRegistry { return getGasType(ResourceLocation(modid, name)) } + private fun getIcon(name: String): ResourceLocation { + return KelvinMod.asResouceLocation("textures/icons/$name") + } + fun init () { - val air = GasType("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026) + val air = GasType("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026, iconLocation = getIcon("air.png")) val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8) val helium = GasType("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66) val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8) - val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7) + val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7, iconLocation = getIcon("methane.png")) registerGasType(air) registerGasType(phlogiston) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt new file mode 100644 index 0000000..b3323b9 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt @@ -0,0 +1,25 @@ +package org.valkyrienskies.kelvin.integration.jei + +import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.PoseStack +import mezz.jei.api.gui.drawable.IDrawable +import net.minecraft.client.gui.GuiComponent +import net.minecraft.resources.ResourceLocation + + +class ImageDrawable(private val width: Int, private val height: Int, private val location: ResourceLocation) : IDrawable { + + override fun getWidth(): Int { + return width + } + + override fun getHeight(): Int { + return height + } + + override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { + RenderSystem.setShaderTexture(0, location) + GuiComponent.blit(stack, xOffset, yOffset, 0, 0f, 0f, width, height, height, width); + + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt new file mode 100644 index 0000000..58e4740 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt @@ -0,0 +1,68 @@ +package org.valkyrienskies.kelvin.integration.jei + +import com.mojang.blaze3d.systems.RenderSystem +import com.mojang.blaze3d.vertex.PoseStack +import mezz.jei.api.ingredients.IIngredientHelper +import mezz.jei.api.ingredients.IIngredientRenderer +import mezz.jei.api.ingredients.IIngredientType +import mezz.jei.api.ingredients.subtypes.UidContext +import net.minecraft.ChatFormatting +import net.minecraft.client.gui.GuiComponent +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.TextComponent +import net.minecraft.world.item.TooltipFlag +import org.valkyrienskies.kelvin.KelvinMod.MOD_ID +import org.valkyrienskies.kelvin.api.GasType + +class GasIngredientType: IIngredientType { + override fun getIngredientClass(): Class { + return GasType::class.java + } +} + +class GasIngredientHelper: IIngredientHelper { + override fun getIngredientType(): IIngredientType { + return GasIngredientType() + } + + override fun getErrorInfo(ingredient: GasType?): String { + return ingredient?.toString() ?: "Null Kelvin GasType" + } + + override fun copyIngredient(ingredient: GasType): GasType { + return ingredient + } + + override fun getResourceId(ingredient: GasType): String { + return ingredient.resourceLocation.path + } + + override fun getModId(ingredient: GasType): String { + return MOD_ID + } + + override fun getUniqueId(ingredient: GasType, context: UidContext): String { + return ingredient.resourceLocation.toString() + } + + // TODO: Make this get lang + override fun getDisplayName(ingredient: GasType): String { + return ingredient.name + } + +} + +class GasIngredientRenderer: IIngredientRenderer { + override fun getTooltip(ingredient: GasType, tooltipFlag: TooltipFlag): MutableList { + return mutableListOf(TextComponent(ingredient.name).withStyle(ChatFormatting.GOLD)) + } + + override fun render(stack: PoseStack, ingredient: GasType) { + if (ingredient.iconLocation == null) return + RenderSystem.setShaderTexture(0, ingredient.iconLocation) + GuiComponent.blit(stack, 0, 0, 0, 0f, 0f, 16, 16, 16, 16); + + super.render(stack, ingredient) + } + +} diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt index 476cee6..49c7ebd 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt @@ -1,25 +1,17 @@ package org.valkyrienskies.kelvin.integration.jei -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.IModPlugin import mezz.jei.api.JeiPlugin -import mezz.jei.api.ingredients.IIngredientHelper -import mezz.jei.api.ingredients.IIngredientRenderer -import mezz.jei.api.ingredients.IIngredientType -import mezz.jei.api.ingredients.IIngredientTypeWithSubtypes -import mezz.jei.api.ingredients.subtypes.UidContext +import mezz.jei.api.recipe.RecipeType import mezz.jei.api.registration.IModIngredientRegistration -import net.minecraft.ChatFormatting -import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent +import mezz.jei.api.registration.IRecipeCategoryRegistration +import mezz.jei.api.registration.IRecipeRegistration import net.minecraft.resources.ResourceLocation -import net.minecraft.world.item.Item -import net.minecraft.world.item.ItemStack -import net.minecraft.world.item.TooltipFlag import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.MOD_ID -import org.valkyrienskies.kelvin.api.GasType +import org.valkyrienskies.kelvin.api.GasReaction import org.valkyrienskies.kelvin.impl.GasTypeRegistry +import org.valkyrienskies.kelvin.impl.KelvinReactionDataLoader @JeiPlugin @@ -30,61 +22,26 @@ class KelvinJeiPlugin: IModPlugin { override fun registerIngredients(registration: IModIngredientRegistration) { val gasTypes = GasTypeRegistry.GAS_TYPES.values - - - registration.register(GasIngredientType(), gasTypes, GasIngredientHelper(), GasIngredientRenderer()) + registration.register(GAS_INGREDIENT_TYPE, gasTypes, GasIngredientHelper(), GasIngredientRenderer()) } + override fun registerCategories(registration: IRecipeCategoryRegistration) { + super.registerCategories(registration) - - class GasIngredientType: IIngredientType { - override fun getIngredientClass(): Class { - return GasType::class.java - } + registration.addRecipeCategories(KelvinReactionRecipeCategory()) } - class GasIngredientHelper: IIngredientHelper { - override fun getIngredientType(): IIngredientType { - return GasIngredientType() - } - - override fun getErrorInfo(ingredient: GasType?): String { - return ingredient?.toString() ?: "Null Kelvin GasType" - } - - override fun copyIngredient(ingredient: GasType): GasType { - return ingredient - } - - override fun getResourceId(ingredient: GasType): String { - return ingredient.resourceLocation.path - } - - override fun getModId(ingredient: GasType): String { - return MOD_ID - } - - override fun getUniqueId(ingredient: GasType, context: UidContext): String { - return "${ingredient.resourceLocation.namespace}/${ingredient.resourceLocation.path}" - } - - // TODO: Make this get lang - override fun getDisplayName(ingredient: GasType): String { - return ingredient.name - } - + override fun registerRecipes(registration: IRecipeRegistration) { + super.registerRecipes(registration) + val recipes = KelvinReactionDataLoader.gas_reactions.values + registration.addRecipes(recipes, KelvinMod.asResouceLocation("gas_reaction_recipe")) // TODO: Figure out how to use the other non-deprecated method. } - class GasIngredientRenderer: IIngredientRenderer { - override fun getTooltip(ingredient: GasType, tooltipFlag: TooltipFlag): MutableList { - return mutableListOf(TextComponent(ingredient.name).withStyle(ChatFormatting.GOLD)) - } - - override fun render(stack: PoseStack, ingredient: GasType) { - super.render(stack, ingredient) - } + companion object { + val GAS_REACTION_RECIPE_TYPE: RecipeType = RecipeType.create(MOD_ID, "gas_reaction_recipe", GasReaction::class.java) + val GAS_INGREDIENT_TYPE = GasIngredientType() } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt new file mode 100644 index 0000000..52355fe --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt @@ -0,0 +1,52 @@ +package org.valkyrienskies.kelvin.integration.jei + +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder +import mezz.jei.api.gui.drawable.IDrawable +import mezz.jei.api.recipe.IFocusGroup +import mezz.jei.api.recipe.RecipeIngredientRole +import mezz.jei.api.recipe.category.IRecipeCategory +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.TextComponent +import net.minecraft.resources.ResourceLocation +import org.valkyrienskies.kelvin.KelvinMod +import org.valkyrienskies.kelvin.api.GasReaction +import org.valkyrienskies.kelvin.integration.jei.KelvinJeiPlugin.Companion.GAS_INGREDIENT_TYPE + +class KelvinReactionRecipeCategory : IRecipeCategory { + override fun getTitle(): Component { + return TextComponent("Gas Reaction") + } + + override fun getBackground(): IDrawable { + return ImageDrawable(100,100, KelvinMod.asResouceLocation("textures/gui/gas_reaction_recipe_background.png")) + } + + override fun getIcon(): IDrawable { + return ImageDrawable(16,16, KelvinMod.asResouceLocation("placeholder")) + } + + override fun getUid(): ResourceLocation { + return KelvinMod.asResouceLocation("gas_reaction_recipe") + } + + override fun getRecipeClass(): Class { + return GasReaction::class.java + } + + override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: GasReaction, focuses: IFocusGroup) { + var i = 0 + recipe.gasses.forEach { (type, moles) -> + val slot = builder.addSlot(RecipeIngredientRole.INPUT, 0, i*17) + slot.addIngredient(GAS_INGREDIENT_TYPE, type) + i++ + } + + i = 0 + recipe.result.forEach { (type, moles) -> + val slot = builder.addSlot(RecipeIngredientRole.OUTPUT, 84, i*17) + slot.addIngredient(GAS_INGREDIENT_TYPE, type) + i++ + } + } +} + diff --git a/common/src/main/resources/assets/kelvin/textures/gui/gas_reaction_recipe_background.png b/common/src/main/resources/assets/kelvin/textures/gui/gas_reaction_recipe_background.png new file mode 100644 index 0000000000000000000000000000000000000000..ff1ba1045fe27e79ebdb05a3c0e88d7cb5e7dca0 GIT binary patch literal 1521 zcmVPx)t4TybRCr$Po$Z>VFbIY9{x7=o*ijoJ3Ez;k?yucx0*CX0TGw{g<@qy|1FMOe zEy~Lzl03+v;ixEEPgx1W9~&TY8=sw(10WCv(8o|?2jV8AOL<+E^%Z>B8?)_pAWU)0 z<;G2fgd1AiRXZRxZbD+IsIz5Zy#vWoqP8$0K-_^afPAq_*yVTfEeGET`C_hKv*HWHOZCKYu^w#$DRyE(CiZ7I>9G^? zkVP9H76>Y5fCb4-69Xi&$jDr`{=t%CuP+M$2p+_wuT^POn@!}4gH+N9K*Xv3H(Gji z#u5e-it_lYrQPR1k zMy=P??*JsK@a=kGU0%sI1JP=CK2%Io13}H0aKTRip>}5&zs}U?fq>NxXF-71%9;yE z=3+5v*z4wk*ta!ie@tf88Y-J-FGGjfb3l(xxH_TOy-Iwwzz zBh~WrR0A9p`mNyT!%(3Ig93Xa=$5G`sQ%<3T>n`ju~yWI6V-h zIq$LfOv~lup$skCo)6^XNOf$-J|k9Ix&OWR5$U{qp#jdCxj)!Mnn_g02X|n9SF$(k>h4ZO}Ig7y_~5l!_QL#{CykstQ|MPs?@Gt9U5GdFsDWE z?IbNat?ypJ=MKJ^aZ0QFlEmw~5)PzOf*BC-X_R_ObY8mo<`$Sa9gU-eAWFGKXZkhy z{er>8JC~qB8(*vw^`X3&EA;$B6h`1^;~S93{g_Df;D18S!%DeJa3o_SC754dfZ4!k zXmkzE@TGsqDlb6*J}gt4MwCxMw%!A6*K$5b*F)A2Kz2hLqX5}m5Q4teNlge05aN|V z5_R=QbAV@qv!Tm02&4LO-^=p$Kd^x|@Cr-e_%4)->HWTrvFUmgEB|$S)4#jG2oAp) z!QDhx;2Qj>UEKsHyqhj(mY#}GPi)Fz}Ud0CFXPuyw(Ka4&-u)km^a1+@wIg&v6l;TQwIL z8IJgLLtROyvg_q5p9a~q`@$igK4AeN7Z3TW+RO)a*#YOi{3pjgF3Lpu?JOYrbU_hl z@Viek(n8qRGdB>qYr{TPIyVq`gOWa`AP+C!2?LRLo?J=n&S5{y^Q#j=z+ZM{T!(JY z0|ft?2!a>`wAc}yw2X)cGVt@ z3}nXQTpV)_N(SPrqj{2x%$w14bxvO((G^niQPy~M0U@^^kUcp;gYh@^7jDv$6YMt& z1m`Nk+XHddPH=CUC9RA9X$lYv4QLXp6!sG$c8#&os(MDssHJlPF?I*zi@k0s=K*5r zrorWj8c1aKVBQU(r7Hqgs0MKaP)Px&%1J~)R5(v9lg&>fbsUGkznQ*FXFBv{+ERwn0$aJ~|x;fp`*ZrtiD2l4Cr9nd@!WZ$Me|Y*V(bE^;Nicr&c|5V=Md`$3GGzf&FcdU` zR`F_72Q8)>Iu9fv2KZh+f0mEDExv_-zvsZlva@17e@;=1)J0Q|KaIy=>(9*?!%`=@ z4uDb^FIa&XusH2}>#8L(K4z{`k@}@;>6O#rbdBA8S9-mj9my9?&tvh}%j3hNx$x-d zLG$J&GBiAV52f(Zf}ihuXrt*XO;Oge2YcV?iXn2G6Y8~QNYhp2?)W&nv$drK`v+ec z1iUPZ1^&M9`5FRa0AZYp+F9mFus`_I3SRmCy~)Yb^P(7vL?We9rP5O=m&tBlw~b-# z#Ky+PZ(lwX*k-+x$=fuzzQVHo2SK zD|3DiaIAv^&;z-%f;u-l+oo(x!^yFrtEzi{?{MA5Ff7a1Wpo?JEx+QW1V0d-aL`>r z@vo7R&^wYOvtEx|E}R#nQu*@g)(7MNS;aUCCIi%_ zGV*?OYNl=Ivz*K2u(5PPx&SxH1eR5(vnQe8|_XBd9JmX^|%BG5{q!%D}fMI+inP@E)Y?wmtha7-NAGVy1q znY)0wSqAeQk1#^O(lq9rJR$&=VKMLI5Z*!pAdCQ^|1I#Q3bQE! z0KhN|=6PO%F*J*Lo+GIAAOM6UQkqGUyhj26l8EDY2}ZLl<~eT5lkC!JnfzM>Cjx|l zp^3W_kw1_m97&Ra6G@y&K(-hGy&2v7kfyA+VQ8`ys(sDQVOAo)bAD%<4zu+iB0`*; zn_!w|u)f`L?Ymuh{$IWvxhsjhH&Nk?+K%{` zOqt4idRc4oUQo0gFSEn1RQo;B5@1YPNY_ZlBlb}pBUjpH9feKxzxjIsTdj|O5Ka4U z%9qClw2=5IRe7NEz+ikMCWxZ)&Ut&iN6Jv^s&+i98*0D#`rBKu9yhGS;s<9|v**k@ zb$N+eIX@Him8szFe_) z?m=L#AxowzoR3BIUzkG^-M&2Q6{@i#B6=DkDKD(VQYBqJUF48q(lr_02WKix1L)zr znR*&L*A|R<-&k~`202vjki%MGQnm~_W!}`zT=&)P@%^`2t1RGN^a|T@w(Zobg%|fd z+w&q4Nu2eMQlL1omzx_!I$ zfjgWHD+%{p?R002ovPDHLkV1oDp BxU~QP literal 0 HcmV?d00001 From 25f68456a57a658fea0bcb4c68a03561ac908e9e Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 16 Mar 2025 20:00:18 +0300 Subject: [PATCH 12/37] use KelvinGasIngredient, instead of Gas --- .../integration/jei/KelvinGasIngredient.kt | 44 ++++++++++--------- .../kelvin/integration/jei/KelvinJeiPlugin.kt | 5 ++- .../jei/KelvinReactionRecipeCategory.kt | 4 +- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt index 58e4740..7483aef 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt @@ -14,52 +14,54 @@ import net.minecraft.world.item.TooltipFlag import org.valkyrienskies.kelvin.KelvinMod.MOD_ID import org.valkyrienskies.kelvin.api.GasType -class GasIngredientType: IIngredientType { - override fun getIngredientClass(): Class { - return GasType::class.java +data class KelvinGasIngredient(val gasType: GasType, val moles: Int) + +class GasIngredientType: IIngredientType { + override fun getIngredientClass(): Class { + return KelvinGasIngredient::class.java } } -class GasIngredientHelper: IIngredientHelper { - override fun getIngredientType(): IIngredientType { +class GasIngredientHelper: IIngredientHelper { + override fun getIngredientType(): IIngredientType { return GasIngredientType() } - override fun getErrorInfo(ingredient: GasType?): String { - return ingredient?.toString() ?: "Null Kelvin GasType" + override fun getErrorInfo(ingredient: KelvinGasIngredient?): String { + return ingredient?.gasType.toString() } - override fun copyIngredient(ingredient: GasType): GasType { + override fun copyIngredient(ingredient: KelvinGasIngredient): KelvinGasIngredient { return ingredient } - override fun getResourceId(ingredient: GasType): String { - return ingredient.resourceLocation.path + override fun getResourceId(ingredient: KelvinGasIngredient): String { + return ingredient.gasType.resourceLocation.path } - override fun getModId(ingredient: GasType): String { + override fun getModId(ingredient: KelvinGasIngredient): String { return MOD_ID } - override fun getUniqueId(ingredient: GasType, context: UidContext): String { - return ingredient.resourceLocation.toString() + override fun getUniqueId(ingredient: KelvinGasIngredient, context: UidContext): String { + return ingredient.gasType.resourceLocation.toString() } // TODO: Make this get lang - override fun getDisplayName(ingredient: GasType): String { - return ingredient.name + override fun getDisplayName(ingredient: KelvinGasIngredient): String { + return ingredient.gasType.name } } -class GasIngredientRenderer: IIngredientRenderer { - override fun getTooltip(ingredient: GasType, tooltipFlag: TooltipFlag): MutableList { - return mutableListOf(TextComponent(ingredient.name).withStyle(ChatFormatting.GOLD)) +class GasIngredientRenderer: IIngredientRenderer { + override fun getTooltip(ingredient: KelvinGasIngredient, tooltipFlag: TooltipFlag): MutableList { + return mutableListOf(TextComponent(ingredient.gasType.name).withStyle(ChatFormatting.GOLD)) } - override fun render(stack: PoseStack, ingredient: GasType) { - if (ingredient.iconLocation == null) return - RenderSystem.setShaderTexture(0, ingredient.iconLocation) + override fun render(stack: PoseStack, ingredient: KelvinGasIngredient) { + if (ingredient.gasType.iconLocation == null) return + RenderSystem.setShaderTexture(0, ingredient.gasType.iconLocation) GuiComponent.blit(stack, 0, 0, 0, 0f, 0f, 16, 16, 16, 16); super.render(stack, ingredient) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt index 49c7ebd..9d1a593 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt @@ -21,8 +21,9 @@ class KelvinJeiPlugin: IModPlugin { } override fun registerIngredients(registration: IModIngredientRegistration) { - val gasTypes = GasTypeRegistry.GAS_TYPES.values - registration.register(GAS_INGREDIENT_TYPE, gasTypes, GasIngredientHelper(), GasIngredientRenderer()) + val recipes = HashSet() + GasTypeRegistry.GAS_TYPES.values.forEach {type -> recipes.add(KelvinGasIngredient(type, 1))} + registration.register(GAS_INGREDIENT_TYPE, recipes, GasIngredientHelper(), GasIngredientRenderer()) } override fun registerCategories(registration: IRecipeCategoryRegistration) { diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt index 52355fe..d26e57c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt @@ -37,14 +37,14 @@ class KelvinReactionRecipeCategory : IRecipeCategory { var i = 0 recipe.gasses.forEach { (type, moles) -> val slot = builder.addSlot(RecipeIngredientRole.INPUT, 0, i*17) - slot.addIngredient(GAS_INGREDIENT_TYPE, type) + slot.addIngredient(GAS_INGREDIENT_TYPE, KelvinGasIngredient(type,moles)) i++ } i = 0 recipe.result.forEach { (type, moles) -> val slot = builder.addSlot(RecipeIngredientRole.OUTPUT, 84, i*17) - slot.addIngredient(GAS_INGREDIENT_TYPE, type) + slot.addIngredient(GAS_INGREDIENT_TYPE, KelvinGasIngredient(type,moles)) i++ } } From 0378b17c9605bb1c09c5101e363c7295f147dca3 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 16 Mar 2025 20:41:14 +0300 Subject: [PATCH 13/37] Add mole counter text --- .../jei/KelvinReactionRecipeCategory.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt index d26e57c..6a513c2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt @@ -1,16 +1,21 @@ package org.valkyrienskies.kelvin.integration.jei +import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.builder.IRecipeLayoutBuilder import mezz.jei.api.gui.drawable.IDrawable +import mezz.jei.api.gui.ingredient.IRecipeSlotsView import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.category.IRecipeCategory +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.GuiComponent import net.minecraft.network.chat.Component import net.minecraft.network.chat.TextComponent import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.GasReaction import org.valkyrienskies.kelvin.integration.jei.KelvinJeiPlugin.Companion.GAS_INGREDIENT_TYPE +import java.awt.Font class KelvinReactionRecipeCategory : IRecipeCategory { override fun getTitle(): Component { @@ -34,6 +39,7 @@ class KelvinReactionRecipeCategory : IRecipeCategory { } override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: GasReaction, focuses: IFocusGroup) { + var i = 0 recipe.gasses.forEach { (type, moles) -> val slot = builder.addSlot(RecipeIngredientRole.INPUT, 0, i*17) @@ -48,5 +54,31 @@ class KelvinReactionRecipeCategory : IRecipeCategory { i++ } } + + override fun draw( + recipe: GasReaction, + recipeSlotsView: IRecipeSlotsView, + stack: PoseStack, + mouseX: Double, + mouseY: Double + ) { + var i = 0 + recipeSlotsView.getSlotViews(RecipeIngredientRole.INPUT).forEach { slot -> + val ingredient = slot.displayedIngredient.get().ingredient as KelvinGasIngredient + // TODO: USE LANG + Minecraft.getInstance().font.draw(stack, "${ingredient.moles} Moles",17f,i*17f, 5592405) + i++ + } + + i = 0 + recipeSlotsView.getSlotViews(RecipeIngredientRole.OUTPUT).forEach { slot -> + val ingredient = slot.displayedIngredient.get().ingredient as KelvinGasIngredient + // TODO: USE LANG + Minecraft.getInstance().font.draw(stack, "${ingredient.moles} Moles",101f,i*17f, 5592405) + i++ + } + + + } } From e7d999742b2e8e72f65d6e9a800186959a34ad11 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 20 Mar 2025 19:47:44 +0300 Subject: [PATCH 14/37] Renderable Requirements --- .../kelvin/api/GasReactionRequirement.kt | 4 +++ .../kelvin/impl/DefaultKelvinRequirements.kt | 26 +++++++++++++++++++ .../jei/KelvinReactionRecipeCategory.kt | 13 +++++++--- .../kelvin_reactions/test_recipe_2.json | 14 ++++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe_2.json diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt index 86140be..e3b3d26 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt @@ -1,6 +1,8 @@ package org.valkyrienskies.kelvin.api import com.google.gson.JsonElement +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.TextComponent import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.Level @@ -9,4 +11,6 @@ abstract class GasReactionRequirement(val resourceLocation: ResourceLocation) { abstract fun apply_requirement(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean + open fun get_text(value: JsonElement): Component { return TextComponent("Empty Component") } + } \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt index fcaf48c..17e5f9d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt @@ -1,6 +1,8 @@ package org.valkyrienskies.kelvin.impl import com.google.gson.JsonElement +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.TextComponent import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.DuctNetwork @@ -18,6 +20,12 @@ object DefaultKelvinRequirements { return temperature >= doubleValue } + override fun get_text(value: JsonElement): Component { + val doubleValue = value.asDouble + + return TextComponent("Minimum Temperature: $doubleValue K") + } + } object maxTemperature: GasReactionRequirement(KelvinMod.asResouceLocation("max_temperature")) { @@ -27,6 +35,12 @@ object DefaultKelvinRequirements { val temperature = network.getTemperatureAt(ductNode) return temperature <= doubleValue } + + override fun get_text(value: JsonElement): Component { + val doubleValue = value.asDouble + + return TextComponent("Maximum Temperature: $doubleValue K") + } } object minPressure: GasReactionRequirement(KelvinMod.asResouceLocation("min_pressure")) { @@ -36,6 +50,12 @@ object DefaultKelvinRequirements { val pressure = network.getPressureAt(ductNode) return pressure >= doubleValue } + + override fun get_text(value: JsonElement): Component { + val doubleValue = value.asDouble + + return TextComponent("Minimum Pressure: $doubleValue Pa") + } } object maxPressure: GasReactionRequirement(KelvinMod.asResouceLocation("max_pressure")) { @@ -45,6 +65,12 @@ object DefaultKelvinRequirements { val pressure = network.getPressureAt(ductNode) return pressure <= doubleValue } + + override fun get_text(value: JsonElement): Component { + val doubleValue = value.asDouble + + return TextComponent("Maximum Pressure: $doubleValue Pa") + } } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt index 6a513c2..ca72467 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt @@ -8,14 +8,12 @@ import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole import mezz.jei.api.recipe.category.IRecipeCategory import net.minecraft.client.Minecraft -import net.minecraft.client.gui.GuiComponent import net.minecraft.network.chat.Component import net.minecraft.network.chat.TextComponent import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.GasReaction import org.valkyrienskies.kelvin.integration.jei.KelvinJeiPlugin.Companion.GAS_INGREDIENT_TYPE -import java.awt.Font class KelvinReactionRecipeCategory : IRecipeCategory { override fun getTitle(): Component { @@ -23,7 +21,7 @@ class KelvinReactionRecipeCategory : IRecipeCategory { } override fun getBackground(): IDrawable { - return ImageDrawable(100,100, KelvinMod.asResouceLocation("textures/gui/gas_reaction_recipe_background.png")) + return ImageDrawable(150,150, KelvinMod.asResouceLocation("textures/gui/gas_reaction_recipe_background.png")) } override fun getIcon(): IDrawable { @@ -62,12 +60,15 @@ class KelvinReactionRecipeCategory : IRecipeCategory { mouseX: Double, mouseY: Double ) { + var maxI = 0 var i = 0 recipeSlotsView.getSlotViews(RecipeIngredientRole.INPUT).forEach { slot -> val ingredient = slot.displayedIngredient.get().ingredient as KelvinGasIngredient // TODO: USE LANG + Minecraft.getInstance().font.draw(stack, "${ingredient.moles} Moles",17f,i*17f, 5592405) i++ + if (i >= maxI) maxI = i } i = 0 @@ -76,8 +77,14 @@ class KelvinReactionRecipeCategory : IRecipeCategory { // TODO: USE LANG Minecraft.getInstance().font.draw(stack, "${ingredient.moles} Moles",101f,i*17f, 5592405) i++ + if (i >= maxI) maxI = i } + i = maxI + 2 + recipe.requirements.forEach { (requirement, value) -> + Minecraft.getInstance().font.draw(stack, requirement.get_text(value),0f,i*17f, 5592405) + i++ + } } } diff --git a/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe_2.json b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe_2.json new file mode 100644 index 0000000..660f0da --- /dev/null +++ b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe_2.json @@ -0,0 +1,14 @@ +{ + "gasses": { + "kelvin:methane": 1, + "kelvin:air": 3, + "kelvin:hydrogen": 2 + }, + "requirements": { + "kelvin:max_temperature": 1200, + "kelvin:max_pressure": 50000 + }, + "result": { + "kelvin:phlogiston": 10 + } +} \ No newline at end of file From 8699ab4ce20935d445fe425d6b6bbeaedcd908e8 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 10 Apr 2025 13:01:44 +0300 Subject: [PATCH 15/37] Add Gibbs free energy change to gas reactions --- .../valkyrienskies/kelvin/api/GasReaction.kt | 2 +- .../kelvin/impl/DuctNetworkServer.kt | 19 ++++++++++--------- .../kelvin/impl/KelvinReactionDataLoader.kt | 10 ++++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt index 4a0000c..8de2d34 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReaction.kt @@ -2,5 +2,5 @@ package org.valkyrienskies.kelvin.api import com.google.gson.JsonElement -data class GasReaction(val gasses : HashMap, val requirements: HashMap, val result: HashMap) +data class GasReaction(val gasses : HashMap, val requirements: HashMap, val energy: Double = 0.0, val result: HashMap) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index 075f7b2..00d6e61 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -575,34 +575,35 @@ class DuctNetworkServer( for (reaction in reactions.values) { var con = false - reaction.requirements.forEach {if (!it.key.apply_requirement(level, node, this, it.value)) { con = true - return@forEach - }} + reaction.requirements.forEach {if (!it.key.apply_requirement(level, node, this, it.value)) { con = true; return@forEach }} if (con) continue - calcReaction(node, gasMasses, reaction.gasses, reaction.result) + calcReaction(node, gasMasses, reaction.gasses, reaction.result, reaction.energy) } } } - private fun calcReaction(ductNodePos: DuctNodePos, gasMasses: HashMap, inputGasses: HashMap, outputGasses: HashMap) { + private fun calcReaction(ductNodePos: DuctNodePos, gasMasses: HashMap, inputGasses: HashMap, outputGasses: HashMap, deltaEnergy: Double) { val gasMoles = HashMap() for (gas in gasMasses) gasMoles[gas.key] = (gas.value/gas.key.density)/22.4 - var reaction_moles = Double.MAX_VALUE + var reactionMoles = Double.MAX_VALUE + for (gas in inputGasses) { if (gas.key !in gasMoles || gasMoles[gas.key]!! < 0.001) return val thisOutput = gasMoles[gas.key]!! / gas.value - if (thisOutput < reaction_moles) reaction_moles = thisOutput + if (thisOutput < reactionMoles) reactionMoles = thisOutput } - for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-reaction_moles * gas.value * gas.key.density * 22.4) + for (gas in inputGasses) modGasMass(ductNodePos,gas.key,-reactionMoles * gas.value * gas.key.density * 22.4) + + for (gas in outputGasses) modGasMass(ductNodePos,gas.key,reactionMoles * gas.value * gas.key.density * 22.4) - for (gas in outputGasses) modGasMass(ductNodePos,gas.key,reaction_moles * gas.value * gas.key.density * 22.4) + modHeatEnergy(ductNodePos, deltaEnergy * reactionMoles) } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt index 157eede..9889dc3 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt @@ -22,7 +22,6 @@ object KelvinReactionDataLoader { resourceManager: ResourceManager, profiler: ProfilerFiller ) { - println("Applying Data loader") gas_reactions.clear() objects.forEach { (location, element) -> try { @@ -76,9 +75,12 @@ object KelvinReactionDataLoader { result[gasType] = gasParts } - val parsed_reaction = GasReaction(gasses, requirements, result) - println(parsed_reaction) - gas_reactions[origin] = parsed_reaction + + val energy = if (jObject.has("energy")) jObject["energy"].asDouble else 0.0 + + val parsedReaction = GasReaction(gasses = gasses, requirements = requirements, energy = energy, result = result) + println(parsedReaction) + gas_reactions[origin] = parsedReaction } } From 15172b0ba74e8ba59a0a8e3808615cd645934413 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 10 Apr 2025 13:02:02 +0300 Subject: [PATCH 16/37] Add Steam and Exhaust gas + make methane reaction more realistic --- .../org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt | 7 +++++++ .../data/kelvin/kelvin_reactions/test_recipe.json | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt index a22ff80..27b2623 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt @@ -32,12 +32,19 @@ object GasTypeRegistry { fun init () { val air = GasType("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026) + val exhaust = GasType("Exhaust", ResourceLocation(KelvinMod.MOD_ID, "exhaust"), 1.98, 1.10e-5, 2.2, 0.031) + val steam = GasType("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031) + + val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8) val helium = GasType("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66) val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8) val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7) + registerGasType(air) + registerGasType(exhaust) + registerGasType(steam) registerGasType(phlogiston) registerGasType(helium) registerGasType(hydrogen) diff --git a/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json index 18af6b0..61c3e4b 100644 --- a/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json +++ b/common/src/main/resources/data/kelvin/kelvin_reactions/test_recipe.json @@ -7,7 +7,9 @@ "kelvin:min_temperature": 800, "kelvin:min_pressure": 1000 }, + "energy": 890400, "result": { - "kelvin:air": 10 + "kelvin:exhaust": 1, + "kelvin:steam": 2 } } \ No newline at end of file From ad0725250fbb92440d9ae6976d94776f2ee777b7 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sat, 7 Jun 2025 23:57:18 +0300 Subject: [PATCH 17/37] broken WIP code. Too sleepy. Finish tomorrow --- common/build.gradle | 13 +++++++ .../org/valkyrienskies/kelvin/KelvinMod.kt | 4 ++ .../valkyrienskies/kelvin/KelvinParticles.kt | 39 +++++++++++++++++++ .../org/valkyrienskies/kelvin/api/GasType.kt | 4 +- .../kelvin/api/ParticleTypePicker.kt | 9 +++++ .../kelvin/impl/GasTypeRegistry.kt | 6 +++ .../client/particle/DefaultGasParticle.kt | 16 ++++++++ .../particle/DefaultGasParticlePicker.kt | 19 +++++++++ .../particle/DefaultGasParticleProvider.kt | 31 +++++++++++++++ .../client/particle/DefaultGasParticleType.kt | 5 +++ 10 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/api/ParticleTypePicker.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt diff --git a/common/build.gradle b/common/build.gradle index da22eac..c6f4581 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -18,6 +18,19 @@ dependencies { api "org.jetbrains.kotlin:kotlin-reflect:1.9.10" } +kotlin { + // This block configures the Kotlin compiler for this module + compilerOptions { + // Add your desired free compiler arguments here + freeCompilerArgs = [ + "-Xtype-enhancement-improvements-strict-mode ", + "-Xjvm-default=all-compatibility" + ] + + // jvmTarget = "17" // Example: Set JVM target version + } +} + publishing { publications { mavenCommon(MavenPublication) { diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt index ba5f6cf..c09a9bc 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt @@ -44,6 +44,8 @@ object KelvinMod { KELVINLOGGER.info("Initializing Kelvin...") networkManager = SimpleNetworkManager.create(MOD_ID) + KelvinParticles.init() + LifecycleEvent.SERVER_BEFORE_START.register { Kelvin.disabled = false KELVINLOGGER.info("Enabling Kelvin...") @@ -121,6 +123,8 @@ object KelvinMod { @JvmStatic fun initClient() { + KelvinParticles.KelvinClientParticles.init() + ClientPlayerEvent.CLIENT_PLAYER_JOIN.register { if (Platform.getEnvironment() == Env.CLIENT) KelvinClient.disabled = false } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt new file mode 100644 index 0000000..aed67c3 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt @@ -0,0 +1,39 @@ +package org.valkyrienskies.kelvin + +import dev.architectury.registry.client.particle.ParticleProviderRegistry +import dev.architectury.registry.registries.DeferredRegister +import dev.architectury.registry.registries.RegistrySupplier +import net.minecraft.core.Registry +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticleProvider +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticleType + + +object KelvinParticles { + + val ALL: HashSet> = HashSet() + val PARTICLES = DeferredRegister.create(KelvinMod.MOD_ID, Registry.PARTICLE_TYPE_REGISTRY) + + fun registerDefaultParticle(name: String): RegistrySupplier { + val supplier = PARTICLES.register(name) { DefaultGasParticleType() } + ALL.add(supplier) + return supplier + } + + fun init() { + PARTICLES.register() + KelvinMod.KELVINLOGGER.info("Registered Kelvin default gas particles") + } + + object KelvinClientParticles { + + fun registerDefaultParticle(supplier: RegistrySupplier) { + ParticleProviderRegistry.register(supplier.get(), ::DefaultGasParticleProvider) + } + + fun init() { + ALL.forEach { entry -> registerDefaultParticle(entry) } + KelvinMod.KELVINLOGGER.info("Registered Kelvin default particle providers") + } + + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt index 7e27a59..0487ba1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt @@ -2,6 +2,7 @@ package org.valkyrienskies.kelvin.api import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import net.minecraft.core.particles.ParticleType import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.util.KelvinKeyMapper @@ -18,7 +19,8 @@ data class GasType( val adiabaticIndex: Double = 1.4, // (dimensionless) (see https://en.wikipedia.org/wiki/Adiabatic_index) Not required, 1.4 is air's. Technically an approximation, only useful for pockets, but oh well. val combustible: Boolean = false, // Whether the gas can be used as fuel val calorificValue: Double = 0.0, // (J / kg) (see https://en.wikipedia.org/wiki/Energy_density), only use if [combustible] is true - val iconLocation: ResourceLocation? = null + val iconLocation: ResourceLocation? = null, + val particleType: ParticleType ) { override fun toString(): String { val iconLoc = iconLocation?.toString() ?: "null" diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/ParticleTypePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/ParticleTypePicker.kt new file mode 100644 index 0000000..01061df --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/ParticleTypePicker.kt @@ -0,0 +1,9 @@ +package org.valkyrienskies.kelvin.api + +import net.minecraft.core.particles.ParticleType +import net.minecraft.world.level.Level + +abstract class ParticleTypePicker { + abstract fun chooseParticleType(level: Level, temperature: Double, pressure: Double, ductNodePos: DuctNodePos): ParticleType<*> +} + diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt index 27b2623..bff4994 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt @@ -22,6 +22,12 @@ object GasTypeRegistry { KELVINLOGGER.info("Icon Location: ${gasType.iconLocation}") } + fun registerGasType(name: String, resourceLocation: ResourceLocation, density: Double, viscosity: Double, + specificHeatCapacity: Double, thermalConductivity: Double, sutherlandConstant: Double, + adiabaticIndex: Double, combustible: Boolean, calorificValue: Double, iconLocation: ResourceLocation? = null) { + gas = GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) + } + fun getGasType(resourceLocation: ResourceLocation): GasType? { return GAS_TYPES[resourceLocation] } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt new file mode 100644 index 0000000..a3f8f84 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt @@ -0,0 +1,16 @@ +package org.valkyrienskies.kelvin.impl.client.particle + +import net.minecraft.client.multiplayer.ClientLevel +import net.minecraft.client.particle.ParticleRenderType +import net.minecraft.client.particle.TextureSheetParticle +import net.minecraft.client.renderer.texture.TextureAtlasSprite + +class DefaultGasParticle(level: ClientLevel, x: Double, y: Double, z: Double, xSpeed: Double, ySpeed: Double, zSpeed: Double): + TextureSheetParticle(level, x, y, z, xSpeed, ySpeed, zSpeed) { + + + + override fun getRenderType(): ParticleRenderType { + return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt new file mode 100644 index 0000000..6f7cb89 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt @@ -0,0 +1,19 @@ +package org.valkyrienskies.kelvin.impl.client.particle + +import net.minecraft.core.particles.ParticleType +import net.minecraft.world.level.Level +import org.valkyrienskies.kelvin.api.DuctNodePos +import org.valkyrienskies.kelvin.api.ParticleTypePicker + +class DefaultGasParticlePicker(val particleType: ParticleType<*>) : ParticleTypePicker() { + + override fun chooseParticleType( + level: Level, + temperature: Double, + pressure: Double, + ductNodePos: DuctNodePos + ): ParticleType<*> { + return particleType + } + +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt new file mode 100644 index 0000000..bfda1e8 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt @@ -0,0 +1,31 @@ +package org.valkyrienskies.kelvin.impl.client.particle + +import net.fabricmc.api.EnvType +import net.fabricmc.api.Environment +import net.minecraft.client.multiplayer.ClientLevel +import net.minecraft.client.particle.Particle +import net.minecraft.client.particle.ParticleProvider +import net.minecraft.client.particle.SpriteSet +import net.minecraft.core.particles.SimpleParticleType + +class DefaultGasParticleProvider(private val sprite: SpriteSet): ParticleProvider { + + override fun createParticle( + type: SimpleParticleType, + level: ClientLevel, + x: Double, + y: Double, + z: Double, + xSpeed: Double, + ySpeed: Double, + zSpeed: Double + ): Particle { + val particle = DefaultGasParticle(level,x,y,z,xSpeed,ySpeed,zSpeed) + particle.setSpriteFromAge(sprite) + level.isClientSide + return particle + } + + +} + diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt new file mode 100644 index 0000000..ae19573 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt @@ -0,0 +1,5 @@ +package org.valkyrienskies.kelvin.impl.client.particle + +import net.minecraft.core.particles.SimpleParticleType + +class DefaultGasParticleType : SimpleParticleType(false) \ No newline at end of file From 2a053877a97aaf55f0c182cf96e3009f9b3a6391 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 8 Jun 2025 10:08:59 +0300 Subject: [PATCH 18/37] remove compiler args that i accidentally committed --- common/build.gradle | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index c6f4581..da22eac 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -18,19 +18,6 @@ dependencies { api "org.jetbrains.kotlin:kotlin-reflect:1.9.10" } -kotlin { - // This block configures the Kotlin compiler for this module - compilerOptions { - // Add your desired free compiler arguments here - freeCompilerArgs = [ - "-Xtype-enhancement-improvements-strict-mode ", - "-Xjvm-default=all-compatibility" - ] - - // jvmTarget = "17" // Example: Set JVM target version - } -} - publishing { publications { mavenCommon(MavenPublication) { From c6657a94b1f8160e915e85bd82a4f38abdbe9383 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 8 Jun 2025 10:45:42 +0300 Subject: [PATCH 19/37] fully functional particle registry --- .../valkyrienskies/kelvin/KelvinParticles.kt | 15 ++++++++++---- .../org/valkyrienskies/kelvin/api/GasType.kt | 18 +++++++++++++++-- ...ePicker.kt => KelvinParticleTypePicker.kt} | 5 ++++- .../kelvin/impl/GasTypeRegistry.kt | 20 +++++++------------ .../client/particle/DefaultGasParticle.kt | 9 ++++----- .../particle/DefaultGasParticlePicker.kt | 7 +++++-- .../particle/DefaultGasParticleProvider.kt | 3 --- .../client/particle/DefaultGasParticleType.kt | 5 ----- .../kelvin/util/KelvinKeyMapper.kt | 7 ++++--- .../assets/kelvin/particles/air.json | 5 +++++ .../assets/kelvin/particles/exhaust.json | 5 +++++ .../assets/kelvin/particles/helium.json | 5 +++++ .../assets/kelvin/particles/hydrogen.json | 5 +++++ .../assets/kelvin/particles/methane.json | 5 +++++ .../assets/kelvin/particles/phlogiston.json | 5 +++++ .../assets/kelvin/particles/steam.json | 5 +++++ 16 files changed, 86 insertions(+), 38 deletions(-) rename common/src/main/kotlin/org/valkyrienskies/kelvin/api/{ParticleTypePicker.kt => KelvinParticleTypePicker.kt} (60%) delete mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt create mode 100644 common/src/main/resources/assets/kelvin/particles/air.json create mode 100644 common/src/main/resources/assets/kelvin/particles/exhaust.json create mode 100644 common/src/main/resources/assets/kelvin/particles/helium.json create mode 100644 common/src/main/resources/assets/kelvin/particles/hydrogen.json create mode 100644 common/src/main/resources/assets/kelvin/particles/methane.json create mode 100644 common/src/main/resources/assets/kelvin/particles/phlogiston.json create mode 100644 common/src/main/resources/assets/kelvin/particles/steam.json diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt index aed67c3..51e669d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt @@ -4,8 +4,9 @@ import dev.architectury.registry.client.particle.ParticleProviderRegistry import dev.architectury.registry.registries.DeferredRegister import dev.architectury.registry.registries.RegistrySupplier import net.minecraft.core.Registry +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticle.DefaultGasParticleType import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticleProvider -import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticleType + object KelvinParticles { @@ -16,12 +17,14 @@ object KelvinParticles { fun registerDefaultParticle(name: String): RegistrySupplier { val supplier = PARTICLES.register(name) { DefaultGasParticleType() } ALL.add(supplier) + KelvinMod.KELVINLOGGER.info("Registered particle: ${supplier.id}") return supplier } fun init() { + KelvinMod.KELVINLOGGER.info("Registering Kelvin default gas particles...") PARTICLES.register() - KelvinMod.KELVINLOGGER.info("Registered Kelvin default gas particles") + } object KelvinClientParticles { @@ -31,8 +34,12 @@ object KelvinParticles { } fun init() { - ALL.forEach { entry -> registerDefaultParticle(entry) } - KelvinMod.KELVINLOGGER.info("Registered Kelvin default particle providers") + KelvinMod.KELVINLOGGER.info("Registering Kelvin default particle providers...") + ALL.forEach { entry -> + registerDefaultParticle(entry) + KelvinMod.KELVINLOGGER.info("Registered particle provider: ${entry.id}") + } + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt index 0487ba1..6f472ff 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt @@ -2,8 +2,9 @@ package org.valkyrienskies.kelvin.api import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize -import net.minecraft.core.particles.ParticleType import net.minecraft.resources.ResourceLocation +import org.valkyrienskies.kelvin.KelvinParticles +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker import org.valkyrienskies.kelvin.util.KelvinKeyMapper @JsonSerialize(using = KelvinKeyMapper.GasTypeSerializer::class) @@ -20,10 +21,23 @@ data class GasType( val combustible: Boolean = false, // Whether the gas can be used as fuel val calorificValue: Double = 0.0, // (J / kg) (see https://en.wikipedia.org/wiki/Energy_density), only use if [combustible] is true val iconLocation: ResourceLocation? = null, - val particleType: ParticleType + val particleTypePicker: KelvinParticleTypePicker ) { + override fun toString(): String { val iconLoc = iconLocation?.toString() ?: "null" return "$name, $density, $viscosity, $specificHeatCapacity, $thermalConductivity, $sutherlandConstant, $adiabaticIndex, $combustible, $calorificValue, $iconLoc" } + + companion object { + fun withDefaultParticlePicker(name: String, resourceLocation: ResourceLocation, density: Double, viscosity: Double, specificHeatCapacity: Double, + thermalConductivity: Double, sutherlandConstant: Double = 111.0, adiabaticIndex: Double = 1.4, combustible: Boolean = false, + calorificValue: Double = 0.0, iconLocation: ResourceLocation? = null): GasType { + val particleType = KelvinParticles.registerDefaultParticle(resourceLocation.path).get() + val typePicker = DefaultGasParticlePicker(particleType) + + return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, + sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation, typePicker) + } + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/ParticleTypePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt similarity index 60% rename from common/src/main/kotlin/org/valkyrienskies/kelvin/api/ParticleTypePicker.kt rename to common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt index 01061df..927615c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/ParticleTypePicker.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt @@ -3,7 +3,10 @@ package org.valkyrienskies.kelvin.api import net.minecraft.core.particles.ParticleType import net.minecraft.world.level.Level -abstract class ParticleTypePicker { +/* +A class for defining a ParticleTypePicker, which kelvin uses to pick out a ParticleType for anything it uses Particles for + */ +abstract class KelvinParticleTypePicker { abstract fun chooseParticleType(level: Level, temperature: Double, pressure: Double, ductNodePos: DuctNodePos): ParticleType<*> } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt index bff4994..eda6b83 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt @@ -22,12 +22,6 @@ object GasTypeRegistry { KELVINLOGGER.info("Icon Location: ${gasType.iconLocation}") } - fun registerGasType(name: String, resourceLocation: ResourceLocation, density: Double, viscosity: Double, - specificHeatCapacity: Double, thermalConductivity: Double, sutherlandConstant: Double, - adiabaticIndex: Double, combustible: Boolean, calorificValue: Double, iconLocation: ResourceLocation? = null) { - gas = GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) - } - fun getGasType(resourceLocation: ResourceLocation): GasType? { return GAS_TYPES[resourceLocation] } @@ -37,15 +31,15 @@ object GasTypeRegistry { } fun init () { - val air = GasType("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026) - val exhaust = GasType("Exhaust", ResourceLocation(KelvinMod.MOD_ID, "exhaust"), 1.98, 1.10e-5, 2.2, 0.031) - val steam = GasType("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031) + val air = GasType.withDefaultParticlePicker("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026) + val exhaust = GasType.withDefaultParticlePicker("Exhaust", ResourceLocation(KelvinMod.MOD_ID, "exhaust"), 1.98, 1.10e-5, 2.2, 0.031) + val steam = GasType.withDefaultParticlePicker("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031) - val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8) - val helium = GasType("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66) - val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8) - val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7) + val phlogiston = GasType.withDefaultParticlePicker("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8) + val helium = GasType.withDefaultParticlePicker("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66) + val hydrogen = GasType.withDefaultParticlePicker("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8) + val methane = GasType.withDefaultParticlePicker("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7) registerGasType(air) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt index a3f8f84..b4f64bc 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt @@ -3,14 +3,13 @@ package org.valkyrienskies.kelvin.impl.client.particle import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.client.particle.ParticleRenderType import net.minecraft.client.particle.TextureSheetParticle -import net.minecraft.client.renderer.texture.TextureAtlasSprite - -class DefaultGasParticle(level: ClientLevel, x: Double, y: Double, z: Double, xSpeed: Double, ySpeed: Double, zSpeed: Double): - TextureSheetParticle(level, x, y, z, xSpeed, ySpeed, zSpeed) { - +import net.minecraft.core.particles.SimpleParticleType +class DefaultGasParticle(level: ClientLevel, x: Double, y: Double, z: Double, xSpeed: Double, ySpeed: Double, zSpeed: Double): TextureSheetParticle(level, x, y, z, xSpeed, ySpeed, zSpeed) { override fun getRenderType(): ParticleRenderType { return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT } + + class DefaultGasParticleType : SimpleParticleType(false) } \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt index 6f7cb89..41b6fc6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt @@ -3,9 +3,12 @@ package org.valkyrienskies.kelvin.impl.client.particle import net.minecraft.core.particles.ParticleType import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.api.DuctNodePos -import org.valkyrienskies.kelvin.api.ParticleTypePicker +import org.valkyrienskies.kelvin.api.KelvinParticleTypePicker -class DefaultGasParticlePicker(val particleType: ParticleType<*>) : ParticleTypePicker() { +/* +The default ParticlePicker. Allows you to make a ParticlePicker which always returns a single ParticleType + */ +class DefaultGasParticlePicker(val particleType: ParticleType<*>) : KelvinParticleTypePicker() { override fun chooseParticleType( level: Level, diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt index bfda1e8..eb0fcdb 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleProvider.kt @@ -1,7 +1,5 @@ package org.valkyrienskies.kelvin.impl.client.particle -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.client.particle.Particle import net.minecraft.client.particle.ParticleProvider @@ -22,7 +20,6 @@ class DefaultGasParticleProvider(private val sprite: SpriteSet): ParticleProvide ): Particle { val particle = DefaultGasParticle(level,x,y,z,xSpeed,ySpeed,zSpeed) particle.setSpriteFromAge(sprite) - level.isClientSide return particle } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt deleted file mode 100644 index ae19573..0000000 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticleType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.valkyrienskies.kelvin.impl.client.particle - -import net.minecraft.core.particles.SimpleParticleType - -class DefaultGasParticleType : SimpleParticleType(false) \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt index e64cc01..872b754 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt @@ -8,7 +8,6 @@ import com.fasterxml.jackson.databind.JsonSerializer import com.fasterxml.jackson.databind.KeyDeserializer import com.fasterxml.jackson.databind.SerializerProvider import net.minecraft.resources.ResourceLocation -import org.valkyrienskies.kelvin.api.DuctNode import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.api.GasType @@ -80,7 +79,8 @@ object KelvinKeyMapper { val calorificValue = parts[9].toDoubleOrNull() val iconLocation = if (parts[10] == "null") null else ResourceLocation(parts[10]) if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { - return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) + //TODO: SERIALIZE PARTICLE PICKER + return GasType.withDefaultParticlePicker(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) } else throw IllegalArgumentException("Invalid GasType string") } } @@ -142,7 +142,8 @@ object KelvinKeyMapper { val iconLocation = if (parts[10] == "null") null else ResourceLocation(parts[10]) if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { - return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) + //TODO: SERIALIZE PARTICLE PICKER + return GasType.withDefaultParticlePicker(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) } } } diff --git a/common/src/main/resources/assets/kelvin/particles/air.json b/common/src/main/resources/assets/kelvin/particles/air.json new file mode 100644 index 0000000..7f6a270 --- /dev/null +++ b/common/src/main/resources/assets/kelvin/particles/air.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "mymod:particle/simple_example_particle" + ] +} diff --git a/common/src/main/resources/assets/kelvin/particles/exhaust.json b/common/src/main/resources/assets/kelvin/particles/exhaust.json new file mode 100644 index 0000000..7f6a270 --- /dev/null +++ b/common/src/main/resources/assets/kelvin/particles/exhaust.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "mymod:particle/simple_example_particle" + ] +} diff --git a/common/src/main/resources/assets/kelvin/particles/helium.json b/common/src/main/resources/assets/kelvin/particles/helium.json new file mode 100644 index 0000000..7f6a270 --- /dev/null +++ b/common/src/main/resources/assets/kelvin/particles/helium.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "mymod:particle/simple_example_particle" + ] +} diff --git a/common/src/main/resources/assets/kelvin/particles/hydrogen.json b/common/src/main/resources/assets/kelvin/particles/hydrogen.json new file mode 100644 index 0000000..7f6a270 --- /dev/null +++ b/common/src/main/resources/assets/kelvin/particles/hydrogen.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "mymod:particle/simple_example_particle" + ] +} diff --git a/common/src/main/resources/assets/kelvin/particles/methane.json b/common/src/main/resources/assets/kelvin/particles/methane.json new file mode 100644 index 0000000..7f6a270 --- /dev/null +++ b/common/src/main/resources/assets/kelvin/particles/methane.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "mymod:particle/simple_example_particle" + ] +} diff --git a/common/src/main/resources/assets/kelvin/particles/phlogiston.json b/common/src/main/resources/assets/kelvin/particles/phlogiston.json new file mode 100644 index 0000000..7f6a270 --- /dev/null +++ b/common/src/main/resources/assets/kelvin/particles/phlogiston.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "mymod:particle/simple_example_particle" + ] +} diff --git a/common/src/main/resources/assets/kelvin/particles/steam.json b/common/src/main/resources/assets/kelvin/particles/steam.json new file mode 100644 index 0000000..7f6a270 --- /dev/null +++ b/common/src/main/resources/assets/kelvin/particles/steam.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "mymod:particle/simple_example_particle" + ] +} From 869a569c8b7d56d38d3d621b32081a90677f564f Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 8 Jun 2025 13:59:25 +0300 Subject: [PATCH 20/37] add DuctNetwork.createGasParticle() and particle test feature --- .../valkyrienskies/kelvin/api/DuctNetwork.kt | 7 ++----- .../kelvin/api/KelvinParticleTypePicker.kt | 4 ++-- .../kelvin/impl/DuctNetworkServer.kt | 14 ++++++++++++++ .../kelvin/impl/client/DuctNetworkClient.kt | 17 ++++++++++++++++- .../client/particle/DefaultGasParticlePicker.kt | 11 +++++------ 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/DuctNetwork.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/DuctNetwork.kt index d2daddd..47bce73 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/DuctNetwork.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/DuctNetwork.kt @@ -1,16 +1,12 @@ package org.valkyrienskies.kelvin.api -import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.player.Player import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.impl.DuctNodeInfo import org.valkyrienskies.kelvin.impl.client.ClientKelvinInfo import org.valkyrienskies.kelvin.util.KelvinChunkPos -import java.util.EnumMap -import java.util.logging.Logger /** * The main class representing the Duct Network. @@ -73,7 +69,6 @@ interface DuctNetwork { fun removeEdge(posA: DuctNodePos, posB: DuctNodePos) { KELVINLOGGER.warn("You can't modify this from here. Called: removeEdge") } - fun modTemperature(pos: DuctNodePos, deltaTemperature: Double) { KELVINLOGGER.warn("You can't modify this from here. Called: modTemperature") } @@ -90,6 +85,8 @@ interface DuctNetwork { KELVINLOGGER.warn("You can't modify this from here. Called: modHeatEnergy") } + fun createGasParticle(level: T, gasType: GasType, pos: DuctNodePos, x: Double, y: Double, z: Double, xSpeed: Double, ySpeed: Double, zSpeed: Double) + // the real meat fun tick(level: T, subSteps: Int = 1) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt index 927615c..7905d0d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt @@ -1,12 +1,12 @@ package org.valkyrienskies.kelvin.api -import net.minecraft.core.particles.ParticleType +import net.minecraft.core.particles.ParticleOptions import net.minecraft.world.level.Level /* A class for defining a ParticleTypePicker, which kelvin uses to pick out a ParticleType for anything it uses Particles for */ abstract class KelvinParticleTypePicker { - abstract fun chooseParticleType(level: Level, temperature: Double, pressure: Double, ductNodePos: DuctNodePos): ParticleType<*> + abstract fun chooseParticleOptions(level: Level, ductNodePos: DuctNodePos): ParticleOptions } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index 00d6e61..34e701d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -220,6 +220,20 @@ class DuctNetworkServer( } + override fun createGasParticle( + level: ServerLevel, + gasType: GasType, + pos: DuctNodePos, + x: Double, + y: Double, + z: Double, + xSpeed: Double, + ySpeed: Double, + zSpeed: Double + ) { + KELVINLOGGER.warn("Server can't add Particles.") + } + override fun tick(level: ServerLevel, subSteps: Int) { if (disabled) return diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt index a6cae33..af7aa39 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt @@ -9,7 +9,6 @@ import org.valkyrienskies.kelvin.impl.DuctNodeInfo import org.valkyrienskies.kelvin.networking.KelvinRequestChunkSyncPacket import org.valkyrienskies.kelvin.util.KelvinChunkPos import org.valkyrienskies.kelvin.util.KelvinExtensions.toChunkPos -import java.util.* import kotlin.collections.HashMap import kotlin.collections.HashSet @@ -37,6 +36,13 @@ class DuctNetworkClient: DuctNetwork { override fun tick(level: ClientLevel, subSteps: Int) { if (disabled) return + nodeInfo.forEach { pos, node -> + if (node.currentPressure - node.previousPressure > 1000) { + val largestGas = node.currentGasMasses.maxBy { (_, amount) -> amount }.key + createGasParticle(level, largestGas, pos, pos.x, pos.y, pos.z, 0.0, 0.0, 0.0) + } + } + ticksSinceLastSync++ } @@ -110,6 +116,15 @@ class DuctNetworkClient: DuctNetwork { nodeInfo.remove(pos) } + override fun createGasParticle( + level: ClientLevel, gasType: GasType, pos: DuctNodePos, + x: Double, y: Double, z: Double, + xSpeed: Double, ySpeed: Double, zSpeed: Double + ) { + val particleOptions = gasType.particleTypePicker.chooseParticleOptions(level, pos) + level.addParticle(particleOptions, x, y, z, xSpeed, ySpeed, zSpeed) + } + override fun getHeatEnergy(pos: DuctNodePos): Double { return getTemperatureAt(pos) * specificHeatAverage(getGasMassAt(pos)) * getGasMassAt(pos).values.sum() } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt index 41b6fc6..642b7f7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt @@ -1,6 +1,7 @@ package org.valkyrienskies.kelvin.impl.client.particle -import net.minecraft.core.particles.ParticleType +import net.minecraft.core.particles.ParticleOptions +import net.minecraft.core.particles.SimpleParticleType import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.api.KelvinParticleTypePicker @@ -8,14 +9,12 @@ import org.valkyrienskies.kelvin.api.KelvinParticleTypePicker /* The default ParticlePicker. Allows you to make a ParticlePicker which always returns a single ParticleType */ -class DefaultGasParticlePicker(val particleType: ParticleType<*>) : KelvinParticleTypePicker() { +class DefaultGasParticlePicker(val particleType: SimpleParticleType) : KelvinParticleTypePicker() { - override fun chooseParticleType( + override fun chooseParticleOptions( level: Level, - temperature: Double, - pressure: Double, ductNodePos: DuctNodePos - ): ParticleType<*> { + ): ParticleOptions { return particleType } From 48818bb802b6fa644327f4e6c5c7386444b94abb Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Sun, 8 Jun 2025 14:49:14 +0300 Subject: [PATCH 21/37] change values --- .../org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt index af7aa39..acf232b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt @@ -11,6 +11,7 @@ import org.valkyrienskies.kelvin.util.KelvinChunkPos import org.valkyrienskies.kelvin.util.KelvinExtensions.toChunkPos import kotlin.collections.HashMap import kotlin.collections.HashSet +import kotlin.math.abs class DuctNetworkClient: DuctNetwork { @@ -37,7 +38,7 @@ class DuctNetworkClient: DuctNetwork { if (disabled) return nodeInfo.forEach { pos, node -> - if (node.currentPressure - node.previousPressure > 1000) { + if (abs(node.currentPressure - node.previousPressure) > 1) { val largestGas = node.currentGasMasses.maxBy { (_, amount) -> amount }.key createGasParticle(level, largestGas, pos, pos.x, pos.y, pos.z, 0.0, 0.0, 0.0) } From f3941c92d73e9feb89b81e6b729533d9586d2bb6 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Wed, 11 Jun 2025 22:13:11 +0300 Subject: [PATCH 22/37] Made GasParticlePickerRegistry --- .../org/valkyrienskies/kelvin/KelvinMod.kt | 6 +- .../org/valkyrienskies/kelvin/api/GasType.kt | 15 +---- ...eTypePicker.kt => KelvinParticlePicker.kt} | 2 +- .../kelvin/impl/DuctNetworkServer.kt | 1 + .../kelvin/impl/GasTypeRegistry.kt | 53 --------------- .../kelvin/impl/KelvinReactionDataLoader.kt | 2 + .../kelvin/impl/client/DuctNetworkClient.kt | 4 +- .../particle/DefaultGasParticlePicker.kt | 4 +- .../registry/GasParticlePickerRegistry.kt | 44 ++++++++++++ .../kelvin/impl/registry/GasTypeRegistry.kt | 67 +++++++++++++++++++ .../ReactionRequirementRegistry.kt | 5 +- .../kelvin/serialization/NodeNBTUtil.kt | 2 +- .../kelvin/util/KelvinKeyMapper.kt | 4 +- 13 files changed, 132 insertions(+), 77 deletions(-) rename common/src/main/kotlin/org/valkyrienskies/kelvin/api/{KelvinParticleTypePicker.kt => KelvinParticlePicker.kt} (89%) delete mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt rename common/src/main/kotlin/org/valkyrienskies/kelvin/impl/{ => registry}/ReactionRequirementRegistry.kt (85%) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt index c09a9bc..eeb8f5a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt @@ -17,10 +17,11 @@ import net.minecraft.world.level.chunk.ChunkAccess import org.valkyrienskies.kelvin.api.DuctNetwork import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.impl.DuctNetworkServer -import org.valkyrienskies.kelvin.impl.GasTypeRegistry -import org.valkyrienskies.kelvin.impl.ReactionRequirementRegistry +import org.valkyrienskies.kelvin.impl.registry.ReactionRequirementRegistry import org.valkyrienskies.kelvin.impl.client.DuctNetworkClient import org.valkyrienskies.kelvin.impl.logger +import org.valkyrienskies.kelvin.impl.registry.GasParticlePickerRegistry +import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry import org.valkyrienskies.kelvin.networking.KelvinNetworking import org.valkyrienskies.kelvin.serialization.SerializableDuctNetwork import org.valkyrienskies.kelvin.util.KelvinChunkPos @@ -115,6 +116,7 @@ object KelvinMod { KELVINLOGGER.info("Registering gas types...") GasTypeRegistry.init() ReactionRequirementRegistry.init() + GasParticlePickerRegistry.init() KELVINLOGGER.info("--- --- ---") KELVINLOGGER.info("Finished registering gas types. We have ${GasTypeRegistry.GAS_TYPES.size} gasses registered!") diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt index 6f472ff..c3e865c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinParticles import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker +import org.valkyrienskies.kelvin.impl.registry.ReactionRequirementRegistry import org.valkyrienskies.kelvin.util.KelvinKeyMapper @JsonSerialize(using = KelvinKeyMapper.GasTypeSerializer::class) @@ -20,8 +21,7 @@ data class GasType( val adiabaticIndex: Double = 1.4, // (dimensionless) (see https://en.wikipedia.org/wiki/Adiabatic_index) Not required, 1.4 is air's. Technically an approximation, only useful for pockets, but oh well. val combustible: Boolean = false, // Whether the gas can be used as fuel val calorificValue: Double = 0.0, // (J / kg) (see https://en.wikipedia.org/wiki/Energy_density), only use if [combustible] is true - val iconLocation: ResourceLocation? = null, - val particleTypePicker: KelvinParticleTypePicker + val iconLocation: ResourceLocation? = null ) { override fun toString(): String { @@ -29,15 +29,4 @@ data class GasType( return "$name, $density, $viscosity, $specificHeatCapacity, $thermalConductivity, $sutherlandConstant, $adiabaticIndex, $combustible, $calorificValue, $iconLoc" } - companion object { - fun withDefaultParticlePicker(name: String, resourceLocation: ResourceLocation, density: Double, viscosity: Double, specificHeatCapacity: Double, - thermalConductivity: Double, sutherlandConstant: Double = 111.0, adiabaticIndex: Double = 1.4, combustible: Boolean = false, - calorificValue: Double = 0.0, iconLocation: ResourceLocation? = null): GasType { - val particleType = KelvinParticles.registerDefaultParticle(resourceLocation.path).get() - val typePicker = DefaultGasParticlePicker(particleType) - - return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, - sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation, typePicker) - } - } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticlePicker.kt similarity index 89% rename from common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt rename to common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticlePicker.kt index 7905d0d..524ffae 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticleTypePicker.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/KelvinParticlePicker.kt @@ -6,7 +6,7 @@ import net.minecraft.world.level.Level /* A class for defining a ParticleTypePicker, which kelvin uses to pick out a ParticleType for anything it uses Particles for */ -abstract class KelvinParticleTypePicker { +abstract class KelvinParticlePicker { abstract fun chooseParticleOptions(level: Level, ductNodePos: DuctNodePos): ParticleOptions } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index 34e701d..c509d55 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -13,6 +13,7 @@ import org.valkyrienskies.kelvin.api.DuctNetwork.Companion.idealGasConstant import org.valkyrienskies.kelvin.api.edges.* import org.valkyrienskies.kelvin.api.nodes.TankDuctNode import org.valkyrienskies.kelvin.impl.client.ClientKelvinInfo +import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry import org.valkyrienskies.kelvin.networking.KelvinSyncPacket import org.valkyrienskies.kelvin.util.* import org.valkyrienskies.kelvin.util.KelvinExtensions.toChunkPos diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt deleted file mode 100644 index eda6b83..0000000 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/GasTypeRegistry.kt +++ /dev/null @@ -1,53 +0,0 @@ -package org.valkyrienskies.kelvin.impl - -import net.minecraft.resources.ResourceLocation -import org.valkyrienskies.kelvin.KelvinMod -import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER -import org.valkyrienskies.kelvin.api.GasType - -object GasTypeRegistry { - val GAS_TYPES = mutableMapOf() - - fun registerGasType(resourceLocation: ResourceLocation, gasType: GasType) { - GAS_TYPES[resourceLocation] = gasType - } - - fun registerGasType(gasType: GasType) { - KELVINLOGGER.info("Registering gas type ${gasType.resourceLocation}...") - registerGasType(gasType.resourceLocation, gasType) - KELVINLOGGER.info("Registered gas type ${gasType.resourceLocation}, with properties:") - KELVINLOGGER.info("Density: ${gasType.density} | Viscosity: ${gasType.viscosity} | Specific Heat Capacity: ${gasType.specificHeatCapacity} | Thermal Conductivity: ${gasType.thermalConductivity}") - KELVINLOGGER.info("Sutherland Constant: ${gasType.sutherlandConstant} | Adiabatic Index: ${gasType.adiabaticIndex}") - KELVINLOGGER.info("Is it combustible?: ${gasType.combustible} | if so, it's Calorific Value is: ${gasType.calorificValue}") - KELVINLOGGER.info("Icon Location: ${gasType.iconLocation}") - } - - fun getGasType(resourceLocation: ResourceLocation): GasType? { - return GAS_TYPES[resourceLocation] - } - - fun getGasType(modid: String, name: String): GasType? { - return getGasType(ResourceLocation(modid, name)) - } - - fun init () { - val air = GasType.withDefaultParticlePicker("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026) - val exhaust = GasType.withDefaultParticlePicker("Exhaust", ResourceLocation(KelvinMod.MOD_ID, "exhaust"), 1.98, 1.10e-5, 2.2, 0.031) - val steam = GasType.withDefaultParticlePicker("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031) - - - val phlogiston = GasType.withDefaultParticlePicker("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8) - val helium = GasType.withDefaultParticlePicker("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66) - val hydrogen = GasType.withDefaultParticlePicker("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8) - val methane = GasType.withDefaultParticlePicker("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7) - - - registerGasType(air) - registerGasType(exhaust) - registerGasType(steam) - registerGasType(phlogiston) - registerGasType(helium) - registerGasType(hydrogen) - registerGasType(methane) - } -} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt index 9889dc3..ea6525a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt @@ -10,6 +10,8 @@ import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.api.GasReaction import org.valkyrienskies.kelvin.api.GasReactionRequirement import org.valkyrienskies.kelvin.api.GasType +import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry +import org.valkyrienskies.kelvin.impl.registry.ReactionRequirementRegistry object KelvinReactionDataLoader { val gas_reactions = hashMapOf() diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt index acf232b..54c40cb 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt @@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Player import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.api.* import org.valkyrienskies.kelvin.impl.DuctNodeInfo +import org.valkyrienskies.kelvin.impl.registry.GasParticlePickerRegistry import org.valkyrienskies.kelvin.networking.KelvinRequestChunkSyncPacket import org.valkyrienskies.kelvin.util.KelvinChunkPos import org.valkyrienskies.kelvin.util.KelvinExtensions.toChunkPos @@ -122,7 +123,8 @@ class DuctNetworkClient: DuctNetwork { x: Double, y: Double, z: Double, xSpeed: Double, ySpeed: Double, zSpeed: Double ) { - val particleOptions = gasType.particleTypePicker.chooseParticleOptions(level, pos) + val particleTypePicker = GasParticlePickerRegistry.getParticlePicker(gasType) ?: return KELVINLOGGER.error("${gasType.resourceLocation} lacks a ParticlePicker") + val particleOptions = particleTypePicker.chooseParticleOptions(level, pos) level.addParticle(particleOptions, x, y, z, xSpeed, ySpeed, zSpeed) } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt index 642b7f7..a5acaf8 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt @@ -4,12 +4,12 @@ import net.minecraft.core.particles.ParticleOptions import net.minecraft.core.particles.SimpleParticleType import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.api.DuctNodePos -import org.valkyrienskies.kelvin.api.KelvinParticleTypePicker +import org.valkyrienskies.kelvin.api.KelvinParticlePicker /* The default ParticlePicker. Allows you to make a ParticlePicker which always returns a single ParticleType */ -class DefaultGasParticlePicker(val particleType: SimpleParticleType) : KelvinParticleTypePicker() { +class DefaultGasParticlePicker(val particleType: SimpleParticleType) : KelvinParticlePicker() { override fun chooseParticleOptions( level: Level, diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt new file mode 100644 index 0000000..6414315 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt @@ -0,0 +1,44 @@ +package org.valkyrienskies.kelvin.impl.registry + +import net.minecraft.resources.ResourceLocation +import org.valkyrienskies.kelvin.KelvinParticles +import org.valkyrienskies.kelvin.api.GasType +import org.valkyrienskies.kelvin.api.KelvinParticlePicker +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker + + +object GasParticlePickerRegistry { + //TODO Make this datapack-compatible (so that GAS_PARTICLE_PICKERS and PARTICLE_PICKERS got synced to client) + val PARTICLE_PICKERS = HashMap() + val GAS_PARTICLE_PICKERS = HashMap() + + fun registerParticlePicker(resourceLocation: ResourceLocation, particlePicker: KelvinParticlePicker) { + PARTICLE_PICKERS[resourceLocation] = particlePicker + } + + fun registerGasToParticlePicker(resourceLocation: ResourceLocation, gasType: GasType) { + GAS_PARTICLE_PICKERS[gasType] = resourceLocation + } + + fun register(resourceLocation: ResourceLocation, gasType: GasType, particlePicker: KelvinParticlePicker) { + registerParticlePicker(resourceLocation, particlePicker) + registerGasToParticlePicker(resourceLocation, gasType) + } + + fun registerWithDefaultParticlePicker(gasType: GasType) { + val particleType = KelvinParticles.registerDefaultParticle(gasType.resourceLocation.path).get() + val particlePicker = DefaultGasParticlePicker(particleType) + register(gasType.resourceLocation, gasType, particlePicker) + + } + + fun getParticlePicker(resourceLocation: ResourceLocation): KelvinParticlePicker? { + return PARTICLE_PICKERS[resourceLocation] + } + + fun getParticlePicker(gasType: GasType): KelvinParticlePicker? { + return PARTICLE_PICKERS[GAS_PARTICLE_PICKERS[gasType] ?: return null] + } + + fun init () {} +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt new file mode 100644 index 0000000..b2b90c7 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt @@ -0,0 +1,67 @@ +package org.valkyrienskies.kelvin.impl.registry + +import net.minecraft.resources.ResourceLocation +import org.valkyrienskies.kelvin.KelvinMod +import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER +import org.valkyrienskies.kelvin.api.GasType +import org.valkyrienskies.kelvin.api.KelvinParticlePicker +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticle +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker + +object GasTypeRegistry { + val GAS_TYPES = mutableMapOf() + + fun registerGasType(resourceLocation: ResourceLocation, gasType: GasType) { + GAS_TYPES[resourceLocation] = gasType + } + + fun registerGasType(gasType: GasType) { + KELVINLOGGER.info("Registering gas type ${gasType.resourceLocation}...") + registerGasType(gasType.resourceLocation, gasType) + KELVINLOGGER.info("Registered gas type ${gasType.resourceLocation}, with properties:") + KELVINLOGGER.info("Density: ${gasType.density} | Viscosity: ${gasType.viscosity} | Specific Heat Capacity: ${gasType.specificHeatCapacity} | Thermal Conductivity: ${gasType.thermalConductivity}") + KELVINLOGGER.info("Sutherland Constant: ${gasType.sutherlandConstant} | Adiabatic Index: ${gasType.adiabaticIndex}") + KELVINLOGGER.info("Is it combustible?: ${gasType.combustible} | if so, it's Calorific Value is: ${gasType.calorificValue}") + KELVINLOGGER.info("Icon Location: ${gasType.iconLocation}") + } + + fun register(gasType: GasType, particlePicker: KelvinParticlePicker) { + GasParticlePickerRegistry.registerParticlePicker(gasType.resourceLocation, particlePicker) + GasParticlePickerRegistry.registerGasToParticlePicker(gasType.resourceLocation, gasType) + registerGasType(gasType) + } + + fun register(gasType: GasType) { + GasParticlePickerRegistry.registerWithDefaultParticlePicker(gasType) + registerGasType(gasType) + } + + fun getGasType(resourceLocation: ResourceLocation): GasType? { + return GAS_TYPES[resourceLocation] + } + + fun getGasType(modid: String, name: String): GasType? { + return getGasType(ResourceLocation(modid, name)) + } + + fun init () { + val air = GasType("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026) + val exhaust = GasType("Exhaust", ResourceLocation(KelvinMod.MOD_ID, "exhaust"), 1.98, 1.10e-5, 2.2, 0.031) + val steam = GasType("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031) + + + val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8) + val helium = GasType("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66) + val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8) + val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7) + + + register(air) + register(exhaust) + register(steam) + register(phlogiston) + register(helium) + register(hydrogen) + register(methane) + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/ReactionRequirementRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/ReactionRequirementRegistry.kt similarity index 85% rename from common/src/main/kotlin/org/valkyrienskies/kelvin/impl/ReactionRequirementRegistry.kt rename to common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/ReactionRequirementRegistry.kt index 8d9f326..a027b0e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/ReactionRequirementRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/ReactionRequirementRegistry.kt @@ -1,11 +1,12 @@ -package org.valkyrienskies.kelvin.impl +package org.valkyrienskies.kelvin.impl.registry import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.api.GasReactionRequirement +import org.valkyrienskies.kelvin.impl.DefaultKelvinRequirements object ReactionRequirementRegistry { - val REACTION_REQUIREMENTS = mutableMapOf() + val REACTION_REQUIREMENTS = HashMap() fun registerReactionRequirement(resourceLocation: ResourceLocation, reactionRequirement: GasReactionRequirement) { REACTION_REQUIREMENTS[resourceLocation] = reactionRequirement diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt index 3557ad0..984750d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/serialization/NodeNBTUtil.kt @@ -6,7 +6,7 @@ import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.DuctNetwork import org.valkyrienskies.kelvin.api.DuctNodePos -import org.valkyrienskies.kelvin.impl.GasTypeRegistry +import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry object NodeNBTUtil { fun serializeNode(pos: DuctNodePos, network: DuctNetwork, tag: CompoundTag) { diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt index 872b754..0254ef3 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt @@ -80,7 +80,7 @@ object KelvinKeyMapper { val iconLocation = if (parts[10] == "null") null else ResourceLocation(parts[10]) if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { //TODO: SERIALIZE PARTICLE PICKER - return GasType.withDefaultParticlePicker(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) + return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) } else throw IllegalArgumentException("Invalid GasType string") } } @@ -143,7 +143,7 @@ object KelvinKeyMapper { if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { //TODO: SERIALIZE PARTICLE PICKER - return GasType.withDefaultParticlePicker(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) + return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) } } } From 8c52e5988d81521fe9aea624119c0490e9468305 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Wed, 11 Jun 2025 23:04:17 +0300 Subject: [PATCH 23/37] swap SimpleParticleType to ParticleOptions --- .../kelvin/impl/client/particle/DefaultGasParticlePicker.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt index a5acaf8..9ee96de 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticlePicker.kt @@ -9,13 +9,13 @@ import org.valkyrienskies.kelvin.api.KelvinParticlePicker /* The default ParticlePicker. Allows you to make a ParticlePicker which always returns a single ParticleType */ -class DefaultGasParticlePicker(val particleType: SimpleParticleType) : KelvinParticlePicker() { +class DefaultGasParticlePicker(val particleOptions: ParticleOptions) : KelvinParticlePicker() { override fun chooseParticleOptions( level: Level, ductNodePos: DuctNodePos ): ParticleOptions { - return particleType + return particleOptions } } \ No newline at end of file From d375a232931fa3448b263165fda4fb257236e9f7 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 12 Jun 2025 12:17:12 +0300 Subject: [PATCH 24/37] big commit --- .../org/valkyrienskies/kelvin/KelvinMod.kt | 4 ++-- .../kelvin/impl/registry/GasTypeRegistry.kt | 14 +++++++------- .../kelvin/integration/jei/KelvinJeiPlugin.kt | 2 +- .../assets/kelvin/textures/icons/air.png | Bin 1040 -> 516 bytes .../assets/kelvin/textures/icons/default.png | Bin 0 -> 500 bytes .../assets/kelvin/textures/icons/exhaust.png | Bin 0 -> 407 bytes .../assets/kelvin/textures/icons/helium.png | Bin 0 -> 416 bytes .../assets/kelvin/textures/icons/hydrogen.png | Bin 0 -> 483 bytes .../assets/kelvin/textures/icons/methane.png | Bin 927 -> 605 bytes .../kelvin/textures/icons/phlogiston.png | Bin 0 -> 491 bytes .../assets/kelvin/textures/icons/steam.png | Bin 0 -> 448 bytes fabric/build.gradle | 1 - .../kelvin/forge/KelvinModForge.kt | 4 ++++ 13 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/default.png create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/exhaust.png create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/helium.png create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/hydrogen.png create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/phlogiston.png create mode 100644 common/src/main/resources/assets/kelvin/textures/icons/steam.png diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt index eeb8f5a..009db3b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt @@ -45,7 +45,7 @@ object KelvinMod { KELVINLOGGER.info("Initializing Kelvin...") networkManager = SimpleNetworkManager.create(MOD_ID) - KelvinParticles.init() + LifecycleEvent.SERVER_BEFORE_START.register { Kelvin.disabled = false @@ -109,7 +109,7 @@ object KelvinMod { } - + KelvinParticles.init() KelvinNetworking.init() KelvinDamageSources.init() diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt index 55412a6..635184c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt @@ -49,15 +49,15 @@ object GasTypeRegistry { } fun init () { - val air = GasType("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026) - val exhaust = GasType("Exhaust", ResourceLocation(KelvinMod.MOD_ID, "exhaust"), 1.98, 1.10e-5, 2.2, 0.031) - val steam = GasType("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031) + val air = GasType("Air",ResourceLocation(KelvinMod.MOD_ID, "air"), 1.293, 1.716e-5, 1.005, 0.026, iconLocation = getIcon("air")) + val exhaust = GasType("Exhaust", ResourceLocation(KelvinMod.MOD_ID, "exhaust"), 1.98, 1.10e-5, 2.2, 0.031, iconLocation = getIcon("exhaust")) + val steam = GasType("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031, iconLocation = getIcon("steam")) - val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8) - val helium = GasType("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66) - val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8) - val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7) + val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8, iconLocation = getIcon("phlogiston")) + val helium = GasType("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66, iconLocation = getIcon("helium")) + val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8, iconLocation = getIcon("hydrogen")) + val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7, iconLocation = getIcon("methane")) register(air) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt index 9d1a593..d3a0276 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt @@ -10,7 +10,7 @@ import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.MOD_ID import org.valkyrienskies.kelvin.api.GasReaction -import org.valkyrienskies.kelvin.impl.GasTypeRegistry +import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry import org.valkyrienskies.kelvin.impl.KelvinReactionDataLoader diff --git a/common/src/main/resources/assets/kelvin/textures/icons/air.png b/common/src/main/resources/assets/kelvin/textures/icons/air.png index ced2d28bdb5362f1ef0f25f12c96ef741cb00d0d..dc338863518dde8aa929c95399b893c76c2b05bd 100644 GIT binary patch delta 478 zcmV<40U`d72!sTXFnA$9Zee9%B}Ae~Dj|DIOu#}IK^DX> zaE+jl*ePC-;y!|fh5w3x5frqw4s4Tv-9=e8kV1kS;bJ4Cw#c$q#93!I>#v%5XP)1@ z?>jRBO}kJ3LcY=M>Vim%M?nSO6th#C_MV3TjBf*G3OTO#g@1?{RIb8sTpXstNt5-z zT^^STQC6aI6@~zf>SSZ5AH={?-iYG$mciOw6M(n(5wB%QCJk1Q($3L@&=8EX0&Eo4hOUI zT$UyDf=LOwI)D8j)`!MJ6Wem4w3QBK=P`E;%#ZE>$feeDrQ>_p6}xMZmMx638cxk9Bj);H;}RxsxIp$zYeq1Tj?cvzDujU!u7ro(Jg#k z)ufT97eh8=56>rdy63yGhGs~-J{?x+C*hagI``*`0$24Hq^yM}jbi|6)!(SG4)XbY zbr}6ON?8j5+U*me#sCXH4r69I4DcU48MNd(`#1go000hUSV?A0O#mtY000O800000 U007cclK=n!07*qoM6N<$fJ~|x;fp`*ZrtiD2l4Cr9nd@!WZ$Me|Y*V(bE^;Nicr&c|5V= zMd`$3GGzf&FcdU`R`F_72Q8)>Iu9fv2KZh+f0mEDExv_-zvsZlva@17e@;=1)J0Q| zKaIy=>(9*?!+%mIx(vIl$L>53t8oD=G`W=PXj zYz9 zrBbERQz@6pZeO>JVeQ1m#>Q`7J`~tyy_4hvy*!}X3u(MaQ+8<7s$iyRq26e$fu{BQ zd|qo{Fhm#g1;tPd#?3jXhTN={%M!@#dgJ=0`t05(9|QV(b2C8@rum!d4PTKeZL`?| z!C=V#=6_(HGTE%G$LW?`Zl_h2YjyGb0z91Sy3uOoECk7Rb+Iy9#>)$4#`0C=sse_t zPiuxIF%0b-9vN=8~eSI5l-X8)YJ#CvHsUY zz0nFB=lFTT@9UjFsy4Zs-79l`4{)r51JDDxvw}J|JKLsgOvA~spsT8TfA4VJ#xN|) z*kyDZ$SuF(r360^o^a4zLGiL6%eC52BobjYMFWx`WVzXDhk`xjn%w3sR?=C_7r!1I z8wK=VRR9>TM(2eGnZtwZ;?ZI5@#y&Y6K6X^vA_SZ&P-2#m^G2)EX~k6k|eWUk6SLB z7o<}8^6J(HespT4ZRoR{%jK}KbaFeh<#l_wfBJ$UxVR`z>~8Ns cHy?QMFF{hsI!>hiUjP6A07*qoM6N<$f)Px$lu1NER5*=wQ?X70K@fdM2!+J3Ar>C7;1)v&6#_N{sU&o^);89b78d-8HH3sl zDy)Fe7zh<1guCkwW3em+hS;nH?!w;Tt9Ewgy?HZxXTXPQrYz*SI~y4OydPRYHB%Pk zOfB9E0k7|M zbY}x2moD_UEpc{9NMY?OBOP z7wNdAEl~;ZwP$qgh9dLGLKE@Bf+mXsfa>gQdZ5vYw%kJ}Y~_Kkz1^2cVhK@A-DAZ1 z006e~K%*6;&P|OZbJDTQ82~_H3GrBXI%-vRRC_ugTF0000pI<%#TK*E*73GY?JlsJzsFol@W6`RdwDt)e$Vr(73_1UAJyQ7hxve*Dq? z;1^kS_IDgjlQRDY(&Bk6(-qDQ_* zZn~vhw6kx+xv-qB{3R>*CR;mJ_q*tM1RDo<_$TcCts?%hUo9ZKVbiVTx1~PJJARk& z9e91XY5RQs_nRuJKECJ5_B~d-ZMXk_ZFi-Ia})!@s?{Fv^yixKLC>NzclSyMhOA$= yPcLz@6*b&{>-EOWsbT!Q!0_ZtjqptK^<~fkvN?bl1TF>zRUzG*Or3ZICmO8biJW(CH*mH{j=-X0zqFaEKJ^e9SB@(Fa;Rh+4y&9zb0 zcy1!+BNe76itEaEe_Lns`KjLh_jiB4i)v!Cjh8F9UAKI?Q0?8UrrXP<%aS>gGhKSv zIM;7GdhFJ^6*(%e%GnrBytBXfa_Nzu;?oqQb$hddIDfTU|9Nyuyx{Q48+#bLST4_L z*u@k1i~D$kYJ|!mkM^%otBjf^wRE{K2x$o|-kQp)JBx33(xW}xRVBQ8=IaQb5wl;U zX)d>vgTe~ HDWM4fAdsgi literal 0 HcmV?d00001 diff --git a/common/src/main/resources/assets/kelvin/textures/icons/hydrogen.png b/common/src/main/resources/assets/kelvin/textures/icons/hydrogen.png new file mode 100644 index 0000000000000000000000000000000000000000..36032737b0b5106c97674695e57e2cdf41f730aa GIT binary patch literal 483 zcmV<90UZ8`P)Px$gGod|R5*=olOb=yP!xr~M@W`5;SVf%Gs84fI0&wOIFOa?WEbYpbt53x%F5w3 zk0ZrZEePEB2_(x-;ywVOzpfDAQfZ(z)RYJx$}h-YR$HH*oxW^7sHH)t%dm<)~N2)RWQM0WMweI<(fxY{A~*VgcM zFz6XqJ3PN{l&hW6ZSkUtZbB5l5c+GO%P?*xNhYSkVx~jtIHnx0000EWmrjOO-%qQ00008 Z000000002eQ}NI2i*jaFnj@!a6-0x6Rph&3Q-v#2A%ElAodKNvZhYP`)}jwB z8C! ziaWb#xi|pXRDXtgUPsHtS=))Jor!4BZxm~G#&0(W%tX|3q~wj&$4XT;m0>V2Y}vu- z3y!NxbBkWOFZb}H*5uvh8(cOQThE_yuIDVHx2E~}WsifsPm084bMgIWm2b(jMWt6Yyb+p5y)-%c%kV!L1J%6vG5&!Fw)e^h9FRA43ot*t{ zrBLRpl@f*b2kk?W3d}{)*Yi5**9jc<4n-uv76pywiF!`6&!#e#)0N=zhx0s5?g{}g zJ`gs7;VOWoQ=@r;!`{JuTHv{Uto}=|8liPnVFO@p(QBD;KP@QM?07gPx!py(zGW(q zO8AGF!7%{80R2G#*7*5{q5uE@4rN$LW=%~1DgXcg2mk;800000(o>TF00000BichyoFr!M zoI_l2OdQ)X@n@)+yO{CDgo~OOvS>CEl3h&iT%s|P5S&-;oK7wZs0k3EP6{2iPzXP@ zV9P1}ITXI-JEb_^n=g6u{C#;|ga7~oK;~sx2J;+`Fhao6G=JutJR$&=VKMLI5Z*!p zAdCQ^|1I#Q3bQE!0KhN|=6PO%F*J*Lo+GIAAOM6UQkqGUyhj26l8EDY2}ZLl<~eT5 zlkC!JnfzM>Cjx|lp^3W_kw1_m97&Ra6G@y&K(-hGy&2v7kfyA+VQ8`ys(sDQVOAo) zbAD%<4zu+iB7Z`hoSR^pX0X29a_zfadH!F%9Jworyf>0Sde`-)l={jL7-kq2o34L2 zxF=r``0K~Q0uC8JgXaOzxn#x zTd*ECti<96XI8W4%sO>>iCQ^76ZMs;nfiCR_J4f2rhi~2vFrM1a0Mc3rP{jEYWUml z4V@_WK|;(|RTdO4jV`|}iHh#$c7r9~E#!JXH?|H)E%XE})SuHv+sU%r#z)i1gZ?E= z?l-nQv;DKvE`xftp+Hpy1&XQXQ>&q4Nu2eMQl4HO% zZT%Wjao12N4suz*Fd=9lmV8mSyHFddDfx6kOh%0b>iW~2Lp?v=In;TSH25FyIC`9o S?Zs690000Px$i%CR5R5*==lfO$sQ545N&m8&z8T2F?t|6fWW#GlB=}j$E;- z`AFfo*`QALa&#TXC7H274TeJsQgVEC34kR8@o1El=dTGbkMt_U}m?(%+~o&iW6<;eo^w>oyNNUK`=CusCKMhR0hg%;VP=_h3wXq>pxc0<4vIb0Z^oRd`JUy>?eAQ|b?BfHATIO|sVO;5Uwz z-HeztdL8#JCJtmPVk&^c#krAqsXuTVdE>qp<|Xnf^sD;?D3_fylE&F%0000EWmrjO hO-%qQ00008000000002eQPx$U`a$lR5*=wk}+$-P!PxeG0slK*}=JV@DmhE9mPV#LYG2^x>YDxECoxYTL)M7 ziUD05gMNY_A#(shRFX2Zr1B)1_lx=MHGNYoPOV&G3JUz~KFFD2qj&;<*lhXe^2t8B5LF_o7 zpE@Ywq;n8@+#m=&e2Xtr0nJa4AIZ#8oArjFwm@L5YNJ-Q4Fyz;3U5|R-UC^2>Mkt6 zQN59C>_AVV*$F29Aa>yA*l}740LGI!CpGI0_BX2~ZXd=BuV)iX-Gya5B!Wrq+35v> z(8GE*L2u-;4*-dBBnmoCOMTAfJnP56!Fl_RJLyIs?|_`^_EkDb9Rt$#2a@jU5siNV q6951J4rN$LW=%~1DgXcg2mk;800000(o>TF0000 From 3e7191fe0b9328555872fa0b48600eb05a7e610f Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 12 Jun 2025 18:29:51 +0300 Subject: [PATCH 25/37] fix everything --- .../org/valkyrienskies/kelvin/KelvinMod.kt | 10 ++++++++-- .../org/valkyrienskies/kelvin/api/GasType.kt | 7 ++++++- .../impl/registry/GasParticlePickerRegistry.kt | 5 +++-- .../kelvin/impl/registry/GasTypeRegistry.kt | 2 +- .../integration/jei/KelvinGasIngredient.kt | 1 - .../jei/KelvinReactionRecipeCategory.kt | 3 ++- .../kelvin/util/KelvinKeyMapper.kt | 4 ++-- .../icons/{default.png => placeholder.png} | Bin .../kelvin/fabric/KelvinModFabric.kt | 2 ++ .../kelvin/forge/KelvinModForge.kt | 16 ++++++++++++++-- 10 files changed, 38 insertions(+), 12 deletions(-) rename common/src/main/resources/assets/kelvin/textures/icons/{default.png => placeholder.png} (100%) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt index 009db3b..a5f8469 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt @@ -1,6 +1,7 @@ package org.valkyrienskies.kelvin import com.fasterxml.jackson.module.kotlin.readValue +import dev.architectury.event.events.client.ClientLifecycleEvent import dev.architectury.event.events.client.ClientPlayerEvent import dev.architectury.event.events.client.ClientTickEvent import dev.architectury.event.events.common.ChunkEvent @@ -9,6 +10,7 @@ import dev.architectury.event.events.common.TickEvent import dev.architectury.networking.simple.SimpleNetworkManager import dev.architectury.platform.Platform import dev.architectury.utils.Env +import net.minecraft.client.Minecraft import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.nbt.CompoundTag import net.minecraft.resources.ResourceLocation @@ -17,17 +19,18 @@ import net.minecraft.world.level.chunk.ChunkAccess import org.valkyrienskies.kelvin.api.DuctNetwork import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.impl.DuctNetworkServer -import org.valkyrienskies.kelvin.impl.registry.ReactionRequirementRegistry import org.valkyrienskies.kelvin.impl.client.DuctNetworkClient import org.valkyrienskies.kelvin.impl.logger import org.valkyrienskies.kelvin.impl.registry.GasParticlePickerRegistry import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry +import org.valkyrienskies.kelvin.impl.registry.ReactionRequirementRegistry import org.valkyrienskies.kelvin.networking.KelvinNetworking import org.valkyrienskies.kelvin.serialization.SerializableDuctNetwork import org.valkyrienskies.kelvin.util.KelvinChunkPos import org.valkyrienskies.kelvin.util.KelvinDamageSources import org.valkyrienskies.kelvin.util.KelvinJacksonUtil + object KelvinMod { const val MOD_ID = "kelvin" @@ -40,6 +43,7 @@ object KelvinMod { val Kelvin: DuctNetworkServer = DuctNetworkServer() val KelvinClient: DuctNetworkClient = DuctNetworkClient() + @JvmStatic fun init() { KELVINLOGGER.info("Initializing Kelvin...") @@ -125,7 +129,7 @@ object KelvinMod { @JvmStatic fun initClient() { - KelvinParticles.KelvinClientParticles.init() + ClientPlayerEvent.CLIENT_PLAYER_JOIN.register { if (Platform.getEnvironment() == Env.CLIENT) KelvinClient.disabled = false @@ -138,6 +142,8 @@ object KelvinMod { ClientTickEvent.CLIENT_LEVEL_POST.register { KelvinClient.tick(it, 10) //todo substeps config } + + } fun getKelvin(): DuctNetwork { diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt index 0809864..1312412 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt @@ -3,6 +3,7 @@ package org.valkyrienskies.kelvin.api import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import net.minecraft.resources.ResourceLocation +import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinParticles import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker import org.valkyrienskies.kelvin.impl.registry.ReactionRequirementRegistry @@ -21,7 +22,7 @@ data class GasType( val adiabaticIndex: Double = 1.4, // (dimensionless) (see https://en.wikipedia.org/wiki/Adiabatic_index) Not required, 1.4 is air's. Technically an approximation, only useful for pockets, but oh well. val combustible: Boolean = false, // Whether the gas can be used as fuel val calorificValue: Double = 0.0, // (J / kg) (see https://en.wikipedia.org/wiki/Energy_density), only use if [combustible] is true - val iconLocation: ResourceLocation? = null + val iconLocation: ResourceLocation = PLACEHOLDER_ICON ) { override fun toString(): String { @@ -29,4 +30,8 @@ data class GasType( return "{$name, $density, $viscosity, $specificHeatCapacity, $thermalConductivity, $sutherlandConstant, $adiabaticIndex, $combustible, $calorificValue, $iconLoc}" } + + companion object { + val PLACEHOLDER_ICON = KelvinMod.asResouceLocation("textures/icons/placeholder.png") + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt index 6414315..621d3b0 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt @@ -4,6 +4,7 @@ import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinParticles import org.valkyrienskies.kelvin.api.GasType import org.valkyrienskies.kelvin.api.KelvinParticlePicker +import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticle import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker @@ -26,8 +27,8 @@ object GasParticlePickerRegistry { } fun registerWithDefaultParticlePicker(gasType: GasType) { - val particleType = KelvinParticles.registerDefaultParticle(gasType.resourceLocation.path).get() - val particlePicker = DefaultGasParticlePicker(particleType) + KelvinParticles.registerDefaultParticle(gasType.resourceLocation.path) + val particlePicker = DefaultGasParticlePicker(DefaultGasParticle.DefaultGasParticleType()) register(gasType.resourceLocation, gasType, particlePicker) } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt index 635184c..e3b16af 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt @@ -45,7 +45,7 @@ object GasTypeRegistry { } private fun getIcon(name: String): ResourceLocation { - return KelvinMod.asResouceLocation("textures/icons/$name") + return KelvinMod.asResouceLocation("textures/icons/$name.png") } fun init () { diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt index 7483aef..ab5e20f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt @@ -60,7 +60,6 @@ class GasIngredientRenderer: IIngredientRenderer { } override fun render(stack: PoseStack, ingredient: KelvinGasIngredient) { - if (ingredient.gasType.iconLocation == null) return RenderSystem.setShaderTexture(0, ingredient.gasType.iconLocation) GuiComponent.blit(stack, 0, 0, 0, 0f, 0f, 16, 16, 16, 16); diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt index ca72467..1eecf56 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt @@ -13,6 +13,7 @@ import net.minecraft.network.chat.TextComponent import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.GasReaction +import org.valkyrienskies.kelvin.api.GasType import org.valkyrienskies.kelvin.integration.jei.KelvinJeiPlugin.Companion.GAS_INGREDIENT_TYPE class KelvinReactionRecipeCategory : IRecipeCategory { @@ -25,7 +26,7 @@ class KelvinReactionRecipeCategory : IRecipeCategory { } override fun getIcon(): IDrawable { - return ImageDrawable(16,16, KelvinMod.asResouceLocation("placeholder")) + return ImageDrawable(16,16, GasType.PLACEHOLDER_ICON) } override fun getUid(): ResourceLocation { diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt index 0254ef3..0b88ed7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt @@ -77,7 +77,7 @@ object KelvinKeyMapper { val adiabaticIndex = parts[7].toDoubleOrNull() val combustible = parts[8].toBoolean() val calorificValue = parts[9].toDoubleOrNull() - val iconLocation = if (parts[10] == "null") null else ResourceLocation(parts[10]) + val iconLocation = ResourceLocation(parts[10]) if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { //TODO: SERIALIZE PARTICLE PICKER return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) @@ -139,7 +139,7 @@ object KelvinKeyMapper { val adiabaticIndex = parts[7].toDoubleOrNull() val combustible = parts[8].toBoolean() val calorificValue = parts[9].toDoubleOrNull() - val iconLocation = if (parts[10] == "null") null else ResourceLocation(parts[10]) + val iconLocation = ResourceLocation(parts[10]) if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { //TODO: SERIALIZE PARTICLE PICKER diff --git a/common/src/main/resources/assets/kelvin/textures/icons/default.png b/common/src/main/resources/assets/kelvin/textures/icons/placeholder.png similarity index 100% rename from common/src/main/resources/assets/kelvin/textures/icons/default.png rename to common/src/main/resources/assets/kelvin/textures/icons/placeholder.png diff --git a/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt b/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt index 615b816..0da0331 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/kelvin/fabric/KelvinModFabric.kt @@ -18,6 +18,7 @@ import java.util.concurrent.CompletableFuture import net.minecraft.server.packs.resources.ResourceManager import net.minecraft.util.profiling.ProfilerFiller import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener +import org.valkyrienskies.kelvin.KelvinParticles import java.util.concurrent.Executor @@ -74,6 +75,7 @@ object KelvinModFabric: ModInitializer { class Client : ClientModInitializer { override fun onInitializeClient() { initClient() + KelvinParticles.KelvinClientParticles.init() } } } diff --git a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt index 50dbf92..75bc7db 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt @@ -2,15 +2,18 @@ package org.valkyrienskies.kelvin.forge import dev.architectury.platform.forge.EventBuses import net.minecraft.server.level.ServerLevel +import net.minecraftforge.client.event.ParticleFactoryRegisterEvent import net.minecraftforge.event.AddReloadListenerEvent +import net.minecraftforge.event.RegistryEvent import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.init import org.valkyrienskies.kelvin.KelvinMod.initClient +import org.valkyrienskies.kelvin.KelvinParticles import org.valkyrienskies.kelvin.impl.KelvinReactionDataLoader import org.valkyrienskies.kelvin.util.KelvinChunkPos import thedarkcolour.kotlinforforge.forge.FORGE_BUS @@ -26,7 +29,12 @@ class KelvinModForge { } EventBuses.registerModEventBus(KelvinMod.MOD_ID, getModBus()); - init() + + + MOD_BUS.addListener { event: FMLCommonSetupEvent -> + init() + } + FORGE_BUS.addListener { event: ChunkEvent.Load -> if (!event.world.isClientSide) { @@ -63,6 +71,10 @@ class KelvinModForge { } FORGE_BUS.addListener(::registerResourceManagers) + + MOD_BUS.addListener { event: ParticleFactoryRegisterEvent -> + KelvinParticles.KelvinClientParticles.init() + } } private fun registerResourceManagers(event: AddReloadListenerEvent) { From 9fd683b25bc4abd0b66e518ab14d8dee0749a655 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 12 Jun 2025 22:35:48 +0300 Subject: [PATCH 26/37] make particles register on forge --- .../org/valkyrienskies/kelvin/KelvinParticles.kt | 1 + .../valkyrienskies/kelvin/forge/KelvinModForge.kt | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt index 51e669d..16d86ca 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt @@ -30,6 +30,7 @@ object KelvinParticles { object KelvinClientParticles { fun registerDefaultParticle(supplier: RegistrySupplier) { + KelvinMod.KELVINLOGGER.info("Registered particle provider: ${supplier.id}") ParticleProviderRegistry.register(supplier.get(), ::DefaultGasParticleProvider) } diff --git a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt index 75bc7db..01de4ad 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt @@ -23,18 +23,12 @@ import thedarkcolour.kotlinforforge.forge.MOD_BUS class KelvinModForge { init { MOD_BUS.addListener { event: FMLClientSetupEvent? -> - clientSetup( - event - ) + println("CLIENT SET UP") + clientSetup(event) } EventBuses.registerModEventBus(KelvinMod.MOD_ID, getModBus()); - - - MOD_BUS.addListener { event: FMLCommonSetupEvent -> - init() - } - + init() FORGE_BUS.addListener { event: ChunkEvent.Load -> if (!event.world.isClientSide) { From 2c9f9f286aabcc13f59bead5d530b7b522091fdd Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 12 Jun 2025 22:47:18 +0300 Subject: [PATCH 27/37] remove no longer needed combustible values in GasType --- .../org/valkyrienskies/kelvin/api/GasType.kt | 9 ++------- .../kelvin/impl/registry/GasTypeRegistry.kt | 9 +++------ .../kelvin/util/KelvinKeyMapper.kt | 16 ++++++---------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt index 1312412..db42ac6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasType.kt @@ -4,9 +4,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod -import org.valkyrienskies.kelvin.KelvinParticles -import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker -import org.valkyrienskies.kelvin.impl.registry.ReactionRequirementRegistry import org.valkyrienskies.kelvin.util.KelvinKeyMapper @JsonSerialize(using = KelvinKeyMapper.GasTypeSerializer::class) @@ -20,14 +17,12 @@ data class GasType( val thermalConductivity: Double, // (W / (m * K)) val sutherlandConstant: Double = 111.0, // (dimensionless) (see https://en.wikipedia.org/wiki/Viscosity#Temperature_dependence) val adiabaticIndex: Double = 1.4, // (dimensionless) (see https://en.wikipedia.org/wiki/Adiabatic_index) Not required, 1.4 is air's. Technically an approximation, only useful for pockets, but oh well. - val combustible: Boolean = false, // Whether the gas can be used as fuel - val calorificValue: Double = 0.0, // (J / kg) (see https://en.wikipedia.org/wiki/Energy_density), only use if [combustible] is true val iconLocation: ResourceLocation = PLACEHOLDER_ICON ) { override fun toString(): String { - val iconLoc = iconLocation?.toString() ?: "null" - return "{$name, $density, $viscosity, $specificHeatCapacity, $thermalConductivity, $sutherlandConstant, $adiabaticIndex, $combustible, $calorificValue, $iconLoc}" + val iconLoc = iconLocation.toString() + return "{$name, $density, $viscosity, $specificHeatCapacity, $thermalConductivity, $sutherlandConstant, $adiabaticIndex, $iconLoc}" } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt index e3b16af..1ded6f6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasTypeRegistry.kt @@ -5,8 +5,6 @@ import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.api.GasType import org.valkyrienskies.kelvin.api.KelvinParticlePicker -import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticle -import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker object GasTypeRegistry { val GAS_TYPES = mutableMapOf() @@ -21,7 +19,6 @@ object GasTypeRegistry { KELVINLOGGER.info("Registered gas type ${gasType.resourceLocation}, with properties:") KELVINLOGGER.info("Density: ${gasType.density} | Viscosity: ${gasType.viscosity} | Specific Heat Capacity: ${gasType.specificHeatCapacity} | Thermal Conductivity: ${gasType.thermalConductivity}") KELVINLOGGER.info("Sutherland Constant: ${gasType.sutherlandConstant} | Adiabatic Index: ${gasType.adiabaticIndex}") - KELVINLOGGER.info("Is it combustible?: ${gasType.combustible} | if so, it's Calorific Value is: ${gasType.calorificValue}") KELVINLOGGER.info("Icon Location: ${gasType.iconLocation}") } @@ -54,10 +51,10 @@ object GasTypeRegistry { val steam = GasType("Steam", ResourceLocation(KelvinMod.MOD_ID, "steam"), 1.98, 1.716e-5, 2.2, 0.031, iconLocation = getIcon("steam")) - val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, true, 3.5e+8, iconLocation = getIcon("phlogiston")) + val phlogiston = GasType("Phlogiston",ResourceLocation(KelvinMod.MOD_ID, "phlogiston"), 3.0, 2.0e-5, 14.30, 0.240, 150.0, 1.008, iconLocation = getIcon("phlogiston")) val helium = GasType("Helium",ResourceLocation(KelvinMod.MOD_ID, "helium"),0.166, 1.96e-5, 5.1832, 0.151, 79.4, 1.66, iconLocation = getIcon("helium")) - val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, true, 1.418e+8, iconLocation = getIcon("hydrogen")) - val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, true, 5.55e+7, iconLocation = getIcon("methane")) + val hydrogen = GasType("Hydrogen",ResourceLocation(KelvinMod.MOD_ID, "hydrogen"), 0.08988, 0.88e-5, 14.30, 0.18, 72.0, 1.4, iconLocation = getIcon("hydrogen")) + val methane = GasType("Methane",ResourceLocation(KelvinMod.MOD_ID, "methane"), 0.657, 1.10e-5, 2.2, 0.031, 90.0, 16.0, iconLocation = getIcon("methane")) register(air) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt index 0b88ed7..b73eacb 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/KelvinKeyMapper.kt @@ -75,12 +75,10 @@ object KelvinKeyMapper { val thermalConductivity = parts[5].toDoubleOrNull() val sutherlandConstant = parts[6].toDoubleOrNull() val adiabaticIndex = parts[7].toDoubleOrNull() - val combustible = parts[8].toBoolean() - val calorificValue = parts[9].toDoubleOrNull() - val iconLocation = ResourceLocation(parts[10]) - if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { + val iconLocation = ResourceLocation(parts[8]) + if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null) { //TODO: SERIALIZE PARTICLE PICKER - return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) + return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, iconLocation) } else throw IllegalArgumentException("Invalid GasType string") } } @@ -137,13 +135,11 @@ object KelvinKeyMapper { val thermalConductivity = parts[5].toDoubleOrNull() val sutherlandConstant = parts[6].toDoubleOrNull() val adiabaticIndex = parts[7].toDoubleOrNull() - val combustible = parts[8].toBoolean() - val calorificValue = parts[9].toDoubleOrNull() - val iconLocation = ResourceLocation(parts[10]) + val iconLocation = ResourceLocation(parts[8]) - if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null && calorificValue != null) { + if (density != null && viscosity != null && specificHeatCapacity != null && thermalConductivity != null && sutherlandConstant != null && adiabaticIndex != null) { //TODO: SERIALIZE PARTICLE PICKER - return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, combustible, calorificValue, iconLocation) + return GasType(name, resourceLocation, density, viscosity, specificHeatCapacity, thermalConductivity, sutherlandConstant, adiabaticIndex, iconLocation) } } } From 9d1733bd17a11871aa19a34b5dad72c8fb03adf9 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 12 Jun 2025 22:52:45 +0300 Subject: [PATCH 28/37] bump mod version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9cbf6cc..1107ab5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M # Identity mod_name=Kelvin mod_id=kelvin -mod_version=0.1.4 +mod_version=0.1.5 mod_description=A dynamic gas framework for Minecraft. mod_license=Apache-2.0 mod_author=ThePlasticPotato, PriestOfFern From bd548b84b261eb83d4677f7ed5d5b28a6428b001 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Thu, 12 Jun 2025 22:58:10 +0300 Subject: [PATCH 29/37] clean up code --- .../valkyrienskies/kelvin/api/edges/AllInOneDuctEdge.kt | 3 +-- .../valkyrienskies/kelvin/api/edges/ApertureDuctEdge.kt | 3 +-- .../kelvin/api/edges/ApertureFilteredDuctEdge.kt | 6 +----- .../kelvin/api/edges/ApertureOneWayDuctEdge.kt | 3 +-- .../valkyrienskies/kelvin/api/edges/FilteredDuctEdge.kt | 8 ++++---- .../org/valkyrienskies/kelvin/api/edges/PipeDuctEdge.kt | 3 +-- .../valkyrienskies/kelvin/impl/client/ClientKelvinInfo.kt | 3 +-- .../kelvin/integration/jei/ImageDrawable.kt | 2 +- .../kelvin/integration/jei/KelvinGasIngredient.kt | 2 +- .../kotlin/org/valkyrienskies/kelvin/util/GasHeatLevel.kt | 4 ++-- .../org/valkyrienskies/kelvin/forge/KelvinModForge.kt | 4 +--- 11 files changed, 15 insertions(+), 26 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/AllInOneDuctEdge.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/AllInOneDuctEdge.kt index 12f08aa..96f4283 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/AllInOneDuctEdge.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/AllInOneDuctEdge.kt @@ -16,5 +16,4 @@ class AllInOneDuctEdge( override var aperture: Double = 0.0, override var reversed: Boolean = false, override val filter: HashSet = HashSet(), override var blacklist: Boolean = false, override var unloaded: Boolean = false -) : DuctEdge, ApertureEdge, OneWayEdge, FilteredEdge { -} \ No newline at end of file +) : DuctEdge, ApertureEdge, OneWayEdge, FilteredEdge \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureDuctEdge.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureDuctEdge.kt index 24892af..28ba34c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureDuctEdge.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureDuctEdge.kt @@ -14,5 +14,4 @@ class ApertureDuctEdge( override var radius: Double = 0.125, override var length: Double = 0.5, override var currentFlowRate: Double = 0.0, override var aperture: Double = 0.0, override var unloaded: Boolean = false -) : DuctEdge, ApertureEdge { -} \ No newline at end of file +) : DuctEdge, ApertureEdge \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureFilteredDuctEdge.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureFilteredDuctEdge.kt index 48e8767..1106ef0 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureFilteredDuctEdge.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureFilteredDuctEdge.kt @@ -1,7 +1,6 @@ package org.valkyrienskies.kelvin.api.edges import org.valkyrienskies.kelvin.api.ConnectionType -import org.valkyrienskies.kelvin.api.DuctEdge import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.api.GasType @@ -17,7 +16,4 @@ class ApertureFilteredDuctEdge( override var blacklist: Boolean = false, override var aperture: Double = 0.0, override var unloaded: Boolean = false -) : ApertureEdge, FilteredEdge { - - -} \ No newline at end of file +) : ApertureEdge, FilteredEdge \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureOneWayDuctEdge.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureOneWayDuctEdge.kt index ea311f3..d22076e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureOneWayDuctEdge.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/ApertureOneWayDuctEdge.kt @@ -15,5 +15,4 @@ class ApertureOneWayDuctEdge( override var aperture: Double = 0.0, override var reversed: Boolean = false, override var unloaded: Boolean = false -) : DuctEdge, ApertureEdge, OneWayEdge { -} \ No newline at end of file +) : DuctEdge, ApertureEdge, OneWayEdge \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/FilteredDuctEdge.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/FilteredDuctEdge.kt index 84c480f..526188b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/FilteredDuctEdge.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/FilteredDuctEdge.kt @@ -1,6 +1,8 @@ package org.valkyrienskies.kelvin.api.edges -import org.valkyrienskies.kelvin.api.* +import org.valkyrienskies.kelvin.api.ConnectionType +import org.valkyrienskies.kelvin.api.DuctNodePos +import org.valkyrienskies.kelvin.api.GasType /** * A default edge type that has a filter which only allows certain gas types to flow through it. Its filter can either be a Whitelist or a Blacklist. @@ -13,6 +15,4 @@ class FilteredDuctEdge( override val filter: HashSet = HashSet(), override var blacklist: Boolean = false, override var unloaded: Boolean = false -) : FilteredEdge { - -} \ No newline at end of file +) : FilteredEdge \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/PipeDuctEdge.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/PipeDuctEdge.kt index 3228d64..08ffc1a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/PipeDuctEdge.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/edges/PipeDuctEdge.kt @@ -10,5 +10,4 @@ class PipeDuctEdge( override val nodeB: DuctNodePos, override var radius: Double = 0.125, override var length: Double = 0.5, override var currentFlowRate: Double = 0.0, override var unloaded: Boolean = false -) : DuctEdge { -} \ No newline at end of file +) : DuctEdge \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/ClientKelvinInfo.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/ClientKelvinInfo.kt index bd4073d..10594cd 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/ClientKelvinInfo.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/ClientKelvinInfo.kt @@ -3,5 +3,4 @@ package org.valkyrienskies.kelvin.impl.client import org.valkyrienskies.kelvin.api.DuctNodePos import org.valkyrienskies.kelvin.impl.DuctNodeInfo -data class ClientKelvinInfo(val nodes: HashMap) { -} +data class ClientKelvinInfo(val nodes: HashMap) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt index b3323b9..cf24b28 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt @@ -19,7 +19,7 @@ class ImageDrawable(private val width: Int, private val height: Int, private val override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { RenderSystem.setShaderTexture(0, location) - GuiComponent.blit(stack, xOffset, yOffset, 0, 0f, 0f, width, height, height, width); + GuiComponent.blit(stack, xOffset, yOffset, 0, 0f, 0f, width, height, height, width) } } \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt index ab5e20f..108dec6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt @@ -61,7 +61,7 @@ class GasIngredientRenderer: IIngredientRenderer { override fun render(stack: PoseStack, ingredient: KelvinGasIngredient) { RenderSystem.setShaderTexture(0, ingredient.gasType.iconLocation) - GuiComponent.blit(stack, 0, 0, 0, 0f, 0f, 16, 16, 16, 16); + GuiComponent.blit(stack, 0, 0, 0, 0f, 0f, 16, 16, 16, 16) super.render(stack, ingredient) } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/GasHeatLevel.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/GasHeatLevel.kt index e5567c6..efff846 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/util/GasHeatLevel.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/util/GasHeatLevel.kt @@ -16,12 +16,12 @@ enum class GasHeatLevel: StringRepresentable { } override fun getSerializedName(): String { - return name.toLowerCase(Locale.ROOT) + return name.lowercase(Locale.ROOT) } companion object { fun byIndex(index: Int): GasHeatLevel { - return values()[index] + return entries[index] } } } \ No newline at end of file diff --git a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt index 01de4ad..47e175f 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt @@ -4,12 +4,10 @@ import dev.architectury.platform.forge.EventBuses import net.minecraft.server.level.ServerLevel import net.minecraftforge.client.event.ParticleFactoryRegisterEvent import net.minecraftforge.event.AddReloadListenerEvent -import net.minecraftforge.event.RegistryEvent import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.init import org.valkyrienskies.kelvin.KelvinMod.initClient @@ -27,7 +25,7 @@ class KelvinModForge { clientSetup(event) } - EventBuses.registerModEventBus(KelvinMod.MOD_ID, getModBus()); + EventBuses.registerModEventBus(KelvinMod.MOD_ID, getModBus()) init() FORGE_BUS.addListener { event: ChunkEvent.Load -> From cbbeed420efabb4432c42a786a67e95f2ddb9f67 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Fri, 13 Jun 2025 17:33:42 +0300 Subject: [PATCH 30/37] bump mod version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 1107ab5..b94b6c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M # Identity mod_name=Kelvin mod_id=kelvin -mod_version=0.1.5 +mod_version=0.1.6 mod_description=A dynamic gas framework for Minecraft. mod_license=Apache-2.0 mod_author=ThePlasticPotato, PriestOfFern From 5bc6292ae54b3ee38d2b4ac332c1b6184631c494 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Fri, 13 Jun 2025 17:34:35 +0300 Subject: [PATCH 31/37] add basic particle textures --- .../main/resources/assets/kelvin/particles/air.json | 11 +++++++++-- .../resources/assets/kelvin/particles/exhaust.json | 11 +++++++++-- .../resources/assets/kelvin/particles/helium.json | 11 +++++++++-- .../resources/assets/kelvin/particles/hydrogen.json | 11 +++++++++-- .../resources/assets/kelvin/particles/methane.json | 11 +++++++++-- .../resources/assets/kelvin/particles/phlogiston.json | 11 +++++++++-- .../main/resources/assets/kelvin/particles/steam.json | 11 +++++++++-- 7 files changed, 63 insertions(+), 14 deletions(-) diff --git a/common/src/main/resources/assets/kelvin/particles/air.json b/common/src/main/resources/assets/kelvin/particles/air.json index 7f6a270..2712610 100644 --- a/common/src/main/resources/assets/kelvin/particles/air.json +++ b/common/src/main/resources/assets/kelvin/particles/air.json @@ -1,5 +1,12 @@ { "textures": [ - "mymod:particle/simple_example_particle" + "minecraft:generic_7", + "minecraft:generic_6", + "minecraft:generic_5", + "minecraft:generic_4", + "minecraft:generic_3", + "minecraft:generic_2", + "minecraft:generic_1", + "minecraft:generic_0" ] -} +} \ No newline at end of file diff --git a/common/src/main/resources/assets/kelvin/particles/exhaust.json b/common/src/main/resources/assets/kelvin/particles/exhaust.json index 7f6a270..2712610 100644 --- a/common/src/main/resources/assets/kelvin/particles/exhaust.json +++ b/common/src/main/resources/assets/kelvin/particles/exhaust.json @@ -1,5 +1,12 @@ { "textures": [ - "mymod:particle/simple_example_particle" + "minecraft:generic_7", + "minecraft:generic_6", + "minecraft:generic_5", + "minecraft:generic_4", + "minecraft:generic_3", + "minecraft:generic_2", + "minecraft:generic_1", + "minecraft:generic_0" ] -} +} \ No newline at end of file diff --git a/common/src/main/resources/assets/kelvin/particles/helium.json b/common/src/main/resources/assets/kelvin/particles/helium.json index 7f6a270..2712610 100644 --- a/common/src/main/resources/assets/kelvin/particles/helium.json +++ b/common/src/main/resources/assets/kelvin/particles/helium.json @@ -1,5 +1,12 @@ { "textures": [ - "mymod:particle/simple_example_particle" + "minecraft:generic_7", + "minecraft:generic_6", + "minecraft:generic_5", + "minecraft:generic_4", + "minecraft:generic_3", + "minecraft:generic_2", + "minecraft:generic_1", + "minecraft:generic_0" ] -} +} \ No newline at end of file diff --git a/common/src/main/resources/assets/kelvin/particles/hydrogen.json b/common/src/main/resources/assets/kelvin/particles/hydrogen.json index 7f6a270..2712610 100644 --- a/common/src/main/resources/assets/kelvin/particles/hydrogen.json +++ b/common/src/main/resources/assets/kelvin/particles/hydrogen.json @@ -1,5 +1,12 @@ { "textures": [ - "mymod:particle/simple_example_particle" + "minecraft:generic_7", + "minecraft:generic_6", + "minecraft:generic_5", + "minecraft:generic_4", + "minecraft:generic_3", + "minecraft:generic_2", + "minecraft:generic_1", + "minecraft:generic_0" ] -} +} \ No newline at end of file diff --git a/common/src/main/resources/assets/kelvin/particles/methane.json b/common/src/main/resources/assets/kelvin/particles/methane.json index 7f6a270..2712610 100644 --- a/common/src/main/resources/assets/kelvin/particles/methane.json +++ b/common/src/main/resources/assets/kelvin/particles/methane.json @@ -1,5 +1,12 @@ { "textures": [ - "mymod:particle/simple_example_particle" + "minecraft:generic_7", + "minecraft:generic_6", + "minecraft:generic_5", + "minecraft:generic_4", + "minecraft:generic_3", + "minecraft:generic_2", + "minecraft:generic_1", + "minecraft:generic_0" ] -} +} \ No newline at end of file diff --git a/common/src/main/resources/assets/kelvin/particles/phlogiston.json b/common/src/main/resources/assets/kelvin/particles/phlogiston.json index 7f6a270..2712610 100644 --- a/common/src/main/resources/assets/kelvin/particles/phlogiston.json +++ b/common/src/main/resources/assets/kelvin/particles/phlogiston.json @@ -1,5 +1,12 @@ { "textures": [ - "mymod:particle/simple_example_particle" + "minecraft:generic_7", + "minecraft:generic_6", + "minecraft:generic_5", + "minecraft:generic_4", + "minecraft:generic_3", + "minecraft:generic_2", + "minecraft:generic_1", + "minecraft:generic_0" ] -} +} \ No newline at end of file diff --git a/common/src/main/resources/assets/kelvin/particles/steam.json b/common/src/main/resources/assets/kelvin/particles/steam.json index 7f6a270..2712610 100644 --- a/common/src/main/resources/assets/kelvin/particles/steam.json +++ b/common/src/main/resources/assets/kelvin/particles/steam.json @@ -1,5 +1,12 @@ { "textures": [ - "mymod:particle/simple_example_particle" + "minecraft:generic_7", + "minecraft:generic_6", + "minecraft:generic_5", + "minecraft:generic_4", + "minecraft:generic_3", + "minecraft:generic_2", + "minecraft:generic_1", + "minecraft:generic_0" ] -} +} \ No newline at end of file From a1990e99c69cdb1bb438e825b503db85602e1206 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Fri, 13 Jun 2025 22:31:26 +0300 Subject: [PATCH 32/37] ParticleSpawner Block --- .../org/valkyrienskies/kelvin/KelvinMod.kt | 5 ++-- .../kelvin/debug/KelvinBlocks.kt | 18 +++++++++++ .../kelvin/debug/ParticleSpawnerBlock.kt | 30 +++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt index a5f8469..7c139f2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinMod.kt @@ -1,7 +1,6 @@ package org.valkyrienskies.kelvin import com.fasterxml.jackson.module.kotlin.readValue -import dev.architectury.event.events.client.ClientLifecycleEvent import dev.architectury.event.events.client.ClientPlayerEvent import dev.architectury.event.events.client.ClientTickEvent import dev.architectury.event.events.common.ChunkEvent @@ -10,7 +9,6 @@ import dev.architectury.event.events.common.TickEvent import dev.architectury.networking.simple.SimpleNetworkManager import dev.architectury.platform.Platform import dev.architectury.utils.Env -import net.minecraft.client.Minecraft import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.nbt.CompoundTag import net.minecraft.resources.ResourceLocation @@ -18,6 +16,7 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.chunk.ChunkAccess import org.valkyrienskies.kelvin.api.DuctNetwork import org.valkyrienskies.kelvin.api.DuctNodePos +import org.valkyrienskies.kelvin.debug.KelvinBlocks import org.valkyrienskies.kelvin.impl.DuctNetworkServer import org.valkyrienskies.kelvin.impl.client.DuctNetworkClient import org.valkyrienskies.kelvin.impl.logger @@ -117,6 +116,8 @@ object KelvinMod { KelvinNetworking.init() KelvinDamageSources.init() + KelvinBlocks.init() + KELVINLOGGER.info("Registering gas types...") GasTypeRegistry.init() ReactionRequirementRegistry.init() diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt new file mode 100644 index 0000000..ddf4236 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt @@ -0,0 +1,18 @@ +package org.valkyrienskies.kelvin.debug + +import dev.architectury.registry.registries.DeferredRegister +import net.minecraft.core.Registry +import net.minecraft.world.level.block.state.BlockBehaviour +import net.minecraft.world.level.material.Material +import org.valkyrienskies.kelvin.KelvinMod + +object KelvinBlocks { + val BLOCKS = DeferredRegister.create(KelvinMod.MOD_ID, Registry.BLOCK_REGISTRY) + + val particleSpawner = + BLOCKS.register("particle_spawner") { ParticleSpawnerBlock(BlockBehaviour.Properties.of(Material.METAL)) } + + fun init() { + BLOCKS.register() + } +} \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt new file mode 100644 index 0000000..901fe93 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt @@ -0,0 +1,30 @@ +package org.valkyrienskies.kelvin.debug + +import net.minecraft.client.multiplayer.ClientLevel +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.state.BlockState +import org.valkyrienskies.kelvin.KelvinMod +import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry +import org.valkyrienskies.kelvin.util.KelvinExtensions.toDuctNodePos +import java.util.* + +class ParticleSpawnerBlock(properties: Properties) : Block(properties) { + override fun animateTick(state: BlockState, level: Level, pos: BlockPos, random: Random) { + val kelvin = KelvinMod.KelvinClient + kelvin.createGasParticle( + level as ClientLevel, + GasTypeRegistry.GAS_TYPES.values.shuffled().first(), + pos.toDuctNodePos(level.dimension().location()), + pos.x.toDouble(), + pos.y.toDouble(), + pos.z.toDouble(), + 0.0, + 1.0, + 0.0 + ) + + super.animateTick(state, level, pos, random) + } +} \ No newline at end of file From d8559e8963bcdaa1af5d8778f1f6a56d7a123b2c Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Fri, 13 Jun 2025 23:01:29 +0300 Subject: [PATCH 33/37] fix ParticlePickerRegistry --- .../valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt | 5 ++++- .../kelvin/impl/client/DuctNetworkClient.kt | 3 +-- .../kelvin/impl/registry/GasParticlePickerRegistry.kt | 8 +++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt index 901fe93..568b114 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt @@ -13,12 +13,15 @@ import java.util.* class ParticleSpawnerBlock(properties: Properties) : Block(properties) { override fun animateTick(state: BlockState, level: Level, pos: BlockPos, random: Random) { val kelvin = KelvinMod.KelvinClient + + println("spawning particle") + kelvin.createGasParticle( level as ClientLevel, GasTypeRegistry.GAS_TYPES.values.shuffled().first(), pos.toDuctNodePos(level.dimension().location()), pos.x.toDouble(), - pos.y.toDouble(), + pos.y.toDouble() + 1.0, pos.z.toDouble(), 0.0, 1.0, diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt index 54c40cb..ef486ec 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt @@ -10,8 +10,6 @@ import org.valkyrienskies.kelvin.impl.registry.GasParticlePickerRegistry import org.valkyrienskies.kelvin.networking.KelvinRequestChunkSyncPacket import org.valkyrienskies.kelvin.util.KelvinChunkPos import org.valkyrienskies.kelvin.util.KelvinExtensions.toChunkPos -import kotlin.collections.HashMap -import kotlin.collections.HashSet import kotlin.math.abs class DuctNetworkClient: DuctNetwork { @@ -125,6 +123,7 @@ class DuctNetworkClient: DuctNetwork { ) { val particleTypePicker = GasParticlePickerRegistry.getParticlePicker(gasType) ?: return KELVINLOGGER.error("${gasType.resourceLocation} lacks a ParticlePicker") val particleOptions = particleTypePicker.chooseParticleOptions(level, pos) + println(particleOptions) level.addParticle(particleOptions, x, y, z, xSpeed, ySpeed, zSpeed) } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt index 621d3b0..6f70e62 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/registry/GasParticlePickerRegistry.kt @@ -4,7 +4,6 @@ import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinParticles import org.valkyrienskies.kelvin.api.GasType import org.valkyrienskies.kelvin.api.KelvinParticlePicker -import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticle import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticlePicker @@ -27,10 +26,9 @@ object GasParticlePickerRegistry { } fun registerWithDefaultParticlePicker(gasType: GasType) { - KelvinParticles.registerDefaultParticle(gasType.resourceLocation.path) - val particlePicker = DefaultGasParticlePicker(DefaultGasParticle.DefaultGasParticleType()) - register(gasType.resourceLocation, gasType, particlePicker) - + KelvinParticles.registerDefaultParticle(gasType.resourceLocation.path).listen { + register(gasType.resourceLocation, gasType, DefaultGasParticlePicker(it.type)) + } } fun getParticlePicker(resourceLocation: ResourceLocation): KelvinParticlePicker? { From 064a9802e3e498cb02529e5029c8f378f5c5dc0f Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Fri, 13 Jun 2025 23:03:29 +0300 Subject: [PATCH 34/37] remove debug logging --- .../org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt | 1 - .../org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt | 3 +-- .../org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt index 568b114..e2cc056 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt @@ -14,7 +14,6 @@ class ParticleSpawnerBlock(properties: Properties) : Block(properties) { override fun animateTick(state: BlockState, level: Level, pos: BlockPos, random: Random) { val kelvin = KelvinMod.KelvinClient - println("spawning particle") kelvin.createGasParticle( level as ClientLevel, diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt index ea6525a..ce56450 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/KelvinReactionDataLoader.kt @@ -3,8 +3,8 @@ package org.valkyrienskies.kelvin.impl import com.google.gson.Gson import com.google.gson.JsonElement import net.minecraft.resources.ResourceLocation -import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener import net.minecraft.server.packs.resources.ResourceManager +import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener import net.minecraft.util.profiling.ProfilerFiller import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.api.GasReaction @@ -81,7 +81,6 @@ object KelvinReactionDataLoader { val energy = if (jObject.has("energy")) jObject["energy"].asDouble else 0.0 val parsedReaction = GasReaction(gasses = gasses, requirements = requirements, energy = energy, result = result) - println(parsedReaction) gas_reactions[origin] = parsedReaction } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt index ef486ec..5f9adf1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/DuctNetworkClient.kt @@ -123,7 +123,6 @@ class DuctNetworkClient: DuctNetwork { ) { val particleTypePicker = GasParticlePickerRegistry.getParticlePicker(gasType) ?: return KELVINLOGGER.error("${gasType.resourceLocation} lacks a ParticlePicker") val particleOptions = particleTypePicker.chooseParticleOptions(level, pos) - println(particleOptions) level.addParticle(particleOptions, x, y, z, xSpeed, ySpeed, zSpeed) } From a699d9023b13c91b575dec9204437b68ed2dae56 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Fri, 13 Jun 2025 23:30:27 +0300 Subject: [PATCH 35/37] make DefaultGasParticle not have randomized speed --- .../kelvin/impl/client/particle/DefaultGasParticle.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt index b4f64bc..76bf115 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/client/particle/DefaultGasParticle.kt @@ -7,6 +7,13 @@ import net.minecraft.core.particles.SimpleParticleType class DefaultGasParticle(level: ClientLevel, x: Double, y: Double, z: Double, xSpeed: Double, ySpeed: Double, zSpeed: Double): TextureSheetParticle(level, x, y, z, xSpeed, ySpeed, zSpeed) { + init { + this.gravity = 0f + this.xd = xSpeed + this.yd = ySpeed + this.zd = zSpeed + } + override fun getRenderType(): ParticleRenderType { return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT } From 4c1bf4a3fa7ded745cb321344a306a568d5586c7 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Wed, 25 Jun 2025 19:45:34 +0300 Subject: [PATCH 36/37] fix 1.18->1.20 differences --- .../valkyrienskies/kelvin/KelvinParticles.kt | 4 +- .../kelvin/api/GasReactionRequirement.kt | 5 ++- .../kelvin/debug/KelvinBlocks.kt | 9 +++-- .../kelvin/debug/ParticleSpawnerBlock.kt | 3 +- .../kelvin/impl/DefaultKelvinRequirements.kt | 9 ++--- .../kelvin/impl/DuctNetworkServer.kt | 9 +++-- .../kelvin/integration/jei/ImageDrawable.kt | 11 ++---- .../integration/jei/KelvinGasIngredient.kt | 28 +++++--------- .../kelvin/integration/jei/KelvinJeiPlugin.kt | 4 +- .../jei/KelvinReactionRecipeCategory.kt | 37 ++++++++----------- .../kelvin/forge/KelvinModForge.kt | 14 +++---- gradle.properties | 2 +- 12 files changed, 59 insertions(+), 76 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt index 16d86ca..445176b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/KelvinParticles.kt @@ -3,7 +3,7 @@ package org.valkyrienskies.kelvin import dev.architectury.registry.client.particle.ParticleProviderRegistry import dev.architectury.registry.registries.DeferredRegister import dev.architectury.registry.registries.RegistrySupplier -import net.minecraft.core.Registry +import net.minecraft.core.registries.Registries import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticle.DefaultGasParticleType import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticleProvider @@ -12,7 +12,7 @@ import org.valkyrienskies.kelvin.impl.client.particle.DefaultGasParticleProvider object KelvinParticles { val ALL: HashSet> = HashSet() - val PARTICLES = DeferredRegister.create(KelvinMod.MOD_ID, Registry.PARTICLE_TYPE_REGISTRY) + val PARTICLES = DeferredRegister.create(KelvinMod.MOD_ID, Registries.PARTICLE_TYPE) fun registerDefaultParticle(name: String): RegistrySupplier { val supplier = PARTICLES.register(name) { DefaultGasParticleType() } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt index e3b3d26..aea8499 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/api/GasReactionRequirement.kt @@ -2,7 +2,6 @@ package org.valkyrienskies.kelvin.api import com.google.gson.JsonElement import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.Level @@ -11,6 +10,8 @@ abstract class GasReactionRequirement(val resourceLocation: ResourceLocation) { abstract fun apply_requirement(level: Level, ductNode: DuctNodePos, network: DuctNetwork<*>, value: JsonElement): Boolean - open fun get_text(value: JsonElement): Component { return TextComponent("Empty Component") } + open fun get_text(value: JsonElement): Component { + return Component.literal("Empty Component") + } } \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt index ddf4236..c585f6b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/KelvinBlocks.kt @@ -1,18 +1,19 @@ package org.valkyrienskies.kelvin.debug import dev.architectury.registry.registries.DeferredRegister -import net.minecraft.core.Registry +import net.minecraft.core.registries.Registries +import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.state.BlockBehaviour -import net.minecraft.world.level.material.Material import org.valkyrienskies.kelvin.KelvinMod object KelvinBlocks { - val BLOCKS = DeferredRegister.create(KelvinMod.MOD_ID, Registry.BLOCK_REGISTRY) + val BLOCKS = DeferredRegister.create(KelvinMod.MOD_ID, Registries.BLOCK) val particleSpawner = - BLOCKS.register("particle_spawner") { ParticleSpawnerBlock(BlockBehaviour.Properties.of(Material.METAL)) } + BLOCKS.register("particle_spawner") { ParticleSpawnerBlock(BlockBehaviour.Properties.of()) } fun init() { BLOCKS.register() + Blocks.HAY_BLOCK } } \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt index e2cc056..17c25f4 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/debug/ParticleSpawnerBlock.kt @@ -2,6 +2,7 @@ package org.valkyrienskies.kelvin.debug import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos +import net.minecraft.util.RandomSource import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState @@ -11,7 +12,7 @@ import org.valkyrienskies.kelvin.util.KelvinExtensions.toDuctNodePos import java.util.* class ParticleSpawnerBlock(properties: Properties) : Block(properties) { - override fun animateTick(state: BlockState, level: Level, pos: BlockPos, random: Random) { + override fun animateTick(state: BlockState, level: Level, pos: BlockPos, random: RandomSource) { val kelvin = KelvinMod.KelvinClient diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt index 17e5f9d..ee859c2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DefaultKelvinRequirements.kt @@ -2,7 +2,6 @@ package org.valkyrienskies.kelvin.impl import com.google.gson.JsonElement import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.DuctNetwork @@ -23,7 +22,7 @@ object DefaultKelvinRequirements { override fun get_text(value: JsonElement): Component { val doubleValue = value.asDouble - return TextComponent("Minimum Temperature: $doubleValue K") + return Component.literal("Minimum Temperature: $doubleValue K") } } @@ -39,7 +38,7 @@ object DefaultKelvinRequirements { override fun get_text(value: JsonElement): Component { val doubleValue = value.asDouble - return TextComponent("Maximum Temperature: $doubleValue K") + return Component.literal("Maximum Temperature: $doubleValue K") } } @@ -54,7 +53,7 @@ object DefaultKelvinRequirements { override fun get_text(value: JsonElement): Component { val doubleValue = value.asDouble - return TextComponent("Minimum Pressure: $doubleValue Pa") + return Component.literal("Minimum Pressure: $doubleValue Pa") } } @@ -69,7 +68,7 @@ object DefaultKelvinRequirements { override fun get_text(value: JsonElement): Component { val doubleValue = value.asDouble - return TextComponent("Maximum Pressure: $doubleValue Pa") + return Component.literal("Maximum Pressure: $doubleValue Pa") } } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt index 14513e6..64f53ab 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/impl/DuctNetworkServer.kt @@ -6,11 +6,14 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.server.level.ServerPlayer import net.minecraft.util.Mth import net.minecraft.world.entity.player.Player -import net.minecraft.world.level.Explosion +import net.minecraft.world.level.Level import org.valkyrienskies.kelvin.KelvinMod.KELVINLOGGER import org.valkyrienskies.kelvin.api.* import org.valkyrienskies.kelvin.api.DuctNetwork.Companion.idealGasConstant -import org.valkyrienskies.kelvin.api.edges.* +import org.valkyrienskies.kelvin.api.edges.ApertureEdge +import org.valkyrienskies.kelvin.api.edges.FilteredEdge +import org.valkyrienskies.kelvin.api.edges.OneWayEdge +import org.valkyrienskies.kelvin.api.edges.PumpEdge import org.valkyrienskies.kelvin.api.nodes.TankDuctNode import org.valkyrienskies.kelvin.impl.client.ClientKelvinInfo import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry @@ -19,8 +22,6 @@ import org.valkyrienskies.kelvin.util.* import org.valkyrienskies.kelvin.util.KelvinExtensions.toChunkPos import org.valkyrienskies.kelvin.util.KelvinExtensions.toMinecraft import java.util.concurrent.ConcurrentLinkedQueue -import kotlin.collections.HashMap -import kotlin.collections.HashSet import kotlin.math.* class DuctNetworkServer( diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt index cf24b28..6f6e3b1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/ImageDrawable.kt @@ -1,9 +1,7 @@ package org.valkyrienskies.kelvin.integration.jei -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.drawable.IDrawable -import net.minecraft.client.gui.GuiComponent +import net.minecraft.client.gui.GuiGraphics import net.minecraft.resources.ResourceLocation @@ -17,9 +15,8 @@ class ImageDrawable(private val width: Int, private val height: Int, private val return height } - override fun draw(stack: PoseStack, xOffset: Int, yOffset: Int) { - RenderSystem.setShaderTexture(0, location) - GuiComponent.blit(stack, xOffset, yOffset, 0, 0f, 0f, width, height, height, width) - + override fun draw(guiGraphics: GuiGraphics, xOffset: Int, yOffset: Int) { + guiGraphics.blit(location, xOffset, yOffset, 0, 0f, 0f, width, height, height, width) } + } \ No newline at end of file diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt index 108dec6..db52481 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinGasIngredient.kt @@ -1,17 +1,14 @@ package org.valkyrienskies.kelvin.integration.jei -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.ingredients.IIngredientHelper import mezz.jei.api.ingredients.IIngredientRenderer import mezz.jei.api.ingredients.IIngredientType import mezz.jei.api.ingredients.subtypes.UidContext import net.minecraft.ChatFormatting -import net.minecraft.client.gui.GuiComponent +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent +import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.TooltipFlag -import org.valkyrienskies.kelvin.KelvinMod.MOD_ID import org.valkyrienskies.kelvin.api.GasType data class KelvinGasIngredient(val gasType: GasType, val moles: Int) @@ -27,6 +24,10 @@ class GasIngredientHelper: IIngredientHelper { return GasIngredientType() } + override fun getResourceLocation(ingredient: KelvinGasIngredient): ResourceLocation { + return ingredient.gasType.resourceLocation + } + override fun getErrorInfo(ingredient: KelvinGasIngredient?): String { return ingredient?.gasType.toString() } @@ -35,14 +36,6 @@ class GasIngredientHelper: IIngredientHelper { return ingredient } - override fun getResourceId(ingredient: KelvinGasIngredient): String { - return ingredient.gasType.resourceLocation.path - } - - override fun getModId(ingredient: KelvinGasIngredient): String { - return MOD_ID - } - override fun getUniqueId(ingredient: KelvinGasIngredient, context: UidContext): String { return ingredient.gasType.resourceLocation.toString() } @@ -56,14 +49,11 @@ class GasIngredientHelper: IIngredientHelper { class GasIngredientRenderer: IIngredientRenderer { override fun getTooltip(ingredient: KelvinGasIngredient, tooltipFlag: TooltipFlag): MutableList { - return mutableListOf(TextComponent(ingredient.gasType.name).withStyle(ChatFormatting.GOLD)) + return mutableListOf(Component.literal(ingredient.gasType.name).withStyle(ChatFormatting.GOLD)) } - override fun render(stack: PoseStack, ingredient: KelvinGasIngredient) { - RenderSystem.setShaderTexture(0, ingredient.gasType.iconLocation) - GuiComponent.blit(stack, 0, 0, 0, 0f, 0f, 16, 16, 16, 16) - - super.render(stack, ingredient) + override fun render(guiGraphics: GuiGraphics, ingredient: KelvinGasIngredient) { + guiGraphics.blit(ingredient.gasType.iconLocation, 0, 0, 0, 0f, 0f, 16, 16, 16, 16) } } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt index d3a0276..4021c7a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinJeiPlugin.kt @@ -10,8 +10,8 @@ import net.minecraft.resources.ResourceLocation import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.KelvinMod.MOD_ID import org.valkyrienskies.kelvin.api.GasReaction -import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry import org.valkyrienskies.kelvin.impl.KelvinReactionDataLoader +import org.valkyrienskies.kelvin.impl.registry.GasTypeRegistry @JeiPlugin @@ -35,7 +35,7 @@ class KelvinJeiPlugin: IModPlugin { override fun registerRecipes(registration: IRecipeRegistration) { super.registerRecipes(registration) val recipes = KelvinReactionDataLoader.gas_reactions.values - registration.addRecipes(recipes, KelvinMod.asResouceLocation("gas_reaction_recipe")) // TODO: Figure out how to use the other non-deprecated method. + registration.addRecipes(GAS_REACTION_RECIPE_TYPE, recipes.toList()) } diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt index 1eecf56..585d5df 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt @@ -1,41 +1,35 @@ package org.valkyrienskies.kelvin.integration.jei -import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.builder.IRecipeLayoutBuilder import mezz.jei.api.gui.drawable.IDrawable import mezz.jei.api.gui.ingredient.IRecipeSlotsView import mezz.jei.api.recipe.IFocusGroup import mezz.jei.api.recipe.RecipeIngredientRole +import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory import net.minecraft.client.Minecraft +import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent -import net.minecraft.resources.ResourceLocation -import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.GasReaction import org.valkyrienskies.kelvin.api.GasType import org.valkyrienskies.kelvin.integration.jei.KelvinJeiPlugin.Companion.GAS_INGREDIENT_TYPE class KelvinReactionRecipeCategory : IRecipeCategory { - override fun getTitle(): Component { - return TextComponent("Gas Reaction") + + override fun getRecipeType(): RecipeType { + return KelvinJeiPlugin.GAS_REACTION_RECIPE_TYPE } - override fun getBackground(): IDrawable { - return ImageDrawable(150,150, KelvinMod.asResouceLocation("textures/gui/gas_reaction_recipe_background.png")) + override fun getTitle(): Component { + + return Component.literal("Gas Reaction") } + override fun getIcon(): IDrawable { return ImageDrawable(16,16, GasType.PLACEHOLDER_ICON) } - override fun getUid(): ResourceLocation { - return KelvinMod.asResouceLocation("gas_reaction_recipe") - } - - override fun getRecipeClass(): Class { - return GasReaction::class.java - } override fun setRecipe(builder: IRecipeLayoutBuilder, recipe: GasReaction, focuses: IFocusGroup) { @@ -57,7 +51,7 @@ class KelvinReactionRecipeCategory : IRecipeCategory { override fun draw( recipe: GasReaction, recipeSlotsView: IRecipeSlotsView, - stack: PoseStack, + guiGraphics: GuiGraphics, mouseX: Double, mouseY: Double ) { @@ -66,27 +60,26 @@ class KelvinReactionRecipeCategory : IRecipeCategory { recipeSlotsView.getSlotViews(RecipeIngredientRole.INPUT).forEach { slot -> val ingredient = slot.displayedIngredient.get().ingredient as KelvinGasIngredient // TODO: USE LANG - - Minecraft.getInstance().font.draw(stack, "${ingredient.moles} Moles",17f,i*17f, 5592405) + guiGraphics.drawString(Minecraft.getInstance().font, "${ingredient.moles} Moles", 17, i * 17, 5592405) i++ if (i >= maxI) maxI = i - } + } i = 0 recipeSlotsView.getSlotViews(RecipeIngredientRole.OUTPUT).forEach { slot -> val ingredient = slot.displayedIngredient.get().ingredient as KelvinGasIngredient // TODO: USE LANG - Minecraft.getInstance().font.draw(stack, "${ingredient.moles} Moles",101f,i*17f, 5592405) + guiGraphics.drawString(Minecraft.getInstance().font, "${ingredient.moles} Moles", 101, i * 17, 5592405) i++ if (i >= maxI) maxI = i } i = maxI + 2 recipe.requirements.forEach { (requirement, value) -> - Minecraft.getInstance().font.draw(stack, requirement.get_text(value),0f,i*17f, 5592405) + guiGraphics.drawString(Minecraft.getInstance().font, requirement.get_text(value).string, 0, i * 17, 5592405) i++ } - } + } diff --git a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt index cd93cbe..c8353c2 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/kelvin/forge/KelvinModForge.kt @@ -2,9 +2,9 @@ package org.valkyrienskies.kelvin.forge import dev.architectury.platform.forge.EventBuses import net.minecraft.server.level.ServerLevel -import net.minecraftforge.client.event.ParticleFactoryRegisterEvent +import net.minecraftforge.client.event.RegisterParticleProvidersEvent import net.minecraftforge.event.AddReloadListenerEvent -import net.minecraftforge.event.world.ChunkEvent +import net.minecraftforge.event.level.ChunkEvent import net.minecraftforge.eventbus.api.IEventBus import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent @@ -30,13 +30,13 @@ class KelvinModForge { init() FORGE_BUS.addListener { event: ChunkEvent.Load -> - if (!event.world.isClientSide) { + if (!event.level.isClientSide) { try { KelvinMod.getKelvin().markChunkLoaded( KelvinChunkPos( event.chunk.pos.x, event.chunk.pos.z, - (event.world as ServerLevel).dimension().location() + (event.level as ServerLevel).dimension().location() ) ) } catch (e: IllegalStateException) { @@ -47,13 +47,13 @@ class KelvinModForge { } FORGE_BUS.addListener { event: ChunkEvent.Unload -> - if (!event.world.isClientSide) { + if (!event.level.isClientSide) { try { KelvinMod.getKelvin().markChunkUnloaded( KelvinChunkPos( event.chunk.pos.x, event.chunk.pos.z, - (event.world as ServerLevel).dimension().location() + (event.level as ServerLevel).dimension().location() ) ) } catch (e: IllegalStateException) { @@ -65,7 +65,7 @@ class KelvinModForge { FORGE_BUS.addListener(::registerResourceManagers) - MOD_BUS.addListener { event: ParticleFactoryRegisterEvent -> + MOD_BUS.addListener { event: RegisterParticleProvidersEvent -> KelvinParticles.KelvinClientParticles.init() } } diff --git a/gradle.properties b/gradle.properties index df4e797..7060cac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ forge_version=1.20.1-47.2.0 forge_kotlin_version=4.10.0 kotlin_version=1.9.10 cloth_config_version=6.4.90 -jei_version=10.2.1.1009 +jei_version=15.20.0.112 # Maven publishing vs_maven_url= vs_maven_username= From c63be577c5942845aded6de48307897c534a4fa1 Mon Sep 17 00:00:00 2001 From: PriestOfFerns Date: Wed, 25 Jun 2025 19:59:18 +0300 Subject: [PATCH 37/37] oops --- .../kelvin/integration/jei/KelvinReactionRecipeCategory.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt index 585d5df..e7d27b0 100644 --- a/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt +++ b/common/src/main/kotlin/org/valkyrienskies/kelvin/integration/jei/KelvinReactionRecipeCategory.kt @@ -10,12 +10,17 @@ import mezz.jei.api.recipe.category.IRecipeCategory import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component +import org.valkyrienskies.kelvin.KelvinMod import org.valkyrienskies.kelvin.api.GasReaction import org.valkyrienskies.kelvin.api.GasType import org.valkyrienskies.kelvin.integration.jei.KelvinJeiPlugin.Companion.GAS_INGREDIENT_TYPE class KelvinReactionRecipeCategory : IRecipeCategory { + override fun getBackground(): IDrawable { + return ImageDrawable(150, 150, KelvinMod.asResouceLocation("textures/gui/gas_reaction_recipe_background.png")) + } + override fun getRecipeType(): RecipeType { return KelvinJeiPlugin.GAS_REACTION_RECIPE_TYPE } @@ -25,7 +30,6 @@ class KelvinReactionRecipeCategory : IRecipeCategory { return Component.literal("Gas Reaction") } - override fun getIcon(): IDrawable { return ImageDrawable(16,16, GasType.PLACEHOLDER_ICON) }