Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kappa-maintainer authored Jan 2, 2024
0 parents commit 55dca2d
Show file tree
Hide file tree
Showing 17 changed files with 869 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Disable autocrlf on generated files, they always generate with LF
# Add any extra files or paths here to make git stop saying they
# are changed when only line endings change.
src/generated/**/.cache/cache text eol=lf
src/generated/**/*.json text eol=lf
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project

# idea
out
*.ipr
*.iws
*.iml
.idea

# gradle
build
.gradle

# other
eclipse
run
/mcmodsrepo/
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ForgeTemplate
Everything but the Java Classes are thanks and are credited to SizeableShrimps ForgeTemplates found [Here](https://github.com/SizableShrimp/ForgeTemplate/tree/1.12.x)

## Setting up
* Open up `gradle.properties` and change all the necessary properties
* Rename the main package to be the same as `mod_base_package` in the properties file, e.g. `io.github.examplemod`

Finally, import into your IDE of choice.
159 changes: 159 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@

buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
maven { url = 'https://maven.outlands.top/releases' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.10.+', changing: true
//classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT"
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'java'

version = "${minecraft_version}-${mod_version}"
group = mod_base_package
archivesBaseName = mod_id



java.toolchain.languageVersion = JavaLanguageVersion.of(21)

minecraft {

mappings channel: mappings_channel, version: mappings_version

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

runs {
client {
workingDirectory project.file('run/client')

property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'

}

server {
workingDirectory project.file('run/server')

property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'

mods {
"${mod_id}" {
source sourceSets.main
}
}
}
}
}

sourceSets.main.resources { srcDir 'src/generated/resources' }
//mixin {add sourceSets.main, mod_id + "mixins.refmap.json"}
repositories {
maven {
name 'Cleanroom Maven'
url 'https://maven.cleanroommc.com/'
}
maven {
url "https://repo.cleanroommc.com/snapshots"
}
maven {
url "https://maven.outlands.top/releases/"
}

mavenCentral()
}

dependencies {
minecraft "com.cleanroommc:cleanroom:15.24.0.3023"
}


def resourceTargets = ['mcmod.info', 'pack.mcmeta']
def intoTargets = ["$rootDir/out/production/resources/", "$rootDir/out/production/${project.name}.main/", "$rootDir/bin/main/"]
def replaceProperties = [mod_id: mod_id, mod_name: mod_name, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description.replace('\n', '\\n'), minecraft_version: minecraft_version]
processResources {
inputs.properties replaceProperties
replaceProperties.put 'project', project

filesMatching(resourceTargets) {
expand replaceProperties
}

intoTargets.each { target ->
if (file(target).exists()) {
copy {
from(sourceSets.main.resources) {
include resourceTargets
expand replaceProperties
}
into target
}
}
}
}
//put what you want to replace here
def modFileTokens = [VERSION: mod_version, MODNAME: mod_name, MODID: mod_id]
def included = ["${mod_base_package.replace('.', '/')}/Reference.java".toString()]

def expandedSrc = new File(project.buildDir, 'expandedSrc')
def srcMainJava = project.file('src/main/java').toPath()
def includedPaths = included.collect { java.nio.file.Paths.get(it) }
task javaReplaceTokens(type: Copy) {
inputs.property 'tokens', modFileTokens
from(srcMainJava) {
include included
}
into expandedSrc
filter(org.apache.tools.ant.filters.ReplaceTokens, beginToken: '@', endToken: '@', tokens: modFileTokens)
}

compileJava {
dependsOn javaReplaceTokens
exclude {
srcMainJava.relativize(it.file.toPath()) in includedPaths
}
source expandedSrc
}

jar {
manifest {
attributes([
'Specification-Title': mod_id,
'Specification-Vendor': mod_authors,
'Specification-Version': '1', // We are version 1 of ourselves
//'FMLCorePluginContainsFMLMod': true,
//'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
//'FMLCorePlugin': '',
//'ForceLoadAsMod': true
//'FMLAT': '',
'Implementation-Title': project.name,
'Implementation-Version': mod_version,
'Implementation-Vendor': mod_authors,
'Implementation-Timestamp': new Date().format('yyyy-MM-dd\'T\'HH:mm:ssZ')
])
}
}

jar.finalizedBy('reobfJar')

publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
}
}
}
22 changes: 22 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs = -Xmx3G
#-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=1081
org.gradle.daemon=false
#org.gradle.java.home=C:/Program Files/Java/jdk-1.8

minecraft_version=1.12.2
minecraft_version_range=[1.12,1.13)
forge_version=14.23.5.2860
forge_version_range=[23,)
loader_version_range=[23,)
mappings_channel=stable
mappings_version=39-1.12

mod_id=examplemod
mod_name=ExampleMod
mod_main_class=ExampleMod
mod_version=1.0.0
mod_base_package=io.github.examplemod
mod_authors=SomeAuthor
mod_description=Example mod description\nNewline characters can be used and will be replaced properly
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 55dca2d

Please sign in to comment.