mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 12:10:30 +00:00
Replace mixin with access transformers
Hadn't realised I could use these to touch final modifiers! More importantly, Mixin doesn't work with FG 5.0, so we needed an alternative :).
This commit is contained in:
parent
0bfe960cbd
commit
2d3e88ef59
19
build.gradle
19
build.gradle
@ -5,16 +5,10 @@ buildscript {
|
||||
name = "forge"
|
||||
url = "https://maven.minecraftforge.net"
|
||||
}
|
||||
maven {
|
||||
name = "Sponge (Mixin)"
|
||||
url = "https://repo.spongepowered.org/repository/maven-public/"
|
||||
content { includeGroup "org.spongepowered" }
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.google.code.gson:gson:2.8.1'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:5.0.12'
|
||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +24,6 @@ plugins {
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
version = mod_version
|
||||
|
||||
@ -68,9 +61,6 @@ minecraft {
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
|
||||
|
||||
mods {
|
||||
computercraft {
|
||||
source sourceSets.main
|
||||
@ -107,9 +97,6 @@ minecraft {
|
||||
testServer {
|
||||
workingDirectory project.file('test-files/server')
|
||||
parent runs.server
|
||||
properties 'mixin.env.disableRefMap': 'true'
|
||||
|
||||
arg "-mixin.config=cctest.mixin.json"
|
||||
arg "--nogui"
|
||||
|
||||
mods {
|
||||
@ -123,10 +110,7 @@ minecraft {
|
||||
mappings channel: 'official', version: mc_version
|
||||
|
||||
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
}
|
||||
|
||||
mixin {
|
||||
add sourceSets.test, "cctest.refmap.json"
|
||||
accessTransformer file('src/test/resources/META-INF/accesstransformer.cfg')
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@ -169,7 +153,6 @@ dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72'
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.72'
|
||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
|
||||
testAnnotationProcessor 'org.spongepowered:mixin:0.8.2:processor'
|
||||
|
||||
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.0'
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import net.minecraftforge.fml.unsafe.UnsafeHacks;
|
||||
import net.minecraftforge.forgespi.language.ModFileScanData;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -87,29 +86,15 @@ class TestLoader
|
||||
long setupTicks
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
TestFunctionInfo func = UnsafeHacks.newInstance( TestFunctionInfo.class );
|
||||
setFinalField( func, "batchName", batchName );
|
||||
setFinalField( func, "testName", testName );
|
||||
setFinalField( func, "structureName", structureName );
|
||||
setFinalField( func, "required", required );
|
||||
setFinalField( func, "function", function );
|
||||
setFinalField( func, "maxTicks", maxTicks );
|
||||
setFinalField( func, "setupTicks", setupTicks );
|
||||
setFinalField( func, "rotation", Rotation.NONE );
|
||||
return func;
|
||||
}
|
||||
catch( ReflectiveOperationException e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
private static void setFinalField( TestFunctionInfo func, String name, Object value ) throws ReflectiveOperationException
|
||||
{
|
||||
Field field = TestFunctionInfo.class.getDeclaredField( name );
|
||||
field.setAccessible( true );
|
||||
field.set( func, value );
|
||||
TestFunctionInfo func = UnsafeHacks.newInstance( TestFunctionInfo.class );
|
||||
func.batchName = batchName;
|
||||
func.testName = testName;
|
||||
func.structureName = structureName;
|
||||
func.required = required;
|
||||
func.function = function;
|
||||
func.maxTicks = maxTicks;
|
||||
func.setupTicks = setupTicks;
|
||||
func.rotation = Rotation.NONE;
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
8
src/test/resources/META-INF/accesstransformer.cfg
Normal file
8
src/test/resources/META-INF/accesstransformer.cfg
Normal file
@ -0,0 +1,8 @@
|
||||
public-f net.minecraft.test.TestFunctionInfo field_229650_a_
|
||||
public-f net.minecraft.test.TestFunctionInfo field_229651_b_
|
||||
public-f net.minecraft.test.TestFunctionInfo field_229652_c_
|
||||
public-f net.minecraft.test.TestFunctionInfo field_229653_d_
|
||||
public-f net.minecraft.test.TestFunctionInfo field_229654_e_
|
||||
public-f net.minecraft.test.TestFunctionInfo field_229655_f_
|
||||
public-f net.minecraft.test.TestFunctionInfo field_229656_g_
|
||||
public-f net.minecraft.test.TestFunctionInfo field_240589_h_
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "dan200.computercraft.ingame.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"refmap": "cctest.refmap.json",
|
||||
"mixins": [
|
||||
"MixinTestFunctionInfo"
|
||||
],
|
||||
"minVersion": "0.8"
|
||||
}
|
Loading…
Reference in New Issue
Block a user