Initial Commit
This commit is contained in:
113
Forge/build.gradle
Normal file
113
Forge/build.gradle
Normal file
@@ -0,0 +1,113 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url = 'https://maven.minecraftforge.net' }
|
||||
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
archivesBaseName = "${mod_id}-forge-${minecraft_version}"
|
||||
|
||||
mixin {
|
||||
add project(":Common").sourceSets.main, "${mod_id}.refmap.json"
|
||||
|
||||
add sourceSets.main, "${mod_id}-forge.refmap.json"
|
||||
|
||||
config "${mod_id}.mixins.json"
|
||||
config "${mod_id}-forge.mixins.json"
|
||||
}
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'official', version: minecraft_version
|
||||
|
||||
if (project.hasProperty('forge_accesstransformers') && project.findProperty('forge_accesstransformers').toBoolean()) {
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
project.logger.debug('Forge Access Transformers are enabled for this project.')
|
||||
}
|
||||
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
taskName 'Client'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}-forge.mixins.json"
|
||||
mods {
|
||||
modClientRun {
|
||||
source sourceSets.main
|
||||
source project(':Common').sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory project.file('run')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
taskName 'Server'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}-forge.mixins.json"
|
||||
mods {
|
||||
modServerRun {
|
||||
source sourceSets.main
|
||||
source project(':Common').sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
ideaModule "${rootProject.name}.${project.name}.main"
|
||||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
taskName 'Data'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
args "-mixin.config=${mod_id}.mixins.json", "-mixin.config=${mod_id}-forge.mixins.json"
|
||||
mods {
|
||||
modDataRun {
|
||||
source sourceSets.main
|
||||
source project(':Common').sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources.srcDir 'src/generated/resources'
|
||||
|
||||
dependencies {
|
||||
// Core Dependencies
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
|
||||
compileOnly project(path: ':Common', configuration: 'namedElements')
|
||||
|
||||
// Add your deps here
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
source(project(':Common').sourceSets.main.allSource)
|
||||
}
|
||||
|
||||
processResources {
|
||||
from project(':Common').sourceSets.main.resources
|
||||
|
||||
filesMatching("${mod_id}.mixins.json") {
|
||||
expand "refmap_target": "${mod_id}."
|
||||
}
|
||||
|
||||
filesMatching("${mod_id}-forge.mixins.json") {
|
||||
expand "refmap_target": "${mod_id}-"
|
||||
}
|
||||
}
|
||||
|
||||
jar.finalizedBy('reobfJar')
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.example.examplemod;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod(ModConstants.MOD_ID)
|
||||
public class ExampleModForge {
|
||||
|
||||
public ExampleModForge() {
|
||||
ModConstants.LOGGER.info("Hello Forge!");
|
||||
ExampleMod.initialize();
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onItemTooltip);
|
||||
}
|
||||
|
||||
private void onItemTooltip(ItemTooltipEvent event) {
|
||||
ExampleMod.onItemTooltip(event.getItemStack(), event.getFlags(), event.getToolTip());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.example.examplemod.mixin.client;
|
||||
|
||||
import com.example.examplemod.ModConstants;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public class ExampleForgeMixin {
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo ci) {
|
||||
ModConstants.LOGGER.info("This line is printed by a mixin from Forge!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.example.examplemod.platform;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
|
||||
public class ForgePlatformHelper implements IPlatformHelper {
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Forge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevelopmentEnvironment() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
}
|
||||
35
Forge/src/main/resources/META-INF/mods.toml
Normal file
35
Forge/src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,35 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[46,)"
|
||||
license="MIT"
|
||||
issueTrackerURL="https://github.com/minecraftforge/"
|
||||
|
||||
[[mods]]
|
||||
modId="examplemod"
|
||||
version="${file.jarVersion}"
|
||||
displayName="Example Mod"
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json"
|
||||
displayURL="https://minecraftforge.net"
|
||||
logoFile="assets/examplemod/icon.png"
|
||||
credits="Thanks for this example mod goes to Java"
|
||||
authors="ExampleAuthor"
|
||||
description='''
|
||||
This is a long form description of the mod. You can write whatever you want here
|
||||
|
||||
Have some lorem ipsum.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
'''
|
||||
|
||||
[[dependencies.examplemod]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[46,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.examplemod]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.20,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
@@ -0,0 +1 @@
|
||||
com.example.examplemod.platform.ForgePlatformHelper
|
||||
17
Forge/src/main/resources/examplemod-forge.mixins.json
Normal file
17
Forge/src/main/resources/examplemod-forge.mixins.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.example.examplemod.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"client.ExampleForgeMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"refmap": "${refmap_target}forge.refmap.json"
|
||||
}
|
||||
Reference in New Issue
Block a user