diff --git a/CHANGELOG.md b/CHANGELOG.md index 5455577..1301721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.6] - 2024-02-03 + +### Changed + +- Update code to new CC:T + +### Fixed + +- Crash when turtle mimic is beacon [#19] + ## [1.2.5] - 2023-11-03 ### Fixed diff --git a/build.gradle.kts b/build.gradle.kts index de4ad6b..195f3fa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ @Suppress("DSL_SCOPE_VIOLATION") plugins { - id("site.siredvin.root") version "0.4.12" - id("site.siredvin.release") version "0.4.12" + id("site.siredvin.root") version "0.6.1" + id("site.siredvin.release") version "0.6.1" } subprojectShaking { diff --git a/gradle.properties b/gradle.properties index 45ea72d..fcc831a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx4G org.gradle.warning.mode = all minecraftVersion = 1.20.1 # Mod Properties -modVersion = 1.2.5 +modVersion = 1.2.6 mavenGroup = site.siredvin modBaseName = turtlematic archivesBaseName = turtlematic diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 05a99d7..d72dbe3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,8 +5,8 @@ loom = "1.2.+" mixinGradle = "0.8.+" forgegradle = "6.+" # Core mod dependencies -cc-tweaked = "1.108.1" -peripheralium = "0.6.13" +cc-tweaked = "1.109.5" +peripheralium = "0.6.15" mixin = "0.8.5" # Fabric dependencies fabric-api = "0.87.0+1.20.1" @@ -31,7 +31,7 @@ rei = "12.0.625" [libraries] # Core mod dependencies -cc-tweaked-common = {module = "cc.tweaked:common", version.ref = "cc-tweaked"} +cc-tweaked-common = {module = "cc.tweaked:cc-tweaked-1.20.1-common", version.ref = "cc-tweaked"} cc-tweaked-common-api = {module = "cc.tweaked:cc-tweaked-1.20.1-common-api", version.ref = "cc-tweaked"} cc-tweaked-core = {module = "cc.tweaked:cc-tweaked-1.20.1-core", version.ref = "cc-tweaked"} common-config = {module = "fuzs.forgeconfigapiport:forgeconfigapiport-common", version.ref = "forgeconfigapirt-fabric"} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 95320d4..c84565a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/projects/core/src/main/kotlin/site/siredvin/turtlematic/TurtlematicCoreClient.kt b/projects/core/src/main/kotlin/site/siredvin/turtlematic/TurtlematicCoreClient.kt index e58bae7..c0c4aeb 100644 --- a/projects/core/src/main/kotlin/site/siredvin/turtlematic/TurtlematicCoreClient.kt +++ b/projects/core/src/main/kotlin/site/siredvin/turtlematic/TurtlematicCoreClient.kt @@ -1,6 +1,5 @@ package site.siredvin.turtlematic -import dan200.computercraft.api.client.ComputerCraftAPIClient import dan200.computercraft.api.client.turtle.TurtleUpgradeModeller import dan200.computercraft.api.turtle.ITurtleUpgrade import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser @@ -18,6 +17,7 @@ import site.siredvin.turtlematic.computercraft.peripheral.misc.ChunkVialPeripher import site.siredvin.turtlematic.computercraft.peripheral.misc.CreativeChestPeripheral import site.siredvin.turtlematic.computercraft.peripheral.misc.MimicPeripheral import site.siredvin.turtlematic.computercraft.peripheral.misc.TurtleChatterPeripheral +import java.util.function.BiConsumer import java.util.function.Consumer import java.util.function.Supplier @@ -33,6 +33,7 @@ object TurtlematicCoreClient { "turtle/creative_chest_left", "turtle/creative_chest_right", ) + val EXTRA_TURTLE_MODEL_PROVIDERS: MutableList, TurtleUpgradeModeller>>> = mutableListOf() @Suppress("UNCHECKED_CAST") val EXTRA_ENTITY_RENDERERS: Array>> = arrayOf( @@ -52,14 +53,14 @@ object TurtlematicCoreClient { } fun asClockwise(serializer: Supplier>) { - ComputerCraftAPIClient.registerTurtleUpgradeModeller( - serializer.get(), - ClockwiseTurtleModeller(), - ) + EXTRA_TURTLE_MODEL_PROVIDERS.add { + @Suppress("UNCHECKED_CAST") + Pair(serializer.get() as TurtleUpgradeSerialiser, ClockwiseTurtleModeller()) + } } - fun onInit() { - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + fun onModelRegister(consumer: BiConsumer, TurtleUpgradeModeller>) { + consumer.accept( TurtleUpgradeSerializers.TURTLE_CHATTER.get(), TurtleUpgradeModeller.sided( ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${TurtleChatterPeripheral.UPGRADE_ID.path}_left"), @@ -67,12 +68,7 @@ object TurtlematicCoreClient { ), ) - TurtleRenderTrickRegistry.registerTrick( - TurtleUpgradeSerializers.TURTLE_CHATTER.get(), - ChattingTurtleRenderTrick, - ) - - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.MIMIC.get(), TurtleUpgradeModeller.sided( ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${MimicPeripheral.UPGRADE_ID.path}_left"), @@ -80,19 +76,14 @@ object TurtlematicCoreClient { ), ) - TurtleRenderTrickRegistry.registerTrick( - TurtleUpgradeSerializers.MIMIC.get(), - MimicTurtleRenderTrick, - ) - - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.CREATIVE_CHEST.get(), TurtleUpgradeModeller.sided( ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${CreativeChestPeripheral.UPGRADE_ID.path}_left"), ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${CreativeChestPeripheral.UPGRADE_ID.path}_right"), ), ) - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.CHUNK_VIAL.get(), TurtleUpgradeModeller.sided( ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${ChunkVialPeripheral.UPGRADE_ID.path}_left"), @@ -100,30 +91,46 @@ object TurtlematicCoreClient { ), ) - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.SOUL_SCRAPPER.get(), TurtleUpgradeModeller.flatItem(), ) - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.LAVA_BUCKET.get(), TurtleUpgradeModeller.flatItem(), ) - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.BOW.get(), AngleItemTurtleModeller(), ) - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.PISTON.get(), FacingBlockTurtleModeller(), ) - ComputerCraftAPIClient.registerTurtleUpgradeModeller( + consumer.accept( TurtleUpgradeSerializers.STICKY_PISTON.get(), FacingBlockTurtleModeller(), ) + EXTRA_TURTLE_MODEL_PROVIDERS.forEach { + val pair = it.get() + consumer.accept(pair.first, pair.second) + } + } + + fun onInit() { + TurtleRenderTrickRegistry.registerTrick( + TurtleUpgradeSerializers.TURTLE_CHATTER.get(), + ChattingTurtleRenderTrick, + ) + + TurtleRenderTrickRegistry.registerTrick( + TurtleUpgradeSerializers.MIMIC.get(), + MimicTurtleRenderTrick, + ) asClockwise(TurtleUpgradeSerializers.AUTOMATA_CORE) asClockwise(TurtleUpgradeSerializers.HUSBANDRY_AUTOMATA) diff --git a/projects/fabric/src/main/kotlin/site/siredvin/turtlematic/FabricTurtlematicClient.kt b/projects/fabric/src/main/kotlin/site/siredvin/turtlematic/FabricTurtlematicClient.kt index eff0a31..8ea00ec 100644 --- a/projects/fabric/src/main/kotlin/site/siredvin/turtlematic/FabricTurtlematicClient.kt +++ b/projects/fabric/src/main/kotlin/site/siredvin/turtlematic/FabricTurtlematicClient.kt @@ -1,5 +1,8 @@ package site.siredvin.turtlematic +import dan200.computercraft.api.client.FabricComputerCraftAPIClient +import dan200.computercraft.api.turtle.ITurtleUpgrade +import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser import net.fabricmc.api.ClientModInitializer import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry @@ -14,5 +17,9 @@ object FabricTurtlematicClient : ClientModInitializer { TurtlematicCoreClient.EXTRA_ENTITY_RENDERERS.forEach { EntityRendererRegistry.register(it.get(), TurtlematicCoreClient.getEntityRendererProvider(it.get())) } + TurtlematicCoreClient.onModelRegister { serializer, modeller -> + @Suppress("UNCHECKED_CAST") + FabricComputerCraftAPIClient.registerTurtleUpgradeModeller(serializer as TurtleUpgradeSerialiser, modeller) + } } } diff --git a/projects/forge/src/main/kotlin/site/siredvin/turtlematic/ForgeTurtlematicClient.kt b/projects/forge/src/main/kotlin/site/siredvin/turtlematic/ForgeTurtlematicClient.kt index 09c6848..b8fecd6 100644 --- a/projects/forge/src/main/kotlin/site/siredvin/turtlematic/ForgeTurtlematicClient.kt +++ b/projects/forge/src/main/kotlin/site/siredvin/turtlematic/ForgeTurtlematicClient.kt @@ -1,5 +1,8 @@ package site.siredvin.turtlematic +import dan200.computercraft.api.client.turtle.RegisterTurtleModellersEvent +import dan200.computercraft.api.turtle.ITurtleUpgrade +import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser import net.minecraft.resources.ResourceLocation import net.minecraftforge.api.distmarker.Dist import net.minecraftforge.client.event.EntityRenderersEvent.RegisterRenderers @@ -30,4 +33,12 @@ object ForgeTurtlematicClient { event.register(model) } } + + @SubscribeEvent + fun registerTurtleModels(event: RegisterTurtleModellersEvent) { + TurtlematicCoreClient.onModelRegister { serializer, model -> + @Suppress("UNCHECKED_CAST") + event.register(serializer as TurtleUpgradeSerialiser, model) + } + } }