diff --git a/.github/scripts/test-no-crash-reports.sh b/.github/scripts/test-no-crash-reports.sh new file mode 100644 index 0000000..c67e342 --- /dev/null +++ b/.github/scripts/test-no-crash-reports.sh @@ -0,0 +1,9 @@ +directory="run/crash-reports" +if [ -d $directory ]; then + echo "Crash reports detected:" + cat $directory/* + exit 1 +else + echo "No crash reports detected" + exit 0 +fi diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..6c9b3cb --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,45 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build and test + +on: + pull_request: + branches: [ master, main ] + push: + branches: [ master, main ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Run server for 1 minute + run: | + mkdir run + echo "eula=true" > run/eula.txt + timeout 10 ./gradlew runServer || true + + - name: Test no crashes happend + run: | + chmod +x .github/scripts/test-no-crash-reports.sh + .github/scripts/test-no-crash-reports.sh diff --git a/.github/workflows/release-latest.yml b/.github/workflows/release-latest.yml new file mode 100644 index 0000000..5ecccc0 --- /dev/null +++ b/.github/workflows/release-latest.yml @@ -0,0 +1,44 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Release latest build + +on: + push: + branches: [ master, main ] + +jobs: + build-and-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Update latest tag + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "latest" + prerelease: false + title: "Latest build" + files: build/libs/*.jar diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml new file mode 100644 index 0000000..25c354b --- /dev/null +++ b/.github/workflows/release-tags.yml @@ -0,0 +1,45 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Release tagged build + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Release under current tag + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "${{ env.RELEASE_VERSION }}" + prerelease: false + title: "${{ env.RELEASE_VERSION }}" + files: build/libs/*.jar diff --git a/.gitignore b/.gitignore index 4f76b3a..558ad12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,28 @@ -/download -/eclipseBin - -## gradle -/.gradle -/build - -## ForgeGradle -/run - -## eclipse -/eclipse -/.settings -/.metadata -/.classpath -/.project -/bin - -## intellij -/out -/.idea -/*.iml -/*.ipr -/*.iws -/atlassian-ide-plugin.xml - -## gedit -*~ - -## translation reports -resources/assets/enderio/lang/*.lang.txt \ No newline at end of file +.gradle +.settings +/.idea/ +/run/ +/build/ +/eclipse/ +.classpath +.project +/bin/ +/config/ +/crash-reports/ +/logs/ +options.txt +/saves/ +usernamecache.json +banned-ips.json +banned-players.json +eula.txt +ops.json +server.properties +servers.dat +usercache.json +whitelist.json +/out/ +*.iml +*.ipr +*.iws +src/main/resources/mixins.*.json diff --git a/build.gradle b/build.gradle index f76e660..e878eee 100644 --- a/build.gradle +++ b/build.gradle @@ -1,176 +1,521 @@ +//version: 7d8e9fd40492c7862532bc771cf8ff3460bf64d5 +/* +DO NOT CHANGE THIS FILE! + +Also, you may replace this file at any time if there is an update available. +Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates. + */ + + +import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +import java.util.concurrent.TimeUnit + buildscript { repositories { - mavenCentral() - maven { url = "http://files.minecraftforge.net/maven" } - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { + name = "forge" + url = "https://maven.minecraftforge.net" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + maven { + name = "Scala CI dependencies" + url = "https://repo1.maven.org/maven2/" + } + maven { + name = "jitpack" + url = "https://jitpack.io" + } } - dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } + dependencies { + classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4' + } +} + +plugins { + id 'idea' + id 'scala' + id("org.ajoberstar.grgit") version("3.1.1") + id("com.github.johnrengelman.shadow") version("4.0.4") + id("com.palantir.git-version") version("0.12.3") } apply plugin: 'forge' -apply plugin: 'maven-publish' -apply plugin: 'curseforge' -ext.buildnumber = 0 -if (System.getenv('BUILD_NUMBER') != null) - project.buildnumber = System.getenv('BUILD_NUMBER') -else - logger.lifecycle "No build number detected, setting to 0" +def projectJavaVersion = JavaLanguageVersion.of(8) -group = "com.enderio.core" -archivesBaseName = "EnderCore" -version = "${minecraft_version}-${mod_version}.${buildnumber}" - -if (project.hasProperty('mod_appendix')) - version += "_${project.mod_appendix}" - -minecraft { - version = "${minecraft_version}-${forge_version}-${minecraft_version}" - runDir = 'run' - - replace "@VERSION@", project.version - replaceIn "EnderCore.java" +java { + toolchain { + languageVersion.set(projectJavaVersion) + } } +idea { + module { + inheritOutputDirs = true + downloadJavadoc = true + downloadSources = true + } +} + +checkPropertyExists("modName") +checkPropertyExists("modId") +checkPropertyExists("modGroup") +checkPropertyExists("autoUpdateBuildScript") +checkPropertyExists("minecraftVersion") +checkPropertyExists("forgeVersion") +checkPropertyExists("replaceGradleTokenInFile") +checkPropertyExists("gradleTokenModId") +checkPropertyExists("gradleTokenModName") +checkPropertyExists("gradleTokenVersion") +checkPropertyExists("gradleTokenGroupName") +checkPropertyExists("apiPackage") +checkPropertyExists("accessTransformersFile") +checkPropertyExists("usesMixins") +checkPropertyExists("mixinPlugin") +checkPropertyExists("mixinsPackage") +checkPropertyExists("coreModClass") +checkPropertyExists("containsMixinsAndOrCoreModOnly") +checkPropertyExists("usesShadowedDependencies") +checkPropertyExists("developmentEnvironmentUserName") + +def checkPropertyExists(String propertyName) { + if (project.hasProperty(propertyName) == false) { + throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties") + } +} + + +String javaSourceDir = "src/main/java/" +String scalaSourceDir = "src/main/scala/" + +String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") +String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") +if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) { + throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala) +} + +if(apiPackage) { + targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) { + throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala) + } +} + +if(accessTransformersFile) { + String targetFile = "src/main/resources/META-INF/" + accessTransformersFile + if(new File(targetFile).exists() == false) { + throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) + } +} + +if(usesMixins.toBoolean()) { + if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) { + throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!") + } + + targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") + targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") + if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) { + throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala) + } + + String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" + String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala" + String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" + if((new File(targetFileJava).exists() || new File(targetFileScala).exists() || new File(targetFileScalaJava).exists()) == false) { + throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava) + } +} + +if(coreModClass) { + String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" + String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala" + String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" + if((new File(targetFileJava).exists() || new File(targetFileScala).exists() || new File(targetFileScalaJava).exists()) == false) { + throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava) + } +} + +configurations.all { + resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) + + // Make sure GregTech build won't time out + System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String) + System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String) +} + +// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version +'git config core.fileMode false'.execute() +// Pulls version from git tag +version = minecraftVersion + "-" + gitVersion() +group = modGroup +archivesBaseName = modId + +minecraft { + version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion + runDir = "run" + + if (replaceGradleTokenInFile) { + replaceIn replaceGradleTokenInFile + if(gradleTokenModId) { + replace gradleTokenModId, modId + } + if(gradleTokenModName) { + replace gradleTokenModName, modName + } + if(gradleTokenVersion) { + replace gradleTokenVersion, versionDetails().lastTag + } + if(gradleTokenGroupName) { + replace gradleTokenGroupName, modGroup + } + } +} + +if(file("addon.gradle").exists()) { + apply from: "addon.gradle" +} + +apply from: 'repositories.gradle' + configurations { - compile.extendsFrom exportedCompile + implementation.extendsFrom(shadowImplementation) } repositories { - maven { url = "http://chickenbones.net/maven/" } + maven { + name = "Overmind forge repo mirror" + url = "https://gregtech.overminddl1.com/" + } + if(usesMixins.toBoolean()) { + maven { + name = "sponge" + url = "https://repo.spongepowered.org/repository/maven-public" + } + maven { + url = "https://jitpack.io" + } + } } dependencies { - compile "codechicken:NotEnoughItems:${minecraft_version}-${NEI_version}:dev" -} - -sourceSets { - main { - java { - srcDir 'src/main/java' - exclude '**/enderio/trigger/**' - } - resources { - srcDir 'resources' + if(usesMixins.toBoolean()) { + annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3") + annotationProcessor("com.google.guava:guava:24.1.1-jre") + annotationProcessor("com.google.code.gson:gson:2.8.6") + annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT") + // using 0.8 to workaround a issue in 0.7 which fails mixin application + compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + // Mixin includes a lot of dependencies that are too up-to-date + exclude module: "launchwrapper" + exclude module: "guava" + exclude module: "gson" + exclude module: "commons-io" + exclude module: "log4j-core" } + compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev") } } -processResources { - inputs.property "version", project.version - inputs.property "mcversion", project.minecraft.version +apply from: 'dependencies.gradle' - from(sourceSets.main.resources.srcDirs) { - include '**/*.info' - include '**/*.properties' +def mixinConfigJson = "mixins." + modId + ".json" +def mixingConfigRefMap = "mixins." + modId + ".refmap.json" +def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap +def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" - expand 'version': project.version, 'mcversion': project.minecraft.version +task generateAssets { + if(usesMixins.toBoolean()) { + new File(projectDir.toString() + "/src/main/resources/", mixinConfigJson).text = """{ + "required": true, + "minVersion": "0.7.11", + "package": "${modGroup}.${mixinsPackage}", + "plugin": "${modGroup}.${mixinPlugin}", + "refmap": "${mixingConfigRefMap}", + "target": "@env(DEFAULT)", + "compatibilityLevel": "JAVA_8" +} + +""" + } +} + +task relocateShadowJar(type: ConfigureShadowRelocation) { + target = tasks.shadowJar + prefix = modGroup + ".shadow" +} + +shadowJar { + manifest { + attributes(getManifestAttributes()) } - from(sourceSets.main.resources.srcDirs) { - exclude '**/*.info' - exclude '**/*.properties' - } + minimize() // This will only allow shading for actually used classes + configurations = [project.configurations.shadowImplementation] + dependsOn(relocateShadowJar) } jar { - from { configurations.exportedCompile.collect { it.isDirectory() ? it : zipTree(it) } } manifest { - attributes 'FMLCorePlugin': 'com.enderio.core.common.transform.EnderCorePlugin' - attributes 'FMLCorePluginContainsFMLMod': 'true' + attributes(getManifestAttributes()) + } + + if(usesShadowedDependencies.toBoolean()) { + dependsOn(shadowJar) + enabled = false } } -task sourceJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' +reobf { + if(usesMixins.toBoolean()) { + addExtraSrgFile mixinSrg + } +} + +afterEvaluate { + if(usesMixins.toBoolean()) { + tasks.compileJava { + options.compilerArgs += [ + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" + ] + } + } +} + +runClient { + def arguments = [] + + if(usesMixins.toBoolean()) { + arguments += [ + "--mods=../build/libs/$modId-${version}.jar", + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + } + + if(developmentEnvironmentUserName) { + arguments += [ + "--username", + developmentEnvironmentUserName + ] + } + + args(arguments) +} + +runServer { + def arguments = [] + + if (usesMixins.toBoolean()) { + arguments += [ + "--mods=../build/libs/$modId-${version}.jar", + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + } + + args(arguments) +} + +tasks.withType(JavaExec).configureEach { + javaLauncher.set( + javaToolchains.launcherFor { + languageVersion = projectJavaVersion + } + ) +} + +processResources + { + // this will ensure that this task is redone when the versions change. + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + // replace stuff in mcmod.info, nothing else + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + + // replace version and mcversion + expand "minecraftVersion": project.minecraft.version, + "modVersion": versionDetails().lastTag, + "modId": modId, + "modName": modName + } + + // copy everything else, thats not the mcmod.info + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } + } + +def getManifestAttributes() { + def manifestAttributes = [:] + if(containsMixinsAndOrCoreModOnly.toBoolean() == false) { + manifestAttributes += ["FMLCorePluginContainsFMLMod": true] + } + + if(accessTransformersFile) { + manifestAttributes += ["FMLAT" : accessTransformersFile.toString()] + } + + if(coreModClass) { + manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass] + } + + if(usesMixins.toBoolean()) { + manifestAttributes += [ + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : mixinConfigJson, + "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false + ] + } + return manifestAttributes +} + +task sourcesJar(type: Jar) { + from (sourceSets.main.allJava) + from (file("$projectDir/LICENSE")) + getArchiveClassifier().set('sources') +} + +task shadowDevJar(type: ShadowJar) { + from sourceSets.main.output + getArchiveClassifier().set("dev") + + manifest { + attributes(getManifestAttributes()) + } + + minimize() // This will only allow shading for actually used classes + configurations = [project.configurations.shadowImplementation] +} + +task relocateShadowDevJar(type: ConfigureShadowRelocation) { + target = tasks.shadowDevJar + prefix = modGroup + ".shadow" +} + +task circularResolverJar(type: Jar) { + dependsOn(relocateShadowDevJar) + dependsOn(shadowDevJar) + enabled = false +} + +task devJar(type: Jar) { + from sourceSets.main.output + getArchiveClassifier().set("dev") + + manifest { + attributes(getManifestAttributes()) + } + + if(usesShadowedDependencies.toBoolean()) { + dependsOn(circularResolverJar) + enabled = false + } } task apiJar(type: Jar) { - from sourceSets.main.allSource - from sourceSets.main.output - include 'crazypants/enderio/api/**/*' - classifier = 'api' + from (sourceSets.main.allJava) { + include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString() + '/**' + } + + from (sourceSets.main.output) { + include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString() + '/**' + } + + from (sourceSets.main.resources.srcDirs) { + include("LICENSE") + } + + getArchiveClassifier().set('api') } -task deobfJar(type: Jar) { - from sourceSets.main.output - from { configurations.exportedCompile.collect { it.isDirectory() ? it : zipTree(it) } } - exclude 'powercrystals/**' - classifier = 'dev' +artifacts { + archives sourcesJar + archives devJar + if(apiPackage) { + archives apiJar + } } -if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') +// Crude handler to append custom maven repositories to maven dependency +install{ + repositories{ + mavenInstaller{ + pom.withXml { + def repositoriesNode = asNode().appendNode("repositories") + project.repositories.each { repository -> + def repositoryNode = repositoriesNode.appendNode("repository") + repositoryNode.appendNode("name", repository.name) + repositoryNode.appendNode("url", repository.properties.get("url")) + } + } } } } -build.dependsOn sourceJar, deobfJar, apiJar, javadoc +// Updating +task updateBuildScript { + doLast { + if (updateBuildScript()) return -publishing { - tasks.publish.dependsOn 'build' - publications { - mavenJava(MavenPublication) { - from components.java - - artifact sourceJar - artifact apiJar - artifact deobfJar - } - } - - repositories { - if (project.hasProperty('mavendir')) { - maven { url mavendir } - } + print("Build script already up-to-date!") } } -curse { - dependsOn 'reobf' - - onlyIf { - return project.hasProperty('cp_curseforge_key') && System.getenv("CURSE") != null && System.getenv("CURSE").equalsIgnoreCase("true") - } - - if (project.hasProperty('cp_curseforge_key')) apiKey = project.curseforge_key - projectId = project.curse_projectId - changelog = System.getenv("CHANGELOG").equals("none") ? project.changelog : System.getenv("CHANGELOG") - releaseType = project.hasProperty('mod_appendix') ? "${mod_appendix}".toString() : 'release' - additionalArtifact deobfJar, sourceJar, apiJar -} - -task checkTranslations << { - Map mapen = new HashMap() - (new File('resources/assets/enderio/lang/en_US.lang')).eachLine { - def (value1, value2) = it.tokenize( '=' ) - if (value1 == null || value2 == null) {return} - mapen.put(value1, value2) - } - - new File('resources/assets/enderio/lang/').eachFileMatch( ~".*\\.lang\$" ) { langfile -> - if (!langfile.getName().contains("en_US")) { - Map map = new HashMap() - File outfile = new File("${langfile}.txt") - Writer outwriter = outfile.newWriter("UTF8") - outwriter.write("\n// Additional translations:\n") - outwriter << langfile.filterLine { - def (value1, value2) = it.tokenize( '=' ) - if (value1 == null || value2 == null) {return false} - map.put(value1, value2) - return !mapen.containsKey(value1) - } - - outwriter.append("\n// Missing translations:\n") - for (e in mapen) { - if (!map.containsKey(e.key)) { - outwriter.append(e.key + "=" + e.value + "\n") - } - } - println "Created translation report ${outfile}" - } +if (isNewBuildScriptVersionAvailable()) { + if (autoUpdateBuildScript.toBoolean()) { + updateBuildScript() + } else { + println("Build script update available! Run 'gradle updateBuildScript'") } } + +static URL availableBuildScriptUrl() { + new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle") +} + +static boolean updateBuildScript() { + if (isNewBuildScriptVersionAvailable()) { + def buildscriptFile = new File("build.gradle") + availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } + print("Build script updated. Please REIMPORT the project or RESTART your IDE!") + return true + } + return false +} + +static boolean isNewBuildScriptVersionAvailable() { + Map parameters = ["connectTimeout": 2000, "readTimeout": 2000] + + String currentBuildScript = new File("build.gradle").getText() + String currentBuildScriptHash = getVersionHash(currentBuildScript) + String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText() + String availableBuildScriptHash = getVersionHash(availableBuildScript) + + boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash + return !isUpToDate +} + +static String getVersionHash(String buildScriptContent) { + String versionLine = buildScriptContent.find("^//version: [a-z0-9]*") + if(versionLine != null) { + return versionLine.split(": ").last() + } + return "" +} + +configure(updateBuildScript) { + group = 'forgegradle' + description = 'Updates the build script to the latest version' +} diff --git a/dependencies.gradle b/dependencies.gradle new file mode 100644 index 0000000..78796b5 --- /dev/null +++ b/dependencies.gradle @@ -0,0 +1,6 @@ +// Add your dependencies here + +dependencies { + compile("com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev") + compileOnly("curse.maven:cofh-core-69162:2388751") +} diff --git a/gradle.properties b/gradle.properties index 0fd1545..9bad160 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,60 @@ -minecraft_version=1.7.10 -forge_version=10.13.4.1490 -NEI_version=1.0.5.111 +modName = EnderCore -mod_version=0.2.0 +# This is a case-sensitive string to identify your mod. Convention is to use lower case. +modId = endercore -#Comment out this line to get rid of the appendix -mod_appendix=beta +modGroup = com.enderio.core -curse_projectId=231868 \ No newline at end of file +# WHY is there no version field? +# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the +# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/ + +# Will update your build.gradle automatically whenever an update is available +autoUpdateBuildScript = false + +minecraftVersion = 1.7.10 +forgeVersion = 10.13.4.1614 + +# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you +# restart Minecraft in development. Choose this dependent on your mod: +# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name +# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty +developmentEnvironmentUserName = "Developer" + +# Define a source file of your project with: +# public static final String VERSION = "GRADLETOKEN_VERSION"; +# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's +# version in @Mod([...], version = VERSION, [...]) +# Leave these properties empty to skip individual token replacements +replaceGradleTokenInFile = EnderCore.java +gradleTokenModId = +gradleTokenModName = +gradleTokenVersion = GRADLETOKEN_VERSION +gradleTokenGroupName = + +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can +# leave this property empty. +# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api +apiPackage = api + +# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/ +# Example value: mymodid_at.cfg +accessTransformersFile = + +# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! +usesMixins = false +# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise. +mixinPlugin = +# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! +mixinsPackage = +# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! +# This parameter is for legacy compatability only +# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin +coreModClass = common.transform.EnderCorePlugin +# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class +# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! +containsMixinsAndOrCoreModOnly = false + +# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your +# responsibility check the licence and request permission for distribution, if required. +usesShadowedDependencies = false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 3d0dee6..5c2d1cf 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cd446a2..3ab0b72 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue Oct 20 17:00:17 EDT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..83f2acf 100644 --- a/gradlew +++ b/gradlew @@ -1,4 +1,20 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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. +# ############################################################################## ## @@ -6,47 +22,6 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -61,9 +36,49 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$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 "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -90,7 +105,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -110,10 +125,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` @@ -154,11 +170,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..9618d8d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@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 @@ -8,14 +24,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@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= - 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="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,10 +62,9 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +75,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..09bbb51 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +before_install: + - ./gradlew setupCIWorkspace \ No newline at end of file diff --git a/repositories.gradle b/repositories.gradle new file mode 100644 index 0000000..c58a9d1 --- /dev/null +++ b/repositories.gradle @@ -0,0 +1,10 @@ +// Add any additional repositiroes for your dependencies here + +repositories { + maven { + url "https://cursemaven.com" + } + maven { + url = "https://jitpack.io" + } +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index be1c43d..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'EnderCore' \ No newline at end of file diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java deleted file mode 100644 index 7f000d4..0000000 --- a/src/main/java/cofh/api/CoFHAPIProps.java +++ /dev/null @@ -1,11 +0,0 @@ -package cofh.api; - -public class CoFHAPIProps { - - private CoFHAPIProps() { - - } - - public static final String VERSION = "1.7.10R1.0.13"; - -} diff --git a/src/main/java/cofh/api/package-info.java b/src/main/java/cofh/api/package-info.java deleted file mode 100644 index 08ff5fc..0000000 --- a/src/main/java/cofh/api/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub - * http://www.teamcofh.com - */ -@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI") -package cofh.api; - -import cpw.mods.fml.common.API; - diff --git a/src/main/java/cofh/api/transport/IEnderAttuned.java b/src/main/java/cofh/api/transport/IEnderAttuned.java deleted file mode 100644 index 4a453f5..0000000 --- a/src/main/java/cofh/api/transport/IEnderAttuned.java +++ /dev/null @@ -1,13 +0,0 @@ -package cofh.api.transport; - -interface IEnderAttuned { - - public String getChannelString(); - - public int getFrequency(); - - public boolean setFrequency(int frequency); - - public boolean clearFrequency(); - -} diff --git a/src/main/java/cofh/api/transport/IEnderDestination.java b/src/main/java/cofh/api/transport/IEnderDestination.java deleted file mode 100644 index f3042a7..0000000 --- a/src/main/java/cofh/api/transport/IEnderDestination.java +++ /dev/null @@ -1,21 +0,0 @@ -package cofh.api.transport; - -public interface IEnderDestination extends IEnderAttuned { - - public boolean isNotValid(); - - public int x(); - - public int y(); - - public int z(); - - public int dimension(); - - public int getDestination(); - - public boolean setDestination(int frequency); - - public boolean clearDestination(); - -} diff --git a/src/main/java/cofh/api/transport/IEnderEnergyHandler.java b/src/main/java/cofh/api/transport/IEnderEnergyHandler.java deleted file mode 100644 index 892a5c6..0000000 --- a/src/main/java/cofh/api/transport/IEnderEnergyHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package cofh.api.transport; - -/** - * This interface is implemented on Ender Attuned objects which can receive Energy (Redstone Flux). - * - * @author King Lemming - * - */ -public interface IEnderEnergyHandler extends IEnderAttuned { - - /** - * Return whether or not the Ender Attuned object can currently send energy (Redstone Flux). - */ - boolean canSendEnergy(); - - /** - * This should be checked to see if the Ender Attuned object can currently receive energy (Redstone Flux). - * - * Note: In practice, this can (and should) be used to ensure that something does not send to itself. - */ - boolean canReceiveEnergy(); - - /** - * This tells the Ender Attuned object to receive energy. This returns the amount remaining, *not* the amount received - a return of 0 means that all energy - * was received! - * - * @param energy - * Amount of energy to be received. - * @param simulate - * If TRUE, the result will only be simulated. - * @return Amount of energy that is remaining (or would be remaining, if simulated). - */ - int receiveEnergy(int energy, boolean simulate); - -} diff --git a/src/main/java/cofh/api/transport/IEnderFluidHandler.java b/src/main/java/cofh/api/transport/IEnderFluidHandler.java deleted file mode 100644 index 2f509e8..0000000 --- a/src/main/java/cofh/api/transport/IEnderFluidHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package cofh.api.transport; - -import net.minecraftforge.fluids.FluidStack; - -/** - * This interface is implemented on Ender Attuned objects which can receive Fluid. - * - * @author King Lemming - * - */ -public interface IEnderFluidHandler extends IEnderAttuned { - - /** - * Return whether or not the Ender Attuned object can currently send FluidStacks. - */ - boolean canSendFluid(); - - /** - * This should be checked to see if the Ender Attuned object can currently receive a FluidStack. - * - * Note: In practice, this can (and should) be used to ensure that something does not send to itself. - */ - boolean canReceiveFluid(); - - /** - * This tells the Ender Attuned object to receive a FluidStack. This returns what remains of the original stack, *not* the amount received - a null return - * means that the entire stack was received! - * - * @param fluid - * FluidStack to be received. - * @param simulate - * If TRUE, the result will only be simulated. - * @return FluidStack representing how much fluid is remaining (or would be remaining, if simulated). - */ - FluidStack receiveFluid(FluidStack fluid, boolean simulate); - -} diff --git a/src/main/java/cofh/api/transport/IEnderItemHandler.java b/src/main/java/cofh/api/transport/IEnderItemHandler.java deleted file mode 100644 index d5dad8f..0000000 --- a/src/main/java/cofh/api/transport/IEnderItemHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package cofh.api.transport; - -import net.minecraft.item.ItemStack; - -/** - * This interface is implemented on Ender Attuned objects which can receive Items. - * - * @author King Lemming - * - */ -public interface IEnderItemHandler extends IEnderAttuned { - - /** - * Return whether or not the Ender Attuned object can currently send ItemStacks. - */ - boolean canSendItems(); - - /** - * This should be checked to see if the Ender Attuned object can currently receive an ItemStack. - * - * Note: In practice, this can (and should) be used to ensure that something does not send to itself. - */ - boolean canReceiveItems(); - - /** - * This tells the Ender Attuned object to receive an ItemStack. This returns what remains of the original stack, *not* the amount received - a null return - * means that the entire stack was received! - * - * This function does not support simulation because Inventory manipulation in Minecraft is an absolute mess and it would be a computational liability to do - * so. - * - * @param item - * ItemStack to be received. - * @return An ItemStack representing how much is remaining. - */ - ItemStack receiveItem(ItemStack item); - -} diff --git a/src/main/java/cofh/api/transport/IItemDuct.java b/src/main/java/cofh/api/transport/IItemDuct.java deleted file mode 100644 index 6733834..0000000 --- a/src/main/java/cofh/api/transport/IItemDuct.java +++ /dev/null @@ -1,26 +0,0 @@ -package cofh.api.transport; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * This interface is implemented on ItemDucts. Use it to attempt to eject items into an entry point. - * - * @author Zeldo Kavira, King Lemming - * - */ -public interface IItemDuct { - - /** - * Insert an ItemStack into the IItemDuct. Will only accept items if there is a valid destination. This returns what is remaining of the original stack - a - * null return means that the entire stack was accepted/routed! - * - * @param from - * Orientation the item is inserted from. - * @param item - * ItemStack to be inserted. The size of this stack corresponds to the maximum amount to insert. - * @return An ItemStack representing how much is remaining after the item was inserted into the Duct. - */ - public ItemStack insertItem(ForgeDirection from, ItemStack item); - -} diff --git a/src/main/java/cofh/api/transport/RegistryEnderAttuned.java b/src/main/java/cofh/api/transport/RegistryEnderAttuned.java deleted file mode 100644 index 9213d95..0000000 --- a/src/main/java/cofh/api/transport/RegistryEnderAttuned.java +++ /dev/null @@ -1,389 +0,0 @@ -package cofh.api.transport; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.common.config.Configuration; - -public final class RegistryEnderAttuned { - - public static Map>> inputItem = new HashMap>>(); - public static Map>> inputFluid = new HashMap>>(); - public static Map>> inputEnergy = new HashMap>>(); - - public static Map>> outputItem = new HashMap>>(); - public static Map>> outputFluid = new HashMap>>(); - public static Map>> outputEnergy = new HashMap>>(); - - public static Map> outputTeleport = new HashMap>(); - - public static Configuration linkConf; - - public static Map clientFrequencyNames = new LinkedHashMap(); - public static Map clientFrequencyNamesReversed = new LinkedHashMap(); - - private static class EnderDestination { - - private final int dimension; - private final int x, y, z; - private IEnderDestination output; - - public EnderDestination(IEnderDestination output) { - - x = output.x(); - y = output.y(); - z = output.z(); - dimension = output.dimension(); - this.output = output; - } - - public boolean hasOutput() { - - return DimensionManager.isDimensionRegistered(dimension); - } - - public IEnderDestination getOutput() { - - if (output == null || output.isNotValid()) { - output = null; - if (!DimensionManager.isDimensionRegistered(dimension)) { - return null; - } - WorldServer world = DimensionManager.getWorld(dimension); - if (world == null) { - DimensionManager.initDimension(dimension); - world = DimensionManager.getWorld(dimension); - } - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof IEnderDestination) { - output = (IEnderDestination) te; - } - } - return output; - } - } - - public static void clear() { - - inputItem.clear(); - inputFluid.clear(); - inputEnergy.clear(); - outputItem.clear(); - outputFluid.clear(); - outputEnergy.clear(); - } - - public static List getLinkedItemInputs(IEnderItemHandler theAttuned) { - - if (inputItem.get(theAttuned.getChannelString()) == null) { - return null; - } - return inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); - } - - public static List getLinkedItemOutputs(IEnderItemHandler theAttuned) { - - if (outputItem.get(theAttuned.getChannelString()) == null) { - return null; - } - return outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); - } - - public static List getLinkedFluidInputs(IEnderFluidHandler theAttuned) { - - if (inputFluid.get(theAttuned.getChannelString()) == null) { - return null; - } - return inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); - } - - public static List getLinkedFluidOutputs(IEnderFluidHandler theAttuned) { - - if (outputFluid.get(theAttuned.getChannelString()) == null) { - return null; - } - return outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); - } - - public static List getLinkedEnergyInputs(IEnderEnergyHandler theAttuned) { - - if (inputEnergy.get(theAttuned.getChannelString()) == null) { - return null; - } - return inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); - } - - public static List getLinkedEnergyOutputs(IEnderEnergyHandler theAttuned) { - - if (outputEnergy.get(theAttuned.getChannelString()) == null) { - return null; - } - return outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); - } - - public static boolean hasDestination(IEnderDestination theAttuned) { - - return hasDestination(theAttuned, true); - } - - public static boolean hasDestination(IEnderDestination theAttuned, boolean to) { - - Map map = outputTeleport.get(theAttuned.getChannelString()); - if (map == null) { - return false; - } - EnderDestination dest = map.get(to ? theAttuned.getDestination() : theAttuned.getFrequency()); - return dest == null ? false : dest.hasOutput(); - } - - public static IEnderDestination getDestination(IEnderDestination theAttuned) { - - Map map = outputTeleport.get(theAttuned.getChannelString()); - if (map == null) { - return null; - } - EnderDestination dest = map.get(theAttuned.getDestination()); - return dest == null ? null : dest.getOutput(); - } - - /* HELPER FUNCTIONS */ - public static void addItemHandler(IEnderItemHandler theAttuned) { - - if (theAttuned.canSendItems()) { - if (inputItem.get(theAttuned.getChannelString()) == null) { - inputItem.put(theAttuned.getChannelString(), new HashMap>()); - } - if (inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) { - inputItem.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList()); - } - if (!inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) { - inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned); - } - } - if (theAttuned.canReceiveItems()) { - if (outputItem.get(theAttuned.getChannelString()) == null) { - outputItem.put(theAttuned.getChannelString(), new HashMap>()); - } - if (outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) { - outputItem.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList()); - } - if (!outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) { - outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned); - } - } - } - - public static void addFluidHandler(IEnderFluidHandler theAttuned) { - - if (theAttuned.canSendFluid()) { - if (inputFluid.get(theAttuned.getChannelString()) == null) { - inputFluid.put(theAttuned.getChannelString(), new HashMap>()); - } - if (inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) { - inputFluid.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList()); - } - if (!inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) { - inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned); - } - } - if (theAttuned.canReceiveFluid()) { - if (outputFluid.get(theAttuned.getChannelString()) == null) { - outputFluid.put(theAttuned.getChannelString(), new HashMap>()); - } - if (outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) { - outputFluid.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList()); - } - if (!outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) { - outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned); - } - } - } - - public static void addEnergyHandler(IEnderEnergyHandler theAttuned) { - - if (theAttuned.canSendEnergy()) { - if (inputEnergy.get(theAttuned.getChannelString()) == null) { - inputEnergy.put(theAttuned.getChannelString(), new HashMap>()); - } - if (inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) { - inputEnergy.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList()); - } - if (!inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) { - inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned); - } - } - if (theAttuned.canReceiveEnergy()) { - if (outputEnergy.get(theAttuned.getChannelString()) == null) { - outputEnergy.put(theAttuned.getChannelString(), new HashMap>()); - } - if (outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) { - outputEnergy.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList()); - } - if (!outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) { - outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned); - } - } - } - - public static void addDestination(IEnderDestination theAttuned) { - - if (!hasDestination(theAttuned, false)) { - if (outputTeleport.get(theAttuned.getChannelString()) == null) { - outputTeleport.put(theAttuned.getChannelString(), new HashMap()); - } - outputTeleport.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new EnderDestination(theAttuned)); - } - } - - public static void removeItemHandler(IEnderItemHandler theAttuned) { - - if (inputItem.get(theAttuned.getChannelString()) != null) { - if (inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) { - inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned); - if (inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) { - inputItem.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency()); - } - } - } - if (outputItem.get(theAttuned.getChannelString()) != null) { - if (outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) { - outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned); - if (outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) { - outputItem.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency()); - } - } - } - } - - public static void removeFluidHandler(IEnderFluidHandler theAttuned) { - - if (inputFluid.get(theAttuned.getChannelString()) != null) { - if (inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) { - inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned); - if (inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) { - inputFluid.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency()); - } - } - } - if (outputFluid.get(theAttuned.getChannelString()) != null) { - if (outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) { - outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned); - if (outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) { - outputFluid.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency()); - } - } - } - } - - public static void removeEnergyHandler(IEnderEnergyHandler theAttuned) { - - if (inputEnergy.get(theAttuned.getChannelString()) != null) { - if (inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) { - inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned); - if (inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) { - inputEnergy.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency()); - } - } - } - if (outputEnergy.get(theAttuned.getChannelString()) != null) { - if (outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) { - outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned); - if (outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) { - outputEnergy.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency()); - } - } - } - } - - public static void removeDestination(IEnderDestination theAttuned) { - - Map map = outputTeleport.get(theAttuned.getChannelString()); - if (map == null) { - return; - } - EnderDestination dest = map.get(theAttuned.getFrequency()); - if (dest == null) { - return; - } - if (dest.dimension == theAttuned.dimension()) { - if (dest.x == theAttuned.x() && dest.y == theAttuned.x() && dest.z == theAttuned.x()) { - map.remove(theAttuned.getFrequency()); - } - } - } - - public static void add(IEnderAttuned theAttuned) { - - if (theAttuned instanceof IEnderItemHandler) { - addItemHandler((IEnderItemHandler) theAttuned); - } - if (theAttuned instanceof IEnderFluidHandler) { - addFluidHandler((IEnderFluidHandler) theAttuned); - } - if (theAttuned instanceof IEnderEnergyHandler) { - addEnergyHandler((IEnderEnergyHandler) theAttuned); - } - if (theAttuned instanceof IEnderDestination) { - addDestination((IEnderDestination) theAttuned); - } - } - - public static void remove(IEnderAttuned theAttuned) { - - if (theAttuned instanceof IEnderItemHandler) { - removeItemHandler((IEnderItemHandler) theAttuned); - } - if (theAttuned instanceof IEnderFluidHandler) { - removeFluidHandler((IEnderFluidHandler) theAttuned); - } - if (theAttuned instanceof IEnderEnergyHandler) { - removeEnergyHandler((IEnderEnergyHandler) theAttuned); - } - if (theAttuned instanceof IEnderDestination) { - removeDestination((IEnderDestination) theAttuned); - } - } - - public static void sortClientNames() { - - List> list = new ArrayList>(clientFrequencyNames.entrySet()); - Collections.sort(list, new Comparator>() { - - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - - int int1 = Integer.valueOf(clientFrequencyNamesReversed.get(o1.getValue())); - int int2 = Integer.valueOf(clientFrequencyNamesReversed.get(o2.getValue())); - return int1 > int2 ? 1 : int1 == int2 ? 0 : -1; - } - }); - Map result = new LinkedHashMap(); - for (Map.Entry entry : list) { - result.put(entry.getKey(), entry.getValue()); - } - clientFrequencyNames = result; - } - - public static void clearClientNames() { - - clientFrequencyNames.clear(); - clientFrequencyNamesReversed.clear(); - } - - public static void addClientNames(String owner, String name) { - - if (!owner.isEmpty()) { - clientFrequencyNames.put(owner, name); - clientFrequencyNamesReversed.put(name, owner); - } - } - -} diff --git a/src/main/java/cofh/api/transport/package-info.java b/src/main/java/cofh/api/transport/package-info.java deleted file mode 100644 index fae0150..0000000 --- a/src/main/java/cofh/api/transport/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub - * http://www.teamcofh.com - */ -@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|transport") -package cofh.api.transport; - -import cofh.api.CoFHAPIProps; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/com/enderio/core/EnderCore.java b/src/main/java/com/enderio/core/EnderCore.java index 9d815d1..2e95dfb 100644 --- a/src/main/java/com/enderio/core/EnderCore.java +++ b/src/main/java/com/enderio/core/EnderCore.java @@ -48,7 +48,7 @@ public class EnderCore implements IEnderMod { public static final String MODID = "endercore"; public static final String NAME = "EnderCore"; public static final String BASE_PACKAGE = "com.enderio"; - public static final String VERSION = "@VERSION@"; + public static final String VERSION = "GRADLETOKEN_VERSION"; public static final Logger logger = LogManager.getLogger(NAME); public static final Lang lang = new Lang(MODID); diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index e5a3262..5690e39 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,10 +1,10 @@ [ { - "modid": "endercore", - "name": "EnderCore", + "modid": "${modId}", + "name": "${modName}", "description": "Library mod used by EnderIO, EnderZoo, and others", - "version": "${version}", - "mcversion": "${mcversion}", + "version": "${modVersion}", + "mcversion": "${minecraftVersion}", "url": "http://enderio.com", "updateUrl": "http://ci.tterrag.com/job/EnderCore", "authorList": ["tterrag", "CrazyPants"],