Skip to content

Commit

Permalink
Babric-ify
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Feb 6, 2024
1 parent 297b7f9 commit 6ab248b
Show file tree
Hide file tree
Showing 23 changed files with 234 additions and 185 deletions.
145 changes: 0 additions & 145 deletions .github/workflows/test-push.yml

This file was deleted.

16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}
}

group = 'net.fabricmc'
group = 'babric'
def baseVersion = '1.5'

def ENV = System.getenv()
Expand All @@ -71,6 +71,10 @@ repositories {
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
maven {
name = 'Babric'
url = 'https://maven.glass-launcher.net/babric'
}
}

configurations {
Expand Down Expand Up @@ -253,7 +257,7 @@ codenarc {
gradlePlugin {
plugins {
fabricLoom {
id = 'fabric-loom'
id = 'babric-loom'
implementationClass = 'net.fabricmc.loom.bootstrap.LoomGradlePluginBootstrap'
}
}
Expand Down Expand Up @@ -312,8 +316,8 @@ publishing {

// Manually crate the plugin marker for snapshot versions
snapshotPlugin(MavenPublication) { publication ->
groupId 'fabric-loom'
artifactId 'fabric-loom.gradle.plugin'
groupId 'babric-loom'
artifactId 'babric-loom.gradle.plugin'
version baseVersion + '-SNAPSHOT'

pom.withXml({
Expand All @@ -323,9 +327,9 @@ publishing {
Node dependencies = root.appendChild(document.createElement('dependencies'))
Node dependency = dependencies.appendChild(document.createElement('dependency'))
Node groupId = dependency.appendChild(document.createElement('groupId'))
groupId.setTextContent('net.fabricmc')
groupId.setTextContent('babric')
Node artifactId = dependency.appendChild(document.createElement('artifactId'))
artifactId.setTextContent('fabric-loom')
artifactId.setTextContent('babric-loom')
Node version = dependency.appendChild(document.createElement('version'))
version.setTextContent(baseVersion + '-SNAPSHOT')
})
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = fabric-loom
name = babric-loom
description = The Gradle plugin for Fabric
url = https://github.com/FabricMC/fabric-loom

Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ commons-io = "2.15.1"
gson = "2.10.1"
guava = "33.0.0-jre"

stitch = "0.6.2"
stitch = "0.6.2-babric.1"
tiny-remapper = "0.10.0"
access-widener = "2.1.0"
mapping-io = "0.5.1"
lorenz-tiny = "4.0.2"
lorenz-tiny = "4.0.2-babric.2"
mercury = "0.4.1"
kotlinx-metadata = "0.8.0"

Expand All @@ -32,11 +32,11 @@ commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }

fabric-stitch = { module = "net.fabricmc:stitch", version.ref = "stitch" }
fabric-stitch = { module = "babric:stitch", version.ref = "stitch" }
fabric-tiny-remapper = { module = "net.fabricmc:tiny-remapper", version.ref = "tiny-remapper" }
fabric-access-widener = { module = "net.fabricmc:access-widener", version.ref = "access-widener" }
fabric-mapping-io = { module = "net.fabricmc:mapping-io", version.ref = "mapping-io" }
fabric-lorenz-tiny = { module = "net.fabricmc:lorenz-tiny", version.ref = "lorenz-tiny" }
fabric-lorenz-tiny = { module = "babric:lorenz-tiny", version.ref = "lorenz-tiny" }
fabric-mercury = { module = "net.fabricmc:mercury", version.ref = "mercury" }

# Misc
Expand Down
4 changes: 2 additions & 2 deletions gradle/runtime.libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cfr = "0.2.1"
vineflower = "1.9.3"

# Runtime depedencies
mixin-compile-extensions = "0.6.0"
mixin-compile-extensions = "0.6.0-babric.1"
dev-launch-injector = "0.2.1+build.8"
terminal-console-appender = "1.3.0"
jetbrains-annotations = "24.1.0"
Expand All @@ -18,7 +18,7 @@ cfr = { module = "net.fabricmc:cfr", version.ref = "cfr" }
vineflower = { module = "org.vineflower:vineflower", version.ref = "vineflower" }

# Runtime depedencies
mixin-compile-extensions = { module = "net.fabricmc:fabric-mixin-compile-extensions", version.ref = "mixin-compile-extensions" }
mixin-compile-extensions = { module = "babric:fabric-mixin-compile-extensions", version.ref = "mixin-compile-extensions" }
dev-launch-injector = { module = "net.fabricmc:dev-launch-injector", version.ref = "dev-launch-injector" }
terminal-console-appender = { module = "net.minecrell:terminalconsoleappender", version.ref = "terminal-console-appender" }
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains-annotations" }
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/fabricmc/loom/LoomGradleExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ default List<Path> getMinecraftJars(MappingsNamespace mappingsNamespace) {
return switch (mappingsNamespace) {
case NAMED -> getNamedMinecraftProvider().getMinecraftJarPaths();
case INTERMEDIARY -> getIntermediaryMinecraftProvider().getMinecraftJarPaths();
case OFFICIAL -> getMinecraftProvider().getMinecraftJars();
case OFFICIAL, GLUE -> getMinecraftProvider().getMinecraftJars();
case SERVER, CLIENT -> null;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ default void splitMinecraftJar() {

boolean areEnvironmentSourceSetsSplit();

default void gluedMinecraftJar() {
getMinecraftJarConfiguration().set(MinecraftJarConfiguration.GLUED);
}

Property<Boolean> getRuntimeOnlyLog4j();

Property<Boolean> getSplitModDependencies();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,22 @@ public enum MappingsNamespace {
/**
* Named mappings are the developer friendly names used to develop mods against.
*/
NAMED;
NAMED,

/**
* Mappings used for merging two jars that were obfuscated differently.
*/
GLUE,

/**
* Official mappings are the names that are used in the vanilla Minecraft server jars, these are usually obfuscated.
*/
SERVER,

/**
* Official mappings are the names that are used in the vanilla Minecraft client jars, these are usually obfuscated.
*/
CLIENT;

/**
* Gets a {@code MappingsNamespace} from a namespace string.
Expand All @@ -62,6 +77,9 @@ public enum MappingsNamespace {
case "official" -> OFFICIAL;
case "intermediary" -> INTERMEDIARY;
case "named" -> NAMED;
case "glue" -> GLUE;
case "server" -> SERVER;
case "client" -> CLIENT;
default -> null;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,15 @@ private synchronized void setupMinecraft(ConfigContext configContext) throws Exc
// Provide the vanilla mc jars -- TODO share across getProject()s.
final MinecraftProvider minecraftProvider = jarConfiguration.getMinecraftProviderFunction().apply(configContext);
extension.setMinecraftProvider(minecraftProvider);
minecraftProvider.provide();
minecraftProvider.init();

final DependencyInfo mappingsDep = DependencyInfo.create(getProject(), Configurations.MAPPINGS);
final MappingConfiguration mappingConfiguration = MappingConfiguration.create(getProject(), configContext.serviceManager(), mappingsDep, minecraftProvider);
extension.setMappingConfiguration(mappingConfiguration);
mappingConfiguration.applyToProject(getProject(), mappingsDep);

minecraftProvider.provide();

// Provide the remapped mc jars
final IntermediaryMinecraftProvider<?> intermediaryMinecraftProvider = jarConfiguration.getIntermediaryMinecraftProviderBiFunction().apply(project, minecraftProvider);
NamedMinecraftProvider<?> namedMinecraftProvider = jarConfiguration.getNamedMinecraftProviderBiFunction().apply(project, minecraftProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private static void populate(Project project, LoomGradleExtension extension, Run
runConfig.mainClass = "net.fabricmc.devlaunchinjector.Main";
runConfig.vmArgs.add("-Dfabric.dli.config=" + encodeEscaped(extension.getFiles().getDevLauncherConfig().getAbsolutePath()));
runConfig.vmArgs.add("-Dfabric.dli.env=" + environment.toLowerCase());
runConfig.vmArgs.add("-Djava.library.path=" + extension.getFiles().getNativesDirectory(project).getAbsolutePath());
}

// Turns camelCase/PascalCase into Capital Case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftProvider;
import net.fabricmc.loom.util.service.SharedService;
import net.fabricmc.loom.util.service.SharedServiceManager;
import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.adapter.MappingNsCompleter;
import net.fabricmc.mappingio.format.tiny.Tiny2FileReader;
import net.fabricmc.mappingio.tree.MemoryMappingTree;

public final class IntermediateMappingsService implements SharedService {
Expand Down Expand Up @@ -90,7 +90,7 @@ private MemoryMappingTree createMemoryMappingTree() {
MappingNsCompleter nsCompleter = new MappingNsCompleter(tree, Collections.singletonMap(MappingsNamespace.NAMED.toString(), MappingsNamespace.INTERMEDIARY.toString()), true);

try (BufferedReader reader = Files.newBufferedReader(getIntermediaryTiny(), StandardCharsets.UTF_8)) {
Tiny2FileReader.read(reader, nsCompleter);
MappingReader.read(reader, nsCompleter);
}
} catch (IOException e) {
throw new UncheckedIOException("Failed to read intermediary mappings", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import net.fabricmc.loom.configuration.DependencyInfo;
import net.fabricmc.loom.configuration.providers.mappings.tiny.MappingsMerger;
import net.fabricmc.loom.configuration.providers.mappings.tiny.TinyJarInfo;
import net.fabricmc.loom.configuration.providers.minecraft.GluedMinecraftProvider;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftProvider;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.DeletingFileVisitor;
Expand Down Expand Up @@ -177,6 +178,8 @@ private void storeMappings(Project project, SharedServiceManager serviceManager,
IntermediateMappingsService intermediateMappingsService = IntermediateMappingsService.getInstance(serviceManager, project, minecraftProvider);

MappingsMerger.mergeAndSaveMappings(baseTinyMappings, tinyMappings, intermediateMappingsService);
} else if (minecraftProvider instanceof GluedMinecraftProvider) {
Files.move(baseTinyMappings, tinyMappings);
} else {
final List<Path> minecraftJars = minecraftProvider.getMinecraftJars();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ public static void mergeAndSaveMappings(Path from, Path out, IntermediateMapping
Tiny2FileReader.read(reader, intermediaryTree);
}

String sourceNs = intermediaryTree.getDstNamespaces().contains(MappingsNamespace.GLUE.toString()) ? MappingsNamespace.GLUE.toString() : MappingsNamespace.OFFICIAL.toString();

MemoryMappingTree officialTree = new MemoryMappingTree();
MappingNsCompleter nsCompleter = new MappingNsCompleter(officialTree, Map.of(MappingsNamespace.OFFICIAL.toString(), MappingsNamespace.INTERMEDIARY.toString()));
MappingSourceNsSwitch nsSwitch = new MappingSourceNsSwitch(nsCompleter, MappingsNamespace.OFFICIAL.toString());
MappingNsCompleter nsCompleter = new MappingNsCompleter(officialTree, Map.of(sourceNs, MappingsNamespace.INTERMEDIARY.toString()));
MappingSourceNsSwitch nsSwitch = new MappingSourceNsSwitch(nsCompleter, sourceNs);
intermediaryTree.accept(nsSwitch);

inheritMappedNamesOfEnclosingClasses(officialTree);
Expand Down
Loading

0 comments on commit 6ab248b

Please sign in to comment.