mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-12-03 04:48:06 +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:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user