diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 9815b22..7c23ce9 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -35,6 +35,13 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle + - name: Update mod version + uses: christian-draeger/write-properties@1.0.1 + with: + path: 'gradle.properties' + property: 'mod_version' + value: ${{ github.sha }} + - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Common/src/main/java/possible_triangle/skygrid/mixin/MinecraftServerMixin.java b/Common/src/main/java/possible_triangle/skygrid/mixin/MinecraftServerMixin.java index b3db323..bb31a21 100644 --- a/Common/src/main/java/possible_triangle/skygrid/mixin/MinecraftServerMixin.java +++ b/Common/src/main/java/possible_triangle/skygrid/mixin/MinecraftServerMixin.java @@ -16,7 +16,7 @@ public class MinecraftServerMixin { @Inject(at = @At("RETURN"), method = "reloadResources(Ljava/util/Collection;)Ljava/util/concurrent/CompletableFuture;", cancellable = true) public void onReload(Collection packs, CallbackInfoReturnable> callback) { var self = (MinecraftServer) (Object) this; - callback.getReturnValue().thenAccept($ -> XMLResource.Companion.reload(self)); + callback.setReturnValue(callback.getReturnValue().thenAccept($ -> XMLResource.Companion.reload(self))); } } diff --git a/Fabric/src/main/java/possible_triangle/skygrid/mixin/WorldPresetMixin.java b/Fabric/src/main/java/possible_triangle/skygrid/mixin/WorldPresetAccessor.java similarity index 90% rename from Fabric/src/main/java/possible_triangle/skygrid/mixin/WorldPresetMixin.java rename to Fabric/src/main/java/possible_triangle/skygrid/mixin/WorldPresetAccessor.java index 9c61b67..7cc8ffe 100644 --- a/Fabric/src/main/java/possible_triangle/skygrid/mixin/WorldPresetMixin.java +++ b/Fabric/src/main/java/possible_triangle/skygrid/mixin/WorldPresetAccessor.java @@ -7,7 +7,7 @@ import java.util.List; @Mixin(WorldPreset.class) -public interface WorldPresetMixin { +public interface WorldPresetAccessor { @Accessor("PRESETS") static List presets() { diff --git a/Fabric/src/main/kotlin/possible_triangle/skygrid/SkygridFabric.kt b/Fabric/src/main/kotlin/possible_triangle/skygrid/SkygridFabric.kt index 3b939ef..4dd92a9 100644 --- a/Fabric/src/main/kotlin/possible_triangle/skygrid/SkygridFabric.kt +++ b/Fabric/src/main/kotlin/possible_triangle/skygrid/SkygridFabric.kt @@ -3,7 +3,6 @@ package possible_triangle.skygrid import kotlinx.serialization.ExperimentalSerializationApi import net.fabricmc.api.ClientModInitializer import net.fabricmc.api.ModInitializer -import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents import net.fabricmc.fabric.api.resource.ResourceManagerHelper @@ -11,20 +10,22 @@ import net.minecraft.server.packs.PackType import nl.adaptivity.xmlutil.ExperimentalXmlUtilApi import possible_triangle.skygrid.command.SkygridCommand import possible_triangle.skygrid.data.XMLResource -import possible_triangle.skygrid.mixin.WorldPresetMixin +import possible_triangle.skygrid.mixin.WorldPresetAccessor import possible_triangle.skygrid.platform.FabricPlatformHelper import possible_triangle.skygrid.world.SkygridGenerator @ExperimentalSerializationApi @ExperimentalXmlUtilApi @Suppress("unused") -object SkygridFabric : ModInitializer { +object SkygridFabric : ModInitializer, ClientModInitializer { override fun onInitialize() { + SkygridMod.LOGGER.info("Common Initialize") SkygridMod.init() SkygridMod.setup() FabricPlatformHelper.register() + XMLResource.register { val listener = FabricReloadListener(it, it.path) ResourceManagerHelper.get(PackType.SERVER_DATA).registerReloadListener(listener) @@ -34,9 +35,11 @@ object SkygridFabric : ModInitializer { ServerLifecycleEvents.SERVER_STOPPING.register { XMLResource.clear() } CommandRegistrationCallback.EVENT.register { it, _ -> SkygridCommand.register(it) } + } - WorldPresetMixin.presets().add(SkygridGenerator) - + override fun onInitializeClient() { + SkygridMod.LOGGER.info("Client Initialize") + WorldPresetAccessor.presets().add(SkygridGenerator) } } \ No newline at end of file diff --git a/Fabric/src/main/resources/fabric.mod.json b/Fabric/src/main/resources/fabric.mod.json index 864b990..bad2919 100644 --- a/Fabric/src/main/resources/fabric.mod.json +++ b/Fabric/src/main/resources/fabric.mod.json @@ -20,12 +20,18 @@ "adapter": "kotlin", "value": "possible_triangle.skygrid.SkygridFabric" } + ], + "client": [ + { + "adapter": "kotlin", + "value": "possible_triangle.skygrid.SkygridFabric" + } ] }, "mixins": [ "skygrid.fabric.mixins.json" ], - "accessWidener" : "skygrid.accesswidener", + "accessWidener": "skygrid.accesswidener", "depends": { "fabricloader": ">=0.12", "fabric": "*", diff --git a/Fabric/src/main/resources/skygrid.fabric.mixins.json b/Fabric/src/main/resources/skygrid.fabric.mixins.json index 0877381..d48e06c 100644 --- a/Fabric/src/main/resources/skygrid.fabric.mixins.json +++ b/Fabric/src/main/resources/skygrid.fabric.mixins.json @@ -10,7 +10,7 @@ "WorldGenSettingsMixin" ], "client": [ - "WorldPresetMixin" + "WorldPresetAccessor" ], "injectors": { "defaultRequire": 1 diff --git a/gradle.properties b/gradle.properties index e373442..df4607d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project -mod_version=3.0.7 +mod_version=0.0.0-dev release_type=release group=com.possible_triangle @@ -10,12 +10,12 @@ common_client_run_name=Common Client common_server_run_name=Common Server # Forge -forge_version=40.0.22 +forge_version=40.1.60 #forge_ats_enabled=true # Fabric -fabric_version=0.48.0+1.18.2 -fabric_loader_version=0.13.3 +fabric_version=0.58.0+1.18.2 +fabric_loader_version=0.14.8 # Mod options mod_name=Skygrid