Skip to content

Commit 9fa4856

Browse files
committed
Use property type when generating getter bytecode
Closes #11
1 parent 17c55a0 commit 9fa4856

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Common/src/transform/groovy/org/groovymc/cgl/impl/transform/registroid/RegistroidASTTransformer.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ final class RegistroidASTTransformer extends AbstractASTTransformation implement
5454
public static final Supplier<ClassNode> MODLIST = Suppliers.memoize { ClassHelper.make('net.minecraftforge.fml.ModList') }
5555
public static final Supplier<ClassNode> FORGEBUS_GETTER = Suppliers.memoize { ClassHelper.make('org.groovymc.cgl.reg.forge.ForgeBusGetter') }
5656

57-
static final String REG_OBJECT_INTERNAL = Type.getInternalName(RegistryObject)
5857
@Override
5958
void visit(ASTNode[] nodes, SourceUnit source) {
6059
init(nodes, source) // ensure that nodes is [AnnotationNode, AnnotatedNode]
@@ -424,8 +423,9 @@ final class RegistroidASTTransformer extends AbstractASTTransformation implement
424423
returnType: property.type,
425424
code: GeneralUtils.stmt(GeneralUtils.bytecodeX(property.type) {
426425
// (MyFieldType) MyClass.$registryObjectForMY_PROPERTY.get()
427-
it.visitFieldInsn(Opcodes.GETSTATIC, classInternal, field.name, Type.getDescriptor(RegistryObject))
428-
it.visitMethodInsn(isForge ? Opcodes.INVOKEVIRTUAL : Opcodes.INVOKEINTERFACE, REG_OBJECT_INTERNAL, 'get', '()Ljava/lang/Object;', !isForge)
426+
final typeInternal = getInternalName(regObjectType)
427+
it.visitFieldInsn(Opcodes.GETSTATIC, classInternal, field.name, "L$typeInternal;")
428+
it.visitMethodInsn(isForge ? Opcodes.INVOKEVIRTUAL : Opcodes.INVOKEINTERFACE, typeInternal, 'get', '()Ljava/lang/Object;', !isForge)
429429
it.visitTypeInsn(Opcodes.CHECKCAST, getInternalName(property.type))
430430
})
431431
])

0 commit comments

Comments
 (0)