MovingBlocks / Terasology

Terasology - open source voxel world
http://terasology.org
Apache License 2.0
3.67k stars 1.34k forks source link

Modding/Plugin API #862

Closed calclavia closed 7 years ago

calclavia commented 10 years ago

Just found this game and the graphics look amazing. It'll be great if a plugin API is provided for people to write plugins for this game similar how Minecraft mods. I would love to write potential mods for it and would definitely help make the modding API if the team is to it. :)

keplersj commented 10 years ago

I know it's no Minecraft Forge, but what about this?

calclavia commented 10 years ago

Ooo, I'll definitely look into that and probably contribute stuff if it needs to be added. :)

keplersj commented 10 years ago

Theoretically you should be able to build Terasology mods in the same repo alongside Minecraft Forge mods because of ForgeGradle.

calclavia commented 10 years ago

Wait, so in other words, a mod can work on both Minecraft and Terasology? That's interesting...

immortius commented 10 years ago

Hello Calclavia.

Essentially Terasology has been designed from the ground up for modding. There are still a lot of rough patches, but blocks, assets and gameplay can all be modified. In particular at the heart of Terasology is an Entity System that drives the ability to mod.

The documentation is a little thin on the ground at the moment, but any class or package that is marked with the API annotation in the engine is available to modules.

I don't know about ForgeGradle, but I think k2b6s9j just means you can store the mod in the same repository, not create a mod that works on both.

calclavia commented 10 years ago

Yeah that makes more sense. I'm trying to design mods that'll probably work on both games or have like a port version. Any license and legal related stuff on modding for this game?

Cervator commented 10 years ago

Yeah it would take quite some creativity in including some sort of wrapper in a module to allow it to work in both games (not to say it is impossible, but ...). Instead we've been lucky enough to get MC modders that simply release their algorithms and such for use in Terasology with a fairly small amount of work adjusting to the different architecture. Being that we're fully open source and super extensible that can be a refreshing breeze :-)

Yeah the documentation is sketchy still since we're still pre-alpha. Feel free to ask lots of questions (especially on IRC) and help out by updating the doc and code comments!

Licensing - no problem. The base engine and all modules so far are Apache 2.0, which is a very permissive license.

immortius commented 10 years ago

Modules themselves may be released under whatever license you desire, including non-open source

keplersj commented 10 years ago

Can Terasology Mods be programmed in any JVM compatible language? Scala?

immortius commented 10 years ago

Hmm, theoretically. Although we'ld need to add any necessarily runtime libraries to the core Terasology classpath and mark them as API accessible. I guess give it a go and we can iterate on any issues. :)

To clarify a little, modules for Terasology run in a secured sandbox, with access restricted only to allowed specific classes and packages, and with permission checks enforced as well. This enables automatic downloading of necessarily modules when connecting to a server, and otherwise helps protect end users from potentially malicious modules (I don't know if Minecraft ever had issues with mods that wiped harddrives or installed malware, but I'm veering on the side of caution).

calclavia commented 10 years ago

When you talk about modules, you refer to mods? Or are they two different terms?

keplersj commented 10 years ago

Like gradle submodules.

keplersj commented 10 years ago

I use them all over the place in my BoatCraft project.

immortius commented 10 years ago

Modules are our term for the packages of assets and/or code that plug into Terasology. These can be mods, but are also used for core gameplay, or just to hold assets - they're at a lower-level than a mod. An actual mod may be composed of a number of modules.

calclavia commented 10 years ago

Side note, if you don't know, I'm a mod author for several fairly large Minecraft mods (MFFS, ICBM, Atomic Science and Resonant induction) and look forward to porting to Tersasology when I know i can successfully port everything. I just need to make sure every feature I had can be translated over.

You can take a look at what features I'm talking about checking out some of my Minecraft mods..

MFFS: http://calclavia.com/mffs/

Some stuff I do are fairly demanding, including microblocks and large structures.

Also, where's your official IRC channel located at?

keplersj commented 10 years ago

@calclavia I think you'll be interested in how I have set up BoatCraft for Terasology. I currently have it set up on a separate branch. I have a module set up to build for Minecraft and an other one for Terasology. The Minecraft module is set up to use the ForgeGradle plugin and the Terasology one is set up to checkout this repo and put it in my module's class path, as per #869.

immortius commented 10 years ago

Our channel is #terasology on freenode

mistertime commented 10 years ago

@k2b6s9j I guess I'm not the only who who thinks this would be freakin' amazing. How about a Forge port to Terasology? It'd need one heck of a class wrapper, but it would be fantastic if this were done.

Cervator commented 10 years ago

Hi @mistertime - as you see above it is kinda-sorta doable but you might just check out how easy Terasology modding is from scratch. You may never look back :D

Admittedly we don't quite have the same userbase yet .... ;-)

skaldarnar commented 10 years ago

Hey @k2b6s9j - I'm interested in using Scala, too. I tried to setup some kind of "Language-module" which contains the necessaray (and probably some useful) dependencies. (https://github.com/skaldarnar/ScalaLib) I've got another Scala module running only with the dependency on ScalaLib, so if you want to give it a try... ;)

keplersj commented 10 years ago

@skaldarnar I really like the looks of it. I have to admit though, I'm incredibly interested to see what it would take to abstract your ScalaLib module and make different versions of it for the different JVM languages (notably: Groovy, Ruby, Python, and Clojure).

immortius commented 10 years ago

The theory is that any JVM language boils down to bytecode, so you develop in whatever language and compile to class files, put them in a module and Terasology can load it. You'ld have to work out how to do the equivalent of implementing marker interfaces like Component and ComponentSystem, and using Terasology's annotations, but otherwise it should be straight forward.

The one catch is that most JVM languages also have a runtime library that drives some of their functionality. The ScalaLib module is a wrapping of the Scala runtime library - and luckily it doesn't use any restricted Java features or permissions so it can run within the module sandbox. Otherwise we'ld need to either add support for modules with greater permissions or add it to the Terasology classpath.

orubel commented 7 years ago

Well Groovy is actually a Java extension whereas Scala attempts to rewrite Java.

For example, you can take any Java class, change the extension to '.groovy' and it will compile. You CAN'T do the same with Scala because of the incompatibilities with Java.

Cervator commented 7 years ago

Ohai @orubel! Slightly dated issue here (2.5 years woo!), we probably could close it now. Our engine is in pretty good shape and exposes a bunch of stuff via API for our modules.

Additionally we've tested both Scala and Kotlin support for developing modules :-) Groovy would work too, for sure, just hasn't been done.

skaldarnar commented 7 years ago

Closing as we have a pretty solid modding API and Alpha 1.0 release which should help with staying compatible with mod interface for some time.