Code Monkey home page Code Monkey logo

forgelin's Introduction

Kotlin Adapter for Minecraft Forge

Kotlin support for Minecraft Forge 1.8-11.14.1.1371 or above

Build Status

Using the Adapter

The basic workflow for using the Adapter in your project is;

  1. Either shade (and repack) the adapter jar or manually copy the adapter + helpers you want into your project
  2. Shade (via a Gradle plugin or with ForgeGradle trickery) the version of Kotlin you want
  3. Hack away

Buildscript Preparation

These instructions are for FG 2.1+.

We require the Kotlin and Forge plugins to be enabled in build.gradle:

buildscript {
	[...]
	dependencies {
		[...]
		classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.1"
	}
	[...]
}

repositories {
	[...]
	// For Kotlin lang adapter
	maven {
		name 'Tethys'
		url 'http://tethys.drakon.io/maven'
	}
}

apply plugin: 'kotlin'
apply plugin: 'net.minecraftforge.gradle.forge'
[...]

Repackaging

This technique requires tinkering with your build.gradle file.

As a second warning: Doing this wrong could break other Kotlin-based mods!

Now the warnings are out the way, we're going to use a technique called shading combined with repacking. Built jars of the adapter do not come with Kotlin installations. This means your mod must include its own, repackaged version.

First, we need to add a new configuration:

configurations {
    shade
    compile.extendsFrom shade
}

Then on the lines where you would normally define compile in the main dependencies block for Kotlin, replace compile with shade - below is an example dependency block (for Kotlin 1.0.1.) If you need the kotlin-reflect library, add that in the same way (but be aware this'll add >1MB to your jar size!)

dependencies {
	shade 'org.jetbrains.kotlin:kotlin-stdlib:1.0.1'
	shade 'io.drakon.forge:kotlin-adapter:1.0.1+1.8.9'
}

Next, tell Gradle what to do with this new shade configuration inside the jar {} block:

jar {
	[...]
	// Shading
    configurations.shade.each { dep ->
        from(project.zipTree(dep)){
            exclude 'META-INF', 'META-INF/**'
        }
    }
	[...]
}

Finally, ask ForgeGradle to add some extra rules for reobfuscation, to avoid namespace issues with other Kotlin versions that may be on the classpath:

reobf {
    jar {
	    // Kotlin+Adapter shading
	    extraLines += [ "PK: kotlin your/package/here/repack/kotlin" ]
	    extraLines += [ "PK: org/jetbrains/annotations your/package/here/repack/annotations" ]
	    extraLines += [ "PK: io/drakon/forge/kotlin your/package/here/repack/adapter" ]
	}
}

The destination package (your/package/here/repack for this example) can be any package you think won't clash, either with your code or anybody else's packages. As in the example, package paths use forward slash (/) in PK lines.

Your @Mod implementation must be an object. There is no reason to make it a class and the adapter will not work if you do so.

Licenses

The Kotlin Adapter is licensed under the ISC License (see LICENSE), which is just a modernised version of the MIT License.

Kotlin is property of Jetbrains. Look at their site for licensing bumf.

forgelin's People

Contributors

dmillerw avatar emberwalker avatar lopcode avatar mokona avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forgelin's Issues

Issue compiling, testing

This is probably user(modder) error and not your mod, but when I googled the issue, all I found was that Kotlin needs an update, and Intellij wasn't showing any errors. Anyways, when I compile my mod, I get this:
http://paste.ubuntu.com/14862086/

Also, with the setup described in your readme, you can't test the mod in intellij either, you have to build and run the mod to test it

Slim distribution to easily shadeable library form

Basic plan is to strip the library down to just the adapter + utility classes, which can be safely included and shaded directly, leaving the shading of Kotlin itself to mods (the stdlib is pretty small anyways, even smaller if stripped to essentials.) This'll also need a large amount of documentation re-writing.

Using with intellij+kotlin

Hey there, kotlin newbie here, how do I hook this up to my project with intellij idea 2017? Methods listed in readme don't really work for me :/

Possible 1.12.2 version?

I need to ask, do you intend on updating forgelin to work with 1.12.2? I'm trying to use a mod on 1.12.2 that relies on LibrarianLib which also relies on forgelin, but the problem is, forgelin won't work on 1.12.2 because according to the curseforge page, the newest version is only for 1.8.9.

1.9

Fairly straight forward: Do you plan on updating this for Minecraft/Forge 1.9? I'd love to be able to write my 1.9 mods in Kotlin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.