Jump to content

[1.7.2] How to code a forge mod in scala


SantacreeperLP

Recommended Posts

I suppose you've used proper tutorial for deploying Forge 1.7 build environment.

Then you should know that Eclipse project is generated from Gradle and thus changes to it won't do any good.

Next, you'd have build.gradle look this way:

repositories {
... // repos config, not our case
}

apply plugin: 'scala' // Here our hero comes
apply plugin: 'forge'

... // rest of Gradle config

and then re-generate Eclipse project with

gradlew eclipse

Also, you need to respect default source layout for Scala or override it

http://www.gradle.org/docs/current/userguide/java_plugin.html

http://www.gradle.org/docs/current/userguide/scala_plugin.html

Last, to see Scala cookes in Eclipse you need to use Scala perspective. Though you should know this if you intend to write in Scala.

 

One of good examples would be ForgeMultipart: https://github.com/Chicken-Bones/ForgeMultipart

It's in Scala, it's a coremod, it's for 1.7 and it's using ForgeGradle.

 

Last advice. Store your launch config as shared and keep it versioned. ForgeGradle doesn't create proper run configurations for you.

 

If you gonna learn Scala by writing your first mod then I wouldn't recommend doing this because Scala is rather complicated and has steep learnring curve. I'd recommend attending these Scala courses on Coursera:

https://www.coursera.org/course/progfun

https://www.coursera.org/course/reactive

Link to comment
Share on other sites

Minalien made a great tutorial for using Scala and the IntelliJ IDEA IDE: http://minalien.com/tutorial-setting-up-forgegradle-for-intellij-idea-scala/

if (user.hasKnowledgeOfJava) {

    if (user.question.hasCode) {

        return interpetHelpfulResponse(user.getQuestion());

    } else {

        return "Could you post your code please?";

    }

} else {

    return "Learn some freaking Java!";

}

Link to comment
Share on other sites

No , It doesn't work. While I create the source folder, eclipse thinks the scala code was java code. How can I fix this?

As I said above, Eclipse project is generated from Gradle. Assume it as some generated code. Next, re-check info on Gradle's Scala plugin. You'll see that your sources should be in src/main/scala. Or override Scala source location manually. Investigate ForgeMultipart's build.gradle. Otherwise, specify exactly what you do, what you expect to happen and what went wrong.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.