diff --git a/.gitignore b/.gitignore index 5e19125..f60b507 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,47 @@ -#eclipse +# eclipse .project .classpath .metadata org.* bin *.launch +.settings +eclipse -#idea +# idea *.iml *.ipr *.iws .idea out -#gradle +# gradle build .gradle +modules libs #runtime run +run_server +run_data classes #mac .DS_Store + +#Custom code to inject the the dev environment +custom +test-results + +#licnse_checker +# Not in git because it contains names + emails. +license_checker/agreed.txt +license_checker/unused_code.txt +license_checker/out/** + +# Files from Forge MDK +forge*changelog.txt + +# For some annoying reason the tests creates a log file in "/logs/latest.txt" +logs diff --git a/.gitmodules b/.gitmodules index 3602e61..7730ed0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "BuildCraft"] path = BuildCraft - url = https://github.com/BuildCraft/BuildCraft.git + url = https://github.com/CalenXwX/BuildCraft.git + branch = 8.0.x-1.20.1 diff --git a/BuildCraft b/BuildCraft index 656b0a0..6ef7425 160000 --- a/BuildCraft +++ b/BuildCraft @@ -1 +1 @@ -Subproject commit 656b0a00a04bf61ebd9f39f6c3e44eac2818b1ec +Subproject commit 6ef7425b1d2003f353058d5ec057884440e4ca83 diff --git a/build.gradle b/build.gradle index 95cf589..cf96f12 100755 --- a/build.gradle +++ b/build.gradle @@ -1,30 +1,26 @@ -// DON'T TOUCH THE BUILDSCRIPT[] BLOCK -// its special, and it is only there to make ForgeGradle work correctly. - buildscript { repositories { + // These repositories are only for Gradle plugins, put any other repositories in the repository core further below + maven { url = 'https://maven.minecraftforge.net' } mavenCentral() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } - maven { - url "https://plugins.gradle.org/m2/" - } } dependencies { - classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT" + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + // Mixin + classpath 'org.spongepowered:mixingradle:0.7.+' classpath "org.ajoberstar:grgit:2.2.1" } } -apply plugin: "net.minecraftforge.gradle.forge" // adds the forge dependency -apply plugin: "maven" // for uploading to a maven repo -apply plugin: 'maven-publish' // for uploading to a maven repo +plugins { + id 'eclipse' + id 'idea' + id 'maven-publish' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' +} +apply plugin: 'net.minecraftforge.gradle' +// Mixin +apply plugin: 'org.spongepowered.mixin' apply plugin: "org.ajoberstar.grgit" ext.configFile = file "build.properties" @@ -44,60 +40,54 @@ group = "com.mod-buildcraft-compat" archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension] ext { - compatModInfo = new groovy.json.JsonSlurper().parse(file("resources/mcmod.info")) - mainModInfo = new groovy.json.JsonSlurper().parse(file("BuildCraft/buildcraft_resources/mcmod.info")) -} - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -repositories { - maven { name="JEI"; url="http://dvs1.progwml6.com/files/maven" } - maven { name="TOP"; url="http://maven.tterrag.com/" } - maven { name="hwyla"; url="http://tehnut.info/maven" } - // The One probe depends on the RF API -- we don't use it ourselves, nor will we ever add compat for it... - maven { name="cofh"; url="http://maven.covers1624.net" } - maven { name="forestry"; url = "http://maven.ic2.player.to/" } - maven { name "CraftTweaker"; url "http://maven.blamejared.com/" } +// compatModInfo = file("resources/mods.toml") +// mainModInfo = file("BuildCraft/buildcraft_resources/mods.toml") + compatModInfo = file("mod_info/META-INF/mods.toml").readLines() + mainModInfo = file("BuildCraft/mod_info/META-INF/mods.toml").readLines() } -dependencies { - // JEI Stuff - // Versions from http://minecraft.curseforge.com/projects/just-enough-items-jei/files - compileOnly "mezz.jei:jei_${config.mc_version}:${config.jei_version}:api" - runtime "mezz.jei:jei_${config.mc_version}:${config.jei_version}" - - // The One Probe Stuff - compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${config.top_version}:api" - runtime "mcjty.theoneprobe:TheOneProbe-1.12:${config.top_version}" - // The One Probe depends on the RF api for some odd reason... we never intend to add support for RF ourselves though. - - // HWYLA - compileOnly "mcp.mobius.waila:Hwyla:${config.hwyla_version}:api" - runtime "mcp.mobius.waila:Hwyla:${config.hwyla_version}" - - // Forestry - deobfCompile "net.sengir.forestry:forestry_${config.mc_version}:${config.forestry_version}" - - deobfCompile "net.industrial-craft:industrialcraft-2:${config.ic2_version}" - - // CraftTweaker - deobfCompile "CraftTweaker2:CraftTweaker2-API:${config.crafttweaker_version}" - deobfCompile "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-${config.crafttweaker_version}" -} +// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. +java.toolchain.languageVersion = JavaLanguageVersion.of(17) +println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { - version = config.mc_version + "-" + config.forge_version - runDir = "run" - - // the mappings can be changed at any time, and must be in the following format. - // snapshot_YYYYMMDD snapshot are built nightly. - // stable_# stables are built at the discretion of the MCP team. - // Use non-default mappings at your own risk. they may not allways work. - // simply re-run your setup task after changing the mappings to update your workspace. - mappings = config.mappings_version - - useDepAts = true + // The mappings can be changed at any time and must be in the following format. + // Channel: Version: + // official MCVersion Official field/method names from Mojang mapping files + // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official + // + // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. + // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md + // + // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge + // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started + // + // Use non-default mappings at your own risk. They may not always work. + // Simply re-run your setup task after changing the mappings to update your workspace. + mappings channel: config.mappings_channel, version: config.mappings_version + + // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. + // In most cases, it is not necessary to enable. + // enableEclipsePrepareRuns = true + // enableIdeaPrepareRuns = true + + // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. + // It is REQUIRED to be set to true for this template to function. + // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html + copyIdeResources = true + + // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations. + // The folder name can be set on a run configuration using the "folderName" property. + // By default, the folder name of a run configuration is the name of the Gradle project containing it. + // generateRunFolders = true + + // This property enables access transformers for use in development. + // They will be applied to the Minecraft artifact. + // The access transformer file can be anywhere in the project. + // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge. + // This default location is a best practice to automatically put the file in the right place in the final jar. + // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information. + accessTransformer = file('BuildCraft/buildcraft_resources/META-INF/accesstransformer.cfg') def separate = Boolean.getBoolean("build_compat_only") if (separate) { @@ -106,35 +96,85 @@ minecraft { project.version = config.mod_version; } - def addVersionDetails = !Boolean.getBoolean("release") - - // Git versioning stuffs - if (grgit != null) { - def repo = grgit.open(dir: project.rootDir) - replace "\${git_commit_hash}", repo.head().id - replace "\${git_commit_msg}", repo.head().fullMessage.replace("\"", "\\\\\\\"").split("\n")[0] - replace "\${git_commit_author}", repo.head().author.name - replace "\${git_branch}", repo.branch.current().getName() - if (addVersionDetails) { - project.version += "-" + repo.head().id.toString().substring(0, 12) +// def addVersionDetails = !Boolean.getBoolean("release") +// +// // Git versioning stuffs +// if (grgit != null) { +// def repo = grgit.open(dir: project.rootDir) +// replace "\${git_commit_hash}", repo.head().id +// replace "\${git_commit_msg}", repo.head().fullMessage.replace("\"", "\\\\\\\"").split("\n")[0] +// replace "\${git_commit_author}", repo.head().author.name +// replace "\${git_branch}", repo.branch.current().getName() +// if (addVersionDetails) { +// project.version += "-" + repo.head().id.toString().substring(0, 12) +// } +// } else { +// if (addVersionDetails) { +// project.version += "-SNAPSHOT" +// } +// } +// +// // replacing stuff in the source +// replace "\$version", project.version +// replace "\${mcversion}", version +// // Replace @Mod.acceptedMinecraftVersions specially as it has to be a valid version in a dev environment :/ +// replace "(gradle_replace_mcversion,)", "[" + version + "]" +// replace "(gradle_replace_forgeversion,)", "[" + config.forge_version + ",)" +// replace "\$bc_version", config.mod_version + + // Default run configurations. + // These can be tweaked, removed, or duplicated as needed. + runs { + // applies to all the run configs below + configureEach { + workingDirectory project.file('run') + + // Recommended logging data for a userdev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + property 'forge.logging.console.level', 'debug' + + mods { + "${mod_id}" { + source sourceSets.main + } + } } - } else { - if (addVersionDetails) { - project.version += "-SNAPSHOT" + + client { + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + property 'forge.enabledGameTestNamespaces', mod_id } - } - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. + server { + workingDirectory project.file('run_server') + property 'forge.enabledGameTestNamespaces', mod_id + args '--nogui' + } + + // This run config launches GameTestServer and runs all registered gametests, then exits. + // By default, the server will crash when no gametests are provided. + // The gametest system is also enabled by default for other run configs under the /test command. + gameTestServer { + property 'forge.enabledGameTestNamespaces', mod_id + } - // replacing stuff in the source - replace "\$version", project.version - replace "\${mcversion}", version - // Replace @Mod.acceptedMinecraftVersions specially as it has to be a valid version in a dev environment :/ - replace "(gradle_replace_mcversion,)", "[" + version + "]" - replace "(gradle_replace_forgeversion,)", "[" + config.forge_version + ",)" - replace "\$bc_version", config.mod_version + data { + // example of overriding the workingDirectory set in configureEach above + workingDirectory project.file('run_data') - useDepAts = true + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. + args '--mod', mod_id, '--all', '--output', file('BuildCraft/buildcraft_resources_generated/'), + '--existing', file('BuildCraft/buildcraft_resources/') + } + } } compileJava { @@ -157,151 +197,333 @@ task setupSubProjects(dependsOn: "BuildCraft:sub_projects:expression:generateSou // Just an inter-dependency task } -eclipseClasspath.dependsOn setupSubProjects -ideaModule.dependsOn setupSubProjects -compileApiJava.dependsOn setupSubProjects +//eclipseClasspath.dependsOn setupSubProjects +//ideaModule.dependsOn setupSubProjects +//compileApiJava.dependsOn setupSubProjects -// configure the source folders +// Include resources generated by data generators. sourceSets { - api { + main { java { + srcDir "common" srcDir "BuildCraft/BuildCraftAPI/api" srcDir "BuildCraft/common" srcDir "BuildCraft/sub_projects/expression/src/main/java" srcDir "BuildCraft/sub_projects/expression/src/autogen/java" } resources { + srcDir "resources" + srcDir "mod_info" srcDir "BuildCraft/buildcraft_resources" + srcDir 'BuildCraft/buildcraft_resources_generated' + srcDir "BuildCraft/BuildCraft-Localization" srcDir "BuildCraft/BuildCraftGuide/guide_resources" - exclude "pack.png" // exclude from the guide repo - exclude "pack.mcmeta" // exclude from the guide repo + exclude "**/.md" // exclude readme from localization repo + exclude "pack.png" + exclude '.cache' + exclude "pack.mcmeta_" + // Calen: we should not exclude the pack.mcmeta file in buildcraft_resources, or all the resources will be lost +// exclude "pack.mcmeta" // exclude from the guide repo } } - main { + api { java { - srcDir "common" + srcDir "BuildCraft/BuildCraftAPI/api" + srcDir "BuildCraft/common" + srcDir "BuildCraft/sub_projects/expression/src/main/java" + srcDir "BuildCraft/sub_projects/expression/src/autogen/java" } resources { - srcDir "resources" + srcDir "BuildCraft/buildcraft_resources" + srcDir "BuildCraft/BuildCraftGuide/guide_resources" + exclude "pack.png" // exclude from the guide repo + // exclude "pack.mcmeta" // exclude from the guide repo + } + } + test { + java { + srcDir "BuildCraft/src/test/java" + srcDir "BuildCraft/sub_projects/expression/src/test/java" } } } -// Obfuscated Jar location -ext.jarFile = zipTree(jar.archivePath) - -processResources { - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' +repositories { + // Put repositories for dependencies here + // ForgeGradle automatically adds the Forge maven and Maven Central for you - // replace version and mcversion - // ${version} and ${mcversion} are the exact strings being replaced - expand 'version': project.version, 'mcversion': project.minecraft.version, 'modid': config.modid + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: + flatDir { + dir 'libs' } - // copy everything else, that's not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - exclude 'pack.mcmeta' - exclude 'pack.png' + maven { + name 'prog' + url 'https://dvs1.progwml6.com/files/maven' + content { + includeGroup 'mezz.jei' + } + } + maven { + name 'CurseMaven' + url 'https://www.cursemaven.com' + content { + includeGroup 'curse.maven' + } + } + // JEI + maven { + // location of the maven that hosts JEI files before January 2023 + name = "Progwml6's maven" + url = "https://dvs1.progwml6.com/files/maven/" + } + // JEI + maven { + // location of a maven mirror for JEI files, as a fallback + name = "ModMaven" + url = "https://modmaven.dev" + } + // CraftTweaker JEI + maven { + url = 'https://maven.blamejared.com' + name = 'BlameJared Maven' + } + // TOP + maven { + url "https://maven.k-4u.nl/" + content { + includeGroup "mcjty" + } + } + // REI + maven { + url "https://maven.shedaniel.me" } } -def createAllModInfo() { - return new File("$projectDir/build/processing/compat-all/mcmod.info") +// Mixin +mixin { + add sourceSets.main, "refmap.buildcraft.json" + config 'mixins.buildcraft.json' + mixin.env.remapRefMap = true + debug = true + debug.verbose = true + debug.export = true } -task writeAllModInfo() { - outputs.upToDateWhen { false } - doLast { - File temp = createAllModInfo() - temp.parentFile.mkdirs() - if (temp.exists()) - temp.delete() - temp.createNewFile() - def elements = []; - for (int i = 0; i < mainModInfo.size(); i++) { - elements += mainModInfo[i]; - } - elements += compatModInfo[0]; - String prettyPrinted = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(elements)) - prettyPrinted = prettyPrinted.replace("\$version", project.version) - prettyPrinted = prettyPrinted.replace("\${mcversion}", project.minecraft.version) - temp.write(prettyPrinted) - return temp - } -} +dependencies { + // Specify the version of Minecraft to use. + // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact. + // The "userdev" classifier will be requested and setup by ForgeGradle. + // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"], + // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. + minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}" -def unzippedSourceJar = new File("$projectDir/build/processing/tasks/unzipped_src_jar/unzip") -def libsDir = new File(System.getenv("LIBS_DIR") ?: "build/libs/", project.version) -def modulesDir = new File(libsDir, "modules") + // Examples using mod jars from ./libs -// forge (or gradle?) creates a special sourceJar which has been processed -// This task unzips that created jar, so that partial source jars can be created. -task unzipSourceJar(type: Copy, dependsOn: sourceJar) { - from (zipTree(sourceJar.archivePath)) { - include "**" - } - into unzippedSourceJar -} + // JEI + implementation fg.deobf("mezz.jei:jei-${config.mc_version}-forge:${config.jei_version}") -task compatJar(type: Jar, dependsOn:reobfJar) { - destinationDir = modulesDir - appendix = "compat" - version = project.version + // REI + implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:${config.cloth_config_version}") + implementation fg.deobf("dev.architectury:architectury-forge:${config.architectury_version}") + implementation fg.deobf("me.shedaniel:RoughlyEnoughItems-forge:${config.rei_version}") - from(project.ext.jarFile) { - includes.addAll("**") - } -} + // Jade + implementation fg.deobf("curse.maven:jade-324717:" + config.jade_id) -task allJar(type: Jar, dependsOn: [reobfJar, writeAllModInfo]) { - destinationDir = libsDir - appendix = "all" - version = project.version + // CraftTweaker + implementation fg.deobf('com.blamejared.crafttweaker:CraftTweaker-forge-1.20.1:14.0.44') - from(createAllModInfo().parentFile) - from(project.ext.jarFile) { - includes.addAll("**") - exclude("mcmod.info") - } -} + // The One Probe + implementation fg.deobf("curse.maven:the-one-probe-245211:" + config.top_id) -task allSrcJar(type: Jar, dependsOn:[reobfJar, writeAllModInfo, unzipSourceJar]) { - destinationDir = libsDir - appendix = "all" - classifier = "sources" + // Testing + testImplementation "junit:junit:4.12" + testImplementation 'org.hamcrest:hamcrest:2.2' - from(createAllModInfo().parentFile) - from(unzippedSourceJar) { - includes.add("**") - exclude("mcmod.info") + // Mixin + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' +} + +// This block of code expands all declared replace properties in the specified resource targets. +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. +// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. +// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html +tasks.named('processResources', ProcessResources).configure { + var replaceProperties = [ + minecraft_version : config.mc_version, + minecraft_version_range: minecraft_version_range, + forge_version : config.forge_version, + forge_version_range : forge_version_range, + loader_version_range : loader_version_range, + mod_id : mod_id, + mod_name : mod_name, + mod_license : mod_license, + mod_version : mod_version, + mod_authors : mod_authors, + mod_description : mod_description, + ] + inputs.properties replaceProperties + + filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { + expand replaceProperties + [project: project] } } +//processResources { +// // replace stuff in mcmod.info, nothing else +// from(sourceSets.main.resources.srcDirs) { +// include 'mcmod.info' +// +// // replace version and mcversion +// // ${version} and ${mcversion} are the exact strings being replaced +// expand 'version': project.version, 'mcversion': project.minecraft.version, 'modid': config.modid +// } +// +// // copy everything else, that's not the mcmod.info +// from(sourceSets.main.resources.srcDirs) { +// exclude 'mcmod.info' +// exclude 'pack.mcmeta' +// exclude 'pack.png' +// } +//} + +// Example for how to get properties into the manifest for reading at runtime. +tasks.named('jar', Jar).configure { + manifest { + attributes([ + "Specification-Title" : "BuildCraft", + "Specification-Vendor" : "BuildCraft Team", + "Specification-Version" : project.version, + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : "BuildCraft Team", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs" : "mixins.buildcraft.json" + ]) + } -build.dependsOn compatJar, allJar, allSrcJar + // This is the preferred method to reobfuscate your jar file + finalizedBy 'reobfJar' +} +//def createAllModInfo() { +// return new File("$projectDir/build/processing/compat-all/mods.toml") +//} + +//task writeAllModInfo() { +// outputs.upToDateWhen { false } +// doLast { +// File temp = createAllModInfo() +// temp.parentFile.mkdirs() +// if (temp.exists()) +// temp.delete() +// temp.createNewFile() +// def elements = []; +// for (int i = 0; i < mainModInfo.size(); i++) { +// elements += mainModInfo[i]; +// } +// elements += compatModInfo[0]; +// String prettyPrinted = elements.join("\r\n") +// prettyPrinted = prettyPrinted.replace("\$version", project.version) +// prettyPrinted = prettyPrinted.replace("\${mcversion}", project.minecraft.version) +// temp.write(prettyPrinted) +// return temp +// } +//} + +//def unzippedSourceJar = new File("$projectDir/build/processing/tasks/unzipped_src_jar/unzip") +//def libsDir = new File(System.getenv("LIBS_DIR") ?: "build/libs/", project.version) +//def modulesDir = new File(libsDir, "modules") + +//// forge (or gradle?) creates a special sourceJar which has been processed +//// This task unzips that created jar, so that partial source jars can be created. +//task unzipSourceJar(type: Copy, dependsOn: sourceJar) { +// from (zipTree(sourceJar.archivePath)) { +// include "**" +// } +// into unzippedSourceJar +//} + +//task allJar(type: Jar, dependsOn: ["reobfJar", "writeAllModInfo"]) { +// destinationDir = libsDir +// appendix = "all" +// version = project.version +// +// from(createAllModInfo().parentFile) +// from(project.ext.jarFile) { +// includes.addAll("**") +// exclude("mcmod.info") +// } +//} + +//task allSrcJar(type: Jar, dependsOn:[reobfJar, writeAllModInfo, unzipSourceJar]) { +// destinationDir = libsDir +// appendix = "all" +// classifier = "sources" +// +// from(createAllModInfo().parentFile) +// from(unzippedSourceJar) { +// includes.add("**") +// exclude("mcmod.info") +// } +//} + +//build.dependsOn compatJar, allJar, allSrcJar + +//task compatJar(type: Jar, dependsOn:reobfJar) { +// destinationDir = modulesDir +// appendix = "compat" +// version = project.version +// +// from(project.ext.jarFile) { +// includes.addAll("**") +// } +//} + +// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing: +// tasks.named('publish').configure { +// dependsOn 'reobfJar' +// } + +// Example configuration to allow publishing using the maven-publish plugin publishing { + publications { + register('mavenJava', MavenPublication) { + artifact jar + } +// pub_allJar(MavenPublication) { +// groupId "com.mod-buildcraft" +// artifactId "buildcraft-all" +// version project.version +// +// artifact allJar +// } +// pub_apiSrcJar(MavenPublication) { +// groupId "com.mod-buildcraft" +// artifactId "buildcraft-all" +// version project.version +// +// artifact allSrcJar +// } + } repositories { maven { +// url "file://${project.projectDir}/mcmodsrepo" url System.getenv("MAVEN_DIR") ?: "$projectDir/build/maven" } } - publications { - pub_allJar(MavenPublication) { - groupId "com.mod-buildcraft" - artifactId "buildcraft-all" - version project.version +} - artifact allJar - } - pub_apiSrcJar(MavenPublication) { - groupId "com.mod-buildcraft" - artifactId "buildcraft-all" - version project.version +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +} - artifact allSrcJar - } - } +jar.enabled = true + +// enable Jar-in-Jar +jarJar.enable() + +tasks.named('jarJar') { + // ... } diff --git a/build.properties b/build.properties index 66c247b..eb0b2a6 100644 --- a/build.properties +++ b/build.properties @@ -1,8 +1,22 @@ -compat_version=7.99.15 +mc_version=1.20.1 +forge_version=47.3.12 +mappings_channel=official +mappings_version=1.20.1 +mod_version=7.99.24.9 -jei_version=4.8.5.138 -top_version=1.12-1.4.19-11 -hwyla_version=1.8.22-B37_1.12 -forestry_version=5.7.0.236 -crafttweaker_version=4.1.9.491 -ic2_version=2.8.221-ex112 +#compat_version=7.99.15 +compat_version=7.99.24.9 + +jade_api_id=3803228 +jade_id=5876199 +#jei_id=5846810 +jei_version=15.20.0.105 +cloth_config_version=11.1.136 +architectury_version=9.2.14 +rei_version=12.1.785 +top_id=5159287 +#crafttweaker_id=5880672 +crafttweaker_version=14.0.44 + +#forestry_version=5.7.0.236 +#ic2_version=2.8.221-ex112 diff --git a/common/buildcraft/compat/BCCompat.java b/common/buildcraft/compat/BCCompat.java index 72fdbaa..9668a92 100644 --- a/common/buildcraft/compat/BCCompat.java +++ b/common/buildcraft/compat/BCCompat.java @@ -1,53 +1,45 @@ -/* - * Copyright (c) 2020 SpaceToad and the BuildCraft team - * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not - * distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/ - */ - package buildcraft.compat; -import java.util.HashMap; -import java.util.Map; - -import net.minecraftforge.common.config.Property; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; - import buildcraft.api.core.BCLog; - import buildcraft.compat.module.crafttweaker.CompatModuleCraftTweaker; -import buildcraft.compat.module.forestry.CompatModuleForestry; import buildcraft.compat.module.ic2.CompatModuleIndustrialCraft2; import buildcraft.compat.module.theoneprobe.CompatModuleTheOneProbe; -import buildcraft.compat.network.CompatGui; -import buildcraft.core.BCCoreConfig; - -//@formatter:off -@Mod( - modid = BCCompat.MODID, - name = "BuildCraft Compat", - version = BCCompat.VERSION, - updateJSON = "https://mod-buildcraft.com/version/versions-compat.json", - acceptedMinecraftVersions = "(gradle_replace_mcversion,)", - dependencies = BCCompat.DEPENDENCIES -) -//@formatter:on -public class BCCompat { +import buildcraft.core.BCCore; +import buildcraft.lib.config.ConfigCategory; +import buildcraft.lib.config.EnumRestartRequirement; +import buildcraft.lib.registry.RegistryConfig; +import buildcraft.lib.registry.TagManager; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; +import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +//@Mod( +// modid = "buildcraftcompat", +// name = "BuildCraft Compat", +// version = "7.99.24.8", +// updateJSON = "https://mod-buildcraft.com/version/versions-compat.json", +// acceptedMinecraftVersions = "[1.12.2]", +// dependencies = "required-after:forge@[14.23.0.2544,);required-after:buildcraftcore@[7.99.24.8,);after:buildcrafttransport;after:buildcraftbuilders;after:buildcraftsilicon;after:theoneprobe;after:forestry;after:crafttweaker;after:ic2" +//) +@Mod(BCCompat.MODID) +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +public class BCCompat { static final String DEPENDENCIES = "required-after:forge@(gradle_replace_forgeversion,)"// - + ";required-after:buildcraftcore@[$bc_version,)"// - + ";after:buildcrafttransport"// - + ";after:buildcraftbuilders"// - + ";after:buildcraftsilicon"// - + ";after:theoneprobe"// - + ";after:forestry"// - + ";after:crafttweaker"// - + ";after:ic2"// - ; - + + ";required-after:buildcraftcore@[$bc_version,)"// + + ";after:buildcrafttransport"// + + ";after:buildcraftbuilders"// + + ";after:buildcraftsilicon"// + + ";after:theoneprobe"// + + ";after:forestry"// + + ";after:crafttweaker"// + + ";after:ic2"// + ; public static final String MODID = "buildcraftcompat"; public static final String VERSION = "$version"; public static final String GIT_BRANCH = "${git_branch}"; @@ -55,17 +47,27 @@ public class BCCompat { public static final String GIT_COMMIT_MSG = "${git_commit_msg}"; public static final String GIT_COMMIT_AUTHOR = "${git_commit_author}"; - @Mod.Instance(MODID) + // @Instance(MOD_ID) public static BCCompat instance; - private static final Map modules = new HashMap<>(); + private static final Map> moduleConfigs = new HashMap<>(); - private static void offerAndPreInitModule(final CompatModuleBase module) { + public BCCompat() { + instance = this; + } + + private static void offerAndPreInitModule(CompatModuleBase module) { String cModId = module.compatModId(); if (module.canLoad()) { - Property prop = BCCoreConfig.config.get("modules", cModId, true); - if (prop.getBoolean(true)) { + String _modules = "modules"; + ConfigCategory prop = BCCompatConfig.config + .define(_modules, + "", + EnumRestartRequirement.NONE, + cModId, true); + if (prop.get()) { modules.put(cModId, module); + moduleConfigs.put(cModId, prop); BCLog.logger.info("[compat] + " + cModId); module.preInit(); } else { @@ -76,9 +78,13 @@ private static void offerAndPreInitModule(final CompatModuleBase module) { } } - @Mod.EventHandler - public static void preInit(final FMLPreInitializationEvent evt) { + @SubscribeEvent + public static void preInit(FMLConstructModEvent evt) { + // Calen + RegistryConfig.useOtherModConfigFor(MODID, BCCore.MODID); + BCCompatConfig.preInit(); + // init BCLog.logger.info(""); BCLog.logger.info("Starting BuildCraftCompat " + VERSION); BCLog.logger.info("Copyright (c) the BuildCraft team, 2011-2017"); @@ -94,54 +100,70 @@ public static void preInit(final FMLPreInitializationEvent evt) { BCLog.logger.info("[compat] Module list:"); // List of all modules - offerAndPreInitModule(new CompatModuleForestry()); + // TODO Calen Forestry? +// offerAndPreInitModule(new CompatModuleForestry()); offerAndPreInitModule(new CompatModuleTheOneProbe()); offerAndPreInitModule(new CompatModuleCraftTweaker()); offerAndPreInitModule(new CompatModuleIndustrialCraft2()); // End of module list - } - - @Mod.EventHandler - public static void init(final FMLInitializationEvent evt) { - NetworkRegistry.INSTANCE.registerGuiHandler(instance, CompatGui.guiHandlerProxy); - // compatChannelHandler = new ChannelHandler(); - // MinecraftForge.EVENT_BUS.register(this); + // Calen + BCCompatProxy.getProxy().fmlPreInit(); + } - // compatChannelHandler.registerPacketType(PacketGenomeFilterChange.class); - // compatChannelHandler.registerPacketType(PacketTypeFilterChange.class); - // compatChannelHandler.registerPacketType(PacketRequestFilterSet.class); + /** This is called after config loaded. */ + private static void loadModules() { + modules.entrySet().forEach(entry -> + { + String cModId = entry.getKey(); + CompatModuleBase module = entry.getValue(); + if (moduleConfigs.get(cModId).get()) { + BCLog.logger.info("[compat] + " + cModId); + module.preInit(); + } else { + BCLog.logger.info("[compat] x " + cModId + " (It has been disabled in the config)"); + } + }); + } - for (final CompatModuleBase m : modules.values()) { + @SubscribeEvent + public static void init(FMLCommonSetupEvent evt) { + loadModules(); + // TODO Calen compat GUI??? +// NetworkRegistry.INSTANCE.registerGuiHandler(instance, CompatGui.guiHandlerProxy); + for (CompatModuleBase m : modules.values()) { m.init(); } } - @Mod.EventHandler - public static void postInit(final FMLPostInitializationEvent evt) { - for (final CompatModuleBase m : modules.values()) { + @SubscribeEvent + public static void postInit(FMLLoadCompleteEvent evt) { + for (CompatModuleBase m : modules.values()) { m.postInit(); } + + BCCompatConfig.saveConfigs(); } - // @Mod.EventHandler - // public void missingMapping(FMLMissingMappingsEvent event) { - // CompatModuleForestry.missingMapping(event); - // } - - // @SubscribeEvent - // @SideOnly(Side.CLIENT) - // public void handleTextureRemap(TextureStitchEvent.Pre event) { - // if (event.map.getTextureType() == 1) { - // TextureManager.getInstance().initIcons(event.map); - // } - // } - - // public static boolean isLoaded(String module) { - // return moduleNames.contains(module); - // } - - // public static boolean hasModule(final String module) { - // return BuildCraftCompat.moduleNames.contains(module); - // } + private static final TagManager tagManager = new TagManager(); + + static { + startBatch(); + + endBatch(TagManager.prependTags("buildcraftcompat:", TagManager.EnumTagType.REGISTRY_NAME) + .andThen(TagManager.setTab("buildcraft.main")) + ); + } + + private static TagManager.TagEntry registerTag(String id) { + return tagManager.registerTag(id); + } + + private static void startBatch() { + tagManager.startBatch(); + } + + private static void endBatch(Consumer consumer) { + tagManager.endBatch(consumer); + } } diff --git a/common/buildcraft/compat/BCCompatConfig.java b/common/buildcraft/compat/BCCompatConfig.java new file mode 100644 index 0000000..8ce5d63 --- /dev/null +++ b/common/buildcraft/compat/BCCompatConfig.java @@ -0,0 +1,56 @@ +package buildcraft.compat; + +import buildcraft.api.BCModules; +import buildcraft.lib.config.BCConfig; +import buildcraft.lib.config.ConfigCategory; +import buildcraft.lib.config.Configuration; +import buildcraft.lib.config.EnumRestartRequirement; + +public class BCCompatConfig { + public static Configuration config; + + // Calen: remove the json file + public static boolean coloredPipesVisible; + public static boolean facadesVisible; + private static ConfigCategory propColoredPipesVisible; + private static ConfigCategory propFacadesVisible; + + public static void preInit() { + // Start config + BCModules module = BCModules.COMPAT; + config = new Configuration(module); + createProps(); + reloadConfig(); +// BCCoreConfig.addReloadListener(BCEnergyConfig::reloadConfig); + BCConfig.registerReloadListener(module, BCCompatConfig::reloadConfig); + } + + public static void createProps() { + EnumRestartRequirement world = EnumRestartRequirement.WORLD; + + propColoredPipesVisible = config + .define("client", + "Should all colored pipes be visible in JEI/REI?", + world, + "colored_pipes_visible", false); + + propFacadesVisible = config + .define("client", + "Should all facades be visible in JEI/REI?", + world, + "facades_visible", false); + } + + public static void reloadConfig() { + coloredPipesVisible = propColoredPipesVisible.get(); + facadesVisible = propFacadesVisible.get(); + + saveConfigs(); + } + + public static void saveConfigs() { + if (config.hasChanged()) { + config.save(); + } + } +} diff --git a/common/buildcraft/compat/BCCompatProxy.java b/common/buildcraft/compat/BCCompatProxy.java new file mode 100644 index 0000000..9c947a4 --- /dev/null +++ b/common/buildcraft/compat/BCCompatProxy.java @@ -0,0 +1,41 @@ +package buildcraft.compat; + +import net.minecraftforge.fml.loading.FMLLoader; + +public abstract class BCCompatProxy { + private static BCCompatProxy proxy = null; + + public static BCCompatProxy getProxy() { + if (proxy == null) { + switch (FMLLoader.getDist()) { + case CLIENT: + proxy = new BCCompatProxy.ClientProxy(); + break; + case DEDICATED_SERVER: + proxy = new BCCompatProxy.ServerProxy(); + break; + } + } + return proxy; + } + + public void fmlPreInit() { + } + + public void fmlInit() { + } + + public void fmlPostInit() { + } + + public static class ServerProxy extends BCCompatProxy { + + } + + public static class ClientProxy extends BCCompatProxy { + @Override + public void fmlPreInit() { + super.fmlPreInit(); + } + } +} diff --git a/common/buildcraft/compat/CompatModuleBase.java b/common/buildcraft/compat/CompatModuleBase.java index 483f782..233b729 100644 --- a/common/buildcraft/compat/CompatModuleBase.java +++ b/common/buildcraft/compat/CompatModuleBase.java @@ -1,10 +1,11 @@ package buildcraft.compat; -import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.ModList; public abstract class CompatModuleBase { public boolean canLoad() { - return Loader.isModLoaded(this.compatModId()); +// return Loader.isModLoaded(this.compatModId()); + return ModList.get().isLoaded(this.compatModId()); } public abstract String compatModId(); diff --git a/common/buildcraft/compat/CompatUtils.java b/common/buildcraft/compat/CompatUtils.java index 876fd34..b3550b5 100644 --- a/common/buildcraft/compat/CompatUtils.java +++ b/common/buildcraft/compat/CompatUtils.java @@ -1,29 +1,29 @@ package buildcraft.compat; -import java.util.List; - +import buildcraft.compat.network.IGuiCreator; +import buildcraft.lib.misc.StackUtil; +import buildcraft.lib.tile.item.ItemHandlerSimple; import com.google.common.collect.Lists; - -import net.minecraft.item.ItemStack; - +import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.CapabilityToken; +import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; -import buildcraft.api.core.CapabilitiesHelper; - -import buildcraft.lib.tile.item.ItemHandlerSimple; - -import buildcraft.compat.network.IGuiCreator; +import java.util.List; +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = BCCompat.MODID) public class CompatUtils { + public static final Capability CAP_GUI_CREATOR = CapabilityManager.get(new CapabilityToken<>() { + }); - public static final Capability CAP_GUI_CREATOR = - CapabilitiesHelper.registerCapability(IGuiCreator.class); - - private CompatUtils() {} + private CompatUtils() { + } public static List compactInventory(ItemHandlerSimple inventory) { List stacks = Lists.newArrayList(); - for (int slot = 0; slot < inventory.getSlots(); slot++) { ItemStack stack = inventory.getStackInSlot(slot); if (stack.isEmpty()) { @@ -32,7 +32,8 @@ public static List compactInventory(ItemHandlerSimple inventory) { boolean handled = false; for (ItemStack existing : stacks) { - if (existing.isItemEqual(stack)) { +// if (existing.isItemEqual(stack)) + if (StackUtil.isSameItemSameDamage(existing, stack)) { existing.grow(stack.getCount()); handled = true; break; @@ -45,4 +46,10 @@ public static List compactInventory(ItemHandlerSimple inventory) { return stacks; } + + // Calen + @SubscribeEvent + public static void registerCapability(RegisterCapabilitiesEvent event) { + event.register(IGuiCreator.class); + } } diff --git a/common/buildcraft/compat/module/crafttweaker/AssemblyTable.java b/common/buildcraft/compat/module/crafttweaker/AssemblyTable.java index a06e22c..6383873 100644 --- a/common/buildcraft/compat/module/crafttweaker/AssemblyTable.java +++ b/common/buildcraft/compat/module/crafttweaker/AssemblyTable.java @@ -1,105 +1,224 @@ package buildcraft.compat.module.crafttweaker; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; - import buildcraft.api.mj.MjAPI; -import buildcraft.api.recipes.AssemblyRecipeBasic; +import buildcraft.api.recipes.IAssemblyRecipe; import buildcraft.api.recipes.IngredientStack; +import buildcraft.lib.recipe.assembly.AssemblyRecipe; +import buildcraft.lib.recipe.assembly.AssemblyRecipeBasic; +import buildcraft.lib.recipe.assembly.IFacadeAssemblyRecipes; +import buildcraft.silicon.recipe.FacadeAssemblyRecipes; +import com.blamejared.crafttweaker.api.CraftTweakerAPI; +import com.blamejared.crafttweaker.api.action.recipe.ActionAddRecipe; +import com.blamejared.crafttweaker.api.action.recipe.ActionRemoveRecipeByName; +import com.blamejared.crafttweaker.api.annotation.ZenRegister; +import com.blamejared.crafttweaker.api.ingredient.IIngredient; +import com.blamejared.crafttweaker.api.item.IItemStack; +import com.blamejared.crafttweaker.api.recipe.component.BuiltinRecipeComponents; +import com.blamejared.crafttweaker.api.recipe.component.DecomposedRecipeBuilder; +import com.blamejared.crafttweaker.api.recipe.component.IDecomposedRecipe; +import com.blamejared.crafttweaker.api.recipe.handler.IRecipeHandler; +import com.blamejared.crafttweaker.api.recipe.manager.base.IRecipeManager; +import com.blamejared.crafttweaker.api.util.ItemStackUtil; +import com.blamejared.crafttweaker.api.util.StringUtil; +import com.google.common.collect.ImmutableSet; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import org.openzen.zencode.java.ZenCodeGlobals; +import org.openzen.zencode.java.ZenCodeType; + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +//@ZenClass("mods.buildcraft.AssemblyTable") +//@ModOnly("buildcraftsilicon") +@ZenRegister +@ZenCodeType.Name("mods.buildcraft.AssemblyTable") +@IRecipeHandler.For(IAssemblyRecipe.class) +//public class AssemblyTable +public enum AssemblyTable implements IRecipeManager, IRecipeHandler { + @ZenCodeGlobals.Global("assemblyTable") + INSTANCE; -import buildcraft.lib.recipe.AssemblyRecipeRegistry; - -import crafttweaker.CraftTweakerAPI; -import crafttweaker.IAction; -import crafttweaker.annotations.ModOnly; -import crafttweaker.api.item.IIngredient; -import crafttweaker.api.item.IItemStack; -import crafttweaker.api.minecraft.CraftTweakerMC; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; + private static int ids; -@ZenClass("mods.buildcraft.AssemblyTable") -@ModOnly("buildcraftsilicon") -public class AssemblyTable { +// // @ZenMethod +// @ZenCodeType.Method +// // public static void addRecipe(IItemStack output, int power, IIngredient[] ingredients) +// public void addRecipe(IItemStack output, int power, IIngredient[] ingredients) { +// addRecipe0("auto_" + ids++, output, power, ingredients); +// } + + // @ZenMethod + @ZenCodeType.Method +// public static void addRecipe(String name, IItemStack output, int power, IIngredient[] ingredients) + public void addRecipe(String name, IItemStack output, int power, IIngredient[] ingredients) { + addRecipe0("custom/" + name, output, power, ingredients); + } - private static int ids; + // @ZenMethod + @ZenCodeType.Method +// public static void addRecipe(String name, IItemStack output, int power, IIngredient[] ingredients) + public void enableFacadeAssembly() { + enableFacadeAssembly0(); + } - @ZenMethod - public static void addRecipe(IItemStack output, int power, IIngredient[] ingredients) { - addRecipe0("auto_" + ids++, output, power, ingredients); + // private static void addRecipe0(String name, IItemStack output, int power, IIngredient[] ingredients) + private void addRecipe0(String name, IItemStack output, int power, IIngredient[] ingredients) { +// CraftTweakerAPI.apply(new AddRecipeAction(name, output, power, ingredients)); + CraftTweakerAPI.apply(AddRecipeAction.create(this, name, output, power, ingredients)); } - @ZenMethod - public static void addRecipe(String name, IItemStack output, int power, IIngredient[] ingredients) { - addRecipe0("custom/" + name, output, power, ingredients); + // private static void addRecipe0(String name, IItemStack output, int power, IIngredient[] ingredients) + private void enableFacadeAssembly0() { +// CraftTweakerAPI.apply(new AddRecipeAction(name, output, power, ingredients)); + CraftTweakerAPI.apply(AddRecipeAction.createFacadeRecipe(this)); } - private static void addRecipe0(String name, IItemStack output, int power, IIngredient[] ingredients) { - CraftTweakerAPI.apply(new AddRecipeAction(name, output, power, ingredients)); + // @ZenMethod + @ZenCodeType.Method + // public static void removeByName(String name) + public void removeByName(String name) { +// CraftTweakerAPI.apply(new RemoveRecipeByNameAction(new ResourceLocation(name))); + CraftTweakerAPI.apply(new RemoveRecipeByNameAction(this, new ResourceLocation(name))); } - @ZenMethod - public static void removeByName(String name) { - CraftTweakerAPI.apply(new RemoveRecipeByNameAction(new ResourceLocation(name))); + @Override + public RecipeType getRecipeType() { + return IAssemblyRecipe.TYPE; } - // ###################### - // ### Action classes ### - // ###################### + @Override + public String dumpToCommandString(final IRecipeManager manager, IAssemblyRecipe recipe) { + if (recipe instanceof IFacadeAssemblyRecipes) { + return String.format( + "assemblyTable.enableFacadeAssembly();" + ); + } else { + return String.format( + "assemblyTable.addRecipe(%s, %s, %s, %s);", + StringUtil.quoteAndEscape(recipe.getId()), + ItemStackUtil.getCommandString(recipe.getOutputPreviews().stream().toList().get(0)), + recipe.getRequiredMicroJoules(), + recipe.getRequiredIngredientStacks().stream() + .map(i -> IIngredient.fromIngredient(i.ingredient)) + .map(IIngredient::getCommandString) + .collect(Collectors.joining(", ", "[", "]")) + ); + } + } - private static class AddRecipeAction implements IAction { + @Override + public > boolean doesConflict(IRecipeManager iRecipeManager, IAssemblyRecipe assemblyRecipe, U u) { + if (assemblyRecipe.getClass() == FacadeAssemblyRecipes.class && u.getClass() == FacadeAssemblyRecipes.class) { + return true; + } + return u instanceof IAssemblyRecipe && + ((IAssemblyRecipe) u).getRequiredIngredientStacks().stream() + .allMatch(u_ingredientStack -> + assemblyRecipe.getIngredients().stream() + .anyMatch(r_ingredientStack -> Arrays.stream(r_ingredientStack.getItems()).anyMatch(u_ingredientStack.ingredient::test)) + ); + } - private final ItemStack output; - private final ResourceLocation name; - private final long requiredMj; - private final ImmutableSet requiredStacks; + @Override + public Optional decompose(IRecipeManager iRecipeManager, IAssemblyRecipe assemblyRecipe) { + DecomposedRecipeBuilder builder = IDecomposedRecipe.builder(); + assemblyRecipe.getRequiredIngredientStacks().forEach(ingredientStack -> + builder.with(BCRecipeComponents.INGREDIENT_STACK, ingredientStack) + ); + builder.with(BCRecipeComponents.MJ, assemblyRecipe.getRequiredMicroJoules()); + builder.with(BuiltinRecipeComponents.Output.ITEMS, assemblyRecipe.getOutput().stream().map(IItemStack::of).toList()); + return Optional.of(builder.build()); + } - public AddRecipeAction(String name, IItemStack output, int power, IIngredient[] ingredients) { - this.output = CraftTweakerMC.getItemStack(output); + @Override + public Optional recompose(IRecipeManager iRecipeManager, ResourceLocation id, IDecomposedRecipe iDecomposedRecipe) { + List requiredStacks = iDecomposedRecipe.getOrThrow(BCRecipeComponents.INGREDIENT_STACK); + long requiredMicroJoules = iDecomposedRecipe.getOrThrowSingle(BCRecipeComponents.MJ); + ItemStack output = iDecomposedRecipe.getOrThrowSingle(BuiltinRecipeComponents.Output.ITEMS).getInternal(); + return Optional.of(new AssemblyRecipeBasic(id, requiredMicroJoules, ImmutableSet.copyOf(requiredStacks), output)); + } - Builder stacks = ImmutableSet.builder(); - for (int i = 0; i < ingredients.length; i++) { - IIngredient ctIng = ingredients[i]; - Ingredient ingredient = CraftTweakerMC.getIngredient(ctIng); - stacks.add(new IngredientStack(ingredient, Math.max(1, ctIng.getAmount()))); - } - requiredStacks = stacks.build(); + // private static class RemoveRecipeByNameAction implements IAction + private static class RemoveRecipeByNameAction extends ActionRemoveRecipeByName { + private final ResourceLocation name; - this.requiredMj = power * MjAPI.MJ; - this.name = new ResourceLocation("crafttweaker", name); + // RemoveRecipeByNameAction(ResourceLocation name) + RemoveRecipeByNameAction(IRecipeManager manager, ResourceLocation name) { + super(manager); + this.name = name; } - @Override public void apply() { - AssemblyRecipeRegistry.REGISTRY.put(name, - new AssemblyRecipeBasic(name, requiredMj, requiredStacks, output)); +// AssemblyRecipeRegistry.REGISTRY.remove(this.name); + getManager().removeByName(this.name.toString()); } - @Override public String describe() { - return "Adding assembly table recipe for " + output; + return "Removing assembly table recipe " + this.name; } } - private static class RemoveRecipeByNameAction implements IAction { - private final ResourceLocation name; + // private static class AddRecipeAction implements IAction + private static class AddRecipeAction extends ActionAddRecipe { +// private final ItemStack output; +// private final ResourceLocation name; +// private final long requiredMj; +// private final ImmutableSet requiredStacks; + + // public AddRecipeAction(IRecipeManager manager, String name, IItemStack output, int power, IIngredient[] ingredients) + private AddRecipeAction(IRecipeManager manager, AssemblyRecipe recipe) { + super(manager, recipe); +// this.output = CraftTweakerMC.getItemStack(output); +// ImmutableSet.Builder stacks = ImmutableSet.builder(); +// +// for (int i = 0; i < ingredients.length; ++i) { +// IIngredient ctIng = ingredients[i]; +// Ingredient ingredient = CraftTweakerMC.getIngredient(ctIng); +// stacks.add(new IngredientStack(ingredient, Math.max(1, ctIng.getAmount()))); +// } +// +// this.requiredStacks = stacks.build(); +// this.requiredMj = (long) power * MjAPI.MJ; +// this.name = new ResourceLocation("crafttweaker", name); + } - RemoveRecipeByNameAction(ResourceLocation name) { - this.name = name; + public static AddRecipeAction create(IRecipeManager manager, String name, IItemStack output, int power, IIngredient[] ingredients) { +// ItemStack output = CraftTweakerMC.getItemStack(output); + ItemStack _output = output.getImmutableInternal(); + ImmutableSet.Builder stacks = ImmutableSet.builder(); + + for (int i = 0; i < ingredients.length; ++i) { + IIngredient ctIng = ingredients[i]; +// Ingredient ingredient = CraftTweakerMC.getIngredient(ctIng); + Ingredient ingredient = ctIng.asVanillaIngredient(); +// stacks.add(new IngredientStack(ingredient, Math.max(1, ctIng.getAmount()))); + stacks.add(new IngredientStack(ingredient, Math.max(1, ctIng.asIIngredientWithAmount().getAmount()))); + } + + ImmutableSet requiredStacks = stacks.build(); + long requiredMj = (long) power * MjAPI.MJ; + ResourceLocation _name = new ResourceLocation("crafttweaker", name); + AssemblyRecipeBasic recipe = new AssemblyRecipeBasic(_name, requiredMj, requiredStacks, _output); + return new AddRecipeAction(manager, recipe); } - @Override - public void apply() { - AssemblyRecipeRegistry.REGISTRY.remove(name); + public static AddRecipeAction createFacadeRecipe(IRecipeManager manager) { + return new AddRecipeAction(manager, FacadeAssemblyRecipes.INSTANCE); } - @Override +// public void apply() { +// AssemblyRecipeRegistry.REGISTRY.put(this.name, new AssemblyRecipeBasic(this.name, this.requiredMj, this.requiredStacks, this.output)); +// } + public String describe() { - return "Removing assembly table recipe " + name; +// return "Adding assembly table recipe for " + this.output; + return "Adding assembly table recipe for " + this.recipe.getOutputPreviews().stream().toList().get(0); } } } diff --git a/common/buildcraft/compat/module/crafttweaker/BCRecipeComponents.java b/common/buildcraft/compat/module/crafttweaker/BCRecipeComponents.java new file mode 100644 index 0000000..8709243 --- /dev/null +++ b/common/buildcraft/compat/module/crafttweaker/BCRecipeComponents.java @@ -0,0 +1,49 @@ +package buildcraft.compat.module.crafttweaker; + +import buildcraft.api.BCModules; +import buildcraft.api.recipes.IngredientStack; +import buildcraft.lib.misc.StackUtil; +import com.blamejared.crafttweaker.api.recipe.component.IRecipeComponent; +import com.google.gson.reflect.TypeToken; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; + +import java.util.List; +import java.util.Objects; + +public class BCRecipeComponents { + public static final IRecipeComponent MJ = IRecipeComponent.simple( + ResourceLocation.tryBuild(BCModules.BUILDCRAFT, "mj"), + new TypeToken<>() {}, + Objects::equals + ); + + public static final IRecipeComponent INGREDIENT_STACK = IRecipeComponent.composite( + ResourceLocation.tryBuild(BCModules.BUILDCRAFT, "ingredient_stack"), + new TypeToken<>() {}, + IngredientStack::equals, + List::of, + ingredientStacks -> ingredientStacks.stream().findFirst().orElse(new IngredientStack(Ingredient.EMPTY)) + ); + + public static final IRecipeComponent DEGREES_COOLING_PER_MB = IRecipeComponent.simple( + ResourceLocation.tryBuild(BCModules.BUILDCRAFT, "degrees_cooling_per_mb"), + new TypeToken<>() {}, + Objects::equals + ); + + public static final IRecipeComponent MULTIPLIER = IRecipeComponent.simple( + ResourceLocation.tryBuild(BCModules.BUILDCRAFT, "multiplier"), + new TypeToken<>() {}, + Objects::equals + ); + + public static final IRecipeComponent ITEM_STACK = IRecipeComponent.composite( + ResourceLocation.tryBuild(BCModules.BUILDCRAFT, "item_stack"), + new TypeToken<>() {}, + ItemStack::equals, + List::of, + itemStacks -> itemStacks.stream().findFirst().orElse(StackUtil.EMPTY) + ); +} diff --git a/common/buildcraft/compat/module/crafttweaker/CombustionEngine.java b/common/buildcraft/compat/module/crafttweaker/CombustionEngine.java index f1cb66a..c494ad3 100644 --- a/common/buildcraft/compat/module/crafttweaker/CombustionEngine.java +++ b/common/buildcraft/compat/module/crafttweaker/CombustionEngine.java @@ -1,153 +1,248 @@ package buildcraft.compat.module.crafttweaker; -import net.minecraftforge.fluids.FluidStack; - -import buildcraft.api.fuels.BuildcraftFuelRegistry; +import buildcraft.api.fuels.IFluidCoolant; +import buildcraft.api.fuels.IFuel; +import buildcraft.api.fuels.IFuelManager; import buildcraft.api.mj.MjAPI; +import buildcraft.lib.misc.FluidUtilBC; +import buildcraft.lib.recipe.fuel.FuelRegistry; +import com.blamejared.crafttweaker.api.CraftTweakerAPI; +import com.blamejared.crafttweaker.api.action.recipe.ActionAddRecipe; +import com.blamejared.crafttweaker.api.annotation.ZenRegister; +import com.blamejared.crafttweaker.api.fluid.CTFluidIngredient; +import com.blamejared.crafttweaker.api.fluid.IFluidStack; +import com.blamejared.crafttweaker.api.recipe.component.BuiltinRecipeComponents; +import com.blamejared.crafttweaker.api.recipe.component.DecomposedRecipeBuilder; +import com.blamejared.crafttweaker.api.recipe.component.IDecomposedRecipe; +import com.blamejared.crafttweaker.api.recipe.handler.IRecipeHandler; +import com.blamejared.crafttweaker.api.recipe.manager.base.IRecipeManager; +import com.blamejared.crafttweaker.api.util.StringUtil; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.material.EmptyFluid; +import net.minecraftforge.fluids.FluidStack; +import org.openzen.zencode.java.ZenCodeGlobals; +import org.openzen.zencode.java.ZenCodeType; -import buildcraft.lib.engine.TileEngineBase_BC8; +import java.util.List; +import java.util.Optional; -import crafttweaker.CraftTweakerAPI; -import crafttweaker.IAction; -import crafttweaker.annotations.ModOnly; -import crafttweaker.api.liquid.ILiquidStack; -import crafttweaker.api.minecraft.CraftTweakerMC; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; +//@ZenClass("mods.buildcraft.CombustionEngine") +//@ModOnly("buildcraftenergy") +@ZenRegister +@ZenCodeType.Name("mods.buildcraft.CombustionEngine") +@IRecipeHandler.For(IFuel.class) +//public class CombustionEngine +public enum CombustionEngine implements IRecipeManager, IRecipeHandler { + @ZenCodeGlobals.Global("combustionEngine") + INSTANCE; -@ZenClass("mods.buildcraft.CombustionEngine") -@ModOnly("buildcraftenergy") -public class CombustionEngine { + private static final double MAX_POWER = 100000.0; - private static final double MAX_POWER - = (TileEngineBase_BC8.MAX_HEAT - TileEngineBase_BC8.MIN_HEAT) / TileEngineBase_BC8.HEAT_PER_MJ; + // @ZenMethod + @ZenCodeType.Method + public void addCleanFuel(String name, IFluidStack liquid, double powerPerTick, int timePerBucket) { + addCleanFuel0("custom/" + name, liquid, powerPerTick, timePerBucket); + } - @ZenMethod - public static void addCleanFuel(ILiquidStack liquid, double powerPerTick, int timePerBucket) { - FluidStack fluid = CraftTweakerMC.getLiquidStack(liquid); - if (fluid == null) { - throw new IllegalArgumentException("Fluid was null!"); - } - if (BuildcraftFuelRegistry.fuel.getFuel(fluid) != null) { + // @ZenMethod + // @ZenCodeType.Method + // public static void addCleanFuel(ILiquidStack liquid, double powerPerTick, int timePerBucket) + private void addCleanFuel0(String name, IFluidStack liquid, double powerPerTick, int timePerBucket) { +// FluidStack fluid = CraftTweakerMC.getLiquidStack(liquid); + FluidStack fluid = liquid.getImmutableInternal(); +// if (fluid == null) + if (fluid.getFluid() == null || fluid.getFluid() instanceof EmptyFluid) { + throw new IllegalArgumentException("Fluid was null or empty!"); + } +// else if (BuildcraftFuelRegistry.fuel.getFuel(fluid) != null) + else if (getAllRecipes().stream().anyMatch(r -> r.getFluid().equals(fluid))) { throw new IllegalArgumentException("The fluid " + fluid + " is already registered as a fuel!"); } - if (BuildcraftFuelRegistry.coolant.getCoolant(fluid) != null) { - throw new IllegalArgumentException( - "The fluid " + fluid - + " is already registered as a coolant - so it won't work very well if you add it as a fuel too!" - ); - } - if (powerPerTick <= 0) { +// else if (BuildcraftFuelRegistry.coolant.getCoolant(fluid) != null) + else if (Coolant.INSTANCE.getAllRecipes().stream().anyMatch(r -> r instanceof IFluidCoolant fluidCoolant && fluidCoolant.getFluid().equals(fluid))) { + throw new IllegalArgumentException("The fluid " + fluid + " is already registered as a coolant - so it won't work very well if you add it as a fuel too!"); + } else if (powerPerTick <= 0.0) { throw new IllegalArgumentException("Power was less than or equal to 0!"); + } else if (powerPerTick > 100000.0) { + throw new IllegalArgumentException("Maximum power is 100000.0, as any values above this would instantly bring the engine to overheat."); + } else { + long mj = (long) ((double) MjAPI.MJ * powerPerTick); +// CraftTweakerAPI.apply(new AddCleanFuel(fluid, mj, timePerBucket)); + CraftTweakerAPI.apply(AddCleanFuel.create(this, name, fluid, mj, timePerBucket)); } - if (powerPerTick > MAX_POWER) { - throw new IllegalArgumentException( - "Maximum power is " + MAX_POWER - + ", as any values above this would instantly bring the engine to overheat." - ); - } - long mj = (long) (MjAPI.MJ * powerPerTick); - CraftTweakerAPI.apply(new AddCleanFuel(fluid, mj, timePerBucket)); } - @ZenMethod - public static void addDirtyFuel(ILiquidStack lFuel, double powerPerTick, int timePerBucket, ILiquidStack lResidue) { - FluidStack fuel = CraftTweakerMC.getLiquidStack(lFuel); - FluidStack residue = CraftTweakerMC.getLiquidStack(lResidue); - if (fuel.getFluid() == null) { - throw new IllegalArgumentException("Fuel fluid was null!"); - } - if (residue.getFluid() == null) { - throw new IllegalArgumentException("Residue fluid was null!"); - } - if (BuildcraftFuelRegistry.fuel.getFuel(fuel) != null) { + // @ZenMethod + @ZenCodeType.Method + public void addDirtyFuel(String name, IFluidStack lFuel, double powerPerTick, int timePerBucket, IFluidStack lResidue) { + addDirtyFuel0("custom/" + name, lFuel, powerPerTick, timePerBucket, lResidue); + } + + // @ZenMethod + // @ZenCodeType.Method + // public static void addDirtyFuel(ILiquidStack lFuel, double powerPerTick, int timePerBucket, ILiquidStack lResidue) + private void addDirtyFuel0(String name, IFluidStack lFuel, double powerPerTick, int timePerBucket, IFluidStack lResidue) { +// FluidStack fuel = CraftTweakerMC.getLiquidStack(lFuel); + FluidStack fuel = lFuel.getImmutableInternal(); +// FluidStack residue = CraftTweakerMC.getLiquidStack(lResidue); + FluidStack residue = lResidue.getImmutableInternal(); +// if (fuel.getFluid() == null) + if (fuel.getFluid() == null || fuel.getFluid() instanceof EmptyFluid) { +// throw new IllegalArgumentException("Fuel fluid was null!"); + throw new IllegalArgumentException("Fuel fluid was null or empty!"); + } +// else if (residue.getFluid() == null) + else if (residue.getFluid() == null || residue.getFluid() instanceof EmptyFluid) { +// throw new IllegalArgumentException("Residue fluid was null!"); + throw new IllegalArgumentException("Residue fluid was null or empty!"); + } +// else if (BuildcraftFuelRegistry.fuel.getFuel(fuel) != null) + else if (getAllRecipes().stream().anyMatch(r -> r.getFluid().equals(fuel))) { throw new IllegalArgumentException("The fluid " + fuel + " is already registered as a fuel!"); } - if (BuildcraftFuelRegistry.coolant.getCoolant(fuel) != null) { - throw new IllegalArgumentException( - "The fluid " + fuel - + " is already registered as a coolant - so it won't work very well if you add it as a fuel too!" - ); - } - if (powerPerTick <= 0) { +// else if (BuildcraftFuelRegistry.coolant.getCoolant(fuel) != null) + else if (Coolant.INSTANCE.getAllRecipes().stream().anyMatch(r -> r instanceof IFluidCoolant fluidCoolant && fluidCoolant.getFluid().equals(fuel))) { + throw new IllegalArgumentException("The fluid " + fuel + " is already registered as a coolant - so it won't work very well if you add it as a fuel too!"); + } else if (powerPerTick <= 0.0) { throw new IllegalArgumentException("Power was less than or equal to 0!"); + } else if (powerPerTick > 100000.0) { + throw new IllegalArgumentException("Maximum power is 100000.0, as any values above this would instantly bring the engine to overheat."); + } else { + long mj = (long) ((double) MjAPI.MJ * powerPerTick); +// CraftTweakerAPI.apply(new AddDirtyFuel(fuel, mj, timePerBucket, residue)); + CraftTweakerAPI.apply(AddDirtyFuel.create(this, name, fuel, mj, timePerBucket, residue)); } - if (powerPerTick > MAX_POWER) { - throw new IllegalArgumentException( - "Maximum power is " + MAX_POWER - + ", as any values above this would instantly bring the engine to overheat." + } + + @Override + public RecipeType getRecipeType() { + return IFuel.TYPE; + } + + @Override + public String dumpToCommandString(final IRecipeManager manager, IFuel recipe) { + if (recipe instanceof IFuelManager.IDirtyFuel dirtyFuel) { + return String.format( + "combustionEngine.addDirtyFuel(%s, %s, %s, %s, %s);", + StringUtil.quoteAndEscape(recipe.getId()), + StringUtil.quoteAndEscape(FluidUtilBC.getRegistryName(recipe.getFluid().getFluid())), + recipe.getPowerPerCycle(), + recipe.getTotalBurningTime(), + StringUtil.quoteAndEscape(FluidUtilBC.getRegistryName(dirtyFuel.getResidue().getFluid())) + ); + } else { + return String.format( + "combustionEngine.addCleanFuel(%s, %s, %s, %s);", + StringUtil.quoteAndEscape(recipe.getId()), + StringUtil.quoteAndEscape(FluidUtilBC.getRegistryName(recipe.getFluid().getFluid())), + recipe.getPowerPerCycle(), + recipe.getTotalBurningTime() ); } - long mj = (long) (MjAPI.MJ * powerPerTick); - CraftTweakerAPI.apply(new AddDirtyFuel(fuel, mj, timePerBucket, residue)); } - // @ZenMethod - // public static void addLiquidCoolant(FluidStack coolant) { - // - // } - // - // @ZenMethod - // public static void addSolidCoolant(ItemStack stack, FluidStack coolant) { - // - // } + @Override + public > boolean doesConflict(IRecipeManager iRecipeManager, IFuel fuel, U u) { + return u instanceof IFuel && ((IFuel) u).getFluid().getFluid() == fuel.getFluid().getFluid(); + } - // ###################### - // ### Action classes ### - // ###################### + @Override + public Optional decompose(IRecipeManager iRecipeManager, IFuel fuel) { + DecomposedRecipeBuilder builder = IDecomposedRecipe.builder(); + builder.with(BuiltinRecipeComponents.Input.FLUID_INGREDIENTS, new CTFluidIngredient.FluidStackIngredient(IFluidStack.of(fuel.getFluid()))); + if (fuel instanceof IFuelManager.IDirtyFuel dirtyFuel) { + builder.with(BuiltinRecipeComponents.Output.FLUIDS, IFluidStack.of(dirtyFuel.getResidue())); + } + builder.with(BuiltinRecipeComponents.Processing.TIME, fuel.getTotalBurningTime()); + builder.with(BCRecipeComponents.MJ, fuel.getPowerPerCycle() * fuel.getTotalBurningTime()); + return Optional.of(builder.build()); + } - static final class AddCleanFuel implements IAction { + @Override + public Optional recompose(IRecipeManager iRecipeManager, ResourceLocation id, IDecomposedRecipe iDecomposedRecipe) { + // input oil + CTFluidIngredient inputFluidIngredient = iDecomposedRecipe.getOrThrowSingle(BuiltinRecipeComponents.Input.FLUID_INGREDIENTS); + Optional inputOptional = CompatModuleCraftTweaker.ctFluidIngredient2SingleFluidStack(inputFluidIngredient); + if (inputOptional.isEmpty()) { + return Optional.empty(); + } + // totalBurningTime powerPerCycle + int totalBurningTime = iDecomposedRecipe.getOrThrowSingle(BuiltinRecipeComponents.Processing.TIME); + long mj = iDecomposedRecipe.getOrThrowSingle(BCRecipeComponents.MJ); + long powerPerCycle = mj / totalBurningTime; + // output residue + List outputFluidStacks = iDecomposedRecipe.get(BuiltinRecipeComponents.Output.FLUIDS); + Optional outputOptional = CompatModuleCraftTweaker.iFluidStack2SingleFluidStack(outputFluidStacks); + if (outputOptional.isEmpty()) { + FuelRegistry.Fuel fuel = new FuelRegistry.Fuel(id, inputOptional.get(), powerPerCycle, totalBurningTime); + return Optional.of(fuel); + } else { + FuelRegistry.DirtyFuel dirtyFuel = new FuelRegistry.DirtyFuel(id, inputOptional.get(), powerPerCycle, totalBurningTime, outputOptional.get()); + return Optional.of(dirtyFuel); + } + } - private final FluidStack fluid; - private final long powerPerTick; - private final int totalBurningTime; + // static final class AddDirtyFuel implements IAction + static final class AddDirtyFuel extends ActionAddRecipe { +// private final FluidStack fuel; +// private final FluidStack residue; +// private final long powerPerTick; +// private final int totalBurningTime; - public AddCleanFuel(FluidStack fluid, long powerPerCycle, int totalBurningTime) { - this.fluid = fluid; - this.powerPerTick = powerPerCycle; - this.totalBurningTime = totalBurningTime; + // public AddDirtyFuel(FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) + private AddDirtyFuel(IRecipeManager manager, IFuel recipe) { + super(manager, recipe); +// this.fuel = fuel; +// this.powerPerTick = powerPerCycle; +// this.totalBurningTime = totalBurningTime; +// this.residue = residue; } - @Override - public void apply() { - BuildcraftFuelRegistry.fuel.addFuel(fluid, powerPerTick, totalBurningTime); + // Calen + public static AddDirtyFuel create(IRecipeManager manager, String name, FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) { + ResourceLocation _name = new ResourceLocation("crafttweaker", name); + return new AddDirtyFuel(manager, new FuelRegistry.DirtyFuel(_name, fuel, powerPerCycle, totalBurningTime, residue)); } - @Override +// public void apply() { +// BuildcraftFuelRegistry.fuel.addDirtyFuel(this.fuel, this.powerPerTick, this.totalBurningTime, this.residue); +// } + public String describe() { - return "Adding combustion engine fuel " + fluid; +// return "Adding combustion engine fuel " + this.fuel; + return "Adding combustion engine fuel " + this.recipe.getFluid(); } } - static final class AddDirtyFuel implements IAction { - - private final FluidStack fuel, residue; - private final long powerPerTick; - private final int totalBurningTime; + // static final class AddCleanFuel implements IAction + static final class AddCleanFuel extends ActionAddRecipe { +// private final FluidStack fluid; +// private final long powerPerTick; +// private final int totalBurningTime; - public AddDirtyFuel(FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) { - this.fuel = fuel; - this.powerPerTick = powerPerCycle; - this.totalBurningTime = totalBurningTime; - this.residue = residue; + // public AddCleanFuel(FluidStack fluid, long powerPerCycle, int totalBurningTime) + public AddCleanFuel(IRecipeManager manager, IFuel recipe) { + super(manager, recipe); +// this.fluid = fluid; +// this.powerPerTick = powerPerCycle; +// this.totalBurningTime = totalBurningTime; } - @Override - public void apply() { - BuildcraftFuelRegistry.fuel.addDirtyFuel(fuel, powerPerTick, totalBurningTime, residue); + // Calen + public static AddCleanFuel create(IRecipeManager manager, String name, FluidStack fluid, long powerPerCycle, int totalBurningTime) { + ResourceLocation _name = new ResourceLocation("crafttweaker", name); + return new AddCleanFuel(manager, new FuelRegistry.Fuel(_name, fluid, powerPerCycle, totalBurningTime)); } - @Override +// public void apply() { +// BuildcraftFuelRegistry.fuel.addFuel(this.fluid, this.powerPerTick, this.totalBurningTime); +// } + public String describe() { - return "Adding combustion engine fuel " + fuel; +// return "Adding combustion engine fuel " + this.fluid; + return "Adding combustion engine fuel " + this.recipe.getFluid(); } } - - // static final class AddLiquidCoolant implements IAction { - // - // } - // - // static final class AddSolidCoolant implements IAction { - // - // } } diff --git a/common/buildcraft/compat/module/crafttweaker/CompatModuleCraftTweaker.java b/common/buildcraft/compat/module/crafttweaker/CompatModuleCraftTweaker.java index 7e93009..586d093 100644 --- a/common/buildcraft/compat/module/crafttweaker/CompatModuleCraftTweaker.java +++ b/common/buildcraft/compat/module/crafttweaker/CompatModuleCraftTweaker.java @@ -1,18 +1,38 @@ package buildcraft.compat.module.crafttweaker; import buildcraft.compat.CompatModuleBase; +import com.blamejared.crafttweaker.api.fluid.CTFluidIngredient; +import com.blamejared.crafttweaker.api.fluid.IFluidStack; +import net.minecraftforge.fluids.FluidStack; -import crafttweaker.CraftTweakerAPI; +import java.util.List; +import java.util.Optional; public class CompatModuleCraftTweaker extends CompatModuleBase { - @Override + public CompatModuleCraftTweaker() { + } + public String compatModId() { return "crafttweaker"; } - @Override public void preInit() { - CraftTweakerAPI.registerClass(AssemblyTable.class); - CraftTweakerAPI.registerClass(CombustionEngine.class); +// CraftTweakerAPI.registerClass(AssemblyTable.class); +// CraftTweakerAPI.getRegistry()..registerClass(AssemblyTable.class); +// CraftTweakerAPI.registerClass(CombustionEngine.class); + } + + public static Optional ctFluidIngredient2SingleFluidStack(CTFluidIngredient fluidIngredient) { + List fluidStacks = fluidIngredient.getMatchingStacks(); + return iFluidStack2SingleFluidStack(fluidStacks); + } + + public static Optional iFluidStack2SingleFluidStack(List fluidStacks) { + if (!fluidStacks.isEmpty()) { + IFluidStack ctFluidStack = fluidStacks.get(0); + FluidStack fluidStack = ctFluidStack.getInternal(); + return Optional.of(fluidStack); + } + return Optional.empty(); } } diff --git a/common/buildcraft/compat/module/crafttweaker/Coolant.java b/common/buildcraft/compat/module/crafttweaker/Coolant.java new file mode 100644 index 0000000..6133e68 --- /dev/null +++ b/common/buildcraft/compat/module/crafttweaker/Coolant.java @@ -0,0 +1,185 @@ +package buildcraft.compat.module.crafttweaker; + +import buildcraft.api.fuels.ICoolant; +import buildcraft.api.fuels.IFluidCoolant; +import buildcraft.api.fuels.ISolidCoolant; +import buildcraft.lib.misc.FluidUtilBC; +import buildcraft.lib.recipe.coolant.CoolantRegistry; +import com.blamejared.crafttweaker.api.CraftTweakerAPI; +import com.blamejared.crafttweaker.api.action.recipe.ActionAddRecipe; +import com.blamejared.crafttweaker.api.annotation.ZenRegister; +import com.blamejared.crafttweaker.api.fluid.CTFluidIngredient; +import com.blamejared.crafttweaker.api.fluid.IFluidStack; +import com.blamejared.crafttweaker.api.item.IItemStack; +import com.blamejared.crafttweaker.api.recipe.component.BuiltinRecipeComponents; +import com.blamejared.crafttweaker.api.recipe.component.DecomposedRecipeBuilder; +import com.blamejared.crafttweaker.api.recipe.component.IDecomposedRecipe; +import com.blamejared.crafttweaker.api.recipe.handler.IRecipeHandler; +import com.blamejared.crafttweaker.api.recipe.manager.base.IRecipeManager; +import com.blamejared.crafttweaker.api.util.ItemStackUtil; +import com.blamejared.crafttweaker.api.util.StringUtil; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.material.EmptyFluid; +import net.minecraftforge.fluids.FluidStack; +import org.openzen.zencode.java.ZenCodeGlobals; +import org.openzen.zencode.java.ZenCodeType; + +import java.util.Optional; + +@ZenRegister +@ZenCodeType.Name("mods.buildcraft.Coolant") +@IRecipeHandler.For(ICoolant.class) +public enum Coolant implements IRecipeManager, IRecipeHandler { + @ZenCodeGlobals.Global("coolant") + INSTANCE; + + @ZenCodeType.Method + public void addFluidCoolant(String name, IFluidStack liquid, float degreesCoolingPerMB) { + addFluidCoolant0("custom/" + name, liquid, degreesCoolingPerMB); + } + + private void addFluidCoolant0(String name, IFluidStack liquid, float degreesCoolingPerMB) { + FluidStack fluid = liquid.getImmutableInternal(); + if (fluid == null) { + throw new IllegalArgumentException("Fluid was null!"); + } else if (getAllRecipes().stream().anyMatch(r -> r instanceof IFluidCoolant fluidCoolant && fluidCoolant.getFluid().equals(fluid))) { + throw new IllegalArgumentException("The fluid " + fluid + " is already registered as a coolant!"); + } else if (CombustionEngine.INSTANCE.getAllRecipes().stream().anyMatch(r -> r.getFluid().equals(fluid))) { + throw new IllegalArgumentException("The fluid " + fluid + " is already registered as a fuel - so it won't work very well if you add it as a coolant too!"); + } else if (degreesCoolingPerMB <= 0.0) { + throw new IllegalArgumentException("Degrees cooling per MB was less than or equal to 0!"); + } else { + CraftTweakerAPI.apply(AddFluidCoolant.create(this, name, fluid, degreesCoolingPerMB)); + } + } + + // @ZenMethod + @ZenCodeType.Method + public void addSolidCoolant(String name, IItemStack item, IFluidStack lFuel, float multiplier) { + addSolidCoolant0("custom/" + name, item, lFuel, multiplier); + } + + private void addSolidCoolant0(String name, IItemStack itemIn, IFluidStack fluidIn, float multiplier) { + ItemStack item = itemIn.getImmutableInternal(); + FluidStack fluid = fluidIn.getImmutableInternal(); + if (item.getItem() == Items.AIR) { + throw new IllegalArgumentException("Coolant item was air!"); + } else if (fluid.getFluid() == null || fluid.getFluid() instanceof EmptyFluid) { + throw new IllegalArgumentException("Fluid was null or empty!"); + } else if (getAllRecipes().stream().anyMatch(r -> r instanceof ISolidCoolant solidCoolant && solidCoolant.getSolid().equals(item))) { + throw new IllegalArgumentException("The item " + item + " is already registered as a coolant!"); + } else if (multiplier <= 0.0) { + throw new IllegalArgumentException("Multiplier was less than or equal to 0!"); + } else { + CraftTweakerAPI.apply(AddSolidCoolant.create(this, name, item, fluid, multiplier)); + } + } + + @Override + public RecipeType getRecipeType() { + return ICoolant.TYPE; + } + + @Override + public String dumpToCommandString(final IRecipeManager manager, ICoolant recipe) { + if (recipe instanceof IFluidCoolant fluidCoolant) { + return String.format( + "coolant.addFluidCoolant(%s, %s, %s);", + StringUtil.quoteAndEscape(recipe.getId()), + StringUtil.quoteAndEscape(FluidUtilBC.getRegistryName(recipe.getFluid().getFluid())), + fluidCoolant.getDegreesCoolingPerMB() + ); + } else if (recipe instanceof ISolidCoolant solidCoolant) { + return String.format( + "coolant.addSolidCoolant(%s, %s, %s, %s);", + StringUtil.quoteAndEscape(recipe.getId()), + ItemStackUtil.getCommandString(solidCoolant.getSolid()), + StringUtil.quoteAndEscape(FluidUtilBC.getRegistryName(recipe.getFluid().getFluid())), + solidCoolant.getMultiplier() + ); + } + return "This is not a fluid coolant or a solid coolant. What happened?"; + } + + @Override + public > boolean doesConflict(IRecipeManager iRecipeManager, ICoolant coolant, U u) { + if (coolant instanceof IFluidCoolant && u instanceof IFluidCoolant) { + return coolant.getFluid().getFluid() == ((IFluidCoolant) u).getFluid().getFluid(); + } else if (coolant instanceof ISolidCoolant && u instanceof ISolidCoolant) { + return ((ISolidCoolant) coolant).getSolid().getItem() == ((ISolidCoolant) u).getSolid().getItem(); + } else { + return false; + } + } + + @Override + public Optional decompose(IRecipeManager iRecipeManager, ICoolant coolant) { + DecomposedRecipeBuilder builder = IDecomposedRecipe.builder(); + if (coolant instanceof IFluidCoolant) { + builder.with(BuiltinRecipeComponents.Input.FLUID_INGREDIENTS, new CTFluidIngredient.FluidStackIngredient(IFluidStack.of(coolant.getFluid()))); + builder.with(BCRecipeComponents.DEGREES_COOLING_PER_MB, ((IFluidCoolant) coolant).getDegreesCoolingPerMB()); + } else if (coolant instanceof ISolidCoolant) { + builder.with(BuiltinRecipeComponents.Input.FLUID_INGREDIENTS, new CTFluidIngredient.FluidStackIngredient(IFluidStack.of(coolant.getFluid()))); + builder.with(BCRecipeComponents.ITEM_STACK, ((ISolidCoolant) coolant).getSolid()); + builder.with(BCRecipeComponents.MULTIPLIER, ((ISolidCoolant) coolant).getMultiplier()); + } else { + return Optional.empty(); + } + return Optional.of(builder.build()); + } + + @Override + public Optional recompose(IRecipeManager iRecipeManager, ResourceLocation id, IDecomposedRecipe iDecomposedRecipe) { + if (!iDecomposedRecipe.get(BCRecipeComponents.DEGREES_COOLING_PER_MB).isEmpty()) { + // IFluidCoolant + Optional fluidOptional = CompatModuleCraftTweaker.ctFluidIngredient2SingleFluidStack(iDecomposedRecipe.getOrThrowSingle(BuiltinRecipeComponents.Input.FLUID_INGREDIENTS)); + if (fluidOptional.isEmpty()) { + return Optional.empty(); + } + FluidStack fluid = fluidOptional.get(); + float degreesCoolingPerMB = iDecomposedRecipe.getOrThrowSingle(BCRecipeComponents.DEGREES_COOLING_PER_MB); + return Optional.of(new CoolantRegistry.FluidCoolant(id, fluid, degreesCoolingPerMB)); + } else if (!iDecomposedRecipe.get(BCRecipeComponents.MULTIPLIER).isEmpty()) { + ItemStack solid = iDecomposedRecipe.getOrThrowSingle(BCRecipeComponents.ITEM_STACK); + FluidStack fluid = iDecomposedRecipe.getOrThrowSingle(BuiltinRecipeComponents.Input.FLUID_INGREDIENTS).getMatchingStacks().get(0).getInternal(); + float multiplier = iDecomposedRecipe.getOrThrowSingle(BCRecipeComponents.MULTIPLIER); + return Optional.of(new CoolantRegistry.SolidCoolant(id, solid, fluid, multiplier)); + } else { + return Optional.empty(); + } + } + + static final class AddFluidCoolant extends ActionAddRecipe { + private AddFluidCoolant(IRecipeManager manager, IFluidCoolant recipe) { + super(manager, recipe); + } + + public static AddFluidCoolant create(IRecipeManager manager, String name, FluidStack fluid, float degreesCoolingPerMB) { + ResourceLocation _name = new ResourceLocation("crafttweaker", name); + return new AddFluidCoolant(manager, new CoolantRegistry.FluidCoolant(_name, fluid, degreesCoolingPerMB)); + } + + public String describe() { + return "Adding combustion engine coolant " + this.recipe.getFluid(); + } + } + + static final class AddSolidCoolant extends ActionAddRecipe { + public AddSolidCoolant(IRecipeManager manager, ISolidCoolant recipe) { + super(manager, recipe); + } + + public static AddSolidCoolant create(IRecipeManager manager, String name, ItemStack item, FluidStack fluid, float multiplier) { + ResourceLocation _name = new ResourceLocation("crafttweaker", name); + return new AddSolidCoolant(manager, new CoolantRegistry.SolidCoolant(_name, item, fluid, multiplier)); + } + + public String describe() { + return "Adding combustion engine coolant " + ((ISolidCoolant) this.recipe).getSolid(); + } + } +} diff --git a/common/buildcraft/compat/module/forestry/CompatModuleForestry.java b/common/buildcraft/compat/module/forestry/CompatModuleForestry.java deleted file mode 100644 index 622aca4..0000000 --- a/common/buildcraft/compat/module/forestry/CompatModuleForestry.java +++ /dev/null @@ -1,39 +0,0 @@ -package buildcraft.compat.module.forestry; - -import buildcraft.api.BCModules; -import buildcraft.api.core.BCLog; -import buildcraft.api.lists.ListRegistry; - -import buildcraft.compat.CompatModuleBase; -import buildcraft.compat.module.forestry.list.ListMatchGenome; -import buildcraft.compat.module.forestry.pipe.ForestryPipes; - -public class CompatModuleForestry extends CompatModuleBase { - @Override - public String compatModId() { - return "forestry"; - } - - @Override - public void preInit() { - ListRegistry.registerHandler(new ListMatchGenome()); - if (canLoadPropolisPipe()) { - ForestryPipes.preInit(); - } - } - - private static boolean canLoadPropolisPipe() { - if (!BCModules.TRANSPORT.isLoaded()) { - return false; - } - try { - // Ensure that forestry is up-to-date - Class.forName("forestry.sorting.tiles.IFilterContainer"); - return true; - } catch (ClassNotFoundException ignored) { - BCLog.logger.warn( - "[compat.forestry] IFilterContainer not found -- forestry must be updated to add the propolis pipe!"); - return false; - } - } -} diff --git a/common/buildcraft/compat/module/forestry/list/ListMatchGenome.java b/common/buildcraft/compat/module/forestry/list/ListMatchGenome.java deleted file mode 100644 index 7b9e247..0000000 --- a/common/buildcraft/compat/module/forestry/list/ListMatchGenome.java +++ /dev/null @@ -1,93 +0,0 @@ -package buildcraft.compat.module.forestry.list; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - -import buildcraft.api.lists.ListMatchHandler; - -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAlleleSpecies; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.ISpeciesRoot; - -public class ListMatchGenome extends ListMatchHandler { - - @Override - public boolean matches(Type type, ItemStack compare, ItemStack target, boolean precise) { - IIndividual infoCompare = AlleleManager.alleleRegistry.getIndividual(compare); - IIndividual infoTarget = AlleleManager.alleleRegistry.getIndividual(target); - if (infoCompare == null || infoTarget == null) { - return false; - } - switch (type) { - case MATERIAL: { - return matchesMaterial(compare, target, infoCompare, infoTarget, precise); - } - case TYPE: { - return matchesType(compare, target, infoCompare, infoTarget, precise); - } - case CLASS: { - return matchesMaterial(compare, target, infoCompare, infoTarget, precise) - && matchesType(compare, target, infoCompare, infoTarget, precise); - } - default: { - throw new IllegalArgumentException("Unknown type " + type); - } - } - } - - private static boolean matchesMaterial(ItemStack compare, ItemStack target, IIndividual infoCompare, - IIndividual infoTarget, boolean precise) { - // Ensures that both individuals have the same species - // If precise is true then also ensure that the secondary species is the same - IAlleleSpecies speciesCompare = infoCompare.getGenome().getPrimary(); - IAlleleSpecies speciesTarget = infoTarget.getGenome().getPrimary(); - if (speciesCompare != speciesTarget) { - return false; - } - if (precise) { - IAlleleSpecies inactiveCompare = infoCompare.getGenome().getSecondary(); - IAlleleSpecies inactiveTarget = infoTarget.getGenome().getSecondary(); - if (inactiveCompare != inactiveTarget) { - return false; - } - } - return true; - } - - private static boolean matchesType(ItemStack compare, ItemStack target, IIndividual infoCompare, - IIndividual infoTarget, boolean precise) { - ISpeciesRoot speciesRootCompare = infoCompare.getGenome().getSpeciesRoot(); - ISpeciesRoot speciesRootTarget = infoTarget.getGenome().getSpeciesRoot(); - if (speciesRootCompare != speciesRootTarget) { - return false; - } - // Ensure that both fully match (both princesses or both drones etc) - if (speciesRootCompare.getType(compare) != speciesRootTarget.getType(target)) { - return false; - } - return true; - } - - @Override - public boolean isValidSource(Type type, @Nonnull ItemStack stack) { - return AlleleManager.alleleRegistry.getIndividual(stack) != null; - } - - @Override - @Nullable - public NonNullList getClientExamples(Type type, @Nonnull ItemStack stack) { - IIndividual individual = AlleleManager.alleleRegistry.getIndividual(stack); - if (individual == null) { - return null; - } - - NonNullList list = NonNullList.create(); - boolean isType = type != Type.MATERIAL; - boolean isMaterial = type != Type.TYPE; - return list; - } -} diff --git a/common/buildcraft/compat/module/forestry/pipe/ContainerPropolisPipe.java b/common/buildcraft/compat/module/forestry/pipe/ContainerPropolisPipe.java deleted file mode 100644 index 1460eff..0000000 --- a/common/buildcraft/compat/module/forestry/pipe/ContainerPropolisPipe.java +++ /dev/null @@ -1,22 +0,0 @@ -package buildcraft.compat.module.forestry.pipe; - -import net.minecraft.entity.player.EntityPlayer; - -import forestry.sorting.gui.ContainerGeneticFilter; - -public class ContainerPropolisPipe extends ContainerGeneticFilter { - - public final PipeBehaviourPropolis pipeBehaviour; - - public ContainerPropolisPipe(PipeBehaviourPropolis behaviour, EntityPlayer player) { - super(behaviour, player.inventory); - this.pipeBehaviour = behaviour; - behaviour.pipe.getHolder().onPlayerOpen(player); - } - - @Override - public void onContainerClosed(EntityPlayer player) { - super.onContainerClosed(player); - pipeBehaviour.pipe.getHolder().onPlayerClose(player); - } -} diff --git a/common/buildcraft/compat/module/forestry/pipe/ForestryPipes.java b/common/buildcraft/compat/module/forestry/pipe/ForestryPipes.java deleted file mode 100644 index cab9d26..0000000 --- a/common/buildcraft/compat/module/forestry/pipe/ForestryPipes.java +++ /dev/null @@ -1,86 +0,0 @@ -package buildcraft.compat.module.forestry.pipe; - -import net.minecraft.init.Items; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.oredict.ShapedOreRecipe; - -import buildcraft.api.transport.pipe.PipeApi; -import buildcraft.api.transport.pipe.PipeDefinition; -import buildcraft.api.transport.pipe.PipeDefinition.PipeDefinitionBuilder; - -import buildcraft.lib.misc.ColourUtil; -import buildcraft.lib.registry.CreativeTabManager; - -public class ForestryPipes { - - public static Item pipeItemPropolis; - public static PipeDefinition pipeDefinitionPropolis; - - public static void preInit() { - MinecraftForge.EVENT_BUS.register(ForestryPipes.class); - - String[] textureSuffixes = new String[8]; - textureSuffixes[0] = ""; - textureSuffixes[7] = "_itemstack"; - for (EnumFacing face : EnumFacing.VALUES) { - textureSuffixes[face.ordinal() + 1] = "_" + face.getName(); - } - - pipeDefinitionPropolis = new PipeDefinitionBuilder()// - .id("forestry_propolis")// Note: id() automatically sets the namespace to "buildcraftcompat" - .texPrefix("propolis")// - .texSuffixes(textureSuffixes)// - .logic(PipeBehaviourPropolis::new, PipeBehaviourPropolis::new)// - .flowItem()// - .define(); - - PipeApi.pipeRegistry.createUnnamedItemForPipe(pipeDefinitionPropolis, item -> { - pipeItemPropolis = item; - item.setRegistryName("pipe_item_propolis"); - item.setUnlocalizedName("buildcraftPipe.pipeitemspropolis"); - item.setCreativeTab(CreativeTabManager.getTab("buildcraft.pipes")); - }); - } - - @SubscribeEvent - public static void registerRecipes(RegistryEvent.Register event) { - Item propolis = ForgeRegistries.ITEMS.getValue(new ResourceLocation("forestry:propolis")); - if (propolis != null && propolis != Items.AIR) { - addPipeRecipe(pipeItemPropolis, propolis, Items.DIAMOND); - } - } - - private static void addPipeRecipe(Item pipe, Object surround) { - addPipeRecipe(pipe, surround, surround); - } - - private static void addPipeRecipe(Item pipe, Object left, Object right) { - // Copied directly from BCTransportRecipes - if (pipe == null) { - return; - } - ItemStack result = new ItemStack(pipe, 8); - IRecipe recipe = new ShapedOreRecipe(pipe.getRegistryName(), result, "lgr", 'l', left, 'r', right, 'g', - "blockGlassColorless"); - recipe.setRegistryName(new ResourceLocation(pipe.getRegistryName() + "_colorless")); - ForgeRegistries.RECIPES.register(recipe); - - for (EnumDyeColor colour : EnumDyeColor.values()) { - ItemStack resultStack = new ItemStack(pipe, 8, colour.getMetadata() + 1); - IRecipe colorRecipe = new ShapedOreRecipe(pipe.getRegistryName(), resultStack, "lgr", 'l', left, 'r', right, - 'g', "blockGlass" + ColourUtil.getName(colour)); - colorRecipe.setRegistryName(new ResourceLocation(pipe.getRegistryName() + "_" + colour)); - ForgeRegistries.RECIPES.register(colorRecipe); - } - } -} diff --git a/common/buildcraft/compat/module/forestry/pipe/PipeBehaviourPropolis.java b/common/buildcraft/compat/module/forestry/pipe/PipeBehaviourPropolis.java deleted file mode 100644 index def558a..0000000 --- a/common/buildcraft/compat/module/forestry/pipe/PipeBehaviourPropolis.java +++ /dev/null @@ -1,196 +0,0 @@ -package buildcraft.compat.module.forestry.pipe; - -import java.io.IOException; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import buildcraft.api.core.EnumPipePart; -import buildcraft.api.transport.pipe.IPipe; -import buildcraft.api.transport.pipe.PipeBehaviour; -import buildcraft.api.transport.pipe.PipeEventHandler; -import buildcraft.api.transport.pipe.PipeEventItem; - -import buildcraft.lib.cap.CapabilityHelper; - -import buildcraft.compat.CompatUtils; -import buildcraft.compat.network.CompatGui; -import buildcraft.compat.network.IGuiCreator; - -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.GeneticCapabilities; -import forestry.api.genetics.IFilterLogic; -import forestry.api.genetics.IFilterLogic.INetworkHandler; -import forestry.sorting.DefaultFilterRuleType; -import forestry.sorting.gui.ContainerGeneticFilter; -import forestry.sorting.gui.GuiGeneticFilter; -import forestry.sorting.tiles.IFilterContainer; - -public class PipeBehaviourPropolis extends PipeBehaviour implements IFilterContainer, INetworkHandler, IGuiCreator { - - private final CapabilityHelper caps = new CapabilityHelper(); - private final IFilterLogic filter = AlleleManager.filterRegistry.createLogic(this, this); - - { - caps.addCapabilityInstance(GeneticCapabilities.FILTER_LOGIC, filter, EnumPipePart.VALUES); - caps.addCapabilityInstance(CompatUtils.CAP_GUI_CREATOR, this, EnumPipePart.CENTER); - } - - public PipeBehaviourPropolis(IPipe pipe) { - super(pipe); - } - - public PipeBehaviourPropolis(IPipe pipe, NBTTagCompound nbt) { - super(pipe, nbt); - filter.readFromNBT(nbt.getCompoundTag("filter")); - } - - @Override - public NBTTagCompound writeToNbt() { - NBTTagCompound nbt = super.writeToNbt(); - nbt.setTag("filter", filter.writeToNBT(new NBTTagCompound())); - return nbt; - } - - @Override - public void readPayload(PacketBuffer buffer, Side side, MessageContext ctx) throws IOException { - super.readPayload(buffer, side, ctx); - if (side == Side.CLIENT) { - filter.readGuiData(buffer); - } - } - - @Override - public void writePayload(PacketBuffer buffer, Side side) { - super.writePayload(buffer, side); - if (side == Side.SERVER) { - // FIXME: Inefficient to be sending gui updates all the time - // but fixing this requires proper fixes throughout the net code :/ - filter.writeGuiData(buffer); - } - } - - @Override - public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - T value = caps.getCapability(capability, facing); - if (value != null) { - return value; - } - return super.getCapability(capability, facing); - } - - @Override - public int getTextureIndex(EnumFacing face) { - return face == null ? 0 : face.ordinal() + 1; - } - - @Override - public boolean onPipeActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ, - EnumPipePart part) { - if (!getWorldObj().isRemote) { - // TODO: Properly abstract this in to make GUI's a bit more sane! - CompatGui.FORESTRY_PROPOLIS_PIPE.openGui(player, pipe.getHolder().getPipePos()); - // sendUpdatePacket(ImmutableList.of()); - } - return true; - } - - @PipeEventHandler - public void sideCheck(PipeEventItem.SideCheck event) { - ItemStack stack = event.stack; - for (EnumFacing face : EnumFacing.VALUES) { - if (!filter.isValid(stack, face)) { - event.disallow(face); - } else if (filter.getRule(face) == DefaultFilterRuleType.ANYTHING) { - event.decreasePriority(face); - } - } - } - - // IFilterContainer - - @Override - public BlockPos getCoordinates() { - return pipe.getHolder().getPipePos(); - } - - @Override - public World getWorldObj() { - return pipe.getHolder().getPipeWorld(); - } - - @Override - public String getUnlocalizedTitle() { - return ForestryPipes.pipeItemPropolis.getUnlocalizedName() + ".name"; - } - - @Override - @Nullable - public IInventory getBuffer() { - return null; - } - - @Override - public TileEntity getTileEntity() { - return pipe.getHolder().getPipeTile(); - } - - @Override - public IFilterLogic getLogic() { - return filter; - } - - // INetworkHandler - - @Override - public void sendToPlayers(IFilterLogic logic, WorldServer server, EntityPlayer currentPlayer) { - for (EntityPlayer player : server.playerEntities) { - if (player != currentPlayer && player.openContainer instanceof ContainerGeneticFilter) { - ContainerGeneticFilter currentContainer = (ContainerGeneticFilter) currentPlayer.openContainer; - ContainerGeneticFilter otherContainer = (ContainerGeneticFilter) player.openContainer; - if (otherContainer.hasSameTile(currentContainer)) { - otherContainer.setGuiNeedsUpdate(true); - } - } - } - } - - // IGuiCreator - - @Override - public Enum getGuiType() { - return CompatGui.FORESTRY_PROPOLIS_PIPE; - } - - @Override - @Nullable - public Container getServerGuiElement(int data, EntityPlayer player) { - return new ContainerPropolisPipe(this, player); - } - - @Override - @Nullable - @SideOnly(Side.CLIENT) - public GuiContainer getClientGuiElement(int data, EntityPlayer player) { - return new GuiGeneticFilter(this, player.inventory); - } -} diff --git a/common/buildcraft/compat/module/ic2/CompatModuleIndustrialCraft2.java b/common/buildcraft/compat/module/ic2/CompatModuleIndustrialCraft2.java index 01c782d..bd441c6 100644 --- a/common/buildcraft/compat/module/ic2/CompatModuleIndustrialCraft2.java +++ b/common/buildcraft/compat/module/ic2/CompatModuleIndustrialCraft2.java @@ -1,37 +1,32 @@ -/* - * Copyright (c) 2020 SpaceToad and the BuildCraft team - * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not - * distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/ - */ - package buildcraft.compat.module.ic2; -import net.minecraft.item.Item; - import buildcraft.compat.CompatModuleBase; - import buildcraft.lib.misc.StackMatchingPredicate; import buildcraft.lib.misc.StackNbtMatcher; import buildcraft.lib.misc.StackUtil; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraftforge.registries.ForgeRegistries; public class CompatModuleIndustrialCraft2 extends CompatModuleBase { - @Override + public CompatModuleIndustrialCraft2() { + } + public String compatModId() { return "ic2"; } - @Override public void preInit() { - registerCableMatchingPredicate(); + this.registerCableMatchingPredicate(); } private void registerCableMatchingPredicate() { - // Distinguish cables by type and insulation - // https://github.com/BuildCraft/BuildCraft/issues/4553 - Item cable = Item.getByNameOrId("ic2:cable"); +// Item cable = Item.func_111206_d("ic2:cable"); + Item cable = ForgeRegistries.ITEMS.getValue(new ResourceLocation("ic2:cable")); if (cable != null) { - StackMatchingPredicate predicate = new StackNbtMatcher("insulation", "type"); + StackMatchingPredicate predicate = new StackNbtMatcher(new String[] { "insulation", "type" }); StackUtil.registerMatchingPredicate(cable, predicate); } + } } diff --git a/common/buildcraft/compat/module/jei/BCPluginJEI.java b/common/buildcraft/compat/module/jei/BCPluginJEI.java index f31d176..5416030 100644 --- a/common/buildcraft/compat/module/jei/BCPluginJEI.java +++ b/common/buildcraft/compat/module/jei/BCPluginJEI.java @@ -1,150 +1,260 @@ package buildcraft.compat.module.jei; -import java.util.Arrays; -import java.util.List; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.common.Loader; - -import buildcraft.api.BCBlocks; import buildcraft.api.BCModules; import buildcraft.api.core.BCLog; import buildcraft.api.enums.EnumEngineType; import buildcraft.api.fuels.IFuel; -import buildcraft.api.recipes.AssemblyRecipeBasic; -import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import buildcraft.api.recipes.IProgrammingRecipe; import buildcraft.api.recipes.IRefineryRecipeManager; - -import buildcraft.lib.fluid.FuelRegistry; -import buildcraft.lib.recipe.AssemblyRecipeRegistry; - +import buildcraft.api.recipes.IntegrationRecipe; +import buildcraft.compat.BCCompatConfig; import buildcraft.compat.module.jei.energy.combustionengine.CategoryCombustionEngine; -import buildcraft.compat.module.jei.energy.combustionengine.HandlerCombustionEngine; import buildcraft.compat.module.jei.factory.CategoryCoolable; import buildcraft.compat.module.jei.factory.CategoryDistiller; import buildcraft.compat.module.jei.factory.CategoryHeatable; -import buildcraft.compat.module.jei.factory.HandlerCoolable; -import buildcraft.compat.module.jei.factory.HandlerDistiller; -import buildcraft.compat.module.jei.factory.HandlerHeatable; -import buildcraft.compat.module.jei.recipe.GuiHandlerBuildCraft; +import buildcraft.compat.module.jei.gui.GuiGhostIngredientHandlerBuildCraft; +import buildcraft.compat.module.jei.gui.GuiHandlerBuildCraft; import buildcraft.compat.module.jei.silicon.CategoryAssemblyTable; -import buildcraft.compat.module.jei.silicon.WrapperAssemblyTable; +import buildcraft.compat.module.jei.silicon.CategoryIntegrationTable; +import buildcraft.compat.module.jei.silicon.CategoryProgrammingTable; import buildcraft.compat.module.jei.transferhandlers.AdvancedCraftingItemsTransferHandler; import buildcraft.compat.module.jei.transferhandlers.AutoCraftItemsTransferHandler; import buildcraft.core.BCCoreBlocks; +import buildcraft.factory.BCFactoryBlocks; +import buildcraft.lib.BCLibItems; +import buildcraft.lib.gui.GuiBC8; +import buildcraft.lib.item.ItemGuide; +import buildcraft.lib.misc.ColourUtil; +import buildcraft.lib.recipe.assembly.AssemblyRecipe; +import buildcraft.lib.recipe.assembly.AssemblyRecipeRegistry; +import buildcraft.lib.recipe.fuel.FuelRegistry; +import buildcraft.lib.recipe.programming.ProgrammingRecipeManager; +import buildcraft.silicon.BCSiliconBlocks; +import buildcraft.silicon.BCSiliconItems; +import buildcraft.silicon.BCSiliconMenuTypes; import buildcraft.silicon.container.ContainerAssemblyTable; - -import mezz.jei.api.IGuiHelper; +import buildcraft.silicon.container.ContainerIntegrationTable; +import buildcraft.silicon.container.ContainerProgrammingTable_Neptune; +import buildcraft.transport.BCTransportItems; +import buildcraft.transport.pipe.PipeRegistry; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import mezz.jei.api.IModPlugin; -import mezz.jei.api.IModRegistry; -import mezz.jei.api.JEIPlugin; -import mezz.jei.api.recipe.IRecipeCategoryRegistration; -import mezz.jei.api.recipe.VanillaRecipeCategoryUid; +import mezz.jei.api.JeiPlugin; +import mezz.jei.api.constants.RecipeTypes; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.category.IRecipeCategory; +import mezz.jei.api.registration.*; +import mezz.jei.api.runtime.IJeiRuntime; +import net.minecraft.client.Minecraft; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.fml.ModList; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; -@JEIPlugin +@JeiPlugin public class BCPluginJEI implements IModPlugin { - // public static boolean disableFacadeJEI; - public static IModRegistry registry; + // public static IModRegistry registry; + public static IRecipeRegistration registryRecipe; + public static IGuiHandlerRegistration registryGui; + public static IRecipeTransferRegistration registryRecipeTransfer; + public static IRecipeCatalystRegistration registryRecipeCatalyst; + public static IJeiRuntime jeiRuntime; + + private static final ResourceLocation UID = new ResourceLocation("buildcraft:jei_plugin"); + + @Override + public ResourceLocation getPluginUid() { + return UID; + } + @Override - public void register(IModRegistry registry) { - BCPluginJEI.registry = registry; - registry.addAdvancedGuiHandlers(new GuiHandlerBuildCraft()); -// boolean transport = BCModules.TRANSPORT.isLoaded(); + public void registerGuiHandlers(IGuiHandlerRegistration registry) { + BCPluginJEI.registryGui = registry; + registry.addGenericGuiContainerHandler(GuiBC8.class, new GuiHandlerBuildCraft()); + registry.addGhostIngredientHandler(GuiBC8.class, new GuiGhostIngredientHandlerBuildCraft()); + } + + // Calen: IRecipeWrapper combined into IRecipeCategory + @Override + public void registerRecipes(IRecipeRegistration registry) { + BCPluginJEI.registryRecipe = registry; boolean factory = BCModules.FACTORY.isLoaded(); boolean energy = BCModules.ENERGY.isLoaded(); boolean silicon = BCModules.SILICON.isLoaded(); -// boolean robotics = BCModules.ROBOTICS.isLoaded(); - if (factory) { - registry.handleRecipes(IRefineryRecipeManager.ICoolableRecipe.class, new HandlerCoolable(), CategoryCoolable.UID); - registry.handleRecipes(IRefineryRecipeManager.IDistillationRecipe.class, new HandlerDistiller(), CategoryDistiller.UID); - registry.handleRecipes(IRefineryRecipeManager.IHeatableRecipe.class, new HandlerHeatable(), CategoryHeatable.UID); - - registry.addRecipes(ImmutableList.copyOf(BuildcraftRecipeRegistry.refineryRecipes.getCoolableRegistry().getAllRecipes()), CategoryCoolable.UID); - registry.addRecipes(ImmutableList.copyOf(BuildcraftRecipeRegistry.refineryRecipes.getDistillationRegistry().getAllRecipes()), CategoryDistiller.UID); - registry.addRecipes(ImmutableList.copyOf(BuildcraftRecipeRegistry.refineryRecipes.getHeatableRegistry().getAllRecipes()), CategoryHeatable.UID); - if (BCBlocks.Factory.DISTILLER != null) { - registry.addRecipeCatalyst(new ItemStack(BCBlocks.Factory.DISTILLER), CategoryDistiller.UID); - } - if (BCBlocks.Factory.HEAT_EXCHANGE != null) { - registry.addRecipeCatalyst(new ItemStack(BCBlocks.Factory.HEAT_EXCHANGE), CategoryCoolable.UID); - registry.addRecipeCatalyst(new ItemStack(BCBlocks.Factory.HEAT_EXCHANGE), CategoryHeatable.UID); - } +// registry.handleRecipes(IRefineryRecipeManager.ICoolableRecipe.class, new HandlerCoolable(), "buildcraft:category_coolable"); +// registry.handleRecipes(IRefineryRecipeManager.IDistillationRecipe.class, new HandlerDistiller(), "buildcraft:category_distiller"); +// registry.handleRecipes(IRefineryRecipeManager.IHeatableRecipe.class, new HandlerHeatable(), "buildcraft:category_heatable"); +// registry.addRecipes(ImmutableList.copyOf(BuildcraftRecipeRegistry.refineryRecipes.getCoolableRegistry().getAllRecipes()), new ResourceLocation("buildcraft:category_coolable")); + registry.addRecipes(CategoryCoolable.RECIPE_TYPE, ImmutableList.copyOf(Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(IRefineryRecipeManager.ICoolableRecipe.TYPE))); +// registry.addRecipes(ImmutableList.copyOf(BuildcraftRecipeRegistry.refineryRecipes.getDistillationRegistry().getAllRecipes()), new ResourceLocation("buildcraft:category_distiller")); + registry.addRecipes(CategoryDistiller.RECIPE_TYPE, ImmutableList.copyOf(Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(IRefineryRecipeManager.IDistillationRecipe.TYPE))); +// registry.addRecipes(ImmutableList.copyOf(BuildcraftRecipeRegistry.refineryRecipes.getHeatableRegistry().getAllRecipes()), new ResourceLocation("buildcraft:category_heatable")); + registry.addRecipes(CategoryHeatable.RECIPE_TYPE, ImmutableList.copyOf(Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(IRefineryRecipeManager.IHeatableRecipe.TYPE))); } + if (energy) { - registry.handleRecipes(IFuel.class, new HandlerCombustionEngine(), CategoryCombustionEngine.UID); - registry.addRecipes(ImmutableList.copyOf(FuelRegistry.INSTANCE.getFuels()), CategoryCombustionEngine.UID); - if (BCCoreBlocks.engine != null){ - if (BCCoreBlocks.engine.isRegistered(EnumEngineType.STONE)) { - registry.addRecipeCatalyst(BCCoreBlocks.engine.getStack(EnumEngineType.STONE), VanillaRecipeCategoryUid.FUEL); - } - if (BCCoreBlocks.engine.isRegistered(EnumEngineType.IRON)) { - registry.addRecipeCatalyst(BCCoreBlocks.engine.getStack(EnumEngineType.IRON), CategoryCombustionEngine.UID); - } - } +// registry.handleRecipes(IFuel.class, new HandlerCombustionEngine(), "buildcraft-compat:engine.combustion"); +// registry.addRecipes(ImmutableList.copyOf(FuelRegistry.INSTANCE.getFuels()), new ResourceLocation("buildcraft-compat:engine.combustion")); + registry.addRecipes(CategoryCombustionEngine.RECIPE_TYPE, ImmutableList.copyOf(Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(IFuel.TYPE))); } - if (silicon) { - registry.handleRecipes(AssemblyRecipeBasic.class, WrapperAssemblyTable::new, CategoryAssemblyTable.UID); -// registry.handleRecipes(IntegrationRecipe.class, new HandlerIntegrationTable(), CategoryIntegrationTable.UID); - registry.addRecipes(ImmutableList.copyOf(AssemblyRecipeRegistry.REGISTRY.values()), CategoryAssemblyTable.UID); -// registry.addRecipes(ImmutableList.copyOf(IntegrationRecipeRegistry.INSTANCE.getAllRecipes()), CategoryIntegrationTable.UID); - if (BCBlocks.Silicon.ASSEMBLY_TABLE != null) { - registry.addRecipeCatalyst(new ItemStack(BCBlocks.Silicon.ASSEMBLY_TABLE), CategoryAssemblyTable.UID); - } - if (BCBlocks.Silicon.ADVANCED_CRAFTING_TABLE != null) { - registry.addRecipeCatalyst(new ItemStack(BCBlocks.Silicon.ADVANCED_CRAFTING_TABLE), VanillaRecipeCategoryUid.CRAFTING); - } + if (silicon) { +// registry.handleRecipes(AssemblyRecipeBasic.class, WrapperAssemblyTable::new, "buildcraft-compat:silicon.assembly"); +// registry.addRecipes(ImmutableList.copyOf(AssemblyRecipeRegistry.REGISTRY.values()), new ResourceLocation("buildcraft-compat:silicon.assembly")); + registry.addRecipes(CategoryAssemblyTable.RECIPE_TYPE, ImmutableList.copyOf(Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(AssemblyRecipe.TYPE))); + registry.addRecipes(CategoryIntegrationTable.RECIPE_TYPE, ImmutableList.copyOf(Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(IntegrationRecipe.TYPE))); + registry.addRecipes(CategoryProgrammingTable.RECIPE_TYPE, ImmutableList.copyOf(Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(IProgrammingRecipe.TYPE))); } + } - registry.getRecipeTransferRegistry().addRecipeTransferHandler(new AutoCraftItemsTransferHandler(), VanillaRecipeCategoryUid.CRAFTING); - registry.getRecipeTransferRegistry().addRecipeTransferHandler(new AdvancedCraftingItemsTransferHandler(), VanillaRecipeCategoryUid.CRAFTING); - // registry.getRecipeTransferRegistry().addRecipeTransferHandler(new AssemblyTableTransferHandler(), CategoryAssemblyTable.UID); - registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerAssemblyTable.class, CategoryAssemblyTable.UID, - 36, 12, 0, 36); + @Override + public void registerRecipeTransferHandlers(IRecipeTransferRegistration registry) { + BCPluginJEI.registryRecipeTransfer = registry; + +// registry.addRecipeTransferHandler(new AutoCraftItemsTransferHandler(), "minecraft.crafting"); + registry.addRecipeTransferHandler(new AutoCraftItemsTransferHandler(), RecipeTypes.CRAFTING); +// registry.addRecipeTransferHandler(new AdvancedCraftingItemsTransferHandler(), "minecraft.crafting"); + registry.addRecipeTransferHandler(new AdvancedCraftingItemsTransferHandler(), RecipeTypes.CRAFTING); +// registry.addRecipeTransferHandler(ContainerAssemblyTable.class, "buildcraft-compat:silicon.assembly", 36, 12, 0, 36); + registry.addRecipeTransferHandler(ContainerAssemblyTable.class, BCSiliconMenuTypes.ASSEMBLY_TABLE, CategoryAssemblyTable.RECIPE_TYPE, 36, 12, 0, 36); + registry.addRecipeTransferHandler(ContainerIntegrationTable.class, BCSiliconMenuTypes.INTEGRATION_TABLE, CategoryIntegrationTable.RECIPE_TYPE, 36, 11, 0, 36); + registry.addRecipeTransferHandler(ContainerProgrammingTable_Neptune.class, BCSiliconMenuTypes.PROGRAMMING_TABLE, CategoryProgrammingTable.RECIPE_TYPE, 36, 26, 0, 36); } @Override public void registerCategories(IRecipeCategoryRegistration registry) { -// boolean transport = Loader.isModLoaded(BCModules.TRANSPORT.getModId()); - boolean factory = Loader.isModLoaded(BCModules.FACTORY.getModId()); - boolean energy = Loader.isModLoaded(BCModules.ENERGY.getModId()); - boolean silicon = Loader.isModLoaded(BCModules.SILICON.getModId()); -// boolean robotics = Loader.isModLoaded(BCModules.ROBOTICS.getModId()); - +// boolean factory = Loader.isModLoaded(BCModules.FACTORY.getModId()); + boolean factory = ModList.get().isLoaded(BCModules.FACTORY.getModId()); +// boolean energy = Loader.isModLoaded(BCModules.ENERGY.getModId()); + boolean energy = ModList.get().isLoaded(BCModules.ENERGY.getModId()); +// boolean silicon = Loader.isModLoaded(BCModules.SILICON.getModId()); + boolean silicon = ModList.get().isLoaded(BCModules.SILICON.getModId()); List lst = Lists.newArrayList(); IGuiHelper helper = registry.getJeiHelpers().getGuiHelper(); - -// jeiRegistry.addAdvancedGuiHandlers(new LedgerGuiHandler()); -// if (transport) { -// lst.add("transport"); -// loadTransport(jeiRegistry); -// } if (factory) { lst.add("factory"); - registry.addRecipeCategories(new CategoryHeatable(helper)); - registry.addRecipeCategories(new CategoryDistiller(helper)); - registry.addRecipeCategories(new CategoryCoolable(helper)); + registry.addRecipeCategories(new IRecipeCategory[] { new CategoryHeatable(helper) }); + registry.addRecipeCategories(new IRecipeCategory[] { new CategoryDistiller(helper) }); + registry.addRecipeCategories(new IRecipeCategory[] { new CategoryCoolable(helper) }); } + if (energy) { lst.add("energy"); - registry.addRecipeCategories(new CategoryCombustionEngine(helper)); +// registry.addRecipeCategories(new IRecipeCategory[]{new CategoryCombustionEngine(helper)}); + registry.addRecipeCategories(new IRecipeCategory[] { new CategoryCombustionEngine(helper, FuelRegistry.INSTANCE.getFuels(Minecraft.getInstance().level)) }); } + if (silicon) { lst.add("silicon"); - registry.addRecipeCategories(new CategoryAssemblyTable(helper)); -// registry.addRecipeCategories(new CategoryIntegrationTable(helper)); +// registry.addRecipeCategories(new IRecipeCategory[]{new CategoryAssemblyTable(helper)}); + registry.addRecipeCategories(new IRecipeCategory[] { new CategoryAssemblyTable(helper, AssemblyRecipeRegistry.getAll(Minecraft.getInstance().level)) }); + registry.addRecipeCategories(new IRecipeCategory[] { new CategoryIntegrationTable(helper) }); + registry.addRecipeCategories(new IRecipeCategory[] { new CategoryProgrammingTable(helper, ProgrammingRecipeManager.INSTANCE.getRecipes(Minecraft.getInstance().level)) }); } BCLog.logger.info("Loaded JEI mods: " + Arrays.toString(lst.toArray())); } -// private static void loadTransport(IModRegistry jeiRegistry) { -// jeiRegistry.addAdvancedGuiHandlers(new GateGuiHandler()); -// } + @Override + public void registerRecipeCatalysts(IRecipeCatalystRegistration registry) { + BCPluginJEI.registryRecipeCatalyst = registry; + + boolean factory = BCModules.FACTORY.isLoaded(); + boolean energy = BCModules.ENERGY.isLoaded(); + boolean silicon = BCModules.SILICON.isLoaded(); + if (factory) { + if (BCFactoryBlocks.distiller != null) { +// registry.addRecipeCatalyst(new ItemStack(BCFactoryBlocks.distiller.get()), new String[]{"buildcraft:category_distiller"}); + registry.addRecipeCatalyst(new ItemStack(BCFactoryBlocks.distiller.get()), CategoryDistiller.RECIPE_TYPE); + } + + if (BCFactoryBlocks.heatExchange != null) { +// registry.addRecipeCatalyst(new ItemStack(BCFactoryBlocks.heatExchange.get()), new String[]{"buildcraft:category_coolable"}); + registry.addRecipeCatalyst(new ItemStack(BCFactoryBlocks.heatExchange.get()), CategoryCoolable.RECIPE_TYPE); +// registry.addRecipeCatalyst(new ItemStack(BCFactoryBlocks.heatExchange.get()), new String[]{"buildcraft:category_heatable"}); + registry.addRecipeCatalyst(new ItemStack(BCFactoryBlocks.heatExchange.get()), CategoryHeatable.RECIPE_TYPE); + } + + if (BCFactoryBlocks.autoWorkbenchItems != null) { + registry.addRecipeCatalyst(new ItemStack(BCFactoryBlocks.autoWorkbenchItems.get()), RecipeTypes.CRAFTING); + } + } + + if (energy) { +// if (BCCoreBlocks.engine != null) + if (!BCCoreBlocks.engineBlockMap.isEmpty()) { +// if (BCCoreBlocks.engine.isRegistered(EnumEngineType.STONE)) + if (BCCoreBlocks.engineBlockMap.containsKey(EnumEngineType.STONE)) { +// registry.addRecipeCatalyst(BCCoreBlocks.engine.getStack(EnumEngineType.STONE), new String[]{"minecraft.fuel"}); + registry.addRecipeCatalyst(new ItemStack(BCCoreBlocks.engineBlockMap.get(EnumEngineType.STONE).get()), RecipeTypes.FUELING); + } + +// if (BCCoreBlocks.engine.isRegistered(EnumEngineType.IRON)) + if (BCCoreBlocks.engineBlockMap.containsKey(EnumEngineType.IRON)) { +//// registry.addRecipeCatalyst(BCCoreBlocks.engine.getStack(EnumEngineType.IRON), new String[]{"buildcraft-compat:engine.combustion"}); +// registry.addRecipeCatalyst(new ItemStack(BCCoreBlocks.engineBlockMap.get(EnumEngineType.IRON).get()), new String[]{"buildcraft-compat:engine.combustion"}); + registry.addRecipeCatalyst(new ItemStack(BCCoreBlocks.engineBlockMap.get(EnumEngineType.IRON).get()), CategoryCombustionEngine.RECIPE_TYPE); + } + } + } + + if (silicon) { + if (BCSiliconBlocks.assemblyTable != null) { +// registry.addRecipeCatalyst(new ItemStack(BCSiliconBlocks.assemblyTable.get()), new String[]{"buildcraft-compat:silicon.assembly"}); + registry.addRecipeCatalyst(new ItemStack(BCSiliconBlocks.assemblyTable.get()), CategoryAssemblyTable.RECIPE_TYPE); + registry.addRecipeCatalyst(new ItemStack(BCSiliconBlocks.integrationTable.get()), CategoryIntegrationTable.RECIPE_TYPE); + registry.addRecipeCatalyst(new ItemStack(BCSiliconBlocks.programmingTable.get()), CategoryProgrammingTable.RECIPE_TYPE); + } + + if (BCSiliconBlocks.advancedCraftingTable != null) { +// registry.addRecipeCatalyst(new ItemStack(BCSiliconBlocks.advancedCraftingTable.get()), new String[]{"minecraft.crafting"}); + registry.addRecipeCatalyst(new ItemStack(BCSiliconBlocks.advancedCraftingTable.get()), RecipeTypes.CRAFTING); + } + } + } + + @Override + public void registerItemSubtypes(ISubtypeRegistration registration) { + boolean transport = BCModules.TRANSPORT.isLoaded(); + boolean silicon = BCModules.SILICON.isLoaded(); + if (transport) { + registration.registerSubtypeInterpreter(BCTransportItems.wire.get(), (stack, context) -> ColourUtil.getStackColourFromTag(stack).getName()); + } + if (silicon) { + registration.registerSubtypeInterpreter(BCSiliconItems.plugLens.get(), (stack, context) -> String.valueOf(stack.getDamageValue())); + } + registration.registerSubtypeInterpreter(BCLibItems.guide.get(), (stack, context) -> ItemGuide.getBookName(stack)); + } + + @Override + public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { + BCPluginJEI.jeiRuntime = jeiRuntime; + + if (!BCCompatConfig.coloredPipesVisible) { + List itemsToRemove = new ArrayList<>(); + Arrays.stream(DyeColor.values()).forEach( + color -> PipeRegistry.INSTANCE.getAllRegisteredPipes().forEach( + def -> itemsToRemove.add(new ItemStack((Item) PipeRegistry.INSTANCE.getItemForPipe(def, color))) + ) + ); + jeiRuntime.getIngredientManager().removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, itemsToRemove); + } + + if (!BCCompatConfig.facadesVisible) { + jeiRuntime.getIngredientManager().removeIngredientsAtRuntime( + VanillaTypes.ITEM_STACK, + jeiRuntime.getIngredientManager().getAllIngredients(VanillaTypes.ITEM_STACK).stream() + .filter(stack -> stack.getItem() == BCSiliconItems.plugFacade.get()).toList() + ); + } + } } diff --git a/common/buildcraft/compat/module/jei/energy/combustionengine/CategoryCombustionEngine.java b/common/buildcraft/compat/module/jei/energy/combustionengine/CategoryCombustionEngine.java index 323ec89..5f33f6d 100644 --- a/common/buildcraft/compat/module/jei/energy/combustionengine/CategoryCombustionEngine.java +++ b/common/buildcraft/compat/module/jei/energy/combustionengine/CategoryCombustionEngine.java @@ -1,40 +1,88 @@ package buildcraft.compat.module.jei.energy.combustionengine; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; import buildcraft.api.BCModules; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IGuiFluidStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.BlankRecipeCategory; +import buildcraft.api.fuels.IFuel; +import buildcraft.api.fuels.IFuelManager; +import buildcraft.api.mj.MjAPI; +import buildcraft.energy.BCEnergyBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.vertex.PoseStack; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.forge.ForgeTypes; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fluids.FluidStack; -public class CategoryCombustionEngine extends BlankRecipeCategory { - public static final String UID = "buildcraft-compat:engine.combustion"; +import java.awt.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +//public class CategoryCombustionEngine extends BlankRecipeCategory +public class CategoryCombustionEngine implements IRecipeCategory { + // Calen + public static final RecipeType RECIPE_TYPE = + RecipeType.create(BCModules.ENERGY.getModId(), "engine_combustion", IFuel.class); + // public static final ResourceLocation UID = new ResourceLocation("buildcraft-compat:engine.combustion"); + public static final ResourceLocation UID = new ResourceLocation(BCModules.ENERGY.getModId(), "engine_combustion"); + public static final ResourceLocation FURNACE = new ResourceLocation("minecraft", "textures/gui/container/furnace.png"); private final IDrawable background; -// private WrapperCombustionEngine wrapper = null; - public CategoryCombustionEngine(IGuiHelper guiHelper) { - super(); - this.background = guiHelper.createDrawable( - new ResourceLocation("minecraft", "textures/gui/container/furnace.png"), - 55, 38, 18, 32, 0, 0, 0, 80); + private final IDrawable icon; + + @OnlyIn(Dist.CLIENT) + private Font font = Minecraft.getInstance().font; + private final Map burnTimeDrabableMap = new HashMap<>(); + + public CategoryCombustionEngine(IGuiHelper guiHelper, Collection fuels) { + // Calen: 80->100 +// this.background = guiHelper.createDrawable(new ResourceLocation("minecraft", "textures/gui/container/furnace.png"), 55, 38, 18, 32, 0, 0, 0, 80); +// this.background = guiHelper.drawableBuilder(FURNACE, 55, 38, 18, 32).addPadding(0, 0, 0, 80).build(); + this.background = guiHelper.drawableBuilder(FURNACE, 55, 38, 18, 32).addPadding(0, 0, 0, 120).build(); + // Calen: from 1.12.2 what is this doing??? guiHelper.createDrawable(new ResourceLocation(BCModules.ENERGY.getModId(), ""), 0, 0, 16, 16); + + this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BCEnergyBlocks.engineIron.get())); + +// ResourceLocation furnaceBackgroundLocation = new ResourceLocation("minecraft", "textures/gui/container/furnace.png"); + IDrawableStatic flameDrawable = guiHelper.createDrawable(FURNACE, 176, 0, 14, 14); +// this.flame = guiHelper.createAnimatedDrawable(flameDrawable, fuel.getTotalBurningTime() / 10, IDrawableAnimated.StartDirection.TOP, true); + for (IFuel fuel : fuels) { + if (!burnTimeDrabableMap.containsKey(fuel.getTotalBurningTime())) { + burnTimeDrabableMap.put(fuel.getTotalBurningTime(), guiHelper.createAnimatedDrawable(flameDrawable, fuel.getTotalBurningTime() / 10, IDrawableAnimated.StartDirection.TOP, true)); + } + } } @Override - public String getUid() { - return UID; + public RecipeType getRecipeType() { + return RECIPE_TYPE; } @Override - public String getTitle() { - return "Combustion Engine Fuels"; + public Component getTitle() { +// return new TextComponent("Combustion Engine Fuels"); + return Component.translatable("buildcraft.jei.title.combustion_engine_fuels"); } - @Override public String getModName() { return BCModules.ENERGY.name(); } @@ -45,27 +93,67 @@ public IDrawable getBackground() { } @Override - public void setRecipe(IRecipeLayout recipeLayout, WrapperCombustionEngine recipeWrapper, IIngredients ingredients) { -// WrapperCombustionEngine wrapper = (WrapperCombustionEngine) recipeWrapper; - IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); + public IDrawable getIcon() { + return this.icon; + } - guiFluidStacks.init(0, true, 1, 15, 16, 16, 1000, false, null); - guiFluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + // Calen + private int lastBurnTime = -1; - if (recipeWrapper instanceof WrapperCombustionEngine.Dirty) { -// WrapperCombustionEngine.Dirty dirty = (WrapperCombustionEngine.Dirty)recipeWrapper; + @Override + public void draw(IFuel fuel, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + PoseStack poseStack = guiGraphics.pose(); +// this.flame.draw(stack, 2, 0); + this.burnTimeDrabableMap.get(fuel.getTotalBurningTime()).draw(guiGraphics, 2, 0); +// GlStateManager.func_179094_E(); + poseStack.pushPose(); + // Calen: 8->6 +// GlStateManager.func_179109_b(24.0F, 8.0F, 0.0F); +// stack.translate(24.0F, 8.0F, 0.0F); + poseStack.translate(24.0F, 6.0F, 0.0F); +// this.font.draw(stack, "Burns for " + fuel.getTotalBurningTime() / 20 + "s", 0, 0, Color.darkGray.getRGB()); + guiGraphics.drawString(this.font, Component.translatable("buildcraft.jei.title.combustion_engine_fuels.burn_time", fuel.getTotalBurningTime() / 20).getString(), 0, 0, Color.darkGray.getRGB(), false); +// this.font.draw(stack, " at " + MjAPI.formatMj(fuel.getPowerPerCycle()) + " MJ/t", 0, font.lineHeight, Color.darkGray.getRGB()); + guiGraphics.drawString(this.font, Component.translatable("buildcraft.jei.title.combustion_engine_fuels.burn_speed", MjAPI.formatMj(fuel.getPowerPerCycle())).getString(), 0, font.lineHeight, Color.darkGray.getRGB(), false); +// GlStateManager.func_179109_b(0.0F, (float)(minecraft.field_71466_p.field_78288_b * 2), 0.0F); + poseStack.translate(0.0F, (float) (font.lineHeight * 2), 0.0F); +// GlStateManager.func_179139_a(0.7, 0.7, 1.0); + poseStack.scale(0.7F, 0.7F, 1.0F); +// this.font.draw(stack, " total " + MjAPI.formatMj(fuel.getPowerPerCycle() * (long) fuel.getTotalBurningTime()) + " MJ", 1, 2, Color.gray.getRGB()); + guiGraphics.drawString(this.font, Component.translatable("buildcraft.jei.title.combustion_engine_fuels.burn_total", MjAPI.formatMj(fuel.getPowerPerCycle() * (long) fuel.getTotalBurningTime())).getString(), 1, 2, Color.gray.getRGB(), false); +// GlStateManager.func_179121_F(); + poseStack.popPose(); + } - guiFluidStacks.init(1, false, 95, 15, 16, 16, 1000, false, null); - guiFluidStacks.set(1, ingredients.getOutputs(FluidStack.class).get(0)); + @Override + // public void setRecipe(IRecipeLayout recipeLayout, WrapperCombustionEngine recipeWrapper, IIngredients ingredients) + public void setRecipe(IRecipeLayoutBuilder builder, IFuel fuel, IFocusGroup focuses) { +// IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); +// guiFluidStacks.init(0, true, 1, 15, 16, 16, 1000, false, (IDrawable) null); +// guiFluidStacks.set(0, (List) ingredients.getInputs(FluidStack.class).get(0)); + builder + .addSlot(RecipeIngredientRole.INPUT, 1, 15) + .setFluidRenderer(1000, false, 16, 16) + .addIngredient(ForgeTypes.FLUID_STACK, new FluidStack(fuel.getFluid(), 1000)); + if (fuel instanceof IFuelManager.IDirtyFuel dirtyFuel) { + // Calen: move right 20 to not covered the text +// guiFluidStacks.init(1, false, 95, 15, 16, 16, 1000, false, (IDrawable) null); +// guiFluidStacks.set(1, (List) ingredients.getOutputs(FluidStack.class).get(0)); + builder +// .addSlot(RecipeIngredientRole.OUTPUT, 95, 15) + .addSlot(RecipeIngredientRole.OUTPUT, 115, 15) + .setFluidRenderer(1000, false, 16, 16) + .addIngredient(ForgeTypes.FLUID_STACK, dirtyFuel.getResidue()); } } -// -// @Override -// public void drawExtras(Minecraft minecraft) { -// super.drawExtras(minecraft); -// -// if (this.wrapper != null) { -// this.wrapper.flame.draw(minecraft, 2, 0); -// } -// } + + @Override + public List getTooltipStrings(IFuel recipe, IRecipeSlotsView recipeSlotsView, double mouseX, double mouseY) { + return Lists.newArrayList(); + } + + @Override + public boolean handleInput(IFuel recipe, double mouseX, double mouseY, InputConstants.Key input) { + return false; + } } diff --git a/common/buildcraft/compat/module/jei/energy/combustionengine/HandlerCombustionEngine.java b/common/buildcraft/compat/module/jei/energy/combustionengine/HandlerCombustionEngine.java deleted file mode 100644 index 7a4a0f0..0000000 --- a/common/buildcraft/compat/module/jei/energy/combustionengine/HandlerCombustionEngine.java +++ /dev/null @@ -1,19 +0,0 @@ -package buildcraft.compat.module.jei.energy.combustionengine; - -import buildcraft.api.fuels.IFuel; -import buildcraft.api.fuels.IFuelManager.IDirtyFuel; - -import buildcraft.compat.module.jei.BCPluginJEI; - -import mezz.jei.api.recipe.IRecipeWrapper; -import mezz.jei.api.recipe.IRecipeWrapperFactory; - -public class HandlerCombustionEngine implements IRecipeWrapperFactory { - @Override - public IRecipeWrapper getRecipeWrapper(IFuel recipe) { - if (recipe instanceof IDirtyFuel) { - return new WrapperCombustionEngine.Dirty(BCPluginJEI.registry.getJeiHelpers().getGuiHelper(), (IDirtyFuel) recipe); - } - return new WrapperCombustionEngine(BCPluginJEI.registry.getJeiHelpers().getGuiHelper(), recipe); - } -} diff --git a/common/buildcraft/compat/module/jei/energy/combustionengine/WrapperCombustionEngine.java b/common/buildcraft/compat/module/jei/energy/combustionengine/WrapperCombustionEngine.java deleted file mode 100644 index d50d9f0..0000000 --- a/common/buildcraft/compat/module/jei/energy/combustionengine/WrapperCombustionEngine.java +++ /dev/null @@ -1,110 +0,0 @@ -package buildcraft.compat.module.jei.energy.combustionengine; - -import java.awt.Color; -import java.util.List; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import buildcraft.api.fuels.IFuel; -import buildcraft.api.fuels.IFuelManager.IDirtyFuel; -import buildcraft.api.mj.MjAPI; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawableAnimated; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; - -public class WrapperCombustionEngine implements IRecipeWrapper { - private final IFuel fuel; - private final ImmutableList in; - private final IDrawableAnimated flame; - - WrapperCombustionEngine(IGuiHelper guiHelper, IFuel fuel) { - this.fuel = fuel; - in = ImmutableList.of(new FluidStack(fuel.getFluid(), Fluid.BUCKET_VOLUME)); - - ResourceLocation furnaceBackgroundLocation = new ResourceLocation("minecraft", "textures/gui/container/furnace.png"); - IDrawableStatic flameDrawable = guiHelper.createDrawable(furnaceBackgroundLocation, 176, 0, 14, 14); - this.flame = guiHelper.createAnimatedDrawable(flameDrawable, fuel.getTotalBurningTime() / 10, IDrawableAnimated.StartDirection.TOP, true); - } - -// @Override -// public List getInputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getOutputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getFluidInputs() { -// return in; -// } -// -// @Override -// public List getFluidOutputs() { -// return null; -// } -// -// @Override -// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight) {} - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(FluidStack.class, this.in); - } - - @Override - @SideOnly(Side.CLIENT) - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - this.flame.draw(minecraft, 2, 0); - - GlStateManager.pushMatrix(); - GlStateManager.translate(24, 8, 0); - // GlStateManager.scale(.7, .7, 1.0); - minecraft.fontRenderer.drawString("Burns for " + (fuel.getTotalBurningTime() / 20) + "s", 0, 0, Color.darkGray.getRGB()); - minecraft.fontRenderer.drawString(" at " + MjAPI.formatMj(fuel.getPowerPerCycle()) + " MJ/t", 0, minecraft.fontRenderer.FONT_HEIGHT, Color.darkGray.getRGB()); - GlStateManager.translate(0, minecraft.fontRenderer.FONT_HEIGHT * 2, 0); - GlStateManager.scale(.7, .7, 1.0); - minecraft.fontRenderer.drawString(" total " + MjAPI.formatMj(fuel.getPowerPerCycle() * fuel.getTotalBurningTime()) + " MJ", 1, 2, Color.gray.getRGB()); - GlStateManager.popMatrix(); - } - -// @Override -// public void drawAnimations(Minecraft minecraft, int recipeWidth, int recipeHeight) { -// flame.draw(minecraft, 2, 0); -// } - - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return Lists.newArrayList(); - } - - @Override - public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { - return false; - } - - public static class Dirty extends WrapperCombustionEngine { - final IDirtyFuel dirty; - - Dirty(IGuiHelper guiHelper, IDirtyFuel fuel) { - super(guiHelper, fuel); - this.dirty = fuel; - } - - @Override - public void getIngredients(IIngredients ingredients) { - super.getIngredients(ingredients); - ingredients.setOutput(FluidStack.class, this.dirty.getResidue()); - } - } -} diff --git a/common/buildcraft/compat/module/jei/energy/combustionengine/package-info.java b/common/buildcraft/compat/module/jei/energy/combustionengine/package-info.java index 1cad84d..3d25469 100644 --- a/common/buildcraft/compat/module/jei/energy/combustionengine/package-info.java +++ b/common/buildcraft/compat/module/jei/energy/combustionengine/package-info.java @@ -2,5 +2,6 @@ @MethodsReturnNonnullByDefault package buildcraft.compat.module.jei.energy.combustionengine; -import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/common/buildcraft/compat/module/jei/factory/CategoryCoolable.java b/common/buildcraft/compat/module/jei/factory/CategoryCoolable.java index 426d952..f913467 100644 --- a/common/buildcraft/compat/module/jei/factory/CategoryCoolable.java +++ b/common/buildcraft/compat/module/jei/factory/CategoryCoolable.java @@ -1,64 +1,131 @@ package buildcraft.compat.module.jei.factory; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; import buildcraft.api.BCModules; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IGuiFluidStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.BlankRecipeCategory; - -public class CategoryCoolable extends BlankRecipeCategory { - public static final String UID = "buildcraft:category_coolable"; +import buildcraft.api.recipes.IRefineryRecipeManager; +import buildcraft.factory.BCFactoryBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.platform.InputConstants; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.forge.ForgeTypes; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.builder.IRecipeSlotBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.List; + +//public class CategoryCoolable extends BlankRecipeCategory +public class CategoryCoolable implements IRecipeCategory { + // Calen + public static final RecipeType RECIPE_TYPE = + RecipeType.create(BCModules.FACTORY.getModId(), "category_coolable", IRefineryRecipeManager.ICoolableRecipe.class); + public static final ResourceLocation UID = new ResourceLocation(BCModules.FACTORY.getModId(), "category_coolable"); public static final ResourceLocation heatExchangerBackground = new ResourceLocation("buildcraftfactory:textures/gui/heat_exchanger.png"); + private final IDrawable background; + private final IDrawable slot; + + private final IDrawable icon; - private final IDrawable background, slot; + private final IDrawableAnimated animatedCooling; + private final IDrawableAnimated animatedHeating; - public CategoryCoolable(IGuiHelper helper) { - this.background = helper.createDrawable(heatExchangerBackground, 61, 38, 54, 17, 0, 0, 18, 80); - this.slot = helper.createDrawable(heatExchangerBackground, 7, 22, 18, 18); + public CategoryCoolable(IGuiHelper guiHelper) { + // Calen: top padding add 2 to be same height as heatable +// this.background = helper.createDrawable(heatExchangerBackground, 61, 38, 54, 17, 0, 0, 18, 80); +// this.background = guiHelper.drawableBuilder(heatExchangerBackground, 61, 38, 54, 17).addPadding(0, 0, 18, 80).build(); + this.background = guiHelper.drawableBuilder(heatExchangerBackground, 61, 38, 54, 17).addPadding(2, 0, 18, 80).build(); + this.slot = guiHelper.createDrawable(heatExchangerBackground, 7, 22, 18, 18); + + this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BCFactoryBlocks.heatExchange.get())); + + IDrawableStatic overComplete = guiHelper.createDrawable(CategoryCoolable.heatExchangerBackground, 52, 171, 54, 17); + this.animatedCooling = guiHelper.createAnimatedDrawable(overComplete, 40, IDrawableAnimated.StartDirection.LEFT, false); + overComplete = guiHelper.createDrawable(CategoryCoolable.heatExchangerBackground, 52, 188, 54, 17); + this.animatedHeating = guiHelper.createAnimatedDrawable(overComplete, 40, IDrawableAnimated.StartDirection.RIGHT, false); } @Override - public String getUid() { - return UID; + public RecipeType getRecipeType() { + return RECIPE_TYPE; } - @Override - public String getTitle() { - return "Coolable Fluids"; + public Component getTitle() { +// return new TextComponent("Coolable Fluids"); + return Component.translatable("buildcraft.jei.title.coolable_fluids"); } - @Override public String getModName() { return BCModules.FACTORY.name(); } - @Override public IDrawable getBackground() { return this.background; } @Override - public void drawExtras(Minecraft minecraft) { - slot.draw(minecraft, 0, 0); - slot.draw(minecraft, 72, 0); + public IDrawable getIcon() { + return this.icon; } -// -// @Override -// public void drawAnimations(Minecraft minecraft) {} @Override - public void setRecipe(IRecipeLayout recipeLayout, WrapperCoolable recipeWrapper, IIngredients ingredients) { - IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); +// public void drawExtras(Minecraft minecraft) + public void draw(IRefineryRecipeManager.ICoolableRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + // Calen: y+1 to be at the same height as tubes of background + // in 1.18.2 additionally +1 +// this.slot.draw(stack, 0, 0); + this.slot.draw(guiGraphics, 0, 1); +// this.slot.draw(stack, 72, 0); + this.slot.draw(guiGraphics, 72, 1); + + // Calen: top padding add 2 to be same height as heatable +// this.animatedCooling.draw(stack, 18, 0); + this.animatedCooling.draw(guiGraphics, 18, 2); +// this.animatedHeating.draw(stack, 18, 0); + this.animatedHeating.draw(guiGraphics, 18, 2); + } - guiFluidStacks.init(0, true, 1, 1, 16, 16, 10, false, null); - guiFluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + @Override +// public void setRecipe(IRecipeLayout recipeLayout, WrapperCoolable recipeWrapper, IIngredients ingredients) + public void setRecipe(IRecipeLayoutBuilder builder, IRefineryRecipeManager.ICoolableRecipe recipe, IFocusGroup focuses) { +// IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); +// guiFluidStacks.init(0, true, 1, 1, 16, 16, 10, false, (IDrawable) null); +// guiFluidStacks.set(0, (List) ingredients.getInputs(FluidStack.class).get(0)); + builder +// .addSlot(RecipeIngredientRole.INPUT, 1, 1) + .addSlot(RecipeIngredientRole.INPUT, 1, 2) + .setFluidRenderer(10, false, 16, 16) + .addIngredient(ForgeTypes.FLUID_STACK, recipe.in()); +// guiFluidStacks.init(1, false, 73, 1, 16, 16, 10, false, (IDrawable) null); +// guiFluidStacks.set(1, (List) ingredients.getOutputs(FluidStack.class).get(0)); + IRecipeSlotBuilder slotBuilder = builder +// .addSlot(RecipeIngredientRole.OUTPUT, 73, 1) + .addSlot(RecipeIngredientRole.OUTPUT, 73, 2) + .setFluidRenderer(10, false, 16, 16); + FluidStack out = recipe.out(); + if (out != null && !out.isEmpty()) { + slotBuilder.addIngredient(ForgeTypes.FLUID_STACK, recipe.out()); + } + } - guiFluidStacks.init(1, false, 73, 1, 16, 16, 10, false, null); - guiFluidStacks.set(1, ingredients.getOutputs(FluidStack.class).get(0)); + @Override + public List getTooltipStrings(IRefineryRecipeManager.ICoolableRecipe recipe, IRecipeSlotsView recipeSlotsView, double mouseX, double mouseY) { + return Lists.newArrayList(); + } + + @Override + public boolean handleInput(IRefineryRecipeManager.ICoolableRecipe recipe, double mouseX, double mouseY, InputConstants.Key input) { + return false; } } diff --git a/common/buildcraft/compat/module/jei/factory/CategoryDistiller.java b/common/buildcraft/compat/module/jei/factory/CategoryDistiller.java index 64f4501..04bbc96 100644 --- a/common/buildcraft/compat/module/jei/factory/CategoryDistiller.java +++ b/common/buildcraft/compat/module/jei/factory/CategoryDistiller.java @@ -1,70 +1,133 @@ package buildcraft.compat.module.jei.factory; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; import buildcraft.api.BCModules; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IGuiFluidStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.BlankRecipeCategory; - -public class CategoryDistiller extends BlankRecipeCategory { - public static final String UID = "buildcraft:category_distiller"; +import buildcraft.api.mj.MjAPI; +import buildcraft.api.recipes.IRefineryRecipeManager; +import buildcraft.factory.BCFactoryBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.platform.InputConstants; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.forge.ForgeTypes; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import java.awt.*; +import java.util.List; + +//public class CategoryDistiller extends BlankRecipeCategory +public class CategoryDistiller implements IRecipeCategory { + // Calen + public static final RecipeType RECIPE_TYPE = + RecipeType.create(BCModules.FACTORY.getModId(), "category_distiller", IRefineryRecipeManager.IDistillationRecipe.class); + public static final ResourceLocation UID = new ResourceLocation(BCModules.FACTORY.getModId(), "category_distiller"); public static final ResourceLocation distillerBackground = new ResourceLocation("buildcraftfactory:textures/gui/distiller.png"); + private final IDrawable background; + private final IDrawable slot; + private final IDrawable fakeBackground; + + private final IDrawable icon; - private final IDrawable background, slot, fakeBackground; + private final IDrawableAnimated animated; - public CategoryDistiller(IGuiHelper helper) { - this.fakeBackground = helper.createBlankDrawable(76, 65); - this.background = helper.createDrawable(distillerBackground, 61, 12, 36, 57); - this.slot = helper.createDrawable(distillerBackground, 7, 34, 18, 18); + @OnlyIn(Dist.CLIENT) + private Font font = Minecraft.getInstance().font; + + public CategoryDistiller(IGuiHelper guiHelper) { +// this.fakeBackground = guiHelper.createBlankDrawable(76, 65); + this.fakeBackground = guiHelper.createBlankDrawable(90, 65); + this.background = guiHelper.createDrawable(distillerBackground, 61, 12, 36, 57); + this.slot = guiHelper.createDrawable(distillerBackground, 7, 34, 18, 18); + + this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BCFactoryBlocks.distiller.get())); + + IDrawableStatic overComplete = guiHelper.createDrawable(CategoryDistiller.distillerBackground, 212, 0, 36, 57); + this.animated = guiHelper.createAnimatedDrawable(overComplete, 40, IDrawableAnimated.StartDirection.LEFT, false); } @Override - public String getUid() { - return UID; + public RecipeType getRecipeType() { + return RECIPE_TYPE; } @Override - public String getTitle() { - return "Distillable Fluids"; + public Component getTitle() { +// return new TextComponent("Distillable Fluids"); + return Component.translatable("buildcraft.jei.title.distillable_fluids"); } - @Override public String getModName() { return BCModules.FACTORY.name(); } @Override public IDrawable getBackground() { - return fakeBackground; + return this.fakeBackground; } @Override - public void drawExtras(Minecraft minecraft) { - this.background.draw(minecraft, 20, 4); - this.slot.draw(minecraft, 0, 25); // -20, 21); - this.slot.draw(minecraft, 56, 0); // 36, -4); - this.slot.draw(minecraft, 56, 45); // 36, 41); + public IDrawable getIcon() { + return this.icon; } -// @Override -// public void drawAnimations(Minecraft minecraft) {} - @Override - public void setRecipe(IRecipeLayout recipeLayout, WrapperDistiller recipeWrapper, IIngredients ingredients) { - IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); +// public void drawExtras(Minecraft minecraft) + public void draw(IRefineryRecipeManager.IDistillationRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.background.draw(guiGraphics, 20, 4); + this.slot.draw(guiGraphics, 0, 25); + this.slot.draw(guiGraphics, 56, 0); + this.slot.draw(guiGraphics, 56, 45); + + this.animated.draw(guiGraphics, 20, 4); + guiGraphics.drawString(this.font, MjAPI.formatMj(recipe.powerRequired()) + " MJ", 58, 28, Color.CYAN.getRGB()); + } - guiFluidStacks.init(0, true, /*-19, 22*/ 1, 26, 16, 16, 10, false, null); - guiFluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + @Override +// public void setRecipe(IRecipeLayout recipeLayout, WrapperDistiller recipeWrapper, IIngredients ingredients) + public void setRecipe(IRecipeLayoutBuilder builder, IRefineryRecipeManager.IDistillationRecipe recipe, IFocusGroup focuses) { +// IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); +// guiFluidStacks.init(0, true, 1, 26, 16, 16, 10, false, (IDrawable) null); +// guiFluidStacks.set(0, (List) ingredients.getInputs(FluidStack.class).get(0)); + builder + .addSlot(RecipeIngredientRole.INPUT, 1, 26) + .setFluidRenderer(10, false, 16, 16) + .addIngredient(ForgeTypes.FLUID_STACK, recipe.in()); +// guiFluidStacks.init(1, false, 57, 1, 16, 16, 10, false, (IDrawable) null); +// guiFluidStacks.set(1, (List) ingredients.getOutputs(FluidStack.class).get(0)); + builder + .addSlot(RecipeIngredientRole.OUTPUT, 57, 1) + .setFluidRenderer(10, false, 16, 16) + .addIngredient(ForgeTypes.FLUID_STACK, recipe.outGas()); +// guiFluidStacks.init(2, false, 57, 46, 16, 16, 10, false, (IDrawable) null); +// guiFluidStacks.set(2, (List) ingredients.getOutputs(FluidStack.class).get(1)); + builder + .addSlot(RecipeIngredientRole.OUTPUT, 57, 46) + .setFluidRenderer(10, false, 16, 16) + .addIngredient(ForgeTypes.FLUID_STACK, recipe.outLiquid()); + } - guiFluidStacks.init(1, false, /*37, -3*/ 57, 1, 16, 16, 10, false, null); - guiFluidStacks.set(1, ingredients.getOutputs(FluidStack.class).get(0)); + @Override + public List getTooltipStrings(IRefineryRecipeManager.IDistillationRecipe recipe, IRecipeSlotsView recipeSlotsView, double mouseX, double mouseY) { + return Lists.newArrayList(); + } - guiFluidStacks.init(2, false, /*37, 42*/ 57, 46, 16, 16, 10, false, null); - guiFluidStacks.set(2, ingredients.getOutputs(FluidStack.class).get(1)); + @Override + public boolean handleInput(IRefineryRecipeManager.IDistillationRecipe recipe, double mouseX, double mouseY, InputConstants.Key input) { + return false; } } diff --git a/common/buildcraft/compat/module/jei/factory/CategoryHeatable.java b/common/buildcraft/compat/module/jei/factory/CategoryHeatable.java index 75300fb..f26ccf0 100644 --- a/common/buildcraft/compat/module/jei/factory/CategoryHeatable.java +++ b/common/buildcraft/compat/module/jei/factory/CategoryHeatable.java @@ -1,39 +1,76 @@ package buildcraft.compat.module.jei.factory; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; import buildcraft.api.BCModules; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IGuiFluidStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.BlankRecipeCategory; - -public class CategoryHeatable extends BlankRecipeCategory { - public static final String UID = "buildcraft:category_heatable"; +import buildcraft.api.recipes.IRefineryRecipeManager; +import buildcraft.factory.BCFactoryBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.platform.InputConstants; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.forge.ForgeTypes; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.builder.IRecipeSlotBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fluids.FluidStack; + +import java.util.List; + +//public class CategoryHeatable extends BlankRecipeCategory +public class CategoryHeatable implements IRecipeCategory { + // Calen + public static final RecipeType RECIPE_TYPE = + RecipeType.create(BCModules.FACTORY.getModId(), "category_heatable", IRefineryRecipeManager.IHeatableRecipe.class); + public static final ResourceLocation UID = new ResourceLocation(BCModules.FACTORY.getModId(), "category_heatable"); public static final ResourceLocation energyHeaterBackground = new ResourceLocation("buildcraftfactory:textures/gui/energy_heater.png"); + private final IDrawable background; + private final IDrawable slotIn; + private final IDrawable slotOut; - private final IDrawable background, slotIn, slotOut; + private final IDrawable icon; - public CategoryHeatable(IGuiHelper helper) { - this.background = helper.createDrawable(energyHeaterBackground, 176, 19, 54, 19, 0, 0, 18, 80); - this.slotIn = helper.createDrawable(energyHeaterBackground, 7, 22, 18, 18, 0, 0, 0, 0); - this.slotOut = helper.createDrawable(energyHeaterBackground, 7, 22, 18, 18, 0, 0, 72, 0); + private final IDrawableAnimated animated; + + public CategoryHeatable(IGuiHelper guiHelper) { +// this.background = helper.createDrawable(energyHeaterBackground, 176, 19, 54, 19, 0, 0, 18, 80); + this.background = guiHelper.drawableBuilder(energyHeaterBackground, 176, 19, 54, 19).addPadding(0, 0, 18, 80).build(); + // Calen: top+1 to be at the same height as tubes of background +// this.slotIn = helper.createDrawable(energyHeaterBackground, 7, 22, 18, 18, 0, 0, 0, 0); +// this.slotIn = guiHelper.drawableBuilder(energyHeaterBackground, 7, 22, 18, 18).addPadding(0, 0, 0, 0).build(); + this.slotIn = guiHelper.drawableBuilder(energyHeaterBackground, 7, 22, 18, 18).addPadding(1, 0, 0, 0).build(); +// this.slotOut = helper.createDrawable(energyHeaterBackground, 7, 22, 18, 18, 0, 0, 72, 0); +// this.slotOut = guiHelper.drawableBuilder(energyHeaterBackground, 7, 22, 18, 18).addPadding(0, 0, 72, 0).build(); + this.slotOut = guiHelper.drawableBuilder(energyHeaterBackground, 7, 22, 18, 18).addPadding(1, 0, 72, 0).build(); + + this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BCFactoryBlocks.heatExchange.get())); + + IDrawableStatic overComplete = guiHelper.createDrawable(CategoryHeatable.energyHeaterBackground, 176, 152, 54, 19); + this.animated = guiHelper.createAnimatedDrawable(overComplete, 40, IDrawableAnimated.StartDirection.LEFT, false); } @Override - public String getUid() { - return UID; + public RecipeType getRecipeType() { + return RECIPE_TYPE; } @Override - public String getTitle() { - return "Heatable Fluids"; + public Component getTitle() { +// return new TextComponent("Heatable Fluids"); + return Component.translatable("buildcraft.jei.title.heatable_fluids"); } - @Override public String getModName() { return BCModules.FACTORY.name(); } @@ -44,22 +81,50 @@ public IDrawable getBackground() { } @Override - public void drawExtras(Minecraft minecraft) { - slotIn.draw(minecraft); - slotOut.draw(minecraft); + public IDrawable getIcon() { + return this.icon; } -// @Override -// public void drawAnimations(Minecraft minecraft) {} + @OnlyIn(Dist.CLIENT) + @Override +// public void drawExtras(Minecraft minecraft) + public void draw(IRefineryRecipeManager.IHeatableRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.slotIn.draw(guiGraphics); + this.slotOut.draw(guiGraphics); + + this.animated.draw(guiGraphics, 18, 0); + } @Override - public void setRecipe(IRecipeLayout recipeLayout, WrapperHeatable recipeWrapper, IIngredients ingredients) { - IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); +// public void setRecipe(IRecipeLayout recipeLayout, WrapperHeatable recipeWrapper, IIngredients ingredients) + public void setRecipe(IRecipeLayoutBuilder builder, IRefineryRecipeManager.IHeatableRecipe recipe, IFocusGroup focuses) { +// IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks(); +// guiFluidStacks.init(0, true, 1, 1, 16, 16, 10, false, (IDrawable) null); +// guiFluidStacks.set(0, (List) ingredients.getInputs(FluidStack.class).get(0)); + builder +// .addSlot(RecipeIngredientRole.INPUT, 1, 1) + .addSlot(RecipeIngredientRole.INPUT, 1, 2) + .setFluidRenderer(10, false, 16, 16) + .addIngredient(ForgeTypes.FLUID_STACK, recipe.in()); +// guiFluidStacks.init(1, false, 73, 1, 16, 16, 10, false, (IDrawable) null); +// guiFluidStacks.set(1, (List) ingredients.getOutputs(FluidStack.class).get(0)); + IRecipeSlotBuilder slotBuilder = builder +// .addSlot(RecipeIngredientRole.OUTPUT, 73, 1) + .addSlot(RecipeIngredientRole.OUTPUT, 73, 2) + .setFluidRenderer(10, false, 16, 16); + FluidStack out = recipe.out(); + if (out != null && !out.isEmpty()) { + slotBuilder.addIngredient(ForgeTypes.FLUID_STACK, recipe.out()); + } + } - guiFluidStacks.init(0, true, 1, 1, 16, 16, 10, false, null); - guiFluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + @Override + public List getTooltipStrings(IRefineryRecipeManager.IHeatableRecipe recipe, IRecipeSlotsView recipeSlotsView, double mouseX, double mouseY) { + return Lists.newArrayList(); + } - guiFluidStacks.init(1, false, 73, 1, 16, 16, 10, false, null); - guiFluidStacks.set(1, ingredients.getOutputs(FluidStack.class).get(0)); + @Override + public boolean handleInput(IRefineryRecipeManager.IHeatableRecipe recipe, double mouseX, double mouseY, InputConstants.Key input) { + return false; } } diff --git a/common/buildcraft/compat/module/jei/factory/HandlerCoolable.java b/common/buildcraft/compat/module/jei/factory/HandlerCoolable.java deleted file mode 100644 index a2fa129..0000000 --- a/common/buildcraft/compat/module/jei/factory/HandlerCoolable.java +++ /dev/null @@ -1,15 +0,0 @@ -package buildcraft.compat.module.jei.factory; - -import buildcraft.api.recipes.IRefineryRecipeManager; - -import buildcraft.compat.module.jei.BCPluginJEI; - -import mezz.jei.api.recipe.IRecipeWrapper; -import mezz.jei.api.recipe.IRecipeWrapperFactory; - -public class HandlerCoolable implements IRecipeWrapperFactory { - @Override - public IRecipeWrapper getRecipeWrapper(IRefineryRecipeManager.ICoolableRecipe recipe) { - return new WrapperCoolable(BCPluginJEI.registry.getJeiHelpers().getGuiHelper(), recipe); - } -} diff --git a/common/buildcraft/compat/module/jei/factory/HandlerDistiller.java b/common/buildcraft/compat/module/jei/factory/HandlerDistiller.java deleted file mode 100644 index a510139..0000000 --- a/common/buildcraft/compat/module/jei/factory/HandlerDistiller.java +++ /dev/null @@ -1,15 +0,0 @@ -package buildcraft.compat.module.jei.factory; - -import buildcraft.api.recipes.IRefineryRecipeManager; - -import buildcraft.compat.module.jei.BCPluginJEI; - -import mezz.jei.api.recipe.IRecipeWrapper; -import mezz.jei.api.recipe.IRecipeWrapperFactory; - -public class HandlerDistiller implements IRecipeWrapperFactory { - @Override - public IRecipeWrapper getRecipeWrapper(IRefineryRecipeManager.IDistillationRecipe recipe) { - return new WrapperDistiller(BCPluginJEI.registry.getJeiHelpers().getGuiHelper(), recipe); - } -} diff --git a/common/buildcraft/compat/module/jei/factory/HandlerHeatable.java b/common/buildcraft/compat/module/jei/factory/HandlerHeatable.java deleted file mode 100644 index 0fbb251..0000000 --- a/common/buildcraft/compat/module/jei/factory/HandlerHeatable.java +++ /dev/null @@ -1,15 +0,0 @@ -package buildcraft.compat.module.jei.factory; - -import buildcraft.api.recipes.IRefineryRecipeManager; - -import buildcraft.compat.module.jei.BCPluginJEI; - -import mezz.jei.api.recipe.IRecipeWrapper; -import mezz.jei.api.recipe.IRecipeWrapperFactory; - -public class HandlerHeatable implements IRecipeWrapperFactory { - @Override - public IRecipeWrapper getRecipeWrapper(IRefineryRecipeManager.IHeatableRecipe recipe) { - return new WrapperHeatable(BCPluginJEI.registry.getJeiHelpers().getGuiHelper(), recipe); - } -} diff --git a/common/buildcraft/compat/module/jei/factory/WrapperCoolable.java b/common/buildcraft/compat/module/jei/factory/WrapperCoolable.java deleted file mode 100644 index 518ae0d..0000000 --- a/common/buildcraft/compat/module/jei/factory/WrapperCoolable.java +++ /dev/null @@ -1,86 +0,0 @@ -package buildcraft.compat.module.jei.factory; - -import java.util.List; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import buildcraft.api.recipes.IRefineryRecipeManager; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawableAnimated; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; - -public class WrapperCoolable implements IRecipeWrapper { - private final IRefineryRecipeManager.ICoolableRecipe recipe; - private final ImmutableList in, out; - private final IDrawableAnimated animatedCooling, animatedHeating; - - WrapperCoolable(IGuiHelper guiHelper, IRefineryRecipeManager.ICoolableRecipe recipe) { - this.recipe = recipe; - this.in = ImmutableList.of(recipe.in()); - //noinspection ConstantConditions - this.out = (recipe.out() != null) ? ImmutableList.of(recipe.out()) : ImmutableList.of(); - - IDrawableStatic overComplete = guiHelper.createDrawable(CategoryCoolable.heatExchangerBackground, 52, 171, 54, 17); - this.animatedCooling = guiHelper.createAnimatedDrawable(overComplete, /*recipe.ticks() * 20*/ 40, IDrawableAnimated.StartDirection.LEFT, false); - overComplete = guiHelper.createDrawable(CategoryCoolable.heatExchangerBackground, 52, 188, 54, 17); - this.animatedHeating = guiHelper.createAnimatedDrawable(overComplete, /*recipe.ticks() * 20*/ 40, IDrawableAnimated.StartDirection.RIGHT, false); - } - -// @Override -// public List getInputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getOutputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getFluidInputs() { -// return in; -// } -// -// @Override -// public List getFluidOutputs() { -// return out; -// } -// -// @Override -// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight) {} - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(FluidStack.class, this.in); - ingredients.setOutputs(FluidStack.class, this.out); - } - - @Override - @SideOnly(Side.CLIENT) - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - this.animatedCooling.draw(minecraft, 18, 0); - this.animatedHeating.draw(minecraft, 18, 0); - // minecraft.fontRenderer.drawString("Takes " + (recipe.ticks() / 20.0) + "s", 93, 0, Color.gray.getRGB()); - } - -// @Override -// public void drawAnimations(Minecraft minecraft, int recipeWidth, int recipeHeight) { -// animatedCooling.draw(minecraft, 18, 0); -// animatedHeating.draw(minecraft, 18, 0); -// } - - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return Lists.newArrayList(); - } - - @Override - public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { - return false; - } -} diff --git a/common/buildcraft/compat/module/jei/factory/WrapperDistiller.java b/common/buildcraft/compat/module/jei/factory/WrapperDistiller.java deleted file mode 100644 index 0c4b316..0000000 --- a/common/buildcraft/compat/module/jei/factory/WrapperDistiller.java +++ /dev/null @@ -1,84 +0,0 @@ -package buildcraft.compat.module.jei.factory; - -import java.awt.Color; -import java.util.List; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import buildcraft.api.mj.MjAPI; -import buildcraft.api.recipes.IRefineryRecipeManager; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawableAnimated; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; - -public class WrapperDistiller implements IRecipeWrapper { - public final IRefineryRecipeManager.IDistillationRecipe recipe; - private final ImmutableList in, out; - private final IDrawableAnimated animated; - - WrapperDistiller(IGuiHelper guiHelper, IRefineryRecipeManager.IDistillationRecipe recipe) { - this.recipe = recipe; - this.in = ImmutableList.of(recipe.in()); - this.out = ImmutableList.of(recipe.outGas(), recipe.outLiquid()); - - IDrawableStatic overComplete = guiHelper.createDrawable(CategoryDistiller.distillerBackground, 212, 0, 36, 57); - this.animated = guiHelper.createAnimatedDrawable(overComplete, /*recipe.ticks() * 20*/ 40, IDrawableAnimated.StartDirection.LEFT, false); - } - -// @Override -// public List getInputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getOutputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getFluidInputs() { -// return in; -// } -// -// @Override -// public List getFluidOutputs() { -// return out; -// } -// -// @Override -// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight) {} - - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(FluidStack.class, this.in); - ingredients.setOutputs(FluidStack.class, this.out); - } - - @Override - @SideOnly(Side.CLIENT) - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - this.animated.draw(minecraft, 20, 4); - minecraft.fontRenderer.drawString(MjAPI.formatMj(recipe.powerRequired()) + " MJ", 58, 28, Color.CYAN.getRGB()); - } - -// @Override -// public void drawAnimations(Minecraft minecraft, int recipeWidth, int recipeHeight) { -// animated.draw(minecraft, 0, 0); -// } - - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return Lists.newArrayList(); - } - - @Override - public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { - return false; - } -} diff --git a/common/buildcraft/compat/module/jei/factory/WrapperHeatable.java b/common/buildcraft/compat/module/jei/factory/WrapperHeatable.java deleted file mode 100644 index 593aed0..0000000 --- a/common/buildcraft/compat/module/jei/factory/WrapperHeatable.java +++ /dev/null @@ -1,84 +0,0 @@ -package buildcraft.compat.module.jei.factory; - -import java.util.List; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import buildcraft.api.recipes.IRefineryRecipeManager; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawableAnimated; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; - -public class WrapperHeatable implements IRecipeWrapper { - private final IRefineryRecipeManager.IHeatableRecipe heatable; - private final ImmutableList in, out; - private final IDrawableAnimated animated; - - public WrapperHeatable(IGuiHelper guiHelper, IRefineryRecipeManager.IHeatableRecipe recipe) { - this.heatable = recipe; - this.in = ImmutableList.of(recipe.in()); - //noinspection ConstantConditions - this.out = (recipe.out() != null) ? ImmutableList.of(recipe.out()) : ImmutableList.of(); - - IDrawableStatic overComplete = guiHelper.createDrawable(CategoryHeatable.energyHeaterBackground, 176, 152, 54, 19); - animated = guiHelper.createAnimatedDrawable(overComplete, /*recipe.ticks() * 20*/ 40, IDrawableAnimated.StartDirection.LEFT, false); - } - -// @Override -// public List getInputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getOutputs() { -// return Collections.emptyList(); -// } -// -// @Override -// public List getFluidInputs() { -// return in; -// } -// -// @Override -// public List getFluidOutputs() { -// return out; -// } -// -// @Override -// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight) {} - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(FluidStack.class, this.in); - ingredients.setOutputs(FluidStack.class, this.out); - } - - @Override - @SideOnly(Side.CLIENT) - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - this.animated.draw(minecraft, 18, 0); -// minecraft.fontRenderer.drawString("Takes " + (heatable.ticks() / 20.0) + "s", 93, 0, Color.gray.getRGB()); -// int rftick = Math.abs(heatable.heatFrom() - heatable.heatTo()) * BuildCraftFactory.rfPerHeatPerMB * heatable.in().amount; -// minecraft.fontRenderer.drawString(" at " + rftick + "RF/t", 93, 11, Color.gray.getRGB()); - } - -// @Override -// public void drawAnimations(Minecraft minecraft, int recipeWidth, int recipeHeight) { -// animated.draw(minecraft, 18, 0); -// } - - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return Lists.newArrayList(); - } - - @Override - public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { - return false; - } -} diff --git a/common/buildcraft/compat/module/jei/factory/package-info.java b/common/buildcraft/compat/module/jei/factory/package-info.java index 04b20ee..3153dd2 100644 --- a/common/buildcraft/compat/module/jei/factory/package-info.java +++ b/common/buildcraft/compat/module/jei/factory/package-info.java @@ -2,5 +2,6 @@ @MethodsReturnNonnullByDefault package buildcraft.compat.module.jei.factory; -import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/common/buildcraft/compat/module/jei/gui/GuiGhostIngredientHandlerBuildCraft.java b/common/buildcraft/compat/module/jei/gui/GuiGhostIngredientHandlerBuildCraft.java new file mode 100644 index 0000000..425adc6 --- /dev/null +++ b/common/buildcraft/compat/module/jei/gui/GuiGhostIngredientHandlerBuildCraft.java @@ -0,0 +1,72 @@ +package buildcraft.compat.module.jei.gui; + +import buildcraft.core.list.ContainerList; +import buildcraft.core.list.GuiList; +import buildcraft.lib.gui.GuiBC8; +import buildcraft.lib.gui.slot.SlotPhantom; +import com.google.common.collect.Lists; +import mezz.jei.api.gui.handlers.IGhostIngredientHandler; +import mezz.jei.api.ingredients.ITypedIngredient; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.world.item.ItemStack; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; + +public class GuiGhostIngredientHandlerBuildCraft implements IGhostIngredientHandler { + @Override + public List> getTargetsTyped(GuiBC8 gui, ITypedIngredient ingredient, boolean doStart) { + if (ingredient.getIngredient() instanceof ItemStack) { + if (gui instanceof GuiList guiList) { + List> ret = Lists.newArrayList(); + for (int lineIndex = 0; lineIndex < guiList.container.lines.length; lineIndex++) { + if (guiList.container.lines[lineIndex].isOneStackMode()) { + ContainerList.WidgetListSlot slot = guiList.container.slots[lineIndex][0]; + ret.add((Target) new SlotPhantomTarget(gui, 8 + 0 * 18, 32 + lineIndex * 34, stack -> guiList.clientSetStackToServer(slot, stack))); + } else { + Arrays.stream(guiList.container.slots[lineIndex]) + .forEach( + slot -> ret.add( + (Target) new SlotPhantomTarget(gui, 8 + slot.slotIndex * 18, 32 + slot.lineIndex * 34, stack -> guiList.clientSetStackToServer(slot, stack)) + ) + ); + } + } + return ret; + } else { + return gui.container.slots.stream() + .filter(s -> s instanceof SlotPhantom) + .map(s -> (SlotPhantom) s) + .map(slot -> (Target) new SlotPhantomTarget(gui, slot.x, slot.y, stack -> gui.container.sendSetPhantomSlot(slot, stack))) + .toList(); + } + } else { + return Lists.newArrayList(); + } + } + + @Override + public void onComplete() { + } + + private static class SlotPhantomTarget implements Target { + private final Rect2i area; + private final Consumer stackConsumer; + + private SlotPhantomTarget(GuiBC8 gui, int slotX, int slotY, Consumer stackConsumer) { + this.area = new Rect2i(gui.getGuiLeft() + slotX, gui.getGuiTop() + slotY, 16, 16); + this.stackConsumer = stackConsumer; + } + + @Override + public Rect2i getArea() { + return area; + } + + @Override + public void accept(ItemStack stack) { + stackConsumer.accept(stack); + } + } +} diff --git a/common/buildcraft/compat/module/jei/gui/GuiHandlerBuildCraft.java b/common/buildcraft/compat/module/jei/gui/GuiHandlerBuildCraft.java new file mode 100644 index 0000000..8cf0f13 --- /dev/null +++ b/common/buildcraft/compat/module/jei/gui/GuiHandlerBuildCraft.java @@ -0,0 +1,48 @@ +package buildcraft.compat.module.jei.gui; + +import buildcraft.lib.gui.GuiBC8; +import buildcraft.lib.gui.IGuiElement; +import buildcraft.lib.gui.pos.GuiRectangle; +import mezz.jei.api.gui.handlers.IGuiContainerHandler; +import net.minecraft.client.renderer.Rect2i; +import net.minecraft.util.Mth; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class GuiHandlerBuildCraft implements IGuiContainerHandler> { + @NotNull + @Override + public List getGuiExtraAreas(GuiBC8 guiDirty) { + List list = new ArrayList<>(); + + for (IGuiElement element : guiDirty.mainGui.shownElements) { + GuiRectangle rect = element.asImmutable(); + int x = (int) rect.x; + int y = (int) rect.y; +// int endX = MathHelper.ceil(rect.getEndX()); + int endX = Mth.ceil(rect.getEndX()); +// int endY = MathHelper.ceil(rect.getEndY()); + int endY = Mth.ceil(rect.getEndY()); + int width = endX - x; + int height = endY - y; + list.add(new Rect2i(x, y, width, height)); + } + + return list; + } + + +// @Nullable +// @Override +// public Object getIngredientUnderMouse(GuiBC8 screen, double mouseX, double mouseY) { +// return screen.getIngredientUnderMouse(mouseX, mouseY); +// } + +// @NotNull +// @Override +// public Collection getGuiClickableAreas(GuiBC8 screen, double mouseX, double mouseY) { +// return Collections.emptyList(); +// } +} diff --git a/common/buildcraft/compat/module/jei/recipe/GateGuiHandler.java b/common/buildcraft/compat/module/jei/recipe/GateGuiHandler.java deleted file mode 100644 index bb27224..0000000 --- a/common/buildcraft/compat/module/jei/recipe/GateGuiHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -package buildcraft.compat.module.jei.recipe; -//package buildcraft.compat.module.jei; -// -//import java.awt.Rectangle; -//import java.util.ArrayList; -//import java.util.List; -// -//import buildcraft.transport.gui.GuiGateInterface; -// -//import mezz.jei.api.gui.IAdvancedGuiHandler; -// -//public class GateGuiHandler implements IAdvancedGuiHandler { -// @Override -// public Class getGuiContainerClass() { -// return GuiGateInterface.class; -// } -// -// @Override -// public List getGuiExtraAreas(GuiGateInterface gate) { -// List rectangles = new ArrayList<>(); -// int guiLeft = (gate.width - gate.xSize()) / 2; -// int guiTop = (gate.height - gate.ySize()) / 2; -// -// // Actions -// int actionStartX = guiLeft + gate.xSize(); -// int actionStartY = guiTop + 6; -// -// if (gate.actionRows > 1) { -// int endRow = gate.actionRows * 18; -// rectangles.add(new Rectangle(actionStartX, actionStartY, 6 * 18, endRow)); -// rectangles.add(new Rectangle(actionStartX, actionStartY + endRow, gate.lastActionRowSize, 18)); -// } else if (gate.actionRows == 1) { -// rectangles.add(new Rectangle(actionStartX, actionStartY, gate.lastActionRowSize, 18)); -// } -// return rectangles; -// } -//} diff --git a/common/buildcraft/compat/module/jei/recipe/GuiHandlerBuildCraft.java b/common/buildcraft/compat/module/jei/recipe/GuiHandlerBuildCraft.java deleted file mode 100644 index f6a434d..0000000 --- a/common/buildcraft/compat/module/jei/recipe/GuiHandlerBuildCraft.java +++ /dev/null @@ -1,51 +0,0 @@ -package buildcraft.compat.module.jei.recipe; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - -import net.minecraft.util.math.MathHelper; - -import buildcraft.lib.gui.GuiBC8; -import buildcraft.lib.gui.IGuiElement; -import buildcraft.lib.gui.pos.GuiRectangle; - -import mezz.jei.api.gui.IAdvancedGuiHandler; - -public class GuiHandlerBuildCraft implements IAdvancedGuiHandler { - - @Override - public Class getGuiContainerClass() { - return GuiBC8.class; - } - - @Override - @Nullable - public List getGuiExtraAreas(GuiBC8 guiDirty) { - GuiBC8 gui = guiDirty; - // Get the rectangles of everything that is *outside* the main gui area - List list = new ArrayList<>(); - for (IGuiElement element : gui.mainGui.shownElements) { - // Ignore children: all ledger style elements are top level - GuiRectangle rect = element.asImmutable(); -// if (!gui.rootElement.contains(rect)) { - // Round down x and y - int x = (int) rect.x; - int y = (int) rect.y; - // Round up width and height - int endX = MathHelper.ceil(rect.getEndX()); - int endY = MathHelper.ceil(rect.getEndY()); - int width = endX - x; - int height = endY - y; - list.add(new Rectangle(x, y, width, height)); -// } - } - if (list.isEmpty()) { - // Cheapen JEI checks a tiny bit. Possibly. - return null; - } - return list; - } -} diff --git a/common/buildcraft/compat/module/jei/recipe/HandlerFlexibleRecipe.java b/common/buildcraft/compat/module/jei/recipe/HandlerFlexibleRecipe.java deleted file mode 100644 index 1454d01..0000000 --- a/common/buildcraft/compat/module/jei/recipe/HandlerFlexibleRecipe.java +++ /dev/null @@ -1,15 +0,0 @@ -package buildcraft.compat.module.jei.recipe; -//package buildcraft.compat.module.jei.recipe; -// -//import buildcraft.api.recipes.IFlexibleRecipe; -// -//import javax.annotation.Nonnull; -//import mezz.jei.api.recipe.IRecipeHandler; -// -//public abstract class HandlerFlexibleRecipe implements IRecipeHandler { -// @Nonnull -// @Override -// public Class getRecipeClass() { -// return IFlexibleRecipe.class; -// } -//} diff --git a/common/buildcraft/compat/module/jei/recipe/LedgerGuiHandler.java b/common/buildcraft/compat/module/jei/recipe/LedgerGuiHandler.java deleted file mode 100644 index 7624e92..0000000 --- a/common/buildcraft/compat/module/jei/recipe/LedgerGuiHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package buildcraft.compat.module.jei.recipe; -//package buildcraft.compat.module.jei; -// -//import java.awt.Rectangle; -//import java.util.ArrayList; -//import java.util.List; -// -//import buildcraft.core.lib.gui.GuiBuildCraft; -//import buildcraft.core.lib.gui.Ledger; -// -//import mezz.jei.api.gui.IAdvancedGuiHandler; -// -//public class LedgerGuiHandler implements IAdvancedGuiHandler { -// @Override -// public Class getGuiContainerClass() { -// return GuiBuildCraft.class; -// } -// -// @Override -// public List getGuiExtraAreas(GuiBuildCraft gui) { -// List rectangles = new ArrayList<>(); -// int guiLeft = (gui.width - gui.xSize()) / 2; -// int guiTop = (gui.height - gui.ySize()) / 2; -// -// int yPos = 8; -// for (Ledger l : gui.ledgerManager.getAll()) { -// if (l.isVisible()) { -// rectangles.add(new Rectangle(guiLeft + gui.xSize(), guiTop + yPos, l.getWidth(), l.getHeight())); -// yPos += l.getHeight(); -// } -// } -// -// return rectangles; -// } -//} diff --git a/common/buildcraft/compat/module/jei/silicon/CategoryAssemblyTable.java b/common/buildcraft/compat/module/jei/silicon/CategoryAssemblyTable.java index 701b365..15da8e8 100644 --- a/common/buildcraft/compat/module/jei/silicon/CategoryAssemblyTable.java +++ b/common/buildcraft/compat/module/jei/silicon/CategoryAssemblyTable.java @@ -1,68 +1,145 @@ package buildcraft.compat.module.jei.silicon; +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.api.recipes.IAssemblyRecipe; +import buildcraft.api.recipes.IngredientStack; +import buildcraft.silicon.BCSiliconBlocks; +import com.google.common.collect.Lists; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import java.awt.*; import java.util.List; +import java.util.*; + +public class CategoryAssemblyTable implements IRecipeCategory { + // Calen + public static final RecipeType RECIPE_TYPE = + RecipeType.create(BCModules.SILICON.getModId(), "assembly", IAssemblyRecipe.class); + // public static final ResourceLocation UID = new ResourceLocation("buildcraft-compat:silicon.assembly"); + public static final ResourceLocation UID = new ResourceLocation(BCModules.SILICON.getModId(), "assembly"); + protected final ResourceLocation backgroundLocation = new ResourceLocation("buildcraftsilicon", "textures/gui/assembly_table.png"); + private final IDrawable background; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; + private final IDrawable icon; -import buildcraft.api.BCModules; + private final Map progressBarMap = new HashMap<>(); + private final Map> inputsMap = new HashMap<>(); + private final Map outputsMap = new HashMap<>(); -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IGuiItemStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; + @OnlyIn(Dist.CLIENT) + private Font font = Minecraft.getInstance().font; -public class CategoryAssemblyTable implements IRecipeCategory { - public static final String UID = "buildcraft-compat:silicon.assembly"; + // public CategoryAssemblyTable(IGuiHelper guiHelper, AssemblyRecipeBasic recipe) + public CategoryAssemblyTable(IGuiHelper guiHelper, Collection recipes) { +// this.background = guiHelper.createDrawable(this.backgroundLocation, 5, 34, 166, 76, 10, 0, 0, 0); + this.background = guiHelper.drawableBuilder(this.backgroundLocation, 5, 34, 166, 76).addPadding(10, 0, 0, 0).build(); - protected final ResourceLocation backgroundLocation; - private final IDrawable background; + this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BCSiliconBlocks.assemblyTable.get())); + + ResourceLocation backgroundLocation = new ResourceLocation("buildcraftsilicon", "textures/gui/assembly_table.png"); +// IDrawableStatic progressDrawable = guiHelper.createDrawable(backgroundLocation, 176, 48, 4, 71, 10, 0, 0, 0); + IDrawableStatic progressDrawable = guiHelper.drawableBuilder(backgroundLocation, 176, 48, 4, 71).addPadding(10, 0, 0, 0).build(); + + for (IAssemblyRecipe recipe : recipes) { + List _inputs = Lists.newArrayList(); + + for (IngredientStack in : recipe.getInputsFor(ItemStack.EMPTY)) { + List inner = new ArrayList(); + + for (ItemStack matching : in.ingredient.getItems()) { + matching = matching.copy(); + matching.setCount(in.count); + inner.add(matching); + } + + _inputs.add(Ingredient.of(inner.stream())); + } - public CategoryAssemblyTable(IGuiHelper guiHelper) { - this.backgroundLocation = new ResourceLocation("buildcraftsilicon", "textures/gui/assembly_table.png"); - this.background = guiHelper.createDrawable(backgroundLocation, 5, 34, 166, 76, 10, 0, 0, 0); + this.inputsMap.put(recipe, _inputs); + this.outputsMap.put(recipe, Ingredient.of(recipe.getOutputPreviews().stream())); + + long mj = recipe.getRequiredMicroJoulesFor(ItemStack.EMPTY); +// this.progressBar = guiHelper.createAnimatedDrawable(progressDrawable, (int) Math.max(10L, mj / MjAPI.MJ / 50L), IDrawableAnimated.StartDirection.BOTTOM, false); + progressBarMap.put(recipe, guiHelper.createAnimatedDrawable(progressDrawable, (int) Math.max(10L, mj / MjAPI.MJ / 50L), IDrawableAnimated.StartDirection.BOTTOM, false)); + } } @Override - public String getUid() { - return UID; + public RecipeType getRecipeType() { + return RECIPE_TYPE; } @Override - public String getTitle() { - return "Assembly Table"; + public Component getTitle() { +// return new TextComponent("Assembly Table"); + return Component.translatable("tile.assemblyTableBlock.name"); } - @Override public String getModName() { return BCModules.SILICON.name(); } @Override public IDrawable getBackground() { - return background; + return this.background; + } + + @Override + public IDrawable getIcon() { + return this.icon; } + @OnlyIn(Dist.CLIENT) @Override - public void setRecipe(IRecipeLayout recipeLayout, WrapperAssemblyTable recipeWrapper, IIngredients ingredients) { - IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); - - List> inputs = ingredients.getInputs(ItemStack.class); - for (int i = 0; i < inputs.size(); i++) { - guiItemStacks.init(i, true, 2 + (i % 3) * 18, 11 + (i / 3) * 18); - - guiItemStacks.set(i, inputs.get(i)); -// Object o = recipeWrapper.getInputs().get(i); -// if (o instanceof ItemStack) { -// guiItemStacks.set(i, (ItemStack) o); -// } else if (o instanceof List) { -// guiItemStacks.set(i, (List) o); -// } + public void draw(IAssemblyRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { +// this.progressBar.draw(stack, 81, 2); + this.progressBarMap.get(recipe).draw(guiGraphics, 81, 2); + long mj = recipe.getRequiredMicroJoulesFor(ItemStack.EMPTY); + guiGraphics.drawString(this.font, MjAPI.formatMj(mj) + " MJ", 4, 0, Color.gray.getRGB(), false); + } + + @Override +// public void setRecipe(IRecipeLayout recipeLayout, WrapperAssemblyTable recipeWrapper, IIngredients ingredients) + public void setRecipe(IRecipeLayoutBuilder builder, IAssemblyRecipe recipe, IFocusGroup focuses) { +// IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); + + // Calen: the looks moved x-1 y-1 off the slot in 1.18.2 with the position used in 1.12.2 +// for (int i = 0; i < inputs.size(); ++i) + List inputs = inputsMap.get(recipe); + for (int i = 0; i < inputs.size(); ++i) { +// guiItemStacks.init(i, true, 2 + i % 3 * 18, 11 + i / 3 * 18); +// guiItemStacks.set(i, (List) inputs.get(i)); + builder +// .addSlot(RecipeIngredientRole.INPUT, 2 + i % 3 * 18, 11 + i / 3 * 18) + .addSlot(RecipeIngredientRole.INPUT, 3 + i % 3 * 18, 12 + i / 3 * 18) + .addIngredients(inputs.get(i)); } - guiItemStacks.init(12, false, 110, 11); - guiItemStacks.set(12, ingredients.getOutputs(ItemStack.class).get(0)); +// guiItemStacks.init(12, false, 110, 11); +// guiItemStacks.set(12, (List) ingredients.getOutputs(ItemStack.class).get(0)); + builder +// .addSlot(RecipeIngredientRole.OUTPUT, 110, 11) + .addSlot(RecipeIngredientRole.OUTPUT, 111, 12) + .addIngredients(this.outputsMap.get(recipe)); } } diff --git a/common/buildcraft/compat/module/jei/silicon/CategoryIntegrationTable.java b/common/buildcraft/compat/module/jei/silicon/CategoryIntegrationTable.java index ffe1d16..759ebe6 100644 --- a/common/buildcraft/compat/module/jei/silicon/CategoryIntegrationTable.java +++ b/common/buildcraft/compat/module/jei/silicon/CategoryIntegrationTable.java @@ -1,77 +1,126 @@ package buildcraft.compat.module.jei.silicon; -import java.util.List; +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.api.recipes.IngredientStack; +import buildcraft.api.recipes.IntegrationRecipe; +import buildcraft.silicon.BCSiliconBlocks; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; +import java.awt.*; +import java.util.List; -import buildcraft.api.BCModules; +//public class CategoryIntegrationTable implements IRecipeCategory +public class CategoryIntegrationTable implements IRecipeCategory { + // Calen + public static final RecipeType RECIPE_TYPE = + RecipeType.create(BCModules.SILICON.getModId(), "integration", IntegrationRecipe.class); + // public static final ResourceLocation UID = new ResourceLocation("buildcraft-compat:silicon.integration"); + public static final ResourceLocation UID = new ResourceLocation(BCModules.SILICON.getModId(), "integration"); + protected final ResourceLocation backgroundLocation = new ResourceLocation("buildcraftsilicon", "textures/gui/integration_table.png"); + private final IDrawable background; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IGuiItemStackGroup; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; + private final IDrawable icon; -public class CategoryIntegrationTable implements IRecipeCategory { - public static final String UID = "buildcraft-compat:silicon.integration"; + private final IDrawableAnimated progressBar; - protected final ResourceLocation backgroundLocation; - private final IDrawable background; - private WrapperIntegrationTable wrapper = null; + @OnlyIn(Dist.CLIENT) + private Font font = Minecraft.getInstance().font; public CategoryIntegrationTable(IGuiHelper guiHelper) { - backgroundLocation = new ResourceLocation("buildcraftsilicon", "textures/gui/integration_table.png"); - background = guiHelper.createDrawable(backgroundLocation, 17, 22, 153, 71, 0, 0, 9, 0); +// this.background = guiHelper.createDrawable(this.backgroundLocation, 17, 22, 153, 71, 0, 0, 9, 0); + this.background = guiHelper.drawableBuilder(this.backgroundLocation, 17, 21, 153, 72).addPadding(0, 0, 9, 0).build(); + + this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BCSiliconBlocks.integrationTable.get())); + +// IDrawableStatic progressDrawable = guiHelper.createDrawable(backgroundLocation, 176, 17, 4, 69, 0, 0, 0, 0); + IDrawableStatic progressDrawable = guiHelper.drawableBuilder(this.backgroundLocation, 176, 0, 4, 70).addPadding(0, 0, 0, 0).build(); + this.progressBar = guiHelper.createAnimatedDrawable(progressDrawable, 720, IDrawableAnimated.StartDirection.BOTTOM, false); } @Override - public String getUid() { - return UID; + public RecipeType getRecipeType() { + return RECIPE_TYPE; } - @Override - public String getTitle() { - return "Integration Table"; + public Component getTitle() { +// return new TextComponent("Integration Table"); + return Component.translatable("tile.integrationTableBlock.name"); } - @Override public String getModName() { return BCModules.SILICON.name(); } - @Override public IDrawable getBackground() { - return background; + return this.background; } @Override - public void setRecipe(IRecipeLayout recipeLayout, WrapperIntegrationTable recipeWrapper, IIngredients ingredients) { - IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); + public IDrawable getIcon() { + return this.icon; + } - List> inputs = ingredients.getInputs(ItemStack.class); - int inventoryIndex = 0; + @OnlyIn(Dist.CLIENT) + @Override + public void draw(IntegrationRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.progressBar.draw(guiGraphics, 156, 1); + guiGraphics.drawString(this.font, MjAPI.formatMj(recipe.getRequiredMicroJoules()) + " MJ", 80, 52, Color.gray.getRGB(), false); + + } + + @Override + // public void setRecipe(IRecipeLayout recipeLayout, WrapperIntegrationTable recipeWrapper, IIngredients ingredients) + public void setRecipe(IRecipeLayoutBuilder builder, IntegrationRecipe recipe, IFocusGroup focuses) { +// IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks(); +// List> inputs = ingredients.getInputs(ItemStack.class); +// int inventoryIndex = 0; + + List inputs = recipe.getRequirements(); for (int y = 0; y < 3; ++y) { for (int x = 0; x < 3; ++x) { - int slotIndex = ((x == 1) && (y == 1)) ? 0 : (x + y * 3 + 1); - if (inputs.size() > slotIndex) { - guiItemStacks.init(inventoryIndex, true, 19 + x * 25, 24 + y * 25); - guiItemStacks.set(inventoryIndex, inputs.get(slotIndex)); - inventoryIndex++; +// int slotIndex = x == 1 && y == 1 ? 0 : x + y * 3 + 1; + if (x == 1 && y == 1) { + builder + .addSlot(RecipeIngredientRole.INPUT, 11 + x * 25, 3 + y * 25) + .addIngredients(recipe.getCenterStack().ingredient); + } else { + int requirementsIndex = (x + y * 3 < 4) ? (x + y * 3) : (x + y * 3 - 1); + if (requirementsIndex < inputs.size()) { +// guiItemStacks.init(inventoryIndex, true, 19 + x * 25, 24 + y * 25); +// guiItemStacks.set(inventoryIndex, (List) inputs.get(slotIndex)); + builder + .addSlot(RecipeIngredientRole.INPUT, 11 + x * 25, 3 + y * 25) + .addIngredients(inputs.get(requirementsIndex).ingredient); +// ++inventoryIndex; + } } - // this.addSlotToContainer(new SlotBase(x == 1 && y == 1 ? tile.invTarget : tile.invToIntegrate, indexes[x + y * 3], 19 + x * 25, 24 + y * 25)); } } -// for (int i = 0; i < wrapper.getInputs().size(); i++) { -// int x = ContainerIntegrationTable.SLOT_X[i] - 9; -// int y = ContainerIntegrationTable.SLOT_Y[i] - 23; -// guiItemStacks.init(i, true, x, y); -// guiItemStacks.set(i, (List) wrapper.getInputs().get(i)); -// } - - guiItemStacks.init(inventoryIndex, false, 129, 26); - guiItemStacks.set(inventoryIndex, ingredients.getOutputs(ItemStack.class).get(0)); +// guiItemStacks.init(inventoryIndex, false, 129, 26); +// guiItemStacks.set(inventoryIndex, (List) ingredients.getOutputs(ItemStack.class).get(0)); + builder + .addSlot(RecipeIngredientRole.OUTPUT, 130, 28) + .addIngredients(Ingredient.of(recipe.getExampleOutput())); } } diff --git a/common/buildcraft/compat/module/jei/silicon/CategoryProgrammingTable.java b/common/buildcraft/compat/module/jei/silicon/CategoryProgrammingTable.java new file mode 100644 index 0000000..fcf4d19 --- /dev/null +++ b/common/buildcraft/compat/module/jei/silicon/CategoryProgrammingTable.java @@ -0,0 +1,108 @@ +package buildcraft.compat.module.jei.silicon; + +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.api.recipes.IProgrammingRecipe; +import buildcraft.silicon.BCSiliconBlocks; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableAnimated; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.recipe.IFocusGroup; +import mezz.jei.api.recipe.RecipeIngredientRole; +import mezz.jei.api.recipe.RecipeType; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import java.awt.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class CategoryProgrammingTable implements IRecipeCategory { + public static final RecipeType RECIPE_TYPE = + RecipeType.create(BCModules.SILICON.getModId(), "programming", IProgrammingRecipe.class); + public static final ResourceLocation UID = new ResourceLocation(BCModules.SILICON.getModId(), "programming"); + protected final ResourceLocation backgroundLocation = new ResourceLocation("buildcraftsilicon", "textures/gui/programming_table.png"); + private final IDrawable background; + private final IDrawable inputSlot; + private final IDrawable outputSlot; + private final IDrawable arrow; + private final IDrawable progressBarBackground; + private final IDrawableAnimated defaultProgressBar; + private final Map progressBarMap = new HashMap<>(); + private final IDrawable icon; + @OnlyIn(Dist.CLIENT) + private Font font = Minecraft.getInstance().font; + + public CategoryProgrammingTable(IGuiHelper guiHelper, Collection recipes) { + this.background = guiHelper.createBlankDrawable(72, 72); + this.inputSlot = guiHelper.drawableBuilder(this.backgroundLocation, 7, 35, 18, 18).build(); + this.outputSlot = guiHelper.drawableBuilder(this.backgroundLocation, 7, 89, 18, 18).build(); + this.arrow = guiHelper.drawableBuilder(this.backgroundLocation, 28, 40, 11, 8).build(); + this.progressBarBackground = guiHelper.drawableBuilder(this.backgroundLocation, 163, 35, 6, 72).build(); + + this.icon = guiHelper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(BCSiliconBlocks.programmingTable.get())); + + IDrawableStatic progressDrawable = guiHelper.drawableBuilder(this.backgroundLocation, 176, 18, 4, 70).addPadding(0, 0, 0, 0).build(); + this.defaultProgressBar = guiHelper.createAnimatedDrawable(progressDrawable, 720, IDrawableAnimated.StartDirection.BOTTOM, false); + for (IProgrammingRecipe recipe : recipes) { + long mj = recipe.getEnergyCost(); + progressBarMap.put(mj, guiHelper.createAnimatedDrawable(progressDrawable, (int) Math.max(10L, mj / MjAPI.MJ / 50L), IDrawableAnimated.StartDirection.BOTTOM, false)); + } + } + + @Override + public RecipeType getRecipeType() { + return RECIPE_TYPE; + } + + @Override + public Component getTitle() { + return Component.translatable("tile.programmingTableBlock.name"); + } + + @Override + public IDrawable getBackground() { + return background; + } + + @Override + public IDrawable getIcon() { + return this.icon; + } + + @OnlyIn(Dist.CLIENT) + @Override + public void draw(IProgrammingRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics guiGraphics, double mouseX, double mouseY) { + this.inputSlot.draw(guiGraphics, 2, 27); + this.arrow.draw(guiGraphics, 2 + 18 + 5, 27 + 5); + this.outputSlot.draw(guiGraphics, 2 + 18 + 5 + 11 + 5, 27); + this.progressBarBackground.draw(guiGraphics, 66, 0); + this.progressBarMap.getOrDefault(recipe.getEnergyCost(), this.defaultProgressBar).draw(guiGraphics, 67, 1); + long mj = recipe.getEnergyCost(); + guiGraphics.drawString(font, MjAPI.formatMj(mj) + " MJ", 10, 30 + 5 + 8 + 10, Color.gray.getRGB(), false); + } + + @Override + public void setRecipe(IRecipeLayoutBuilder builder, IProgrammingRecipe recipe, IFocusGroup focuses) { + builder + .addSlot(RecipeIngredientRole.INPUT, 2 + 1, 27 + 1) + .addIngredients(recipe.getInput().ingredient); + + builder + .addSlot(RecipeIngredientRole.OUTPUT, 2 + 18 + 5 + 11 + 5 + 1, 27 + 1) + .addIngredients(Ingredient.of(recipe.getOutput())); + } +} diff --git a/common/buildcraft/compat/module/jei/silicon/HandlerIntegrationTable.java b/common/buildcraft/compat/module/jei/silicon/HandlerIntegrationTable.java deleted file mode 100644 index dfefe11..0000000 --- a/common/buildcraft/compat/module/jei/silicon/HandlerIntegrationTable.java +++ /dev/null @@ -1,38 +0,0 @@ -package buildcraft.compat.module.jei.silicon; - -import buildcraft.api.recipes.IntegrationRecipe; - -import buildcraft.compat.module.jei.BCPluginJEI; - -import mezz.jei.api.recipe.IRecipeWrapper; -import mezz.jei.api.recipe.IRecipeWrapperFactory; - -public class HandlerIntegrationTable implements IRecipeWrapperFactory { - @Override - public IRecipeWrapper getRecipeWrapper(IntegrationRecipe recipe) { - return new WrapperIntegrationTable(BCPluginJEI.registry.getJeiHelpers().getGuiHelper(), recipe); - } - - // -// @Nonnull -// @Override -// public Class getRecipeClass() { -// return IIntegrationRecipe.class; -// } -// -// @Override -// public String getRecipeCategoryUid() { -// return CategoryIntegrationTable.UID; -// } -// -// @Nonnull -// @Override -// public IRecipeWrapper getRecipeWrapper(@Nonnull IIntegrationRecipe recipe) { -// return new WrapperIntegrationTable(BCPluginJEI.registry.getJeiHelpers().getGuiHelper(), recipe); -// } -// -// @Override -// public boolean isRecipeValid(@Nonnull IIntegrationRecipe recipe) { -// return true; -// } -} diff --git a/common/buildcraft/compat/module/jei/silicon/Utils.java b/common/buildcraft/compat/module/jei/silicon/Utils.java index 197c28d..b7fb4fa 100644 --- a/common/buildcraft/compat/module/jei/silicon/Utils.java +++ b/common/buildcraft/compat/module/jei/silicon/Utils.java @@ -1,15 +1,19 @@ package buildcraft.compat.module.jei.silicon; -import java.util.List; -import com.google.common.collect.Lists; -import net.minecraft.item.ItemStack; import buildcraft.api.recipes.StackDefinition; +import com.google.common.collect.Lists; +import net.minecraft.world.item.ItemStack; + +import java.util.List; public final class Utils { + public Utils() { + } + public static List getItemStacks(StackDefinition definition) { List list = Lists.newArrayList(); - if (definition.filter != null) { + for (ItemStack stack : definition.filter.getExamples()) { ItemStack sizedStack = stack.copy(); sizedStack.setCount(definition.count); diff --git a/common/buildcraft/compat/module/jei/silicon/WrapperAssemblyTable.java b/common/buildcraft/compat/module/jei/silicon/WrapperAssemblyTable.java deleted file mode 100644 index 0015916..0000000 --- a/common/buildcraft/compat/module/jei/silicon/WrapperAssemblyTable.java +++ /dev/null @@ -1,83 +0,0 @@ -package buildcraft.compat.module.jei.silicon; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.List; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import buildcraft.api.mj.MjAPI; -import buildcraft.api.recipes.AssemblyRecipeBasic; -import buildcraft.api.recipes.IngredientStack; - -import buildcraft.compat.module.jei.BCPluginJEI; - -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawableAnimated; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; - -public class WrapperAssemblyTable implements IRecipeWrapper { - private final AssemblyRecipeBasic recipe; - private final IDrawableAnimated progressBar; - private final List> inputs; - private final List outputs; - - public WrapperAssemblyTable(AssemblyRecipeBasic recipe) { - this.recipe = recipe; - List> _inputs = Lists.newArrayList(); - for (IngredientStack in : recipe.getInputsFor(ItemStack.EMPTY)) { - List inner = new ArrayList<>(); - for (ItemStack matching : in.ingredient.getMatchingStacks()) { - matching = matching.copy(); - matching.setCount(in.count); - inner.add(matching); - } - _inputs.add(inner); - } - this.inputs = ImmutableList.copyOf(_inputs); - this.outputs = ImmutableList.copyOf(recipe.getOutputPreviews()); - - IGuiHelper guiHelper = BCPluginJEI.registry.getJeiHelpers().getGuiHelper(); - - ResourceLocation backgroundLocation = - new ResourceLocation("buildcraftsilicon", "textures/gui/assembly_table.png"); - IDrawableStatic progressDrawable = guiHelper.createDrawable(backgroundLocation, 176, 48, 4, 71, 10, 0, 0, 0); - long mj = this.recipe.getRequiredMicroJoulesFor(ItemStack.EMPTY); - progressBar = guiHelper.createAnimatedDrawable(progressDrawable, (int) Math.max(10, mj / MjAPI.MJ / 50), - IDrawableAnimated.StartDirection.BOTTOM, false); - } - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputLists(ItemStack.class, this.inputs); - ingredients.setOutputs(ItemStack.class, this.outputs); - } - - @Override - @SideOnly(Side.CLIENT) - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - this.progressBar.draw(minecraft, 81, 2); - long mj = this.recipe.getRequiredMicroJoulesFor(ItemStack.EMPTY); - minecraft.fontRenderer.drawString(MjAPI.formatMj(mj) + " MJ", 4, 0, Color.gray.getRGB()); - } - - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return Lists.newArrayList(); - } - - @Override - public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { - return false; - } -} diff --git a/common/buildcraft/compat/module/jei/silicon/WrapperIntegrationTable.java b/common/buildcraft/compat/module/jei/silicon/WrapperIntegrationTable.java deleted file mode 100644 index abe1a52..0000000 --- a/common/buildcraft/compat/module/jei/silicon/WrapperIntegrationTable.java +++ /dev/null @@ -1,93 +0,0 @@ -package buildcraft.compat.module.jei.silicon; - -import java.awt.Color; -import java.util.List; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import buildcraft.api.mj.MjAPI; -import buildcraft.api.recipes.IntegrationRecipe; -import buildcraft.api.recipes.StackDefinition; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawableAnimated; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; - -public class WrapperIntegrationTable implements IRecipeWrapper { - private final IntegrationRecipe recipe; - private final IDrawableAnimated progressBar; - private final List inputs, outputs; - - public WrapperIntegrationTable(IGuiHelper guiHelper, IntegrationRecipe recipe) { - this.recipe = recipe; - - List inputs = Lists.newArrayList(); -// inputs.addAll(Utils.getItemStacks(recipe.target)); -// for (StackDefinition definition : recipe.toIntegrate) { -// inputs.addAll(Utils.getItemStacks(definition)); -// } - this.inputs = ImmutableList.copyOf(inputs); - this.outputs = ImmutableList.of(new ItemStack(Blocks.COBBLESTONE)); - - ResourceLocation backgroundLocation = new ResourceLocation("buildcraftsilicon", "textures/gui/integration_table.png"); - IDrawableStatic progressDrawable = guiHelper.createDrawable(backgroundLocation, 176, 17, 4, 69, 0, 0, 0, 0); - this.progressBar = guiHelper.createAnimatedDrawable(progressDrawable, (int) (/*recipe.requiredMicroJoules / */ 720), IDrawableAnimated.StartDirection.BOTTOM, false); - } - -// @Override -// public List getInputs() { -// return inputs; -// } -// -// @Override -// public List getOutputs() { -// return outputs; -// } -// -// @Override -// public List getFluidInputs() { -// return null; -// } -// -// @Override -// public List getFluidOutputs() { -// return null; -// } -// -// @Override -// public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight) {} - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(ItemStack.class, this.inputs); - ingredients.setOutputs(ItemStack.class, this.outputs); - } - - @Override - @SideOnly(Side.CLIENT) - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - this.progressBar.draw(minecraft, 156, 1); - minecraft.fontRenderer.drawString(MjAPI.formatMj(/*this.recipe.requiredMicroJoules*/0) + " MJ", 80, 52, Color.gray.getRGB()); - } -// -// @Override -// public void drawAnimations(Minecraft minecraft, int recipeWidth, int recipeHeight) { -// progressBar.draw(minecraft, 156, 1); -// } - - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return Lists.newArrayList(); - } - - @Override - public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { - return false; - } -} diff --git a/common/buildcraft/compat/module/jei/silicon/package-info.java b/common/buildcraft/compat/module/jei/silicon/package-info.java index fce7fb1..f747716 100644 --- a/common/buildcraft/compat/module/jei/silicon/package-info.java +++ b/common/buildcraft/compat/module/jei/silicon/package-info.java @@ -2,5 +2,6 @@ @MethodsReturnNonnullByDefault package buildcraft.compat.module.jei.silicon; -import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/common/buildcraft/compat/module/jei/transferhandlers/AdvancedCraftingItemsTransferHandler.java b/common/buildcraft/compat/module/jei/transferhandlers/AdvancedCraftingItemsTransferHandler.java index 02282e5..b3a4eec 100644 --- a/common/buildcraft/compat/module/jei/transferhandlers/AdvancedCraftingItemsTransferHandler.java +++ b/common/buildcraft/compat/module/jei/transferhandlers/AdvancedCraftingItemsTransferHandler.java @@ -1,34 +1,51 @@ package buildcraft.compat.module.jei.transferhandlers; -import javax.annotation.Nullable; -import net.minecraft.entity.player.EntityPlayer; +import buildcraft.silicon.BCSiliconMenuTypes; import buildcraft.silicon.container.ContainerAdvancedCraftingTable; -import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.constants.RecipeTypes; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.transfer.IRecipeTransferError; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.crafting.CraftingRecipe; + +import javax.annotation.Nullable; +import java.util.Optional; + +public class AdvancedCraftingItemsTransferHandler implements IRecipeTransferHandler { + public AdvancedCraftingItemsTransferHandler() { + } -public class AdvancedCraftingItemsTransferHandler implements IRecipeTransferHandler { @Override public Class getContainerClass() { return ContainerAdvancedCraftingTable.class; } - @Nullable @Override - public IRecipeTransferError transferRecipe(ContainerAdvancedCraftingTable container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) { + public Optional> getMenuType() { + return Optional.of(BCSiliconMenuTypes.ADVANCED_CRAFTING_TABLE); + } + + @Override + public RecipeType getRecipeType() { + return RecipeTypes.CRAFTING; + } + + @Override + @Nullable +// public IRecipeTransferError transferRecipe(ContainerAdvancedCraftingTable container, IRecipeLayout recipeLayout, Player player, boolean maxTransfer, boolean doTransfer) + public IRecipeTransferError transferRecipe(ContainerAdvancedCraftingTable container, CraftingRecipe recipe, IRecipeSlotsView recipeSlots, Player player, boolean maxTransfer, boolean doTransfer) { if (doTransfer) { -// Map> inputs = recipeLayout.getItemStacks().getGuiIngredients(); -// -// for (int slot = 0; slot < 9; slot++) { -// IGuiIngredient ingredient = inputs.getOrDefault(slot + 1, null); -// ItemStack stack = (ingredient == null) ? ItemStack.EMPTY : ingredient.getDisplayedIngredient(); -// -// container.sendSetPhantomSlot(container.tile.invBlueprint, slot, (stack == null) ? ItemStack.EMPTY : stack); -// } - - AutoCraftItemsTransferHandler.transferRecipe( - itemStacks -> container.sendSetPhantomSlots(container.tile.invBlueprint, itemStacks), - recipeLayout); + AutoCraftItemsTransferHandler.transferRecipe((itemStacks) -> + { + container.sendSetPhantomSlots(container.tile.invBlueprint, itemStacks); + }, +// recipeLayout + recipe, + recipeSlots + ); } return null; diff --git a/common/buildcraft/compat/module/jei/transferhandlers/AssemblyTableTransferHandler.java b/common/buildcraft/compat/module/jei/transferhandlers/AssemblyTableTransferHandler.java index e0ce8ee..413b9c9 100644 --- a/common/buildcraft/compat/module/jei/transferhandlers/AssemblyTableTransferHandler.java +++ b/common/buildcraft/compat/module/jei/transferhandlers/AssemblyTableTransferHandler.java @@ -1,23 +1,41 @@ package buildcraft.compat.module.jei.transferhandlers; -import javax.annotation.Nullable; -import net.minecraft.entity.player.EntityPlayer; +import buildcraft.api.recipes.IAssemblyRecipe; +import buildcraft.compat.module.jei.silicon.CategoryAssemblyTable; +import buildcraft.silicon.BCSiliconMenuTypes; import buildcraft.silicon.container.ContainerAssemblyTable; -import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.transfer.IRecipeTransferError; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.MenuType; + +import javax.annotation.Nullable; +import java.util.Optional; + +// Calen: never used in 1.12.2? +public class AssemblyTableTransferHandler implements IRecipeTransferHandler { -public class AssemblyTableTransferHandler implements IRecipeTransferHandler { @Override public Class getContainerClass() { return ContainerAssemblyTable.class; } - @Nullable @Override - public IRecipeTransferError transferRecipe(ContainerAssemblyTable container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) { + public Optional> getMenuType() { + return Optional.of(BCSiliconMenuTypes.ASSEMBLY_TABLE); + } + @Override + public RecipeType getRecipeType() { + return CategoryAssemblyTable.RECIPE_TYPE; + } + @Override + @Nullable +// public IRecipeTransferError transferRecipe(ContainerAssemblyTable container, IRecipeLayout recipeLayout, Player player, boolean maxTransfer, boolean doTransfer) + public IRecipeTransferError transferRecipe(ContainerAssemblyTable container, IAssemblyRecipe recipe, IRecipeSlotsView recipeSlots, Player player, boolean maxTransfer, boolean doTransfer) { return null; } } diff --git a/common/buildcraft/compat/module/jei/transferhandlers/AutoCraftItemsTransferHandler.java b/common/buildcraft/compat/module/jei/transferhandlers/AutoCraftItemsTransferHandler.java index 5ab756e..d31285a 100644 --- a/common/buildcraft/compat/module/jei/transferhandlers/AutoCraftItemsTransferHandler.java +++ b/common/buildcraft/compat/module/jei/transferhandlers/AutoCraftItemsTransferHandler.java @@ -1,53 +1,74 @@ package buildcraft.compat.module.jei.transferhandlers; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import javax.annotation.Nullable; -import com.google.common.collect.Lists; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; +import buildcraft.factory.BCFactoryMenuTypes; import buildcraft.factory.container.ContainerAutoCraftItems; -import mezz.jei.api.gui.IGuiIngredient; -import mezz.jei.api.gui.IRecipeLayout; +import com.google.common.collect.Lists; +import mezz.jei.api.constants.RecipeTypes; +import mezz.jei.api.gui.ingredient.IRecipeSlotView; +import mezz.jei.api.gui.ingredient.IRecipeSlotsView; +import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.transfer.IRecipeTransferError; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; + +import javax.annotation.Nullable; +import java.util.List; +import java.util.Optional; +import java.util.function.Consumer; + +public class AutoCraftItemsTransferHandler implements IRecipeTransferHandler { + public AutoCraftItemsTransferHandler() { + } -public class AutoCraftItemsTransferHandler implements IRecipeTransferHandler { @Override public Class getContainerClass() { return ContainerAutoCraftItems.class; } - @Nullable @Override - public IRecipeTransferError transferRecipe(ContainerAutoCraftItems container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) { + public Optional> getMenuType() { + return Optional.of(BCFactoryMenuTypes.AUTO_WORKBENCH_ITEMS); + } + + @Override + public RecipeType getRecipeType() { + return RecipeTypes.CRAFTING; + } + + @Override + @Nullable +// public IRecipeTransferError transferRecipe(ContainerAutoCraftItems container, IRecipeLayout recipeLayout, Player player, boolean maxTransfer, boolean doTransfer) + public IRecipeTransferError transferRecipe(ContainerAutoCraftItems container, CraftingRecipe recipe, IRecipeSlotsView recipeSlots, Player player, boolean maxTransfer, boolean doTransfer) { if (doTransfer) { -// Map> inputs = recipeLayout.getItemStacks().getGuiIngredients(); -// -// for (int slot = 0; slot < 9; slot++) { -// IGuiIngredient ingredient = inputs.getOrDefault(slot + 1, null); -// ItemStack stack = (ingredient == null) ? ItemStack.EMPTY : ingredient.getDisplayedIngredient(); -// -// container.sendSetPhantomSlot(container.tile.invBlueprint, slot, (stack == null) ? ItemStack.EMPTY : stack); -// } - - AutoCraftItemsTransferHandler.transferRecipe( - itemStacks -> container.sendSetPhantomSlots(container.tile.invBlueprint, itemStacks), - recipeLayout); + transferRecipe((itemStacks) -> + { + container.sendSetPhantomSlots((container.tile).invBlueprint, itemStacks); + }, +// recipeLayout + recipe, + recipeSlots + ); } return null; } - static void transferRecipe(Consumer> callback, IRecipeLayout recipeLayout) { - Map> inputs = recipeLayout.getItemStacks().getGuiIngredients(); + // static void transferRecipe(Consumer> callback, IRecipeLayout recipeLayout) + static void transferRecipe(Consumer> callback, CraftingRecipe recipe, IRecipeSlotsView recipeLayout) { +// Map> inputs = recipeLayout.getItemStacks().getGuiIngredients(); + List inputs = recipeLayout.getSlotViews(); List stacks = Lists.newArrayList(); - for (int slot = 0; slot < 9; slot++) { - IGuiIngredient ingredient = inputs.getOrDefault(slot + 1, null); - ItemStack stack = (ingredient == null) ? ItemStack.EMPTY : ingredient.getDisplayedIngredient(); - stacks.add((stack == null) ? ItemStack.EMPTY : stack); + + for (int slot = 0; slot < 9; ++slot) { +// IGuiIngredient ingredient = (IGuiIngredient) inputs.getOrDefault(slot + 1, (Object) null); + IRecipeSlotView ingredient = inputs.get(slot + 1); +// ItemStack stack = ingredient == null ? ItemStack.EMPTY : (ItemStack) ingredient.getDisplayedIngredient(); + ItemStack stack = ingredient == null ? ItemStack.EMPTY : (ItemStack) ingredient.getDisplayedIngredient().get().getIngredient(); + stacks.add(stack == null ? ItemStack.EMPTY : stack); } callback.accept(stacks); diff --git a/common/buildcraft/compat/module/jei/transferhandlers/package-info.java b/common/buildcraft/compat/module/jei/transferhandlers/package-info.java index 546f6b9..107bd58 100644 --- a/common/buildcraft/compat/module/jei/transferhandlers/package-info.java +++ b/common/buildcraft/compat/module/jei/transferhandlers/package-info.java @@ -2,5 +2,6 @@ @MethodsReturnNonnullByDefault package buildcraft.compat.module.jei.transferhandlers; -import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/common/buildcraft/compat/module/rei/BCPluginREI.java b/common/buildcraft/compat/module/rei/BCPluginREI.java new file mode 100644 index 0000000..1b3bdad --- /dev/null +++ b/common/buildcraft/compat/module/rei/BCPluginREI.java @@ -0,0 +1,126 @@ +package buildcraft.compat.module.rei; + +import buildcraft.api.BCModules; +import buildcraft.api.core.BCLog; +import buildcraft.api.fuels.IFuel; +import buildcraft.api.recipes.IAssemblyRecipe; +import buildcraft.api.recipes.IProgrammingRecipe; +import buildcraft.api.recipes.IRefineryRecipeManager; +import buildcraft.api.recipes.IntegrationRecipe; +import buildcraft.compat.BCCompatConfig; +import buildcraft.compat.module.rei.energy.combustionengine.CategoryCombustionEngine; +import buildcraft.compat.module.rei.energy.combustionengine.DisplayCombustionEngine; +import buildcraft.compat.module.rei.factory.*; +import buildcraft.compat.module.rei.gui.GuiGhostIngredientHandlerBuildCraft; +import buildcraft.compat.module.rei.gui.GuiHandlerBuildCraft; +import buildcraft.compat.module.rei.silicon.*; +import buildcraft.core.BCCoreItems; +import buildcraft.factory.BCFactoryBlocks; +import buildcraft.lib.gui.GuiBC8; +import buildcraft.silicon.BCSiliconBlocks; +import buildcraft.silicon.BCSiliconItems; +import buildcraft.transport.item.ItemPipeHolder; +import com.google.common.collect.Lists; +import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; +import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; +import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; +import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.forge.REIPluginClient; +import me.shedaniel.rei.plugin.common.BuiltinPlugin; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.fml.ModList; + +import java.util.Arrays; +import java.util.List; + +@REIPluginClient +public class BCPluginREI implements REIClientPlugin { + @Override + public void registerCategories(CategoryRegistry registry) { + boolean factory = ModList.get().isLoaded(BCModules.FACTORY.getModId()); + boolean energy = ModList.get().isLoaded(BCModules.ENERGY.getModId()); + boolean silicon = ModList.get().isLoaded(BCModules.SILICON.getModId()); + List lst = Lists.newArrayList(); + if (factory) { + lst.add("factory"); + registry.add(CategoryHeatable.INSTANCE); + registry.addWorkstations(CategoryHeatable.ID, CategoryHeatable.ICON); + registry.add(CategoryDistiller.INSTANCE); + registry.addWorkstations(CategoryDistiller.ID, CategoryDistiller.ICON); + registry.add(CategoryCoolable.INSTANCE); + registry.addWorkstations(CategoryCoolable.ID, CategoryCoolable.ICON); + + registry.addWorkstations(BuiltinPlugin.CRAFTING, EntryStacks.of(new ItemStack(BCFactoryBlocks.autoWorkbenchItems.get()))); + } + + if (energy) { + lst.add("energy"); + registry.add(CategoryCombustionEngine.INSTANCE); + registry.addWorkstations(CategoryCombustionEngine.ID, CategoryCombustionEngine.ICON); + } + + if (silicon) { + lst.add("silicon"); + registry.add(CategoryAssemblyTable.INSTANCE); + registry.add(CategoryIntegrationTable.INSTANCE); + registry.add(CategoryProgrammingTable.INSTANCE); + registry.addWorkstations(CategoryAssemblyTable.ID, CategoryAssemblyTable.ICON); + registry.addWorkstations(CategoryIntegrationTable.ID, CategoryIntegrationTable.ICON); + registry.addWorkstations(CategoryProgrammingTable.ID, CategoryProgrammingTable.ICON); + + registry.addWorkstations(BuiltinPlugin.CRAFTING, EntryStacks.of(new ItemStack(BCSiliconBlocks.advancedCraftingTable.get()))); + } + + BCLog.logger.info("Loaded REI mods: " + Arrays.toString(lst.toArray())); + } + + @Override + public void registerDisplays(DisplayRegistry registry) { + registry.registerRecipeFiller(IRefineryRecipeManager.IHeatableRecipe.class, IRefineryRecipeManager.IHeatableRecipe.TYPE, DisplayHeatable::new); + registry.registerRecipeFiller(IRefineryRecipeManager.IDistillationRecipe.class, IRefineryRecipeManager.IDistillationRecipe.TYPE, DisplayDistillation::new); + registry.registerRecipeFiller(IRefineryRecipeManager.ICoolableRecipe.class, IRefineryRecipeManager.ICoolableRecipe.TYPE, DisplayCoolable::new); + registry.registerRecipeFiller(IFuel.class, IFuel.TYPE, DisplayCombustionEngine::new); + registry.registerRecipeFiller(IAssemblyRecipe.class, IAssemblyRecipe.TYPE, DisplayAssembly::new); + registry.registerRecipeFiller(IntegrationRecipe.class, IntegrationRecipe.TYPE, DisplayIntegration::new); + registry.registerRecipeFiller(IProgrammingRecipe.class, IProgrammingRecipe.TYPE, DisplayProgramming::new); + } + + @Override + public void registerExclusionZones(ExclusionZones zones) { + zones.register(GuiBC8.class, new GuiHandlerBuildCraft()); + } + + @Override + public void registerEntries(EntryRegistry registry) { + registry.removeEntryIf(entryStack -> { + if (entryStack.getType() == VanillaEntryTypes.ITEM) { + ItemStack itemStack = entryStack.castValue(); + Item item = itemStack.getItem(); + if (item == BCCoreItems.fragileFluidShard.get()) { + return true; + } else if (item instanceof ItemPipeHolder pipe) { + if (!BCCompatConfig.coloredPipesVisible) { + if (pipe.getColour() != null) { + return true; + } + } + } else if (item == BCSiliconItems.plugFacade.get()) { + if (!BCCompatConfig.facadesVisible) { + return true; + } + } + } + return false; + }); + } + + @Override + public void registerScreens(ScreenRegistry registry) { + registry.registerDraggableStackVisitor(new GuiGhostIngredientHandlerBuildCraft()); + } +} diff --git a/common/buildcraft/compat/module/rei/ReiUtils.java b/common/buildcraft/compat/module/rei/ReiUtils.java new file mode 100644 index 0000000..db6fdbe --- /dev/null +++ b/common/buildcraft/compat/module/rei/ReiUtils.java @@ -0,0 +1,61 @@ +package buildcraft.compat.module.rei; + +import com.mojang.blaze3d.systems.RenderSystem; +import me.shedaniel.math.Point; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; + +public class ReiUtils { + public static final int PADDING = 5; + + public static void drawAnimation(GuiGraphics graphics, Point lu, ResourceLocation rl, int ticksPerCycle, int x, int y, int u, int v, int fullWidth, int fullHeight, ReiUtils.StartPosition startPosition) { + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.enableBlend(); + RenderSystem.blendFuncSeparate(770, 771, 1, 0); + RenderSystem.blendFunc(770, 771); + final double width_double = fullWidth; + final double height_double = fullHeight; + if (startPosition == StartPosition.LEFT) { + int width = Mth.ceil((System.currentTimeMillis() / (ticksPerCycle * 50 / width_double) % fullWidth)); + graphics.blit( + rl, + lu.getX() + x, lu.getY() + y, + u, v, + width, fullHeight + ); + } else if (startPosition == StartPosition.RIGHT) { + int width = Mth.ceil((System.currentTimeMillis() / (ticksPerCycle * 50 / width_double) % fullWidth)); + graphics.blit( + rl, + lu.getX() + x + fullWidth - width, lu.getY() + y, + u + fullWidth - width, v, + width, fullHeight + ); + } else if (startPosition == StartPosition.TOP) { + int height = Mth.ceil((System.currentTimeMillis() / (ticksPerCycle * 50 / height_double) % fullHeight)); + graphics.blit( + rl, + lu.getX() + x, lu.getY() + y, + u, v, + fullWidth, height + ); + } else if (startPosition == StartPosition.BOTTOM) { + int height = Mth.ceil((System.currentTimeMillis() / (ticksPerCycle * 50 / height_double) % fullHeight)); + graphics.blit( + rl, + lu.getX() + x, lu.getY() + y + fullHeight - height, + u, v + fullHeight - height, + fullWidth, height + ); + } + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + } + + public static enum StartPosition { + LEFT, + RIGHT, + TOP, + BOTTOM; + } +} diff --git a/common/buildcraft/compat/module/rei/energy/combustionengine/CategoryCombustionEngine.java b/common/buildcraft/compat/module/rei/energy/combustionengine/CategoryCombustionEngine.java new file mode 100644 index 0000000..a498cd5 --- /dev/null +++ b/common/buildcraft/compat/module/rei/energy/combustionengine/CategoryCombustionEngine.java @@ -0,0 +1,114 @@ +package buildcraft.compat.module.rei.energy.combustionengine; + +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.compat.module.rei.ReiUtils; +import buildcraft.energy.BCEnergyBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import java.awt.*; +import java.util.List; + +public enum CategoryCombustionEngine implements DisplayCategory { + INSTANCE; + + public static final CategoryIdentifier ID = CategoryIdentifier.of(new ResourceLocation(BCModules.ENERGY.getModId(), "category_engine_combustion")); + public static final EntryStack ICON = EntryStacks.of(new ItemStack(BCEnergyBlocks.engineIron.get())); + public static final ResourceLocation BACKGROUND = new ResourceLocation("minecraft", "textures/gui/container/furnace.png"); + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable("buildcraft.rei.title.combustion_engine_fuels"); + } + + @Override + public Renderer getIcon() { + return ICON; + } + + @Override + public int getDisplayHeight() { + return 32 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public int getDisplayWidth(DisplayCombustionEngine display) { + return 138 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public List setupDisplay(DisplayCombustionEngine display, Rectangle bounds) { + List ret = Lists.newArrayList(); + + ret.add(Widgets.createRecipeBase(bounds)); + + Point lu = new Point(bounds.getX() + ReiUtils.PADDING, bounds.getY() + ReiUtils.PADDING); + + // background + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 0, lu.getY() + 0, 55, 38, 18, 32)); + + // slot + if (!display.getOutputEntries().isEmpty()) { + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 114, lu.getY() + 14, 7, 22, 18, 18)); + } + + // animation + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + display.totalBurningTime / 10, + 2, 0, + 176, 0, + 14, 14, + ReiUtils.StartPosition.BOTTOM + ) + )); + + // slot content + ret.add(Widgets.createSlot(new Point(lu.getX() + 1, lu.getY() + 15)).markInput().entries(display.getInputEntries().get(0)).disableBackground()); + if (!display.getOutputEntries().isEmpty()) { + ret.add(Widgets.createSlot(new Point(lu.getX() + 115, lu.getY() + 15)).markOutput().entries(display.getOutputEntries().get(0)).disableBackground()); + } + + // text + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + { + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); + poseStack.translate(lu.getX(), lu.getY(), 0); + Font font = Minecraft.getInstance().font; + + poseStack.pushPose(); + poseStack.translate(24.0F, 6.0F, 0.0F); + guiGraphics.drawString(font, Component.translatable("buildcraft.jei.title.combustion_engine_fuels.burn_time", display.totalBurningTime / 20).getString(), 0, 0, Color.darkGray.getRGB(), false); + guiGraphics.drawString(font, Component.translatable("buildcraft.jei.title.combustion_engine_fuels.burn_speed", MjAPI.formatMj(display.powerPerCycle)).getString(), 0, font.lineHeight, Color.darkGray.getRGB(), false); + poseStack.translate(0.0F, (float) (font.lineHeight * 2), 0.0F); + poseStack.scale(0.7F, 0.7F, 1.0F); + guiGraphics.drawString(font, Component.translatable("buildcraft.jei.title.combustion_engine_fuels.burn_total", MjAPI.formatMj(display.powerPerCycle * (long) display.totalBurningTime)).getString(), 1, 2, Color.gray.getRGB(), false); + poseStack.popPose(); + poseStack.popPose(); + })); + + return ret; + } +} diff --git a/common/buildcraft/compat/module/rei/energy/combustionengine/DisplayCombustionEngine.java b/common/buildcraft/compat/module/rei/energy/combustionengine/DisplayCombustionEngine.java new file mode 100644 index 0000000..ffdfc4a --- /dev/null +++ b/common/buildcraft/compat/module/rei/energy/combustionengine/DisplayCombustionEngine.java @@ -0,0 +1,48 @@ +package buildcraft.compat.module.rei.energy.combustionengine; + +import buildcraft.api.fuels.IFuel; +import buildcraft.api.fuels.IFuelManager; +import dev.architectury.fluid.FluidStack; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; + +import java.util.List; + +public class DisplayCombustionEngine implements Display { + private final EntryIngredient fluid; + private final EntryIngredient residue; + public final int totalBurningTime; + public final long powerPerCycle; + + public DisplayCombustionEngine(IFuel recipe) { + totalBurningTime = recipe.getTotalBurningTime(); + powerPerCycle = recipe.getPowerPerCycle(); + fluid = EntryIngredients.of(FluidStack.create(recipe.getFluid().getRawFluid(), recipe.getFluid().getAmount())); + if (recipe instanceof IFuelManager.IDirtyFuel dirtyFuel) { + residue = EntryIngredients.of(FluidStack.create(dirtyFuel.getResidue().getRawFluid(), dirtyFuel.getResidue().getAmount())); + } else { + residue = null; + } + } + + @Override + public List getInputEntries() { + return List.of(fluid); + } + + @Override + public List getOutputEntries() { + if (residue == null) { + return List.of(); + } else { + return List.of(residue); + } + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CategoryCombustionEngine.ID; + } +} diff --git a/common/buildcraft/compat/module/rei/factory/CategoryCoolable.java b/common/buildcraft/compat/module/rei/factory/CategoryCoolable.java new file mode 100644 index 0000000..adda395 --- /dev/null +++ b/common/buildcraft/compat/module/rei/factory/CategoryCoolable.java @@ -0,0 +1,97 @@ +package buildcraft.compat.module.rei.factory; + +import buildcraft.api.BCModules; +import buildcraft.compat.module.rei.ReiUtils; +import buildcraft.factory.BCFactoryBlocks; +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import java.util.List; + +public enum CategoryCoolable implements DisplayCategory { + INSTANCE; + + public static final CategoryIdentifier ID = CategoryIdentifier.of(new ResourceLocation(BCModules.FACTORY.getModId(), "category_coolable")); + public static final EntryStack ICON = EntryStacks.of(new ItemStack(BCFactoryBlocks.heatExchange.get())); + public static final ResourceLocation BACKGROUND = new ResourceLocation(BCModules.FACTORY.getModId(), "textures/gui/heat_exchanger.png"); + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable("buildcraft.rei.title.coolable_fluids"); + } + + @Override + public Renderer getIcon() { + return ICON; + } + + @Override + public int getDisplayHeight() { + return 17 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public int getDisplayWidth(DisplayCoolable display) { + return 90 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public List setupDisplay(DisplayCoolable display, Rectangle bounds) { + List ret = Lists.newArrayList(); + + ret.add(Widgets.createRecipeBase(bounds)); + + Point lu = new Point(bounds.getX() + ReiUtils.PADDING, bounds.getY() + ReiUtils.PADDING); + + // background + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 18, lu.getY() + 2, 61, 38, 54, 17)); + + // slot + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 0, lu.getY() + 1, 7, 22, 18, 18)); + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 72, lu.getY() + 1, 7, 22, 18, 18)); + + // animation + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + 40, + 18, 2, + 52, 171, + 54, 17, + ReiUtils.StartPosition.LEFT + ) + )); + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + 40, + 18, 2, + 52, 188, + 54, 17, + ReiUtils.StartPosition.RIGHT + ) + )); + + // slot content + ret.add(Widgets.createSlot(new Point(lu.getX() + 1, lu.getY() + 2)).markInput().entries(display.getInputEntries().get(0)).disableBackground()); + ret.add(Widgets.createSlot(new Point(lu.getX() + 73, lu.getY() + 2)).markOutput().entries(display.getOutputEntries().get(0)).disableBackground()); + + return ret; + } +} diff --git a/common/buildcraft/compat/module/rei/factory/CategoryDistiller.java b/common/buildcraft/compat/module/rei/factory/CategoryDistiller.java new file mode 100644 index 0000000..cab10c1 --- /dev/null +++ b/common/buildcraft/compat/module/rei/factory/CategoryDistiller.java @@ -0,0 +1,105 @@ +package buildcraft.compat.module.rei.factory; + +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.compat.module.rei.ReiUtils; +import buildcraft.factory.BCFactoryBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import java.awt.*; +import java.util.List; + +public enum CategoryDistiller implements DisplayCategory { + INSTANCE; + + public static final CategoryIdentifier ID = CategoryIdentifier.of(new ResourceLocation(BCModules.FACTORY.getModId(), "category_distiller")); + public static final EntryStack ICON = EntryStacks.of(new ItemStack(BCFactoryBlocks.distiller.get())); + public static final ResourceLocation BACKGROUND = new ResourceLocation(BCModules.FACTORY.getModId(), "textures/gui/distiller.png"); + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable("buildcraft.rei.title.distillable_fluids"); + } + + @Override + public Renderer getIcon() { + return ICON; + } + + @Override + public int getDisplayHeight() { + return 65 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public int getDisplayWidth(DisplayDistillation display) { + return 90 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public List setupDisplay(DisplayDistillation display, Rectangle bounds) { + List ret = Lists.newArrayList(); + + ret.add(Widgets.createRecipeBase(bounds)); + + Point lu = new Point(bounds.getX() + ReiUtils.PADDING, bounds.getY() + ReiUtils.PADDING); + + // background + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 20, lu.getY() + 4, 61, 12, 36, 57)); + + // slot + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 0, lu.getY() + 25, 7, 34, 18, 18)); + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 56, lu.getY() + 0, 7, 34, 18, 18)); + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 56, lu.getY() + 45, 7, 34, 18, 18)); + + // animation + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + 40, + 20, 4, + 212, 0, + 36, 57, + ReiUtils.StartPosition.LEFT + ) + )); + + // text + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + { + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); + poseStack.translate(lu.getX(), lu.getY(), 0); + Font font = Minecraft.getInstance().font; + guiGraphics.drawString(font, MjAPI.formatMj(display.powerRequired) + " MJ", 58, 28, Color.CYAN.getRGB()); + poseStack.popPose(); + })); + + // slot content + ret.add(Widgets.createSlot(new Point(lu.getX() + 1, lu.getY() + 26)).markInput().entries(display.getInputEntries().get(0)).disableBackground()); + ret.add(Widgets.createSlot(new Point(lu.getX() + 57, lu.getY() + 1)).markOutput().entries(display.getOutputEntries().get(0)).disableBackground()); + ret.add(Widgets.createSlot(new Point(lu.getX() + 57, lu.getY() + 46)).markOutput().entries(display.getOutputEntries().get(1)).disableBackground()); + + return ret; + } +} diff --git a/common/buildcraft/compat/module/rei/factory/CategoryHeatable.java b/common/buildcraft/compat/module/rei/factory/CategoryHeatable.java new file mode 100644 index 0000000..c5f20ed --- /dev/null +++ b/common/buildcraft/compat/module/rei/factory/CategoryHeatable.java @@ -0,0 +1,87 @@ +package buildcraft.compat.module.rei.factory; + +import buildcraft.api.BCModules; +import buildcraft.compat.module.rei.ReiUtils; +import buildcraft.factory.BCFactoryBlocks; +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import java.util.List; + +public enum CategoryHeatable implements DisplayCategory { + INSTANCE; + + public static final CategoryIdentifier ID = CategoryIdentifier.of(new ResourceLocation(BCModules.FACTORY.getModId(), "category_heatable")); + public static final EntryStack ICON = EntryStacks.of(new ItemStack(BCFactoryBlocks.heatExchange.get())); + public static final ResourceLocation BACKGROUND = new ResourceLocation(BCModules.FACTORY.getModId(), "textures/gui/energy_heater.png"); + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable("buildcraft.rei.title.heatable_fluids"); + } + + @Override + public Renderer getIcon() { + return ICON; + } + + @Override + public int getDisplayHeight() { + return 17 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public int getDisplayWidth(DisplayHeatable display) { + return 90 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public List setupDisplay(DisplayHeatable display, Rectangle bounds) { + List ret = Lists.newArrayList(); + + ret.add(Widgets.createRecipeBase(bounds)); + + Point lu = new Point(bounds.getX() + ReiUtils.PADDING, bounds.getY() + ReiUtils.PADDING); + + // background + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 18, lu.getY() + 0, 176, 19, 54, 19)); + + // slot + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 0, lu.getY() + 1, 7, 22, 18, 18)); + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 72, lu.getY() + 1, 7, 22, 18, 18)); + + // animation + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + 40, + 18, 0, + 176, 152, + 54, 19, + ReiUtils.StartPosition.LEFT + ) + )); + + // slot content + ret.add(Widgets.createSlot(new Point(lu.getX() + 1, lu.getY() + 2)).markInput().entries(display.getInputEntries().get(0)).disableBackground()); + ret.add(Widgets.createSlot(new Point(lu.getX() + 73, lu.getY() + 2)).markOutput().entries(display.getOutputEntries().get(0)).disableBackground()); + + return ret; + } +} diff --git a/common/buildcraft/compat/module/rei/factory/DisplayCoolable.java b/common/buildcraft/compat/module/rei/factory/DisplayCoolable.java new file mode 100644 index 0000000..9b1d9dc --- /dev/null +++ b/common/buildcraft/compat/module/rei/factory/DisplayCoolable.java @@ -0,0 +1,35 @@ +package buildcraft.compat.module.rei.factory; + +import buildcraft.api.recipes.IRefineryRecipeManager; +import dev.architectury.fluid.FluidStack; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; + +import java.util.List; + +public class DisplayCoolable implements Display { + private final EntryIngredient in; + private final EntryIngredient out; + + public DisplayCoolable(IRefineryRecipeManager.ICoolableRecipe recipe) { + in = EntryIngredients.of(FluidStack.create(recipe.in().getRawFluid(), recipe.in().getAmount())); + out = EntryIngredients.of(FluidStack.create(recipe.out().getRawFluid(), recipe.out().getAmount())); + } + + @Override + public List getInputEntries() { + return List.of(in); + } + + @Override + public List getOutputEntries() { + return List.of(out); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CategoryCoolable.ID; + } +} diff --git a/common/buildcraft/compat/module/rei/factory/DisplayDistillation.java b/common/buildcraft/compat/module/rei/factory/DisplayDistillation.java new file mode 100644 index 0000000..c6853d8 --- /dev/null +++ b/common/buildcraft/compat/module/rei/factory/DisplayDistillation.java @@ -0,0 +1,39 @@ +package buildcraft.compat.module.rei.factory; + +import buildcraft.api.recipes.IRefineryRecipeManager; +import dev.architectury.fluid.FluidStack; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; + +import java.util.List; + +public class DisplayDistillation implements Display { + private final EntryIngredient in; + private final EntryIngredient outGas; + private final EntryIngredient outLiquid; + public final long powerRequired; + + public DisplayDistillation(IRefineryRecipeManager.IDistillationRecipe recipe) { + in = EntryIngredients.of(FluidStack.create(recipe.in().getRawFluid(), recipe.in().getAmount())); + outGas = EntryIngredients.of(FluidStack.create(recipe.outGas().getRawFluid(), recipe.outGas().getAmount())); + outLiquid = EntryIngredients.of(FluidStack.create(recipe.outLiquid().getRawFluid(), recipe.outLiquid().getAmount())); + powerRequired = recipe.powerRequired(); + } + + @Override + public List getInputEntries() { + return List.of(in); + } + + @Override + public List getOutputEntries() { + return List.of(outGas, outLiquid); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CategoryDistiller.ID; + } +} diff --git a/common/buildcraft/compat/module/rei/factory/DisplayHeatable.java b/common/buildcraft/compat/module/rei/factory/DisplayHeatable.java new file mode 100644 index 0000000..78ee10d --- /dev/null +++ b/common/buildcraft/compat/module/rei/factory/DisplayHeatable.java @@ -0,0 +1,35 @@ +package buildcraft.compat.module.rei.factory; + +import buildcraft.api.recipes.IRefineryRecipeManager; +import dev.architectury.fluid.FluidStack; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; + +import java.util.List; + +public class DisplayHeatable implements Display { + private final EntryIngredient in; + private final EntryIngredient out; + + public DisplayHeatable(IRefineryRecipeManager.IHeatableRecipe recipe) { + in = EntryIngredients.of(FluidStack.create(recipe.in().getRawFluid(), recipe.in().getAmount())); + out = EntryIngredients.of(FluidStack.create(recipe.out().getRawFluid(), recipe.out().getAmount())); + } + + @Override + public List getInputEntries() { + return List.of(in); + } + + @Override + public List getOutputEntries() { + return List.of(out); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CategoryHeatable.ID; + } +} diff --git a/common/buildcraft/compat/module/rei/gui/GuiGhostIngredientHandlerBuildCraft.java b/common/buildcraft/compat/module/rei/gui/GuiGhostIngredientHandlerBuildCraft.java new file mode 100644 index 0000000..b8bba40 --- /dev/null +++ b/common/buildcraft/compat/module/rei/gui/GuiGhostIngredientHandlerBuildCraft.java @@ -0,0 +1,81 @@ +package buildcraft.compat.module.rei.gui; + +import buildcraft.core.list.GuiList; +import buildcraft.lib.gui.GuiBC8; +import buildcraft.lib.gui.slot.SlotPhantom; +import com.google.common.collect.Lists; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.drag.DraggableStack; +import me.shedaniel.rei.api.client.gui.drag.DraggableStackVisitor; +import me.shedaniel.rei.api.client.gui.drag.DraggedAcceptorResult; +import me.shedaniel.rei.api.client.gui.drag.DraggingContext; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; +import net.minecraft.client.gui.screens.Screen; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +public class GuiGhostIngredientHandlerBuildCraft implements DraggableStackVisitor> { + @Override + public boolean isHandingScreen(R screen) { + return screen instanceof GuiBC8; + } + + @Override + public Stream getDraggableAcceptingBounds(DraggingContext> context, DraggableStack stack) { + EntryStack entryStack = stack.getStack(); + if (entryStack.getType() == VanillaEntryTypes.ITEM) { + GuiBC8 gui = context.getScreen(); + if (gui instanceof GuiList guiList) { + List retList = Lists.newArrayList(); + for (int lineIndex = 0; lineIndex < guiList.container.lines.length; lineIndex++) { + if (guiList.container.lines[lineIndex].isOneStackMode()) { + retList.add(BoundsProvider.ofRectangle(new Rectangle(gui.getGuiLeft() + 8 + 0 * 18, gui.getGuiTop() + 32 + lineIndex * 34, 16, 16))); + } else { + Arrays.stream(guiList.container.slots[lineIndex]) + .forEach( + slot -> retList.add( + BoundsProvider.ofRectangle(new Rectangle(gui.getGuiLeft() + 8 + slot.slotIndex * 18, gui.getGuiTop() + 32 + slot.lineIndex * 34)) + ) + ); + } + } + return retList.stream(); + } else { + return gui.container.slots.stream() + .filter(slot -> slot instanceof SlotPhantom) + .map(slot -> BoundsProvider.ofRectangle(new Rectangle(gui.getGuiLeft() + slot.x, gui.getGuiTop() + slot.y, 16, 16))); + } + } else { + return Stream.builder().build(); + } + } + + @Override + public DraggedAcceptorResult acceptDraggedStack(DraggingContext> context, DraggableStack stack) { + Point position = context.getCurrentPosition(); + GuiBC8 gui = context.getScreen(); + EntryStack entryStack = stack.getStack(); + if (entryStack.getType() == VanillaEntryTypes.ITEM) { + if (gui instanceof GuiList guiList) { + Arrays.stream(guiList.container.slots) + .flatMap(Arrays::stream) + .filter(slot -> slot.slotIndex == 0 || !guiList.container.lines[slot.lineIndex].isOneStackMode()) + .filter(slot -> new Rectangle(gui.getGuiLeft() + 8 + slot.slotIndex * 18, gui.getGuiTop() + 32 + slot.lineIndex * 34, 16, 16).contains(position)) + .forEach(slot -> guiList.clientSetStackToServer(slot, entryStack.castValue())); + } else { + gui.container.slots.stream() + .filter(slot -> slot instanceof SlotPhantom) + .filter(slot -> new Rectangle(gui.getGuiLeft() + slot.x, gui.getGuiTop() + slot.y, 16, 16).contains(position)) + .map(slot -> (SlotPhantom) slot) + .forEach(slotPhantom -> gui.container.sendSetPhantomSlot(slotPhantom, entryStack.castValue())); + } + return DraggedAcceptorResult.ACCEPTED; + } else { + return DraggedAcceptorResult.PASS; + } + } +} diff --git a/common/buildcraft/compat/module/rei/gui/GuiHandlerBuildCraft.java b/common/buildcraft/compat/module/rei/gui/GuiHandlerBuildCraft.java new file mode 100644 index 0000000..bc4b0e9 --- /dev/null +++ b/common/buildcraft/compat/module/rei/gui/GuiHandlerBuildCraft.java @@ -0,0 +1,32 @@ +package buildcraft.compat.module.rei.gui; + +import buildcraft.lib.gui.GuiBC8; +import buildcraft.lib.gui.IGuiElement; +import buildcraft.lib.gui.pos.GuiRectangle; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider; +import net.minecraft.util.Mth; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class GuiHandlerBuildCraft implements ExclusionZonesProvider> { + @Override + public Collection provide(GuiBC8 guiDirty) { + List list = new ArrayList<>(); + + for (IGuiElement element : guiDirty.mainGui.shownElements) { + GuiRectangle rect = element.asImmutable(); + int x = (int) rect.x; + int y = (int) rect.y; + int endX = Mth.ceil(rect.getEndX()); + int endY = Mth.ceil(rect.getEndY()); + int width = endX - x; + int height = endY - y; + list.add(new Rectangle(x, y, width, height)); + } + + return list; + } +} diff --git a/common/buildcraft/compat/module/rei/silicon/CategoryAssemblyTable.java b/common/buildcraft/compat/module/rei/silicon/CategoryAssemblyTable.java new file mode 100644 index 0000000..7c3a813 --- /dev/null +++ b/common/buildcraft/compat/module/rei/silicon/CategoryAssemblyTable.java @@ -0,0 +1,102 @@ +package buildcraft.compat.module.rei.silicon; + +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.compat.module.rei.ReiUtils; +import buildcraft.silicon.BCSiliconBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import java.awt.*; +import java.util.List; + +public enum CategoryAssemblyTable implements DisplayCategory { + INSTANCE; + + public static final CategoryIdentifier ID = CategoryIdentifier.of(new ResourceLocation(BCModules.SILICON.getModId(), "category_assembly")); + public static final EntryStack ICON = EntryStacks.of(new ItemStack(BCSiliconBlocks.assemblyTable.get())); + public static final ResourceLocation BACKGROUND = new ResourceLocation(BCModules.SILICON.getModId(), "textures/gui/assembly_table.png"); + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable("tile.assemblyTableBlock.name"); + } + + @Override + public Renderer getIcon() { + return ICON; + } + + @Override + public int getDisplayHeight() { + return 86 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public int getDisplayWidth(DisplayAssembly display) { + return 166 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public List setupDisplay(DisplayAssembly display, Rectangle bounds) { + List ret = Lists.newArrayList(); + + ret.add(Widgets.createRecipeBase(bounds)); + + Point lu = new Point(bounds.getX() + ReiUtils.PADDING, bounds.getY() + ReiUtils.PADDING); + + // background + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 0, lu.getY() + 10, 5, 34, 166, 76)); + + // animation + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + (int) Math.max(10L, display.requiredMicroJoules / MjAPI.MJ / 50L), + 81, 12, + 176, 48, + 4, 71, + ReiUtils.StartPosition.BOTTOM + ) + )); + + // text + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + { + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); + poseStack.translate(lu.getX(), lu.getY(), 0); + Font font = Minecraft.getInstance().font; + long mj = display.requiredMicroJoules; + guiGraphics.drawString(font, MjAPI.formatMj(mj) + " MJ", 4, 0, Color.gray.getRGB(), false); + poseStack.popPose(); + })); + + // slot content + for (int i = 0; i < display.getInputEntries().size(); ++i) { + ret.add(Widgets.createSlot(new Point(lu.getX() + 3 + i % 3 * 18, lu.getY() + 12 + i / 3 * 18)).markInput().entries(display.getInputEntries().get(i)).disableBackground()); + } + ret.add(Widgets.createSlot(new Point(lu.getX() + 111, lu.getY() + 12)).markOutput().entries(display.getOutputEntries().get(0)).disableBackground()); + + return ret; + } +} diff --git a/common/buildcraft/compat/module/rei/silicon/CategoryIntegrationTable.java b/common/buildcraft/compat/module/rei/silicon/CategoryIntegrationTable.java new file mode 100644 index 0000000..c69cf96 --- /dev/null +++ b/common/buildcraft/compat/module/rei/silicon/CategoryIntegrationTable.java @@ -0,0 +1,114 @@ +package buildcraft.compat.module.rei.silicon; + +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.compat.module.rei.ReiUtils; +import buildcraft.silicon.BCSiliconBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import java.awt.*; +import java.util.List; + +public enum CategoryIntegrationTable implements DisplayCategory { + INSTANCE; + + public static final CategoryIdentifier ID = CategoryIdentifier.of(new ResourceLocation(BCModules.SILICON.getModId(), "category_integration")); + public static final EntryStack ICON = EntryStacks.of(new ItemStack(BCSiliconBlocks.integrationTable.get())); + public static final ResourceLocation BACKGROUND = new ResourceLocation(BCModules.SILICON.getModId(), "textures/gui/integration_table.png"); + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable("tile.integrationTableBlock.name"); + } + + @Override + public Renderer getIcon() { + return ICON; + } + + @Override + public int getDisplayHeight() { + return 72 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public int getDisplayWidth(DisplayIntegration display) { + return 153 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public List setupDisplay(DisplayIntegration display, Rectangle bounds) { + List ret = Lists.newArrayList(); + + ret.add(Widgets.createRecipeBase(bounds)); + + Point lu = new Point(bounds.getX() + ReiUtils.PADDING, bounds.getY() + ReiUtils.PADDING); + + // background + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX(), lu.getY(), 17, 21, 153, 72)); + + // animation + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + 720, + 147, 1, + 176, 0, + 4, 70, + ReiUtils.StartPosition.BOTTOM + ) + )); + + // text + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + { + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); + poseStack.translate(lu.getX(), lu.getY(), 0); + Font font = Minecraft.getInstance().font; + long mj = display.requiredMicroJoules; + guiGraphics.drawString(font, MjAPI.formatMj(mj) + " MJ", 71, 52, Color.gray.getRGB(), false); + poseStack.popPose(); + })); + + // slot content + List inputs = display.getInputEntries(); + EntryIngredient center = inputs.get(0); + List surroundings = inputs.subList(1, inputs.size()); + int surroundingsIndexCounter = 0; + for (int y = 0; y < 3; ++y) { + for (int x = 0; x < 3; ++x) { + if (x == 1 && y == 1) { + ret.add(Widgets.createSlot(new Point(lu.getX() + 2 + x * 25, lu.getY() + 3 + y * 25)).markInput().entries(center).disableBackground()); + } else if (surroundingsIndexCounter < surroundings.size()) { + ret.add(Widgets.createSlot(new Point(lu.getX() + 2 + x * 25, lu.getY() + 3 + y * 25)).markInput().entries(surroundings.get(surroundingsIndexCounter)).disableBackground()); + surroundingsIndexCounter++; + } + } + } + + ret.add(Widgets.createSlot(new Point(lu.getX() + 121, lu.getY() + 28)).markOutput().entries(display.getOutputEntries().get(0)).disableBackground()); + return ret; + } +} diff --git a/common/buildcraft/compat/module/rei/silicon/CategoryProgrammingTable.java b/common/buildcraft/compat/module/rei/silicon/CategoryProgrammingTable.java new file mode 100644 index 0000000..b5c51b8 --- /dev/null +++ b/common/buildcraft/compat/module/rei/silicon/CategoryProgrammingTable.java @@ -0,0 +1,109 @@ +package buildcraft.compat.module.rei.silicon; + +import buildcraft.api.BCModules; +import buildcraft.api.mj.MjAPI; +import buildcraft.compat.module.rei.ReiUtils; +import buildcraft.silicon.BCSiliconBlocks; +import com.google.common.collect.Lists; +import com.mojang.blaze3d.vertex.PoseStack; +import me.shedaniel.math.Point; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Widget; +import me.shedaniel.rei.api.client.gui.widgets.Widgets; +import me.shedaniel.rei.api.client.registry.display.DisplayCategory; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.util.EntryStacks; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; + +import java.awt.*; +import java.util.List; + +public enum CategoryProgrammingTable implements DisplayCategory { + INSTANCE; + + public static final CategoryIdentifier ID = CategoryIdentifier.of(new ResourceLocation(BCModules.SILICON.getModId(), "category_programming")); + public static final EntryStack ICON = EntryStacks.of(new ItemStack(BCSiliconBlocks.programmingTable.get())); + public static final ResourceLocation BACKGROUND = new ResourceLocation(BCModules.SILICON.getModId(), "textures/gui/programming_table.png"); + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return ID; + } + + @Override + public Component getTitle() { + return Component.translatable("tile.programmingTableBlock.name"); + } + + @Override + public Renderer getIcon() { + return ICON; + } + + @Override + public int getDisplayHeight() { + return 72 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public int getDisplayWidth(DisplayProgramming display) { + return 72 + 2 + ReiUtils.PADDING * 2; + } + + @Override + public List setupDisplay(DisplayProgramming display, Rectangle bounds) { + List ret = Lists.newArrayList(); + + ret.add(Widgets.createRecipeBase(bounds)); + + Point lu = new Point(bounds.getX() + ReiUtils.PADDING, bounds.getY() + ReiUtils.PADDING); + + // input slot + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 2, lu.getY() + 27, 7, 35, 18, 18)); + + // arrow + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 2 + 18 + 5, lu.getY() + 27 + 5, 28, 40, 11, 8)); + + // output slot + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 2 + 18 + 5 + 11 + 5, lu.getY() + 27, 7, 89, 18, 18)); + + // animation background + ret.add(Widgets.createTexturedWidget(BACKGROUND, lu.getX() + 66, lu.getY() + 0, 163, 35, 6, 72)); + + // animation + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + ReiUtils.drawAnimation( + guiGraphics, lu, BACKGROUND, + (int) Math.max(10L, display.requiredMicroJoules / MjAPI.MJ / 50L), + 67, 1, + 176, 18, + 4, 70, + ReiUtils.StartPosition.BOTTOM + ) + )); + + // text + ret.add(Widgets.createDrawableWidget((guiGraphics, mouseX, mouseY, delta) -> + { + PoseStack poseStack = guiGraphics.pose(); + poseStack.pushPose(); + poseStack.translate(lu.getX(), lu.getY(), 0); + Font font = Minecraft.getInstance().font; + long mj = display.requiredMicroJoules; + guiGraphics.drawString(font, MjAPI.formatMj(mj) + " MJ", 10, 30 + 5 + 8 + 10, Color.gray.getRGB(), false); + poseStack.popPose(); + })); + + // slot content + ret.add(Widgets.createSlot(new Point(lu.getX() + 2 + 1, lu.getY() + 27 + 1)).markInput().entries(display.getInputEntries().get(0)).disableBackground()); + ret.add(Widgets.createSlot(new Point(lu.getX() + 2 + 18 + 5 + 11 + 5 + 1, lu.getY() + 27 + 1)).markOutput().entries(display.getOutputEntries().get(0)).disableBackground()); + + return ret; + } +} diff --git a/common/buildcraft/compat/module/rei/silicon/DisplayAssembly.java b/common/buildcraft/compat/module/rei/silicon/DisplayAssembly.java new file mode 100644 index 0000000..97b3fb4 --- /dev/null +++ b/common/buildcraft/compat/module/rei/silicon/DisplayAssembly.java @@ -0,0 +1,36 @@ +package buildcraft.compat.module.rei.silicon; + +import buildcraft.api.recipes.IAssemblyRecipe; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; + +import java.util.List; + +public class DisplayAssembly implements Display { + private final List in; + private final EntryIngredient out; + public final long requiredMicroJoules; + + public DisplayAssembly(IAssemblyRecipe recipe) { + in = EntryIngredients.ofIngredients(recipe.getRequiredIngredientStacks().stream().map(ingredientStack -> ingredientStack.ingredient).toList()); + out = EntryIngredients.of(recipe.getOutput().stream().toList().get(0)); + requiredMicroJoules = recipe.getRequiredMicroJoules(); + } + + @Override + public List getInputEntries() { + return in; + } + + @Override + public List getOutputEntries() { + return List.of(out); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CategoryAssemblyTable.ID; + } +} diff --git a/common/buildcraft/compat/module/rei/silicon/DisplayIntegration.java b/common/buildcraft/compat/module/rei/silicon/DisplayIntegration.java new file mode 100644 index 0000000..834939d --- /dev/null +++ b/common/buildcraft/compat/module/rei/silicon/DisplayIntegration.java @@ -0,0 +1,37 @@ +package buildcraft.compat.module.rei.silicon; + +import buildcraft.api.recipes.IntegrationRecipe; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; + +import java.util.List; +import java.util.stream.Stream; + +public class DisplayIntegration implements Display { + private final List in; + private final EntryIngredient out; + public final long requiredMicroJoules; + + public DisplayIntegration(IntegrationRecipe recipe) { + in = EntryIngredients.ofIngredients(Stream.concat(List.of(recipe.getCenterStack()).stream(), recipe.getRequirements().stream()).map(ingredientStack -> ingredientStack.ingredient).toList()); + out = EntryIngredients.of(recipe.getExampleOutput()); + requiredMicroJoules = recipe.getRequiredMicroJoules(); + } + + @Override + public List getInputEntries() { + return in; + } + + @Override + public List getOutputEntries() { + return List.of(out); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CategoryIntegrationTable.ID; + } +} diff --git a/common/buildcraft/compat/module/rei/silicon/DisplayProgramming.java b/common/buildcraft/compat/module/rei/silicon/DisplayProgramming.java new file mode 100644 index 0000000..df2cc30 --- /dev/null +++ b/common/buildcraft/compat/module/rei/silicon/DisplayProgramming.java @@ -0,0 +1,36 @@ +package buildcraft.compat.module.rei.silicon; + +import buildcraft.api.recipes.IProgrammingRecipe; +import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.Display; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.util.EntryIngredients; + +import java.util.List; + +public class DisplayProgramming implements Display { + private final List in; + private final EntryIngredient out; + public final long requiredMicroJoules; + + public DisplayProgramming(IProgrammingRecipe recipe) { + in = EntryIngredients.ofIngredients(List.of(recipe.getInput().ingredient)); + out = EntryIngredients.of(recipe.getOutput()); + requiredMicroJoules = recipe.getEnergyCost(); + } + + @Override + public List getInputEntries() { + return in; + } + + @Override + public List getOutputEntries() { + return List.of(out); + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return CategoryProgrammingTable.ID; + } +} diff --git a/common/buildcraft/compat/module/theoneprobe/BCPluginTOP.java b/common/buildcraft/compat/module/theoneprobe/BCPluginTOP.java index 947e923..0f3ed7e 100644 --- a/common/buildcraft/compat/module/theoneprobe/BCPluginTOP.java +++ b/common/buildcraft/compat/module/theoneprobe/BCPluginTOP.java @@ -1,48 +1,38 @@ package buildcraft.compat.module.theoneprobe; -import static buildcraft.compat.module.theoneprobe.BCPluginTOP.TOP_MOD_ID; - -import java.util.List; - -import com.google.common.base.Function; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.Optional; -import net.minecraftforge.fml.common.event.FMLInterModComms; - import buildcraft.api.BCModules; import buildcraft.api.mj.ILaserTarget; import buildcraft.api.mj.MjAPI; - -import buildcraft.lib.tile.craft.IAutoCraft; - import buildcraft.compat.CompatUtils; +import buildcraft.lib.misc.BlockUtil; +import buildcraft.lib.tile.craft.IAssemblyCraft; +import buildcraft.lib.tile.craft.IAutoCraft; +import com.google.common.base.Function; +import mcjty.theoneprobe.api.*; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; -import mcjty.theoneprobe.api.ElementAlignment; -import mcjty.theoneprobe.api.IBlockDisplayOverride; -import mcjty.theoneprobe.api.IProbeHitData; -import mcjty.theoneprobe.api.IProbeInfo; -import mcjty.theoneprobe.api.IProbeInfoProvider; -import mcjty.theoneprobe.api.ITheOneProbe; -import mcjty.theoneprobe.api.ProbeMode; +import java.util.List; -@Optional.InterfaceList({ - @Optional.Interface(modid = TOP_MOD_ID, iface = "mcjty.theoneprobe.api.IBlockDisplayOverride"), - @Optional.Interface(modid = TOP_MOD_ID, iface = "mcjty.theoneprobe.api.IProbeInfoProvider") -}) -public class BCPluginTOP implements Function, IBlockDisplayOverride, IProbeInfoProvider { +//@InterfaceList({@Interface( +// modid = "theoneprobe", +// iface = "mcjty.theoneprobe.api.IBlockDisplayOverride" +//), @Interface( +// modid = "theoneprobe", +// iface = "mcjty.theoneprobe.api.IProbeInfoProvider" +//)}) +//public class BCPluginTOP implements Function, IBlockDisplayOverride, IProbeInfoProvider +public enum BCPluginTOP implements Function, IBlockDisplayOverride, IProbeInfoProvider { + INSTANCE; static final String TOP_MOD_ID = "theoneprobe"; @Override - @Optional.Method(modid = TOP_MOD_ID) + // @Method(modid = "theoneprobe") public Void apply(ITheOneProbe top) { top.registerBlockDisplayOverride(this); top.registerProvider(this); @@ -50,23 +40,27 @@ public Void apply(ITheOneProbe top) { } @Override - @Optional.Method(modid = TOP_MOD_ID) - public boolean overrideStandardInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { + // @Method(modid = "theoneprobe") + // public boolean overrideStandardInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) + public boolean overrideStandardInfo(ProbeMode mode, IProbeInfo probeInfo, Player player, Level world, BlockState blockState, IProbeHitData data) { return false; } @Override - @Optional.Method(modid = TOP_MOD_ID) - public String getID() { - return "buildcraftcompat.top"; + // @Method(modid = "theoneprobe") + // public String getID() + public ResourceLocation getID() { +// return "buildcraftcompat.top"; + return new ResourceLocation("buildcraftcompat.top"); } @Override - @Optional.Method(modid = TOP_MOD_ID) - public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) { - ResourceLocation blockRegistryName = blockState.getBlock().getRegistryName(); - if ((blockRegistryName != null) && (BCModules.isBcMod(blockRegistryName.getResourceDomain()))) { - TileEntity entity = world.getTileEntity(data.getPos()); + // @Method(modid = "theoneprobe") +// public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) + public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, Player player, Level world, BlockState blockState, IProbeHitData data) { + ResourceLocation blockRegistryName = BlockUtil.getRegistryName(blockState.getBlock()); + if (blockRegistryName != null && BCModules.isBcMod(blockRegistryName.getNamespace())) { + BlockEntity entity = world.getBlockEntity(data.getPos()); if (entity instanceof IAutoCraft) { this.addAutoCraftInfo(probeInfo, (IAutoCraft) entity); } @@ -74,36 +68,48 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play if (entity instanceof ILaserTarget) { this.addLaserTargetInfo(probeInfo, (ILaserTarget) entity); } + + if (entity instanceof IAssemblyCraft) { + this.addAssemblyInfo(probeInfo, (IAssemblyCraft) entity); + } } } - @Optional.Method(modid = TOP_MOD_ID) + // @Method(modid = "theoneprobe") private void addAutoCraftInfo(IProbeInfo probeInfo, IAutoCraft crafter) { if (!crafter.getCurrentRecipeOutput().isEmpty()) { IProbeInfo mainInfo = probeInfo.vertical(); - mainInfo - .horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)) - .text("Making: ") - .item(crafter.getCurrentRecipeOutput()); - IProbeInfo info = mainInfo - .horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)) - .text("From: "); +// mainInfo.horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)).text("Making: ").item(crafter.getCurrentRecipeOutput()); + mainInfo.horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)).text(Component.translatable("buildcraft.waila.crafting")).item(crafter.getCurrentRecipeOutput()); +// IProbeInfo info = mainInfo.horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)).text("From: "); + IProbeInfo info = mainInfo.horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)).text(Component.translatable("buildcraft.waila.crafting_from")); List stacks = CompatUtils.compactInventory(crafter.getInvBlueprint()); - for (ItemStack stack : stacks) + for (ItemStack stack : stacks) { info.item(stack); + } + } else { + IProbeInfo mainInfo = probeInfo.vertical(); + mainInfo.horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)).text(Component.translatable("buildcraft.waila.no_recipe")); } } - @Optional.Method(modid = TOP_MOD_ID) + // @Method(modid = "theoneprobe") private void addLaserTargetInfo(IProbeInfo probeInfo, ILaserTarget laserTarget) { long power = laserTarget.getRequiredLaserPower(); - if (power > 0) { - probeInfo.horizontal() - .text(TextFormatting.WHITE + "Waiting from laser: ") - .text(TextFormatting.AQUA + MjAPI.formatMj(power)) - .text(TextFormatting.AQUA + "MJ"); + if (power > 0L) { +// probeInfo.horizontal().text(TextFormatting.WHITE + "Waiting from laser: ").text(TextFormatting.AQUA + MjAPI.formatMj(power)).text(TextFormatting.AQUA + "MJ"); + probeInfo.horizontal().text(Component.translatable("buildcraft.waila.waiting_for_laser", MjAPI.formatMj(power))); } } -} + private void addAssemblyInfo(IProbeInfo probeInfo, IAssemblyCraft assembly) { + ItemStack result = assembly.getAssemblyResult(); + if (!result.isEmpty()) { + probeInfo.horizontal().text(Component.translatable("buildcraft.waila.crafting")).item(result); + } else { + IProbeInfo mainInfo = probeInfo.vertical(); + mainInfo.horizontal(mainInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)).text(Component.translatable("buildcraft.waila.no_recipe")); + } + } +} diff --git a/common/buildcraft/compat/module/theoneprobe/CompatModuleTheOneProbe.java b/common/buildcraft/compat/module/theoneprobe/CompatModuleTheOneProbe.java index 964bc69..a6210ba 100644 --- a/common/buildcraft/compat/module/theoneprobe/CompatModuleTheOneProbe.java +++ b/common/buildcraft/compat/module/theoneprobe/CompatModuleTheOneProbe.java @@ -1,19 +1,18 @@ package buildcraft.compat.module.theoneprobe; -import net.minecraftforge.fml.common.event.FMLInterModComms; - import buildcraft.compat.CompatModuleBase; +import net.minecraftforge.fml.InterModComms; public class CompatModuleTheOneProbe extends CompatModuleBase { + public CompatModuleTheOneProbe() { + } - @Override public String compatModId() { return "theoneprobe"; } - @Override public void preInit() { - FMLInterModComms.sendFunctionMessage(compatModId(), "getTheOneProbe", - "buildcraft.compat.module.theoneprobe.BCPluginTOP"); +// FMLInterModComms.sendFunctionMessage(this.compatModId(), "getTheOneProbe", "buildcraft.compat.module.theoneprobe.BCPluginTOP"); + InterModComms.sendTo(this.compatModId(), "getTheOneProbe", () -> BCPluginTOP.INSTANCE); } } diff --git a/common/buildcraft/compat/module/waila/AssemblyCraftDataProvider.java b/common/buildcraft/compat/module/waila/AssemblyCraftDataProvider.java new file mode 100644 index 0000000..40e3604 --- /dev/null +++ b/common/buildcraft/compat/module/waila/AssemblyCraftDataProvider.java @@ -0,0 +1,63 @@ +package buildcraft.compat.module.waila; + +import buildcraft.lib.tile.craft.IAssemblyCraft; +import buildcraft.silicon.BCSilicon; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.Vec2; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; +import snownee.jade.impl.ui.ItemStackElement; +import snownee.jade.impl.ui.SpacerElement; + +public class AssemblyCraftDataProvider { + static class BodyProvider extends BaseWailaDataProvider.BodyProvider { + @Override + public void getWailaBody(ITooltip currentTip, BlockAccessor accessor, IPluginConfig iPluginConfig) { + BlockEntity tile = accessor.getBlockEntity(); + if (tile instanceof IAssemblyCraft) { +// CompoundTag nbt = accessor.getNBTData(); + CompoundTag nbt = accessor.getServerData(); + if (nbt.contains("recipe_result", Tag.TAG_COMPOUND)) { + ItemStack recipe_result = ItemStack.of(nbt.getCompound("recipe_result")); + if (!recipe_result.isEmpty()) { + currentTip.add(Component.translatable("buildcraft.waila.crafting")); + currentTip.append(ItemStackElement.of(recipe_result)); + // Calen: an empty line because the item icon is 2 lines height + // if ItemStackElement.of(result, 0.5F), the count text of the stack will not scale + currentTip.add(new SpacerElement(new Vec2(0, 5))); + return; + } + } + currentTip.add(Component.translatable("buildcraft.waila.no_recipe")); + } +// else { +// currentTip.add(new TextComponent(ChatFormatting.RED + "{wrong tile entity}")); +// } + } + + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCSilicon.MODID, "assembly_client_data"); + } + } + + static class NBTProvider extends BaseWailaDataProvider.NBTProvider { + @Override + public void getNBTData(CompoundTag nbt, BlockAccessor accessor) { + if (accessor.getBlockEntity() instanceof IAssemblyCraft assembly) { + nbt.put("recipe_result", assembly.getAssemblyResult().serializeNBT()); + } + } + + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCSilicon.MODID, "assembly_server_data"); + } + } +} diff --git a/common/buildcraft/compat/module/waila/AutoCraftDataProvider.java b/common/buildcraft/compat/module/waila/AutoCraftDataProvider.java index df1f7c4..449ba5d 100644 --- a/common/buildcraft/compat/module/waila/AutoCraftDataProvider.java +++ b/common/buildcraft/compat/module/waila/AutoCraftDataProvider.java @@ -1,83 +1,87 @@ package buildcraft.compat.module.waila; -import static buildcraft.compat.module.waila.HWYLAPlugin.WAILA_MOD_ID; - -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fml.common.Optional; - +import buildcraft.compat.CompatUtils; +import buildcraft.factory.BCFactory; import buildcraft.lib.tile.craft.IAutoCraft; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.Vec2; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; +import snownee.jade.impl.ui.ItemStackElement; +import snownee.jade.impl.ui.SpacerElement; -import buildcraft.compat.CompatUtils; +import java.util.List; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; -import mcp.mobius.waila.api.SpecialChars; +public class AutoCraftDataProvider { -class AutoCraftDataProvider extends BaseWailaDataProvider { - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public List getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - TileEntity tile = accessor.getTileEntity(); - if (tile instanceof IAutoCraft) { - NBTTagCompound nbt = accessor.getNBTData(); - if (nbt.hasKey("recipe_result", Constants.NBT.TAG_COMPOUND)) { - ItemStack result = new ItemStack(nbt.getCompoundTag("recipe_result")); - currentTip.add(TextFormatting.WHITE + "Making: " + SpecialChars.WailaSplitter + HWYLAPlugin.getItemStackString(result)); + static class BodyProvider extends BaseWailaDataProvider.BodyProvider { + @Override + public void getWailaBody(ITooltip currentTip, BlockAccessor accessor, IPluginConfig iPluginConfig) { + BlockEntity tile = accessor.getBlockEntity(); + if (tile instanceof IAutoCraft) { + CompoundTag nbt = accessor.getServerData(); + if (nbt.contains("recipe_result", Tag.TAG_COMPOUND)) { + // Calen: add -> create new line / append -> append at the last line + ItemStack result = ItemStack.of(nbt.getCompound("recipe_result")); + currentTip.add(Component.translatable("buildcraft.waila.crafting")); + currentTip.append(ItemStackElement.of(result)); + // Calen: an empty line, because the item icon is 2 lines height + // if ItemStackElement.of(result, 0.5F), the count text of the stack will not scale + currentTip.add(new SpacerElement(new Vec2(0, 5))); + if (nbt.contains("recipe_inputs", Tag.TAG_LIST)) { + ListTag list = nbt.getList("recipe_inputs", Tag.TAG_COMPOUND); + currentTip.add(Component.translatable("buildcraft.waila.crafting_from")); - if (nbt.hasKey("recipe_inputs", Constants.NBT.TAG_LIST)) { - NBTTagList list = nbt.getTagList("recipe_inputs", Constants.NBT.TAG_COMPOUND); - StringBuilder inputs = new StringBuilder(TextFormatting.WHITE + "From: " + SpecialChars.WailaSplitter); - for (int index = 0; index < list.tagCount(); index++) { - NBTTagCompound compound = NBTTagCompound.class.cast(list.get(index)); - inputs.append(HWYLAPlugin.getItemStackString(new ItemStack(compound))); + for (int index = 0; index < list.size(); ++index) { + CompoundTag compound = list.getCompound(index); + currentTip.append(ItemStackElement.of(ItemStack.of(compound))); + } + currentTip.add(new SpacerElement(new Vec2(0, 5))); } - currentTip.add(inputs.toString()); + } else { + currentTip.add(Component.translatable("buildcraft.waila.no_recipe")); } - } else { - currentTip.add(TextFormatting.GRAY + "No recipe"); } - } else { - currentTip.add(TextFormatting.RED + "{wrong tile entity}"); +// else { +// currentTip.add(new TextComponent(ChatFormatting.RED + "{wrong tile entity}")); +// } + } + + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCFactory.MODID, "autocraft_client_data"); } - return currentTip; } - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { - NBTTagCompound nbt = super.getNBTData(player, te, tag, world, pos); + static class NBTProvider extends BaseWailaDataProvider.NBTProvider { + @Override + public void getNBTData(CompoundTag nbt, BlockAccessor accessor) { + if (accessor.getBlockEntity() instanceof IAutoCraft auto) { + ItemStack output = auto.getCurrentRecipeOutput(); + if (!output.isEmpty()) { + nbt.put("recipe_result", output.serializeNBT()); + List stacks = CompatUtils.compactInventory(auto.getInvBlueprint()); + ListTag list = new ListTag(); - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof IAutoCraft) { - IAutoCraft auto = IAutoCraft.class.cast(tile); - ItemStack output = auto.getCurrentRecipeOutput(); - if (!output.isEmpty()) { - nbt.setTag("recipe_result", output.serializeNBT()); + for (int index = 0; index < stacks.size(); ++index) { + list.add((stacks.get(index)).serializeNBT()); + } - List stacks = CompatUtils.compactInventory(auto.getInvBlueprint()); - NBTTagList list = new NBTTagList(); - for (int index = 0; index < stacks.size(); index++) { - list.appendTag(stacks.get(index).serializeNBT()); + nbt.put("recipe_inputs", list); } - nbt.setTag("recipe_inputs", list); } } - return nbt; + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCFactory.MODID, "autocraft_server_data"); + } } } diff --git a/common/buildcraft/compat/module/waila/BaseWailaDataProvider.java b/common/buildcraft/compat/module/waila/BaseWailaDataProvider.java index 630b8af..f6c5170 100644 --- a/common/buildcraft/compat/module/waila/BaseWailaDataProvider.java +++ b/common/buildcraft/compat/module/waila/BaseWailaDataProvider.java @@ -1,57 +1,51 @@ package buildcraft.compat.module.waila; -import static buildcraft.compat.module.waila.HWYLAPlugin.WAILA_MOD_ID; - -import java.util.List; -import javax.annotation.Nonnull; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.Optional; - -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; -import mcp.mobius.waila.api.IWailaDataProvider; - -@Optional.InterfaceList({ - @Optional.Interface(modid = WAILA_MOD_ID, iface = "mcp.mobius.waila.api.IWailaDataProvider") -}) -class BaseWailaDataProvider implements IWailaDataProvider { - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { - return ItemStack.EMPTY; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import snownee.jade.api.*; +import snownee.jade.api.config.IPluginConfig; + +//class BaseWailaDataProvider implements IWailaDataProvider +public interface BaseWailaDataProvider { + + static abstract class BodyProvider implements IBlockComponentProvider { + @Override + public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) { + getWailaBody(iTooltip, blockAccessor, iPluginConfig); + } + + abstract void getWailaBody(ITooltip iTooltip, BlockAccessor accessor, IPluginConfig iPluginConfig); } - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public List getWailaHead(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - return currentTip; - } + // static abstract class NBTProvider implements IServerDataProvider + static abstract class NBTProvider implements IServerDataProvider { + @Override +// public void appendServerData(CompoundTag tag, ServerPlayer player, Level blockAccessor, BlockEntity blockEntity, boolean showDetails) + public void appendServerData(CompoundTag tag, BlockAccessor accessor) { + getNBTData(tag, accessor); + } - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public List getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - return currentTip; + // abstract void getNBTData(CompoundTag tag, ServerPlayer player, Level blockAccessor, BlockEntity blockEntity, boolean showDetails); + abstract void getNBTData(CompoundTag tag, BlockAccessor accessor); } - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public List getWailaTail(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - return currentTip; + static abstract class BodyProviderEntity implements IEntityComponentProvider { + @Override + public void appendTooltip(ITooltip iTooltip, EntityAccessor blockAccessor, IPluginConfig iPluginConfig) { + getWailaBody(iTooltip, blockAccessor, iPluginConfig); + } + + abstract void getWailaBody(ITooltip iTooltip, EntityAccessor accessor, IPluginConfig iPluginConfig); } - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { - return tag; + static abstract class NBTProviderEntity implements IServerDataProvider { + @Override + public void appendServerData(CompoundTag tag, EntityAccessor entityAccessor) { + getNBTData(tag, (ServerPlayer) entityAccessor.getPlayer(), entityAccessor.getLevel(), entityAccessor.getEntity(), entityAccessor.showDetails()); + } + + abstract void getNBTData(CompoundTag tag, ServerPlayer player, Level world, Entity entity, boolean showDetails); } } diff --git a/common/buildcraft/compat/module/waila/HWYLAPlugin.java b/common/buildcraft/compat/module/waila/HWYLAPlugin.java index 2ddff63..e8bbd4c 100644 --- a/common/buildcraft/compat/module/waila/HWYLAPlugin.java +++ b/common/buildcraft/compat/module/waila/HWYLAPlugin.java @@ -1,49 +1,47 @@ package buildcraft.compat.module.waila; -import static buildcraft.compat.module.waila.HWYLAPlugin.WAILA_MOD_ID; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.common.Optional; - -import buildcraft.api.mj.ILaserTarget; - -import buildcraft.lib.tile.craft.IAutoCraft; - -import mcp.mobius.waila.api.IWailaDataProvider; -import mcp.mobius.waila.api.IWailaPlugin; -import mcp.mobius.waila.api.IWailaRegistrar; -import mcp.mobius.waila.api.SpecialChars; -import mcp.mobius.waila.api.WailaPlugin; +import buildcraft.api.robots.EntityRobotBase; +import buildcraft.lib.block.BlockBCTile_Neptune; +import buildcraft.lib.tile.TileBC_Neptune; +import snownee.jade.api.*; @WailaPlugin -@Optional.InterfaceList({ - @Optional.Interface(modid = WAILA_MOD_ID, iface = "mcp.mobius.waila.api.IWailaPlugin") -}) public class HWYLAPlugin implements IWailaPlugin { - static final String WAILA_MOD_ID = "waila"; - + // Calen: in 1.18.2 we should use Block or TE class instead of interface here, it's too difficult to get all matched if allowing some BC modules absent, + // so just use TileBC_Neptune and BlockBCTile_Neptune @Override - public void register(IWailaRegistrar registrar) { - IWailaDataProvider autoCraftProvider = new AutoCraftDataProvider(); - registrar.registerNBTProvider(autoCraftProvider, IAutoCraft.class); - registrar.registerBodyProvider(autoCraftProvider, IAutoCraft.class); - - IWailaDataProvider laserTargetProvider = new LaserTargetDataProvider(); - registrar.registerNBTProvider(laserTargetProvider, ILaserTarget.class); - registrar.registerBodyProvider(laserTargetProvider, ILaserTarget.class); + public void register(IWailaCommonRegistration registrar) { + IServerDataProvider autoCraftNbtProvider = new AutoCraftDataProvider.NBTProvider(); + IServerDataProvider laserTargetNbtProvider = new LaserTargetDataProvider.NBTProvider(); + IServerDataProvider assemblyCraftNbtProvider = new AssemblyCraftDataProvider.NBTProvider(); + IServerDataProvider mjStorageNbtProvider = new MjStorageDataProvider.NBTProvider(); + IServerDataProvider robotPowerNbtProvider = new RobotPowerDataProvider.NBTProvider(); + + registrar.registerBlockDataProvider(autoCraftNbtProvider, TileBC_Neptune.class); + registrar.registerBlockDataProvider(laserTargetNbtProvider, TileBC_Neptune.class); + registrar.registerBlockDataProvider(assemblyCraftNbtProvider, TileBC_Neptune.class); + registrar.registerBlockDataProvider(mjStorageNbtProvider, TileBC_Neptune.class); + registrar.registerEntityDataProvider(robotPowerNbtProvider, EntityRobotBase.class); } - static String getItemStackString(ItemStack stack) { - return getItemStackString(stack, "1"); - } - - private static String getItemStackString(ItemStack stack, String thing) { - // TODO: find out what that 'thing' really is - return SpecialChars.getRenderString("waila.stack", thing, - stack.getItem().getRegistryName().toString(), - String.valueOf(stack.getCount()), - String.valueOf(stack.getItemDamage()) - ); + @Override + public void registerClient(IWailaClientRegistration registrar) { +// IComponentProvider autoCraftBodyProvider = new AutoCraftDataProvider.BodyProvider(); +// IComponentProvider laserTargetBodyProvider = new LaserTargetDataProvider.BodyProvider(); +// IComponentProvider assemblyCraftBodyProvider = new AssemblyCraftDataProvider.BodyProvider(); + IBlockComponentProvider autoCraftBodyProvider = new AutoCraftDataProvider.BodyProvider(); + IBlockComponentProvider laserTargetBodyProvider = new LaserTargetDataProvider.BodyProvider(); + IBlockComponentProvider assemblyCraftBodyProvider = new AssemblyCraftDataProvider.BodyProvider(); + IBlockComponentProvider mjStorageBodyProvider = new MjStorageDataProvider.BodyProvider(); + IEntityComponentProvider robotPowerNbtProvider = new RobotPowerDataProvider.BodyProvider(); + +// registrar.registerComponentProvider(autoCraftBodyProvider, TooltipPosition.BODY, BlockBCTile_Neptune.class); +// registrar.registerComponentProvider(laserTargetBodyProvider, TooltipPosition.BODY, BlockBCTile_Neptune.class); +// registrar.registerComponentProvider(assemblyCraftBodyProvider, TooltipPosition.BODY, BlockBCTile_Neptune.class); + registrar.registerBlockComponent(autoCraftBodyProvider, BlockBCTile_Neptune.class); + registrar.registerBlockComponent(laserTargetBodyProvider, BlockBCTile_Neptune.class); + registrar.registerBlockComponent(assemblyCraftBodyProvider, BlockBCTile_Neptune.class); + registrar.registerBlockComponent(mjStorageBodyProvider, BlockBCTile_Neptune.class); + registrar.registerEntityComponent(robotPowerNbtProvider, EntityRobotBase.class); } } diff --git a/common/buildcraft/compat/module/waila/LaserTargetDataProvider.java b/common/buildcraft/compat/module/waila/LaserTargetDataProvider.java index 426e975..8bcc917 100644 --- a/common/buildcraft/compat/module/waila/LaserTargetDataProvider.java +++ b/common/buildcraft/compat/module/waila/LaserTargetDataProvider.java @@ -1,56 +1,54 @@ package buildcraft.compat.module.waila; -import static buildcraft.compat.module.waila.HWYLAPlugin.WAILA_MOD_ID; - -import java.util.List; -import javax.annotation.Nonnull; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fml.common.Optional; import buildcraft.api.mj.ILaserTarget; import buildcraft.api.mj.MjAPI; +import buildcraft.silicon.BCSilicon; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.entity.BlockEntity; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; +abstract class LaserTargetDataProvider { -class LaserTargetDataProvider extends BaseWailaDataProvider { - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public List getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - TileEntity tile = accessor.getTileEntity(); - if (tile instanceof ILaserTarget) { - NBTTagCompound nbt = accessor.getNBTData(); - if (nbt.hasKey("required_power", Constants.NBT.TAG_LONG)) { - long power = nbt.getLong("required_power"); - if (power > 0) { - currentTip.add(TextFormatting.WHITE + "Waiting from laser: " + TextFormatting.AQUA + MjAPI.formatMj(power) + " MJ"); + static class BodyProvider extends BaseWailaDataProvider.BodyProvider { + @Override + public void getWailaBody(ITooltip currentTip, BlockAccessor accessor, IPluginConfig iPluginConfig) { + BlockEntity tile = accessor.getBlockEntity(); + if (tile instanceof ILaserTarget) { + CompoundTag nbt = accessor.getServerData(); + if (nbt.contains("required_power", Tag.TAG_LONG)) { + long power = nbt.getLong("required_power"); + if (power > 0L) { + currentTip.add(Component.translatable("buildcraft.waila.waiting_for_laser", MjAPI.formatMj(power))); + } } } - } else { - currentTip.add(TextFormatting.RED + "{wrong tile entity}"); +// else { +// currentTip.add(new TextComponent(ChatFormatting.RED + "{wrong tile entity}")); +// } } - return currentTip; - } - @Nonnull - @Override - @Optional.Method(modid = WAILA_MOD_ID) - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) { - NBTTagCompound nbt = super.getNBTData(player, te, tag, world, pos); + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCSilicon.MODID, "laser_target_client_data"); + } + } - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof ILaserTarget) { - ILaserTarget target = ILaserTarget.class.cast(tile); - nbt.setLong("required_power", target.getRequiredLaserPower()); + static class NBTProvider extends BaseWailaDataProvider.NBTProvider { + @Override + public void getNBTData(CompoundTag nbt, BlockAccessor accessor) { + if (accessor.getBlockEntity() instanceof ILaserTarget target) { + nbt.putLong("required_power", target.getRequiredLaserPower()); + } } - return nbt; + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCSilicon.MODID, "laser_target_server_data"); + } } } diff --git a/common/buildcraft/compat/module/waila/MjStorageDataProvider.java b/common/buildcraft/compat/module/waila/MjStorageDataProvider.java new file mode 100644 index 0000000..da587d1 --- /dev/null +++ b/common/buildcraft/compat/module/waila/MjStorageDataProvider.java @@ -0,0 +1,64 @@ +package buildcraft.compat.module.waila; + +import buildcraft.api.mj.MjAPI; +import buildcraft.core.BCCore; +import buildcraft.lib.tile.TileBC_Neptune; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.DyeColor; +import snownee.jade.api.BlockAccessor; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; +import snownee.jade.api.ui.BoxStyle; +import snownee.jade.api.ui.IProgressStyle; +import snownee.jade.impl.ui.ProgressElement; +import snownee.jade.impl.ui.ProgressStyle; + +public class MjStorageDataProvider { + static class BodyProvider extends BaseWailaDataProvider.BodyProvider { + private static final IProgressStyle PROGRESS_STYLE = new ProgressStyle() + .color(-15731468, -16721961) + .textColor(DyeColor.WHITE.getTextColor()); + + @Override + public void getWailaBody(ITooltip currentTip, BlockAccessor accessor, IPluginConfig iPluginConfig) { + if (accessor.getBlockEntity() instanceof TileBC_Neptune tileBC) { + tileBC.getCapability(MjAPI.CAP_READABLE).ifPresent(mjReadable -> { + CompoundTag nbt = accessor.getServerData(); + if (nbt.contains("mj_storage", Tag.TAG_COMPOUND)) { + CompoundTag mj_storage_Tag = nbt.getCompound("mj_storage"); + long mj_capability = mj_storage_Tag.getLong("mj_capability"); + long mj_stored = mj_storage_Tag.getLong("mj_stored"); + currentTip.add(new ProgressElement((float) (((double) mj_stored) / ((double) mj_capability)), Component.literal(mj_stored + " MJ/" + mj_capability + "MJ"), PROGRESS_STYLE, BoxStyle.DEFAULT, false)); + } + }); + } + } + + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCCore.MODID, "mj_storage_client_data"); + } + } + + static class NBTProvider extends BaseWailaDataProvider.NBTProvider { + @Override + public void getNBTData(CompoundTag nbt, BlockAccessor accessor) { + if (accessor.getBlockEntity() instanceof TileBC_Neptune tileBC) { + tileBC.getCapability(MjAPI.CAP_READABLE).ifPresent(mjReadable -> { + CompoundTag mj_storage_Tag = new CompoundTag(); + mj_storage_Tag.putLong("mj_capability", mjReadable.getCapacity() / MjAPI.MJ); + mj_storage_Tag.putLong("mj_stored", mjReadable.getStored() / MjAPI.MJ); + nbt.put("mj_storage", mj_storage_Tag); + }); + } + } + + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCCore.MODID, "mj_storage_server_data"); + } + } +} diff --git a/common/buildcraft/compat/module/waila/RobotPowerDataProvider.java b/common/buildcraft/compat/module/waila/RobotPowerDataProvider.java new file mode 100644 index 0000000..4caf82b --- /dev/null +++ b/common/buildcraft/compat/module/waila/RobotPowerDataProvider.java @@ -0,0 +1,63 @@ +package buildcraft.compat.module.waila; + +import buildcraft.api.mj.MjAPI; +import buildcraft.api.robots.EntityRobotBase; +import buildcraft.robotics.BCRobotics; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.Level; +import snownee.jade.api.EntityAccessor; +import snownee.jade.api.ITooltip; +import snownee.jade.api.config.IPluginConfig; +import snownee.jade.api.ui.BoxStyle; +import snownee.jade.api.ui.IProgressStyle; +import snownee.jade.impl.ui.ProgressElement; +import snownee.jade.impl.ui.ProgressStyle; + +public class RobotPowerDataProvider { + static class BodyProvider extends BaseWailaDataProvider.BodyProviderEntity { + private static final IProgressStyle PROGRESS_STYLE = new ProgressStyle() + .color(-15731468, -16721961) + .textColor(DyeColor.WHITE.getTextColor()); + + @Override + public void getWailaBody(ITooltip currentTip, EntityAccessor accessor, IPluginConfig iPluginConfig) { + if (accessor.getEntity() instanceof EntityRobotBase) { + CompoundTag nbt = accessor.getServerData(); + if (nbt.contains("mj_storage", Tag.TAG_COMPOUND)) { + CompoundTag mj_storage_Tag = nbt.getCompound("mj_storage"); + long mj_capability = mj_storage_Tag.getLong("mj_capability"); + long mj_stored = mj_storage_Tag.getLong("mj_stored"); + currentTip.add(new ProgressElement((float) (((double) mj_stored) / ((double) mj_capability)), Component.literal(mj_stored + " MJ/" + mj_capability + "MJ"), PROGRESS_STYLE, BoxStyle.DEFAULT, false)); + } + } + } + + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCRobotics.MODID, "robot_power_client_data"); + } + } + + static class NBTProvider extends BaseWailaDataProvider.NBTProviderEntity { + @Override + public void getNBTData(CompoundTag nbt, ServerPlayer player, Level world, Entity entity, boolean showDetails) { + if (entity instanceof EntityRobotBase) { + CompoundTag mj_storage_Tag = new CompoundTag(); + mj_storage_Tag.putLong("mj_capability", ((EntityRobotBase) entity).getBattery().getCapacity() / MjAPI.MJ); + mj_storage_Tag.putLong("mj_stored", ((EntityRobotBase) entity).getBattery().getStored() / MjAPI.MJ); + nbt.put("mj_storage", mj_storage_Tag); + } + } + + @Override + public ResourceLocation getUid() { + return ResourceLocation.tryBuild(BCRobotics.MODID, "robot_power_server_data"); + } + } +} diff --git a/common/buildcraft/compat/network/CompatGui.java b/common/buildcraft/compat/network/CompatGui.java index 3c5d599..75212fc 100644 --- a/common/buildcraft/compat/network/CompatGui.java +++ b/common/buildcraft/compat/network/CompatGui.java @@ -1,144 +1,160 @@ -package buildcraft.compat.network; - -import javax.annotation.Nullable; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.network.IGuiHandler; - -import buildcraft.compat.BCCompat; -import buildcraft.compat.CompatUtils; - -// Half-decent class (inspired by how forestry does things) -// This really wants fleshing out and moving into mainline buildcraft though -// Along with a sensible way of dealing with pluggables etc -public enum CompatGui { - - FORESTRY_PROPOLIS_PIPE(IGuiTarget.TILE); - - static final CompatGui[] VALUES = values(); - - @SidedProxy(modId = BCCompat.MODID) - public static CommonProxy guiHandlerProxy; - - public final IGuiTarget target; - - private CompatGui(IGuiTarget target) { - this.target = target; - } - - public void openGui(EntityPlayer player) { - openGui(player, 0, 0, 0, 0); - } - - public void openGui(EntityPlayer player, BlockPos pos) { - openGui(player, pos.getX(), pos.getY(), pos.getZ(), 0); - } - - public void openGui(EntityPlayer player, int x, int y, int z) { - openGui(player, x, y, z, 0); - } - - public void openGui(EntityPlayer player, int data) { - openGui(player, 0, 0, 0, data); - } - - public void openGui(EntityPlayer player, BlockPos pos, int data) { - openGui(player, pos.getX(), pos.getY(), pos.getZ(), data); - } - - public void openGui(EntityPlayer player, int x, int y, int z, int data) { - player.openGui(BCCompat.instance, packGui(this, data), player.world, x, y, z); - } - - protected static int packGui(Enum gui, int data) { - if (data < 0 || data > 0xFF_FF_FF) { - throw new IllegalArgumentException("Data must be between 0 and 0xFF_FF_FF (inclusive)"); - } - return (data << 8) | gui.ordinal(); - } - - @Nullable - protected static CompatGui getGui(int id) { - id &= 0xFF; - if (id < 0 || id >= CompatGui.VALUES.length) { - return null; - } - return CompatGui.VALUES[id]; - } - - protected static int getData(int id) { - return id >>> 8; - } - - @FunctionalInterface - public interface IGuiTarget { - public static final IGuiTarget TILE = (player, world, x, y, z, data) -> { - TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); - if (tile instanceof IGuiCreator) { - return (IGuiCreator) tile; - } - if (tile != null) { - return tile.getCapability(CompatUtils.CAP_GUI_CREATOR, null); - } - return null; - }; - - @Nullable - IGuiCreator getCreator(EntityPlayer player, World world, int x, int y, int z, int data); - } - - public static abstract class CommonProxy implements IGuiHandler { - - @Nullable - protected static IGuiCreator getGuiCreator(int id, EntityPlayer player, World world, int x, int y, int z) { - CompatGui type = getGui(id); - int data = getData(id); - if (type == null) { - return null; - } - IGuiCreator creator = type.target.getCreator(player, world, x, y, z, data); - if (creator == null || creator.getGuiType() != type) { - return null; - } - return creator; - } - - @Override - @Nullable - public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - IGuiCreator creator = getGuiCreator(id, player, world, x, y, z); - if (creator == null) { - return null; - } - return creator.getServerGuiElement(getData(id), player); - } - } - - public static class ServerProxy extends CommonProxy { - - @Override - @Nullable - public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - return null; - } - } - - public static class ClientProxy extends CommonProxy { - - @Override - @Nullable - public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - IGuiCreator creator = getGuiCreator(id, player, world, x, y, z); - if (creator == null) { - return null; - } - return creator.getClientGuiElement(getData(id), player); - } - } - -} +//package buildcraft.compat.network; +// +//import buildcraft.compat.BCCompat; +//import buildcraft.compat.CompatUtils; +//import net.minecraft.core.BlockPos; +//import net.minecraft.core.Direction; +//import net.minecraft.world.entity.player.Player; +//import net.minecraft.world.level.Level; +//import net.minecraft.world.level.block.entity.BlockEntity; +// +//import javax.annotation.Nullable; +// +//public enum CompatGui +//{ +// FORESTRY_PROPOLIS_PIPE(CompatGui.IGuiTarget.TILE); +// +// static final CompatGui[] VALUES = values(); +// // @SidedProxy( +//// modId = "buildcraftcompat" +//// ) +// public static CommonProxy guiHandlerProxy; +// public final IGuiTarget target; +// +// private CompatGui(IGuiTarget target) +// { +// this.target = target; +// } +// +// public void openGui(EntityPlayer player) +// { +// this.openGui(player, 0, 0, 0, 0); +// } +// +// public void openGui(EntityPlayer player, BlockPos pos) +// { +// this.openGui(player, pos.func_177958_n(), pos.func_177956_o(), pos.func_177952_p(), 0); +// } +// +// public void openGui(EntityPlayer player, int x, int y, int z) +// { +// this.openGui(player, x, y, z, 0); +// } +// +// public void openGui(EntityPlayer player, int data) +// { +// this.openGui(player, 0, 0, 0, data); +// } +// +// public void openGui(EntityPlayer player, BlockPos pos, int data) +// { +// this.openGui(player, pos.func_177958_n(), pos.func_177956_o(), pos.func_177952_p(), data); +// } +// +// public void openGui(EntityPlayer player, int x, int y, int z, int data) +// { +// player.openGui(BCCompat.instance, packGui(this, data), player.field_70170_p, x, y, z); +// } +// +// protected static int packGui(Enum gui, int data) +// { +// if (data >= 0 && data <= 16777215) +// { +// return data << 8 | gui.ordinal(); +// } +// else +// { +// throw new IllegalArgumentException("Data must be between 0 and 0xFF_FF_FF (inclusive)"); +// } +// } +// +// @Nullable +// protected static CompatGui getGui(int id) +// { +// id &= 255; +// return id >= 0 && id < VALUES.length ? VALUES[id] : null; +// } +// +// protected static int getData(int id) +// { +// return id >>> 8; +// } +// +// public static class ClientProxy extends CommonProxy +// { +// public ClientProxy() +// { +// } +// +// @Nullable +// public Object getClientGuiElement(int id, Player player, Level world, int x, int y, int z) +// { +// IGuiCreator creator = getGuiCreator(id, player, world, x, y, z); +// return creator == null ? null : creator.getClientGuiElement(CompatGui.getData(id), player); +// } +// } +// +// public static class ServerProxy extends CommonProxy +// { +// public ServerProxy() +// { +// } +// +// @Nullable +// public Object getClientGuiElement(int id, Player player, Level world, int x, int y, int z) +// { +// return null; +// } +// } +// +// // public abstract static class CommonProxy implements IGuiHandler +// public abstract static class CommonProxy +// { +// public CommonProxy() +// { +// } +// +// @Nullable +// protected static IGuiCreator getGuiCreator(int id, Player player, Level world, int x, int y, int z) +// { +// CompatGui type = CompatGui.getGui(id); +// int data = CompatGui.getData(id); +// if (type == null) +// { +// return null; +// } +// else +// { +// IGuiCreator creator = type.target.getCreator(player, world, x, y, z, data); +// return creator != null && creator.getGuiType() == type ? creator : null; +// } +// } +// +// @Nullable +// public Object getServerGuiElement(int id, Player player, Level world, int x, int y, int z) +// { +// IGuiCreator creator = getGuiCreator(id, player, world, x, y, z); +// return creator == null ? null : creator.getServerGuiElement(CompatGui.getData(id), player); +// } +// } +// +// @FunctionalInterface +// public interface IGuiTarget +// { +// IGuiTarget TILE = (player, world, x, y, z, data) -> +// { +// BlockEntity tile = world.getBlockEntity(new BlockPos(x, y, z)); +// if (tile instanceof IGuiCreator) +// { +// return (IGuiCreator) tile; +// } +// else +// { +// return tile != null ? (IGuiCreator) tile.getCapability(CompatUtils.CAP_GUI_CREATOR, null) : null; +// } +// }; +// +// @Nullable +// IGuiCreator getCreator(Player var1, Level var2, int var3, int var4, int var5, int var6); +// } +//} diff --git a/common/buildcraft/compat/network/IGuiCreator.java b/common/buildcraft/compat/network/IGuiCreator.java index c1d26fe..7897365 100644 --- a/common/buildcraft/compat/network/IGuiCreator.java +++ b/common/buildcraft/compat/network/IGuiCreator.java @@ -1,25 +1,22 @@ package buildcraft.compat.network; -import javax.annotation.Nullable; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import javax.annotation.Nullable; -/** A creator that can */ -// TODO: Move this into bc lib and make it more useful! public interface IGuiCreator { Enum getGuiType(); - /** @param data The extra 24 bits that are unused by the byte ID. */ @Nullable - @SideOnly(Side.CLIENT) - GuiContainer getClientGuiElement(int data, EntityPlayer player); + @OnlyIn(Dist.CLIENT) +// GuiContainer getClientGuiElement(int var1, EntityPlayer var2); + AbstractContainerScreen getClientGuiElement(int var1, Player var2); - /** @param data The extra 24 bits that are unused by the byte ID. */ @Nullable - Container getServerGuiElement(int data, EntityPlayer player); +// Container getServerGuiElement(int var1, EntityPlayer var2); + AbstractContainerMenu getServerGuiElement(int var1, Player var2); } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..aa2c4cc --- /dev/null +++ b/gradle.properties @@ -0,0 +1,38 @@ +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false + + +minecraft_version=1.20.1 +minecraft_version_range=[1.20.1,1.20.2) +forge_version=47.3.12 +# The Forge version range can use any version of Forge as bounds or match the loader version range +forge_version_range=[47,) +# The loader version range can only use the major version of Forge/FML as bounds +loader_version_range=[47,) +# The mapping channel to use for mappings. +# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. +# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. +# +# | Channel | Version | | +# |-----------|----------------------|--------------------------------------------------------------------------------| +# | official | MCVersion | Official field/method names from Mojang mapping files | +# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official | +# +# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. +# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md +# +# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge. +# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started +mapping_channel=official +# The mapping version to query from the mapping channel. +# This must match the format required by the mapping channel. +mapping_version=1.20.1 + + +mod_id=buildcraft +mod_name=BuildCraft +mod_license=Minecraft Mod Public License +mod_version=7.99.24.9 +mod_group_id=com.mod-buildcraft +mod_authors=SpaceToad, BuildCraft Team +mod_description=Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index ca78035..c1962a7 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 66ad866..2617362 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Sep 05 20:44:05 EEST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 27309d9..aeb74cb 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,126 @@ -#!/usr/bin/env bash +#!/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 UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +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 -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -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="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +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 - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +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" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +129,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + 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 @@ -89,76 +137,109 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -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 - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -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" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; 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` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + 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 - i=$((i+1)) + # 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 - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - 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=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# 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"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 832fdb6..93e3f59 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,20 @@ -@if "%DEBUG%" == "" @echo off +@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 @@ -9,19 +25,23 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused 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= +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 init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,44 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%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 +if %ERRORLEVEL% equ 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 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/mod_info/META-INF/mods.toml b/mod_info/META-INF/mods.toml new file mode 100644 index 0000000..a055f53 --- /dev/null +++ b/mod_info/META-INF/mods.toml @@ -0,0 +1,151 @@ +modLoader="javafml" +loaderVersion="[47,)" +license="Minecraft Mod Public License" +issueTrackerURL="" +[[mods]] +modId="buildcraftlib" +displayName="BuildCraft Lib" +version="7.99.24.9" +description="Library mod used by buildcraft." +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftcore" +displayName="BuildCraft" +version="7.99.24.9" +description="Extending Minecraft with pipes, auto-crafting, quarries, engines and much more!" +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftbuilders" +displayName="BuildCraft Builders" +version="7.99.24.9" +description="Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Builders Component)" +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftenergy" +displayName="BuildCraft Energy" +version="7.99.24.9" +description="Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Energy Component)" +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftfactory" +displayName="BuildCraft Factory" +version="7.99.24.9" +description="Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Factory Component)" +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftsilicon" +displayName="BuildCraft Silicon" +version="7.99.24.9" +description="Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Silicon Component)" +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcrafttransport" +displayName="BuildCraft Transport" +version="7.99.24.9" +description="Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Transport Component)" +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftrobotics" +displayName="BuildCraft Robotics" +version="7.99.24.9" +description="Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Robotics Component)" +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftcompat" +displayName="BuildCraft Compat" +version="7.99.24.9" +description="Compatibility add-on for BuildCraft" +credits="Created by asie" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="BuildCraft Team" + +[[dependencies.buildcraftcore]] + modId="forge" + mandatory=true + versionRange="[47,)" + ordering="NONE" + side="BOTH" +[[dependencies.buildcraftcore]] + modId="minecraft" + mandatory=true + versionRange="[1.20,1.20.2)" + ordering="NONE" + side="BOTH" +[[dependencies.buildcraftcore]] + modId="buildcraftlib" + mandatory=true + versionRange="[0.0.0,)" + ordering="AFTER" + side="BOTH" +[[dependencies.buildcraftenergy]] + modId="buildcraftcore" + mandatory=true + versionRange="[0.0.0,)" + ordering="AFTER" + side="BOTH" +[[dependencies.buildcraftbuilders]] + modId="buildcraftcore" + mandatory=true + versionRange="[0.0.0,)" + ordering="AFTER" + side="BOTH" +[[dependencies.buildcrafttransport]] + modId="buildcraftcore" + mandatory=true + versionRange="[0.0.0,)" + ordering="AFTER" + side="BOTH" +[[dependencies.buildcraftrobotics]] + modId="buildcraftcore" + mandatory=true + versionRange="[0.0.0,)" + ordering="AFTER" + side="BOTH" +[[dependencies.buildcraftcompat]] + modId="buildcraftcore" + mandatory=true + versionRange="[0.0.0,)" + ordering="AFTER" + side="BOTH" diff --git a/resources/META-INF/mods.toml_ b/resources/META-INF/mods.toml_ new file mode 100644 index 0000000..9864995 --- /dev/null +++ b/resources/META-INF/mods.toml_ @@ -0,0 +1,32 @@ +modLoader="javafml" +loaderVersion="[32,)" +license="Minecraft Mod Public License" +issueTrackerURL="" +[[mods]] +modId="buildcraftlib" +displayName="BuildCraft Lib" +version="7.99.24.9" +description="Library mod used by buildcraft." +credits="Created by SpaceToad" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="SpaceToad, BuildCraft Team" + +[[mods]] +modId="buildcraftcompat" +displayName="BuildCraft Compat" +version="7.99.24.9" +description="Compatibility add-on for BuildCraft" +credits="Created by asie" +logoFile="logo.png" +displayURL="http://www.mod-buildcraft.com/" +updateJSONURL="" +authors="BuildCraft Team" + +[[dependencies.buildcraftcompat]] + modId="buildcraftcore" + mandatory=true + versionRange="[0.0.0,)" + ordering="AFTER" + side="BOTH" diff --git a/resources/assets/buildcraftcompat/lang/de_DE.lang b/resources/assets/buildcraftcompat/lang/de_DE.lang deleted file mode 100644 index 03ffea5..0000000 --- a/resources/assets/buildcraftcompat/lang/de_DE.lang +++ /dev/null @@ -1,20 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=Bienenrohr - -for.gui.pipe.filter.anything=Alles -for.gui.pipe.filter.bee=Alle Bienen -for.gui.pipe.filter.cave=Höhlenbewohner -for.gui.pipe.filter.closed=Geschlossen -for.gui.pipe.filter.drone=Dronen -for.gui.pipe.filter.flyer=Starke Flieger -for.gui.pipe.filter.item=Gegenstände -for.gui.pipe.filter.nocturnal=Nachtaktive -for.gui.pipe.filter.princess=Prinzessinnen -for.gui.pipe.filter.pure_breed=Reinrassige -for.gui.pipe.filter.pure_cave=Reinrassige Höhlenbewohner -for.gui.pipe.filter.pure_flyer=Reinrassig starke Flieger -for.gui.pipe.filter.pure_nocturnal=Reinrassig nachtaktive -for.gui.pipe.filter.queen=Königinnen diff --git a/resources/assets/buildcraftcompat/lang/de_de.json b/resources/assets/buildcraftcompat/lang/de_de.json new file mode 100644 index 0000000..728942c --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/de_de.json @@ -0,0 +1,24 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "Bienenrohr", + + "for.gui.pipe.filter.anything": "Alles", + "for.gui.pipe.filter.bee": "Alle Bienen", + "for.gui.pipe.filter.cave": "Höhlenbewohner", + "for.gui.pipe.filter.closed": "Geschlossen", + "for.gui.pipe.filter.drone": "Dronen", + "for.gui.pipe.filter.flyer": "Starke Flieger", + "for.gui.pipe.filter.item": "Gegenstände", + "for.gui.pipe.filter.nocturnal": "Nachtaktive", + "for.gui.pipe.filter.princess": "Prinzessinnen", + "for.gui.pipe.filter.pure_breed": "Reinrassige", + "for.gui.pipe.filter.pure_cave": "Reinrassige Höhlenbewohner", + "for.gui.pipe.filter.pure_flyer": "Reinrassig starke Flieger", + "for.gui.pipe.filter.pure_nocturnal": "Reinrassig nachtaktive", + "for.gui.pipe.filter.queen": "Königinnen", + + "null": "=w=" +} diff --git a/resources/assets/buildcraftcompat/lang/en_US.lang b/resources/assets/buildcraftcompat/lang/en_US.lang deleted file mode 100644 index 3975239..0000000 --- a/resources/assets/buildcraftcompat/lang/en_US.lang +++ /dev/null @@ -1,25 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=Apiarist's Pipe - -for.gui.pipe.filter.anything=Anything -for.gui.pipe.filter.bee=Any Bees -for.gui.pipe.filter.cave=Cave-Dwellers -for.gui.pipe.filter.closed=Closed -for.gui.pipe.filter.drone=Drones -for.gui.pipe.filter.flyer=Strong Flyers -for.gui.pipe.filter.item=Items -for.gui.pipe.filter.natural=Natural Origin -for.gui.pipe.filter.nocturnal=Nocturnal Bees -for.gui.pipe.filter.princess=Princesses -for.gui.pipe.filter.pure_breed=Pure-Bred Bees -for.gui.pipe.filter.pure_cave=Pure Cave-Dwellers -for.gui.pipe.filter.pure_flyer=Pure Flyers -for.gui.pipe.filter.pure_nocturnal=Pure Nocturnal Bees -for.gui.pipe.filter.queen=Queen - -gate.trigger.mfr.backstuffed=Has Drops -gate.trigger.mfr.conreversed=Conveyor Reversed -gate.trigger.mfr.conrunning=Conveyor Running \ No newline at end of file diff --git a/resources/assets/buildcraftcompat/lang/en_us.json b/resources/assets/buildcraftcompat/lang/en_us.json new file mode 100644 index 0000000..3643699 --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/en_us.json @@ -0,0 +1,64 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "Apiarist's Pipe", + + "for.gui.pipe.filter.anything": "Anything", + "for.gui.pipe.filter.bee": "Any Bees", + "for.gui.pipe.filter.cave": "Cave-Dwellers", + "for.gui.pipe.filter.closed": "Closed", + "for.gui.pipe.filter.drone": "Drones", + "for.gui.pipe.filter.flyer": "Strong Flyers", + "for.gui.pipe.filter.item": "Items", + "for.gui.pipe.filter.natural": "Natural Origin", + "for.gui.pipe.filter.nocturnal": "Nocturnal Bees", + "for.gui.pipe.filter.princess": "Princesses", + "for.gui.pipe.filter.pure_breed": "Pure-Bred Bees", + "for.gui.pipe.filter.pure_cave": "Pure Cave-Dwellers", + "for.gui.pipe.filter.pure_flyer": "Pure Flyers", + "for.gui.pipe.filter.pure_nocturnal": "Pure Nocturnal Bees", + "for.gui.pipe.filter.queen": "Queen", + + "gate.trigger.mfr.backstuffed": "Has Drops", + "gate.trigger.mfr.conreversed": "Conveyor Reversed", + "gate.trigger.mfr.conrunning": "Conveyor Running", + + // Calen 1.18.2 + // JEI + "buildcraft.jei.title.heatable_fluids": "Heatable Fluids", + "buildcraft.jei.title.coolable_fluids": "Coolable Fluids", + "buildcraft.jei.title.distillable_fluids": "Distillable Fluids", + "buildcraft.jei.title.combustion_engine_fuels": "Combustion Engine Fuels", + "buildcraft.jei.title.combustion_engine_fuels.burn_time": "Burns for %ds", + "buildcraft.jei.title.combustion_engine_fuels.burn_speed": " at %s MJ/t", + "buildcraft.jei.title.combustion_engine_fuels.burn_total": " total %s MJ", + + // REI + "buildcraft.rei.title.heatable_fluids": "Heatable Fluids", + "buildcraft.rei.title.coolable_fluids": "Coolable Fluids", + "buildcraft.rei.title.distillable_fluids": "Distillable Fluids", + "buildcraft.rei.title.combustion_engine_fuels": "Combustion Engine Fuels", + "buildcraft.rei.title.combustion_engine_fuels.burn_time": "Burns for %ds", + "buildcraft.rei.title.combustion_engine_fuels.burn_speed": " at %s MJ/t", + "buildcraft.rei.title.combustion_engine_fuels.burn_total": " total %s MJ", + + // Waila + "buildcraft.waila.crafting": "§fMaking: ", + "buildcraft.waila.no_recipe": "§7No recipe", + "buildcraft.waila.crafting_from": "§fFrom: ", + "buildcraft.waila.waiting_for_laser": "§fWaiting from laser: §b%s MJ", + "config.jade.plugin_buildcraftsilicon.laser_target_client_data": "Laser Target", + "config.jade.plugin_buildcraftsilicon.laser_target_server_data": "Laser Target", + "config.jade.plugin_buildcraftfactory.autocraft_client_data": "Autocraft", + "config.jade.plugin_buildcraftfactory.autocraft_server_data": "Autocraft", + "config.jade.plugin_buildcraftsilicon.assembly_client_data": "Assembly", + "config.jade.plugin_buildcraftsilicon.assembly_server_data": "Assembly", + "config.jade.plugin_buildcraftcore.mj_storage_client_data": "MJ Storage", + "config.jade.plugin_buildcraftcore.mj_storage_server_data": "MJ Storage", + "config.jade.plugin_buildcraftrobotics.robot_power_client_data": "Robot Power", + "config.jade.plugin_buildcraftrobotics.robot_power_server_data": "Robot Power", + + "null": "=w=" +} diff --git a/resources/assets/buildcraftcompat/lang/fr_FR.lang b/resources/assets/buildcraftcompat/lang/fr_FR.lang deleted file mode 100644 index 02f01f3..0000000 --- a/resources/assets/buildcraftcompat/lang/fr_FR.lang +++ /dev/null @@ -1,20 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=Tuyau de transport d'apiculteur - -for.gui.pipe.filter.anything=Tout -for.gui.pipe.filter.bee=Toutes abeilles -for.gui.pipe.filter.cave=De cave -for.gui.pipe.filter.closed=Rien -for.gui.pipe.filter.drone=Ouvrières -for.gui.pipe.filter.flyer=Les volantes -for.gui.pipe.filter.item=Éléments -for.gui.pipe.filter.nocturnal=Les noctures -for.gui.pipe.filter.princess=Princesses -for.gui.pipe.filter.pure_breed=Pures races -for.gui.pipe.filter.pure_cave=De cave pures -for.gui.pipe.filter.pure_flyer=Volantes pures -for.gui.pipe.filter.pure_nocturnal=Nocturne pures -for.gui.pipe.filter.queen=Reines diff --git a/resources/assets/buildcraftcompat/lang/fr_fr.json b/resources/assets/buildcraftcompat/lang/fr_fr.json new file mode 100644 index 0000000..d35b127 --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/fr_fr.json @@ -0,0 +1,24 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "Tuyau de transport d'apiculteur", + + "for.gui.pipe.filter.anything": "Tout", + "for.gui.pipe.filter.bee": "Toutes abeilles", + "for.gui.pipe.filter.cave": "De cave", + "for.gui.pipe.filter.closed": "Rien", + "for.gui.pipe.filter.drone": "Ouvrières", + "for.gui.pipe.filter.flyer": "Les volantes", + "for.gui.pipe.filter.item": "Éléments", + "for.gui.pipe.filter.nocturnal": "Les noctures", + "for.gui.pipe.filter.princess": "Princesses", + "for.gui.pipe.filter.pure_breed": "Pures races", + "for.gui.pipe.filter.pure_cave": "De cave pures", + "for.gui.pipe.filter.pure_flyer": "Volantes pures", + "for.gui.pipe.filter.pure_nocturnal": "Nocturne pures", + "for.gui.pipe.filter.queen": "Reines", + + "null": "=w=" +} diff --git a/resources/assets/buildcraftcompat/lang/ko_KR.lang b/resources/assets/buildcraftcompat/lang/ko_KR.lang deleted file mode 100644 index bdcfa70..0000000 --- a/resources/assets/buildcraftcompat/lang/ko_KR.lang +++ /dev/null @@ -1,20 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=양봉업자의 파이프 - -for.gui.pipe.filter.anything=모든 아이템과 벌을 통과 -for.gui.pipe.filter.bee=모든 벌들 -for.gui.pipe.filter.cave=동굴 속에서도 작업 가능 -for.gui.pipe.filter.closed=아이템을 받지 않음 -for.gui.pipe.filter.drone=일벌 -for.gui.pipe.filter.flyer=우천시에도 작업 가능 -for.gui.pipe.filter.item=아이템만 -for.gui.pipe.filter.nocturnal=야행성 벌 -for.gui.pipe.filter.princess=공주벌 -for.gui.pipe.filter.pure_breed=공주벌 -for.gui.pipe.filter.pure_cave=동굴 속에서도 작업 가능한 순종 벌 -for.gui.pipe.filter.pure_flyer=우천시에도 작업 가능한 순종 벌 -for.gui.pipe.filter.pure_nocturnal=순종 야행성 벌 -for.gui.pipe.filter.queen=여왕벌 diff --git a/resources/assets/buildcraftcompat/lang/ko_kr.json b/resources/assets/buildcraftcompat/lang/ko_kr.json new file mode 100644 index 0000000..aba0c09 --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/ko_kr.json @@ -0,0 +1,24 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "양봉업자의 파이프", + + "for.gui.pipe.filter.anything": "모든 아이템과 벌을 통과", + "for.gui.pipe.filter.bee": "모든 벌들", + "for.gui.pipe.filter.cave": "동굴 속에서도 작업 가능", + "for.gui.pipe.filter.closed": "아이템을 받지 않음", + "for.gui.pipe.filter.drone": "일벌", + "for.gui.pipe.filter.flyer": "우천시에도 작업 가능", + "for.gui.pipe.filter.item": "아이템만", + "for.gui.pipe.filter.nocturnal": "야행성 벌", + "for.gui.pipe.filter.princess": "공주벌", + "for.gui.pipe.filter.pure_breed": "공주벌", + "for.gui.pipe.filter.pure_cave": "동굴 속에서도 작업 가능한 순종 벌", + "for.gui.pipe.filter.pure_flyer": "우천시에도 작업 가능한 순종 벌", + "for.gui.pipe.filter.pure_nocturnal": "순종 야행성 벌", + "for.gui.pipe.filter.queen": "여왕벌", + + "null": "=w=" +} diff --git a/resources/assets/buildcraftcompat/lang/pt_BR.lang b/resources/assets/buildcraftcompat/lang/pt_BR.lang deleted file mode 100644 index 35da29d..0000000 --- a/resources/assets/buildcraftcompat/lang/pt_BR.lang +++ /dev/null @@ -1,20 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=Tubo do Apicultor - -for.gui.pipe.filter.anything=Nada -for.gui.pipe.filter.bee=Quaisquer Abelhas -for.gui.pipe.filter.cave=Habitante de Cavernas -for.gui.pipe.filter.closed=Fechado -for.gui.pipe.filter.drone=Zangões -for.gui.pipe.filter.flyer=Insetos Fortes -for.gui.pipe.filter.item=Ítens -for.gui.pipe.filter.nocturnal=Abelhas Noturnas -for.gui.pipe.filter.princess=Princesas -for.gui.pipe.filter.pure_breed=Abelhas de Raça Pura -for.gui.pipe.filter.pure_cave=Puras Habitantes das Cavernas -for.gui.pipe.filter.pure_flyer=Insetos Puros -for.gui.pipe.filter.pure_nocturnal=Abelhas Noturnas Puras -for.gui.pipe.filter.queen=Rainha diff --git a/resources/assets/buildcraftcompat/lang/pt_br.json b/resources/assets/buildcraftcompat/lang/pt_br.json new file mode 100644 index 0000000..8a5185f --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/pt_br.json @@ -0,0 +1,24 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "Tubo do Apicultor", + + "for.gui.pipe.filter.anything": "Nada", + "for.gui.pipe.filter.bee": "Quaisquer Abelhas", + "for.gui.pipe.filter.cave": "Habitante de Cavernas", + "for.gui.pipe.filter.closed": "Fechado", + "for.gui.pipe.filter.drone": "Zangões", + "for.gui.pipe.filter.flyer": "Insetos Fortes", + "for.gui.pipe.filter.item": "Ítens", + "for.gui.pipe.filter.nocturnal": "Abelhas Noturnas", + "for.gui.pipe.filter.princess": "Princesas", + "for.gui.pipe.filter.pure_breed": "Abelhas de Raça Pura", + "for.gui.pipe.filter.pure_cave": "Puras Habitantes das Cavernas", + "for.gui.pipe.filter.pure_flyer": "Insetos Puros", + "for.gui.pipe.filter.pure_nocturnal": "Abelhas Noturnas Puras", + "for.gui.pipe.filter.queen": "Rainha", + + "null": "=w=" +} diff --git a/resources/assets/buildcraftcompat/lang/ru_RU.lang b/resources/assets/buildcraftcompat/lang/ru_RU.lang deleted file mode 100644 index 4d41e5a..0000000 --- a/resources/assets/buildcraftcompat/lang/ru_RU.lang +++ /dev/null @@ -1,25 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=Труба пчеловода - -for.gui.pipe.filter.anything=Всё -for.gui.pipe.filter.bee=Любые пчелы -for.gui.pipe.filter.cave=Пещерные -for.gui.pipe.filter.closed=Закрыт -for.gui.pipe.filter.drone=Трутни -for.gui.pipe.filter.flyer=Летуны -for.gui.pipe.filter.item=Предметы -for.gui.pipe.filter.natural=Естественного происх. -for.gui.pipe.filter.nocturnal=Ночные -for.gui.pipe.filter.princess=Принцессы -for.gui.pipe.filter.pure_breed=Чистопородные -for.gui.pipe.filter.pure_cave=Породистые пещерные -for.gui.pipe.filter.pure_flyer=Породистые летуны -for.gui.pipe.filter.pure_nocturnal=Породистые ночные -for.gui.pipe.filter.queen=Матки - -gate.trigger.mfr.backstuffed=Есть предметы -gate.trigger.mfr.conreversed=Конвейер реверсирован -gate.trigger.mfr.conrunning=Конвейер работает \ No newline at end of file diff --git a/resources/assets/buildcraftcompat/lang/ru_ru.json b/resources/assets/buildcraftcompat/lang/ru_ru.json new file mode 100644 index 0000000..1be6465 --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/ru_ru.json @@ -0,0 +1,29 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "Труба пчеловода", + + "for.gui.pipe.filter.anything": "Всё", + "for.gui.pipe.filter.bee": "Любые пчелы", + "for.gui.pipe.filter.cave": "Пещерные", + "for.gui.pipe.filter.closed": "Закрыт", + "for.gui.pipe.filter.drone": "Трутни", + "for.gui.pipe.filter.flyer": "Летуны", + "for.gui.pipe.filter.item": "Предметы", + "for.gui.pipe.filter.natural": "Естественного происх.", + "for.gui.pipe.filter.nocturnal": "Ночные", + "for.gui.pipe.filter.princess": "Принцессы", + "for.gui.pipe.filter.pure_breed": "Чистопородные", + "for.gui.pipe.filter.pure_cave": "Породистые пещерные", + "for.gui.pipe.filter.pure_flyer": "Породистые летуны", + "for.gui.pipe.filter.pure_nocturnal": "Породистые ночные", + "for.gui.pipe.filter.queen": "Матки", + + "gate.trigger.mfr.backstuffed": "Есть предметы", + "gate.trigger.mfr.conreversed": "Конвейер реверсирован", + "gate.trigger.mfr.conrunning": "Конвейер работает", + + "null": "=w=" +} diff --git a/resources/assets/buildcraftcompat/lang/uk_UA.lang b/resources/assets/buildcraftcompat/lang/uk_UA.lang deleted file mode 100644 index 711c823..0000000 --- a/resources/assets/buildcraftcompat/lang/uk_UA.lang +++ /dev/null @@ -1,20 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=Труба пчеловода - -for.gui.pipe.filter.anything=Всё -for.gui.pipe.filter.bee=Любые пчелы -for.gui.pipe.filter.cave=Пещерные -for.gui.pipe.filter.closed=Закрыт -for.gui.pipe.filter.drone=Трутни -for.gui.pipe.filter.flyer=Летуны -for.gui.pipe.filter.item=Предметы -for.gui.pipe.filter.nocturnal=Ночные -for.gui.pipe.filter.princess=Принцессы -for.gui.pipe.filter.pure_breed=Чистопородные -for.gui.pipe.filter.pure_cave=Породистые пещерные -for.gui.pipe.filter.pure_flyer=Породистые летуны -for.gui.pipe.filter.pure_nocturnal=Породистые ночные -for.gui.pipe.filter.queen=Королевы diff --git a/resources/assets/buildcraftcompat/lang/uk_ua.json b/resources/assets/buildcraftcompat/lang/uk_ua.json new file mode 100644 index 0000000..da44267 --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/uk_ua.json @@ -0,0 +1,24 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "Труба пчеловода", + + "for.gui.pipe.filter.anything": "Всё", + "for.gui.pipe.filter.bee": "Любые пчелы", + "for.gui.pipe.filter.cave": "Пещерные", + "for.gui.pipe.filter.closed": "Закрыт", + "for.gui.pipe.filter.drone": "Трутни", + "for.gui.pipe.filter.flyer": "Летуны", + "for.gui.pipe.filter.item": "Предметы", + "for.gui.pipe.filter.nocturnal": "Ночные", + "for.gui.pipe.filter.princess": "Принцессы", + "for.gui.pipe.filter.pure_breed": "Чистопородные", + "for.gui.pipe.filter.pure_cave": "Породистые пещерные", + "for.gui.pipe.filter.pure_flyer": "Породистые летуны", + "for.gui.pipe.filter.pure_nocturnal": "Породистые ночные", + "for.gui.pipe.filter.queen": "Королевы", + + "null": "=w=" +} diff --git a/resources/assets/buildcraftcompat/lang/zh_CN.lang b/resources/assets/buildcraftcompat/lang/zh_CN.lang deleted file mode 100644 index e9f5aff..0000000 --- a/resources/assets/buildcraftcompat/lang/zh_CN.lang +++ /dev/null @@ -1,20 +0,0 @@ -#################### -# APIARIST'S PIPE -#################### - -item.buildcraftPipe.pipeitemspropolis.name=养蜂员管道 - -for.gui.pipe.filter.anything=任意物品 -for.gui.pipe.filter.bee=任意蜜蜂 -for.gui.pipe.filter.cave=穴居蜂 -for.gui.pipe.filter.closed=已关闭 -for.gui.pipe.filter.drone=雄蜂 -for.gui.pipe.filter.flyer=强壮飞蜂 -for.gui.pipe.filter.item=物品 -for.gui.pipe.filter.nocturnal=夜行蜜蜂 -for.gui.pipe.filter.princess=公主蜂 -for.gui.pipe.filter.pure_breed=纯种蜜蜂 -for.gui.pipe.filter.pure_cave=纯种穴居蜂 -for.gui.pipe.filter.pure_flyer=纯种飞蜂 -for.gui.pipe.filter.pure_nocturnal=纯种夜行蜜蜂 -for.gui.pipe.filter.queen=蜂后 diff --git a/resources/assets/buildcraftcompat/lang/zh_cn.json b/resources/assets/buildcraftcompat/lang/zh_cn.json new file mode 100644 index 0000000..9482639 --- /dev/null +++ b/resources/assets/buildcraftcompat/lang/zh_cn.json @@ -0,0 +1,59 @@ +{ + //################### + // APIARIST'S PIPE + //################### + + "item.buildcraftPipe.pipeitemspropolis.name": "养蜂员管道", + + "for.gui.pipe.filter.anything": "任意物品", + "for.gui.pipe.filter.bee": "任意蜜蜂", + "for.gui.pipe.filter.cave": "穴居蜂", + "for.gui.pipe.filter.closed": "已关闭", + "for.gui.pipe.filter.drone": "雄蜂", + "for.gui.pipe.filter.flyer": "强壮飞蜂", + "for.gui.pipe.filter.item": "物品", + "for.gui.pipe.filter.nocturnal": "夜行蜜蜂", + "for.gui.pipe.filter.princess": "公主蜂", + "for.gui.pipe.filter.pure_breed": "纯种蜜蜂", + "for.gui.pipe.filter.pure_cave": "纯种穴居蜂", + "for.gui.pipe.filter.pure_flyer": "纯种飞蜂", + "for.gui.pipe.filter.pure_nocturnal": "纯种夜行蜜蜂", + "for.gui.pipe.filter.queen": "蜂后", + + // Calen 1.18.2 + // JEI + "buildcraft.jei.title.heatable_fluids": "加热流体", + "buildcraft.jei.title.coolable_fluids": "冷却流体", + "buildcraft.jei.title.distillable_fluids": "蒸馏", + "buildcraft.jei.title.combustion_engine_fuels": "燃油引擎燃料", + "buildcraft.jei.title.combustion_engine_fuels.burn_time": "燃烧时间 %ds", + "buildcraft.jei.title.combustion_engine_fuels.burn_speed": " 产能速率 %s MJ/t", + "buildcraft.jei.title.combustion_engine_fuels.burn_total": " 产能总计 %s MJ", + + // REI + "buildcraft.rei.title.heatable_fluids": "加热流体", + "buildcraft.rei.title.coolable_fluids": "冷却流体", + "buildcraft.rei.title.distillable_fluids": "蒸馏", + "buildcraft.rei.title.combustion_engine_fuels": "燃油引擎燃料", + "buildcraft.rei.title.combustion_engine_fuels.burn_time": "燃烧时间 %ds", + "buildcraft.rei.title.combustion_engine_fuels.burn_speed": " 产能速率 %s MJ/t", + "buildcraft.rei.title.combustion_engine_fuels.burn_total": " 产能总计 %s MJ", + + // Waila + "buildcraft.waila.crafting": "§f正在合成: ", + "buildcraft.waila.no_recipe": "§7当前没有配方正在合成", + "buildcraft.waila.crafting_from": "§f使用: ", + "buildcraft.waila.waiting_for_laser": "§f还需要能量: §b%s MJ", + "config.jade.plugin_buildcraftsilicon.laser_target_client_data": "镭射器目标", + "config.jade.plugin_buildcraftsilicon.laser_target_server_data": "镭射器目标", + "config.jade.plugin_buildcraftfactory.autocraft_client_data": "自动合成台", + "config.jade.plugin_buildcraftfactory.autocraft_server_data": "自动合成台", + "config.jade.plugin_buildcraftsilicon.assembly_client_data": "装配台", + "config.jade.plugin_buildcraftsilicon.assembly_server_data": "装配台", + "config.jade.plugin_buildcraftcore.mj_storage_client_data": "MJ存储", + "config.jade.plugin_buildcraftcore.mj_storage_server_data": "MJ存储", + "config.jade.plugin_buildcraftrobotics.robot_power_client_data": "机器人能量", + "config.jade.plugin_buildcraftrobotics.robot_power_server_data": "机器人能量", + + "null": "=w=" +} diff --git a/resources/mcmod.info b/resources/mcmod.info deleted file mode 100644 index 4b57663..0000000 --- a/resources/mcmod.info +++ /dev/null @@ -1,16 +0,0 @@ -[{ - "modid": "buildcraftcompat", - "name": "BuildCraft Compat", - "version": "$version", - "mcversion": "$mcversion", - "description": "Compatibility add-on for BuildCraft", - "credits": "Created by asie", - "url": "http://www.mod-buildcraft.com/", - "updateUrl": "", - "authorList": [ "BuildCraft Team" ], - "parent":"buildcraftcore", - "screenshots": [], - "dependencies": [ - "mod_MinecraftForge" - ] -}] diff --git a/settings.gradle b/settings.gradle index 9279d42..d05889e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,15 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' +} include 'BuildCraft' include 'BuildCraft:sub_projects:expression'