diff --git a/.github/README.md b/.github/README.md index adf0fcc30..21d285ab9 100644 --- a/.github/README.md +++ b/.github/README.md @@ -6,7 +6,7 @@ Logo
- + Join our Discord diff --git a/.github/SECURITY.md b/.github/SECURITY.md deleted file mode 100644 index 026884c3b..000000000 --- a/.github/SECURITY.md +++ /dev/null @@ -1,42 +0,0 @@ -# Security Policy - -## Scope - -Keeping users safe and secure is a top priority for us.We welcome the contribution of external security researchers. - -If you believe you’ve found a security or vulnerability issue in the repo we encourage you to notify us. - -There are no hard and fast rules to determine if a bug is worth reporting as a security issue or a “regular” issue. -When in doubt, please do send us a report. - -## How to submit a report - -Security issues can be reported by sending an [email to us][contact]. - -The team will acknowledge your email within 48 hours. You will receive a more detailed response within 96 hours. - -We will create a maintainer security advisory on GitHub to discuss internally, and when needed, invite you to the -advisory. - -## Purpose - -- Make a good faith effort to avoid privacy violations, destruction of data, and interruption or degradation of our - services -- Only interact with accounts you own or with explicit permission of the account holder. If you do encounter Personally - Identifiable Information (PII) contact us immediately, - do not proceed with access, and immediately purge any local information -- Provide us with a reasonable amount of time to resolve vulnerabilities prior to any disclosure to the public or a - third-party -- We will consider activities conducted consistent with this policy to constitute “authorized” conduct and will not - pursue civil action or initiate a complaint to law enforcement. - We will help to the extent we can if legal action is initiated by a third party against you - -Please submit a report to us before engaging in conduct that may be inconsistent with or unaddressed by this policy. - -## Preferences - -- Please provide detailed reports with reproducible steps and a clearly defined impact -- Submit one vulnerability per report -- Social engineering (such as phishing, vishing, smishing) is prohibited - -[contact]: mailto:admin@terrafirmagreg.su \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9afe7ac74..2f0ea7027 100644 --- a/.gitignore +++ b/.gitignore @@ -40,5 +40,5 @@ run runs libs - +moveToInstance.gradle *.jar \ No newline at end of file diff --git a/build.gradle b/build.gradle index 27a4b10ea..0a360545e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,138 +1,127 @@ buildscript { repositories { - // These repositories are only for Gradle plugins, put any other repositories in the repository block further below + // These repositories are only for Gradle plugins maven { url = 'https://repo.spongepowered.org/repository/maven-public/' } mavenCentral() - } - dependencies { - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' + maven { + name = "NeoForged" + url = 'https://maven.neoforged.net/releases' + content { + includeGroup "net.neoforged" + } + } } } plugins { + id 'java' + id 'java-library' id 'idea' - id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' - id 'org.parchmentmc.librarian.forgegradle' version '1.+' - id 'com.diffplug.spotless' version '7.2.1' + id 'net.neoforged.moddev.legacyforge' version "${mdg_legacy_version}" + id 'com.diffplug.spotless' version "${spotless_version}" + id "com.github.ManifestClasspath" version "0.1.0-RELEASE" } -apply from: 'gradle/scripts/helpers.gradle' -apply plugin: 'org.spongepowered.mixin' - - -// Early Assertions -assertProperty 'mod_version' -assertProperty 'mod_package' -assertProperty 'mod_id' -assertProperty 'mod_name' -assertProperty 'mod_name_suffix' +apply from: 'gradle/scripts/repositories.gradle' +apply from: 'gradle/scripts/dependencies.gradle' +apply from: 'gradle/scripts/spotless.gradle' +if (file("moveToInstance.gradle").exists()) apply from: "moveToInstance.gradle" base { - version = propertyString('mod_version') - group = propertyString('mod_package') - archivesName = propertyString('mod_name', 'mod_name_suffix') + version = "${mod_version}" + group = "${mod_package}" + archivesName = "${mod_name}-${mod_name_suffix}" } +idea { + module { + downloadSources = true + downloadJavadoc = true + } +} java { toolchain { - languageVersion.set(JavaLanguageVersion.of(java_version)) + languageVersion = JavaLanguageVersion.of(17) } + } -minecraft { - mappings channel: mapping_channel, version: mapping_version +mixin { + var refMap = add sourceSets.main, "${mod_id}.refmap.json" + jar.from refMap; + config "${mod_id}.mixins.json" +} - enableIdeaPrepareRuns = true - copyIdeResources = true +sourceSets { + main.resources { + srcDir 'src/main/resources' + srcDir 'src/generated/resources' + } - // 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 + dev { + java.srcDir("src/dev/java") + resources.srcDir("src/dev/resources") + compileClasspath += sourceSets.main.compileClasspath + } +} - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') +legacyForge { + version = "${minecraft_version}-${forge_version}" runs { configureEach { - workingDirectory project.file('run') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'INFO' - - mods { - "${mod_id}" { - source sourceSets.main - } - } + gameDirectory = project.file('run') + systemProperty 'forge.logging.markers', 'REGISTRIES' + systemProperty 'forge.logging.console.level', 'INFO' } client { - workingDirectory project.file('run/client') - - property 'mixin.env.remapRefMap', 'true' - property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" - - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - property 'forge.enabledGameTestNamespaces', mod_id + client() + gameDirectory = project.file('run/client') } 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 { - workingDirectory project.file('run/game-test') - - property 'forge.enabledGameTestNamespaces', mod_id + server() + gameDirectory = project.file('run/server') + programArgument '--nogui' } data { - workingDirectory project.file('run/data') + data() + gameDirectory = project.file('run/data') // 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('src/generated/resources/'), '--existing', file('src/main/resources/') + programArguments.addAll('--mod', "${mod_id}", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()) } - } -} -mixin { - add sourceSets.main, "${mod_id}.refmap.json" - - config "${mod_id}.mixins.json" + } - // THIS PRODUCES A TON OF LOG SPAM THAT DOESN'T NEED TO BE SEEN BY PLAYERS - // ONLY ENABLE THIS WHEN WORKING WITH MIXINS! DISABLE IN ALL OTHER CASES - debug.verbose = false + mods { + "${mod_id}" { + sourceSet(sourceSets.main) + } + } } -apply from: 'gradle/scripts/repositories.gradle' -apply from: 'gradle/scripts/dependencies.gradle' - processResources { var replaceProperties = [ - 'mod_id': propertyString('mod_id'), - 'mod_name': propertyString('mod_name'), - 'mod_version': propertyString('mod_version'), - 'mod_description': propertyString('mod_description'), - 'mod_authors': propertyString('mod_authors'), - 'mod_credits': propertyString('mod_credits'), - 'mod_url': propertyString('mod_url'), - 'mod_update_json': propertyString('mod_update_json'), - 'mod_logo_path': propertyString('mod_logo_path'), - - 'minecraft_version': propertyString('minecraft_version'), - 'minecraft_version_range': propertyString('minecraft_version_range'), - - 'forge_version': propertyString('forge_version'), - 'forge_version_range': propertyString('forge_version_range'), - 'loader_version_range': propertyString('loader_version_range') + 'mod_id' : "${mod_id}", + 'mod_name' : "${mod_name}", + 'mod_version' : "${mod_version}", + 'mod_description' : "${mod_description}", + 'mod_authors' : "${mod_authors}", + 'mod_credits' : "${mod_credits}", + 'mod_url' : "${mod_url}", + 'mod_update_json' : "${mod_update_json}", + 'mod_logo_path' : "${mod_logo_path}", + + 'minecraft_version' : "${minecraft_version}", + 'minecraft_version_range': "${minecraft_version_range}", + + 'forge_version' : "${forge_version}", + 'forge_version_range' : "${forge_version_range}", + 'loader_version_range' : "${loader_version_range}" ] var filterList = [ 'META-INF/mods.toml', @@ -140,63 +129,12 @@ processResources { ] inputs.properties replaceProperties + duplicatesStrategy = DuplicatesStrategy.INCLUDE filesMatching(filterList) { fcd -> fcd.expand(replaceProperties + [project: project]) } } - - -// Example for how to get properties into the manifest for reading at runtime. -tasks.named('jar', Jar).configure { - manifest { - attributes([ - "Specification-Title": propertyString('mod_id'), - "Specification-Vendor": propertyString('mod_authors'), - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": propertyString('mod_name'), - "Implementation-Version": propertyString('mod_version'), - "Implementation-Vendor": propertyString('mod_authors'), - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } - - // This is the preferred method to reobfuscate your jar file - finalizedBy 'reobfJar' -} - -apply from: 'gradle/scripts/spotless.gradle' - -// Rename the final file: delete regular *.jar (if produced) and strip the -all suffix from the shaded jar -tasks.register('renameAllJar') { - doLast { - def libsDir = file("${buildDir}/libs") - if (!libsDir.exists()) return - // Delete a possible regular jar first - libsDir.listFiles()?.findAll { it.name == "${archivesBaseName}-${version}.jar" }?.each { File reg -> - reg.delete() - } - // Rename *-all.jar to *.jar - libsDir.listFiles()?.findAll { it.name.endsWith('-all.jar') }?.each { File f -> - def targetName = f.name.replace('-all.jar', '.jar') - def target = new File(f.parentFile, targetName) - if (target.exists()) target.delete() - if (!f.renameTo(target)) { - throw new GradleException("Failed to rename ${f.name} to ${target.name}") - } - } - } -} - -// Run rename step after available packaging task (bind safely after tasks are created) -gradle.projectsEvaluated { - tasks.findByName('reobfJarJar')?.finalizedBy('renameAllJar') - tasks.findByName('reobfJar')?.finalizedBy('renameAllJar') - // Fallbacks if reobf tasks are not present in this environment - tasks.findByName('jarJar')?.finalizedBy('renameAllJar') - tasks.findByName('jar')?.finalizedBy('renameAllJar') -} - sourceSets { dev { java.srcDir("src/dev/java") @@ -205,6 +143,19 @@ sourceSets { } } +tasks.withType(Jar).configureEach { + manifest.attributes([ + "Specification-Title" : "${mod_id}", + "Specification-Vendor" : "${mod_authors}", + "Specification-Version" : "1", + "Implementation-Title" : "${mod_name}", + "Implementation-Version" : "${mod_version}", + "Implementation-Vendor" : "${mod_authors}", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs" : "${mod_id}.mixins.json" + ]) +} + // Fix a bug in Species that only shows up when running from dev env // Compile our patched Species.class, and use it instead of the normal one in the species-3.5.jar. // Put the result in run/server/mods @@ -241,7 +192,6 @@ tasks.register("prepareServerDev") { dependsOn patchSpeciesJar def serverDir = file("run/server") - def eulaFile = file("${serverDir}/eula.txt") def propsFile = file("${serverDir}/server.properties") outputs.file(eulaFile) @@ -250,12 +200,6 @@ tasks.register("prepareServerDev") { doLast { serverDir.mkdirs() - copy { - from "src/dev/resources" - include "eula.txt" - into serverDir - } - // Create or patch server.properties to set online-mode=false if (propsFile.exists()) { def content = propsFile.text @@ -271,42 +215,31 @@ tasks.register("prepareServerDev") { } } -// Prepare client: fix missing Jade lang files -tasks.register("prepareClientDev") { - def langDir = file("run/client/kubejs/assets/jade/lang") - def langFile = file("${langDir}/en_us.json") - - outputs.file(langFile) - - doLast { - langDir.mkdirs() - - copy { - from "src/dev/resources/assets/jade/lang" - include "en_us.json" - into langDir - } - } -} - // Runs Species patch before runServer. allprojects { tasks.matching { it.name == "prepareRunServer" }.configureEach { dependsOn("prepareServerDev") } - tasks.matching { it.name == "prepareRunClient" }.configureEach { - dependsOn("prepareClientDev") - } - } - // Moving the core jar to a custom folder -tasks.register('copyJarToCustomFolder', Copy) { - from("$buildDir/libs") - include("*${version}.jar") - into("D:/Modding/TerrafirmaGreg/Prism launcher/instances/TerrafirmaGreg-Modern/minecraft/mods/") +tasks.register('copyJarToInstance', Copy) { + + group = 'mod development/internal' + + from("${buildDir}/libs") { + include("*${version}.jar") + exclude("*-sources.jar", "*-javadoc.jar") + } + into("${modpack_mods}") } -// Uncomment to enable -//tasks.build.finalizedBy('copyJarToCustomFolder') +if (project.findProperty('enable_copy_jar_to_instance')?.toBoolean()) { + tasks.build.finalizedBy('copyJarToInstance') +} + +configurations.all { + resolutionStrategy { + cacheChangingModulesFor 0, 'seconds' + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index b32efc269..adf60a357 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,68 +1,74 @@ # Gradle Properties -org.gradle.jvmargs=-Xmx8G -Dnet.minecraftforge.gradle.test_certs=false -org.gradle.parallel=true -org.gradle.logging.stacktrace=all -gradle_version=8.12.1 -java_version=17 +org.gradle.jvmargs = -Xmx8G -Dnet.minecraftforge.gradle.test_certs=false +org.gradle.parallel = true +org.gradle.logging.stacktrace = all # Mod Information # HIGHLY RECOMMEND complying with SemVer for mod_version: https://semver.org/ -mod_version = 0.8.21 -mod_package = su.terrafirmagreg -mod_id = tfg -mod_name = TerraFirmaGreg-Core -mod_name_suffix = Modern +mod_version = 0.8.22 +mod_package = su.terrafirmagreg +mod_id = tfg +mod_name = TerraFirmaGreg-Core +mod_name_suffix = Modern # Mod Metadata (Optional) -mod_description = Compat mod for TFC, GTCEu, and the other parts of TerraFirmaGreg. -mod_url = https://www.curseforge.com/minecraft/mc-mods/terrafirmagreg-core -mod_update_json = https://www.curseforge.com/minecraft/mc-mods/terrafirmagreg-core +mod_description = Compat mod for TFC, GTCEu, and the other parts of TerraFirmaGreg. +mod_url = https://www.curseforge.com/minecraft/mc-mods/terrafirmagreg-core +mod_update_json = https://www.curseforge.com/minecraft/mc-mods/terrafirmagreg-core # Delimit authors with commas -mod_authors = Exception, Xikaro, Zleub, Pyritie, aidie8, jojo7682345, Redeix, Thomasx0, Gustavo, AirRice, Zeropol, voidstar240, Mqrius, et. al. -mod_credits = Bioxx, Dunkleosteus, Kittychanley for the original TerraFirmaCraft for 1.7.10 and before. -mod_logo_path = /assets/tfg/textures/gui/logo.png +mod_authors = Exception, Xikaro, Zleub, Pyritie, aidie8, jojo7682345, Redeix, Thomasx0, Gustavo, AirRice, Zeropol, voidstar240, Mqrius, et. al. +mod_credits = Bioxx, Dunkleosteus, Kittychanley for the original TerraFirmaCraft for 1.7.10 and before. +mod_logo_path = /assets/tfg/textures/gui/logo.png # Mapping Properties -mapping_channel = parchment -mapping_version = 2023.09.03-1.20.1 -use_dependency_at_files = true +mapping_channel = parchment +mapping_version = 2023.09.03-1.20.1 +use_dependency_at_files = true # Run Configurations # If multiple arguments/tweak classes are stated, use spaces as the delimiter -minecraft_version = 1.20.1 -minecraft_version_range=[1.20.1,1.21) -minecraft_username = Developer +minecraft_version = 1.20.1 +minecraft_version_range = [1.20.1,1.21) +minecraft_username = Developer -forge_version=47.4.13 -forge_version_range=[47,) +enable_copy_jar_to_instance = false +modpack_mods = D:/path/to/instances/TerrafirmaGreg-Modern/minecraft/mods/ -loader_version_range=[47,) +### Dependency versions -# Mod versions -# Some mods need to have the dependency package updated manually, instead of just changing the version number +# Build environment +java_version = 17 +gradle_version = 8.12.1 +mdg_legacy_version = 2.0.119 +spotless_version = 7.2.1 + +# Forge +forge_version = 47.4.13 +forge_version_range = [47,) +loader_version_range = [47,) # Dependencies -ldlib_version = 1.0.40.b -jei_version = 15.3.0.7 -emi_version = 1.1.22+1.20.1 +ldlib_version = 1.0.40.b +jei_version = 15.20.0.129 +emi_version = 1.1.22+1.20.1 # GTCEu & create -create_version = 6.0.8-289 -flywheel_version = 1.0.4 -ponder_version = 1.0.80 -greate_version = 0.0.64 -gtm_version = 7.4.1 +create_version = 6.0.8-289 +flywheel_version = 1.0.4 +ponder_version = 1.0.80 +greate_version = 0.0.68 +gtm_version = 7.5.2 # TFC & related -tfc_version = 3.2.19 -firmalife_version = 2.1.26 -firmaciv_version = 1.0.9 -alekiships_version = 1.0.14 -beneath_version = 1.0.6 +tfc_version = 3.2.19 +firmalife_version = 2.1.27 +firmaciv_version = 1.0.9 +alekiships_version = 1.0.14 +beneath_version = 1.0.6 # Other -cc_tweaked_version = 1.111.0 -ad_astra_version = 1.15.20 -puzzleslib_version = v8.1.32-1.20.1-Forge -hangglider_version = v8.0.1-1.20.1-Forge -ae2_version=15.4.10-cosmolite.34 +cc_tweaked_version = 1.111.0 +ad_astra_version = 1.15.20 +puzzleslib_version = v8.1.32-1.20.1-Forge +hangglider_version = v8.0.1-1.20.1-Forge +ae2_version = 15.4.10-cosmolite.34 diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index 674cfe47d..43135e22f 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -1,156 +1,153 @@ dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - compileOnly 'org.jetbrains:annotations:26.0.+' annotationProcessor 'org.jetbrains:annotations:26.0.+' compileOnly 'org.projectlombok:lombok:1.18.+' annotationProcessor 'org.projectlombok:lombok:1.18.+' - annotationProcessor 'org.spongepowered:mixin:0.8.7:processor' compileOnly annotationProcessor("io.github.llamalad7:mixinextras-common:0.5.0") - implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.5.0")) { - jarJar.ranged(it, "[0.5.0,)") - } - compileOnly(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-common:0.3.6-beta.1")) - implementation(jarJar("com.github.bawnorton.mixinsquared:mixinsquared-forge:0.3.6-beta.1")) { - jarJar.ranged(it, "[0.3.6-beta.1,)") - } + implementation jarJar("io.github.llamalad7:mixinextras-forge:0.5.0") - compileOnly fg.deobf("com.tterrag.registrate:Registrate:MC1.20-1.3.11") + compileOnly annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-common:0.3.6-beta.1") + implementation jarJar("com.github.bawnorton.mixinsquared:mixinsquared-forge:0.3.6-beta.1") - implementation fg.deobf("maven.modrinth:embeddium:0.3.31+mc1.20.1") - implementation fg.deobf("maven.modrinth:ferrite-core:DG5Fn9Sz") - implementation fg.deobf("maven.modrinth:architectury-api:9.2.14+forge") + modCompileOnly "com.tterrag.registrate:Registrate:MC1.20-1.3.11" - //implementation fg.deobf("curse.maven:configuration-444699:4710266") + modImplementation "maven.modrinth:embeddium:0.3.31+mc1.20.1" + modImplementation "maven.modrinth:ferrite-core:DG5Fn9Sz" + modImplementation "maven.modrinth:architectury-api:9.2.14+forge" + + //modImplementation "curse.maven:configuration-444699:4710266" // JEI - compileOnly fg.deobf("mezz.jei:jei-1.20.1-common-api:${jei_version}") - compileOnly fg.deobf("mezz.jei:jei-1.20.1-forge-api:${jei_version}") - compileOnly fg.deobf("mezz.jei:jei-1.20.1-forge:${jei_version}") + modCompileOnly "mezz.jei:jei-1.20.1-common-api:${jei_version}" + modCompileOnly "mezz.jei:jei-1.20.1-forge-api:${jei_version}" + modCompileOnly "mezz.jei:jei-1.20.1-forge:${jei_version}" // EMI - //compileOnly fg.deobf("dev.emi:emi-forge:${emi_version}:api") - implementation fg.deobf("dev.emi:emi-forge:${emi_version}") + //modCompileOnly "dev.emi:emi-forge:${emi_version}:api" + modImplementation "dev.emi:emi-forge:${emi_version}" // Create - compileOnly(fg.deobf("dev.engine-room.flywheel:flywheel-forge-api-${minecraft_version}:${flywheel_version}")) - runtimeOnly(fg.deobf("dev.engine-room.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}")) - implementation fg.deobf("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } - implementation(fg.deobf("net.createmod.ponder:Ponder-Forge-${minecraft_version}:${ponder_version}")) + modCompileOnly "dev.engine-room.flywheel:flywheel-forge-api-${minecraft_version}:${flywheel_version}" + modRuntimeOnly "dev.engine-room.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}" + modImplementation ("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } + modImplementation "net.createmod.ponder:Ponder-Forge-${minecraft_version}:${ponder_version}" // Create: Vintage Improvements - implementation fg.deobf("curse.maven:vintage-improvements-ssw-edition-1255448:7436235") { transitive = false } + modImplementation ("curse.maven:vintage-improvements-ssw-edition-1255448:7436235") { transitive = false } // Greate - implementation fg.deobf("maven.modrinth:greate:${greate_version}") { transitive = false } + modImplementation ("maven.modrinth:greate:${greate_version}") { transitive = false } // GTM - implementation fg.deobf("com.gregtechceu.gtceu:gtceu-${minecraft_version}:${gtm_version}") { transitive = false } - implementation fg.deobf("com.lowdragmc.ldlib:ldlib-forge-${minecraft_version}:${ldlib_version}") { transitive = false } + modImplementation ("com.gregtechceu.gtceu:gtceu-${minecraft_version}:${gtm_version}") { transitive = false } + modImplementation ("com.lowdragmc.ldlib:ldlib-forge-${minecraft_version}:${ldlib_version}") { transitive = false } // KJS - implementation fg.deobf("maven.modrinth:rhino:2001.2.2-build.18+forge") - implementation fg.deobf("maven.modrinth:kubejs:2001.6.5-build.7+forge") + modImplementation "maven.modrinth:rhino:2001.2.2-build.18+forge" + modImplementation "maven.modrinth:kubejs:2001.6.5-build.7+forge" // TFC - implementation fg.deobf("maven.modrinth:patchouli:1.20.1-84.1-forge") { transitive = false } - implementation fg.deobf("maven.modrinth:terrafirmacraft:${tfc_version}") { transitive = false } - implementation fg.deobf("curse.maven:kubejs-tfc-841001:6996502") { transitive = false } + modImplementation ("maven.modrinth:patchouli:1.20.1-84.1-forge") { transitive = false } + modImplementation ("maven.modrinth:terrafirmacraft:${tfc_version}") { transitive = false } + modImplementation ("curse.maven:kubejs-tfc-841001:6996502") { transitive = false } // FirmaLife - implementation fg.deobf("maven.modrinth:firmalife:${firmalife_version}") + modImplementation "maven.modrinth:firmalife:${firmalife_version}" // Beneath - implementation fg.deobf("maven.modrinth:beneath:${beneath_version}") { transitive = false } + modImplementation ("maven.modrinth:beneath:${beneath_version}") { transitive = false } // TFC-Ambiental - implementation fg.deobf("maven.modrinth:curios:5.12.1+1.20.1") - implementation fg.deobf("maven.modrinth:tfc-ambiental-second-edition:1.20.1-3.3.0") + modImplementation "maven.modrinth:curios:5.12.1+1.20.1" + modImplementation "maven.modrinth:tfc-ambiental-second-edition:1.20.1-3.3.0" // FirmaCiv - implementation fg.deobf("maven.modrinth:alekiships:${alekiships_version}") { transitive = false } - implementation fg.deobf("maven.modrinth:firmaciv:${firmaciv_version}") { transitive = false } + modImplementation ("maven.modrinth:alekiships:${alekiships_version}") { transitive = false } + modImplementation ("maven.modrinth:firmaciv:${firmaciv_version}") { transitive = false } // TFC AstikorCarts - implementation fg.deobf("curse.maven:astikor-carts-redux-916493:4988266") { transitive = false } - implementation fg.deobf("curse.maven:astikor-carts-tfc-844019:5141430") { transitive = false } + modImplementation ("curse.maven:astikor-carts-redux-916493:4988266") { transitive = false } + modImplementation ("curse.maven:astikor-carts-tfc-844019:5141430") { transitive = false } // TFC hot or not - implementation fg.deobf("curse.maven:tfc-hot-or-not-499096:6047294") { transitive = false } + modImplementation ("curse.maven:tfc-hot-or-not-499096:6047294") { transitive = false } // AE2 - implementation fg.deobf("curse.maven:guideme-1173950:7013686") - implementation fg.deobf(jarJar("appeng:appliedenergistics2-forge:$ae2_version")) { - jarJar.ranged(it, "[$ae2_version,)") - } - implementation fg.deobf("curse.maven:applied-energistics-2-wireless-terminals-459929:7014805") + modImplementation "curse.maven:guideme-1173950:7013686" + modImplementation jarJar("appeng:appliedenergistics2-forge:$ae2_version") + modImplementation "curse.maven:applied-energistics-2-wireless-terminals-459929:7014805" // ComputerCraft - compileOnly fg.deobf("cc.tweaked:cc-tweaked-1.20.1-core-api:${cc_tweaked_version}") - compileOnly fg.deobf("cc.tweaked:cc-tweaked-1.20.1-forge-api:${cc_tweaked_version}") - implementation fg.deobf("cc.tweaked:cc-tweaked-1.20.1-forge:${cc_tweaked_version}") + modCompileOnly "cc.tweaked:cc-tweaked-1.20.1-core-api:${cc_tweaked_version}" + modCompileOnly "cc.tweaked:cc-tweaked-1.20.1-forge-api:${cc_tweaked_version}" + modImplementation "cc.tweaked:cc-tweaked-1.20.1-forge:${cc_tweaked_version}" // FTB - implementation fg.deobf("curse.maven:ftb-teams-forge-404468:6130786") { transitive = false } - implementation fg.deobf("curse.maven:ftb-library-forge-404465:6164053") { transitive = false } - implementation fg.deobf("curse.maven:ftb-quests-forge-289412:6431737") { transitive = false } - implementation fg.deobf("curse.maven:ftb-chunks-forge-314906:6431735") { transitive = false } + modImplementation ("curse.maven:ftb-teams-forge-404468:6130786") { transitive = false } + modImplementation ("curse.maven:ftb-library-forge-404465:6164053") { transitive = false } + modImplementation ("curse.maven:ftb-quests-forge-289412:6431737") { transitive = false } + modImplementation ("curse.maven:ftb-chunks-forge-314906:6431735") { transitive = false } // Jade - implementation fg.deobf("curse.maven:jade-324717:6271651") + modImplementation "curse.maven:jade-324717:6271651" // TFC Roads and Roofs - implementation fg.deobf("curse.maven:roads-and-roofs-tfc-1048212:5852507") + modImplementation "curse.maven:roads-and-roofs-tfc-1048212:5852507" // Ad Astra - implementation fg.deobf("curse.maven:ad-astra-635042:6262032") { transitive = false } - implementation fg.deobf("curse.maven:botarium-704113:5486070") { transitive = false } - implementation fg.deobf("curse.maven:resourceful-lib-570073:5659871") { transitive = false } - implementation fg.deobf("curse.maven:resourceful-config-714059:6231176") { transitive = false } + modImplementation ("curse.maven:ad-astra-635042:6262032") { transitive = false } + modImplementation ("curse.maven:botarium-704113:5486070") { transitive = false } + modImplementation ("curse.maven:resourceful-lib-570073:5659871") { transitive = false } + modImplementation ("curse.maven:resourceful-config-714059:6231176") { transitive = false } // Species - implementation fg.deobf("maven.modrinth:species:3.5") { transitive = false } + modImplementation ("maven.modrinth:species:3.5") { transitive = false } // Simply Stacked Dimensions - implementation fg.deobf("curse.maven:simply-stacked-dimensions-523416:5562948") { transitive = false } + modImplementation ("curse.maven:simply-stacked-dimensions-523416:5562948") { transitive = false } // Grappling Hook -- needless dependencies are dumb - implementation fg.deobf("curse.maven:cloth-config-348521:5729105") - implementation fg.deobf("curse.maven:grappling-hook-mod-reforged-1166811:6028357") { transitive = false } + modImplementation "curse.maven:cloth-config-348521:5729105" + modImplementation ("curse.maven:grappling-hook-mod-reforged-1166811:6028357") { transitive = false } // Hang Glider - implementation fg.deobf("maven.modrinth:puzzles-lib:${puzzleslib_version}") - implementation fg.deobf("maven.modrinth:hang-glider:${hangglider_version}") + modImplementation "maven.modrinth:puzzles-lib:${puzzleslib_version}" + modImplementation "maven.modrinth:hang-glider:${hangglider_version}" // Wan's ancient beasts - implementation fg.deobf("curse.maven:wans-ancient-beasts-1108604:7552366") - implementation fg.deobf("curse.maven:geckolib-388172:7553267") + modImplementation "curse.maven:wans-ancient-beasts-1108604:7552366" + modImplementation "curse.maven:geckolib-388172:7553267" // Immersive Aircraft - implementation fg.deobf("curse.maven:immersive-aircraft-666014:6742170") + modImplementation "curse.maven:immersive-aircraft-666014:6742170" //Create Liquid Fuel - implementation fg.deobf("curse.maven:create-liquid-fuel-840734:5217310") + modImplementation "curse.maven:create-liquid-fuel-840734:5217310" //Dea's Fission Vazde - implementation fg.deobf("curse.maven:deafission-1354541:7258440") + modImplementation "curse.maven:deafission-1354541:7633771" //Create Picky Waterwheels - implementation fg.deobf("curse.maven:create-picky-waterwheels-866839:6932328") + modImplementation "curse.maven:create-picky-waterwheels-866839:6932328" //Panda's Falling Trees - implementation fg.deobf("curse.maven:pandas-falling-trees-880630:5653236") - implementation fg.deobf("curse.maven:pandalib-975460:5653131") + modImplementation "curse.maven:pandas-falling-trees-880630:5653236" + modImplementation "curse.maven:pandalib-975460:5653131" // ArborFirmaCraft - implementation fg.deobf("curse.maven:arborfirmacraft-877545:7200580") + modImplementation "curse.maven:arborfirmacraft-877545:7200580" // TFC Improved Badlands - implementation fg.deobf("curse.maven:tfc-improved-badlands-969207:5126426") + modImplementation "curse.maven:tfc-improved-badlands-969207:5126426" + + // TFC Water Flasks + modImplementation "curse.maven:water-flasks-354353:7056478" + // Sacks and such + modImplementation "curse.maven:sacks-n-such-695822:6965231" } diff --git a/gradle/scripts/helpers.gradle b/gradle/scripts/helpers.gradle deleted file mode 100644 index a3d8f39db..000000000 --- a/gradle/scripts/helpers.gradle +++ /dev/null @@ -1,104 +0,0 @@ -import groovy.text.SimpleTemplateEngine -import org.codehaus.groovy.runtime.MethodClosure - -ext.propertyString = this.&propertyString as MethodClosure -ext.propertyBool = this.&propertyBool as MethodClosure -ext.propertyStringList = this.&propertyStringList as MethodClosure -ext.interpolate = this.&interpolate as MethodClosure -ext.assertProperty = this.&assertProperty as MethodClosure -ext.assertSubProperties = this.&assertSubProperties as MethodClosure -ext.setDefaultProperty = this.&setDefaultProperty as MethodClosure -ext.assertEnvironmentVariable = this.&assertEnvironmentVariable as MethodClosure - -String propertyString(String key) { - return $property(key).toString() -} - -String propertyString(String key, String key2) { - return propertyString(key) + '-' + propertyString(key2) -} - -boolean propertyBool(String key) { - return propertyString(key).toBoolean() -} - -Collection propertyStringList(String key) { - return propertyStringList(key, ' ') -} - -Collection propertyStringList(String key, String delimit) { - return propertyString(key).split(delimit).findAll { !it.isEmpty() } -} - -Collection propertyStringList(String key, String delimit, String join) { - return propertyString(key).split(delimit).findAll { !it.isEmpty() }.join(join) -} - -private Object $property(String key) { - def value = project.findProperty(key) - if (value instanceof String) { - return interpolate(value) - } - return value -} - -String interpolate(String value) { - if (value.startsWith('${{') && value.endsWith('}}')) { - value = value.substring(3, value.length() - 2) - Binding newBinding = new Binding(this.binding.getVariables()) - newBinding.setProperty('it', this) - return new GroovyShell(this.getClass().getClassLoader(), newBinding).evaluate(value) - } - if (value.contains('${')) { - return new SimpleTemplateEngine().createTemplate(value).make(project.properties).toString() - } - return value -} - -void assertProperty(String propertyName) { - def property = property(propertyName) - if (property == null) { - throw new GradleException("Property ${propertyName} is not defined!") - } - if (property.isEmpty()) { - throw new GradleException("Property ${propertyName} is empty!") - } -} - -void assertSubProperties(String propertyName, String... subPropertyNames) { - assertProperty(propertyName) - if (propertyBool(propertyName)) { - for (String subPropertyName : subPropertyNames) { - assertProperty(subPropertyName) - } - } -} - -void setDefaultProperty(String propertyName, boolean warn, defaultValue) { - def property = property(propertyName) - def exists = true - if (property == null) { - exists = false - if (warn) { - project.logger.log(LogLevel.WARN, "Property ${propertyName} is not defined!") - } - } else if (property.isEmpty()) { - exists = false - if (warn) { - project.logger.log(LogLevel.WARN, "Property ${propertyName} is empty!") - } - } - if (!exists) { - project.setProperty(propertyName, defaultValue.toString()) - } -} - -void assertEnvironmentVariable(String propertyName) { - def property = System.getenv(propertyName) - if (property == null) { - throw new GradleException("System Environment Variable $propertyName is not defined!") - } - if (property.isEmpty()) { - throw new GradleException("Property $propertyName is empty!") - } -} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ca025c83a..aaaabb3cb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index e5ad52d89..ec22a54f5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -32,4 +32,4 @@ plugins { // Due to an IntelliJ bug, this has to be done // rootProject.name = archives_base_name -rootProject.name = rootProject.projectDir.getName() +rootProject.name = "${mod_name}-${mod_name_suffix}" diff --git a/src/dev/resources/assets/jade/lang/en_us.json b/src/dev/resources/assets/jade/lang/en_us.json deleted file mode 100644 index 10a594086..000000000 --- a/src/dev/resources/assets/jade/lang/en_us.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "config.jade.plugin_tfc.charger": "", - "config.jade.plugin_tfc.soarer": "", - "config.jade.plugin_tfc.snatcher": "", - "config.jade.plugin_tfc.surfer": "", - "config.jade.plugin_tfc.axolotl": "" -} diff --git a/src/dev/resources/eula.txt b/src/dev/resources/eula.txt deleted file mode 100644 index 02dccd973..000000000 --- a/src/dev/resources/eula.txt +++ /dev/null @@ -1 +0,0 @@ -eula=true diff --git a/src/main/java/su/terrafirmagreg/core/common/TFGCommonEventHandler.java b/src/main/java/su/terrafirmagreg/core/common/TFGCommonEventHandler.java index 67a3f2683..b25ceb9cb 100644 --- a/src/main/java/su/terrafirmagreg/core/common/TFGCommonEventHandler.java +++ b/src/main/java/su/terrafirmagreg/core/common/TFGCommonEventHandler.java @@ -6,13 +6,16 @@ import com.gregtechceu.gtceu.api.data.chemical.material.event.MaterialRegistryEvent; import com.gregtechceu.gtceu.api.data.chemical.material.event.PostMaterialEvent; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AttachCapabilitiesEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.network.PacketDistributor; import appeng.core.definitions.AEItems; import appeng.core.localization.GuiText; @@ -26,6 +29,8 @@ import su.terrafirmagreg.core.compat.gtceu.materials.TFGMaterialHandler; import su.terrafirmagreg.core.compat.tfcambiental.TFCAmbientalCompat; import su.terrafirmagreg.core.config.TFGConfig; +import su.terrafirmagreg.core.network.TFGNetworkHandler; +import su.terrafirmagreg.core.network.packet.FuelSyncPacket; import su.terrafirmagreg.core.utils.TFGModsResolver; public final class TFGCommonEventHandler { @@ -36,6 +41,7 @@ public static void init() { final IEventBus otherBus = MinecraftForge.EVENT_BUS; otherBus.addGenericListener(ItemStack.class, TFGCommonEventHandler::attachItemCapabilities); + otherBus.addListener(TFGCommonEventHandler::onPlayerLogin); bus.addListener(TFGConfig::onLoad); bus.addListener(TFGCommonEventHandler::onCommonSetup); @@ -79,4 +85,15 @@ private static void onCommonSetup(final FMLCommonSetupEvent event) { private static void addUpgrades(ItemLike item) { add(TFGItems.WIRELESS_CARD.get(), item, 1, GuiText.WirelessTerminals.getTranslationKey()); } + + /** + * Send the blaze burner liquid fuel map to send to the client and populate emi. + */ + private static void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { + if (event.getEntity() instanceof ServerPlayer player) { + TFGNetworkHandler.INSTANCE.send( + PacketDistributor.PLAYER.with(() -> player), + new FuelSyncPacket(FuelSyncPacket.capturedJsonData)); + } + } } diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/TFGTRecipeConditions.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/TFGTRecipeConditions.java index 543fc7fa8..756eae12d 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/TFGTRecipeConditions.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/TFGTRecipeConditions.java @@ -31,7 +31,7 @@ public static void init() { GRAVITY = register("gravity", GravityCondition::new, GravityCondition.CODEC); } - private static RecipeConditionType register( + private static > RecipeConditionType register( String name, RecipeConditionType.ConditionFactory factory, Codec codec) { diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/TFGMachines.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/TFGMachines.java index 5c12734d4..f6cf88cbf 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/TFGMachines.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/TFGMachines.java @@ -284,7 +284,7 @@ private static MachineDefinition createULVTank() { public static MachineDefinition[] registerTieredMachines(GTRegistrate registrate, String name, BiFunction factory, - BiFunction, MachineDefinition> builder, + BiFunction, MachineDefinition> builder, int... tiers) { MachineDefinition[] definitions = new MachineDefinition[tiers.length]; @@ -299,7 +299,7 @@ public static MachineDefinition[] registerTieredMachines(GTRegistrate registrate public static MachineDefinition registerSteamMachine(String name, BiFunction factory, - BiFunction, MachineDefinition> builder) { + BiFunction, MachineDefinition> builder) { return builder.apply(true, REGISTRATE.machine("hp_%s".formatted(name), holder -> factory.apply(holder, true)) .tier(1)); @@ -321,7 +321,7 @@ private static MachineDefinition[] registerSMRFluidImportHatch( name, SMRFluidImportHatchPartMachine::new, - (Integer tier, MachineBuilder builder) -> builder + (Integer tier, MachineBuilder builder) -> builder .langValue(GTValues.VNF[tier] + " " + displayName) .rotationState(RotationState.ALL) .abilities(abilities) diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageRainfallCondition.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageRainfallCondition.java index 2194e683f..01f2c2574 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageRainfallCondition.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageRainfallCondition.java @@ -23,7 +23,7 @@ *

- LT: passes when rainfall < value *

- BETWEEN: passes when start < rainfall < end */ -public class AverageRainfallCondition extends RecipeCondition { +public class AverageRainfallCondition extends RecipeCondition { public enum Mode { GT, @@ -92,7 +92,7 @@ public AverageRainfallCondition(boolean isReverse, Mode mode, float value, boole } @Override - public RecipeConditionType getType() { + public RecipeConditionType getType() { return TFGTRecipeConditions.CLIMATE_AVG_RAINFALL; } @@ -159,7 +159,7 @@ public boolean testCondition(@NotNull GTRecipe recipe, @NotNull RecipeLogic reci } @Override - public RecipeCondition createTemplate() { + public AverageRainfallCondition createTemplate() { return new AverageRainfallCondition(); } diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageTemperatureCondition.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageTemperatureCondition.java index 6ef73b974..7eea9f2df 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageTemperatureCondition.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/AverageTemperatureCondition.java @@ -23,7 +23,7 @@ *

- LT: passes when temperature < value *

- BETWEEN: passes when start < temperature < end */ -public class AverageTemperatureCondition extends RecipeCondition { +public class AverageTemperatureCondition extends RecipeCondition { public enum Mode { GT, @@ -92,7 +92,7 @@ public AverageTemperatureCondition(boolean isReverse, Mode mode, float value, bo } @Override - public RecipeConditionType getType() { + public RecipeConditionType getType() { return TFGTRecipeConditions.CLIMATE_AVG_TEMPERATURE; } @@ -159,7 +159,7 @@ public boolean testCondition(@NotNull GTRecipe recipe, @NotNull RecipeLogic reci } @Override - public RecipeCondition createTemplate() { + public AverageTemperatureCondition createTemplate() { return new AverageTemperatureCondition(); } diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/GravityCondition.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/GravityCondition.java index a6b844515..2331dee4d 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/GravityCondition.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/GravityCondition.java @@ -29,7 +29,7 @@ *

- LT: passes when gravity < value *

- BETWEEN: passes when start < gravity < end */ -public class GravityCondition extends RecipeCondition { +public class GravityCondition extends RecipeCondition { private static final float EARTH_GRAVITY = PlanetConstants.EARTH_GRAVITY; @@ -101,7 +101,7 @@ public GravityCondition(boolean isReverse, Mode mode, float value, boolean value } @Override - public RecipeConditionType getType() { + public RecipeConditionType getType() { return TFGTRecipeConditions.GRAVITY; } @@ -187,7 +187,7 @@ private boolean isPasses(float gravityRatio) { } @Override - public RecipeCondition createTemplate() { + public GravityCondition createTemplate() { return new GravityCondition(); } diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/MonthCondition.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/MonthCondition.java index 96f003b1a..cced4c520 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/MonthCondition.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/MonthCondition.java @@ -29,7 +29,7 @@ *

- Whitelist months *

- Start/end range. Supports wrap around (example: september-march) */ -public class MonthCondition extends RecipeCondition { +public class MonthCondition extends RecipeCondition { private static final Codec MONTH_CODEC = Codec.INT.xmap(Month::valueOf, Month::ordinal); @@ -74,7 +74,7 @@ public MonthCondition(boolean isReverse, List months, @Nullable Month sta } @Override - public RecipeConditionType getType() { + public RecipeConditionType getType() { return TFGTRecipeConditions.MONTHS; } @@ -137,7 +137,7 @@ private boolean matches(Month current) { } @Override - public RecipeCondition createTemplate() { + public MonthCondition createTemplate() { return new MonthCondition(); } diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/OxygenatedCondition.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/OxygenatedCondition.java index fd1e0e619..e1767066d 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/OxygenatedCondition.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/OxygenatedCondition.java @@ -25,7 +25,7 @@ *

- isOxygenated = false: passes when no adjacent block has oxygen. *

*/ -public class OxygenatedCondition extends RecipeCondition { +public class OxygenatedCondition extends RecipeCondition { public static final Codec CODEC = RecordCodecBuilder.create(instance -> RecipeCondition.isReverse(instance) .and(Codec.BOOL.fieldOf("isOxygenated").forGetter(cond -> cond.isOxygenated)) @@ -50,7 +50,7 @@ public OxygenatedCondition(boolean isReverse, boolean requiresOxygen) { } @Override - public RecipeConditionType getType() { + public RecipeConditionType getType() { return TFGTRecipeConditions.OXYGENATED; } @@ -97,7 +97,7 @@ private static boolean hasOxygenOnAnySide(ServerLevel level, BlockPos pos) { } @Override - public RecipeCondition createTemplate() { + public OxygenatedCondition createTemplate() { return new OxygenatedCondition(); } } diff --git a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/SeasonCondition.java b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/SeasonCondition.java index d210d54cb..ac2af73a0 100644 --- a/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/SeasonCondition.java +++ b/src/main/java/su/terrafirmagreg/core/common/data/tfgt/machine/conditions/SeasonCondition.java @@ -30,7 +30,7 @@ *

- Whitelist months. *

- start/end range. Supports wrap around (example: fall-spring). */ -public class SeasonCondition extends RecipeCondition { +public class SeasonCondition extends RecipeCondition { private static final Codec SEASON_CODEC = Codec.INT.xmap(i -> Season.values()[i], Season::ordinal); @@ -75,7 +75,7 @@ public SeasonCondition(boolean isReverse, List seasons, @Nullable Season } @Override - public RecipeConditionType getType() { + public RecipeConditionType getType() { return TFGTRecipeConditions.SEASONS; } @@ -166,7 +166,7 @@ private static String displayName(Season s) { } @Override - public RecipeCondition createTemplate() { + public SeasonCondition createTemplate() { return new SeasonCondition(); } diff --git a/src/main/java/su/terrafirmagreg/core/compat/emi/ExportedOreVeinInfo.java b/src/main/java/su/terrafirmagreg/core/compat/emi/ExportedOreVeinInfo.java index d07718f85..88db68cd2 100644 --- a/src/main/java/su/terrafirmagreg/core/compat/emi/ExportedOreVeinInfo.java +++ b/src/main/java/su/terrafirmagreg/core/compat/emi/ExportedOreVeinInfo.java @@ -114,7 +114,7 @@ public class ExportedOreVeinInfo { new OreVeinInfoRecipe.WeightedBlock("garnierite", 30),new OreVeinInfoRecipe.WeightedBlock("nickel", 10),new OreVeinInfoRecipe.WeightedBlock("cobaltite", 20),new OreVeinInfoRecipe.WeightedBlock("pentlandite", 25),new OreVeinInfoRecipe.WeightedBlock("cobalt", 15),}, new String[] {"ore_vein.tfg.normal_garnierite.emi.0", "ore_vein.tfg.normal_garnierite.emi.1"}), new OreVeinInfoRecipe("normal_gold", "minecraft:overworld", - 170, 0.4, -32, 60, 40, 12, 0, new String[] { + 210, 0.4, -32, 60, 40, 12, 0, new String[] { "tfc:rock/raw/rhyolite","tfc:rock/raw/basalt","tfc:rock/raw/andesite","tfc:rock/raw/dacite","tfc:rock/raw/granite","tfc:rock/raw/diorite","tfc:rock/raw/gabbro",}, new OreVeinInfoRecipe.WeightedBlock[] { new OreVeinInfoRecipe.WeightedBlock("goethite", 5),new OreVeinInfoRecipe.WeightedBlock("yellow_limonite", 20),new OreVeinInfoRecipe.WeightedBlock("hematite", 20),new OreVeinInfoRecipe.WeightedBlock("gold", 55),}, null), @@ -151,7 +151,7 @@ public class ExportedOreVeinInfo { new OreVeinInfoRecipe("normal_magnetite", "minecraft:overworld", 200, 0.3, -32, 75, 30, 0, 0, new String[] { "tfc:rock/raw/shale","tfc:rock/raw/claystone","tfc:rock/raw/limestone","tfc:rock/raw/conglomerate","tfc:rock/raw/dolomite","tfc:rock/raw/chert","tfc:rock/raw/chalk",}, new OreVeinInfoRecipe.WeightedBlock[] { - new OreVeinInfoRecipe.WeightedBlock("magnetite", 63),new OreVeinInfoRecipe.WeightedBlock("vanadium_magnetite", 22),new OreVeinInfoRecipe.WeightedBlock("gold", 9),new OreVeinInfoRecipe.WeightedBlock("chromite", 4),}, + new OreVeinInfoRecipe.WeightedBlock("magnetite", 60),new OreVeinInfoRecipe.WeightedBlock("vanadium_magnetite", 30),new OreVeinInfoRecipe.WeightedBlock("gold", 5),new OreVeinInfoRecipe.WeightedBlock("chromite", 5),}, null), new OreVeinInfoRecipe("normal_manganese", "minecraft:overworld", 195, 0.3, -32, 60, 30, 0, 0, new String[] { @@ -159,7 +159,7 @@ public class ExportedOreVeinInfo { new OreVeinInfoRecipe.WeightedBlock("grossular", 37),new OreVeinInfoRecipe.WeightedBlock("spessartine", 25),new OreVeinInfoRecipe.WeightedBlock("pyrolusite", 25),new OreVeinInfoRecipe.WeightedBlock("tantalite", 12),}, null), new OreVeinInfoRecipe("normal_mica", "minecraft:overworld", - 190, 0.25, 0, 210, 36, 0, 0, new String[] { + 230, 0.25, -32, 140, 36, 0, 0, new String[] { "tfc:rock/raw/granite","tfc:rock/raw/diorite","tfc:rock/raw/gabbro","tfc:rock/raw/quartzite","tfc:rock/raw/slate","tfc:rock/raw/phyllite","tfc:rock/raw/schist","tfc:rock/raw/gneiss","tfc:rock/raw/marble",}, new OreVeinInfoRecipe.WeightedBlock[] { new OreVeinInfoRecipe.WeightedBlock("kyanite", 35),new OreVeinInfoRecipe.WeightedBlock("mica", 25),new OreVeinInfoRecipe.WeightedBlock("bauxite", 25),new OreVeinInfoRecipe.WeightedBlock("pollucite", 15),}, null), @@ -239,9 +239,9 @@ public class ExportedOreVeinInfo { new OreVeinInfoRecipe.WeightedBlock("cassiterite", 55),new OreVeinInfoRecipe.WeightedBlock("tin", 35),new OreVeinInfoRecipe.WeightedBlock("saltpeter", 10),}, null), new OreVeinInfoRecipe("surface_copper", "minecraft:overworld", - 200, 0.25, 20, 217, 50, 0, 0, new String[] { + 250, 0.25, 20, 217, 50, 0, 0, new String[] { "tfc:rock/raw/rhyolite","tfc:rock/raw/basalt","tfc:rock/raw/andesite","tfc:rock/raw/dacite",}, new OreVeinInfoRecipe.WeightedBlock[] { - new OreVeinInfoRecipe.WeightedBlock("chalcopyrite", 61),new OreVeinInfoRecipe.WeightedBlock("zeolite", 16),new OreVeinInfoRecipe.WeightedBlock("cassiterite", 5),new OreVeinInfoRecipe.WeightedBlock("realgar", 16),}, + new OreVeinInfoRecipe.WeightedBlock("chalcopyrite", 61),new OreVeinInfoRecipe.WeightedBlock("zeolite", 22),new OreVeinInfoRecipe.WeightedBlock("realgar", 16),}, null), new OreVeinInfoRecipe("surface_sphalerite", "minecraft:overworld", 145, 0.25, 60, 210, 50, 0, 0, new String[] { diff --git a/src/main/java/su/terrafirmagreg/core/mixins/client/waterflasks/FlaskItemMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/client/waterflasks/FlaskItemMixin.java new file mode 100644 index 000000000..a2c3e7d1f --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/mixins/client/waterflasks/FlaskItemMixin.java @@ -0,0 +1,72 @@ +package su.terrafirmagreg.core.mixins.client.waterflasks; + +import java.util.function.Supplier; + +import org.labellum.mc.waterflasks.item.FlaskItem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Slice; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; + +import net.dries007.tfc.common.capabilities.Capabilities; +import net.dries007.tfc.common.items.DiscreteFluidContainerItem; +import net.dries007.tfc.util.Drinkable; +import net.dries007.tfc.util.Helpers; +import net.minecraft.tags.TagKey; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.fluids.capability.IFluidHandler; + +@Mixin(value = FlaskItem.class, remap = false) +public abstract class FlaskItemMixin extends DiscreteFluidContainerItem { + + public FlaskItemMixin(Properties properties, Supplier capacity, TagKey whitelist, boolean canPlaceLiquidsInWorld, boolean canPlaceSourceBlocks) { + super(properties, capacity, whitelist, canPlaceLiquidsInWorld, canPlaceSourceBlocks); + } + + // spotless:off + /** + * @author Ujhik + * @reason Add tfc behavior enabling certain drinks like wines that give buffs to be drink when player has full water meter + */ + @ModifyExpressionValue( + method = "use", + slice = @Slice( + from = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/player/Player;getFoodData()Lnet/minecraft/world/food/FoodData;" + ), + to = @At( + value = "INVOKE", + target = "Lnet/minecraftforge/fluids/FluidStack;getAmount()I", + remap = false + ) + ), + at = @At( + value = "INVOKE", + target = "Lnet/minecraftforge/common/ForgeConfigSpec$BooleanValue;get()Ljava/lang/Object;", + ordinal = 0, + remap = false + ), + remap = true + ) + private Object modifyConfig(Object original, @Local(name = "player") Player player, @Local(name = "hand") InteractionHand hand) { + Boolean bOriginal = (Boolean) original; + + ItemStack stack = player.getItemInHand(hand); + final IFluidHandler handler = Helpers.getCapability(stack, Capabilities.FLUID_ITEM); + if (handler == null) + return bOriginal; + + final Drinkable drinkable = Drinkable.get(handler.getFluidInTank(0).getFluid()); + if (drinkable == null) + return bOriginal; + + return bOriginal || drinkable.mayDrinkWhenFull(); + } + // spotless:on +} diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/create/BlazeBurnerBlockEntityMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/common/create/BlazeBurnerBlockEntityMixin.java new file mode 100644 index 000000000..ad073bcff --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/mixins/common/create/BlazeBurnerBlockEntityMixin.java @@ -0,0 +1,53 @@ +package su.terrafirmagreg.core.mixins.common.create; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import com.bawnorton.mixinsquared.TargetHandler; +import com.simibubi.create.content.processing.burner.BlazeBurnerBlockEntity; +import com.simibubi.create.foundation.blockEntity.SmartBlockEntity; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; + +/** + * Mixin to prevent fuel from being inserted in the Blaze Burner by hand or mechanical arm in airless dimensions. + * Needs higher priority than CreateLiquidFuel's mixin to prevent liquid insertion with a bucket. + * Automated liquid insertion with pipes etc still works, but won't burn. + */ +@Mixin(value = BlazeBurnerBlockEntity.class, priority = 900, remap = false) +public abstract class BlazeBurnerBlockEntityMixin extends SmartBlockEntity { + + public BlazeBurnerBlockEntityMixin(BlockEntityType type, BlockPos pos, BlockState state) { + super(type, pos, state); + } + + @Inject(method = "tryUpdateFuel", at = @At("HEAD"), cancellable = true) + public void tfg$tryUpdateFuel(ItemStack itemStack, boolean forceOverflow, boolean simulate, CallbackInfoReturnable cir) { + assert level != null; + if (level.dimension() != Level.OVERWORLD && level.dimension() != Level.NETHER) { + cir.setReturnValue(false); + } + } + + /** + * Prevent inserted liquid fuel from being burned + * MixinSquared, targeting Create Liquid Fuel's tick method + * Exits out of their mixin if we're not in the overworld/beneath. + */ + @SuppressWarnings("CancellableInjectionUsage") // Idea gets confused about the two CallbackInfos + @TargetHandler(mixin = "com.forsteri.createliquidfuel.mixin.MixinBlazeBurnerTileEntity", name = "tick") + @Inject(method = "@MixinSquared:Handler", at = @At("HEAD"), cancellable = true) + private void tfg$cancelLiquidFuelTick(CallbackInfo originalCi, CallbackInfo ci) { + assert level != null; + if (level.dimension() != Level.OVERWORLD && level.dimension() != Level.NETHER) { + ci.cancel(); + } + } +} diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/create/BlazeBurnerBlockMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/common/create/BlazeBurnerBlockMixin.java new file mode 100644 index 000000000..54c5e4b94 --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/mixins/common/create/BlazeBurnerBlockMixin.java @@ -0,0 +1,40 @@ +package su.terrafirmagreg.core.mixins.common.create; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import com.simibubi.create.AllTags; +import com.simibubi.create.content.processing.burner.BlazeBurnerBlock; + +import net.dries007.tfc.util.Helpers; +import net.minecraft.core.BlockPos; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +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.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; + +/** + * Mixin to play a sound when trying to insert valid fuel in airless dimensions. + */ +@Mixin(value = BlazeBurnerBlock.class) +public abstract class BlazeBurnerBlockMixin { + @Inject(method = "use", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/processing/burner/BlazeBurnerBlock;tryInsert(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;ZZZ)Lnet/minecraft/world/InteractionResultHolder;", remap = false)) + private void injected(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult blockRayTraceResult, CallbackInfoReturnable cir) { + + if (level.dimension() != Level.OVERWORLD && level.dimension() != Level.NETHER) { + ItemStack heldItem = player.getItemInHand(hand); + + if (AllTags.AllItemTags.BLAZE_BURNER_FUEL_REGULAR.matches(heldItem) + || AllTags.AllItemTags.BLAZE_BURNER_FUEL_SPECIAL.matches(heldItem)) { + + Helpers.playSound(level, pos, SoundEvents.FIRE_EXTINGUISH); + } + } + } +} diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/createliquidfuel/LiquidBurnerFuelJsonLoaderMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/common/createliquidfuel/LiquidBurnerFuelJsonLoaderMixin.java new file mode 100644 index 000000000..c6d7c41f5 --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/mixins/common/createliquidfuel/LiquidBurnerFuelJsonLoaderMixin.java @@ -0,0 +1,30 @@ +package su.terrafirmagreg.core.mixins.common.createliquidfuel; + +import java.util.HashMap; +import java.util.Map; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.forsteri.createliquidfuel.core.LiquidBurnerFuelJsonLoader; +import com.google.gson.JsonElement; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.profiling.ProfilerFiller; + +import su.terrafirmagreg.core.network.packet.FuelSyncPacket; + +/** + * Capture the finalized blaze burner liquid fuel map to send to the client and populate emi. + */ +@Mixin(value = LiquidBurnerFuelJsonLoader.class, remap = false) +public class LiquidBurnerFuelJsonLoaderMixin { + + @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("TAIL")) + private void tfg$syncFuelsToClient(Map map, ResourceManager manager, ProfilerFiller profiler, CallbackInfo ci) { + FuelSyncPacket.capturedJsonData = new HashMap<>(map); + } +} diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/GTRecipeWidgetMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/GTRecipeWidgetMixin.java index 6e3256bd9..33ea80781 100644 --- a/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/GTRecipeWidgetMixin.java +++ b/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/GTRecipeWidgetMixin.java @@ -3,7 +3,9 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.gregtechceu.gtceu.integration.xei.widgets.GTRecipeWidget; @@ -18,4 +20,9 @@ public class GTRecipeWidgetMixin { tfg$dimensionOffset -= 17; return yOffset + tfg$dimensionOffset; } + + @Inject(method = "setRecipeWidget", at = @At(value = "TAIL")) + private void tfg$resetOffset(CallbackInfo ci) { + tfg$dimensionOffset = 17; + } } diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/ProtectionTypeMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/ProtectionTypeMixin.java new file mode 100644 index 000000000..18d48d5ae --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/ProtectionTypeMixin.java @@ -0,0 +1,19 @@ +package su.terrafirmagreg.core.mixins.common.gtceu; + +import java.util.Set; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import com.gregtechceu.gtceu.api.data.chemical.material.properties.HazardProperty.ProtectionType; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; + +@Mixin(value = ProtectionType.class, remap = false) +public abstract class ProtectionTypeMixin { + + //Change mask curio slot from "head" to "face" + @ModifyExpressionValue(method = "", at = @At(value = "INVOKE", target = "Ljava/util/Set;of(Ljava/lang/Object;)Ljava/util/Set;", ordinal = 0)) + private static Set tfg$modifyMaskCurioSlot(Set original) { + return Set.of("face"); + } +} diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/materials/ElementMaterialsMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/materials/ElementMaterialsMixin.java deleted file mode 100644 index 5557bf59e..000000000 --- a/src/main/java/su/terrafirmagreg/core/mixins/common/gtceu/materials/ElementMaterialsMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package su.terrafirmagreg.core.mixins.common.gtceu.materials; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import com.gregtechceu.gtceu.api.data.chemical.material.Material; -import com.gregtechceu.gtceu.api.data.chemical.material.properties.ToolProperty; -import com.gregtechceu.gtceu.common.data.materials.ElementMaterials; - -@Mixin(value = ElementMaterials.class, remap = false) -public abstract class ElementMaterialsMixin { - - /** - * Отключение инстурментов из железа GTCEu. - */ - @Redirect(method = "register", at = @At(value = "INVOKE", target = "Lcom/gregtechceu/gtceu/api/data/chemical/material/Material$Builder;toolStats(Lcom/gregtechceu/gtceu/api/data/chemical/material/properties/ToolProperty;)Lcom/gregtechceu/gtceu/api/data/chemical/material/Material$Builder;", ordinal = 1), remap = false) - private static Material.Builder tfg$register$toolStats$iron(Material.Builder instance, ToolProperty toolProperty) { - return instance; - } -} diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/sacks_n_such/AbstractArrowMixinSquared.java b/src/main/java/su/terrafirmagreg/core/mixins/common/sacks_n_such/AbstractArrowMixinSquared.java new file mode 100644 index 000000000..50588b465 --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/mixins/common/sacks_n_such/AbstractArrowMixinSquared.java @@ -0,0 +1,36 @@ +package su.terrafirmagreg.core.mixins.common.sacks_n_such; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import com.bawnorton.mixinsquared.TargetHandler; +import com.llamalad7.mixinextras.sugar.Local; + +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.item.ItemStack; + +@Mixin(value = AbstractArrow.class, priority = 1100) +public abstract class AbstractArrowMixinSquared { + + /** Handles arrow pickup logic + * @author Ujhik + * @reason To correct the arrow dupe bug that happens when a player has and stack of arrows in the inventory, no quiver, and picks up a shoot arrow from the ground. + */ + @SuppressWarnings("CancellableInjectionUsage") + @TargetHandler(mixin = "mod.traister101.sns.mixins.common.AbstractArrowMixin", name = "tryInsertIntoQuiver") + @Inject(method = "@MixinSquared:Handler", at = @At("RETURN")) + private void tfg$modifyReturnBasedOnRemainder( + Player player, + CallbackInfoReturnable cir, + CallbackInfo ci, + @SuppressWarnings("LocalMayBeArgsOnly") @Local(name = "inventoryRemainder") ItemStack inventoryRemainder) { + + if (inventoryRemainder != null && inventoryRemainder.getCount() < 1) { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/java/su/terrafirmagreg/core/mixins/common/sacks_n_such/SimpleDynamicCachedWeightMixin.java b/src/main/java/su/terrafirmagreg/core/mixins/common/sacks_n_such/SimpleDynamicCachedWeightMixin.java new file mode 100644 index 000000000..daf455cbd --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/mixins/common/sacks_n_such/SimpleDynamicCachedWeightMixin.java @@ -0,0 +1,36 @@ +package su.terrafirmagreg.core.mixins.common.sacks_n_such; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; + +import net.dries007.tfc.common.capabilities.size.Weight; +import net.minecraft.world.item.ItemStack; + +import mod.traister101.sns.common.capability.SimpleDynamicCachedWeight; +import mod.traister101.sns.common.items.SNSItems; + +@Mixin(value = SimpleDynamicCachedWeight.class, remap = false) +public abstract class SimpleDynamicCachedWeightMixin { + @Final + @Shadow(remap = false) + private ItemStack owner; + + /** Changes the dynamic weight returning VERY_HEAVY when nearly full to HEAVY for HUGE containers so they don't trigger the exhaust debuff on players + * @author Ujhik + * @reason To avoid exhaust debuff given by FRAME_PACK or QUIVER when full or nearly full because they are HUGE and the dynamic weight of the mod sns returns VERY_HEAVY + */ + @ModifyReturnValue(method = "getWeight", at = @At("RETURN"), remap = false) + private Weight tfg$changeVeryHeavyToHeavy(Weight originalReturn) { + boolean isFramePack = owner.is(SNSItems.FRAME_PACK.get()); + boolean isQuiver = owner.is(SNSItems.QUIVER.get()); + if (originalReturn == Weight.VERY_HEAVY && (isFramePack || isQuiver)) { + return Weight.HEAVY; + } + + return originalReturn; + } +} diff --git a/src/main/java/su/terrafirmagreg/core/network/TFGNetworkHandler.java b/src/main/java/su/terrafirmagreg/core/network/TFGNetworkHandler.java index e18b8e81a..ac079ae3e 100644 --- a/src/main/java/su/terrafirmagreg/core/network/TFGNetworkHandler.java +++ b/src/main/java/su/terrafirmagreg/core/network/TFGNetworkHandler.java @@ -11,6 +11,7 @@ import net.minecraftforge.network.simple.SimpleChannel; import su.terrafirmagreg.core.TFGCore; +import su.terrafirmagreg.core.network.packet.FuelSyncPacket; import su.terrafirmagreg.core.network.packet.OreHighlightPacket; import su.terrafirmagreg.core.network.packet.OreHighlightVeinPacket; import su.terrafirmagreg.core.network.packet.ParticlePacket; @@ -55,6 +56,12 @@ public static void init() { OreHighlightVeinPacket::encode, OreHighlightVeinPacket::decode, OreHighlightVeinPacket::handle); + INSTANCE.registerMessage( + id(), + FuelSyncPacket.class, + FuelSyncPacket::encode, + FuelSyncPacket::decode, + FuelSyncPacket::handle); } private static void sendToAllAround(Level level, BlockPos pos, Object packet) { diff --git a/src/main/java/su/terrafirmagreg/core/network/packet/FuelSyncPacket.java b/src/main/java/su/terrafirmagreg/core/network/packet/FuelSyncPacket.java new file mode 100644 index 000000000..21289d62d --- /dev/null +++ b/src/main/java/su/terrafirmagreg/core/network/packet/FuelSyncPacket.java @@ -0,0 +1,88 @@ +package su.terrafirmagreg.core.network.packet; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; + +import com.forsteri.createliquidfuel.core.BurnerStomachHandler; +import com.forsteri.createliquidfuel.util.Triplet; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.mojang.datafixers.util.Pair; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.material.Fluid; +import net.minecraftforge.network.NetworkEvent; +import net.minecraftforge.registries.ForgeRegistries; + +/** + * Packet for syncing blaze burner liquid fuel map to the client to populate emi. + */ +public record FuelSyncPacket(Map data) { + + private static final Gson GSON = new Gson(); + @SuppressWarnings("removal") + private static final ResourceLocation JSON_LOADER_ID = ResourceLocation.of("createliquidfuel:drainable_fuel_loader", ':'); + + // Populated by mixin after server-side JSON reload + public static Map capturedJsonData = new HashMap<>(); + + public static void encode(FuelSyncPacket pkt, FriendlyByteBuf buf) { + buf.writeVarInt(pkt.data.size()); + for (Map.Entry entry : pkt.data.entrySet()) { + buf.writeResourceLocation(entry.getKey()); + buf.writeUtf(GSON.toJson(entry.getValue())); + } + } + + public static FuelSyncPacket decode(FriendlyByteBuf buf) { + int size = buf.readVarInt(); + Map map = new HashMap<>(size); + for (int i = 0; i < size; i++) { + ResourceLocation key = buf.readResourceLocation(); + JsonElement element = GSON.fromJson(buf.readUtf(), JsonElement.class); + map.put(key, element); + } + return new FuelSyncPacket(map); + } + + // Copied from LiquidBurnerFuelJsonLoader.apply() + public static void handle(FuelSyncPacket pkt, Supplier ctx) { + ctx.get().enqueueWork(() -> { + for (Map.Entry entry : pkt.data.entrySet()) { + JsonElement element = entry.getValue(); + if (!element.isJsonObject()) + continue; + + JsonObject object = element.getAsJsonObject(); + JsonElement fluidElement = object.get("fluid"); + if (fluidElement == null) + continue; + + @SuppressWarnings("removal") + Fluid fluid = ForgeRegistries.FLUIDS.getValue(new ResourceLocation(fluidElement.getAsString())); + if (fluid == null) + continue; + + BurnerStomachHandler.LIQUID_BURNER_FUEL_MAP.put(fluid, + Pair.of( + JSON_LOADER_ID, + Triplet.of( + object.has("burnTime") + ? object.get("burnTime").getAsInt() + : object.has("superHeat") && object.get("superHeat").getAsBoolean() + ? 32 + : 20, + object.has("superHeat") && object.get("superHeat").getAsBoolean(), + object.has("amountConsumedPerTick") + ? object.get("amountConsumedPerTick").getAsInt() + : object.has("superHeat") && object.get("superHeat").getAsBoolean() + ? 10 + : 1))); + } + }); + ctx.get().setPacketHandled(true); + } +} diff --git a/src/main/resources/tfg.mixins.json b/src/main/resources/tfg.mixins.json index 1ed3d3b5d..4a065c898 100644 --- a/src/main/resources/tfg.mixins.json +++ b/src/main/resources/tfg.mixins.json @@ -3,6 +3,7 @@ "client.create.ChainConveyorRendererMixin", "client.minecraft.IBlockModelGeneratorsInvoker", "client.tfc.ClientForgeEventHandlerMixin", + "client.waterflasks.FlaskItemMixin", "client.tfc.DrinkableMixin", "common.ad_astra.EnvironmentEffectsMixin", "common.ad_astra.GasTankItemMixin", @@ -38,6 +39,8 @@ "common.cc_tweaked.ModRegistryMixin", "common.create.BasinBlockEntityMixin", "common.create.BasinCategoryMixin", + "common.create.BlazeBurnerBlockMixin", + "common.create.BlazeBurnerBlockEntityMixin", "common.create.BoilerFluidHandlerMixin", "common.create.ChainConveyorBlockEntityMixin", "common.create.ChainConveyorBlockMixin", @@ -56,6 +59,7 @@ "common.create.WaterWheelBlockMixin", "common.create.WindmillBearingBlockEntityMixin", "common.create.WindmillBearingBlockMixin", + "common.createliquidfuel.LiquidBurnerFuelJsonLoaderMixin", "common.emi.ItemEmiStackMixin", "common.fallingtrees.StandardTreeMixin", "common.firmalife.ClimateStationOxygenatedMixin", @@ -90,12 +94,12 @@ "common.gtceu.NBTPredicateIngredientAccessor", "common.gtceu.NBTPredicateIngredientSerializerMixin", "common.gtceu.NotifiableItemStackHandlerMixin", + "common.gtceu.ProtectionTypeMixin", "common.gtceu.QuarkTechSuiteMixin", "common.gtceu.SteamBoilerMachineMixin", "common.gtceu.SurfaceRockBlockMixin", "common.gtceu.TagPrefixItemMixin", "common.gtceu.ToolHelperMixin", - "common.gtceu.materials.ElementMaterialsMixin", "common.gtceu.materials.FirstDegreeMixin", "common.gtceu.materials.MaterialBlocksMixin", "common.gtceu.materials.MaterialBuilderMixin", @@ -129,6 +133,8 @@ "common.minecraft.SmallFireballMixin", "common.minecraft.SnifferEggBlockMixin", "common.minecraft.StriderMixin", + "common.sacks_n_such.AbstractArrowMixinSquared", + "common.sacks_n_such.SimpleDynamicCachedWeightMixin", "common.sandworms.WormSignHandlerMixin", "common.simply_stacked_dimensions.TeleportHandlerMixin", "common.sophisticatedbackpacks.FeedingUpgradeWrapperMixin",