commit 07af324f0161a768efafbf02a21f0239f85dbd31 Author: Oier Bravo Urtasun Date: Mon Apr 21 23:05:40 2025 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e7bd2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.idea +.vscode +run +.gradle +build diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..153d416 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..75a80a7 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Create Mechanical Addon Template + +## Requirements: +- Copier https://copier.readthedocs.io/en/stable/ \ No newline at end of file diff --git a/README.md.jinja b/README.md.jinja new file mode 100644 index 0000000..61241fb --- /dev/null +++ b/README.md.jinja @@ -0,0 +1,16 @@ +# {{MECHANICAL_NAME}} + +Addon for create. + +## Features + + +## Compat + + +**Thanks to the Creators of Create.** + +## License +{{MECHANICAL_NAME}} is licensed under the LGPL3 license. See [LICENSE](LICENSE) for more information. + +Certain sections of the code are from the Create mod, which is licensed under the MIT license. See [Create's license](https://github.com/Creators-of-Create/Create/blob/mc1.18/dev/LICENSE) for more information. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..97ad567 --- /dev/null +++ b/build.gradle @@ -0,0 +1,236 @@ +plugins { + id "idea" + id "net.neoforged.moddev" version "2.0.74" + id "dev.ithundxr.silk" version "0.11.15" + id "me.modmuss50.mod-publish-plugin" version "0.8.3" +} + +apply from: "./gradle/java.gradle" +apply from: "gradle/property_loader.gradle" + +group = "com.${mod_author}.${mod_id}" +version = "${minecraft_version}-${mod_version}" +archivesBaseName = mod_id + +idea { + module { + downloadJavadoc = true + downloadSources = true + } +} + +neoForge { + version = project.neo_version + + // TODO - Try turning this on later + validateAccessTransformers = false + + if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { + accessTransformers.from "src/main/resources/META-INF/accesstransformer.cfg" + } + + parchment { + minecraftVersion = minecraft_version + mappingsVersion = parchment_version + } + mods { + "$mod_id" { + sourceSet sourceSets.main + } + } + runs { + // applies to all the run configs below + configureEach { + systemProperty 'forge.logging.markers', '' + systemProperty 'forge.logging.console.level', 'info' + jvmArguments = ["-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition"] + //jvmArgs("-XX:-OmitStackTraceInFastThrow") // uncomment when you get exceptions with null messages etc + //jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling + + systemProperty 'mixin.debug.export', 'true' + systemProperty 'mixin.debug.verbose', 'true' + //programArgument '-mixin.config=create.mixins.json' + //programArgument '-mixin.config=ponder.mixins.json' + //systemProperty("mixin.env.remapRefMap", "true") + //systemProperty("mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg") + + + + + } + + client { + client() + gameDirectory = project.file('run') + } + + server { + server() + + gameDirectory = project.file('run/server') + } + + data { + data() + + gameDirectory = project.file('run') + systemProperty 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP' + systemProperty 'forge.logging.console.level', 'debug' + programArguments.addAll("--mod", project.mod_id, "--all", "--output", file("src/generated/resources/").getAbsolutePath(), "--existing", file("src/main/resources").getAbsolutePath()) + } + + gameTestServer { + type = "gameTestServer" + + gameDirectory = project.file('run/gametest') + } + } +} + +sourceSets.main { + resources { + srcDir 'src/generated/resources' + exclude '.cache/' + } +} + +repositories { + maven { url = "https://maven.createmod.net" } // Create, Ponder, Flywheel + maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // ForgeConfigAPIPort + maven { url = "https://mvn.devos.one/snapshots" } // Registrate + maven { url = "https://maven.blamejared.com" } // JEI, Vazkii's Mods + + maven { + // location of the maven for Curios API + url = "https://maven.theillusivec4.top/" + } + maven { + // location of maven for CC: Tweaked + name = "squiddev" + url = "https://squiddev.cc/maven/" + } + + maven { + url = 'https://www.cursemaven.com' + content { + includeGroup "curse.maven" + } + } + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + maven { + url "https://jitpack.io" + content { + includeGroup "com.github.llamalad7.mixinextras" + } + } + + maven { + url "https://maven.saps.dev/minecraft" + content { + includeGroup "dev.latvian.mods" + includeGroup "dev.ftb.mods" + } + } + maven { + url "https://maven.architectury.dev/" + content { + includeGroup "dev.architectury" + } + } + mavenLocal() + flatDir { + dirs 'libs' + } +} + +dependencies { + implementation 'org.jetbrains:annotations:22.0.0' + + jarJar(implementation("com.oierbravo.mechanicals:Mechanicals:${mechanicals}")) + + implementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } + implementation("net.createmod.ponder:Ponder-NeoForge-${minecraft_version}:${ponder_version}") + compileOnly("dev.engine-room.flywheel:flywheel-neoforge-api-${minecraft_version}:${flywheel_version}") + runtimeOnly("dev.engine-room.flywheel:flywheel-neoforge-${minecraft_version}:${flywheel_version}") + implementation("com.tterrag.registrate:Registrate:${registrate_version}") + + compileOnly("top.theillusivec4.curios:curios-neoforge:${curios_version}+${curios_minecraft_version}:api") + runtimeOnly("top.theillusivec4.curios:curios-neoforge:${curios_version}+${curios_minecraft_version}") + + implementation("curse.maven:jade-324717:${jade_id}") + implementation("mezz.jei:jei-${jei_minecraft_version}-neoforge:${jei_version}") + + + if (cc_tweaked_enable.toBoolean()) { + compileOnly("cc.tweaked:cc-tweaked-${cc_tweaked_minecraft_version}-core-api:${cc_tweaked_version}") + compileOnly("cc.tweaked:cc-tweaked-${cc_tweaked_minecraft_version}-forge-api:${cc_tweaked_version}") + runtimeOnly("cc.tweaked:cc-tweaked-${cc_tweaked_minecraft_version}-forge:${cc_tweaked_version}") + } + + if (kubejs_enabled.toBoolean()) { + compileOnly("dev.architectury:architectury-neoforge:$architectury_version") + //api("dev.latvian.mods:kubejs-neoforge:$kubejs_version") + //interfaceInjectionData("dev.latvian.mods:kubejs-neoforge:$kubejs_version") // optional + } + +} + +processResources { + def buildProps = project.properties.clone() + + // Replaces FML's magic file.jarVersion string with the correct version at build time. + buildProps.put('file', [jarVersion: project.version]) + + filesMatching(['META-INF/neoforge.mods.toml', 'pack.mcmeta']) { + expand buildProps + } +} +compileJava { + options.compilerArgs = ['-Xdiags:verbose'] +} + +jar { + from('LICENSE') { + rename { "${it}_${archivesBaseName}" } + } + +} + +publishMods { + file = jar.archiveFile + changelog = rootProject.file("changes/${minecraft_version}-${mod_version}.md").text + type = BETA + version = "$minecraft_version-$mod_version" + displayName = "$mod_name $mod_version for mc$minecraft_version" + modLoaders.add("neoforge") + + var cfToken = System.getenv("CF_TOKEN") + if(cfToken != null) { + curseforge { + accessToken = providers.environmentVariable("CF_TOKEN") + projectId = "${curseforge_id}" + minecraftVersions.add(minecraft_version) + clientRequired = true + serverRequired = true + requires("create") + optional("jei") + + } + } + var mrToken = System.getenv("MODRINTH_TOKEN") + if(mrToken != null) { + modrinth { + accessToken = providers.environmentVariable("MODRINTH_TOKEN") + projectId = "${modrinth_id}" + minecraftVersions.add(minecraft_version) + requires("create") + optional("jei") + } + } +} diff --git a/changes/1.21.1-1.0.0-6.0.4.md b/changes/1.21.1-1.0.0-6.0.4.md new file mode 100644 index 0000000..ef55171 --- /dev/null +++ b/changes/1.21.1-1.0.0-6.0.4.md @@ -0,0 +1 @@ +Fixed crash \ No newline at end of file diff --git a/copier.yml b/copier.yml new file mode 100644 index 0000000..d02f79e --- /dev/null +++ b/copier.yml @@ -0,0 +1,12 @@ +# questions +MECHANICAL_ID: + type: str + help: What is your project id? + +MECHANICAL_NAME: + type: str + help: What is your project name? + +MECHANICAL_MAIN_CLASS: + type: str + help: What is your main class? \ No newline at end of file diff --git a/gradle.properties.jinja b/gradle.properties.jinja new file mode 100644 index 0000000..a350b76 --- /dev/null +++ b/gradle.properties.jinja @@ -0,0 +1,51 @@ +# 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 +org.gradle.daemon=false + +use_parchment = true + +# mod version info +mod_version=1.0.0-6.0.4 +mod_id={{MECHANICAL_ID}} +mod_author=oierbravo +mod_name={{MECHANICAL_NAME}} + +mechanicals = 0.4.27 + +# Base Dependencies +minecraft_version = 1.21.1 +minecraft_version_range=[1.21.1] + +neo_version = 21.1.129 +neo_version_range=[21.1.129,) + +parchment_minecraft_version = 1.21.1 +parchment_version = 2024.11.17 + +# Dependency Versions +create_version = 6.0.4-53 +ponder_version = 1.0.46 +flywheel_version = 1.0.2 +registrate_version = MC1.21-1.3.0+62 +jei_minecraft_version = 1.21.1 +jei_version = 19.21.0.247 +curios_minecraft_version = 1.21.1 +curios_version = 9.2.2 + +jade_id = 6198776 + +cc_tweaked_enable = false +cc_tweaked_minecraft_version = 1.21.1 +cc_tweaked_version = 1.114.2 + +kubejs_enabled = false +kubejs_version=2101.7.1-build.181 +#kubejs_version=2101.7.2-build.230 +rhino_version=2101.2.7-build.74 +architectury_version=13.0.2 +mixin_extras_version = 0.4.1 + + +#curseforge_id = +#modrinth_id = diff --git a/gradle/java.gradle b/gradle/java.gradle new file mode 100644 index 0000000..e7a4bd0 --- /dev/null +++ b/gradle/java.gradle @@ -0,0 +1,39 @@ +apply plugin: 'java' + +java.toolchain.languageVersion = JavaLanguageVersion.of(21) +java.withSourcesJar() +java.withJavadocJar() + +jar { + manifest { + attributes([ + 'Specification-Title' : mod_name, + 'Specification-Vendor' : mod_author, + 'Specification-Version' : project.jar.archiveVersion, + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.jar.archiveVersion, + 'Implementation-Vendor' : mod_author, + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + 'Timestampe' : System.currentTimeMillis(), + 'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})", + 'Built-On-Minecraft' : minecraft_version + ]) + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.encoding = 'UTF-8' + it.options.release = 21 +} + +// Disables Gradle's custom module metadata from being published to maven. The +// metadata includes mapped dependencies which are not reasonably consumable by +// other mod developers. +tasks.withType(GenerateModuleMetadata) { + enabled = false +} + +javadoc { + // Suppress annoying warnings when generating JavaDoc files. + options.addStringOption('Xdoclint:none', '-quiet') +} diff --git a/gradle/property_loader.gradle b/gradle/property_loader.gradle new file mode 100644 index 0000000..a0154ef --- /dev/null +++ b/gradle/property_loader.gradle @@ -0,0 +1,48 @@ +/* + This module can inject build properties from a JSON file. Each property in the + JSON file will be mapped to a build property using the key of that property. + Property keys ending with _comment will be skipped. + + If a secretFile property exists and points to a valid JSON file that file will + be automatically loaded. You can manually load a file using the loadProperties + method. +*/ +import groovy.json.JsonSlurper + +// Auto detects a secret file and injects it. +if (project.rootProject.hasProperty("secretFile")) { + project.logger.lifecycle("Automatically loading properties from the secretFile") + final def secretsFile = project.rootProject.file(project.rootProject.getProperty("secretFile")) + + if (secretsFile.exists() && secretsFile.name.endsWith(".json")) { + loadProperties(secretsFile) + } +} + +// Loads properties using a specified json file. +def loadProperties(propertyFile) { + if (propertyFile.exists()) { + propertyFile.withReader { + Map propMap = new JsonSlurper().parse it + + for (entry in propMap) { + + // Filter entries that use _comment in the key. + if (!entry.key.endsWith("_comment")) { + + project.ext.set(entry.key, entry.value) + } + } + + project.logger.lifecycle("Successfully loaded " + propMap.size() + " properties") + propMap.clear() + } + } else { + project.logger.warn("The property file " + propertyFile.getName() + " could not be loaded. It does not exist.") + } +} + +// Allows other scripts to use these methods. +ext { + loadProperties = this.&loadProperties +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..943f0cb Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..8fc91c8 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..65dcd68 --- /dev/null +++ b/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.jinja b/settings.gradle.jinja new file mode 100644 index 0000000..05db250 --- /dev/null +++ b/settings.gradle.jinja @@ -0,0 +1,12 @@ +pluginManagement { + repositories { + mavenLocal() + gradlePluginPortal() + maven { url = 'https://maven.neoforged.net/releases' } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} +rootProject.name = '{{MECHANICAL_NAME}}' \ No newline at end of file diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ModConstants.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ModConstants.java.jinja new file mode 100644 index 0000000..2198aa1 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ModConstants.java.jinja @@ -0,0 +1,11 @@ +package com.oierbravo.{{MECHANICAL_ID}}; + +import net.minecraft.resources.ResourceLocation; + +public class ModConstants { + public static final String MODID = "{{MECHANICAL_ID}}"; + public static final String DISPLAY_NAME = "{{MECHANICAL_NAME}}"; + public static ResourceLocation asResource(String path) { + return ResourceLocation.fromNamespaceAndPath(MODID, path); + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ModLang.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ModLang.java.jinja new file mode 100644 index 0000000..e5e74dd --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ModLang.java.jinja @@ -0,0 +1,17 @@ +package com.oierbravo.{{MECHANICAL_ID}}.foundation.utility; + +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import net.createmod.catnip.lang.Lang; +import net.createmod.catnip.lang.LangBuilder; + +public class ModLang extends Lang { + public ModLang() { + super(); + } + public static LangBuilder builder() { + return new LangBuilder(ModConstants.MODID); + } + public static LangBuilder translate(String langKey, Object... args) { + return builder().translate(langKey, args); + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/MConfigs.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/MConfigs.java.jinja new file mode 100644 index 0000000..ac1739b --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/MConfigs.java.jinja @@ -0,0 +1,71 @@ +package com.oierbravo.{{MECHANICAL_ID}}.infrastructure.config; + +import com.simibubi.create.api.stress.BlockStressValues; +import net.createmod.catnip.config.ConfigBase; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.fml.config.ModConfig; +import net.neoforged.fml.event.config.ModConfigEvent; +import net.neoforged.neoforge.common.ModConfigSpec; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.EnumMap; +import java.util.Map; +import java.util.function.Supplier; + +@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD) +public class MConfigs { + private static final Map CONFIGS = new EnumMap<>(ModConfig.Type.class); + + private static ModConfigServer server; + private static ModConfigClient client; + + public static ModConfigServer server() { + return server; + } + public static ModConfigClient client() { return client; } + + public static ConfigBase byType(ModConfig.Type type) { + return CONFIGS.get(type); + } + private static T register(Supplier factory, ModConfig.Type side) { + Pair specPair = new ModConfigSpec.Builder().configure(builder -> { + T config = factory.get(); + config.registerAll(builder); + return config; + }); + + T config = specPair.getLeft(); + config.specification = specPair.getRight(); + CONFIGS.put(side, config); + return config; + } + public static void register(ModLoadingContext context, ModContainer container) { + server = register(ModConfigServer::new, ModConfig.Type.SERVER); + client = register(ModConfigClient::new, ModConfig.Type.CLIENT); + + for (Map.Entry pair : CONFIGS.entrySet()) + container.registerConfig(pair.getKey(), pair.getValue().specification); + + ModStress stress = server().stressValues; + BlockStressValues.IMPACTS.registerProvider(stress::getImpact); + } + + @SubscribeEvent + public static void onLoad(ModConfigEvent.Loading event) { + for (ConfigBase config : CONFIGS.values()) + if (config.specification == event.getConfig() + .getSpec()) + config.onLoad(); + } + + @SubscribeEvent + public static void onReload(ModConfigEvent.Reloading event) { + for (ConfigBase config : CONFIGS.values()) + if (config.specification == event.getConfig() + .getSpec()) + config.onReload(); + } +} \ No newline at end of file diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModConfigClient.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModConfigClient.java.jinja new file mode 100644 index 0000000..93d4563 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModConfigClient.java.jinja @@ -0,0 +1,12 @@ +package com.oierbravo.{{MECHANICAL_ID}}.infrastructure.config; + +import net.createmod.catnip.config.ConfigBase; + +public class ModConfigClient extends ConfigBase { + //public final ExampleConfigsClient example = nested(0, ExampleConfigsClient::new, "Example Configs"); + + @Override + public String getName() { + return "client"; + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModConfigServer.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModConfigServer.java.jinja new file mode 100644 index 0000000..603b142 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModConfigServer.java.jinja @@ -0,0 +1,14 @@ +package com.oierbravo.{{MECHANICAL_ID}}.infrastructure.config; + +import net.createmod.catnip.config.ConfigBase; + +public class ModConfigServer extends ConfigBase { + //public final ExampleConfigs example = nested(0, ExampleConfigs::new, "Example"); + + public final ModStress stressValues = nested(0, ModStress::new, "Stress values"); + + @Override + public String getName() { + return "server"; + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModStress.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModStress.java.jinja new file mode 100644 index 0000000..320da38 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/config/ModStress.java.jinja @@ -0,0 +1,98 @@ +package com.oierbravo.{{MECHANICAL_ID}}.infrastructure.config; + +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import com.tterrag.registrate.builders.BlockBuilder; +import com.tterrag.registrate.util.nullness.NonNullUnaryOperator; +import it.unimi.dsi.fastutil.objects.Object2DoubleMap; +import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap; +import net.createmod.catnip.config.ConfigBase; +import net.createmod.catnip.registry.RegisteredObjectsHelper; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.neoforged.neoforge.common.ModConfigSpec.Builder; +import net.neoforged.neoforge.common.ModConfigSpec.ConfigValue; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.DoubleSupplier; + +public class ModStress extends ConfigBase { + // bump this version to reset configured values. + private static final int VERSION = 1; + + // IDs need to be used since configs load before registration + + private static final Object2DoubleMap DEFAULT_IMPACTS = new Object2DoubleOpenHashMap<>(); + private static final Object2DoubleMap DEFAULT_CAPACITIES = new Object2DoubleOpenHashMap<>(); + + protected final Map> capacities = new HashMap<>(); + protected final Map> impacts = new HashMap<>(); + + @Override + public void registerAll(Builder builder) { + builder.comment(".", Comments.su, Comments.impact) + .push("impact"); + DEFAULT_IMPACTS.forEach((id, value) -> this.impacts.put(id, builder.define(id.getPath(), value))); + builder.pop(); + + builder.comment(".", Comments.su, Comments.capacity) + .push("capacity"); + DEFAULT_CAPACITIES.forEach((id, value) -> this.capacities.put(id, builder.define(id.getPath(), value))); + builder.pop(); + } + + @Override + public String getName() { + return "stressValues.v" + VERSION; + } + + @Nullable + public DoubleSupplier getImpact(Block block) { + ResourceLocation id = RegisteredObjectsHelper.getKeyOrThrow(block); + ConfigValue value = this.impacts.get(id); + return value == null ? null : value::get; + } + + @Nullable + public DoubleSupplier getCapacity(Block block) { + ResourceLocation id = RegisteredObjectsHelper.getKeyOrThrow(block); + ConfigValue value = this.capacities.get(id); + return value == null ? null : value::get; + } + + public static NonNullUnaryOperator> setNoImpact() { + return setImpact(0); + } + + public static NonNullUnaryOperator> setImpact(double value) { + return builder -> { + assertFromThisMod(builder); + ResourceLocation id = ModConstants.asResource(builder.getName()); + DEFAULT_IMPACTS.put(id, value); + return builder; + }; + } + + public static NonNullUnaryOperator> setCapacity(double value) { + return builder -> { + assertFromThisMod(builder); + ResourceLocation id = ModConstants.asResource(builder.getName()); + DEFAULT_CAPACITIES.put(id, value); + return builder; + }; + } + private static void assertFromThisMod(BlockBuilder builder) { + if (!builder.getOwner().getModid().equals(ModConstants.MODID)) { + throw new IllegalStateException("Non-Create blocks cannot be added to " + ModConstants.DISPLAY_NAME + "'s config."); + } + } + + private static class Comments { + static String su = "[in Stress Units]"; + static String impact = + "Configure the individual stress impact of mechanical blocks. Note that this cost is doubled for every speed increase it receives."; + static String capacity = "Configure how much stress a source can accommodate for."; + } + +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/data/ModDataGen.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/data/ModDataGen.java.jinja new file mode 100644 index 0000000..e1d0c2a --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/infrastructure/data/ModDataGen.java.jinja @@ -0,0 +1,23 @@ +package com.oierbravo.{{MECHANICAL_ID}}.infrastructure.data; + +import com.oierbravo.{{MECHANICAL_ID}}.{{MECHANICAL_MAIN_CLASS}}; +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import com.simibubi.create.Create; +import com.tterrag.registrate.providers.RegistrateDataProvider; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; +import net.neoforged.neoforge.data.event.GatherDataEvent; + +public class ModDataGen { + public static void gatherData(GatherDataEvent event) { + + DataGenerator generator = event.getGenerator(); + PackOutput output = generator.getPackOutput(); + + if (event.includeServer()) { + //generator.addProvider(true, new ExamplenRecipeGen(output, event.getLookupProvider())); + + } + event.getGenerator().addProvider(true, {{MECHANICAL_MAIN_CLASS}}.registrate().setDataProvider(new RegistrateDataProvider({{MECHANICAL_MAIN_CLASS}}.registrate(), ModConstants.MODID, event))); + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ponders/ModPonderPlugin.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ponders/ModPonderPlugin.java.jinja new file mode 100644 index 0000000..3464d59 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/ponders/ModPonderPlugin.java.jinja @@ -0,0 +1,33 @@ +package com.oierbravo.{{MECHANICAL_ID}}.ponders; + +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import net.createmod.ponder.api.registration.PonderPlugin; +import net.createmod.ponder.api.registration.PonderSceneRegistrationHelper; +import net.createmod.ponder.api.registration.PonderTagRegistrationHelper; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; + +public class ModPonderPlugin implements PonderPlugin { + + @Override + public @NotNull String getModId() { + return ModConstants.MODID; + } + + @Override + public void registerScenes(PonderSceneRegistrationHelper helper) { + //PonderSceneRegistrationHelper> HELPER = helper.withKeyFunction(RegistryEntry::getId); + + //HELPER.forComponents(ModRegistration.MECHANICAL_CHICKEN_BLOCK) + // .addStoryBoard("mechanical", MechanicalChickenScenes::mechanicalChicken); + + } + + @Override + public void registerTags(PonderTagRegistrationHelper helper) { + //PonderTagRegistrationHelper> TAG_HELPER = helper.withKeyFunction(RegistryEntry::getId); + //TAG_HELPER.addToTag(KINETIC_APPLIANCES).add(ModRegistration.MECHANICAL_BLOCK); + } + + +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModBlockEntities.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModBlockEntities.java.jinja new file mode 100644 index 0000000..9d4eb49 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModBlockEntities.java.jinja @@ -0,0 +1,16 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.oierbravo.{{MECHANICAL_ID}}.{{MECHANICAL_MAIN_CLASS}}; + +import com.tterrag.registrate.util.entry.BlockEntityEntry; +public class ModBlockEntities { + + /*public static final BlockEntityEntry EXAMPLE = CreateSifter.registrate() + .blockEntity("example", SifterBlockEntity::new) + .visual(() -> SifterVisual::new) + .validBlocks(ModBlocks.EXAMPLE) + .renderer(() -> SifterRenderer::new) + .register();*/ + + public static void register() {} +} \ No newline at end of file diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModBlocks.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModBlocks.java.jinja new file mode 100644 index 0000000..4532705 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModBlocks.java.jinja @@ -0,0 +1,49 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import com.oierbravo.{{MECHANICAL_ID}}.infrastucture.config.ModStress; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.AllTags; +import com.simibubi.create.foundation.data.AssetLookup; +import com.simibubi.create.foundation.data.BlockStateGen; +import com.simibubi.create.foundation.data.SharedProperties; +import com.tterrag.registrate.providers.RegistrateRecipeProvider; +import com.tterrag.registrate.util.entry.BlockEntry; +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.MapColor; + +import static com.oierbravo.{{MECHANICAL_ID}}.{{MECHANICAL_MAIN_CLASS}}.REGISTRATE; +import static com.simibubi.create.foundation.data.ModelGen.customItemModel; +import static com.simibubi.create.foundation.data.TagGen.pickaxeOnly; + +public class ModBlocks { + /*public static final BlockEntry SIFTER = REGISTRATE.block("example_block", ExampleBlock::new) + .initialProperties(SharedProperties::stone) + .properties(p -> p.mapColor(MapColor.METAL)) + .transform(pickaxeOnly()) + .blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p))) + .transform(ModStress.setImpact(4.0)) + .item() + .transform(customItemModel()) + .recipe((c, p) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, c.get()) + .define('W', ItemTags.PLANKS) + .define('A', AllBlocks.ANDESITE_CASING) + .define('C', AllBlocks.COGWHEEL) + .define('P', AllTags.commonItemTag("stones")) + .define('S', Items.STICK) + .pattern("WAW") + .pattern("SCS") + .pattern(" P ") + .unlockedBy("has_andesite_casing", RegistrateRecipeProvider.has(AllTags.AllItemTags.CASING.tag)) + .save(p, ModConstants.asResource("crafting/" + c.getName()))) + .register(); +*/ + + public static void register() {} +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModCreativeTabs.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModCreativeTabs.java.jinja new file mode 100644 index 0000000..ad0cc21 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModCreativeTabs.java.jinja @@ -0,0 +1,41 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.oierbravo.{{MECHANICAL_ID}}.ModLang; +import com.oierbravo.mechanicals.Mechanicals; +import com.oierbravo.mechanicals.utility.MechanicalLangIdGenerator; +import com.simibubi.create.AllCreativeModeTabs; +import com.simibubi.create.AllItems; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.item.TagDependentIngredientItem; +import com.tterrag.registrate.util.entry.ItemEntry; +import com.tterrag.registrate.util.entry.RegistryEntry; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +import java.util.List; + +import static com.oierbravo.{{MECHANICAL_ID}}.ModConstants.MODID; + +public class ModCreativeTabs { + + private static final DeferredRegister TAB_REGISTER = + DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID); + + + public static final DeferredHolder MAIN_TAB = TAB_REGISTER.register("main", + () -> CreativeModeTab.builder() + .title(ModLang.translate(MechanicalLangIdGenerator.creativeTabId("main")).component()) + .withTabsBefore(AllCreativeModeTabs.PALETTES_CREATIVE_TAB.getId()) + //.icon(ModBlocks.EXAMPLE::asStack) + .build()); + + public static void register(IEventBus modEventBus) { + TAB_REGISTER.register(modEventBus); + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModFluids.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModFluids.java.jinja new file mode 100644 index 0000000..e6fdf04 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModFluids.java.jinja @@ -0,0 +1,44 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.oierbravo.{{MECHANICAL_ID}}.{{MECHANICAL_MAIN_CLASS}}; +import com.oierbravo.mechanicals.register.fluid.MechanicalSolidRenderedPlaceableFluidType; +import com.simibubi.create.AllFluids; +import com.simibubi.create.AllTags; +import com.simibubi.create.foundation.data.CreateRegistrate; +import com.tterrag.registrate.builders.FluidBuilder; +import com.tterrag.registrate.util.entry.FluidEntry; +import net.createmod.catnip.theme.Color; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.material.FluidState; +import net.neoforged.neoforge.fluids.BaseFlowingFluid; +import net.neoforged.neoforge.fluids.FluidStack; +import org.joml.Vector3f; + +import java.util.function.Supplier; + +public class ModFluids { + public static final CreateRegistrate REGISTRATE = {{MECHANICAL_MAIN_CLASS}}.registrate(); + + /*public static final FluidEntry EXAMPLE_FLUID = + REGISTRATE.standardFluid("example_fluid", + MechanicalSolidRenderedPlaceableFluidType.create(0x88A000, + () -> 1f / 8f *0.5f)) + .lang("Example fluid") + .properties(b -> b.viscosity(2000) + .density(1400)) + .fluidProperties(p -> p.levelDecreasePerBlock(2) + .tickRate(25) + .slopeFindDistance(3) + .explosionResistance(100f)) + .tag(AllTags.commonFluidTag("example_fluid")) + .source(BaseFlowingFluid.Source::new) // TODO: remove when Registrate fixes FluidBuilder + .bucket() + .tag(AllTags.commonItemTag("buckets/example_fluid")) + .build() + .register(); + */ + public static void register() {} + +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModItems.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModItems.java.jinja new file mode 100644 index 0000000..c46763b --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModItems.java.jinja @@ -0,0 +1,45 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import com.simibubi.create.AllItems; +import com.simibubi.create.AllTags; +import com.simibubi.create.foundation.data.AssetLookup; +import com.simibubi.create.foundation.data.recipe.CompatMetals; +import com.simibubi.create.foundation.item.TagDependentIngredientItem; +import com.tterrag.registrate.providers.RegistrateRecipeProvider; +import com.tterrag.registrate.util.entry.ItemEntry; +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.data.recipes.ShapedRecipeBuilder; +import net.minecraft.data.recipes.ShapelessRecipeBuilder; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; + +import static com.oierbravo.{{MECHANICAL_ID}}.{{MECHANICAL_MAIN_CLASS}}.REGISTRATE; +import static com.tterrag.registrate.providers.RegistrateRecipeProvider.inventoryTrigger; + +public class ModItems { + + /*public static final ItemEntry STRING_MESH = + REGISTRATE.item("example_item", ExampleItem::new) + .model(AssetLookup.existingItemModel()) + .properties(properties -> properties.durability(8)) + .tag(AllTags.commonItemTag("meshes")) + .recipe((c, p) -> ShapedRecipeBuilder.shaped(RecipeCategory.MISC, c.get()) + .define('C', Items.STRING) + .define('S', Items.STICK) + .pattern("SSS") + .pattern("SCS") + .pattern("SSS") + .unlockedBy("has_string", RegistrateRecipeProvider.has(Items.STRING)) + .unlockedBy("has_stick", RegistrateRecipeProvider.has(Items.STICK)) + .save(p, ModConstants.asResource("crafting/" + c.getName()))) + .register(); + */ + + public static void register() {} + + +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModPartials.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModPartials.java.jinja new file mode 100644 index 0000000..bb86fdf --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModPartials.java.jinja @@ -0,0 +1,17 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import dev.engine_room.flywheel.lib.model.baked.PartialModel; + +public class ModPartials { + private static PartialModel block(String path) { + return PartialModel.of(ModConstants.asResource("block/" + path)); + } + private static PartialModel item(String path) { + return PartialModel.of(ModConstants.asResource("item/" + path)); + } + public static void init() { + // init static fields + } + +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModRecipes.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModRecipes.java.jinja new file mode 100644 index 0000000..af3e40e --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModRecipes.java.jinja @@ -0,0 +1,35 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.oierbravo.{{MECHANICAL_ID}}.ModConstants; +import com.simibubi.create.foundation.recipe.RecipeFinder; +import net.minecraft.client.Minecraft; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.*; +import net.minecraft.world.level.Level; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.registries.DeferredRegister; + +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.function.Supplier; + +import static com.oierbravo.{{MECHANICAL_ID}}.ModConstants.MODID; + +public class ModRecipes { + public static final DeferredRegister> SERIALIZERS = + DeferredRegister.create(Registries.RECIPE_SERIALIZER, MODID); + public static final DeferredRegister> RECIPE_TYPES = DeferredRegister.create(Registries.RECIPE_TYPE, MODID); + + public static void register(IEventBus eventBus) { + + SERIALIZERS.register(eventBus); + RECIPE_TYPES.register(eventBus); + + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModShapes.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModShapes.java.jinja new file mode 100644 index 0000000..020ec57 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/registrate/ModShapes.java.jinja @@ -0,0 +1,19 @@ +package com.oierbravo.{{MECHANICAL_ID}}.registrate; + +import com.simibubi.create.AllShapes; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class ModShapes { + + private static AllShapes.Builder shape(VoxelShape shape) { + return new AllShapes.Builder(shape); + } + private static AllShapes.Builder shape(double x1, double y1, double z1, double x2, double y2, double z2) { + return shape(cuboid(x1, y1, z1, x2, y2, z2)); + } + + private static VoxelShape cuboid(double x1, double y1, double z1, double x2, double y2, double z2) { + return Block.box(x1, y1, z1, x2, y2, z2); + } +} diff --git a/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/{{MECHANICAL_MAIN_CLASS}}.java.jinja b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/{{MECHANICAL_MAIN_CLASS}}.java.jinja new file mode 100644 index 0000000..7a7efc8 --- /dev/null +++ b/src/main/java/com/oierbravo/{{MECHANICAL_ID}}/{{MECHANICAL_MAIN_CLASS}}.java.jinja @@ -0,0 +1,81 @@ +package com.oierbravo.{{MECHANICAL_ID}}; + +import com.mojang.logging.LogUtils; +import com.oierbravo.{{MECHANICAL_ID}}.infrastructure.data.ModDataGen; +import com.oierbravo.{{MECHANICAL_ID}}.infrastucture.config.MConfigs; +import com.oierbravo.{{MECHANICAL_ID}}.ponders.ModPonderPlugin; +import com.oierbravo.{{MECHANICAL_ID}}.registrate.*; +import com.oierbravo.mechanicals.utility.RegistrateLangBuilder; +import com.simibubi.create.foundation.data.CreateRegistrate; +import com.simibubi.create.foundation.item.ItemDescription; +import com.simibubi.create.foundation.item.KineticStats; +import com.simibubi.create.foundation.item.TooltipModifier; +import net.createmod.catnip.lang.FontHelper; +import net.createmod.ponder.foundation.PonderIndex; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import org.slf4j.Logger; + +import static com.oierbravo.{{MECHANICAL_ID}}.ModConstants.MODID; + +@Mod(MODID) +public class {{MECHANICAL_MAIN_CLASS}} +{ + + public static final CreateRegistrate REGISTRATE = CreateRegistrate.create(MODID).defaultCreativeTab(ModCreativeTabs.MAIN_TAB.getKey()); + static { + REGISTRATE.setTooltipModifierFactory(item -> + new ItemDescription.Modifier(item, FontHelper.Palette.STANDARD_CREATE) + .andThen(TooltipModifier.mapNull(KineticStats.create(item))) + ); + } + public static final Logger LOGGER = LogUtils.getLogger(); + + public {{MECHANICAL_MAIN_CLASS}}(IEventBus modEventBus, ModContainer modContainer) + { + ModLoadingContext modLoadingContext = ModLoadingContext.get(); + + REGISTRATE.registerEventListeners(modEventBus); + + ModCreativeTabs.register(modEventBus); + + ModBlocks.register(); + ModItems.register(); + ModBlockEntities.register(); + + ModFluids.register(); + + MConfigs.register(modLoadingContext,modContainer); + + + modEventBus.addListener(this::doClientStuff); + modEventBus.addListener(this::registerCapabilities); + + modEventBus.addListener(ModDataGen::gatherData); + + ModFluids.register(); + generateLangEntries(); + } + private void generateLangEntries(){ + new RegistrateLangBuilder(MODID, registrate()) + .addRaw("config.jade.plugin_{{MECHANICAL_ID}}.{{MECHANICAL_ID}}_data", "Example") + .add("itemGroup.{{MECHANICAL_ID}}:main", "Example"); + + } + @net.neoforged.bus.api.SubscribeEvent + public void registerCapabilities(net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent event) { + + } + private void doClientStuff(final FMLClientSetupEvent event) { + + ModPartials.init(); + PonderIndex.addPlugin(new ModPonderPlugin()); + + } + public static CreateRegistrate registrate() { + return REGISTRATE; + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..0e88a40 --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1 @@ +public-f net.minecraft.data.recipes.RecipeProvider getName()Ljava/lang/String; \ No newline at end of file diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..430dc16 --- /dev/null +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,33 @@ +modLoader="javafml" #mandatory +loaderVersion = "[0,)" +license="LGPL3" +[[mods]] #mandatory +modId="${mod_id}" #mandatory +version="${file.jarVersion}" #mandatory +displayName="${mod_name}" #mandatory +logoFile="logo.png" #optional +credits="Thanks to the Creators of Create" #optional +authors="oierbravo" #optional +description=''' +Create addon +''' +[[dependencies."${mod_id}"]] + modId="neoforge" + type="required" + versionRange="${neo_version_range}" + ordering="NONE" + side="BOTH" + +[[dependencies."${mod_id}"]] + modId="minecraft" + type="required" + versionRange="${minecraft_version_range}" + ordering="NONE" + side="BOTH" + +[[dependencies."${mod_id}"]] + modId = "create" + mandatory = true + versionRange="[6.0.4,6.1.0)" + ordering = "AFTER" + side = "BOTH" diff --git a/src/main/resources/assets/atlases/blocks.json b/src/main/resources/assets/atlases/blocks.json new file mode 100644 index 0000000..3cbc73b --- /dev/null +++ b/src/main/resources/assets/atlases/blocks.json @@ -0,0 +1,9 @@ +{ + "sources": [ + { + "type": "directory", + "source": "fluid", + "prefix": "fluid/" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/atlases/blocks.json b/src/main/resources/assets/minecraft/atlases/blocks.json new file mode 100644 index 0000000..3cbc73b --- /dev/null +++ b/src/main/resources/assets/minecraft/atlases/blocks.json @@ -0,0 +1,9 @@ +{ + "sources": [ + { + "type": "directory", + "source": "fluid", + "prefix": "fluid/" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/{{MECHANICAL_ID}}/lang/.gitkeep b/src/main/resources/assets/{{MECHANICAL_ID}}/lang/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/logo.png b/src/main/resources/logo.png new file mode 100644 index 0000000..0cabd4f Binary files /dev/null and b/src/main/resources/logo.png differ diff --git a/src/main/resources/{{MECHANICAL_ID}}.mixins.json.jinja b/src/main/resources/{{MECHANICAL_ID}}.mixins.json.jinja new file mode 100644 index 0000000..db36454 --- /dev/null +++ b/src/main/resources/{{MECHANICAL_ID}}.mixins.json.jinja @@ -0,0 +1,13 @@ +{ + "required": true, + "priority": 1100, + "package": "com.oierbravo.{{MECHANICAL_ID}}.mixin", + "compatibilityLevel": "JAVA_16", + "refmap": "{{MECHANICAL_ID}}.refmap.json", + "mixins": [], + "client": [], + "injectors": { + "defaultRequire": 1 + }, + "minVersion": "0.8" +} \ No newline at end of file