Introduction to Mixins - Understanding Mixin Architecture

The first page of the Mixins wiki is complete, which is designed to provide an extremely basic introduction to some of the core concepts underpinning the mixin functionality we’re using to implement Sponge.

I’ve chosen to start at the very beginning in order to provide an introduction for those who may be less familiar with the ins and outs of Java so if you’re an experienced java dev feel free to skip right on down to section 4 where the mixins themselves are actually discussed.

I will be working on the remaining sections over the next few weeks but I’m keen to try and provide as comprehensive documentation as possible and making the diagrams takes a while, I also don’t want this documentation project to interfere with actually working on Sponge so I’ll be basically working on this only in my spare time, please be patient, I’ll post here as I add pages.

Current pages:

If you’re looking to get started writing mixins, I also strongly recommend reading (thoroughly) all of the examples in the Sponge repository which are extensively documented and cover a lot of the more complex scenarios. You should also consult the Javadoc of the Mixin repository itself, since almost everything is already documented that way should you wish to learn more.

Let me know if there’s any way you feel the docs can be improved, I’ve tried my best to make the introduction clear but if I’ve missed anything out then let me know.

11 Likes

What I’d like t know is how you made those class hierachy field method thingy diagrams… xD

1 Like

They’re just made with Visio.

2 Likes

I’d be delighted to add a link to the Mixin Wiki in the SpongeDocs, if that’s OK.
Longer term, we might be able to port some content to make translations available too.

Ya sure, the Mixin project will be servicing a number of other projects in addition to Sponge itself so I wanted to keep all the documentation together with the repository, but feel free to link to it and/or translate as appropriate.

Done https://docs.spongepowered.org/en/latest/devs/forge/mixins/ (I cribbed most of it from your OP). Feel free to edit it if you think it needs any more info or corrections.

NOTE It’s been moved to the devs/forge section.

Perfect, thanks.

1 Like

That is an amazingly thorough document! Great work!

1 Like

Excellent, especially the illustrations are helpful!

@mumfrey I just realise mixins can be used to fix mods that don’t give forge events in a moded-server. Can we depend the Sponge CoreMod in a forgemod and use these classes? Or will that json file stop us from doing that :cry:?
I kinda like these mixins more, than the patchengine approach.

Yes. But you don’t even need sponge to depend on this, as it’s a standalone library.

Yeah I know, but if you depend it and include it in a mod. It will conflict with sponge. I would like to avoid shading :smile:.

Then what about not including it and instead depending on it in a compat plugin / mod?