#Cannot add methods to class with mixin

16 messages ยท Page 1 of 1 (latest)

pulsar oar
#

!!duck

golden flaxBOT
#

Example of Duck interfaces:

io/github/mymod/mixin/MyClassMixin

// This mixin implements the duck interface onto `MyClass`
@Mixin(MyClass.class)
public class MyClassMixin implements MyClassAccess {
    @Override
    public void access() {
        System.out.println("Accessed!");
    }
}

io/github/mymod/access/MyClassAccess

// The duck interface being implemented onto `MyClass`
public interface MyClassAccess {
    void access();
}

To use it:

public class Container {
    public void slapHaykam(MyClass instance) {
        ((MyClassAccess)instance).access(); // Will print "Accessed!"
    }
}
pulsar oar
#

you cannot cast an object to a mixin

#

mixins don't exist at runtime, and clearly the compiler is also complaining

unique storm
#

So, I cannot cast to class mixins but I can to interface mixins true?

pulsar oar
#

yes

#

the example is exactly that

unique storm
#

I really appreciate the patience you guys have with the recurring questions ๐Ÿ™‚ tyty

#

The transformation is somehow failing

#

Mixin transformation of com.iadnah.addon.mixin.ITestMixin failed

pulsar oar
#

what's the full error?

unique storm
pulsar oar
#

meteor?

#

we don't support hacks here

#

!!hacks

golden flaxBOT
#

We do not support hacked clients, cheats, or modifications that are intended to give you the upper hand in a server, competitive or otherwise.
See rule 1 in #welcome and the Discord TOS: https://discordapp.com/terms