-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
praise the lord, the remapper is actually working
- Loading branch information
1 parent
7ba2c3f
commit e14dd35
Showing
13 changed files
with
213 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...ra-minecraft/src/test/java/io/github/coolcrabs/brachyura/fabric/LegFabricProjectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package io.github.coolcrabs.brachyura.fabric; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.github.coolcrabs.brachyura.TestUtil; | ||
import io.github.coolcrabs.brachyura.decompiler.BrachyuraDecompiler; | ||
import io.github.coolcrabs.brachyura.dependency.JavaJarDependency; | ||
import io.github.coolcrabs.brachyura.fabric.FabricContext.ModDependencyCollector; | ||
import io.github.coolcrabs.brachyura.fabric.FabricContext.ModDependencyFlag; | ||
import io.github.coolcrabs.brachyura.mappings.Namespaces; | ||
import io.github.coolcrabs.brachyura.maven.Maven; | ||
import io.github.coolcrabs.brachyura.maven.MavenId; | ||
import io.github.coolcrabs.brachyura.minecraft.Minecraft; | ||
import io.github.coolcrabs.brachyura.minecraft.VersionMeta; | ||
import io.github.coolcrabs.brachyura.util.JvmUtil; | ||
import net.fabricmc.mappingio.tree.MappingTree; | ||
import net.fabricmc.mappingio.tree.MemoryMappingTree; | ||
|
||
public class LegFabricProjectTest { | ||
|
||
SimpleFabricProject fabricProject = new SimpleFabricProject() { | ||
static final String LEG_FABRIC_MAVEN = "https://repo.legacyfabric.net/repository/legacyfabric/"; | ||
|
||
@Override | ||
public VersionMeta createMcVersion() { | ||
return Minecraft.getVersion("1.8.9"); | ||
} | ||
|
||
@Override | ||
protected FabricContext createContext() { | ||
return new SimpleFabricContext() { | ||
@Override | ||
protected MappingTree createIntermediary() { | ||
MappingTree tree = Intermediary.ofMaven(LEG_FABRIC_MAVEN, new MavenId("net.legacyfabric", "intermediary", "1.8.9")).tree; | ||
return tree; | ||
}; | ||
}; | ||
}; | ||
|
||
@Override | ||
public MappingTree createMappings() { | ||
MappingTree tree = Yarn.ofMaven(LEG_FABRIC_MAVEN, new MavenId("net.legacyfabric:yarn:1.8.9+build.451")).tree; | ||
tree.getClass("net/minecraft/world/chunk/ServerChunkProvider", tree.getNamespaceId(Namespaces.NAMED)).getMethod("method_3864", "(II)Z", tree.getNamespaceId(Namespaces.INTERMEDIARY)).setDstName("chunkExists", tree.getNamespaceId(Namespaces.NAMED)); | ||
return tree; | ||
} | ||
|
||
@Override | ||
public FabricLoader getLoader() { | ||
return new FabricLoader(FabricMaven.URL, FabricMaven.loader("0.12.5")); | ||
} | ||
|
||
@Override | ||
public Path getProjectDir() { | ||
Path result = TestUtil.ROOT.resolve("test").resolve("fabric").resolve("legfabric"); | ||
assertTrue(Files.isDirectory(result)); | ||
return result; | ||
} | ||
|
||
@Override | ||
public void getModDependencies(ModDependencyCollector d) { | ||
}; | ||
|
||
@Override | ||
public BrachyuraDecompiler decompiler() { | ||
return null; | ||
}; | ||
}; | ||
|
||
@Test | ||
void compile() { | ||
try { | ||
long s = System.currentTimeMillis(); | ||
JavaJarDependency b = fabricProject.build(); | ||
long s2 = System.currentTimeMillis() - s; | ||
System.out.println(s2); | ||
if (JvmUtil.CURRENT_JAVA_VERSION == 8) // TestMod.java produces different cp order in j8 and j17 | ||
TestUtil.assertSha256(b.jar, "09b408c35e71afd037d9eefae98bdb8b5bc64320989b798dad4aa5b96594c52d"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw e; | ||
} | ||
} | ||
|
||
@Test | ||
void ide() { | ||
long a = System.currentTimeMillis(); | ||
//Todo better api for this? | ||
fabricProject.getTasks(p -> { | ||
try { | ||
if (p.name.equals("netbeans")) p.doTask(new String[]{}); | ||
if (p.name.equals("idea")) p.doTask(new String[]{}); | ||
if (p.name.equals("jdt")) p.doTask(new String[]{}); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw e; | ||
} | ||
}); | ||
long b = System.currentTimeMillis(); | ||
System.out.println(b - a); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.vscode | ||
build | ||
.brachyura | ||
run | ||
netbeans | ||
*.iml | ||
.idea | ||
*.launch | ||
.project | ||
.classpath | ||
.settings |
10 changes: 10 additions & 0 deletions
10
test/fabric/legfabric/src/main/java/io/github/coolcrabs/testmod/TestMod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.coolcrabs.testmod; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
|
||
public class TestMod implements ModInitializer { | ||
@Override | ||
public void onInitialize() { | ||
System.out.println("yate"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
test/fabric/legfabric/src/main/java/io/github/coolcrabs/testmod/TestModClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.github.coolcrabs.testmod; | ||
|
||
import net.fabricmc.api.ClientModInitializer; | ||
import net.minecraft.client.MinecraftClient; | ||
|
||
public class TestModClient implements ClientModInitializer { | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
System.out.println(MinecraftClient.getInstance().isDemo); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
test/fabric/legfabric/src/main/java/io/github/coolcrabs/testmod/mixin/RandomMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.coolcrabs.testmod.mixin; | ||
|
||
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 net.minecraft.client.gui.screen.TitleScreen; | ||
|
||
@Mixin(TitleScreen.class) | ||
public class RandomMixin { | ||
@Shadow | ||
String splashText; | ||
|
||
@Inject(at = @At("HEAD"), method = "init()V") | ||
private void init(CallbackInfo info) { | ||
System.out.println("This line is printed by an example mod mixin!"); | ||
System.out.println(splashText); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
test/fabric/legfabric/src/main/resources/brachyuratestmod.mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "io.github.coolcrabs.testmod.mixin", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": [], | ||
"client": [ | ||
"RandomMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "brachyuratestmod", | ||
"version": "1337.0.0", | ||
"name": "Test Mod", | ||
"description": "Test mod for brachyura build tool.", | ||
"entrypoints": { | ||
"main": [ | ||
"io.github.coolcrabs.testmod.TestMod" | ||
], | ||
"client": [ | ||
"io.github.coolcrabs.testmod.TestModClient" | ||
] | ||
}, | ||
"mixins": [ | ||
"brachyuratestmod.mixins.json" | ||
], | ||
"accessWidener" : "testaw.accesswidener" | ||
} |
2 changes: 2 additions & 0 deletions
2
test/fabric/legfabric/src/main/resources/testaw.accesswidener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
accessWidener v1 named | ||
accessible field net/minecraft/client/MinecraftClient isDemo Z |