Skip to content

Commit 9ec8613

Browse files
authored
Initial commit
0 parents  commit 9ec8613

35 files changed

+1266
-0
lines changed

.gitattributes

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
* text eol=lf
2+
*.bat text eol=crlf
3+
*.patch text eol=lf
4+
*.java text eol=lf
5+
*.gradle text eol=crlf
6+
*.png binary
7+
*.gif binary
8+
*.exe binary
9+
*.dll binary
10+
*.jar binary
11+
*.lzma binary
12+
*.zip binary
13+
*.pyd binary
14+
*.cfg text eol=lf
15+
*.jks binary

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# eclipse
2+
bin
3+
*.launch
4+
.settings
5+
.metadata
6+
.classpath
7+
.project
8+
9+
# idea
10+
out
11+
*.ipr
12+
*.iws
13+
*.iml
14+
.idea/*
15+
!.idea/scopes
16+
17+
# gradle
18+
build
19+
.gradle
20+
21+
# other
22+
eclipse
23+
run

.idea/scopes/Fabric_sources.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/scopes/Forge_sources.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Creative Commons Legal Code
2+
3+
CC0 1.0 Universal
4+
5+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12+
HEREUNDER.
13+
14+
Statement of Purpose
15+
16+
The laws of most jurisdictions throughout the world automatically confer
17+
exclusive Copyright and Related Rights (defined below) upon the creator
18+
and subsequent owner(s) (each and all, an "owner") of an original work of
19+
authorship and/or a database (each, a "Work").
20+
21+
Certain owners wish to permanently relinquish those rights to a Work for
22+
the purpose of contributing to a commons of creative, cultural and
23+
scientific works ("Commons") that the public can reliably and without fear
24+
of later claims of infringement build upon, modify, incorporate in other
25+
works, reuse and redistribute as freely as possible in any form whatsoever
26+
and for any purposes, including without limitation commercial purposes.
27+
These owners may contribute to the Commons to promote the ideal of a free
28+
culture and the further production of creative, cultural and scientific
29+
works, or to gain reputation or greater distribution for their Work in
30+
part through the use and efforts of others.
31+
32+
For these and/or other purposes and motivations, and without any
33+
expectation of additional consideration or compensation, the person
34+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35+
is an owner of Copyright and Related Rights in the Work, voluntarily
36+
elects to apply CC0 to the Work and publicly distribute the Work under its
37+
terms, with knowledge of his or her Copyright and Related Rights in the
38+
Work and the meaning and intended legal effect of CC0 on those rights.
39+
40+
1. Copyright and Related Rights. A Work made available under CC0 may be
41+
protected by copyright and related or neighboring rights ("Copyright and
42+
Related Rights"). Copyright and Related Rights include, but are not
43+
limited to, the following:
44+
45+
i. the right to reproduce, adapt, distribute, perform, display,
46+
communicate, and translate a Work;
47+
ii. moral rights retained by the original author(s) and/or performer(s);
48+
iii. publicity and privacy rights pertaining to a person's image or
49+
likeness depicted in a Work;
50+
iv. rights protecting against unfair competition in regards to a Work,
51+
subject to the limitations in paragraph 4(a), below;
52+
v. rights protecting the extraction, dissemination, use and reuse of data
53+
in a Work;
54+
vi. database rights (such as those arising under Directive 96/9/EC of the
55+
European Parliament and of the Council of 11 March 1996 on the legal
56+
protection of databases, and under any national implementation
57+
thereof, including any amended or successor version of such
58+
directive); and
59+
vii. other similar, equivalent or corresponding rights throughout the
60+
world based on applicable law or treaty, and any national
61+
implementations thereof.
62+
63+
2. Waiver. To the greatest extent permitted by, but not in contravention
64+
of, applicable law, Affirmer hereby overtly, fully, permanently,
65+
irrevocably and unconditionally waives, abandons, and surrenders all of
66+
Affirmer's Copyright and Related Rights and associated claims and causes
67+
of action, whether now known or unknown (including existing as well as
68+
future claims and causes of action), in the Work (i) in all territories
69+
worldwide, (ii) for the maximum duration provided by applicable law or
70+
treaty (including future time extensions), (iii) in any current or future
71+
medium and for any number of copies, and (iv) for any purpose whatsoever,
72+
including without limitation commercial, advertising or promotional
73+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74+
member of the public at large and to the detriment of Affirmer's heirs and
75+
successors, fully intending that such Waiver shall not be subject to
76+
revocation, rescission, cancellation, termination, or any other legal or
77+
equitable action to disrupt the quiet enjoyment of the Work by the public
78+
as contemplated by Affirmer's express Statement of Purpose.
79+
80+
3. Public License Fallback. Should any part of the Waiver for any reason
81+
be judged legally invalid or ineffective under applicable law, then the
82+
Waiver shall be preserved to the maximum extent permitted taking into
83+
account Affirmer's express Statement of Purpose. In addition, to the
84+
extent the Waiver is so judged Affirmer hereby grants to each affected
85+
person a royalty-free, non transferable, non sublicensable, non exclusive,
86+
irrevocable and unconditional license to exercise Affirmer's Copyright and
87+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
88+
maximum duration provided by applicable law or treaty (including future
89+
time extensions), (iii) in any current or future medium and for any number
90+
of copies, and (iv) for any purpose whatsoever, including without
91+
limitation commercial, advertising or promotional purposes (the
92+
"License"). The License shall be deemed effective as of the date CC0 was
93+
applied by Affirmer to the Work. Should any part of the License for any
94+
reason be judged legally invalid or ineffective under applicable law, such
95+
partial invalidity or ineffectiveness shall not invalidate the remainder
96+
of the License, and in such case Affirmer hereby affirms that he or she
97+
will not (i) exercise any of his or her remaining Copyright and Related
98+
Rights in the Work or (ii) assert any associated claims and causes of
99+
action with respect to the Work, in either case contrary to Affirmer's
100+
express Statement of Purpose.
101+
102+
4. Limitations and Disclaimers.
103+
104+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
105+
surrendered, licensed or otherwise affected by this document.
106+
b. Affirmer offers the Work as-is and makes no representations or
107+
warranties of any kind concerning the Work, express, implied,
108+
statutory or otherwise, including without limitation warranties of
109+
title, merchantability, fitness for a particular purpose, non
110+
infringement, or the absence of latent or other defects, accuracy, or
111+
the present or absence of errors, whether or not discoverable, all to
112+
the greatest extent permissible under applicable law.
113+
c. Affirmer disclaims responsibility for clearing rights of other persons
114+
that may apply to the Work or any use thereof, including without
115+
limitation any person's Copyright and Related Rights in the Work.
116+
Further, Affirmer disclaims responsibility for obtaining any necessary
117+
consents, permissions or other rights required for any use of the
118+
Work.
119+
d. Affirmer understands and acknowledges that Creative Commons is not a
120+
party to this document and has no duty or obligation with respect to
121+
this CC0 or use of the Work.

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# MultiLoader Template
2+
3+
This project provides a Gradle project template that can compile mods for both Forge and Fabric using a common sourceset. This project does not require any third party libraries or dependencies. If you have any questions or want to discuss the project join our [Discord](https://discord.myceliummod.network).
4+
5+
## Getting Started
6+
7+
## IntelliJ IDEA
8+
This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up Forge and Fabric independently and should be very familiar to anyone who has worked with their MDKs.
9+
10+
1. Clone or download this repository to your computer.
11+
2. Configure the project by editing the `group`, `mod_name`, `mod_author`, and `mod_id` properties in the `gradle.properties` file. You will also need to change the `rootProject.name` property in `settings.gradle`, this should match the folder name of your project, or else IDEA may complain.
12+
3. Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable.
13+
4. If your default JVM/JDK is not Java 17 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM`and changing the value to a valid Java 17 JVM. You will also need to set the Project SDK to Java 17. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project.
14+
5. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Common > Tasks > vanilla gradle > decompile`. Run this task to decompile Minecraft.
15+
6. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Forge > Tasks > forgegradle runs > genIntellijRuns`. Run this task to set up run configurations for Forge.
16+
7. Open your Run/Debug Configurations. Under the Application category there should now be options to run Forge and Fabric projects. Select one of the client options and try to run it.
17+
8. Assuming you were able to run the game in step 7 your workspace should now be set up.
18+
19+
### Eclipse
20+
While it is possible to use this template in Eclipse it is not recommended. During the development of this template multiple critical bugs and quirks related to Eclipse were found at nearly every level of the required build tools. While we continue to work with these tools to report and resolve issues support for projects like these are not there yet. For now Eclipse is considered unsupported by this project. The development cycle for build tools is notoriously slow so there are no ETAs available.
21+
22+
## Development Guide
23+
When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the Forge or Fabric project.
24+
25+
Loader specific projects such as the Forge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects.

build.gradle

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
plugins {
2+
id 'fabric-loom' version '1.2-SNAPSHOT' apply(false)
3+
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
4+
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
5+
id("org.spongepowered.mixin") version "0.7-SNAPSHOT" apply(false)
6+
}
7+
8+
subprojects {
9+
apply plugin: 'java'
10+
11+
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
12+
java.withSourcesJar()
13+
java.withJavadocJar()
14+
15+
jar {
16+
from(rootProject.file("LICENSE")) {
17+
rename { "${it}_${mod_name}" }
18+
}
19+
manifest {
20+
attributes([
21+
'Specification-Title' : mod_name,
22+
'Specification-Vendor' : mod_author,
23+
'Specification-Version' : project.jar.archiveVersion,
24+
'Implementation-Title' : project.name,
25+
'Implementation-Version' : project.jar.archiveVersion,
26+
'Implementation-Vendor' : mod_author,
27+
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
28+
'Timestamp' : System.currentTimeMillis(),
29+
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
30+
'Built-On-Minecraft' : minecraft_version
31+
])
32+
}
33+
}
34+
35+
sourcesJar {
36+
from(rootProject.file("LICENSE")) {
37+
rename { "${it}_${mod_name}" }
38+
}
39+
}
40+
41+
repositories {
42+
mavenCentral()
43+
maven {
44+
name = 'Sponge / Mixin'
45+
url = 'https://repo.spongepowered.org/repository/maven-public/'
46+
}
47+
maven {
48+
name = 'BlameJared Maven (JEI / CraftTweaker / Bookshelf)'
49+
url = 'https://maven.blamejared.com'
50+
}
51+
}
52+
53+
tasks.withType(JavaCompile).configureEach {
54+
55+
it.options.encoding = 'UTF-8'
56+
it.options.getRelease().set(17)
57+
}
58+
59+
processResources {
60+
def expandProps = [
61+
"version": version,
62+
"group": project.group, //Else we target the task's group.
63+
"minecraft_version": minecraft_version,
64+
"forge_version": forge_version,
65+
"forge_loader_version_range": forge_loader_version_range,
66+
"forge_version_range": forge_version_range,
67+
"minecraft_version_range": minecraft_version_range,
68+
"fabric_version": fabric_version,
69+
"fabric_loader_version": fabric_loader_version,
70+
"mod_name": mod_name,
71+
"mod_author": mod_author,
72+
"mod_id": mod_id,
73+
"license": license,
74+
"description": project.description
75+
]
76+
77+
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) {
78+
expand expandProps
79+
}
80+
inputs.properties(expandProps)
81+
}
82+
83+
// Disables Gradle's custom module metadata from being published to maven. The
84+
// metadata includes mapped dependencies which are not reasonably consumable by
85+
// other mod developers.
86+
tasks.withType(GenerateModuleMetadata).configureEach {
87+
88+
enabled = false
89+
}
90+
}

common/build.gradle

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
id 'idea'
3+
id 'java'
4+
id 'maven-publish'
5+
id 'org.spongepowered.gradle.vanilla'
6+
}
7+
base {
8+
archivesName = "${mod_name}-common-${minecraft_version}"
9+
}
10+
minecraft {
11+
version(minecraft_version)
12+
if(file("src/main/resources/${mod_id}.accesswidener").exists()){
13+
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
14+
}
15+
}
16+
17+
dependencies {
18+
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
19+
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
20+
}
21+
22+
publishing {
23+
publications {
24+
mavenJava(MavenPublication) {
25+
artifactId base.archivesName.get()
26+
from components.java
27+
}
28+
}
29+
repositories {
30+
maven {
31+
url "file://" + System.getenv("local_maven")
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.example.examplemod;
2+
3+
import com.example.examplemod.platform.Services;
4+
import net.minecraft.core.registries.BuiltInRegistries;
5+
import net.minecraft.world.item.Items;
6+
7+
// This class is part of the common project meaning it is shared between all supported loaders. Code written here can only
8+
// import and access the vanilla codebase, libraries used by vanilla, and optionally third party libraries that provide
9+
// common compatible binaries. This means common code can not directly use loader specific concepts such as Forge events
10+
// however it will be compatible with all supported mod loaders.
11+
public class CommonClass {
12+
13+
// The loader specific projects are able to import and use any code from the common project. This allows you to
14+
// write the majority of your code here and load it from your loader specific projects. This example has some
15+
// code that gets invoked by the entry point of the loader specific projects.
16+
public static void init() {
17+
18+
Constants.LOG.info("Hello from Common init on {}! we are currently in a {} environment!", Services.PLATFORM.getPlatformName(), Services.PLATFORM.getEnvironmentName());
19+
Constants.LOG.info("The ID for diamonds is {}", BuiltInRegistries.ITEM.getKey(Items.DIAMOND));
20+
21+
// It is common for all supported loaders to provide a similar feature that can not be used directly in the
22+
// common code. A popular way to get around this is using Java's built-in service loader feature to create
23+
// your own abstraction layer. You can learn more about this in our provided services class. In this example
24+
// we have an interface in the common code and use a loader specific implementation to delegate our call to
25+
// the platform specific approach.
26+
if (Services.PLATFORM.isModLoaded("examplemod")) {
27+
28+
Constants.LOG.info("Hello to examplemod");
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.example.examplemod;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
public class Constants {
7+
8+
public static final String MOD_ID = "examplemod";
9+
public static final String MOD_NAME = "ExampleMod";
10+
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example.examplemod.mixin;
2+
3+
import com.example.examplemod.Constants;
4+
import net.minecraft.client.Minecraft;
5+
import net.minecraft.client.gui.screens.TitleScreen;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Inject;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10+
11+
@Mixin(Minecraft.class)
12+
public class MixinMinecraft {
13+
14+
@Inject(at = @At("TAIL"), method = "<init>")
15+
private void init(CallbackInfo info) {
16+
17+
Constants.LOG.info("This line is printed by an example mod common mixin!");
18+
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
19+
}
20+
}

0 commit comments

Comments
 (0)