diff --git a/build.gradle b/build.gradle index f4709ad7..12a78783 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,4 @@ buildscript { - repositories { - jcenter() - } dependencies { //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory classpath "org.jfrog.buildinfo:build-info-extractor-gradle:5.1.10" @@ -105,39 +102,48 @@ allprojects { ) } } + + apply { + plugin 'fabric-loom' + } + + dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + // Kotlin support + modApi("net.fabricmc:fabric-language-kotlin:1.9.2+kotlin.1.8.10") + // MaLiLib, required on client + modApi "fi.dy.masa.malilib:malilib-fabric-1.20.4:0.18.0" + // carpet, required on client & server + modApi "carpet:fabric-carpet:1.20.3-1.4.128+v231205" + // Game test + testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}" + //include(implementation("org.bouncycastle:bcprov-jdk18on:1.76")) + //include(implementation("org.bouncycastle:bcpg-jdk18on:1.76")) + include(implementation("com.squareup.okhttp3:okhttp:4.11.0")) + include(implementation("org.eclipse.jgit:org.eclipse.jgit:6.6.0.202305301015-r")) + include(implementation("com.squareup.okio:okio-jvm:3.2.0")) + modImplementation "curse.maven:litematica-308892:4946471" + modImplementation "curse.maven:tweakeroo-297344:4946344" + modApi "maven.modrinth:modmenu:9.0.0-pre.1" + modImplementation "maven.modrinth:ferrite-core:6.0.3-fabric" + modApi "io.wispforest:owo-lib:${project.owo_version}" + } } -dependencies { - // implementation 'org.bouncycastle:' - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // Fabric API - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - // Kotlin support - modApi("net.fabricmc:fabric-language-kotlin:1.9.2+kotlin.1.8.10") - // MaLiLib, required on client - modApi "fi.dy.masa.malilib:malilib-fabric-1.20.4:0.18.0" - // carpet, required on client & server - modApi "carpet:fabric-carpet:1.20.3-1.4.128+v231205" - // Game test - modApi "net.fabricmc:fabric-loader-junit:${project.loader_version}" - //include(implementation("org.bouncycastle:bcprov-jdk18on:1.76")) - //include(implementation("org.bouncycastle:bcpg-jdk18on:1.76")) - include(implementation("com.squareup.okhttp3:okhttp:4.11.0")) - include(implementation("org.eclipse.jgit:org.eclipse.jgit:6.6.0.202305301015-r")) - include(implementation("com.squareup.okio:okio-jvm:3.2.0")) - modImplementation "curse.maven:litematica-308892:4946471" - modImplementation "curse.maven:tweakeroo-297344:4946344" - modApi "maven.modrinth:modmenu:9.0.0-pre.1" - modImplementation "maven.modrinth:ferrite-core:6.0.3-fabric" - modApi "io.wispforest:owo-lib:${project.owo_version}" +configurations { + dev { + canBeResolved = false + canBeConsumed = true + } } -test { - useJUnitPlatform() +artifacts { + dev jar } base { diff --git a/settings.gradle b/settings.gradle index b02216ba..88c1dac5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,3 +8,5 @@ pluginManagement { gradlePluginPortal() } } + +include("testmod") diff --git a/src/main/java/com/github/zly2006/reden/mixin/debugger/MixinWorld.java b/src/main/java/com/github/zly2006/reden/mixin/debugger/MixinWorld.java index ce88bd07..c1157548 100644 --- a/src/main/java/com/github/zly2006/reden/mixin/debugger/MixinWorld.java +++ b/src/main/java/com/github/zly2006/reden/mixin/debugger/MixinWorld.java @@ -3,8 +3,6 @@ import com.github.zly2006.reden.Reden; import com.github.zly2006.reden.access.WorldData; import com.github.zly2006.reden.carpet.RedenCarpetSettings; -import com.github.zly2006.reden.debugger.stages.block.BlockUpdateStage; -import com.github.zly2006.reden.debugger.stages.block.StageBlockComparatorUpdate; import com.github.zly2006.reden.debugger.stages.world.BlockEntitiesRootStage; import com.github.zly2006.reden.debugger.stages.world.BlockEntityStage; import com.github.zly2006.reden.debugger.tree.TickStageTree; @@ -16,7 +14,6 @@ import net.minecraft.world.WorldAccess; import net.minecraft.world.chunk.BlockEntityTickInvoker; import org.jetbrains.annotations.Nullable; -import org.junit.jupiter.api.Assertions; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -24,8 +21,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; - import static com.github.zly2006.reden.access.ServerData.getData; @Mixin(value = World.class, priority = Reden.REDEN_HIGHEST_MIXIN_PRIORITY) diff --git a/src/test/kotlin/com/github/zly2006/reden/TestUtils.kt b/src/test/kotlin/com/github/zly2006/reden/TestUtils.kt index 00fbe989..ef6db38d 100644 --- a/src/test/kotlin/com/github/zly2006/reden/TestUtils.kt +++ b/src/test/kotlin/com/github/zly2006/reden/TestUtils.kt @@ -3,7 +3,9 @@ package com.github.zly2006.reden import net.fabricmc.loader.impl.launch.knot.KnotClient import net.minecraft.Bootstrap import net.minecraft.SharedConstants +import org.junit.jupiter.api.BeforeAll +@BeforeAll fun setupMinecraftRegistries() { SharedConstants.createGameVersion() Bootstrap.initialize() diff --git a/testmod/build.gradle b/testmod/build.gradle new file mode 100644 index 00000000..32924db8 --- /dev/null +++ b/testmod/build.gradle @@ -0,0 +1,24 @@ +plugins { + id 'fabric-loom' version '1.4-SNAPSHOT' + id 'maven-publish' + id 'org.jetbrains.kotlin.jvm' version '1.8.10' + id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.10' +} + +dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + implementation project(path: ':', configuration: "dev") +} + +kotlin { + jvmToolchain(17) +} + +test { + useJUnitPlatform() + + jvmArgs('-Dfabric.side=server') +} diff --git a/testmod/src/main/java/com/github/zly2006/reden/test/TestMod.java b/testmod/src/main/java/com/github/zly2006/reden/test/TestMod.java new file mode 100644 index 00000000..80f8a68b --- /dev/null +++ b/testmod/src/main/java/com/github/zly2006/reden/test/TestMod.java @@ -0,0 +1,10 @@ +package com.github.zly2006.reden.test; + +import net.fabricmc.api.ModInitializer; + +public class TestMod implements ModInitializer { + @Override + public void onInitialize() { + + } +} diff --git a/testmod/src/main/resources/fabric.mod.json b/testmod/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..503eb593 --- /dev/null +++ b/testmod/src/main/resources/fabric.mod.json @@ -0,0 +1,11 @@ +{ + "schemaVersion": 1, + "version": "reden", + "id": "reden-test", + "name": "Reden Test Mod", + "entrypoints": { + "main": [ + "com.github.zly2006.reden.test.TestMod" + ] + } +} \ No newline at end of file diff --git a/src/test/kotlin/com/github/zly2006/reden/BreakpointSerializerTest.kt b/testmod/src/test/java/com/github/zly2006/reden/test/BreakpointSerializerTest.kt similarity index 97% rename from src/test/kotlin/com/github/zly2006/reden/BreakpointSerializerTest.kt rename to testmod/src/test/java/com/github/zly2006/reden/test/BreakpointSerializerTest.kt index 24fb6e2c..e536b157 100644 --- a/src/test/kotlin/com/github/zly2006/reden/BreakpointSerializerTest.kt +++ b/testmod/src/test/java/com/github/zly2006/reden/test/BreakpointSerializerTest.kt @@ -1,4 +1,4 @@ -package com.github.zly2006.reden +package com.github.zly2006.reden.test import com.github.zly2006.reden.debugger.breakpoint.* import com.github.zly2006.reden.debugger.breakpoint.behavior.FreezeGame diff --git a/testmod/src/test/java/com/github/zly2006/reden/test/Utils.kt b/testmod/src/test/java/com/github/zly2006/reden/test/Utils.kt new file mode 100644 index 00000000..2e041cb9 --- /dev/null +++ b/testmod/src/test/java/com/github/zly2006/reden/test/Utils.kt @@ -0,0 +1,40 @@ +package com.github.zly2006.reden.test + +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService +import net.minecraft.Bootstrap +import net.minecraft.SharedConstants +import net.minecraft.datafixer.Schemas +import net.minecraft.resource.VanillaDataPackProvider +import net.minecraft.server.MinecraftServer +import net.minecraft.server.WorldGenerationProgressLogger +import net.minecraft.server.dedicated.MinecraftDedicatedServer +import net.minecraft.util.ApiServices +import net.minecraft.world.level.storage.LevelStorage +import java.io.File +import java.net.Proxy + +fun setupMinecraftRegistries() { + SharedConstants.createGameVersion() + Bootstrap.initialize() +} + +fun setupServer() { + setupMinecraftRegistries() + val file = File(".") + val apiServices = ApiServices.create(YggdrasilAuthenticationService(Proxy.NO_PROXY), file) + val levelStorage = LevelStorage.create(file.toPath()) + val session = levelStorage.createSession("world") + val resourcePackManager = VanillaDataPackProvider.createManager(session); + val saveLoader = TODO() + val serverPropertiesLoader = TODO() + val server = MinecraftServer.startServer { threadx -> + val minecraftDedicatedServerxx = MinecraftDedicatedServer( + threadx, session, resourcePackManager, saveLoader, serverPropertiesLoader, Schemas.getFixer(), apiServices, + ::WorldGenerationProgressLogger + ) + minecraftDedicatedServerxx.serverPort = 25565 + minecraftDedicatedServerxx.isDemo = false + minecraftDedicatedServerxx + } +} +