Compare commits
40 Commits
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 7e582d39ee | |
Shadowfacts | 09bd973e77 | |
NikkyAI | 85b8fd917b | |
Shadowfacts | 7aa0a3ef37 | |
Shadowfacts | 1342a6f5a6 | |
Shadowfacts | b18b818f64 | |
Shadowfacts | 90c0276180 | |
Shadowfacts | 583e9d8170 | |
Shadowfacts | 9809314759 | |
Shadowfacts | 9e8935d4cf | |
Shadowfacts | 7b885ea4cd | |
Shadowfacts | 7cebe692e7 | |
Shadowfacts | 26b895b6ce | |
gegy1000 | df437491f1 | |
Shadowfacts | ecf20f1a76 | |
Shadowfacts | 5d8ddee776 | |
Shadowfacts | c64538e7b0 | |
Kitten | be61809a7b | |
gegy1000 | 438c604d52 | |
Shadowfacts | 68c718fe57 | |
Shadowfacts | 06f171947d | |
Shadowfacts | ebba471b4b | |
Marvin Rösch | 6f718d74fc | |
Marvin Rösch | 23dfb368e1 | |
Shadowfacts | 8a5751bc19 | |
Shadowfacts | bb3a703467 | |
Severen Redwood | ae873b5cc4 | |
Shadowfacts | b3fe2d34b3 | |
Shadowfacts | 2065fbd62b | |
Shadowfacts | 33320699ac | |
Shadowfacts | 469fcdaea7 | |
Shadowfacts | d5138b9814 | |
Shadowfacts | 4dda702c93 | |
Shadowfacts | 531b3da7ef | |
Shadowfacts | e0209c61b2 | |
Shadowfacts | 757db6540d | |
Shadowfacts | 106c697b49 | |
Shadowfacts | 8a06ed849e | |
Shadowfacts | 307b2bb8cf | |
Eladkay | 5aa5c6b5c4 |
|
@ -0,0 +1,329 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library. GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
|
@ -2,14 +2,15 @@
|
|||
Fork of [Emberwalker's Forgelin](https://github.com/Emberwalker/Forgelin).
|
||||
|
||||
## Additions
|
||||
- Shades the Kotlin standard library, runtime, and reflect libraries so you don't have to.
|
||||
- Shades the Kotlin standard library, runtime, coroutines-core, and reflect libraries so you don't have to.
|
||||
- Provides a Forge `ILanguageAdapter` for using Kotlin `object` classes as your main mod class.
|
||||
|
||||
## Usage
|
||||
```groovy
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
url "http://mvn.rx14.co.uk/shadowfacts/
|
||||
url "http://maven.shadowfacts.net/"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,4 +19,6 @@ dependencies {
|
|||
}
|
||||
```
|
||||
|
||||
All versions can be seen [here](http://mvn.rx14.co.uk/shadowfacts/net/shadowfacts/Forgelin/).
|
||||
All versions can be seen [here](http://maven.shadowfacts.net/net/shadowfacts/Forgelin/).
|
||||
|
||||
**Note:** You must have the `jcenter()` call in your `repositories` block. JCenter is used to host the Kotlin coroutines libraries.
|
||||
|
|
40
build.gradle
40
build.gradle
|
@ -7,7 +7,7 @@ buildscript {
|
|||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT"
|
||||
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,9 @@ plugins {
|
|||
id "com.github.johnrengelman.shadow" version "1.2.3"
|
||||
}
|
||||
|
||||
apply plugin: "net.minecraftforge.gradle.forge"
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "net.minecraftforge.gradle.forge"
|
||||
apply from: "https://github.com/shadowfacts/maven/raw/master/maven.gradle"
|
||||
|
||||
version = mod_version
|
||||
|
||||
|
@ -31,8 +32,7 @@ minecraft {
|
|||
|
||||
mappings = mcp_mappings
|
||||
|
||||
replaceIn "Reference.kt"
|
||||
replaceIn "Reference.kt"
|
||||
replaceIn "Forgelin.kt"
|
||||
replace "@VERSION@", mod_version
|
||||
|
||||
useDepAts = true
|
||||
|
@ -52,28 +52,23 @@ processResources {
|
|||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name "shadowfacts"
|
||||
url "http://mvn.rx14.co.uk/shadowfacts/"
|
||||
}
|
||||
maven {
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
maven {
|
||||
url "http://maven.epoxide.xyz"
|
||||
}
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: kotlin_version
|
||||
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk7", version: kotlin_version
|
||||
compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib-jdk8", version: kotlin_version
|
||||
compile group: "org.jetbrains.kotlin", name: "kotlin-reflect", version: kotlin_version
|
||||
compile group: "org.jetbrains.kotlin", name: "kotlin-runtime", version: kotlin_version
|
||||
compile group: "org.jetbrains", name: "annotations", version: annotations_version
|
||||
compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-core", version: coroutines_version
|
||||
compile group: "org.jetbrains.kotlinx", name: "kotlinx-coroutines-jdk8", version: coroutines_version
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes "FMLCorePlugin": "net.shadowfacts.forgelin.ForgelinPlugin"
|
||||
attributes "FMLCorePluginContainsFMLMod": "true"
|
||||
attributes "FMLCorePlugin": "net.shadowfacts.forgelin.preloader.ForgelinPlugin",
|
||||
"FMLCorePluginContainsFMLMod": "true"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,11 +76,16 @@ shadowJar {
|
|||
classifier = ""
|
||||
dependencies {
|
||||
include(dependency("org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"))
|
||||
include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"))
|
||||
include(dependency("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"))
|
||||
include(dependency("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"))
|
||||
include(dependency("org.jetbrains.kotlin:kotlin-runtime:${kotlin_version}"))
|
||||
include(dependency("org.jetbrains:annotations:${annotations_version}"))
|
||||
include(dependency("org.jetbrains.kotlinx:kotlinx-coroutines-core:${coroutines_version}"))
|
||||
include(dependency("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${coroutines_version}"))
|
||||
}
|
||||
manifest {
|
||||
attributes "FMLCorePlugin": "net.shadowfacts.forgelin.ForgelinPlugin"
|
||||
attributes "FMLCorePlugin": "net.shadowfacts.forgelin.preloader.ForgelinPlugin",
|
||||
"FMLCorePluginContainsFMLMod": "true"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,3 +102,5 @@ reobf {
|
|||
}
|
||||
tasks.reobfShadowJar.mustRunAfter shadowJar
|
||||
tasks.build.dependsOn reobfShadowJar
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
mod_version = 1.1.0
|
||||
mod_version = 1.8.4
|
||||
group = net.shadowfacts
|
||||
archivesBaseName = Forgelin
|
||||
|
||||
mc_version = 1.10.2
|
||||
mcp_mappings = snapshot_20160802
|
||||
forge_version = 12.18.1.2045
|
||||
mc_version = 1.12.2
|
||||
mcp_mappings = snapshot_20180609
|
||||
forge_version = 14.23.4.2705
|
||||
|
||||
kotlin_version = 1.0.5
|
||||
kotlin_version = 1.3.50
|
||||
annotations_version = 16.0.3
|
||||
coroutines_version = 1.3.1
|
||||
|
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package net.shadowfacts.forgelin;
|
||||
package net.shadowfacts.forgelin.preloader;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class ForgelinPlugin implements IFMLLoadingPlugin {
|
|||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return "net.shadowfacts.forgelin.ForgelinSetup";
|
||||
return "net.shadowfacts.forgelin.preloader.ForgelinSetup";
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package net.shadowfacts.forgelin;
|
||||
package net.shadowfacts.forgelin.preloader;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.IFMLCallHook;
|
||||
|
||||
|
@ -15,7 +15,8 @@ public class ForgelinSetup implements IFMLCallHook {
|
|||
try {
|
||||
loader.loadClass("net.shadowfacts.forgelin.KotlinAdapter");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// this should never happen
|
||||
throw new RuntimeException("Couldn't find Forgelin langague adapter, this shouldn't be happening", e);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package net.shadowfacts.forgelin
|
||||
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
||||
import net.minecraftforge.fml.common.Loader
|
||||
import net.minecraftforge.fml.common.Mod
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Mod(modid = Forgelin.MOD_ID, name = Forgelin.NAME, version = Forgelin.VERSION, acceptableRemoteVersions = "*", acceptedMinecraftVersions = "*", modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter")
|
||||
object Forgelin {
|
||||
|
||||
const val MOD_ID = "forgelin"
|
||||
const val NAME = "Forgelin"
|
||||
const val VERSION = "@VERSION@"
|
||||
|
||||
@EventHandler
|
||||
fun onPreInit(event: FMLPreInitializationEvent) {
|
||||
Loader.instance().modList.forEach {
|
||||
ForgelinAutomaticEventSubscriber.subscribeAutomatic(it, event.asmData, FMLCommonHandler.instance().side)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package net.shadowfacts.forgelin
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.fml.common.Loader
|
||||
import net.minecraftforge.fml.common.LoaderException
|
||||
import net.minecraftforge.fml.common.Mod
|
||||
import net.minecraftforge.fml.common.ModContainer
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData
|
||||
import net.minecraftforge.fml.common.discovery.asm.ModAnnotation.EnumHolder
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||
import net.minecraftforge.fml.relauncher.Side
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.EnumSet
|
||||
import kotlin.reflect.full.companionObjectInstance
|
||||
|
||||
object ForgelinAutomaticEventSubscriber {
|
||||
private val DEFAULT_SUBSCRIPTION_SIDES = EnumSet.allOf(Side::class.java)
|
||||
private val LOGGER = LogManager.getLogger(ForgelinAutomaticEventSubscriber::class.java)
|
||||
|
||||
private val unregistered = mutableSetOf<Class<*>>()
|
||||
private val registered = mutableSetOf<Any>()
|
||||
|
||||
fun subscribeAutomatic(mod: ModContainer, asm: ASMDataTable, currentSide: Side) {
|
||||
val modAnnotations = asm.getAnnotationsFor(mod) ?: return
|
||||
|
||||
val containedMods = modAnnotations.get(Mod::class.java.name)
|
||||
val subscribers = modAnnotations.get(Mod.EventBusSubscriber::class.java.name)
|
||||
.filter { parseTargetSides(it).contains(currentSide) }
|
||||
|
||||
val loader = Loader.instance().modClassLoader
|
||||
|
||||
|
||||
for (containedMod in containedMods) {
|
||||
val containedModId = containedMod.annotationInfo["modid"] as String
|
||||
if (containedMod.annotationInfo["modLanguageAdapter"] != KotlinAdapter::class.qualifiedName) {
|
||||
LOGGER.debug("Skipping @EventBusSubscriber injection for {} since it does not use KotlinAdapter", containedModId)
|
||||
continue
|
||||
}
|
||||
|
||||
LOGGER.debug("Attempting to register Kotlin @EventBusSubscriber objects for {}", containedModId)
|
||||
|
||||
for (subscriber in subscribers) {
|
||||
try {
|
||||
val ownerModId = parseModId(containedMods, subscriber)
|
||||
if (ownerModId.isNullOrEmpty()) {
|
||||
LOGGER.debug("Could not determine owning mod for @EventBusSubscriber on {} for mod {}", subscriber.className, mod.modId)
|
||||
continue
|
||||
}
|
||||
|
||||
if (containedModId != ownerModId) {
|
||||
LOGGER.debug("Skipping @EventBusSubscriber injection for {} since it is not for mod {}", subscriber.className, containedModId)
|
||||
continue
|
||||
}
|
||||
|
||||
val subscriberClass = Class.forName(subscriber.className, false, loader) ?: continue
|
||||
val kotlinClass = subscriberClass.kotlin
|
||||
val objectInstance = kotlinClass.objectInstance ?: kotlinClass.companionObjectInstance ?: continue
|
||||
|
||||
if (!hasStaticEventHandlers(subscriberClass) && subscriberClass !in unregistered) {
|
||||
MinecraftForge.EVENT_BUS.unregister(subscriberClass)
|
||||
unregistered += subscriberClass
|
||||
LOGGER.debug("Unregistered static @EventBusSubscriber class {}", subscriber.className)
|
||||
}
|
||||
if (hasObjectEventHandlers(objectInstance) && objectInstance !in registered) {
|
||||
MinecraftForge.EVENT_BUS.register(objectInstance)
|
||||
registered += objectInstance
|
||||
LOGGER.debug("Registered @EventBusSubscriber object instance {}", subscriber.className)
|
||||
}
|
||||
|
||||
} catch (e: Throwable) {
|
||||
LOGGER.error("An error occurred trying to load an @EventBusSubscriber object {} for modid {}", mod.modId, e)
|
||||
throw LoaderException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasObjectEventHandlers(objectInstance: Any): Boolean {
|
||||
return objectInstance.javaClass.methods.any {
|
||||
!Modifier.isStatic(it.modifiers) && it.isAnnotationPresent(SubscribeEvent::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasStaticEventHandlers(clazz: Class<*>): Boolean {
|
||||
return clazz.methods.any {
|
||||
Modifier.isStatic(it.modifiers) && it.isAnnotationPresent(SubscribeEvent::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseModId(containedMods: MutableSet<ASMData>, subscriber: ASMData): String? {
|
||||
val parsedModId: String? = subscriber.annotationInfo["modid"] as? String
|
||||
if (parsedModId.isNullOrEmpty()) {
|
||||
return parsedModId
|
||||
}
|
||||
|
||||
return ASMDataTable.getOwnerModID(containedMods, subscriber)
|
||||
}
|
||||
|
||||
private fun parseTargetSides(subscriber: ASMData): EnumSet<Side> {
|
||||
val parsedSides: List<EnumHolder>? = subscriber.annotationInfo["value"] as? List<EnumHolder>
|
||||
if (parsedSides != null) {
|
||||
val targetSides = EnumSet.noneOf(Side::class.java)
|
||||
for (parsed in parsedSides) {
|
||||
targetSides.add(Side.valueOf(parsed.value))
|
||||
}
|
||||
return targetSides
|
||||
}
|
||||
return DEFAULT_SUBSCRIPTION_SIDES
|
||||
}
|
||||
}
|
|
@ -23,45 +23,19 @@ class KotlinAdapter : ILanguageAdapter {
|
|||
|
||||
override fun setProxy(target: Field, proxyTarget: Class<*>, proxy: Any) {
|
||||
log.debug("Setting proxy: ${target.declaringClass.simpleName}.${target.name} -> $proxy")
|
||||
if (proxyTarget.fields.any { x -> x.name == "INSTANCE" }) {
|
||||
// Singleton
|
||||
try {
|
||||
log.debug("Setting proxy on INSTANCE; singleton target")
|
||||
val obj = proxyTarget.getField("INSTANCE").get(null)
|
||||
target.set(obj, proxy)
|
||||
} catch (e: Exception) {
|
||||
throw KotlinAdapterException(e)
|
||||
}
|
||||
} else {
|
||||
target.set(proxyTarget, proxy)
|
||||
}
|
||||
|
||||
// objectInstance is not null if it's a Kotlin object, so set the value on the object
|
||||
// if it is null, set the value on the static field
|
||||
target.set(proxyTarget.kotlin.objectInstance, proxy)
|
||||
}
|
||||
|
||||
override fun getNewInstance(container: FMLModContainer, objectClass: Class<*>, classLoader: ClassLoader, factoryMarkedAnnotation: Method?): Any {
|
||||
log.debug("FML has asked for ${objectClass.simpleName} to be constructed")
|
||||
try {
|
||||
// Try looking for an object type
|
||||
val f = objectClass.getField("INSTANCE")
|
||||
val obj = f.get(null) ?: throw NullPointerException()
|
||||
log.debug("Found an object INSTANCE reference in ${objectClass.simpleName}, using that. ${obj}")
|
||||
return obj
|
||||
} catch (e: Exception) {
|
||||
// Try looking for a class type
|
||||
log.debug("Failed to get object reference, trying class construction")
|
||||
try {
|
||||
val obj = objectClass.newInstance() ?: throw NullPointerException()
|
||||
log.debug("Constructed an object from a class type ($objectClass), using that. $obj")
|
||||
return obj
|
||||
} catch (e: Exception) {
|
||||
throw KotlinAdapterException(e)
|
||||
}
|
||||
}
|
||||
return objectClass.kotlin.objectInstance ?: objectClass.newInstance()
|
||||
}
|
||||
|
||||
override fun setInternalProxies(mod: ModContainer?, side: Side?, loader: ClassLoader?) {
|
||||
// Nothing to do; FML's got this covered for Kotlin
|
||||
}
|
||||
|
||||
private class KotlinAdapterException(e: Exception) : RuntimeException("Kotlin adapter error - do not report to Forge!", e)
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"modid": "forgelin",
|
||||
"name": "Shadowfacts' Forgelin",
|
||||
"version": "$version",
|
||||
"mcversion": "$mcversion",
|
||||
"description": "Kotlin helper library for Forge.",
|
||||
"credits": "Emberwalker, for the original Forgelin",
|
||||
"url": "https://github.com/shadowfacts/Forgelin",
|
||||
"updateUrl": "",
|
||||
"authorList": [ "shadowfacts" ],
|
||||
"screenshots": []
|
||||
}
|
||||
]
|
|
@ -1,16 +0,0 @@
|
|||
import net.minecraftforge.fml.common.FMLLog
|
||||
import net.minecraftforge.fml.common.Mod
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Mod(modid = "test", modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter")
|
||||
object Test {
|
||||
|
||||
@Mod.EventHandler
|
||||
fun preInit(event: FMLPreInitializationEvent) {
|
||||
FMLLog.bigWarning("Hello from Kotlin!")
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package net.shadowfacts.forgelin
|
||||
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock
|
||||
import net.minecraftforge.fml.common.Mod
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||
|
||||
@Mod(modid = AutomaticKtSubscriberTest.MODID, modLanguageAdapter = "net.shadowfacts.forgelin.KotlinAdapter")
|
||||
object AutomaticKtSubscriberTest {
|
||||
const val MODID = "ktsubtest"
|
||||
|
||||
@EventBusSubscriber(modid = AutomaticKtSubscriberTest.MODID)
|
||||
object EventSubscriber {
|
||||
@SubscribeEvent
|
||||
fun onRightClickBlock(event: RightClickBlock) {
|
||||
println("Automatic KT subscriber: Right click ${event.pos}")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@SubscribeEvent
|
||||
fun onRightClickItem(event: PlayerInteractEvent.RightClickItem) {
|
||||
println("Right click item")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue