diff --git a/.gitignore b/.gitignore index 2c770e0..341153e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ build # other eclipse run +/localGitDependency/ diff --git a/build.gradle b/build.gradle index a81b05a..a95e965 100644 --- a/build.gradle +++ b/build.gradle @@ -1,101 +1,60 @@ -buildscript { - repositories { - maven { - name 'MixinGradle' - url 'https://repo.spongepowered.org/repository/maven-public' - } - } - dependencies { - if (project.use_mixins.toBoolean()) { - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' - } - } -} +import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar +import org.jetbrains.gradle.ext.Gradle plugins { - id 'net.minecraftforge.gradle' version '5.1.+' - id 'wtf.gofancy.fancygradle' version '1.1.+' -} - -configurations { - gitDependencies { - exclude group: 'curse.maven', module: 'AdvancedRocketry-236542' - exclude group: 'curse.maven', module: 'Libvulpes-236541' - exclude group: 'curse.maven', module: 'had-enough-items-557549' - } - implementation.extendsFrom(gitDependencies) -} - -apply { - plugin 'net.minecraftforge.gradle' - plugin 'org.spongepowered.mixin' - plugin 'java' - plugin 'idea' -} - -fancyGradle { - patches { - resources - coremods - asm - codeChickenLib - } + id("java") + id("java-library") + id("maven-publish") + id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7" + id("eclipse") + id("com.gtnewhorizons.retrofuturagradle") version "1.3.9" + id("com.matthewprenger.cursegradle") version "1.4.0" + id('io.github.srdjan-v.local-git-dependency') version '0.5.2' } +def currentBranch = ("git rev-parse --abbrev-ref HEAD").execute().inputStream.readLines().get(0) version = project.mod_version group = project.maven_group archivesBaseName = project.archives_base_name -java.toolchain.languageVersion = JavaLanguageVersion.of(8) - -idea { - module { - downloadJavadoc = true - downloadSources = true +// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + // Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64 + vendor.set(JvmVendorSpec.AZUL) } + // Generate sources and javadocs jars when building and publishing + withSourcesJar() + //withJavadocJar() } minecraft { - - mappings channel: 'stable', version: '39-1.12' - - if (project.has_access_transformer.toBoolean()) { - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + mcVersion = '1.12.2' + def args = ["-ea:${project.group}"] + if (project.use_coremod.toBoolean()) { + args << '-Dfml.coreMods.load=' + coremod_plugin_class_name } - runs { - client { - workingDirectory project.file('run') - if (project.use_coremod.toBoolean()) { - jvmArg '-Dfml.coreMods.load=' + coremod_plugin_class_name - } - if (project.use_mixins.toBoolean()) { - jvmArg '-Dmixin.hotSwap=true' - jvmArg '-Dmixin.checks.interfaces=true' - jvmArg '-Dmixin.debug=true' - } - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - environment 'MC_VERSION', '1.12.2' - } - - server { - workingDirectory project.file('run') - if (project.use_coremod.toBoolean()) { - jvmArg '-Dfml.coreMods.load=' + coremod_plugin_class_name - } - if (project.use_mixins.toBoolean()) { - jvmArg '-Dmixin.hotSwap=true' - jvmArg '-Dmixin.checks.interfaces=true' - } - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - environment 'MC_VERSION', '1.12.2' - } + if (project.use_mixins.toBoolean()) { + args << '-Dmixin.hotSwap=true' + args << '-Dmixin.checks.interfaces=true' + args << '-Dmixin.debug.export=true' } + extraRunJvmArguments.addAll(args) + + useDependencyAccessTransformers = true + injectedTags.put("VERSION", project.version) + injectedTags.put("TWEAKED_PETROLEUM_VERSION", tweaked_petroleum_version) + injectedTags.put("TWEAKED_LIB_VERSION", tweaked_lib_version) } +// Generate a my.project.Tags class with the version number as a field +tasks.injectTags.configure { + outputClassName.set("${project.group}.${project.archives_base_name}.Tags") +} repositories { + mavenCentral() maven { url = 'https://maven.cleanroommc.com' } @@ -120,22 +79,33 @@ repositories { name = "Progwml6 maven" url = "https://dvs1.progwml6.com/files/maven/" } + mavenLocal() } -dependencies { - minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860' +configurations { + embed + implementation.extendsFrom(embed) +} +dependencies { implementation 'CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.679' - implementation fg.deobf('curse.maven:ImmersiveEngineering-231951:2974106') - implementation fg.deobf('curse.maven:ImmersivePetroleum-268250:3382321') + implementation rfg.deobf('curse.maven:ImmersiveEngineering-231951:2974106') + implementation rfg.deobf('curse.maven:ImmersivePetroleum-268250:3382321') + + implementation ("com.cleanroommc:groovyscript:${project.groovy_script_version}") { + exclude group: 'mezz.jei', module: 'jei_1.12.2' + exclude group: 'curse.maven', module: 'top-245211' + exclude group: 'zone.rong', module: 'mixinbooter' + exclude group: 'codechicken', module:'codechickenlib' + } //Mekanism implementation('curse.maven:Mekanism_api-268560:2835176') implementation('curse.maven:Mekanism-268560:2835175') //HEI/JEI - compileOnly fg.deobf('mezz.jei:jei_1.12.2:4.16.1.302:api') - runtimeOnly fg.deobf('mezz.jei:jei_1.12.2:4.16.1.302') + //compileOnly rfg.deobf('mezz.jei:jei_1.12.2:4.16.1.302:api') + //runtimeOnly rfg.deobf('mezz.jei:jei_1.12.2:4.16.1.302') //implementation fg.deobf('curse.maven:had-enough-items-557549:3862733') @@ -155,155 +125,237 @@ dependencies { runtimeOnly 'curse.maven:Hwyla-253449:2568751' - if (project.use_mixins.toBoolean()) { - compileOnly 'zone.rong:mixinbooter:5.0' - runtimeOnly 'zone.rong:mixinbooter:5.0' - annotationProcessor "org.spongepowered:mixin:0.8.2:processor" - } -} - -git { - def props = new Properties() - new File("${project.projectDir}/gradle.properties").withInputStream { props.load(it) } + //enables java 17 features on java 8 + annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0' + annotationProcessor 'net.java.dev.jna:jna-platform:5.13.0' + compileOnly 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0' - gitDependencies 'https://github.com/Srdjan-V/TweakedLib.git', { - name 'TweakedLib' - commit "v${props.getProperty('tweaked_lib_version')}" + if (project.use_assetmover.toBoolean()) { + implementation 'com.cleanroommc:assetmover:2.0' } - gitDependencies 'https://github.com/Srdjan-V/TweakedPetroleum.git', { - name 'TweakedPetroleum' - commit "v${props.getProperty('tweaked_petroleum_version')}" + if (project.use_mixins.toBoolean()) { + api("zone.rong:mixinbooter:9.1") { transitive = false } + annotationProcessor 'org.ow2.asm:asm-debug-all:5.2' + annotationProcessor 'com.google.guava:guava:24.1.1-jre' + annotationProcessor 'com.google.code.gson:gson:2.8.6' } + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' } -sourceSets { - main { - if (project.use_mixins.toBoolean()) { - ext.refMap = 'mixins.' + archives_base_name + '.refmap.json' +localGitDependency { + add('https://github.com/Srdjan-V/TweakedPetroleum.git', { + buildLauncher { + startup { + mainTasks "setupCIWorkspace" + } } - - java { - srcDirs = ["src/main/java"] + configuration("runtimeOnly") + subConfiguration({ + name "TweakedLib" + configuration({ + configuration "runtimeOnly" + include "tweakedlib" + }) + }, { + name "HadEnoughItems" + configuration({ + configuration "implementation" + include "HadEnoughItems_1.12.2" + }) + }) + enableIdeSupport true + mapSourceSets({ + recursive true + map "main", "main" + }) + if (currentBranch == "master") { + keepGitUpdated true + tag 'v' + project.tweaked_petroleum_version + } else { + keepGitUpdated false + branch 'develop' } + }) +} - resources { - srcDirs = ["src/main/java", "src/main/resources"] - } +def mixinConfigRefMap = 'mixins.' + project.archives_base_name + '.refmap.json' +def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins' +def refMap = "${mixinTmpDir}" + File.separator + mixinConfigRefMap +def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg" + +if (project.use_mixins.toBoolean()) { + tasks.named("reobfJar", ReobfuscatedJar).configure { + extraSrgFiles.from(mixinSrg) } - test { - java { - srcDirs = ["src/test/java"] - } - resources { - srcDirs = ["src/test/resources"] + tasks.named("compileJava", JavaCompile).configure { + doFirst { + new File(mixinTmpDir).mkdirs() } + options.compilerArgs += [ + "-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + ] } - - // at compile time, put resources in same directories as classes - main.output.setResourcesDir(main.java.classesDirectory) } +if (project.use_access_transformer.toBoolean()) { + for (File at : sourceSets.getByName("main").resources.files) { + if (at.name.toLowerCase().endsWith("_at.cfg")) { + tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at) + tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at) + } + } +} jar { manifest { - // noinspection GroovyAssignabilityCheck def attribute_map = [:] if (project.use_coremod.toBoolean()) { attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name if (project.include_mod.toBoolean()) { attribute_map['FMLCorePluginContainsFMLMod'] = true - attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == 'build' + attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build" } } - if (project.use_mixins.toBoolean()) { - attribute_map['TweakClass'] = 'org.spongepowered.asm.launch.MixinTweaker' + if (project.use_access_transformer.toBoolean()) { + attribute_map['FMLAT'] = project.archives_base_name + '_at.cfg' } attributes(attribute_map) } + // Add all embedded dependencies into the jar + from(provider { configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } }) } -jar.finalizedBy('reobfJar') - - -import org.apache.tools.ant.filters.ReplaceTokens +processResources { + // this will ensure that this task is redone when the versions change. + inputs.property 'version', project.version + inputs.property 'mcversion', project.minecraft.version + // replace stuff in mcmod.info, nothing else + filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd -> + // replace version and mcversion + fcd.expand( + 'version': project.version, + //'mcversion': project.minecraft.version + ) + } -task filterTokens(type: Sync) { - inputs.property 'version', version - inputs.property 'tweaked_petroleum_version', tweaked_petroleum_version + if (project.use_access_transformer.toBoolean()) { + rename '(.+_at.cfg)', 'META-INF/$1' // Access Transformers + } - from sourceSets.main.java - filter(ReplaceTokens, tokens: [VERSION: version.toString(), TWEAKEDPETROLEUMVERSION: tweaked_petroleum_version.toString()]) - into "$buildDir/src/$sourceSets.main.name/$sourceSets.main.java.name" + if (project.use_mixins.toBoolean()) { + // Embed mixin refmap + from refMap + dependsOn("compileJava") + } } -compileJava.source = filterTokens.outputs +tasks.register('updateGitVersionTag') { + doLast { + def versionTagArray = new ArrayList() + for (versionString in project.version.toString().trim().split("\\.")) { + versionTagArray.add(Integer.valueOf(versionString)) + } -/*compileJava { - classpath = sourceSets.main.compileClasspath + configurations.gitDependencies -}*/ + def gitVersionTagArray = new ArrayList() + def gitStringTag = ("git describe --tags --abbrev=0").execute().inputStream.readLines().get(0) + for (versionString in gitStringTag.substring(1, gitStringTag.length()).trim().split("\\.")) { + gitVersionTagArray.add(Integer.valueOf(versionString)) + } -processResources { - // required to allow file expansion later - duplicatesStrategy = 'include' + def invalid = true + def smallestSizeArray = versionTagArray.size() > gitVersionTagArray.size() ? gitVersionTagArray.size() : versionTagArray.size() + for (i in 0.. gitVersionTagArray.get(i)) { + invalid = false + break + } + } - // this will ensure that this task is redone when the versions change. - inputs.property 'version', version + if (!invalid && versionTagArray.size() > gitVersionTagArray.size()) { + invalid = false + } - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' + if (invalid) { + project.logger.error("Current project version is the same or lower then the latest tag") + return + } - // replace version and mcversion - expand 'version': version + project.logger.lifecycle('Pushing tag {}', project.version) + ("git tag v${project.version}").execute() + ("git push --tags").execute() } +} - // copy everything else except the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' +idea { + module { + inheritOutputDirs = true + downloadJavadoc = true + downloadSources = true + } + project { + settings { + runConfigurations { + "1. Run Client"(Gradle) { + taskNames = ["runClient"] + } + "2. Run Server"(Gradle) { + taskNames = ["runServer"] + } + "3. Run Obfuscated Client"(Gradle) { + taskNames = ["runObfClient"] + } + "4. Run Obfuscated Server"(Gradle) { + taskNames = ["runObfServer"] + } + } + compiler.javac { + afterEvaluate { + javacAdditionalOptions = "-encoding utf8" + moduleJavacAdditionalOptions = [ + (project.name + ".main"): tasks.compileJava.options.compilerArgs.collect { '"' + it + '"' }.join(' ') + ] + } + } + } } } -if (project.build_deobfJar.toBoolean()) { - // Create deobf dev jars - task deobfJar(type: Jar) { - archiveClassifier.set("deobf") - from sourceSets.main.output - } +tasks.named("processIdeaSettings").configure { + dependsOn("injectTags") } -if (project.build_apiJar.toBoolean()) { - // Create API library jar - task apiZip(type: Jar) { - archiveClassifier.set("api") - from(sourceSets.main.java) { - include "name/api/**" - } - from(sourceSets.main.output) { - include "name/api/**" +afterEvaluate { + tasks.withType(JavaCompile.class).configureEach { + options.encoding = "UTF-8" + sourceCompatibility = 17 // for the IDE support + options.release = 8 + + javaCompiler = javaToolchains.compilerFor { + languageVersion = JavaLanguageVersion.of(17) } } } -if (project.build_sourceJar.toBoolean()) { - // Create source jar - task sourcesJar(type: Jar) { - archiveClassifier.set("sources") - from sourceSets.main.allJava - } +configure([tasks.javadoc]) { + javadocTool.set(javaToolchains.javadocToolFor { + languageVersion = JavaLanguageVersion.of(17) + }) } -artifacts { - if (project.build_deobfJar.toBoolean()) { - archives deobfJar - } - if (project.build_apiJar.toBoolean()) { - archives apiZip - } - if (project.build_sourceJar.toBoolean()) { - archives sourcesJar - } +tasks.named('test') { + useJUnitPlatform() } +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourcesJar + } + } +} \ No newline at end of file diff --git a/examples/examples.zs b/examples/CraftTweaker/Reservoirs.zs similarity index 100% rename from examples/examples.zs rename to examples/CraftTweaker/Reservoirs.zs diff --git a/examples/GroovyScript/Reservoirs.groovy b/examples/GroovyScript/Reservoirs.groovy new file mode 100644 index 0000000..e2cc094 --- /dev/null +++ b/examples/GroovyScript/Reservoirs.groovy @@ -0,0 +1,37 @@ +//Register an power tier +var power = mods.tweakedMods.PowerTier.recipeBuilder() + .capacity(5555555) + .rft(5) + .register() + +/* +This method will register a reservoir with the chance to drain fluid from the chunk. +If drainChance is set to 0.25 it will have a 25% chance to drain from the chunk +If drainChance is set to 0.5 it will have a 50% chance to drain from the chunk +If drainChance is set to 1 it will have a 100% chance to drain from the chunk, its the same as registering it normally +*/ + +//Register an gas reservoir +mods.tweakedMods.GasReservoir.recipeBuilder() + .name("GroovyGasReservoir") + .fluid(gas("hydrogen")) + .weight(80000) + .powerTier(power) + .minSize(50) + .maxSize(1500) + .pumpSpeed(10) + .replenishRate(5) + .register() + +//Remove an gas reservoir +mods.tweakedMods.GasReservoir.remove("Some_Name") + +//Modify an reservoir +mods.tweakedMods.GasReservoir.get("lava").toBuilder() + .drainChance(0.8).maxSize(Integer.MAX_VALUE).register() + +/* +Groovy compat is located in 'io.github.srdjanv.tweakedpetroleum.common.compat.groovy' + +Also see https://cleanroommc.com/groovy-script/ +*/ \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0b6775a..9899cc5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,27 +5,24 @@ org.gradle.daemon = false # Mod Information -tweaked_petroleum_version = 1.3.0 -tweaked_lib_version = 1.0.0 +tweaked_petroleum_version = 2.0.0 +tweaked_lib_version = 2.0.0 +groovy_script_version = 1.0.1 -mod_version = 1.1.2 -maven_group = srki2k +mod_version = 2.0.0 +maven_group = io.github.srdjanv archives_base_name = tweakedpetroleumgas - -# Optionial Jar compiling -build_deobfJar = false -build_apiJar = false -build_sourceJar = true - # If any properties changes below this line, run `gradlew setupDecompWorkspace` and refresh gradle again to ensure everything is working correctly. # Boilerplate Options use_mixins = true use_coremod = true use_assetmover = false -has_access_transformer = false + +# Access Transformer files should be in the root of `resources` folder and with the filename formatted as: `{archives_base_name}_at.cfg` +use_access_transformer = false # Coremod Arguments include_mod = true -coremod_plugin_class_name = srki2k.tweakedpetroleumgas.core.TweakedPetroleumGasPlugin \ No newline at end of file +coremod_plugin_class_name = io.github.srdjanv.tweakedpetroleumgas.core.TweakedPetroleumGasPlugin \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c68..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 2458929..505a59e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,17 +1,22 @@ pluginManagement { repositories { - gradlePluginPortal() - maven { - name 'FancyGradle' - url 'https://gitlab.com/api/v4/projects/26758973/packages/maven' - } maven { - name 'ForgeGradle 5' - url 'https://maven.minecraftforge.net' + // RetroFuturaGradle + name = "GTNH Maven" + url = uri("http://jenkins.usrv.eu:8081/nexus/content/groups/public/") + allowInsecureProtocol = true + mavenContent { + includeGroup("com.gtnewhorizons") + includeGroup("com.gtnewhorizons.retrofuturagradle") + } } + gradlePluginPortal() + mavenCentral() + mavenLocal() } } plugins { - id 'com.alexvasilkov.git-dependencies' version '2.0.4' -} + // Automatic toolchain provisioning + id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" +} \ No newline at end of file diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/TweakedPetroleumGas.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/TweakedPetroleumGas.java new file mode 100644 index 0000000..8d6ca6b --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/TweakedPetroleumGas.java @@ -0,0 +1,42 @@ +package io.github.srdjanv.tweakedpetroleumgas; + + +import blusunrize.immersiveengineering.ImmersiveEngineering; +import blusunrize.immersiveengineering.common.IEContent; +import flaxbeard.immersivepetroleum.ImmersivePetroleum; +import io.github.srdjanv.tweakedlib.api.integration.DiscoveryHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.color.IItemColor; +import net.minecraft.client.renderer.color.ItemColors; +import net.minecraft.item.ItemStack; +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; + +@Mod(modid = TweakedPetroleumGas.MODID, + version = TweakedPetroleumGas.VERSION, + name = "Tweaked Petroleum: Gas Addon", + dependencies = "required-after:tweakedpetroleum@["+ Tags.TWEAKED_PETROLEUM_VERSION+",);" + + "required-after:mekanism;") + +public class TweakedPetroleumGas { + + public static final String MODID = "tweakedpetroleumgas"; + public static final String VERSION = Tags.VERSION; + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) { + DiscoveryHandler.getInstance().preInit(event); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + DiscoveryHandler.getInstance().init(event); + } + + @Mod.EventHandler + public void postInit(final FMLPostInitializationEvent event) { + DiscoveryHandler.getInstance().postInit(event); + } +} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/api/crafting/TweakedGasPumpjackHandler.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/crafting/TweakedGasPumpjackHandler.java similarity index 66% rename from src/main/java/srki2k/tweakedpetroleumgas/api/crafting/TweakedGasPumpjackHandler.java rename to src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/crafting/TweakedGasPumpjackHandler.java index 453480e..532eab6 100644 --- a/src/main/java/srki2k/tweakedpetroleumgas/api/crafting/TweakedGasPumpjackHandler.java +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/crafting/TweakedGasPumpjackHandler.java @@ -1,13 +1,14 @@ -package srki2k.tweakedpetroleumgas.api.crafting; +package io.github.srdjanv.tweakedpetroleumgas.api.crafting; import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import io.github.srdjanv.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasReservoirType; import mekanism.api.gas.Gas; import net.minecraft.world.World; -import srki2k.tweakedpetroleumgas.api.util.IGasReservoirType; import static flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler.getOilWorldInfo; -public class TweakedGasPumpjackHandler { +public class TweakedGasPumpjackHandler extends TweakedPumpjackHandler { /** * Gets the gas of a given chunk @@ -25,7 +26,7 @@ public static Gas getGas(World world, int chunkX, int chunkZ) { PumpjackHandler.OilWorldInfo info = getOilWorldInfo(world, chunkX, chunkZ); if (info != null && info.getType() != null) { - return ((IGasReservoirType) info.getType()).getGas(); + return ((ITweakedGasReservoirType) info.getType()).getGas(); } return null; diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasPumpjackAddons.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasPumpjackAddons.java new file mode 100644 index 0000000..e032bc8 --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasPumpjackAddons.java @@ -0,0 +1,15 @@ +package io.github.srdjanv.tweakedpetroleumgas.api.mixins; + +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetPumpjackAddons; +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasTank; +import mekanism.api.gas.GasTankInfo; +import net.minecraft.util.EnumFacing; + +public interface ITweakedGasPumpjackAddons extends ITweakedPetPumpjackAddons { + + Gas getGas(); + + GasTankInfo[] getAccessibleGasTanks(EnumFacing side); + +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirType.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirType.java new file mode 100644 index 0000000..c596767 --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirType.java @@ -0,0 +1,8 @@ +package io.github.srdjanv.tweakedpetroleumgas.api.mixins; + +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirType; +import mekanism.api.gas.Gas; + +public interface ITweakedGasReservoirType extends ITweakedPetReservoirType, ITweakedGasReservoirTypeGetters, ITweakedGasReservoirTypeSetters { + +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirTypeGetters.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirTypeGetters.java new file mode 100644 index 0000000..e55a33c --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirTypeGetters.java @@ -0,0 +1,9 @@ +package io.github.srdjanv.tweakedpetroleumgas.api.mixins; + +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirTypeGetters; +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirTypeSetters; +import mekanism.api.gas.Gas; + +public interface ITweakedGasReservoirTypeGetters extends ITweakedPetReservoirTypeGetters { + Gas getGas(); +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirTypeSetters.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirTypeSetters.java new file mode 100644 index 0000000..2ff13dc --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/api/mixins/ITweakedGasReservoirTypeSetters.java @@ -0,0 +1,6 @@ +package io.github.srdjanv.tweakedpetroleumgas.api.mixins; + +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirTypeSetters; + +public interface ITweakedGasReservoirTypeSetters extends ITweakedPetReservoirTypeSetters { +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/ClientHandler.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/ClientHandler.java new file mode 100644 index 0000000..7e33d2b --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/ClientHandler.java @@ -0,0 +1,42 @@ +package io.github.srdjanv.tweakedpetroleumgas.client; + +import blusunrize.immersiveengineering.common.IEContent; +import io.github.srdjanv.tweakedpetroleumgas.client.model.ModelCoresampleGasExtended; +import io.github.srdjanv.tweakedpetroleumgas.common.Configs; +import io.github.srdjanv.tweakedpetroleumgas.util.TweakedPetroleumGasInitializer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ModelBakeEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class ClientHandler implements TweakedPetroleumGasInitializer { + @Override public boolean shouldRun() { + return FMLCommonHandler.instance().getSide().isClient(); + } + + @Override public void preInit(FMLPreInitializationEvent event) { + MinecraftForge.EVENT_BUS.register(this); + } + + @Override public void init(FMLInitializationEvent event) { + //this will allow the application of fluid and gas color tint + if (Configs.clientConfig.replaceCoreSampleModel) + Minecraft.getMinecraft().getItemColors().registerItemColorHandler( + (stack, tintIndex) -> Math.max(tintIndex, -1), + IEContent.itemCoresample); + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onModelBakeEvent(ModelBakeEvent event) { + if (Configs.clientConfig.replaceCoreSampleModel) { + ModelResourceLocation mLoc = new ModelResourceLocation(new ResourceLocation("immersiveengineering", IEContent.itemCoresample.itemName), "inventory"); + event.getModelRegistry().putObject(mLoc, new ModelCoresampleGasExtended()); + } + } +} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/client/hei/GasPumpjackCategory.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/GasPumpjackCategory.java similarity index 79% rename from src/main/java/srki2k/tweakedpetroleumgas/client/hei/GasPumpjackCategory.java rename to src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/GasPumpjackCategory.java index ee75393..b7cc7a1 100644 --- a/src/main/java/srki2k/tweakedpetroleumgas/client/hei/GasPumpjackCategory.java +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/GasPumpjackCategory.java @@ -1,5 +1,6 @@ -package srki2k.tweakedpetroleumgas.client.hei; +package io.github.srdjanv.tweakedpetroleumgas.client.hei; +import io.github.srdjanv.tweakedpetroleumgas.TweakedPetroleumGas; import mekanism.api.gas.GasStack; import mekanism.client.jei.MekanismJEI; import mekanism.client.jei.gas.GasStackRenderer; @@ -8,8 +9,7 @@ import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; -import srki2k.tweakedlib.api.hei.BaseHEIUtil; -import srki2k.tweakedpetroleumgas.TweakedPetroleumGas; +import io.github.srdjanv.tweakedlib.api.hei.BaseHEIUtil; @SuppressWarnings("NullableProblems") public class GasPumpjackCategory implements IRecipeCategory { @@ -40,12 +40,12 @@ public void setRecipe(IRecipeLayout recipeLayout, GasPumpjackWrapper recipeWrapp IGuiIngredientGroup gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.TYPE_GAS); gasStacks.addTooltipCallback(recipeWrapper); - GasStackRenderer renderer1 = new GasStackRenderer(recipeWrapper.getMaxFluid(), false, 16, 60, null); - gasStacks.init(0, false, renderer1, 12, 10, 16, 60, 0, 0); + GasStackRenderer renderer1 = new GasStackRenderer(recipeWrapper.getMaxFluid(), false, 16, 47, null); + gasStacks.init(0, false, renderer1, 12, 23, 16, 47, 0, 0); gasStacks.set(0, recipeWrapper.getAverageGas()); - GasStackRenderer renderer2 = new GasStackRenderer(recipeWrapper.getPumpSpeed(), false, 16, 60, null); - gasStacks.init(1, false, renderer2, 36, 10, 16, 60, 0, 0); + GasStackRenderer renderer2 = new GasStackRenderer(recipeWrapper.getPumpSpeed(), false, 16, 47, null); + gasStacks.init(1, false, renderer2, 36, 23, 16, 47, 0, 0); gasStacks.set(1, recipeWrapper.getReplenishRateGas()); } diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/GasPumpjackWrapper.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/GasPumpjackWrapper.java new file mode 100644 index 0000000..b58fe8f --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/GasPumpjackWrapper.java @@ -0,0 +1,111 @@ +package io.github.srdjanv.tweakedpetroleumgas.client.hei; + +import com.google.common.collect.Lists; +import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import flaxbeard.immersivepetroleum.common.Config; +import io.github.srdjanv.tweakedpetroleum.common.Configs; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasReservoirType; +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasStack; +import mekanism.client.jei.MekanismJEI; +import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.client.Minecraft; +import io.github.srdjanv.tweakedpetroleum.util.HEIPumpjackUtil; + +import java.util.List; +import java.util.function.Consumer; + +import static flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler.reservoirList; + +@SuppressWarnings("NullableProblems") +public class GasPumpjackWrapper implements IRecipeWrapper, ITooltipCallback { + private final ITweakedGasReservoirType reservoir; + private final Gas reservoirGas; + + public GasPumpjackWrapper(PumpjackHandler.ReservoirType reservoir) { + this.reservoir = (ITweakedGasReservoirType) reservoir; + reservoirGas = this.reservoir.getGas(); + } + + public GasStack getReplenishRateGas() { + return new GasStack(reservoirGas, reservoir.getReplenishRate()); + } + + public int getPumpSpeed() { + return reservoir.getPumpSpeed(); + } + + public int getMaxFluid() { + return reservoir.getMaxSize(); + } + + public GasStack getAverageGas() { + return new GasStack(reservoirGas, getAverage()); + } + + public int getAverage() { + return (int) (((long) reservoir.getMaxSize() + (long) reservoir.getMinSize()) / 2); + } + + private int getStringWidth() { + return Math.min(77, Minecraft.getMinecraft().fontRenderer.getStringWidth(reservoir.getName()) + 6); + } + + @Override + public void getIngredients(IIngredients ingredients) { + ingredients.setOutputs(MekanismJEI.TYPE_GAS, Lists.newArrayList(getAverageGas())); + } + + @Override + public List getTooltipStrings(int mouseX, int mouseY) { + Consumer> warnings = list -> { + if (reservoir.getDrainChance() != 1f) { + list.add(HEIPumpjackUtil.translateToLocal("tweakedpetroleum.jei.reservoir.draw_chance1") + " " + reservoir.getDrainChance() * 100 + + HEIPumpjackUtil.translateToLocal("tweakedpetroleum.jei.reservoir.draw_chance2") + " " + (100f - (reservoir.getDrainChance() * 100)) + + HEIPumpjackUtil.translateToLocal("tweakedpetroleum.jei.reservoir.draw_chance3")); + } + + if (Config.IPConfig.Extraction.req_pipes) + list.add(HEIPumpjackUtil.translateToLocal("tweakedpetroleum.jei.reservoir.req_pipes")); + + list.add(HEIPumpjackUtil.translateToLocal("tweakedpetroleumgas.jei.reservoir.gas_info")); + }; + + return HEIPumpjackUtil.tooltipStrings(mouseX, mouseY, warnings, reservoir, + this::getAverage, this::getStringWidth); + } + + @Override + public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { + if (Configs.TPConfig.HEIConfig.drawPowerTier) HEIPumpjackUtil.drawPowerTier(minecraft,57, 50, reservoir.getPowerTier()); + if (Configs.TPConfig.HEIConfig.drawSpawnWeight) HEIPumpjackUtil.drawSpawnWeight(minecraft,57, 70, reservoirList.get((PumpjackHandler.ReservoirType) reservoir)); + + int warningCount = 1; + + if (Config.IPConfig.Extraction.req_pipes) { + warningCount++; + } + + if (reservoir.getDrainChance() != 1f) { + warningCount++; + } + + HEIPumpjackUtil.getPumpjackWarning().draw(minecraft, 56, 24); + minecraft.fontRenderer.drawString(String.valueOf(warningCount), 56, 22, 16696077); + + if (getStringWidth() >= 77) { + minecraft.fontRenderer.drawString(minecraft.fontRenderer.trimStringToWidth( + HEIPumpjackUtil.formatString(reservoir.getName()), 68).concat("..."), 6, 6, 15658734); + return; + } + minecraft.fontRenderer.drawString(HEIPumpjackUtil.formatString(reservoir.getName()), 6, 6, 15658734); + } + + @Override + public void onTooltip(int slotIndex, boolean input, GasStack ingredient, List tooltip) { + HEIPumpjackUtil.onTooltip(slotIndex, reservoir, ingredient.amount, ingredient.getGas().getLocalizedName(), tooltip); + } + +} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/client/hei/HEIPlugin.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/HEIPlugin.java similarity index 51% rename from src/main/java/srki2k/tweakedpetroleumgas/client/hei/HEIPlugin.java rename to src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/HEIPlugin.java index a2bbda6..faa0216 100644 --- a/src/main/java/srki2k/tweakedpetroleumgas/client/hei/HEIPlugin.java +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/hei/HEIPlugin.java @@ -1,13 +1,14 @@ -package srki2k.tweakedpetroleumgas.client.hei; +package io.github.srdjanv.tweakedpetroleumgas.client.hei; import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirType; import mezz.jei.api.IModPlugin; import mezz.jei.api.IModRegistry; import mezz.jei.api.recipe.IRecipeCategoryRegistration; -import srki2k.tweakedlib.api.hei.BaseHEIUtil; -import srki2k.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; -import srki2k.tweakedpetroleum.api.ihelpers.IReservoirType; +import io.github.srdjanv.tweakedlib.api.hei.BaseHEIUtil; +import io.github.srdjanv.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; +import java.util.Collection; import java.util.stream.Collectors; @mezz.jei.api.JEIPlugin @@ -22,10 +23,13 @@ public void registerCategories(IRecipeCategoryRegistration registry) { @Override public void register(IModRegistry registry) { registry.handleRecipes(PumpjackHandler.ReservoirType.class, GasPumpjackWrapper::new, GasPumpjackCategory.UID); - registry.addRecipes(PumpjackHandler.reservoirList.keySet().stream(). - filter(reservoirType -> ((IReservoirType)reservoirType).getReservoirContent() == TweakedPumpjackHandler.ReservoirContent.GAS). - collect(Collectors.toList()), GasPumpjackCategory.UID); + registry.addRecipes(getRecipes(), GasPumpjackCategory.UID); registry.addRecipeCatalyst(BaseHEIUtil.getPumpjackCatalyst(), GasPumpjackCategory.UID); } + private Collection getRecipes() { + return PumpjackHandler.reservoirList.keySet().stream(). + filter(reservoirType -> ((ITweakedPetReservoirType) reservoirType).getReservoirContent() == TweakedPumpjackHandler.ReservoirContent.GAS). + collect(Collectors.toList()); + } } diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/model/ModelCoresampleGasExtended.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/model/ModelCoresampleGasExtended.java new file mode 100644 index 0000000..994df10 --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/client/model/ModelCoresampleGasExtended.java @@ -0,0 +1,466 @@ +package io.github.srdjanv.tweakedpetroleumgas.client.model; + +import blusunrize.immersiveengineering.api.tool.ExcavatorHandler; +import blusunrize.immersiveengineering.client.ClientUtils; +import blusunrize.immersiveengineering.common.util.ItemNBTHelper; +import com.google.common.base.Suppliers; +import com.google.common.collect.Lists; +import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import flaxbeard.immersivepetroleum.client.model.ModelCoresampleExtended; +import flaxbeard.immersivepetroleum.common.IPContent; +import flaxbeard.immersivepetroleum.common.blocks.metal.BlockTypes_Dummy; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasReservoirType; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import mekanism.api.gas.Gas; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.client.model.pipeline.LightUtil; +import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; +import net.minecraftforge.fluids.Fluid; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.lwjgl.util.vector.Vector2f; +import org.lwjgl.util.vector.Vector3f; + +import javax.annotation.Nullable; +import java.util.*; +import java.util.function.Supplier; + +public class ModelCoresampleGasExtended extends ModelCoresampleExtended { + private final static Logger logger = LogManager.getLogger(ModelCoresampleGasExtended.class); + + public static Map modelCache = new Object2ObjectOpenHashMap<>(); + private final Supplier contentDataSupplier; + private final ExcavatorHandler.MineralMix mineral; + private final ItemOverrideList overrideList; + private List bakedQuads; + + public ModelCoresampleGasExtended(ExcavatorHandler.MineralMix mineral, + com.google.common.base.Supplier contentDataSupplier) { + super(mineral); + overrideList = new ItemOverrideList(Collections.emptyList()) { + public @NotNull IBakedModel handleItemState(@NotNull IBakedModel originalModel, @NotNull ItemStack stack, World world, EntityLivingBase entity) { + String resName = ItemNBTHelper.hasKey(stack, "resType") ? ItemNBTHelper.getString(stack, "resType") : null; + if (ItemNBTHelper.hasKey(stack, "oil") && resName == null && ItemNBTHelper.getInt(stack, "oil") > 0) { + resName = "oil"; + } + + if (ItemNBTHelper.hasKey(stack, "mineral")) { + final String name = ItemNBTHelper.getString(stack, "mineral"); + String indexName = resName == null ? name : name + "_" + resName; + if (name != null && !name.isEmpty()) { + if (!modelCache.containsKey(indexName)) { + var opMix = ExcavatorHandler.mineralList.keySet() + .stream() + .filter(mixx -> name.equals(mixx.name)) + .findFirst(); + + lableRet: + if (opMix.isPresent()) { + var mix = opMix.get(); + if (resName != null) { + for (PumpjackHandler.ReservoirType type : PumpjackHandler.reservoirList.keySet()) { + if (!resName.equals(type.name)) continue; + + String[] newOres = new String[mix.ores.length + 1]; + float[] newChances = new float[mix.chances.length + 1]; + newOres[mix.ores.length] = "obsidian"; + newChances[mix.ores.length] = 0.4F; + + for (int i = 0; i < mix.ores.length; ++i) { + newOres[i] = mix.ores[i]; + newChances[i] = mix.chances[i]; + } + + ExcavatorHandler.MineralMix mix2 = new ExcavatorHandler.MineralMix(mix.name, mix.failChance, newOres, newChances); + mix2.recalculateChances(); + mix2.oreOutput.set(mix2.oreOutput.size() - 1, new ItemStack(IPContent.blockDummy, 1, BlockTypes_Dummy.OIL_DEPOSIT.getMeta())); + switch (((ITweakedGasReservoirType) type).getReservoirContent()) { + case GAS -> + modelCache.put("_" + resName, new ModelCoresampleGasExtended(mix2, ((ITweakedGasReservoirType) type).getGas())); + case LIQUID -> + modelCache.put("_" + resName, new ModelCoresampleGasExtended(mix2, type.getFluid())); + case EMPTY, DEFAULT -> + modelCache.put("_" + resName, new ModelCoresampleGasExtended(mix2, ContentData.NONE)); + } + break lableRet; + } + + modelCache.put(indexName, new ModelCoresampleGasExtended(mix)); + } else { + modelCache.put(indexName, new ModelCoresampleGasExtended(mix)); + } + } + } + + IBakedModel modelx = modelCache.get(indexName); + if (modelx != null) return modelx; + } + } + + if (resName != null) { + if (!modelCache.containsKey("_" + resName)) { + for (PumpjackHandler.ReservoirType typex : PumpjackHandler.reservoirList.keySet()) { + if (!resName.equals(typex.name)) continue; + + ExcavatorHandler.MineralMix mixx = new ExcavatorHandler.MineralMix(resName, 1.0F, new String[]{"obsidian"}, new float[]{1.0F}); + mixx.recalculateChances(); + mixx.oreOutput.set(0, new ItemStack(IPContent.blockDummy, 1, BlockTypes_Dummy.OIL_DEPOSIT.getMeta())); + switch (((ITweakedGasReservoirType) typex).getReservoirContent()) { + case GAS -> + modelCache.put("_" + resName, new ModelCoresampleGasExtended(mixx, ((ITweakedGasReservoirType) typex).getGas())); + case LIQUID -> + modelCache.put("_" + resName, new ModelCoresampleGasExtended(mixx, typex.getFluid())); + case EMPTY, DEFAULT -> + modelCache.put("_" + resName, new ModelCoresampleGasExtended(mixx, ContentData.NONE)); + } + } + } + + IBakedModel model = modelCache.get("_" + resName); + if (model != null) return model; + } + + return originalModel; + } + }; + + this.mineral = mineral; + this.contentDataSupplier = contentDataSupplier == null ? ContentData.NONE : Suppliers.memoize(contentDataSupplier); + } + + public ModelCoresampleGasExtended(ExcavatorHandler.MineralMix mineral, Gas gas) { + this(mineral, ContentData.gas(gas)); + } + + public ModelCoresampleGasExtended(ExcavatorHandler.MineralMix mineral, Fluid fluid) { + this(mineral, ContentData.fluid(fluid)); + } + + public ModelCoresampleGasExtended(ExcavatorHandler.MineralMix mineral) { + this(mineral, (com.google.common.base.Supplier) null); + } + + public ModelCoresampleGasExtended() { + this(null); + } + + public List getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) { + if (bakedQuads == null) bakedQuads = buildBakedQuads(); + return bakedQuads; + } + + @NotNull + protected List buildBakedQuads() { + List bakedQuads = new ObjectArrayList<>(); + try { + float width = 0.25F; + float depth = 0.25F; + float wOff = (1.0F - width) / 2.0F; + float dOff = (1.0F - depth) / 2.0F; + float fWidth = 0.24F; + float fDepth = 0.24F; + float fWOff = (1.0F - fWidth) / 2.0F; + float fDOff = (1.0F - fDepth) / 2.0F; + int pixelLength = 0; + Object2IntMap textureOre = new Object2IntOpenHashMap<>(); + if (this.mineral != null && this.mineral.oreOutput != null) { + NonNullList oreOutput = this.mineral.oreOutput; + for (int i = 0; i < oreOutput.size(); i++) { + final ItemStack itemStack = oreOutput.get(i); + if (itemStack.isEmpty()) continue; + int weight = Math.max(2, Math.round(16.0F * this.mineral.recalculatedChances[i])); + Block block = Block.getBlockFromItem(itemStack.getItem()); + IBlockState state = block != Blocks.AIR ? block.getStateFromMeta(itemStack.getMetadata()) : Blocks.STONE.getDefaultState(); + IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); + if (block == IPContent.blockDummy) { + textureOre.put(null, weight); + } else { + var particleTexture = model.getParticleTexture(); + if (particleTexture != null) textureOre.put(particleTexture, weight); + } + pixelLength += weight; + } + } else pixelLength = 16; + + TextureAtlasSprite textureStone = ClientUtils.getSprite(new ResourceLocation("blocks/stone")); + Vector2f[] stoneUVs = new Vector2f[]{new Vector2f(textureStone.getInterpolatedU(16.0F * wOff), textureStone.getInterpolatedV((double) (16.0F * dOff))), new Vector2f(textureStone.getInterpolatedU((double) (16.0F * wOff)), textureStone.getInterpolatedV((double) (16.0F * (dOff + depth)))), new Vector2f(textureStone.getInterpolatedU((double) (16.0F * (wOff + width))), textureStone.getInterpolatedV((double) (16.0F * (dOff + depth)))), new Vector2f(textureStone.getInterpolatedU((double) (16.0F * (wOff + width))), textureStone.getInterpolatedV((double) (16.0F * dOff)))}; + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, -1.0F, 0.0F), + new Vector3f[]{ + new Vector3f(wOff, 0.0F, dOff), + new Vector3f(wOff + width, 0.0F, dOff), + new Vector3f(wOff + width, 0.0F, dOff + depth), + new Vector3f(wOff, 0.0F, dOff + depth)}, + stoneUVs, textureStone); + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, 1.0F, 0.0F), + new Vector3f[]{ + new Vector3f(wOff, 1.0F, dOff), + new Vector3f(wOff, 1.0F, dOff + depth), + new Vector3f(wOff + width, 1.0F, dOff + depth), + new Vector3f(wOff + width, 1.0F, dOff)}, + stoneUVs, textureStone); + if (textureOre.isEmpty()) { + Vector2f[][] uvs = new Vector2f[4][]; + + for (int j = 0; j < 4; ++j) { + uvs[j] = new Vector2f[]{ + new Vector2f(textureStone.getInterpolatedU(j * 4), textureStone.getInterpolatedV(0.0)), + new Vector2f(textureStone.getInterpolatedU(j * 4), textureStone.getInterpolatedV(16.0)), + new Vector2f(textureStone.getInterpolatedU((j + 1) * 4), textureStone.getInterpolatedV(16.0)), + new Vector2f(textureStone.getInterpolatedU((j + 1) * 4), textureStone.getInterpolatedV(0.0))}; + } + + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, 0.0F, -1.0F), + new Vector3f[]{ + new Vector3f(wOff, 0.0F, dOff), + new Vector3f(wOff, 1.0F, dOff), + new Vector3f(wOff + width, 1.0F, dOff), + new Vector3f(wOff + width, 0.0F, dOff)}, + uvs[0], textureStone); + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, 0.0F, 1.0F), + new Vector3f[]{ + new Vector3f(wOff + width, 0.0F, dOff + depth), + new Vector3f(wOff + width, 1.0F, dOff + depth), + new Vector3f(wOff, 1.0F, dOff + depth), + new Vector3f(wOff, 0.0F, dOff + depth)}, + uvs[2], textureStone); + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(-1.0F, 0.0F, 0.0F), + new Vector3f[]{ + new Vector3f(wOff, 0.0F, dOff + depth), + new Vector3f(wOff, 1.0F, dOff + depth), + new Vector3f(wOff, 1.0F, dOff), + new Vector3f(wOff, 0.0F, dOff)}, + uvs[3], textureStone); + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(1.0F, 0.0F, 0.0F), + new Vector3f[]{ + new Vector3f(wOff + width, 0.0F, dOff), + new Vector3f(wOff + width, 1.0F, dOff), + new Vector3f(wOff + width, 1.0F, dOff + depth), + new Vector3f(wOff + width, 0.0F, dOff + depth)}, + uvs[1], textureStone); + } else { + float h = 0.0F; + + float h1; + + for (Object2IntMap.Entry entry : textureOre.object2IntEntrySet()) { + TextureAtlasSprite sprite = entry.getKey(); + final int weight = entry.getIntValue(); + int v = weight > 8 ? 16 - weight : 8; + if (sprite == null) { + TextureAtlasSprite fSprite = null; + int tint = -1; + if (contentDataSupplier.get() != null) { + fSprite = contentDataSupplier.get().sprite; + tint = contentDataSupplier.get().tint; + } + + if (fSprite != null) { + Vector2f[][] uvs = new Vector2f[4][]; + + for (int j = 0; j < 4; ++j) { + uvs[j] = new Vector2f[]{ + new Vector2f(fSprite.getInterpolatedU(j * 4), fSprite.getInterpolatedV(v)), + new Vector2f(fSprite.getInterpolatedU(j * 4), fSprite.getInterpolatedV(v + weight)), + new Vector2f(fSprite.getInterpolatedU((j + 1) * 4), fSprite.getInterpolatedV(v + weight)), + new Vector2f(fSprite.getInterpolatedU((j + 1) * 4), fSprite.getInterpolatedV(v))}; + } + + h1 = (float) weight / (float) pixelLength; + putTintedVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, 0.0F, -1.0F), + new Vector3f[]{new Vector3f(fWOff, h, fDOff), + new Vector3f(fWOff, h + h1, fDOff), + new Vector3f(fWOff + fWidth, h + h1, fDOff), + new Vector3f(fWOff + fWidth, h, fDOff)}, + uvs[0], fSprite, tint); + + putTintedVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, 0.0F, 1.0F), + new Vector3f[]{new Vector3f(fWOff + fWidth, h, fDOff + fDepth), + new Vector3f(fWOff + fWidth, h + h1, fDOff + fDepth), + new Vector3f(fWOff, h + h1, fDOff + fDepth), + new Vector3f(fWOff, h, fDOff + fDepth)}, + uvs[2], fSprite, tint); + putTintedVertexDataSpr( + bakedQuads, + new Vector3f(-1.0F, 0.0F, 0.0F), + new Vector3f[]{new Vector3f(fWOff, h, fDOff + fDepth), + new Vector3f(fWOff, h + h1, fDOff + fDepth), + new Vector3f(fWOff, h + h1, fDOff), + new Vector3f(fWOff, h, fDOff)}, + uvs[3], fSprite, tint); + putTintedVertexDataSpr( + bakedQuads, + new Vector3f(1.0F, 0.0F, 0.0F), + new Vector3f[]{new Vector3f(fWOff + fWidth, h, fDOff), + new Vector3f(fWOff + fWidth, h + h1, fDOff), + new Vector3f(fWOff + fWidth, h + h1, fDOff + fDepth), + new Vector3f(fWOff + fWidth, h, fDOff + fDepth)}, + uvs[1], fSprite, tint); + } + + IBlockState state = IPContent.blockDummy.getStateFromMeta(BlockTypes_Dummy.OIL_DEPOSIT.getMeta()); + IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); + sprite = model.getParticleTexture(); + } + + Vector2f[][] uvs = new Vector2f[4][]; + + for (int j = 0; j < 4; ++j) { + uvs[j] = new Vector2f[]{ + new Vector2f(sprite.getInterpolatedU(j * 4), sprite.getInterpolatedV(v)), + new Vector2f(sprite.getInterpolatedU(j * 4), sprite.getInterpolatedV(v + weight)), + new Vector2f(sprite.getInterpolatedU((j + 1) * 4), sprite.getInterpolatedV(v + weight)), + new Vector2f(sprite.getInterpolatedU((j + 1) * 4), sprite.getInterpolatedV(v))}; + } + + h1 = (float) weight / (float) pixelLength; + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, 0.0F, -1.0F), + new Vector3f[]{ + new Vector3f(wOff, h, dOff), + new Vector3f(wOff, h + h1, dOff), + new Vector3f(wOff + width, h + h1, dOff), + new Vector3f(wOff + width, h, dOff)}, + uvs[0], sprite); + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(0.0F, 0.0F, 1.0F), + new Vector3f[]{ + new Vector3f(wOff + width, h, dOff + depth), + new Vector3f(wOff + width, h + h1, dOff + depth), + new Vector3f(wOff, h + h1, dOff + depth), + new Vector3f(wOff, h, dOff + depth)}, + uvs[2], sprite); + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(-1.0F, 0.0F, 0.0F), + new Vector3f[]{ + new Vector3f(wOff, h, dOff + depth), + new Vector3f(wOff, h + h1, dOff + depth), + new Vector3f(wOff, h + h1, dOff), + new Vector3f(wOff, h, dOff)}, + uvs[3], sprite); + putNormalVertexDataSpr( + bakedQuads, + new Vector3f(1.0F, 0.0F, 0.0F), + new Vector3f[]{ + new Vector3f(wOff + width, h, dOff), + new Vector3f(wOff + width, h + h1, dOff), + new Vector3f(wOff + width, h + h1, dOff + depth), + new Vector3f(wOff + width, h, dOff + depth)}, + uvs[1], sprite); + + h += h1; + } + } + } catch (Throwable e) { + logger.warn(e.getLocalizedMessage()); + bakedQuads = Collections.emptyList(); + } + + return bakedQuads; + } + + protected void putNormalVertexDataSpr(List bakedQuads , + Vector3f normal, + Vector3f[] vertices, + Vector2f[] uvs, + TextureAtlasSprite sprite) { + putTintedVertexDataSpr(bakedQuads, normal, vertices, uvs, sprite, -1); + } + + protected void putTintedVertexDataSpr(List bakedQuads, + Vector3f normal, + Vector3f[] vertices, + Vector2f[] uvs, + TextureAtlasSprite sprite, int tint) { + + UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(DefaultVertexFormats.ITEM); + builder.setQuadOrientation(EnumFacing.getFacingFromVector(normal.x, normal.y, normal.z)); + builder.setTexture(sprite); + builder.setQuadTint(tint); + + for (int i = 0; i < vertices.length; ++i) { + builder.put(0, vertices[i].x, vertices[i].y, vertices[i].z, 1.0F); + float d = LightUtil.diffuseLight(normal.x, normal.y, normal.z); + builder.put(1, d, d, d, 1.0F); + builder.put(2, uvs[i].x, uvs[i].y, 0.0F, 1.0F); + builder.put(3, normal.x, normal.y, normal.z, 0.0F); + builder.put(4); + } + + bakedQuads.add(builder.build()); + } + + public ItemOverrideList getOverrides() { + return this.overrideList; + } + + public static class ContentData { + public static final com.google.common.base.Supplier NONE = () -> null; + + public static com.google.common.base.Supplier gas(Gas gas) { + return () -> new ContentData(gas.getSprite(), gas.getTint()); + } + + public static com.google.common.base.Supplier fluid(Fluid fluid) { + return () -> new ContentData(Minecraft.getMinecraft() + .getTextureMapBlocks().getAtlasSprite(fluid.getStill().toString()), + fluid.getColor()); + } + + private final TextureAtlasSprite sprite; + private final int tint; + + public ContentData(TextureAtlasSprite sprite, int tint) { + this.sprite = sprite; + this.tint = tint; + } + + public ContentData(TextureAtlasSprite sprite) { + this(sprite, -1); + } + + public TextureAtlasSprite getSprite() { + return sprite; + } + + public int getTint() { + return tint; + } + } +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/Configs.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/Configs.java new file mode 100644 index 0000000..9af8674 --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/Configs.java @@ -0,0 +1,20 @@ +package io.github.srdjanv.tweakedpetroleumgas.common; + + +import io.github.srdjanv.tweakedpetroleumgas.TweakedPetroleumGas; +import net.minecraftforge.common.config.Config; + +import static net.minecraftforge.common.config.Config.*; + +@Config(modid = TweakedPetroleumGas.MODID) +public class Configs { + public static ClientConfig clientConfig = new ClientConfig(); + + public static class ClientConfig { + @RequiresMcRestart + @Name("Replace Core Sample Model") + @Comment("This will enable correct gas reservoir rendering, In case of errors disable") + public boolean replaceCoreSampleModel = true; + + } +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/crafttweaker/TweakedGasReservoir.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/crafttweaker/TweakedGasReservoir.java new file mode 100644 index 0000000..4d1310c --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/crafttweaker/TweakedGasReservoir.java @@ -0,0 +1,75 @@ +package io.github.srdjanv.tweakedpetroleumgas.common.compat.crafttweaker; + + +import crafttweaker.CraftTweakerAPI; +import crafttweaker.annotations.ZenRegister; +import io.github.srdjanv.tweakedlib.api.powertier.PowerTierHandler; +import io.github.srdjanv.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirType; +import io.github.srdjanv.tweakedpetroleum.util.ReservoirValidation; +import mekanism.common.integration.crafttweaker.gas.IGasStack; +import stanhebben.zenscript.annotations.Optional; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@SuppressWarnings("unused") +@ZenClass("mods.TweakedPetroleum.TweakedGasReservoir") +@ZenRegister +public class TweakedGasReservoir { + + @ZenMethod + public static void registerGasReservoir(String name, IGasStack gas, int minSize, int maxSize, int replenishRate, int pumpSpeed, int weight, int powerTier, + @Optional int[] dimBlacklist, @Optional int[] dimWhitelist, @Optional String[] biomeBlacklist, @Optional String[] biomeWhitelist) { + + + ITweakedPetReservoirType res; + if (ReservoirValidation.validateReservoir(CraftTweakerAPI::logError, name, gas, + minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier, + biomeBlacklist, biomeWhitelist)) { + res = TweakedPumpjackHandler.addTweakedReservoir(name, gas.getName(), minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier); + } else { + if (name != null && !name.isEmpty()) { + CraftTweakerAPI.logError(String.format("Added dummy gas reservoir: %s", name)); + TweakedPumpjackHandler.addTweakedReservoir(name, "water", 0, 10, 0, 10, 0, PowerTierHandler.getFallbackPowerTier().getId()); + } + return; + } + + res.setReservoirContent(TweakedPumpjackHandler.ReservoirContent.GAS); + res.setDimensionBlacklist(dimBlacklist); + res.setDimensionWhitelist(dimWhitelist); + res.setBiomeBlacklist(biomeBlacklist); + res.setBiomeWhitelist(biomeWhitelist); + + CraftTweakerAPI.logInfo("Added Gas Reservoir Type: " + name); + } + + @ZenMethod + public static void registerGasReservoirWithDrainChance(String name, IGasStack gas, int minSize, int maxSize, int replenishRate, int pumpSpeed, float drainChance, int weight, int powerTier, + @Optional int[] dimBlacklist, @Optional int[] dimWhitelist, @Optional String[] biomeBlacklist, @Optional String[] biomeWhitelist) { + + ITweakedPetReservoirType res; + if (ReservoirValidation.validateReservoir(CraftTweakerAPI::logError, name, gas, + minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier, drainChance, + biomeBlacklist, biomeWhitelist)) { + res = TweakedPumpjackHandler.addTweakedReservoir(name, gas.getName(), minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier); + } else { + if (name != null && !name.isEmpty()) { + CraftTweakerAPI.logError(String.format("Added dummy gas reservoir: %s", name)); + TweakedPumpjackHandler.addTweakedReservoir(name, "water", 0, 10, 0, 10, 0, PowerTierHandler.getFallbackPowerTier().getId()); + } + return; + } + + res.setReservoirContent(TweakedPumpjackHandler.ReservoirContent.GAS); + res.setDrainChance(drainChance); + if (dimBlacklist != null) res.setDimensionBlacklist(dimBlacklist); + if (dimWhitelist != null) res.setDimensionWhitelist(dimWhitelist); + if (biomeBlacklist != null) res.setBiomeBlacklist(biomeBlacklist); + if (biomeWhitelist != null) res.setBiomeWhitelist(biomeWhitelist); + + CraftTweakerAPI.logInfo("Added Gas Reservoir Type: " + name); + + } + +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/groovy/GasReservoir.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/groovy/GasReservoir.java new file mode 100644 index 0000000..d0afa05 --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/groovy/GasReservoir.java @@ -0,0 +1,97 @@ +package io.github.srdjanv.tweakedpetroleumgas.common.compat.groovy; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import io.github.srdjanv.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirType; +import io.github.srdjanv.tweakedpetroleum.common.compat.groovy.VirtualizedReservoirRegistry; +import io.github.srdjanv.tweakedpetroleum.util.ReservoirValidation; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasReservoirType; +import mekanism.api.gas.GasStack; + +import java.util.Arrays; +import java.util.function.BiFunction; + +public class GasReservoir extends VirtualizedReservoirRegistry< + ITweakedGasReservoirType, + GasReservoir.GasReservoirBuilder, + GasReservoir.GasReservoirWrapper> { + + + public GasReservoir() { + super("Gas"); + } + + @Override protected BiFunction getReservoirTypeWrapperFunction() { + return GasReservoirWrapper::new; + } + + @Override public GasReservoirBuilder recipeBuilder() { + return new GasReservoirBuilder(); + } + + public class GasReservoirBuilder extends ReservoirBuilder { + protected GasStack gas; + + public GasReservoirBuilder gas(GasStack gas) { + this.gas = gas; + return this; + } + + @Override + public boolean validate() { + GroovyLog.Msg msg = GroovyLog.msg("Error adding custom gas reservoir").error(); + ReservoirValidation.validateReservoir(msg::add, name, gas, minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier, drainChance, + biomeBlacklist == null ? null : biomeBlacklist.toArray(new String[]{}), biomeWhitelist == null ? null : biomeWhitelist.toArray(new String[]{})); + + return !msg.postIfNotEmpty(); + } + + @SuppressWarnings("UnreachableCode") @Override + public GasReservoirWrapper register() { + if (!validate()) return null; + ITweakedGasReservoirType res = (ITweakedGasReservoirType) + new PumpjackHandler.ReservoirType(name, gas.getGas().getName(), minSize, maxSize, replenishRate); + + res.setDrainChance(drainChance); + res.setPumpSpeed(pumpSpeed); + res.setPowerTier(powerTier); + res.setReservoirContent(TweakedPumpjackHandler.ReservoirContent.GAS); + if (dimBlacklist != null) res.setDimensionBlacklist(dimBlacklist.stream().mapToInt(Integer::intValue).toArray()); + if (dimWhitelist != null) res.setDimensionWhitelist(dimWhitelist.stream().mapToInt(Integer::intValue).toArray()); + if (biomeBlacklist != null) res.setBiomeBlacklist(biomeBlacklist.toArray(new String[]{})); + if (biomeWhitelist != null) res.setBiomeWhitelist(biomeWhitelist.toArray(new String[]{})); + + GasReservoirWrapper wrapper = new GasReservoirWrapper(res, weight); + add(wrapper); + return wrapper; + } + } + + public class GasReservoirWrapper extends ReservoirWrapper { + private final ITweakedGasReservoirType reservoirType; + + public GasReservoirWrapper(ITweakedGasReservoirType reservoirType, int weight) { + this((PumpjackHandler.ReservoirType) reservoirType, weight); + } + + public GasReservoirWrapper(PumpjackHandler.ReservoirType reservoirType, int weight) { + super(GasReservoir.this::recipeBuilder, reservoirType, weight); + this.reservoirType = (ITweakedGasReservoirType) reservoirType; + } + + @Override + public ITweakedGasReservoirType getRealReservoirType() { + return reservoirType; + } + + @Override public GasReservoirBuilder toBuilder() { + remove(this); + GasReservoirBuilder builder = super.toBuilder(); + builder.gas(new GasStack(getRealReservoirType().getGas(), 1000)); + return builder; + } + + } + +} diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/groovy/GroovyCompat.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/groovy/GroovyCompat.java new file mode 100644 index 0000000..8b0608e --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/common/compat/groovy/GroovyCompat.java @@ -0,0 +1,17 @@ +package io.github.srdjanv.tweakedpetroleumgas.common.compat.groovy; + +import io.github.srdjanv.tweakedlib.common.Constants; +import io.github.srdjanv.tweakedlib.common.compat.groovyscript.GroovyScriptRegistry; +import io.github.srdjanv.tweakedpetroleumgas.util.TweakedPetroleumGasInitializer; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class GroovyCompat implements TweakedPetroleumGasInitializer { + + @Override public boolean shouldRun() { + return Constants.isGroovyScriptLoaded(); + } + + @Override public void preInit(FMLPreInitializationEvent event) { + GroovyScriptRegistry.getRegistry().addRegistry(new GasReservoir()); + } +} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/core/TweakedPetroleumGasPlugin.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/core/TweakedPetroleumGasPlugin.java similarity index 94% rename from src/main/java/srki2k/tweakedpetroleumgas/core/TweakedPetroleumGasPlugin.java rename to src/main/java/io/github/srdjanv/tweakedpetroleumgas/core/TweakedPetroleumGasPlugin.java index 24fac1d..c97a129 100644 --- a/src/main/java/srki2k/tweakedpetroleumgas/core/TweakedPetroleumGasPlugin.java +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/core/TweakedPetroleumGasPlugin.java @@ -1,4 +1,4 @@ -package srki2k.tweakedpetroleumgas.core; +package io.github.srdjanv.tweakedpetroleumgas.core; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import zone.rong.mixinbooter.ILateMixinLoader; diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinClientProxy.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinClientProxy.java new file mode 100644 index 0000000..1c9e109 --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinClientProxy.java @@ -0,0 +1,155 @@ +package io.github.srdjanv.tweakedpetroleumgas.mixin; + + +import blusunrize.immersiveengineering.api.ManualHelper; +import blusunrize.lib.manual.IManualPage; +import blusunrize.lib.manual.ManualInstance; +import blusunrize.lib.manual.ManualPages; +import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import flaxbeard.immersivepetroleum.client.ClientProxy; +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirType; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasReservoirType; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import mekanism.api.gas.GasStack; +import mekanism.common.MekanismBlocks; +import mekanism.common.item.ItemBlockGasTank; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.UniversalBucket; +import net.minecraftforge.fluids.capability.IFluidHandlerItem; +import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import java.text.DecimalFormat; +import java.util.*; + +@Mixin(value = ClientProxy.class, remap = false) +public abstract class MixinClientProxy { + + @Shadow + static ManualInstance.ManualEntry resEntry; + + + @Overwrite + public static void handleReservoirManual() { + if (ManualHelper.getManual() != null) { + DecimalFormat f = new DecimalFormat("#,###.##"); + List pages = new ObjectArrayList<>(); + pages.add(new ManualPages.Text(ManualHelper.getManual(), "oil0")); + pages.add(new ManualPages.Text(ManualHelper.getManual(), "oil1")); + PumpjackHandler.ReservoirType[] reservoirTypes = PumpjackHandler.reservoirList.keySet().toArray(new PumpjackHandler.ReservoirType[0]); + StringBuilder builder = new StringBuilder(); + StringBuilder dimBuilder = new StringBuilder(); + StringBuilder biomeBuilder = new StringBuilder(); + + resLoop: + for (PumpjackHandler.ReservoirType type : reservoirTypes) { + String name = "desc.immersivepetroleum.info.reservoir." + type.name; + String localizedName = I18n.format(name); + if (localizedName.equalsIgnoreCase(name)) localizedName = type.name; + + boolean isVowel = localizedName.toLowerCase().charAt(0) == 'a' || localizedName.toLowerCase().charAt(0) == 'e' || localizedName.toLowerCase().charAt(0) == 'i' || localizedName.toLowerCase().charAt(0) == 'o' || localizedName.toLowerCase().charAt(0) == 'u'; + String aOrAn = I18n.format(isVowel ? "ie.manual.entry.oilVowel" : "ie.manual.entry.oilConsonant"); + builder.setLength(0); + dimBuilder.setLength(0); + biomeBuilder.setLength(0); + + if ((type.dimensionWhitelist != null && type.dimensionWhitelist.length > 0) || (type.dimensionBlacklist != null && type.dimensionBlacklist.length > 0)) { + if (type.dimensionWhitelist != null && type.dimensionWhitelist.length > 0) { + builder.setLength(0); + for (int dim : type.dimensionWhitelist) + builder.append(builder.length() != 0 ? ", " : "").append(""); + + dimBuilder.append(I18n.format("ie.manual.entry.oilDimValid", localizedName, builder, aOrAn)); + } else { + builder.setLength(0); + for (int dim : type.dimensionBlacklist) + builder.append(builder.length() != 0 ? ", " : "").append(""); + + dimBuilder.append(I18n.format("ie.manual.entry.oilDimInvalid", localizedName, builder, aOrAn)); + } + + } else dimBuilder.append(I18n.format("ie.manual.entry.oilDimAny", localizedName, aOrAn)); + + if ((type.biomeWhitelist != null && type.biomeWhitelist.length > 0) || (type.biomeBlacklist != null && type.biomeBlacklist.length > 0)) { + if (type.biomeWhitelist != null && type.biomeWhitelist.length > 0) { + builder.setLength(0); + for (String biome : type.biomeWhitelist) + builder.append(builder.length() != 0 ? ", " : "").append(PumpjackHandler.getTagDisplayName(biome)); + biomeBuilder.append(I18n.format("ie.manual.entry.oilBiomeValid", builder)); + } else { + builder.setLength(0); + for (String biome : type.biomeBlacklist) + builder.append(builder.length() != 0 ? ", " : "").append(PumpjackHandler.getTagDisplayName(biome)); + + biomeBuilder.append(I18n.format("ie.manual.entry.oilBiomeInvalid", builder)); + } + + } else biomeBuilder.append(I18n.format("ie.manual.entry.oilBiomeAny")); + + + String resContent = ""; + ItemStack displayStack = ItemStack.EMPTY; + ITweakedPetReservoirType tweakedType = (ITweakedPetReservoirType) type; + switch (tweakedType.getReservoirContent()) { + case GAS -> { + var gasType = (ITweakedGasReservoirType) tweakedType; + resContent = gasType.getGas().getLocalizedName(); + displayStack = new ItemStack(MekanismBlocks.GasTank); + var blockGasTank = (ItemBlockGasTank) ItemBlockGasTank.getItemFromBlock(MekanismBlocks.GasTank); + blockGasTank.addGas(displayStack, new GasStack(gasType.getGas(), Integer.MAX_VALUE)); + } + case LIQUID -> { + Fluid fluid = type.getFluid(); + if (fluid != null) { + String unlocalizedName = fluid.getUnlocalizedName(); + resContent = unlocalizedName == null ? "" : I18n.format(unlocalizedName); + } + + UniversalBucket bucket = ForgeModContainer.getInstance().universalBucket; + ItemStack stack = new ItemStack(bucket); + FluidStack fs = new FluidStack(fluid, bucket.getCapacity()); + IFluidHandlerItem fluidHandler = new FluidBucketWrapper(stack); + fluidHandler.fill(fs, true); + displayStack = fluidHandler.getContainer(); + } + case EMPTY, DEFAULT -> { + continue resLoop; + } + } + + String replenishRate = ""; + if (type.replenishRate > 0) + replenishRate = I18n.format("ie.manual.entry.oilReplenish", type.replenishRate, resContent); + + pages.add(new ManualPages.ItemDisplay(ManualHelper.getManual(), switch (tweakedType.getReservoirContent()) { + case LIQUID -> I18n.format("ie.manual.entry.oil2", + dimBuilder, resContent, + f.format(type.minSize), f.format(type.maxSize), + replenishRate, biomeBuilder); + case GAS -> I18n.format("ie.manual.entry.oil2", + dimBuilder, resContent, + f.format(type.minSize), f.format(type.maxSize), + replenishRate, biomeBuilder) + .replace("fluid reservoir", "gas reservoir");//todo fix, wont work if localized + case EMPTY, DEFAULT -> { + throw new IllegalStateException(); + } + }, displayStack)); + } + + if (resEntry != null) { + resEntry.setPages(pages.toArray(new IManualPage[0])); + } else { + ManualHelper.addEntry("oil", "ip", pages.toArray(new IManualPage[0])); + resEntry = ManualHelper.getManual().getEntry("oil"); + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinEventHandler.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinEventHandler.java new file mode 100644 index 0000000..7fdf7fe --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinEventHandler.java @@ -0,0 +1,157 @@ +package io.github.srdjanv.tweakedpetroleumgas.mixin; + +import blusunrize.immersiveengineering.client.ClientProxy; +import blusunrize.immersiveengineering.client.ClientUtils; +import blusunrize.immersiveengineering.common.Config; +import blusunrize.immersiveengineering.common.blocks.stone.TileEntityCoresample; +import blusunrize.immersiveengineering.common.items.ItemCoresample; +import blusunrize.immersiveengineering.common.util.ItemNBTHelper; +import blusunrize.immersiveengineering.common.util.Utils; +import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import flaxbeard.immersivepetroleum.common.EventHandler; +import flaxbeard.immersivepetroleum.common.entity.EntitySpeedboat; +import io.github.srdjanv.tweakedpetroleum.api.mixins.ITweakedPetReservoirType; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasReservoirType; +import mekanism.api.gas.Gas; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.RayTraceResult; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +import java.text.DecimalFormat; +import java.util.List; +import java.util.Optional; + +@Mixin(value = EventHandler.class, remap = false) +public abstract class MixinEventHandler { + + @Overwrite + @SubscribeEvent + static void handleItemTooltip(ItemTooltipEvent event) { + final ItemStack stack = event.getItemStack(); + if (!(stack.getItem() instanceof ItemCoresample) || !ItemNBTHelper.hasKey(stack, "oil")) return; + final List tooltip = event.getToolTip(); + final String resName; + if (ItemNBTHelper.hasKey(stack, "resType")) { + resName = ItemNBTHelper.getString(stack, "resType"); + } else resName = null; + + Optional res = PumpjackHandler.reservoirList.keySet().stream() + .map(reservoirType -> (ITweakedPetReservoirType) reservoirType) + .filter(reservoirType -> reservoirType.getName().equals(resName)) + .findFirst(); + + if (res.isPresent()) { + ITweakedPetReservoirType reservoirType = res.get(); + int amount = ItemNBTHelper.getInt(stack, "oil"); + String localizedName; + switch (reservoirType.getReservoirContent()) { + case LIQUID -> { + Fluid fluid = ((PumpjackHandler.ReservoirType) reservoirType).getFluid(); + localizedName = I18n.format(fluid.getUnlocalizedName()); + } + case GAS -> { + Gas gas = ((ITweakedGasReservoirType) reservoirType).getGas(); + localizedName = gas.getLocalizedName(); + } + default -> { + return; + } + } + if (amount > 0) { + int est = amount / 1000 * 1000; + tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.oil", (new DecimalFormat("#,###.##")).format(est), localizedName)); + } else if (reservoirType.getReplenishRate() > 0) { + tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.oilRep", reservoirType.getReplenishRate(), localizedName)); + } + } else tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.noOil")); + } + + @Overwrite + @SubscribeEvent + static void renderCoresampleInfo(RenderGameOverlayEvent.Post event) { + if (ClientUtils.mc().player == null || event.getType() != RenderGameOverlayEvent.ElementType.TEXT) return; + + EntityPlayer player = ClientUtils.mc().player; + if (ClientUtils.mc().objectMouseOver == null) return; + + boolean hammer = player.getHeldItem(EnumHand.MAIN_HAND) != null && Utils.isHammer(player.getHeldItem(EnumHand.MAIN_HAND)); + RayTraceResult mop = ClientUtils.mc().objectMouseOver; + if (mop == null) return; + + switch (mop.typeOfHit) { + case BLOCK -> { + if (!(player.world.getTileEntity(mop.getBlockPos()) instanceof TileEntityCoresample coresampleTile)) return; + String[] text = coresampleTile.getOverlayText(ClientUtils.mc().player, mop, hammer); + boolean useNixie = coresampleTile.useNixieFont(ClientUtils.mc().player, mop); + ItemStack coresample = coresampleTile.coresample; + if (!ItemNBTHelper.hasKey(coresample, "oil") || text == null || text.length == 0) return; + final String resName = ItemNBTHelper.hasKey(coresample, "resType") ? ItemNBTHelper.getString(coresample, "resType") : ""; + int amount = ItemNBTHelper.getInt(coresample, "oil"); + + Optional res = PumpjackHandler.reservoirList.keySet().stream(). + map(reservoirType -> (ITweakedPetReservoirType) reservoirType). + filter(reservoirType -> reservoirType.getName().equals(resName)). + findFirst(); + + String tooltip = null; + if (res.isPresent()) { + ITweakedPetReservoirType reservoirType = res.get(); + String localizedName; + switch (reservoirType.getReservoirContent()) { + case LIQUID -> { + Fluid fluid = ((PumpjackHandler.ReservoirType) reservoirType).getFluid(); + localizedName = I18n.format(fluid.getUnlocalizedName()); + } + case GAS -> { + Gas gas = ((ITweakedGasReservoirType) reservoirType).getGas(); + localizedName = gas.getLocalizedName(); + } + default -> { + return; + } + } + if (amount > 0) { + int est = amount / 1000 * 1000; + tooltip = I18n.format("chat.immersivepetroleum.info.coresample.oil", (new DecimalFormat("#,###.##")).format(est), localizedName); + } else if (reservoirType.getReplenishRate() > 0) + tooltip = I18n.format("chat.immersivepetroleum.info.coresample.oilRep", reservoirType.getReplenishRate(), localizedName); + } else { + tooltip = I18n.format("chat.immersivepetroleum.info.coresample.noOil"); + } + + if (tooltip != null) { + FontRenderer font = useNixie ? ClientProxy.nixieFontOptional : ClientUtils.font(); + int col = useNixie && Config.IEConfig.nixietubeFont ? 16750848 : 16777215; + int i = text.length; + font.drawString(tooltip, (float) (event.getResolution().getScaledWidth() / 2 + 8), (float) (event.getResolution().getScaledHeight() / 2 + 8 + i * font.FONT_HEIGHT), col, true); + } + } + + case ENTITY -> { + if (!(mop.entityHit instanceof EntitySpeedboat)) return; + String[] text = ((EntitySpeedboat) mop.entityHit).getOverlayText(ClientUtils.mc().player, mop); + if (text == null) return; + + int i = 0; + FontRenderer font = ClientUtils.font(); + for (String t : text) { + if (t != null) + font.drawString(t, + (float) (event.getResolution().getScaledWidth() / 2 + 8), + (float) (event.getResolution().getScaledHeight() / 2 + 8 + i++ * font.FONT_HEIGHT), + 16777215, true); + } + } + } + } + +} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinReservoirType.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinReservoirType.java similarity index 74% rename from src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinReservoirType.java rename to src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinReservoirType.java index a8dccd9..53ab21a 100644 --- a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinReservoirType.java +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinReservoirType.java @@ -1,15 +1,15 @@ -package srki2k.tweakedpetroleumgas.mixin; +package io.github.srdjanv.tweakedpetroleumgas.mixin; import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasReservoirType; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import srki2k.tweakedpetroleumgas.api.util.IGasReservoirType; @Mixin(value = PumpjackHandler.ReservoirType.class, remap = false) -public abstract class MixinReservoirType implements IGasReservoirType { +public abstract class MixinReservoirType implements ITweakedGasReservoirType { @Shadow public String fluid; diff --git a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinTileEntityPumpjack.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinTileEntityPumpjack.java similarity index 78% rename from src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinTileEntityPumpjack.java rename to src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinTileEntityPumpjack.java index 8fca24c..a51aeeb 100644 --- a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinTileEntityPumpjack.java +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/mixin/MixinTileEntityPumpjack.java @@ -1,28 +1,24 @@ -package srki2k.tweakedpetroleumgas.mixin; +package io.github.srdjanv.tweakedpetroleumgas.mixin; import blusunrize.immersiveengineering.api.MultiblockHandler; import blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe; import blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal; import flaxbeard.immersivepetroleum.common.blocks.metal.TileEntityPumpjack; -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTank; -import mekanism.api.gas.IGasHandler; +import io.github.srdjanv.tweakedpetroleumgas.api.mixins.ITweakedGasPumpjackAddons; +import mekanism.api.gas.*; import mekanism.common.capabilities.Capabilities; import mekanism.common.util.GasUtils; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import org.spongepowered.asm.mixin.*; -import srki2k.tweakedpetroleumgas.api.crafting.TweakedGasPumpjackHandler; -import srki2k.tweakedpetroleumgas.api.util.IGasPumpjackAddons; -import srki2k.tweakedpetroleumgas.common.gaspumpjack.DummyMultiblockGasWrapper; +import io.github.srdjanv.tweakedpetroleumgas.api.crafting.TweakedGasPumpjackHandler; import javax.annotation.Nullable; @SuppressWarnings("NullableProblems") @Mixin(value = TileEntityPumpjack.class, remap = false, priority = 950) -public abstract class MixinTileEntityPumpjack extends TileEntityMultiblockMetal implements IGasPumpjackAddons { +public abstract class MixinTileEntityPumpjack extends TileEntityMultiblockMetal implements ITweakedGasPumpjackAddons, IGasHandler { @Shadow public abstract void extractOil(int drained); @@ -31,9 +27,6 @@ public MixinTileEntityPumpjack(MultiblockHandler.IMultiblock mutliblockInstance, super(mutliblockInstance, structureDimensions, energyCapacity, redstoneControl); } - @Unique - GasTank fakeGasTank = new GasTank(0); - @Unique @Override public boolean caseGas(int consumed, int pumpSpeed, int oilAmnt) { @@ -77,29 +70,26 @@ public Gas getGas() { @Unique @Override - public GasTank[] getAccessibleGasTanks(EnumFacing side) { + public GasTankInfo[] getAccessibleGasTanks(EnumFacing side) { TileEntityPumpjack master = this.master(); - if (master != null) { if (this.pos == 9 && (side == null || side == this.facing.rotateY() || side == this.facing.getOpposite().rotateY())) { - return new GasTank[]{fakeGasTank}; + return new GasTank[]{new GasTank(0)}; } if (this.pos == 11 && (side == null || side == this.facing.rotateY() || side == this.facing.getOpposite().rotateY())) { - return new GasTank[]{fakeGasTank}; + return new GasTank[]{new GasTank(0)}; } - } - return new GasTank[0]; + return NONE; } @Unique @Override public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { - if (capability == Capabilities.GAS_HANDLER_CAPABILITY && this.getAccessibleGasTanks(facing).length > 0) { + if (capability == Capabilities.GAS_HANDLER_CAPABILITY && this.getAccessibleGasTanks(facing).length > 0) return true; - } return super.hasCapability(capability, facing); } @@ -108,11 +98,29 @@ public boolean hasCapability(Capability capability, @Nullable EnumFacing faci @Override @SuppressWarnings("unchecked") public T getCapability(Capability capability, @Nullable EnumFacing facing) { - if (capability == Capabilities.GAS_HANDLER_CAPABILITY && this.getAccessibleGasTanks(facing).length > 0) { - return (T) DummyMultiblockGasWrapper.INSTANCE; - } + if (capability == Capabilities.GAS_HANDLER_CAPABILITY && this.getAccessibleGasTanks(facing).length > 0) + return (T) this; return super.getCapability(capability, facing); } + @Override + public int receiveGas(EnumFacing side, GasStack resource, boolean doTransfer) { + return 0; + } + + @Override + public GasStack drawGas(EnumFacing side, int amount, boolean doTransfer) { + return null; + } + + @Override + public boolean canReceiveGas(EnumFacing side, Gas type) { + return false; + } + + @Override + public boolean canDrawGas(EnumFacing side, Gas type) { + return false; + } } diff --git a/src/main/java/io/github/srdjanv/tweakedpetroleumgas/util/TweakedPetroleumGasInitializer.java b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/util/TweakedPetroleumGasInitializer.java new file mode 100644 index 0000000..e803f79 --- /dev/null +++ b/src/main/java/io/github/srdjanv/tweakedpetroleumgas/util/TweakedPetroleumGasInitializer.java @@ -0,0 +1,10 @@ +package io.github.srdjanv.tweakedpetroleumgas.util; + +import io.github.srdjanv.tweakedlib.api.integration.IInitializer; +import io.github.srdjanv.tweakedpetroleumgas.TweakedPetroleumGas; + +public interface TweakedPetroleumGasInitializer extends IInitializer { + default String getModID() { + return TweakedPetroleumGas.MODID; + } +} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/TweakedPetroleumGas.java b/src/main/java/srki2k/tweakedpetroleumgas/TweakedPetroleumGas.java deleted file mode 100644 index 4aeb9f2..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/TweakedPetroleumGas.java +++ /dev/null @@ -1,17 +0,0 @@ -package srki2k.tweakedpetroleumgas; - - -import net.minecraftforge.fml.common.Mod; - -@Mod(modid = TweakedPetroleumGas.MODID, - version = TweakedPetroleumGas.VERSION, - name = "Tweaked Petroleum: Gas Addon", - dependencies = "required-after:tweakedpetroleum@[@TWEAKEDPETROLEUMVERSION@,);" + - "required-after:mekanism;") - -public class TweakedPetroleumGas { - - public static final String MODID = "tweakedpetroleumgas"; - public static final String VERSION = "@VERSION@"; - -} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/api/util/IGasPumpjackAddons.java b/src/main/java/srki2k/tweakedpetroleumgas/api/util/IGasPumpjackAddons.java deleted file mode 100644 index 89fb77c..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/api/util/IGasPumpjackAddons.java +++ /dev/null @@ -1,14 +0,0 @@ -package srki2k.tweakedpetroleumgas.api.util; - -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasTank; -import net.minecraft.util.EnumFacing; -import srki2k.tweakedpetroleum.api.ihelpers.IPumpjackAddons; - -public interface IGasPumpjackAddons extends IPumpjackAddons { - - Gas getGas(); - - GasTank[] getAccessibleGasTanks(EnumFacing side); - -} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/api/util/IGasReservoirType.java b/src/main/java/srki2k/tweakedpetroleumgas/api/util/IGasReservoirType.java deleted file mode 100644 index 26d7fa2..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/api/util/IGasReservoirType.java +++ /dev/null @@ -1,10 +0,0 @@ -package srki2k.tweakedpetroleumgas.api.util; - -import mekanism.api.gas.Gas; -import srki2k.tweakedpetroleum.api.ihelpers.IReservoirType; - -public interface IGasReservoirType extends IReservoirType { - - Gas getGas(); - -} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/client/hei/GasPumpjackWrapper.java b/src/main/java/srki2k/tweakedpetroleumgas/client/hei/GasPumpjackWrapper.java deleted file mode 100644 index a93995f..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/client/hei/GasPumpjackWrapper.java +++ /dev/null @@ -1,90 +0,0 @@ -package srki2k.tweakedpetroleumgas.client.hei; - -import com.google.common.collect.Lists; -import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; -import flaxbeard.immersivepetroleum.common.Config; -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasStack; -import mekanism.client.jei.MekanismJEI; -import mezz.jei.api.gui.ITooltipCallback; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; -import srki2k.tweakedlib.api.hei.BaseHEIUtil; -import srki2k.tweakedpetroleum.util.HEIPumpjackUtil; -import srki2k.tweakedpetroleumgas.api.util.IGasReservoirType; - -import java.util.List; - -@SuppressWarnings("NullableProblems") -public class GasPumpjackWrapper implements IRecipeWrapper, ITooltipCallback { - private final IGasReservoirType reservoir; - private final Gas reservoirGas; - - public GasPumpjackWrapper(PumpjackHandler.ReservoirType reservoir) { - this.reservoir = (IGasReservoirType) reservoir; - reservoirGas = this.reservoir.getGas(); - } - - public GasStack getReplenishRateGas() { - return new GasStack(reservoirGas, reservoir.getReplenishRate()); - } - - public int getPumpSpeed() { - return reservoir.getPumpSpeed(); - } - - public int getMaxFluid() { - return reservoir.getMaxSize(); - } - - public GasStack getAverageGas() { - return new GasStack(reservoirGas, (int) (((long) reservoir.getMaxSize() + (long) reservoir.getMinSize()) / 2)); - } - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setOutputs(MekanismJEI.TYPE_GAS, Lists.newArrayList(getAverageGas())); - } - - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - String[][] strings = new String[3][]; - - if (reservoir.getDrainChance() != 1f) { - strings[0] = new String[]{"tweakedpetroleum.jei.reservoir.draw_chance", - String.valueOf(reservoir.getDrainChance() * 100), - String.valueOf(100f - (reservoir.getDrainChance() * 100))}; - } - - if (Config.IPConfig.Extraction.req_pipes) { - strings[2] = new String[]{"tweakedpetroleum.jei.reservoir.req_pipes"}; - } - - strings[1] = new String[]{"tweakedpetroleumgas.jei.reservoir.gas_info"}; - - return HEIPumpjackUtil.tooltipStrings(mouseX, mouseY, strings, reservoir); - } - - @Override - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - int warningCount = 1; - - if (Config.IPConfig.Extraction.req_pipes) { - warningCount++; - } - - if (reservoir.getDrainChance() != 1f) { - warningCount++; - } - - BaseHEIUtil.getPumpjackWarning().draw(minecraft, 55, 8); - minecraft.fontRenderer.drawString(String.valueOf(warningCount), 55, 6, 16696077); - } - - @Override - public void onTooltip(int slotIndex, boolean input, GasStack ingredient, List tooltip) { - HEIPumpjackUtil.onTooltip(slotIndex, reservoir, ingredient.amount, ingredient.getGas().getLocalizedName(), tooltip); - } - -} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/common/compat/crafttweaker/TweakedGasReservoir.java b/src/main/java/srki2k/tweakedpetroleumgas/common/compat/crafttweaker/TweakedGasReservoir.java deleted file mode 100644 index b9c1815..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/common/compat/crafttweaker/TweakedGasReservoir.java +++ /dev/null @@ -1,72 +0,0 @@ -package srki2k.tweakedpetroleumgas.common.compat.crafttweaker; - - -import crafttweaker.CraftTweakerAPI; -import crafttweaker.annotations.ZenRegister; -import mekanism.common.integration.crafttweaker.gas.IGasStack; -import srki2k.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; -import srki2k.tweakedpetroleum.api.ihelpers.IReservoirType; -import srki2k.tweakedpetroleum.util.ReservoirValidation; -import stanhebben.zenscript.annotations.Optional; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -import java.util.ArrayList; -import java.util.List; - -@SuppressWarnings("unused") -@ZenClass("mods.TweakedPetroleum.TweakedGasReservoir") -@ZenRegister -public class TweakedGasReservoir { - - @ZenMethod - public static void registerGasReservoir(String name, IGasStack gas, int minSize, int maxSize, int replenishRate, int pumpSpeed, int weight, int powerTier, - @Optional int[] dimBlacklist, @Optional int[] dimWhitelist, @Optional String[] biomeBlacklist, @Optional String[] biomeWhitelist) { - - - List biomeBlacklistList = new ArrayList<>(); - List biomeWhitelistList = new ArrayList<>(); - - ReservoirValidation.validateReservoir(name, minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier, - biomeBlacklist, biomeWhitelist, - biomeBlacklistList, biomeWhitelistList); - - - IReservoirType res = TweakedPumpjackHandler.addTweakedReservoir(name, gas.getName(), minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier); - - res.setReservoirContent(TweakedPumpjackHandler.ReservoirContent.GAS); - res.setDimensionBlacklist(dimBlacklist); - res.setDimensionWhitelist(dimWhitelist); - res.setBiomeBlacklist(biomeBlacklistList.toArray(new String[0])); - res.setBiomeWhitelist(biomeWhitelistList.toArray(new String[0])); - - CraftTweakerAPI.logInfo("Added Gas Reservoir Type: " + name); - - } - - @ZenMethod - public static void registerGasReservoirWithDrainChance(String name, IGasStack gas, int minSize, int maxSize, int replenishRate, int pumpSpeed, float drainChance, int weight, int powerTier, - @Optional int[] dimBlacklist, @Optional int[] dimWhitelist, @Optional String[] biomeBlacklist, @Optional String[] biomeWhitelist) { - - List biomeBlacklistList = new ArrayList<>(); - List biomeWhitelistList = new ArrayList<>(); - - ReservoirValidation.validateReservoir(name, minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier, drainChance, - biomeBlacklist, biomeWhitelist, - biomeBlacklistList, biomeWhitelistList); - - - IReservoirType res = TweakedPumpjackHandler.addTweakedReservoir(name, gas.getName(), minSize, maxSize, replenishRate, pumpSpeed, weight, powerTier); - - res.setReservoirContent(TweakedPumpjackHandler.ReservoirContent.GAS); - res.setDrainChance(drainChance); - res.setDimensionBlacklist(dimBlacklist); - res.setDimensionWhitelist(dimWhitelist); - res.setBiomeBlacklist(biomeBlacklistList.toArray(new String[0])); - res.setBiomeWhitelist(biomeWhitelistList.toArray(new String[0])); - - CraftTweakerAPI.logInfo("Added Gas Reservoir Type: " + name); - - } - -} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/common/gaspumpjack/DummyMultiblockGasWrapper.java b/src/main/java/srki2k/tweakedpetroleumgas/common/gaspumpjack/DummyMultiblockGasWrapper.java deleted file mode 100644 index 10099c8..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/common/gaspumpjack/DummyMultiblockGasWrapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package srki2k.tweakedpetroleumgas.common.gaspumpjack; - - -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.util.EnumFacing; - -public class DummyMultiblockGasWrapper implements IGasHandler { - public static IGasHandler INSTANCE = new DummyMultiblockGasWrapper(); - - @Override - public int receiveGas(EnumFacing side, GasStack resource, boolean doTransfer) { - return 0; - } - - @Override - public GasStack drawGas(EnumFacing side, int amount, boolean doTransfer) { - return null; - } - - @Override - public boolean canReceiveGas(EnumFacing side, Gas type) { - return false; - } - - @Override - public boolean canDrawGas(EnumFacing side, Gas type) { - return false; - } -} diff --git a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinClientProxy.java b/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinClientProxy.java deleted file mode 100644 index f486b82..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinClientProxy.java +++ /dev/null @@ -1,35 +0,0 @@ -package srki2k.tweakedpetroleumgas.mixin; - - -import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; -import flaxbeard.immersivepetroleum.client.ClientProxy; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import srki2k.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; -import srki2k.tweakedpetroleum.api.ihelpers.IReservoirType; - -import java.util.Iterator; -import java.util.LinkedHashMap; - -@Mixin(value = ClientProxy.class, remap = false) -public abstract class MixinClientProxy { - - @Redirect(method = "handleReservoirManual", at = @At(value = "FIELD", target = "Lflaxbeard/immersivepetroleum/api/crafting/PumpjackHandler;reservoirList:Ljava/util/LinkedHashMap;")) - private static LinkedHashMap onHandleReservoirManual() { - LinkedHashMap reservoirList = new LinkedHashMap<>(); - Iterator keySet = PumpjackHandler.reservoirList.keySet().iterator(); - - int i = 0; - while (keySet.hasNext()) { - PumpjackHandler.ReservoirType reservoirType = keySet.next(); - if (((IReservoirType) reservoirType).getReservoirContent() == TweakedPumpjackHandler.ReservoirContent.LIQUID) { - reservoirList.put(reservoirType, i); - i++; - } - } - - return reservoirList; - } - -} \ No newline at end of file diff --git a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinEventHandler.java b/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinEventHandler.java deleted file mode 100644 index df0d223..0000000 --- a/src/main/java/srki2k/tweakedpetroleumgas/mixin/MixinEventHandler.java +++ /dev/null @@ -1,181 +0,0 @@ -package srki2k.tweakedpetroleumgas.mixin; - -import blusunrize.immersiveengineering.client.ClientProxy; -import blusunrize.immersiveengineering.client.ClientUtils; -import blusunrize.immersiveengineering.common.Config; -import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces; -import blusunrize.immersiveengineering.common.blocks.stone.TileEntityCoresample; -import blusunrize.immersiveengineering.common.items.ItemCoresample; -import blusunrize.immersiveengineering.common.util.ItemNBTHelper; -import blusunrize.immersiveengineering.common.util.Utils; -import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; -import flaxbeard.immersivepetroleum.common.EventHandler; -import flaxbeard.immersivepetroleum.common.entity.EntitySpeedboat; -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasRegistry; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.RayTraceResult; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -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 srki2k.tweakedpetroleum.api.crafting.TweakedPumpjackHandler; -import srki2k.tweakedpetroleum.api.ihelpers.IReservoirType; - -import java.text.DecimalFormat; -import java.util.List; -import java.util.Optional; - -@Mixin(value = EventHandler.class, remap = false) -public abstract class MixinEventHandler { - - @Inject(method = "handleItemTooltip", cancellable = true, at = @At( - value = "INVOKE", - target = "Lnet/minecraftforge/event/entity/player/ItemTooltipEvent;getItemStack()Lnet/minecraft/item/ItemStack;", - shift = At.Shift.BEFORE)) - private static void onHandleItemTooltip(ItemTooltipEvent event, CallbackInfo ci) { - ItemStack stack = event.getItemStack(); - - if (stack.getItem() instanceof ItemCoresample && ItemNBTHelper.hasKey(stack, "oil")) { - final String resName; - if (ItemNBTHelper.hasKey(stack, "resType")) { - resName = ItemNBTHelper.getString(stack, "resType"); - } else { - resName = ""; - } - - Optional res = PumpjackHandler.reservoirList.keySet().stream(). - map(reservoirType -> (IReservoirType) reservoirType). - filter(reservoirType -> reservoirType.getName().equals(resName)). - findFirst(); - List tooltip = event.getToolTip(); - if (res.isPresent()) { - IReservoirType reservoirType = res.get(); - - int amnt = ItemNBTHelper.getInt(stack, "oil"); - String fluidName; - if (reservoirType.getReservoirContent() == TweakedPumpjackHandler.ReservoirContent.LIQUID) { - if (amnt > 0) { - int est = amnt / 1000 * 1000; - Fluid fluid = FluidRegistry.getFluid(reservoirType.getStringFluid()); - fluidName = net.minecraft.util.text.translation.I18n.translateToLocal(fluid.getUnlocalizedName()); - tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.oil", (new DecimalFormat("#,###.##")).format(est), fluidName)); - } else if (reservoirType.getReplenishRate() > 0) { - Fluid fluid = FluidRegistry.getFluid(reservoirType.getStringFluid()); - fluidName = net.minecraft.util.text.translation.I18n.translateToLocal(fluid.getUnlocalizedName()); - tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.oilRep", reservoirType.getReplenishRate(), fluidName)); - } - } else if (reservoirType.getReservoirContent() == TweakedPumpjackHandler.ReservoirContent.GAS) { - if (amnt > 0) { - int est = amnt / 1000 * 1000; - Gas g = GasRegistry.getGas(reservoirType.getStringFluid()); - fluidName = g.getLocalizedName(); - tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.oil", (new DecimalFormat("#,###.##")).format(est), fluidName)); - } else if (reservoirType.getReplenishRate() > 0) { - Gas g = GasRegistry.getGas(reservoirType.getStringFluid()); - fluidName = g.getLocalizedName(); - tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.oilRep", reservoirType.getReplenishRate(), fluidName)); - } - } - } else { - tooltip.add(2, I18n.format("chat.immersivepetroleum.info.coresample.noOil")); - } - } - ci.cancel(); - } - - @Inject(method = "renderCoresampleInfo", cancellable = true, at = @At( - value = "INVOKE", - target = "Lblusunrize/immersiveengineering/client/ClientUtils;mc()Lnet/minecraft/client/Minecraft;", - shift = At.Shift.BEFORE, - ordinal = 1)) - private static void onRenderCoresampleInfo(RenderGameOverlayEvent.Post event, CallbackInfo ci) { - EntityPlayer player = ClientUtils.mc().player; - if (ClientUtils.mc().objectMouseOver != null) { - boolean hammer = player.getHeldItem(EnumHand.MAIN_HAND) != null && Utils.isHammer(player.getHeldItem(EnumHand.MAIN_HAND)); - RayTraceResult mop = ClientUtils.mc().objectMouseOver; - int amnt; - if (mop != null && mop.getBlockPos() != null) { - TileEntity tileEntity = player.world.getTileEntity(mop.getBlockPos()); - if (tileEntity instanceof TileEntityCoresample) { - IEBlockInterfaces.IBlockOverlayText overlayBlock = (IEBlockInterfaces.IBlockOverlayText) tileEntity; - String[] text = overlayBlock.getOverlayText(ClientUtils.mc().player, mop, hammer); - boolean useNixie = overlayBlock.useNixieFont(ClientUtils.mc().player, mop); - ItemStack coresample = ((TileEntityCoresample) tileEntity).coresample; - if (ItemNBTHelper.hasKey(coresample, "oil") && text != null && text.length > 0) { - final String resName = ItemNBTHelper.hasKey(coresample, "resType") ? ItemNBTHelper.getString(coresample, "resType") : ""; - amnt = ItemNBTHelper.getInt(coresample, "oil"); - - Optional res = PumpjackHandler.reservoirList.keySet().stream(). - map(reservoirType -> (IReservoirType) reservoirType). - filter(reservoirType -> reservoirType.getName().equals(resName)). - findFirst(); - - String tooltip = null; - if (res.isPresent()) { - IReservoirType reservoirType = res.get(); - String fluidName; - if (reservoirType.getReservoirContent() == TweakedPumpjackHandler.ReservoirContent.LIQUID) { - if (amnt > 0) { - int est = amnt / 1000 * 1000; - Fluid fluid = FluidRegistry.getFluid(reservoirType.getStringFluid()); - fluidName = net.minecraft.util.text.translation.I18n.translateToLocal(fluid.getUnlocalizedName()); - tooltip = I18n.format("chat.immersivepetroleum.info.coresample.oil", (new DecimalFormat("#,###.##")).format(est), fluidName); - } else if (reservoirType.getReplenishRate() > 0) { - Fluid fluid = FluidRegistry.getFluid(reservoirType.getStringFluid()); - fluidName = net.minecraft.util.text.translation.I18n.translateToLocal(fluid.getUnlocalizedName()); - tooltip = I18n.format("chat.immersivepetroleum.info.coresample.oilRep", reservoirType.getReplenishRate(), fluidName); - } - } else if (reservoirType.getReservoirContent() == TweakedPumpjackHandler.ReservoirContent.GAS) { - if (amnt > 0) { - int est = amnt / 1000 * 1000; - Gas g = GasRegistry.getGas(reservoirType.getStringFluid()); - fluidName = g.getLocalizedName(); - tooltip = I18n.format("chat.immersivepetroleum.info.coresample.oil", (new DecimalFormat("#,###.##")).format(est), fluidName); - } else if (reservoirType.getReplenishRate() > 0) { - Gas g = GasRegistry.getGas(reservoirType.getStringFluid()); - fluidName = g.getLocalizedName(); - tooltip = I18n.format("chat.immersivepetroleum.info.coresample.oilRep", reservoirType.getReplenishRate(), fluidName); - } - } - } else { - tooltip = I18n.format("chat.immersivepetroleum.info.coresample.noOil"); - } - - if (tooltip != null) { - FontRenderer font = useNixie ? ClientProxy.nixieFontOptional : ClientUtils.font(); - int col = useNixie && Config.IEConfig.nixietubeFont ? 16750848 : 16777215; - int i = text.length; - font.drawString(tooltip, (float) (event.getResolution().getScaledWidth() / 2 + 8), (float) (event.getResolution().getScaledHeight() / 2 + 8 + i * font.FONT_HEIGHT), col, true); - } - } - } - } else if (mop != null && mop.entityHit != null && mop.entityHit instanceof EntitySpeedboat) { - String[] text = ((EntitySpeedboat) mop.entityHit).getOverlayText(ClientUtils.mc().player, mop); - if (text != null && text.length > 0) { - FontRenderer font = ClientUtils.font(); - int col = 16777215; - int i = 0; - - for (amnt = 0; amnt < text.length; ++amnt) { - String s = text[amnt]; - if (s != null) { - font.drawString(s, (float) (event.getResolution().getScaledWidth() / 2 + 8), (float) (event.getResolution().getScaledHeight() / 2 + 8 + i++ * font.FONT_HEIGHT), col, true); - } - } - } - } - } - ci.cancel(); - } - -} diff --git a/src/main/resources/mixins.tweakedpetroleumgas.json b/src/main/resources/mixins.tweakedpetroleumgas.json index a425c2a..5725799 100644 --- a/src/main/resources/mixins.tweakedpetroleumgas.json +++ b/src/main/resources/mixins.tweakedpetroleumgas.json @@ -1,6 +1,6 @@ { "minVersion": "0.8", - "package": "srki2k.tweakedpetroleumgas.mixin", + "package": "io.github.srdjanv.tweakedpetroleumgas.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ "MixinReservoirType",