diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..525ecc7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,43 @@ +name: Bug Report +description: File a bug report +labels: ["bug"] +assignees: [PssbleTrngle] + +body: + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also tell us, what did you expect to happen? + placeholder: Tell us what you see! + validations: + required: true + + - type: input + id: version-version + attributes: + label: Mod Version + validations: + required: true + + - type: dropdown + id: minecraft-version + attributes: + label: Minecraft Version + multiple: false + options: + - 1.18 + + - type: input + id: loader-version + attributes: + label: Forge Version + validations: + required: true + + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..3ce9947 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,21 @@ +name: Feature Request +description: Suggest a feature +labels: ["enhancement", "feature", "feature-request"] +assignees: [PssbleTrngle] + +body: + - type: textarea + id: idea + attributes: + label: Describe the feature you have in mind. + placeholder: So I was think about... + validations: + required: true + + - type: textarea + id: problem-solving + attributes: + label: Does this solve a particular problem? + placeholder: Yes, it balances... + validations: + required: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d0fcd52 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: Release +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: temurin + + - uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle + + - run: chmod +x ./gradlew + + - name: Update mod version + uses: christian-draeger/write-properties@1.0.1 + with: + path: "gradle.properties" + property: "mod_version" + value: ${{ github.event.release.tag_name }} + + - name: build + run: ./gradlew build + + - name: Upload to github releases + if: ${{ github.event_name == 'release' }} + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: build/libs/thermomix-${{ github.event.release.tag_name }}.jar + asset_name: thermomix-${{ github.event.release.tag_name }}.jar + asset_content_type: application/java-archive + + - name: publish to github packages + run: ./gradlew publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: upload to curseforge + continue-on-error: true + run: ./gradlew curseforge + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + CHANGELOG: ${{ github.event.release.body }} + + - name: upload to modrinth + continue-on-error: true + run: ./gradlew modrinth + env: + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + CHANGELOG: ${{ github.event.release.body }} diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml new file mode 100644 index 0000000..5f543ea --- /dev/null +++ b/.github/workflows/sonar.yml @@ -0,0 +1,42 @@ +name: Analyze +on: + push: + branches: [ 1.18.x ] + +jobs: + build: + name: Analyze + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + + - run: chmod +x ./gradlew + + - name: Cache SonarQube packages + uses: actions/cache@v2 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + run: ./gradlew build sonarqube diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..432c68e --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# eclipse +bin +*.launch +.settings +.metadata +.classpath +.project + +# idea +out +*.ipr +*.iws +*.iml +.idea + +# gradle +build +.gradle + +# other +eclipse +run + +# Files from Forge MDK +forge*changelog.txt \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..604e032 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,35 @@ +Copyright (c) 2020 possible_triangle. All Rights Reserved. + +Permissions are hereby granted below to any person having a copy of +this software and/or its associated files: + +Usage - You may use this software for private and public use. You may use this software as a library +or integrate it with your code with the predicate being it must be downloaded from our sources and a soft or hard dependency. +Copying - You may copy this software for private use or to contribute to this software. +Modification - You may modify this software for private use or to contribute to this software. +Publishing - You may not publish copies of this software. +Distributing - You may not distribute this software. +Sublicensing - You may not sublicense this software. +Selling - You may not sell this software. + +Modpack Clarification: +Permission is granted for Modpacks to include this software as long +as the copy of this software in the pack is an unmodified public copy +from our public sources and is marked as included in the Modpack. + +Definition of 'Our Sources' in this license: +Our Sources in this license means a copy +of this software or its associated files that come +directly from the owners of this software, an example +are the files uploaded by us on our Curse Page. + +The above copyright notice and these permission notices shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..dbb16aa --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Thermomix diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..82452be --- /dev/null +++ b/build.gradle @@ -0,0 +1,234 @@ +buildscript { + repositories { + maven { url = 'https://maven.minecraftforge.net' } + mavenCentral() + maven { url = 'https://repo.spongepowered.org/repository/maven-public' } + } + dependencies { + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + // Make sure this version matches the one included in Kotlin for Forge + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10' + // OPTIONAL Gradle plugin for Kotlin Serialization + classpath 'org.jetbrains.kotlin:kotlin-serialization:1.6.10' + classpath "org.spongepowered:mixingradle:0.7-SNAPSHOT" + } +} + +plugins { + id "org.sonarqube" version "3.4.0.2513" + id 'maven-publish' + id 'com.matthewprenger.cursegradle' version '1.4.0' + id "com.modrinth.minotaur" version "2.+" +} + +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'kotlin' +apply plugin: 'kotlinx-serialization' + +apply from: 'https://raw.githubusercontent.com/thedarkcolour/KotlinForForge/site/thedarkcolour/kotlinforforge/gradle/kff-3.1.0.gradle' + +apply plugin: 'org.spongepowered.mixin' + +mixin { + add sourceSets.main, "${project.mod_id}.refmap.json" +} + +version = project.mod_version +group = 'com.possible_triangle' +archivesBaseName = project.mod_id + +java.toolchain.languageVersion = JavaLanguageVersion.of(17) + +minecraft { + // Change to your preferred mappings + mappings channel: project.mappings_channel, version: project.mc_version + // Add your AccessTransformer + accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + + runs { + client { + workingDirectory project.file('run') + + property 'forge.logging.console.level', 'debug' + + arg '-mixin.config=create.mixins.json' + arg '-mixin.config=flywheel.mixins.json' + arg "-mixin.config=${project.mod_id}.mixins.json" + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + + mods { + thermomix { + source sourceSets.main + } + } + } + + server { + workingDirectory project.file('run/server') + + property 'forge.logging.console.level', 'debug' + + arg '-mixin.config=create.mixins.json' + arg '-mixin.config=flywheel.mixins.json' + arg "-mixin.config=${project.mod_id}.mixins.json" + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + + mods { + thermomix { + source sourceSets.main + } + } + } + + data { + workingDirectory project.file('run') + + property 'forge.logging.console.level', 'debug' + + arg '-mixin.config=create.mixins.json' + arg '-mixin.config=flywheel.mixins.json' + arg "-mixin.config=${project.mod_id}.mixins.json" + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" + + args '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources') + + mods { + thermomix { + source sourceSets.main + } + } + } + } +} + +// Include assets and data from data generators +sourceSets.main.resources { srcDirs 'src/generated/resources/' } + +repositories { + maven { + name = "Progwml6 maven" + url = "https://dvs1.progwml6.com/files/maven/" + } + maven { + name = "ModMaven" + url = "https://modmaven.k-4u.nl" + } + maven { + // Location of the maven for mixed mappings, Registrate, and Flywheel + name 'tterrag maven' + url 'https://maven.tterrag.com' + } + maven { + url 'https://www.cursemaven.com' + content { + includeGroup "curse.maven" + } + } + maven { url = "https://maven.theillusivec4.top/" } +} + +dependencies { + // Use the latest version of Minecraft Forge + minecraft "net.minecraftforge:forge:${project.mc_version}-${project.forge_version}" + + compileOnly fg.deobf("mezz.jei:jei-${project.mc_version}:${project.jei_version}:api") + runtimeOnly fg.deobf("mezz.jei:jei-${project.mc_version}:${project.jei_version}") + + implementation fg.deobf("curse.maven:create-328085:${project.create_version}") + implementation fg.deobf("curse.maven:flywheel-486392:${project.flywheel_version}") + + implementation fg.deobf("curse.maven:farmers-delight-398521:${project.farmers_delight_version}") + + annotationProcessor "org.spongepowered:mixin:0.8.5:processor" +} + +compileKotlin { + kotlinOptions.jvmTarget = "17" +} + +jar { + manifest { + attributes([ + 'Specification-Title' : project.mod_id, + 'Specification-Vendor' : "examplemodsareus", + 'Specification-Version' : "1", + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.mod_version, + 'Implementation-Vendor' : "examplemodsareus", + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs" : "${project.mod_id}.mixins.json", + ]) + } +} + +def ENV = System.getenv() + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/${project.repository}") + version = version + credentials { + username = ENV.GITHUB_ACTOR + password = ENV.GITHUB_TOKEN + } + } + } + publications { + gpr(MavenPublication) { + groupId = group + artifactId = project.mod_id + version = project.mod_version + from(components.java) + } + } +} + +if (ENV.CURSEFORGE_TOKEN) curseforge { + apiKey = ENV.CURSEFORGE_TOKEN + project { + id = project.curseforge_project_id + addGameVersion project.mc_version + addGameVersion 'Forge' + changelog = ENV.CHANGELOG + changelogType = 'markdown' + releaseType = project.release_type + mainArtifact(jar) { + displayName = "Version ${project.mod_version}" + } + relations { + requiredDependency 'create' + requiredDependency 'kotlin-for-forge' + } + } +} + +if (ENV.MODRINTH_TOKEN) modrinth { + token = ENV.MODRINTH_TOKEN + projectId = project.modrinth_project_id + versionNumber = version + versionName = "Version ${project.mod_version}" + changelog = ENV.CHANGELOG + gameVersions = [project.mc_version] + loaders = ["forge"] + versionType = project.release_type + uploadFile = jar + syncBodyFrom = project.file("README.md").text + dependencies { + required.project "ordsPcFz" + required.project "LNytGWDc" + } +} + +tasks.modrinth.dependsOn(tasks.modrinthSyncBody) + +sonarqube { + properties { + property 'sonar.projectVersion', project.mod_version + property "sonar.projectKey", project.mod_id + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..d9f6842 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,20 @@ +kotlin.code.style=official +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false + +mc_version=1.18.2 +mappings_channel=official +forge_version=40.1.60 + +mod_id=thermomix +mod_version=0.0.0-dev +release_type=release + +jei_version=9.5.0.128 +flywheel_version=3871082 +create_version=3871091 +farmers_delight_version=3834150 + +repository=pssbletrngle/thermomix +modrinth_project_id= +curseforge_project_id= \ 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..7454180 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..d2880ba --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..c53aefa --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/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/master/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 + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# 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*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + 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 \ + "$@" + +# 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..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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/src/main/java/com/possible_triangle/thermomix/ThermomixMod.java b/src/main/java/com/possible_triangle/thermomix/ThermomixMod.java new file mode 100644 index 0000000..f30b823 --- /dev/null +++ b/src/main/java/com/possible_triangle/thermomix/ThermomixMod.java @@ -0,0 +1,16 @@ +package com.possible_triangle.thermomix; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + +@Mod(ThermomixMod.MOD_ID) +public class ThermomixMod { + + public static final String MOD_ID = "thermomix"; + + public ThermomixMod() { + var eventBus = FMLJavaModLoadingContext.get().getModEventBus(); + Content.INSTANCE.register(eventBus); + } + +} \ No newline at end of file diff --git a/src/main/java/com/possible_triangle/thermomix/mixins/.gitkeep b/src/main/java/com/possible_triangle/thermomix/mixins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/kotlin/com/possible_triangle/thermomix/Content.kt b/src/main/kotlin/com/possible_triangle/thermomix/Content.kt new file mode 100644 index 0000000..8aef352 --- /dev/null +++ b/src/main/kotlin/com/possible_triangle/thermomix/Content.kt @@ -0,0 +1,60 @@ +package com.possible_triangle.thermomix + +import com.possible_triangle.thermomix.ThermomixMod.MOD_ID +import com.possible_triangle.thermomix.block.ThermomixBlock +import com.possible_triangle.thermomix.block.tile.ThermomixTile +import com.possible_triangle.thermomix.config.Configs +import com.simibubi.create.AllTags +import com.simibubi.create.content.AllSections +import com.simibubi.create.content.CreateItemGroup +import com.simibubi.create.content.contraptions.components.mixer.MixerInstance +import com.simibubi.create.foundation.block.BlockStressDefaults +import com.simibubi.create.foundation.data.AssetLookup +import com.simibubi.create.foundation.data.CreateRegistrate +import com.simibubi.create.foundation.data.SharedProperties +import com.simibubi.create.repack.registrate.util.entry.BlockEntityEntry +import net.minecraft.client.renderer.RenderType +import net.minecraft.core.Registry +import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.TagKey +import net.minecraft.world.level.block.state.BlockBehaviour +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.fml.config.ModConfig +import thedarkcolour.kotlinforforge.forge.LOADING_CONTEXT +import java.util.function.BiFunction +import java.util.function.Supplier + +object Content { + + val REGISTRATE = CreateRegistrate.lazy(MOD_ID).get() + .creativeModeTab { CreateItemGroup.TAB_TOOLS } + .startSection(AllSections.LOGISTICS) + + val KNIVES = TagKey.create(Registry.ITEM_REGISTRY, ResourceLocation("farmersdelight")) + + val THERMOMIX_BLOCK = REGISTRATE + .block("thermomix", ::ThermomixBlock) + .initialProperties(SharedProperties::stone) + .properties(BlockBehaviour.Properties::noOcclusion) + .transform(AllTags.axeOrPickaxe()) + .blockstate { c, p -> + p.simpleBlock(c.entry, AssetLookup.partialBaseModel(c, p)); + } + .addLayer { Supplier { RenderType.cutoutMipped() } } + .transform(BlockStressDefaults.setImpact(4.0)) + //.item(AssemblyOperatorBlockItem::new) + //.transform { NonNullFunction { ModelGen.customItemModel() } } + .register() + + val THERMOMIX_TILE = REGISTRATE + .tileEntity("thermomix", ::ThermomixTile) + .instance { BiFunction { manager, tile -> MixerInstance(manager, tile) } } + .validBlock(THERMOMIX_BLOCK) + .register() + + fun register(modBus: IEventBus) { + LOADING_CONTEXT.registerConfig(ModConfig.Type.COMMON, Configs.SERVER_SPEC) + LOADING_CONTEXT.registerConfig(ModConfig.Type.CLIENT, Configs.CLIENT_SPEC) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/thermomix/block/ThermomixBlock.kt b/src/main/kotlin/com/possible_triangle/thermomix/block/ThermomixBlock.kt new file mode 100644 index 0000000..f9bee83 --- /dev/null +++ b/src/main/kotlin/com/possible_triangle/thermomix/block/ThermomixBlock.kt @@ -0,0 +1,10 @@ +package com.possible_triangle.thermomix.block + +import com.possible_triangle.thermomix.Content +import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerBlock + +class ThermomixBlock(properties: Properties) : MechanicalMixerBlock(properties) { + + override fun getTileEntityType() = Content.THERMOMIX_TILE.get() + +} \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/thermomix/block/tile/ThermomixTile.kt b/src/main/kotlin/com/possible_triangle/thermomix/block/tile/ThermomixTile.kt new file mode 100644 index 0000000..5e6a4e3 --- /dev/null +++ b/src/main/kotlin/com/possible_triangle/thermomix/block/tile/ThermomixTile.kt @@ -0,0 +1,94 @@ +package com.possible_triangle.thermomix.block.tile + +import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntity +import net.minecraft.core.BlockPos +import net.minecraft.world.Container +import net.minecraft.world.item.crafting.Recipe +import net.minecraft.world.level.block.entity.BlockEntityType +import net.minecraft.world.level.block.state.BlockState +import net.minecraftforge.common.crafting.IShapedRecipe + +class ThermomixTile(type: BlockEntityType<*>, pos: BlockPos, state: BlockState) : + MechanicalMixerTileEntity(type, pos, state) { + + override fun matchStaticFilters(recipe: Recipe): Boolean { + return recipe is IShapedRecipe + } + + /* + override fun tick() { + super.tick() + if (runningTicks >= 40) { + running = false + runningTicks = 0 + basinChecker.scheduleUpdate() + } else { + if (running) runningLogic() + } + } + + private fun runningLogic() { + val world = level ?: return + val speed = abs(getSpeed()) + + if (runningTicks != 20) { + ++runningTicks + return + } + + if (world.isClientSide) this.particles() + + if (!world.isClientSide || this.isVirtual) { + if (this.processingTicks < 0) { + val recipeSpeed = 1.0F + + this.processingTicks = + Mth.clamp(Mth.log2((512.0F / speed).toInt()) * Mth.ceil(recipeSpeed * 15.0F) + 1, 1, 512) + basin.ifPresent { basin -> + val tanks = basin.tanks + val hasFluid = listOf(tanks.first, tanks.second).any { !it.isEmpty } + if (hasFluid) { + world.playSound( + null, + blockPos, + SoundEvents.BUBBLE_COLUMN_WHIRLPOOL_AMBIENT, + SoundSource.BLOCKS, + 0.75f, + if (speed < 65.0f) 0.75f else 1.5f + ) + } + } + } else { + --this.processingTicks + if (this.processingTicks == 0) { + ++runningTicks + this.processingTicks = -1 + applyBasinRecipe() + sendData() + } + } + } + } + + private fun particles() {} + + override fun read(compound: CompoundTag, clientPacket: Boolean) { + super.read(compound, clientPacket) + running = compound.getBoolean("Running") + runningTicks = compound.getInt("Ticks") + //if (clientPacket && hasLevel()) { + // this.basin.ifPresent { + // it.setAreFluidsMoving( + // running && this.runningTicks <= 20 + // ) + // } + //} + } + + override fun write(compound: CompoundTag, clientPacket: Boolean) { + compound.putBoolean("Running", running) + compound.putInt("Ticks", runningTicks) + super.write(compound, clientPacket) + } + */ +} \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/thermomix/config/ClientConfig.kt b/src/main/kotlin/com/possible_triangle/thermomix/config/ClientConfig.kt new file mode 100644 index 0000000..b7b48ee --- /dev/null +++ b/src/main/kotlin/com/possible_triangle/thermomix/config/ClientConfig.kt @@ -0,0 +1,7 @@ +package com.possible_triangle.thermomix.config + +import net.minecraftforge.common.ForgeConfigSpec + +class ClientConfig(builder: ForgeConfigSpec.Builder) { + +} \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/thermomix/config/Configs.kt b/src/main/kotlin/com/possible_triangle/thermomix/config/Configs.kt new file mode 100644 index 0000000..6f7afc0 --- /dev/null +++ b/src/main/kotlin/com/possible_triangle/thermomix/config/Configs.kt @@ -0,0 +1,29 @@ +package com.possible_triangle.thermomix.config + +import net.minecraftforge.common.ForgeConfigSpec + +object Configs { + + var SERVER_SPEC: ForgeConfigSpec + private set + var SERVER: ServerConfig + private set + + var CLIENT_SPEC: ForgeConfigSpec + private set + var CLIENT: ClientConfig + private set + + init { + with(ForgeConfigSpec.Builder().configure { ServerConfig(it) }) { + SERVER = left + SERVER_SPEC = right + } + + with(ForgeConfigSpec.Builder().configure { ClientConfig(it) }) { + CLIENT = left + CLIENT_SPEC = right + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/thermomix/config/ServerConfig.kt b/src/main/kotlin/com/possible_triangle/thermomix/config/ServerConfig.kt new file mode 100644 index 0000000..f4aeff4 --- /dev/null +++ b/src/main/kotlin/com/possible_triangle/thermomix/config/ServerConfig.kt @@ -0,0 +1,7 @@ +package com.possible_triangle.thermomix.config + +import net.minecraftforge.common.ForgeConfigSpec + +class ServerConfig(builder: ForgeConfigSpec.Builder) { + +} \ No newline at end of file diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..f49277f --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,2 @@ +public net.minecraft.server.network.ServerGamePacketListenerImpl f_9737_ # aboveGroundTickCount +public net.minecraft.client.renderer.entity.EntityRendererManager field_178637_m # playerRenderer \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..155c562 --- /dev/null +++ b/src/main/resources/META-INF/mods.toml @@ -0,0 +1,31 @@ +modLoader = "javafml" +loaderVersion = "[40,)" +license = 'LGPL' + +[[mods]] +modId = "thermomix" +version = "${file.jarVersion}" +displayName = "Thermomix" +authors = "possible_triangle" +description = '''Making automation for Farmers Delight more sensible''' + +[[dependencies.thermomix]] +modId = "forge" +mandatory = true +versionRange = "[36,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.thermomix]] +modId = "minecraft" +mandatory = true +versionRange = "[1.16.5,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.thermomix]] +modId = "create" +mandatory = true +versionRange = "[0.5.0a,)" +ordering = "NONE" +side = "BOTH" \ No newline at end of file diff --git a/src/main/resources/assets/thermomix/lang/en_us.json b/src/main/resources/assets/thermomix/lang/en_us.json new file mode 100644 index 0000000..2c07161 --- /dev/null +++ b/src/main/resources/assets/thermomix/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "block.thermomix.thermomix": "Thermomix" +} diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..ecd5d8f --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "ExampleMod resources", + "pack_format": 6 + } +} diff --git a/src/main/resources/thermomix.mixins.json b/src/main/resources/thermomix.mixins.json new file mode 100644 index 0000000..e704b9b --- /dev/null +++ b/src/main/resources/thermomix.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "com.possible_triangle.thermomix.mixins", + "compatibilityLevel": "JAVA_8", + "minVersion": "0.8", + "refmap": "thermomix.refmap.json", + "mixins": [], + "injectors": { + "defaultRequire": 1 + } +}