Skip to content

Commit

Permalink
Fixed ModLauncher somehow existing and a couple different crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
BluSpring committed Feb 22, 2024
1 parent 160080f commit 3bcfea7
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 12 deletions.
12 changes: 10 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,16 @@ dependencies {
modImplementation("fuzs.forgeconfigapiport:forgeconfigapiport-fabric:${property("forgeconfigapiport_version")}")

// Forge stuff
implementation(include("net.minecraftforge:eventbus:${property("eventbus_version")}")!!)
implementation(include("net.minecraftforge:forgespi:${property("forgespi_version")}")!!)
implementation(include("net.minecraftforge:eventbus:${property("eventbus_version")}") {
exclude("cpw.mods", "modlauncher")
exclude("net.minecraftforge", "modlauncher")
exclude("net.minecraftforge", "securemodules")
})
implementation(include("net.minecraftforge:forgespi:${property("forgespi_version")}") {
exclude("cpw.mods", "modlauncher")
exclude("net.minecraftforge", "modlauncher")
exclude("net.minecraftforge", "securemodules")
})
implementation(include("org.apache.maven:maven-artifact:3.8.5")!!)
implementation(include("cpw.mods:securejarhandler:${property("securejarhandler_version")}")!!)
implementation(include("net.jodah:typetools:0.8.3")!!)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ cursedmixinextensions_version=1.1.0
fabric_asm_version=2.3

# https://mvn.devos.one/#/snapshots/io/github/fabricators_of_create/Porting-Lib/Porting-Lib
porting_lib_version=2.1.1206+1.20.1
porting_lib_version=2.1.1232+1.20.1

# https://mvn.devos.one/#/snapshots/io/github/tropheusj/serialization-hooks
serialization_hooks_version=0.4.27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import net.minecraft.gametest.framework.GameTest;
import org.spongepowered.asm.mixin.Mixin;
import xyz.bluspring.kilt.injections.gametest.framework.GameTestInjection;

import java.lang.annotation.Annotation;

@Mixin(GameTest.class)
public interface GameTestInject extends GameTestInjection {
public interface GameTestInject extends Annotation {
default String templateNamespace() {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.google.common.collect.Lists;
import net.minecraft.world.level.DataPackConfig;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -13,8 +15,8 @@

@Mixin(DataPackConfig.class)
public class DataPackConfigInject implements DataPackConfigInjection {
@Shadow
public List<String> enabled;
@Final @Shadow @Mutable
private List<String> enabled;

@Inject(method = "<init>", at = @At("TAIL"))
public void kilt$makeEnabledPacksMutable(List<String> list, List<String> list2, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import net.minecraftforge.forgespi.language.IModLanguageProvider
import net.minecraftforge.forgespi.language.ModFileScanData
import net.minecraftforge.forgespi.locating.IModFile
import net.minecraftforge.forgespi.locating.IModProvider
import xyz.bluspring.kilt.Kilt
import xyz.bluspring.kilt.loader.KiltModProvider
import xyz.bluspring.kilt.loader.mod.ForgeMod
import java.nio.file.Path
import java.util.function.Supplier
import kotlin.io.path.toPath

class ModFile(private val kiltMod: ForgeMod) : IModFile {
override fun getLoaders(): MutableList<IModLanguageProvider> {
Expand All @@ -35,7 +37,11 @@ class ModFile(private val kiltMod: ForgeMod) : IModFile {
}

override fun getFilePath(): Path {
TODO("Not yet implemented")
if (kiltMod.modFile == null) {
return Kilt::class.java.protectionDomain.codeSource.location.toURI().toPath()
}

return kiltMod.modFile.toPath()
}

override fun getSecureJar(): SecureJar {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/xyz/bluspring/kilt/loader/KiltLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ class KiltLoader {

companion object {
// These constants are to be updated each time we change versions
val SUPPORTED_FORGE_SPEC_VERSION = DefaultArtifactVersion("43") // 1.19.2
val SUPPORTED_FORGE_API_VERSION = DefaultArtifactVersion("43.2.14")
val SUPPORTED_FORGE_SPEC_VERSION = DefaultArtifactVersion("47") // 1.20.1
val SUPPORTED_FORGE_API_VERSION = DefaultArtifactVersion("47.1.100")
val MC_VERSION = FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().metadata.version

private val MOD_ANNOTATION = Type.getType(Mod::class.java)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/xyz/bluspring/kilt/loader/mod/ForgeMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ForgeMod(
if (this@ForgeMod::remappedModFile.isInitialized)
SecureJar.from(remappedModFile.toPath())
else
SecureJar.from(modFile?.toPath())
SecureJar.from((modFile?.toPath() ?: Kilt::class.java.protectionDomain.codeSource.location.toURI().toPath()))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object KiltRemapper {
// Keeps track of the remapper changes, so every time I update the remapper,
// it remaps all the mods following the remapper changes.
// this can update by like 12 versions in 1 update, so don't worry too much about it.
const val REMAPPER_VERSION = 114
const val REMAPPER_VERSION = 115

val logConsumer = Consumer<String> {
logger.debug(it)
Expand Down

0 comments on commit 3bcfea7

Please sign in to comment.