Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add test mod #79

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 38 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pluginManagement {
gradlePluginPortal()
}
}

include("testmod")
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,16 +14,13 @@
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;
import org.spongepowered.asm.mixin.injection.At;
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)
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/com/github/zly2006/reden/TestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
24 changes: 24 additions & 0 deletions testmod/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
}
10 changes: 10 additions & 0 deletions testmod/src/main/java/com/github/zly2006/reden/test/TestMod.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.github.zly2006.reden.test;

import net.fabricmc.api.ModInitializer;

public class TestMod implements ModInitializer {
@Override
public void onInitialize() {

}
}
11 changes: 11 additions & 0 deletions testmod/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"schemaVersion": 1,
"version": "reden",
"id": "reden-test",
"name": "Reden Test Mod",
"entrypoints": {
"main": [
"com.github.zly2006.reden.test.TestMod"
]
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
40 changes: 40 additions & 0 deletions testmod/src/test/java/com/github/zly2006/reden/test/Utils.kt
Original file line number Diff line number Diff line change
@@ -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
}
}