diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..fd2792b6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,44 @@ +* text eol=lf + +*.[jJ][aA][rR] binary + +*.[pP][nN][gG] binary +*.[jJ][pP][gG] binary +*.[jJ][pP][eE][gG] binary +*.[gG][iI][fF] binary +*.[tT][iI][fF] binary +*.[tT][iI][fF][fF] binary +*.[iI][cC][oO] binary +*.[sS][vV][gG] text +*.[eE][pP][sS] binary +*.[xX][cC][fF] binary + +*.[kK][aA][rR] binary +*.[mM]4[aA] binary +*.[mM][iI][dD] binary +*.[mM][iI][dD][iI] binary +*.[mM][pP]3 binary +*.[oO][gG][gG] binary +*.[rR][aA] binary + +*.7[zZ] binary +*.[gG][zZ] binary +*.[tT][aA][rR] binary +*.[tT][gG][zZ] binary +*.[zZ][iI][pP] binary + +*.[tT][cC][nN] binary +*.[sS][oO] binary +*.[dD][lL][lL] binary +*.[dD][yY][lL][iI][bB] binary +*.[pP][sS][dD] binary +*.[tT][tT][fF] binary +*.[oO][tT][fF] binary + +*.[pP][aA][tT][cC][hH] -text + +*.[bB][aA][tT] text eol=crlf +*.[cC][mM][dD] text eol=crlf +*.[pP][sS]1 text eol=crlf + +*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary diff --git a/build.gradle b/build.gradle index 0d76f1ca..b961a5e1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,25 +1,40 @@ -//version: 1650343995 +//version: 1664372158 /* -DO NOT CHANGE THIS FILE! - -Also, you may replace this file at any time if there is an update available. -Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. -*/ + DO NOT CHANGE THIS FILE! + Also, you may replace this file at any time if there is an update available. + Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates. + */ import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import com.matthewprenger.cursegradle.CurseArtifact +import com.matthewprenger.cursegradle.CurseRelation +import com.modrinth.minotaur.dependencies.ModDependency +import com.modrinth.minotaur.dependencies.VersionDependency import org.gradle.internal.logging.text.StyledTextOutput.Style import org.gradle.internal.logging.text.StyledTextOutputFactory +import java.nio.file.Files +import java.nio.file.Paths import java.util.concurrent.TimeUnit +import java.util.zip.ZipEntry +import java.util.zip.ZipInputStream +import java.util.zip.ZipOutputStream buildscript { repositories { + mavenCentral() + maven { name 'forge' url 'https://maven.minecraftforge.net' } + maven { + // GTNH ForgeGradle Fork + name = "GTNH Maven" + url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" + } maven { name 'sonatype' url 'https://oss.sonatype.org/content/repositories/snapshots/' @@ -28,30 +43,39 @@ buildscript { name 'Scala CI dependencies' url 'https://repo1.maven.org/maven2/' } - maven { - name 'jitpack' - url 'https://jitpack.io' - } } dependencies { - classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7' + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.9' } } - plugins { id 'java-library' id 'idea' id 'eclipse' id 'scala' id 'maven-publish' - id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false - id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false - id 'org.ajoberstar.grgit' version '4.1.1' + id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false + id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false + id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false + id 'org.ajoberstar.grgit' version '4.1.1' id 'com.github.johnrengelman.shadow' version '4.0.4' - id 'com.palantir.git-version' version '0.13.0' apply false - id 'de.undercouch.download' version '5.0.1' - id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false + id 'com.palantir.git-version' version '0.13.0' apply false + id 'de.undercouch.download' version '5.0.1' + id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false + id 'com.diffplug.spotless' version '6.7.2' apply false + id 'com.modrinth.minotaur' version '2.+' apply false + id 'com.matthewprenger.cursegradle' version '1.4.0' apply false } +boolean settingsupdated = verifySettingsGradle() +settingsupdated = verifyGitAttributes() || settingsupdated +if (settingsupdated) + throw new GradleException("Settings has been updated, please re-run task.") + +dependencies { + implementation 'com.diffplug:blowdryer:1.6.0' +} + +apply plugin: 'com.diffplug.blowdryer' if (project.file('.git/HEAD').isFile()) { apply plugin: 'com.palantir.git-version' @@ -77,7 +101,14 @@ idea { } } -if(JavaVersion.current() != JavaVersion.VERSION_1_8) { +boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false + +if (!disableSpotless) { + apply plugin: 'com.diffplug.spotless' + apply from: Blowdryer.file('spotless.gradle') +} + +if (JavaVersion.current() != JavaVersion.VERSION_1_8) { throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) } @@ -102,8 +133,15 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly") checkPropertyExists("usesShadowedDependencies") checkPropertyExists("developmentEnvironmentUserName") -boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false -boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean() +propertyDefaultIfUnset("noPublishedSources", false) +propertyDefaultIfUnset("usesMixinDebug", project.usesMixins) +propertyDefaultIfUnset("forceEnableMixins", false) +propertyDefaultIfUnset("channel", "stable") +propertyDefaultIfUnset("mappingsVersion", "12") +propertyDefaultIfUnset("modrinthProjectId", "") +propertyDefaultIfUnset("modrinthRelations", "") +propertyDefaultIfUnset("curseForgeProjectId", "") +propertyDefaultIfUnset("curseForgeRelations", "") String javaSourceDir = "src/main/java/" String scalaSourceDir = "src/main/scala/" @@ -112,53 +150,53 @@ String kotlinSourceDir = "src/main/kotlin/" String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") -if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { +if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) } -if(apiPackage) { +if (apiPackage) { targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") - if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { + if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) } } -if(accessTransformersFile) { +if (accessTransformersFile) { String targetFile = "src/main/resources/META-INF/" + accessTransformersFile - if(!getFile(targetFile).exists()) { + if (!getFile(targetFile).exists()) { throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) } } -if(usesMixins.toBoolean()) { - if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) { +if (usesMixins.toBoolean()) { + if (mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) { throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!") } targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/") - if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { - throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) + if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) { + throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin) } String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala" String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java" String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt" - if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { + if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) } } -if(coreModClass) { +if (coreModClass) { String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala" String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java" String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt" - if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { + if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) { throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) } } @@ -188,7 +226,7 @@ try { catch (Exception ignored) { out.style(Style.Failure).text( 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' + - 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + + 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' ) versionOverride = 'NO-GIT-TAG-SET' @@ -199,22 +237,21 @@ ext { modVersion = identifiedVersion } -if(identifiedVersion == versionOverride) { +if (identifiedVersion == versionOverride) { out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7') } group = modGroup -if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) { +if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) { archivesBaseName = customArchiveBaseName -} -else { +} else { archivesBaseName = modId } def arguments = [] def jvmArguments = [] -if (usesMixins.toBoolean()) { +if (usesMixins.toBoolean() || forceEnableMixins) { arguments += [ "--tweakClass org.spongepowered.asm.launch.MixinTweaker" ] @@ -233,16 +270,16 @@ minecraft { if (replaceGradleTokenInFile) { replaceIn replaceGradleTokenInFile - if(gradleTokenModId) { + if (gradleTokenModId) { replace gradleTokenModId, modId } - if(gradleTokenModName) { + if (gradleTokenModName) { replace gradleTokenModName, modName } - if(gradleTokenVersion) { + if (gradleTokenVersion) { replace gradleTokenVersion, modVersion } - if(gradleTokenGroupName) { + if (gradleTokenGroupName) { replace gradleTokenGroupName, modGroup } } @@ -251,7 +288,7 @@ minecraft { args(arguments) jvmArgs(jvmArguments) - if(developmentEnvironmentUserName) { + if (developmentEnvironmentUserName) { args("--username", developmentEnvironmentUserName) } } @@ -262,7 +299,7 @@ minecraft { } } -if(file('addon.gradle').exists()) { +if (file('addon.gradle').exists()) { apply from: 'addon.gradle' } @@ -279,7 +316,7 @@ repositories { name 'Overmind forge repo mirror' url 'https://gregtech.overminddl1.com/' } - if(usesMixins.toBoolean()) { + if (usesMixins.toBoolean() || forceEnableMixins) { maven { name 'sponge' url 'https://repo.spongepowered.org/repository/maven-public' @@ -291,11 +328,13 @@ repositories { } dependencies { - if(usesMixins.toBoolean()) { + if (usesMixins.toBoolean()) { annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3') annotationProcessor('com.google.guava:guava:24.1.1-jre') annotationProcessor('com.google.code.gson:gson:2.8.6') annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT') + } + if (usesMixins.toBoolean() || forceEnableMixins) { // using 0.8 to workaround a issue in 0.7 which fails mixin application compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') { // Mixin includes a lot of dependencies that are too up-to-date @@ -353,7 +392,10 @@ shadowJar { } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] + configurations = [ + project.configurations.shadowImplementation, + project.configurations.shadowCompile + ] dependsOn(relocateShadowJar) } @@ -368,38 +410,38 @@ jar { attributes(getManifestAttributes()) } - if(usesShadowedDependencies.toBoolean()) { + if (usesShadowedDependencies.toBoolean()) { dependsOn(shadowJar) enabled = false } } reobf { - if(usesMixins.toBoolean()) { + if (usesMixins.toBoolean()) { addExtraSrgFile mixinSrg } } afterEvaluate { - if(usesMixins.toBoolean()) { + if (usesMixins.toBoolean()) { tasks.compileJava { options.compilerArgs += [ - "-AreobfSrgFile=${tasks.reobf.srg}", - "-AoutSrgFile=${mixinSrg}", - "-AoutRefMapFile=${refMap}", - // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code - "-XDenableSunApiLintControl", - "-XDignore.symbol.file" + "-AreobfSrgFile=${tasks.reobf.srg}", + "-AoutSrgFile=${mixinSrg}", + "-AoutRefMapFile=${refMap}", + // Elan: from what I understand they are just some linter configs so you get some warning on how to properly code + "-XDenableSunApiLintControl", + "-XDignore.symbol.file" ] } } } runClient { - if(developmentEnvironmentUserName) { + if (developmentEnvironmentUserName) { arguments += [ - "--username", - developmentEnvironmentUserName + "--username", + developmentEnvironmentUserName ] } @@ -414,9 +456,9 @@ runServer { tasks.withType(JavaExec).configureEach { javaLauncher.set( - javaToolchains.launcherFor { - languageVersion = projectJavaVersion - } + javaToolchains.launcherFor { + languageVersion = projectJavaVersion + } ) } @@ -424,6 +466,7 @@ processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version + exclude("spotless.gradle") // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { @@ -436,43 +479,44 @@ processResources { "modName": modName } - if(usesMixins.toBoolean()) { + if (usesMixins.toBoolean()) { from refMap } // copy everything else that's not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' + exclude 'spotless.gradle' } } def getManifestAttributes() { def manifestAttributes = [:] - if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) { + if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) { manifestAttributes += ["FMLCorePluginContainsFMLMod": true] } - if(accessTransformersFile) { - manifestAttributes += ["FMLAT" : accessTransformersFile.toString()] + if (accessTransformersFile) { + manifestAttributes += ["FMLAT": accessTransformersFile.toString()] } - if(coreModClass) { + if (coreModClass) { manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass] } - if(usesMixins.toBoolean()) { + if (usesMixins.toBoolean()) { manifestAttributes += [ - "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : "mixins." + modId + ".json", - "ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean() + "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", + "MixinConfigs" : "mixins." + modId + ".json", + "ForceLoadAsMod": !containsMixinsAndOrCoreModOnly.toBoolean() ] } return manifestAttributes } task sourcesJar(type: Jar) { - from (sourceSets.main.allSource) - from (file("$projectDir/LICENSE")) + from(sourceSets.main.allSource) + from(file("$projectDir/LICENSE")) getArchiveClassifier().set('sources') } @@ -491,7 +535,10 @@ task shadowDevJar(type: ShadowJar) { } minimize() // This will only allow shading for actually used classes - configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile] + configurations = [ + project.configurations.shadowImplementation, + project.configurations.shadowCompile + ] } task relocateShadowDevJar(type: ConfigureShadowRelocation) { @@ -519,22 +566,22 @@ task devJar(type: Jar) { attributes(getManifestAttributes()) } - if(usesShadowedDependencies.toBoolean()) { + if (usesShadowedDependencies.toBoolean()) { dependsOn(circularResolverJar) enabled = false } } task apiJar(type: Jar) { - from (sourceSets.main.allSource) { + from(sourceSets.main.allSource) { include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' } - from (sourceSets.main.output) { + from(sourceSets.main.output) { include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' } - from (sourceSets.main.resources.srcDirs) { + from(sourceSets.main.resources.srcDirs) { include("LICENSE") } @@ -542,11 +589,11 @@ task apiJar(type: Jar) { } artifacts { - if(!noPublishedSources) { + if (!noPublishedSources) { archives sourcesJar } archives devJar - if(apiPackage) { + if (apiPackage) { archives apiJar } } @@ -564,10 +611,10 @@ publishing { publications { maven(MavenPublication) { from components.java - if(usesShadowedDependencies.toBoolean()) { + if (usesShadowedDependencies.toBoolean()) { artifact source: shadowJar, classifier: "" } - if(!noPublishedSources) { + if (!noPublishedSources) { artifact source: sourcesJar, classifier: "sources" } artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev" @@ -582,8 +629,11 @@ publishing { // remove extra garbage from minecraft and minecraftDeps configuration pom.withXml { - def badArtifacts = [:].withDefault {[] as Set} - for (configuration in [projectConfigs.minecraft, projectConfigs.minecraftDeps]) { + def badArtifacts = [:].withDefault { [] as Set } + for (configuration in [ + projectConfigs.minecraft, + projectConfigs.minecraftDeps + ]) { for (dependency in configuration.allDependencies) { badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name } @@ -612,6 +662,107 @@ publishing { } } +if (modrinthProjectId.size() != 0) { + apply plugin: 'com.modrinth.minotaur' + + File changelogFile = new File("CHANGELOG.md") + + modrinth { + token = System.getenv("MODRINTH_TOKEN") + projectId = modrinthProjectId + versionNumber = identifiedVersion + versionType = identifiedVersion.endsWith("-pre") ? "beta" : "release" + changelog = changelogFile.exists() ? changelogFile.getText("UTF-8") : "" + uploadFile = jar + additionalFiles = getSecondaryArtifacts() + gameVersions = [minecraftVersion] + loaders = ["forge"] + debugMode = false + } + + if (modrinthRelations.size() != 0) { + String[] deps = modrinthRelations.split(";") + deps.each { dep -> + if (dep.size() == 0) { + return + } + String[] parts = dep.split(":") + String[] qual = parts[0].split("-") + addModrinthDep(qual[0], qual[1], parts[1]) + } + } + tasks.modrinth.dependsOn(build) + tasks.publish.dependsOn(tasks.modrinth) +} + +if (curseForgeProjectId.size() != 0) { + apply plugin: 'com.matthewprenger.cursegradle' + + File changelogFile = new File("CHANGELOG.md") + + curseforge { + apiKey = System.getenv("CURSEFORGE_TOKEN") + project { + id = curseForgeProjectId + if (changelogFile.exists()) { + changelogType = "markdown" + changelog = changelogFile + } + releaseType = identifiedVersion.endsWith("-pre") ? "beta" : "release" + addGameVersion minecraftVersion + addGameVersion "Forge" + mainArtifact jar + for (artifact in getSecondaryArtifacts()) addArtifact artifact + } + + options { + javaIntegration = false + forgeGradleIntegration = false + debug = false + } + } + + if (curseForgeRelations.size() != 0) { + String[] deps = curseForgeRelations.split(";") + deps.each { dep -> + if (dep.size() == 0) { + return + } + String[] parts = dep.split(":") + addCurseForgeRelation(parts[0], parts[1]) + } + } + tasks.curseforge.dependsOn(build) + tasks.publish.dependsOn(tasks.curseforge) +} + +def addModrinthDep(scope, type, name) { + com.modrinth.minotaur.dependencies.Dependency dep; + if (!(scope in ["required", "optional", "incompatible", "embedded"])) { + throw new Exception("Invalid modrinth dependency scope: " + scope) + } + switch (type) { + case "project": + dep = new ModDependency(name, scope) + break + case "version": + dep = new VersionDependency(name, scope) + break + default: + throw new Exception("Invalid modrinth dependency type: " + type) + } + project.modrinth.dependencies.add(dep) +} + +def addCurseForgeRelation(type, name) { + if (!(type in ["requiredDependency", "embeddedLibrary", "optionalDependency", "tool", "incompatible"])) { + throw new Exception("Invalid CurseForge relation type: " + type) + } + CurseArtifact artifact = project.curseforge.curseProjects[0].mainArtifact + CurseRelation rel = (artifact.curseRelations ?: (artifact.curseRelations = new CurseRelation())) + rel."$type"(name) +} + // Updating task updateBuildScript { doLast { @@ -621,7 +772,7 @@ task updateBuildScript { } } -if (isNewBuildScriptVersionAvailable(projectDir.toString())) { +if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAvailable(projectDir.toString())) { if (autoUpdateBuildScript.toBoolean()) { performBuildScriptUpdate(projectDir.toString()) } else { @@ -630,7 +781,40 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) { } static URL availableBuildScriptUrl() { - new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle") + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/build.gradle") +} + +static URL exampleSettingsGradleUrl() { + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/settings.gradle.example") +} + +static URL exampleGitAttributesUrl() { + new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/.gitattributes") +} + + +boolean verifyGitAttributes() { + def gitattributesFile = getFile(".gitattributes") + if (!gitattributesFile.exists()) { + println("Downloading default .gitattributes") + exampleGitAttributesUrl().withInputStream { i -> gitattributesFile.withOutputStream { it << i } } + exec { + workingDir '.' + commandLine 'git', 'add', '--renormalize', '.' + } + return true + } + return false +} + +boolean verifySettingsGradle() { + def settingsFile = getFile("settings.gradle") + if (!settingsFile.exists()) { + println("Downloading default settings.gradle") + exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } } + return true + } + return false } boolean performBuildScriptUpdate(String projectDir) { @@ -638,13 +822,17 @@ boolean performBuildScriptUpdate(String projectDir) { def buildscriptFile = getFile("build.gradle") availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } } out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!") + boolean settingsupdated = verifySettingsGradle() + settingsupdated = verifyGitAttributes() || settingsupdated + if (settingsupdated) + throw new GradleException("Settings has been updated, please re-run task.") return true } return false } boolean isNewBuildScriptVersionAvailable(String projectDir) { - Map parameters = ["connectTimeout": 5000, "readTimeout": 5000] + Map parameters = ["connectTimeout": 2000, "readTimeout": 2000] String currentBuildScript = getFile("build.gradle").getText() String currentBuildScriptHash = getVersionHash(currentBuildScript) @@ -657,7 +845,7 @@ boolean isNewBuildScriptVersionAvailable(String projectDir) { static String getVersionHash(String buildScriptContent) { String versionLine = buildScriptContent.find("^//version: [a-z0-9]*") - if(versionLine != null) { + if (versionLine != null) { return versionLine.split(": ").last() } return "" @@ -668,7 +856,103 @@ configure(updateBuildScript) { description = 'Updates the build script to the latest version' } -// Deobfuscation +// Parameter Deobfuscation + +task deobfParams { + doLast { + + String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion" + String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" + String paramsCSV = "$mcpDir/params.csv" + + download.run { + src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip" + dest mcpZIP + overwrite false + } + + if (!file(paramsCSV).exists()) { + println("Extracting MCP archive ...") + unzip(mcpZIP, mcpDir) + } + + println("Parsing params.csv ...") + Map params = new HashMap<>() + Files.lines(Paths.get(paramsCSV)).forEach { line -> + String[] cells = line.split(",") + if (cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) { + params.put(cells[0], cells[1]) + } + } + + out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!") + out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.") + } +} + +static int replaceParams(File file, Map params) { + int fileCount = 0 + + if (file.isDirectory()) { + for (File f : file.listFiles()) { + fileCount += replaceParams(f, params) + } + return fileCount + } + println("Visiting ${file.getName()} ...") + try { + String content = new String(Files.readAllBytes(file.toPath())) + int hash = content.hashCode() + params.forEach { key, value -> + content = content.replaceAll(key, value) + } + if (hash != content.hashCode()) { + Files.write(file.toPath(), content.getBytes("UTF-8")) + return 1 + } + } catch (Exception e) { + e.printStackTrace() + } + return 0 +} + +// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681) +static unzip(String zipFileName, String outputDir) { + byte[] buffer = new byte[16384] + ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName)) + ZipEntry zipEntry = zis.getNextEntry() + while (zipEntry != null) { + File newFile = new File(outputDir + File.separator, zipEntry.name) + if (zipEntry.isDirectory()) { + if (!newFile.isDirectory() && !newFile.mkdirs()) { + throw new IOException("Failed to create directory $newFile") + } + } else { + // fix for Windows-created archives + File parent = newFile.parentFile + if (!parent.isDirectory() && !parent.mkdirs()) { + throw new IOException("Failed to create directory $parent") + } + // write file content + FileOutputStream fos = new FileOutputStream(newFile) + int len = 0 + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len) + } + fos.close() + } + zipEntry = zis.getNextEntry() + } + zis.closeEntry() + zis.close() +} + +configure(deobfParams) { + group = 'forgegradle' + description = 'Rename all obfuscated parameter names inherited from Minecraft classes' +} + +// Dependency Deobfuscation def deobf(String sourceURL) { try { @@ -677,42 +961,57 @@ def deobf(String sourceURL) { //get rid of directories: int lastSlash = fileName.lastIndexOf("/") - if(lastSlash > 0) { + if (lastSlash > 0) { fileName = fileName.substring(lastSlash + 1) } //get rid of extension: - if(fileName.endsWith(".jar")) { + if (fileName.endsWith(".jar") || fileName.endsWith(".litemod")) { fileName = fileName.substring(0, fileName.lastIndexOf(".")) } String hostName = url.getHost() - if(hostName.startsWith("www.")) { + if (hostName.startsWith("www.")) { hostName = hostName.substring(4) } List parts = Arrays.asList(hostName.split("\\.")) Collections.reverse(parts) hostName = String.join(".", parts) - return deobf(sourceURL, hostName + "/" + fileName) - } catch(Exception e) { - return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode())) + return deobf(sourceURL, "$hostName/$fileName") + } catch (Exception e) { + return deobf(sourceURL, "deobf/${sourceURL.hashCode()}") } } // The method above is to be preferred. Use this method if the filename is not at the end of the URL. -def deobf(String sourceURL, String fileName) { - String cacheDir = System.getProperty("user.home") + "/.gradle/caches/" - String bon2Dir = cacheDir + "forge_gradle/deobf" - String bon2File = bon2Dir + "/BON2-2.5.0.jar" - String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar" - String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar" +def deobf(String sourceURL, String rawFileName) { + String bon2Version = "2.5.1" + String fileName = URLDecoder.decode(rawFileName, "UTF-8") + String cacheDir = "$project.gradle.gradleUserHomeDir/caches" + String bon2Dir = "$cacheDir/forge_gradle/deobf" + String bon2File = "$bon2Dir/BON2-${bon2Version}.jar" + String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar" + String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar" - if(file(deobfFile).exists()) { + if (file(deobfFile).exists()) { return files(deobfFile) } + String mappingsVer + String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/' + if (remoteMappings) { + String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion" + String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip" + + zipMappings(mappingsZIP, remoteMappings, bon2Dir) + + mappingsVer = "snapshot_$id" + } else { + mappingsVer = "${channel}_$mappingsVersion" + } + download.run { - src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar' + src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar" dest bon2File quiet true overwrite false @@ -726,14 +1025,48 @@ def deobf(String sourceURL, String fileName) { } exec { - commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch' + commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch' workingDir bon2Dir - standardOutput = new ByteArrayOutputStream() + standardOutput = new FileOutputStream("${deobfFile}.log") } return files(deobfFile) } +def zipMappings(String zipPath, String url, String bon2Dir) { + File zipFile = new File(zipPath) + if (zipFile.exists()) { + return + } + + String fieldsCache = "$bon2Dir/data/fields.csv" + String methodsCache = "$bon2Dir/data/methods.csv" + + download.run { + src "${url}fields.csv" + dest fieldsCache + quiet true + } + download.run { + src "${url}methods.csv" + dest methodsCache + quiet true + } + + zipFile.getParentFile().mkdirs() + ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)) + + zos.putNextEntry(new ZipEntry("fields.csv")) + Files.copy(Paths.get(fieldsCache), zos) + zos.closeEntry() + + zos.putNextEntry(new ZipEntry("methods.csv")) + Files.copy(Paths.get(methodsCache), zos) + zos.closeEntry() + + zos.close() +} + // Helper methods def checkPropertyExists(String propertyName) { @@ -742,6 +1075,21 @@ def checkPropertyExists(String propertyName) { } } +def propertyDefaultIfUnset(String propertyName, defaultValue) { + if (!project.hasProperty(propertyName) || project.property(propertyName) == "") { + project.ext.setProperty(propertyName, defaultValue) + } +} + def getFile(String relativePath) { return new File(projectDir, relativePath) } + +def getSecondaryArtifacts() { + // Because noPublishedSources from the beginning of the script is somehow not visible here... + boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false + def secondaryArtifacts = [devJar] + if (!noPublishedSources) secondaryArtifacts += [sourcesJar] + if (apiPackage) secondaryArtifacts += [apiJar] + return secondaryArtifacts +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..93c852a1 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +plugins { + id 'com.diffplug.blowdryerSetup' version '1.6.0' +} + +apply plugin: 'com.diffplug.blowdryerSetup' + +blowdryerSetup { + github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.5') + //devLocal '.' // Use this when testing config updates locally +} diff --git a/src/main/java/com/glodblock/github/FluidCraft.java b/src/main/java/com/glodblock/github/FluidCraft.java index e79af60a..ffec99c1 100644 --- a/src/main/java/com/glodblock/github/FluidCraft.java +++ b/src/main/java/com/glodblock/github/FluidCraft.java @@ -21,7 +21,11 @@ import cpw.mods.fml.common.network.NetworkRegistry; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -@Mod(modid = FluidCraft.MODID, version = FluidCraft.VERSION, name = FluidCraft.MODNAME, dependencies = "required-after:appliedenergistics2") +@Mod( + modid = FluidCraft.MODID, + version = FluidCraft.VERSION, + name = FluidCraft.MODNAME, + dependencies = "required-after:appliedenergistics2") public class FluidCraft { public static final String MODID = "GRADLETOKEN_MODID"; @@ -31,7 +35,9 @@ public class FluidCraft { @Mod.Instance(MODID) public static FluidCraft INSTANCE; - @SidedProxy(clientSide = "com.glodblock.github.proxy.ClientProxy", serverSide = "com.glodblock.github.proxy.CommonProxy") + @SidedProxy( + clientSide = "com.glodblock.github.proxy.ClientProxy", + serverSide = "com.glodblock.github.proxy.CommonProxy") public static CommonProxy proxy; @Mod.EventHandler @@ -62,30 +68,28 @@ public class FluidCraft { } if (ModAndClassUtil.isBigInterface) { - Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 3 ); - Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 3 ); + Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 3); + Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 3); } - Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1 ); - Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1 ); + Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1); + Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1); if (Config.fluidIOBus) { - Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2 ); - Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2 ); - Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1 ); - Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 1 ); - Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4 ); - Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4 ); + Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2); + Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2); + Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1); + Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 1); + Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4); + Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4); } proxy.postInit(event); } @Mod.EventHandler - public void onLoadComplete(FMLLoadCompleteEvent event) { - } + public void onLoadComplete(FMLLoadCompleteEvent event) {} public static ResourceLocation resource(String path) { return new ResourceLocation(MODID, path); } - } diff --git a/src/main/java/com/glodblock/github/client/ClientHelper.java b/src/main/java/com/glodblock/github/client/ClientHelper.java index 41d19560..45f80896 100644 --- a/src/main/java/com/glodblock/github/client/ClientHelper.java +++ b/src/main/java/com/glodblock/github/client/ClientHelper.java @@ -9,13 +9,10 @@ import net.minecraftforge.common.MinecraftForge; public class ClientHelper { @SubscribeEvent - public void updateTextureSheet( final TextureStitchEvent.Pre ev ) - { - if( ev.map.getTextureType() == 0 ) - { - for( final FCPartsTexture cb : FCPartsTexture.values() ) - { - cb.registerIcon( ev.map ); + public void updateTextureSheet(final TextureStitchEvent.Pre ev) { + if (ev.map.getTextureType() == 0) { + for (final FCPartsTexture cb : FCPartsTexture.values()) { + cb.registerIcon(ev.map); } } } @@ -25,5 +22,4 @@ public class ClientHelper { MinecraftForge.EVENT_BUS.register(handler); FMLCommonHandler.instance().bus().register(handler); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java b/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java index c8933d18..589f789a 100644 --- a/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java +++ b/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java @@ -23,8 +23,14 @@ public class FCGuiTextField extends GuiTextField { * @param width absolute width * @param height absolute height */ - public FCGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) { - super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth('_'), height - 2 * PADDING); + public FCGuiTextField( + final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) { + super( + fontRenderer, + xPos + PADDING, + yPos + PADDING, + width - 2 * PADDING - fontRenderer.getCharWidth('_'), + height - 2 * PADDING); this._xPos = xPos; this._yPos = yPos; @@ -55,13 +61,11 @@ public class FCGuiTextField extends GuiTextField { return withinXRange && withinYRange; } - public void setMessage(String t) - { + public void setMessage(String t) { tooltip = t; } - public class TooltipProvider implements ITooltip - { + public class TooltipProvider implements ITooltip { @Override public String getMessage() { return tooltip; @@ -83,7 +87,9 @@ public class FCGuiTextField extends GuiTextField { } @Override - public int getWidth() { return _width; } + public int getWidth() { + return _width; + } @Override public boolean isVisible() { diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java index d8ecad73..1e20d406 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java @@ -41,161 +41,153 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { private GuiFCImgButton combineEnableBtn; private GuiFCImgButton combineDisableBtn; - public GuiBaseFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te ) - { - super( inventoryPlayer, te, new FCBasePartContainer( inventoryPlayer, te ) ); + public GuiBaseFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { + super(inventoryPlayer, te, new FCBasePartContainer(inventoryPlayer, te)); this.container = (FCBasePartContainer) this.inventorySlots; setReservedSpace(81); } @Override - protected void actionPerformed( final GuiButton btn ) - { - super.actionPerformed( btn ); + protected void actionPerformed(final GuiButton btn) { + super.actionPerformed(btn); - if( this.tabCraftButton == btn || this.tabProcessButton == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING ) ); - } - else if( this.encodeBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0) )); - } - else if( this.clearBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Clear", "1" ) ); - } - else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) ); - } - else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Combine", this.combineDisableBtn == btn ? "1" : "0" ) ); - } - else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") ); + if (this.tabCraftButton == btn || this.tabProcessButton == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminal.CraftMode", + this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING)); + } else if (this.encodeBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0))); + } else if (this.clearBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Clear", "1")); + } else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminal.Substitute", + this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE)); + } else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminal.Combine", this.combineDisableBtn == btn ? "1" : "0")); + } else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminal.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0")); } } @Override @SuppressWarnings("unchecked") - public void initGui() - { + public void initGui() { super.initGui(); - this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ), GuiText.CraftingPattern.getLocal(), itemRender ); - this.buttonList.add( this.tabCraftButton ); + this.tabCraftButton = new GuiTabButton( + this.guiLeft + 173, + this.guiTop + this.ySize - 177, + new ItemStack(Blocks.crafting_table), + GuiText.CraftingPattern.getLocal(), + itemRender); + this.buttonList.add(this.tabCraftButton); - this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ), GuiText.ProcessingPattern.getLocal(), itemRender ); - this.buttonList.add( this.tabProcessButton ); + this.tabProcessButton = new GuiTabButton( + this.guiLeft + 173, + this.guiTop + this.ySize - 177, + new ItemStack(Blocks.furnace), + GuiText.ProcessingPattern.getLocal(), + itemRender); + this.buttonList.add(this.tabProcessButton); - this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED ); - this.substitutionsEnabledBtn.setHalfSize( true ); - this.buttonList.add( this.substitutionsEnabledBtn ); + this.substitutionsEnabledBtn = new GuiImgButton( + this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED); + this.substitutionsEnabledBtn.setHalfSize(true); + this.buttonList.add(this.substitutionsEnabledBtn); - this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED ); - this.substitutionsDisabledBtn.setHalfSize( true ); - this.buttonList.add( this.substitutionsDisabledBtn ); + this.substitutionsDisabledBtn = new GuiImgButton( + this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED); + this.substitutionsDisabledBtn.setHalfSize(true); + this.buttonList.add(this.substitutionsDisabledBtn); - this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ); - this.clearBtn.setHalfSize( true ); - this.buttonList.add( this.clearBtn ); + this.clearBtn = new GuiImgButton( + this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE); + this.clearBtn.setHalfSize(true); + this.buttonList.add(this.clearBtn); - this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ); - this.buttonList.add( this.encodeBtn ); + this.encodeBtn = new GuiImgButton( + this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE); + this.buttonList.add(this.encodeBtn); int combineLeft = 74; if (ModAndClassUtil.isDoubleButton) { - this.doubleBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE ); - this.doubleBtn.setHalfSize( true ); - this.buttonList.add( this.doubleBtn ); + this.doubleBtn = new GuiImgButton( + this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE); + this.doubleBtn.setHalfSize(true); + this.buttonList.add(this.doubleBtn); combineLeft = 84; } - this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "FORCE_COMBINE", "DO_COMBINE" ); - this.combineEnableBtn.setHalfSize( true ); - this.buttonList.add( this.combineEnableBtn ); + this.combineEnableBtn = new GuiFCImgButton( + this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "FORCE_COMBINE", "DO_COMBINE"); + this.combineEnableBtn.setHalfSize(true); + this.buttonList.add(this.combineEnableBtn); - this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "NOT_COMBINE", "DONT_COMBINE" ); - this.combineDisableBtn.setHalfSize( true ); - this.buttonList.add( this.combineDisableBtn ); + this.combineDisableBtn = new GuiFCImgButton( + this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "NOT_COMBINE", "DONT_COMBINE"); + this.combineDisableBtn.setHalfSize(true); + this.buttonList.add(this.combineDisableBtn); } @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - if( !this.container.isCraftingMode() ) - { + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + if (!this.container.isCraftingMode()) { this.tabCraftButton.visible = false; this.tabProcessButton.visible = true; - if (ModAndClassUtil.isDoubleButton) - this.doubleBtn.visible = true; - } - else - { + if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = true; + } else { this.tabCraftButton.visible = true; this.tabProcessButton.visible = false; - if (ModAndClassUtil.isDoubleButton) - this.doubleBtn.visible = false; + if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = false; } - if( this.container.substitute ) - { + if (this.container.substitute) { this.substitutionsEnabledBtn.visible = true; this.substitutionsDisabledBtn.visible = false; - } - else - { + } else { this.substitutionsEnabledBtn.visible = false; this.substitutionsDisabledBtn.visible = true; } - if (!this.container.isCraftingMode()) - { - if ( this.container.combine ) - { + if (!this.container.isCraftingMode()) { + if (this.container.combine) { this.combineEnableBtn.visible = true; this.combineDisableBtn.visible = false; - } - else - { + } else { this.combineEnableBtn.visible = false; this.combineDisableBtn.visible = true; } - } - else - { + } else { this.combineEnableBtn.visible = false; this.combineDisableBtn.visible = false; } - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 ); + super.drawFG(offsetX, offsetY, mouseX, mouseY); + this.fontRendererObj.drawString( + StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), + 8, + this.ySize - 96 + 2 - getReservedSpace(), + 4210752); } @Override - protected String getBackground() - { - if( this.container.isCraftingMode() ) - { + protected String getBackground() { + if (this.container.isCraftingMode()) { return "gui/pattern.png"; } return "gui/pattern2.png"; } @Override - protected void repositionSlot( final AppEngSlot s ) - { - if( s.isPlayerSide() ) - { + protected void repositionSlot(final AppEngSlot s) { + if (s.isPlayerSide()) { s.yDisplayPosition = s.getY() + this.ySize - 78 - 5; - } - else - { + } else { s.yDisplayPosition = s.getY() + this.ySize - 78 - 3; } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java index 2e19ae6d..5f1ebf31 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java @@ -41,9 +41,8 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { private GuiFCImgButton combineDisableBtn; private final GuiScrollbar processingScrollBar = new GuiScrollbar(); - public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te ) - { - super( inventoryPlayer, te, new FCBasePartContainerEx( inventoryPlayer, te ) ); + public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { + super(inventoryPlayer, te, new FCBasePartContainerEx(inventoryPlayer, te)); this.container = (FCBasePartContainerEx) this.inventorySlots; setReservedSpace(81); @@ -52,155 +51,147 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { } @Override - protected void actionPerformed( final GuiButton btn ) - { - super.actionPerformed( btn ); + protected void actionPerformed(final GuiButton btn) { + super.actionPerformed(btn); - if( this.encodeBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Encode",(isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)) ); - } - else if( this.clearBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Clear", "1" ) ); - } - else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) ); - } - else if( this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE ) ); - } - else if( this.invertBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Invert", container.inverted ? "0" : "1" ) ); - } - else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Combine", this.combineDisableBtn == btn ? "1" : "0" ) ); - } - else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") ); + if (this.encodeBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminalEx.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0))); + } else if (this.clearBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.Clear", "1")); + } else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminalEx.Substitute", + this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE)); + } else if (this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminalEx.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE)); + } else if (this.invertBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer( + new CPacketFluidPatternTermBtns("PatternTerminalEx.Invert", container.inverted ? "0" : "1")); + } else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminalEx.Combine", this.combineDisableBtn == btn ? "1" : "0")); + } else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminalEx.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0")); } } @Override @SuppressWarnings("unchecked") - public void initGui() - { + public void initGui() { super.initGui(); - this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED ); - this.substitutionsEnabledBtn.setHalfSize( true ); - this.buttonList.add( this.substitutionsEnabledBtn ); + this.substitutionsEnabledBtn = new GuiImgButton( + this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED); + this.substitutionsEnabledBtn.setHalfSize(true); + this.buttonList.add(this.substitutionsEnabledBtn); - this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED ); - this.substitutionsDisabledBtn.setHalfSize( true ); - this.buttonList.add( this.substitutionsDisabledBtn ); + this.substitutionsDisabledBtn = new GuiImgButton( + this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED); + this.substitutionsDisabledBtn.setHalfSize(true); + this.buttonList.add(this.substitutionsDisabledBtn); - this.fluidPrioritizedEnabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "FORCE_PRIO", "DO_PRIO" ); - this.fluidPrioritizedEnabledBtn.setHalfSize( true ); - this.buttonList.add( this.fluidPrioritizedEnabledBtn ); + this.fluidPrioritizedEnabledBtn = + new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 143, "FORCE_PRIO", "DO_PRIO"); + this.fluidPrioritizedEnabledBtn.setHalfSize(true); + this.buttonList.add(this.fluidPrioritizedEnabledBtn); - this.fluidPrioritizedDisabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "NOT_PRIO", "DONT_PRIO" ); - this.fluidPrioritizedDisabledBtn.setHalfSize( true ); - this.buttonList.add( this.fluidPrioritizedDisabledBtn ); + this.fluidPrioritizedDisabledBtn = + new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 143, "NOT_PRIO", "DONT_PRIO"); + this.fluidPrioritizedDisabledBtn.setHalfSize(true); + this.buttonList.add(this.fluidPrioritizedDisabledBtn); - invertBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 153, Settings.ACTIONS, container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4); - invertBtn.setHalfSize( true ); - this.buttonList.add( this.invertBtn ); + invertBtn = new GuiImgButton( + this.guiLeft + 87, + this.guiTop + this.ySize - 153, + Settings.ACTIONS, + container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4); + invertBtn.setHalfSize(true); + this.buttonList.add(this.invertBtn); - this.clearBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ); - this.clearBtn.setHalfSize( true ); - this.buttonList.add( this.clearBtn ); + this.clearBtn = new GuiImgButton( + this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE); + this.clearBtn.setHalfSize(true); + this.buttonList.add(this.clearBtn); - this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ); - this.buttonList.add( this.encodeBtn ); + this.encodeBtn = new GuiImgButton( + this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE); + this.buttonList.add(this.encodeBtn); if (ModAndClassUtil.isDoubleButton) { - this.doubleBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE ); - this.doubleBtn.setHalfSize( true ); - this.buttonList.add( this.doubleBtn ); + this.doubleBtn = new GuiImgButton( + this.guiLeft + 97, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE); + this.doubleBtn.setHalfSize(true); + this.buttonList.add(this.doubleBtn); } - this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "FORCE_COMBINE", "DO_COMBINE" ); - this.combineEnableBtn.setHalfSize( true ); - this.buttonList.add( this.combineEnableBtn ); + this.combineEnableBtn = + new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 143, "FORCE_COMBINE", "DO_COMBINE"); + this.combineEnableBtn.setHalfSize(true); + this.buttonList.add(this.combineEnableBtn); - this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "NOT_COMBINE", "DONT_COMBINE" ); - this.combineDisableBtn.setHalfSize( true ); - this.buttonList.add( this.combineDisableBtn ); + this.combineDisableBtn = + new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 143, "NOT_COMBINE", "DONT_COMBINE"); + this.combineDisableBtn.setHalfSize(true); + this.buttonList.add(this.combineDisableBtn); processingScrollBar.setTop(this.ySize - 164); } @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - if (ModAndClassUtil.isDoubleButton) - this.doubleBtn.visible = true; + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = true; - if( this.container.substitute ) - { + if (this.container.substitute) { this.substitutionsEnabledBtn.visible = true; this.substitutionsDisabledBtn.visible = false; - } - else - { + } else { this.substitutionsEnabledBtn.visible = false; this.substitutionsDisabledBtn.visible = true; } - if( this.container.prioritize ) - { + if (this.container.prioritize) { this.fluidPrioritizedEnabledBtn.visible = false; this.fluidPrioritizedDisabledBtn.visible = true; - } - else - { + } else { this.fluidPrioritizedEnabledBtn.visible = true; this.fluidPrioritizedDisabledBtn.visible = false; } - if ( this.container.combine ) - { + if (this.container.combine) { this.combineEnableBtn.visible = true; this.combineDisableBtn.visible = false; - } - else - { + } else { this.combineEnableBtn.visible = false; this.combineDisableBtn.visible = true; } - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 ); + super.drawFG(offsetX, offsetY, mouseX, mouseY); + this.fontRendererObj.drawString( + StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), + 8, + this.ySize - 96 + 2 - getReservedSpace(), + 4210752); this.processingScrollBar.draw(this); } @Override - protected String getBackground() - { + protected String getBackground() { return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png"; } @Override - protected void repositionSlot( final AppEngSlot s ) - { - if( s.isPlayerSide() ) - { + protected void repositionSlot(final AppEngSlot s) { + if (s.isPlayerSide()) { s.yDisplayPosition = s.getY() + this.ySize - 78 - 5; - } - else - { + } else { s.yDisplayPosition = s.getY() + this.ySize - 78 - 3; } } @Override - public void drawScreen( final int mouseX, final int mouseY, final float btn ) - { + public void drawScreen(final int mouseX, final int mouseY, final float btn) { if (container.substitute) { substitutionsEnabledBtn.visible = true; @@ -217,14 +208,14 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { fluidPrioritizedDisabledBtn.visible = true; } - final int offset = container.inverted? 18 * -3: 0; + final int offset = container.inverted ? 18 * -3 : 0; - substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset; + substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset; substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset; fluidPrioritizedEnabledBtn.xPosition = this.guiLeft + 97 + offset; fluidPrioritizedDisabledBtn.xPosition = this.guiLeft + 97 + offset; doubleBtn.xPosition = this.guiLeft + 97 + offset; - clearBtn.xPosition = this.guiLeft + 87 + offset; + clearBtn.xPosition = this.guiLeft + 87 + offset; invertBtn.xPosition = this.guiLeft + 87 + offset; combineEnableBtn.xPosition = this.guiLeft + 87 + offset; combineDisableBtn.xPosition = this.guiLeft + 87 + offset; @@ -235,8 +226,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { } @Override - protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) - { + protected void mouseClicked(final int xCoord, final int yCoord, final int btn) { final int currentScroll = this.processingScrollBar.getCurrentScroll(); this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop); super.mouseClicked(xCoord, yCoord, btn); @@ -247,10 +237,9 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { } @Override - protected void mouseClickMove( final int x, final int y, final int c, final long d ) - { + protected void mouseClickMove(final int x, final int y, final int c, final long d) { final int currentScroll = this.processingScrollBar.getCurrentScroll(); - this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop ); + this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop); super.mouseClickMove(x, y, c, d); if (currentScroll != this.processingScrollBar.getCurrentScroll()) { @@ -259,8 +248,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { } @Override - public void handleMouseInput() - { + public void handleMouseInput() { super.handleMouseInput(); final int wheel = Mouse.getEventDWheel(); @@ -276,15 +264,12 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { if (currentScroll != this.processingScrollBar.getCurrentScroll()) { changeActivePage(); } - } } - } - private void changeActivePage() - { - FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll()))); + private void changeActivePage() { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns( + "PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll()))); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java b/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java index daa8ab6f..bd858f89 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java @@ -42,51 +42,59 @@ public class GuiDualInterface extends GuiUpgradeable { @Override @SuppressWarnings("unchecked") - protected void addButtons() - { - this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ); - this.buttonList.add( this.priority ); + protected void addButtons() { + this.priority = + new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender); + this.buttonList.add(this.priority); - this.switcher = new GuiTabButton( this.guiLeft + 132, this.guiTop, host instanceof PartFluidInterface ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender ); - this.buttonList.add( this.switcher ); + this.switcher = new GuiTabButton( + this.guiLeft + 132, + this.guiTop, + host instanceof PartFluidInterface + ? ItemAndBlockHolder.FLUID_INTERFACE.stack() + : ItemAndBlockHolder.INTERFACE.stack(), + StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), + itemRender); + this.buttonList.add(this.switcher); - this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO ); - this.buttonList.add( this.BlockMode ); + this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO); + this.buttonList.add(this.BlockMode); - this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal() ); - this.buttonList.add( this.interfaceMode ); + this.interfaceMode = new GuiToggleButton( + this.guiLeft - 18, + this.guiTop + 26, + 84, + 85, + GuiText.InterfaceTerminal.getLocal(), + GuiText.InterfaceTerminalHint.getLocal()); + this.buttonList.add(this.interfaceMode); - this.insertionMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT ); - this.buttonList.add( this.insertionMode ); + this.insertionMode = + new GuiImgButton(this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT); + this.buttonList.add(this.insertionMode); } @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - if( this.BlockMode != null ) - { - this.BlockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() ); + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + if (this.BlockMode != null) { + this.BlockMode.set(((ContainerInterface) this.cvb).getBlockingMode()); } - if( this.interfaceMode != null ) - { - this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).getInterfaceTerminalMode() == YesNo.YES ); + if (this.interfaceMode != null) { + this.interfaceMode.setState(((ContainerInterface) this.cvb).getInterfaceTerminalMode() == YesNo.YES); } - if( this.insertionMode != null ) - { - this.insertionMode.set( ( (ContainerInterface) this.cvb ).getInsertionMode()); + if (this.insertionMode != null) { + this.insertionMode.set(((ContainerInterface) this.cvb).getInsertionMode()); } - this.fontRendererObj.drawString( getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752 ); + this.fontRendererObj.drawString( + getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752); } @Override - protected String getBackground() - { - if (!ModAndClassUtil.isBigInterface) - return "guis/interface.png"; - switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) - { + protected String getBackground() { + if (!ModAndClassUtil.isBigInterface) return "guis/interface.png"; + switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) { case 1: return "guis/interface2.png"; case 2: @@ -98,44 +106,36 @@ public class GuiDualInterface extends GuiUpgradeable { } @Override - protected void actionPerformed( final GuiButton btn ) - { - super.actionPerformed( btn ); + protected void actionPerformed(final GuiButton btn) { + super.actionPerformed(btn); - final boolean backwards = Mouse.isButtonDown( 1 ); + final boolean backwards = Mouse.isButtonDown(1); - if( btn == this.priority ) - { + if (btn == this.priority) { if (host instanceof TileFluidInterface) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY)); - } - else if(host instanceof PartFluidInterface) { + } else if (host instanceof PartFluidInterface) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART)); } } - if( btn == this.switcher ) - { + if (btn == this.switcher) { if (host instanceof TileFluidInterface) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID)); - } - else if (host instanceof PartFluidInterface) { + } else if (host instanceof PartFluidInterface) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART)); } } - if( btn == this.interfaceMode ) - { - NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) ); + if (btn == this.interfaceMode) { + NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards)); } - if( btn == this.BlockMode ) - { - NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) ); + if (btn == this.BlockMode) { + NetworkHandler.instance.sendToServer(new PacketConfigButton(this.BlockMode.getSetting(), backwards)); } - if( btn == this.insertionMode ) - { - NetworkHandler.instance.sendToServer( new PacketConfigButton( this.insertionMode.getSetting(), backwards ) ); + if (btn == this.insertionMode) { + NetworkHandler.instance.sendToServer(new PacketConfigButton(this.insertionMode.getSetting(), backwards)); } } } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java index 9512ca57..44b9c53b 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java @@ -37,6 +37,8 @@ import com.glodblock.github.client.gui.container.FCBaseMonitorContain; import com.glodblock.github.network.CPacketInventoryAction; import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.ModAndClassUtil; +import java.io.IOException; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; @@ -47,11 +49,7 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import java.io.IOException; -import java.util.List; - -public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost -{ +public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost { public static int craftingGridOffsetX; public static int craftingGridOffsetY; @@ -80,113 +78,98 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi private GuiImgButton terminalStyleBox; private GuiImgButton searchStringSave; - public GuiFCBaseMonitor( final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c ) - { + public GuiFCBaseMonitor( + final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c) { - super( c ); + super(c); final GuiScrollbar scrollbar = new GuiScrollbar(); - this.setScrollBar( scrollbar ); - this.repo = new ItemRepo( scrollbar, this ); + this.setScrollBar(scrollbar); + this.repo = new ItemRepo(scrollbar, this); this.xSize = 195; this.ySize = 204; this.standardSize = this.xSize; - this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager(); - ( this.monitorableContainer = (FCBaseMonitorContain) this.inventorySlots ).setGui( this ); + this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager(); + (this.monitorableContainer = (FCBaseMonitorContain) this.inventorySlots).setGui(this); this.viewCell = te instanceof IViewCellStorage; - } - public void postUpdate( final List list ) - { - for( final IAEItemStack is : list ) - { - this.repo.postUpdate( is ); + public void postUpdate(final List list) { + for (final IAEItemStack is : list) { + this.repo.postUpdate(is); } this.repo.updateView(); this.setScrollBar(); } - private void setScrollBar() - { - this.getScrollBar().setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 ); - this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) ); + private void setScrollBar() { + this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2); + this.getScrollBar() + .setRange( + 0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6)); } @Override - protected void actionPerformed( final GuiButton btn ) - { + protected void actionPerformed(final GuiButton btn) { - if( btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn ) - { - NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) ); + if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) { + NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS)); } - if( btn instanceof GuiImgButton ) - { - final boolean backwards = Mouse.isButtonDown( 1 ); + if (btn instanceof GuiImgButton) { + final boolean backwards = Mouse.isButtonDown(1); final GuiImgButton iBtn = (GuiImgButton) btn; - if( iBtn.getSetting() != Settings.ACTIONS ) - { + if (iBtn.getSetting() != Settings.ACTIONS) { final Enum cv = iBtn.getCurrentValue(); - final Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() ); + final Enum next = + Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues()); - if( btn == this.terminalStyleBox ) - { - AEConfig.instance.settings.putSetting( iBtn.getSetting(), next ); - } - else if( btn == this.searchBoxSettings ) - { - AEConfig.instance.settings.putSetting( iBtn.getSetting(), next ); - } - else if( ModAndClassUtil.isSaveText && btn == this.searchStringSave ) - { + if (btn == this.terminalStyleBox) { + AEConfig.instance.settings.putSetting(iBtn.getSetting(), next); + } else if (btn == this.searchBoxSettings) { + AEConfig.instance.settings.putSetting(iBtn.getSetting(), next); + } else if (ModAndClassUtil.isSaveText && btn == this.searchStringSave) { AEConfig.instance.preserveSearchBar = next == YesNo.YES; - } - else - { - try - { - NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) ); - } - catch( final IOException e ) - { - AELog.debug( e ); + } else { + try { + NetworkHandler.instance.sendToServer( + new PacketValueConfig(iBtn.getSetting().name(), next.name())); + } catch (final IOException e) { + AELog.debug(e); } } - iBtn.set( next ); + iBtn.set(next); - if( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class ) - { + if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) { this.reinitalize(); } } } } - private void reinitalize() - { + private void reinitalize() { this.buttonList.clear(); this.initGui(); } @Override @SuppressWarnings("unchecked") - public void initGui() - { - Keyboard.enableRepeatEvents( true ); + public void initGui() { + Keyboard.enableRepeatEvents(true); this.maxRows = this.getMaxRows(); - this.perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 ); + this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL + ? 9 + : 9 + ((this.width - this.standardSize) / 18); - final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.NEI ); + final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI); final int NEI = hasNEI ? 0 : 0; int top = hasNEI ? 22 : 0; @@ -194,38 +177,31 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi final int magicNumber = 114 + 1; final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace; - this.rows = (int) Math.floor( extraSpace / 18.0 ); - if( this.rows > this.maxRows ) - { - top += ( this.rows - this.maxRows ) * 18 / 2; + this.rows = (int) Math.floor(extraSpace / 18.0); + if (this.rows > this.maxRows) { + top += (this.rows - this.maxRows) * 18 / 2; this.rows = this.maxRows; } - if( hasNEI ) - { + if (hasNEI) { this.rows--; } - if( this.rows < 3 ) - { + if (this.rows < 3) { this.rows = 3; } this.getMeSlots().clear(); - for( int y = 0; y < this.rows; y++ ) - { - for( int x = 0; x < this.perRow; x++ ) - { - this.getMeSlots().add( new InternalSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) ); + for (int y = 0; y < this.rows; y++) { + for (int x = 0; x < this.perRow; x++) { + this.getMeSlots() + .add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18)); } } - if( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ) - { - this.xSize = this.standardSize + ( ( this.perRow - 9 ) * 18 ); - } - else - { + if (AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL) { + this.xSize = this.standardSize + ((this.perRow - 9) * 18); + } else { this.xSize = this.standardSize; } @@ -237,61 +213,97 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi this.ySize = magicNumber + this.rows * 18 + this.reservedSpace; // this.guiTop = top; final int unusedSpace = this.height - this.ySize; - this.guiTop = (int) Math.floor( unusedSpace / ( unusedSpace < 0 ? 3.8f : 2.0f ) ); + this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f)); int offset = this.guiTop + 8; - if( this.customSortOrder ) - { - this.buttonList.add( this.SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ) ) ); + if (this.customSortOrder) { + this.buttonList.add( + this.SortByBox = new GuiImgButton( + this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY))); offset += 20; } - this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) ); + this.buttonList.add( + this.ViewBox = new GuiImgButton( + this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting(Settings.VIEW_MODE))); offset += 20; - this.buttonList.add( this.SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting( Settings.SORT_DIRECTION ) ) ); + this.buttonList.add( + this.SortDirBox = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.SORT_DIRECTION, + this.configSrc.getSetting(Settings.SORT_DIRECTION))); offset += 20; - this.buttonList.add( this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ) ) ); + this.buttonList.add( + this.searchBoxSettings = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.SEARCH_MODE, + AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE))); offset += 20; if (ModAndClassUtil.isSaveText) { - this.buttonList.add( this.searchStringSave = new GuiImgButton( this.guiLeft - 18, offset, Settings.SAVE_SEARCH, AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO ) ); + this.buttonList.add( + this.searchStringSave = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.SAVE_SEARCH, + AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO)); offset += 20; } - this.buttonList.add( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting( Settings.TERMINAL_STYLE ) ) ); + this.buttonList.add( + this.terminalStyleBox = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.TERMINAL_STYLE, + AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE))); offset += 20; - this.searchField = new FCGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 ); - this.searchField.setEnableBackgroundDrawing( false ); - this.searchField.setMaxStringLength( 25 ); - this.searchField.setTextColor( 0xFFFFFF ); - this.searchField.setVisible( true ); + this.searchField = new FCGuiTextField( + this.fontRendererObj, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, 12); + this.searchField.setEnableBackgroundDrawing(false); + this.searchField.setMaxStringLength(25); + this.searchField.setTextColor(0xFFFFFF); + this.searchField.setVisible(true); if (ModAndClassUtil.isSearchStringTooltip) searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal()); - if( this.viewCell) - { - if (ModAndClassUtil.isCraftStatus && AEConfig.instance.getConfigManager().getSetting(Settings.CRAFTING_STATUS).equals(CraftingStatus.BUTTON)) { - this.buttonList.add(this.craftingStatusImgBtn = new GuiImgButton(this.guiLeft - 18, offset, Settings.CRAFTING_STATUS, AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS))); + if (this.viewCell) { + if (ModAndClassUtil.isCraftStatus + && AEConfig.instance + .getConfigManager() + .getSetting(Settings.CRAFTING_STATUS) + .equals(CraftingStatus.BUTTON)) { + this.buttonList.add( + this.craftingStatusImgBtn = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.CRAFTING_STATUS, + AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS))); } else { - this.buttonList.add(this.craftingStatusBtn = new GuiTabButton(this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender)); - this.craftingStatusBtn.setHideEdge( 13 ); // GuiTabButton implementation // + this.buttonList.add( + this.craftingStatusBtn = new GuiTabButton( + this.guiLeft + 170, + this.guiTop - 4, + 2 + 11 * 16, + GuiText.CraftingStatus.getLocal(), + itemRender)); + this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation // } } // Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH ); - final Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ); - this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting ); + final Enum setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); + this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting); - if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) - { + if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) { setSearchString(memoryText, false); } - if( this.isSubGui() ) - { + if (this.isSubGui()) { this.repo.updateView(); this.setScrollBar(); } @@ -299,23 +311,18 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi craftingGridOffsetX = Integer.MAX_VALUE; craftingGridOffsetY = Integer.MAX_VALUE; - for( final Object s : this.inventorySlots.inventorySlots ) - { - if( s instanceof AppEngSlot) - { - if( ( (Slot) s ).xDisplayPosition < 195 ) - { - this.repositionSlot( (AppEngSlot) s ); + for (final Object s : this.inventorySlots.inventorySlots) { + if (s instanceof AppEngSlot) { + if (((Slot) s).xDisplayPosition < 195) { + this.repositionSlot((AppEngSlot) s); } } - if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) - { + if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) { final Slot g = (Slot) s; - if( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 ) - { - craftingGridOffsetX = Math.min( craftingGridOffsetX, g.xDisplayPosition ); - craftingGridOffsetY = Math.min( craftingGridOffsetY, g.yDisplayPosition ); + if (g.xDisplayPosition > 0 && g.yDisplayPosition > 0) { + craftingGridOffsetX = Math.min(craftingGridOffsetX, g.xDisplayPosition); + craftingGridOffsetY = Math.min(craftingGridOffsetY, g.yDisplayPosition); } } } @@ -324,176 +331,148 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi craftingGridOffsetY -= 6; } - public void setSearchString(String memoryText, boolean updateView) - { + public void setSearchString(String memoryText, boolean updateView) { this.searchField.setText(memoryText); this.repo.setSearchString(memoryText); - if (updateView) - { + if (updateView) { this.repo.updateView(); this.setScrollBar(); } } @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Terminal.getLocal() ), 8, 6, 4210752 ); - this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.Terminal.getLocal()), 8, 6, 4210752); + this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); } @Override - protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) - { - final Enum searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ); + protected void mouseClicked(final int xCoord, final int yCoord, final int btn) { + final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); - if( searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH ) - { - this.searchField.mouseClicked( xCoord, yCoord, btn ); + if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) { + this.searchField.mouseClicked(xCoord, yCoord, btn); } - if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) ) - { + if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) { setSearchString("", true); } - super.mouseClicked( xCoord, yCoord, btn ); + super.mouseClicked(xCoord, yCoord, btn); } @Override - protected void handleMouseClick( final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton ) - { + protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) { final EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (mouseButton == 3 ){ + if (mouseButton == 3) { if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) { if (slot.getHasStack()) { InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE"); IAEItemStack stack = AEItemStack.create(slot.getStack()); ((AEBaseContainer) this.inventorySlots).setTargetStack(stack); - FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack)); + FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction( + action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack)); return; } } } - if( slot instanceof SlotFake) - { - InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; + if (slot instanceof SlotFake) { + InventoryAction action = + ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) { if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) { action = InventoryAction.MOVE_REGION; - } - else { + } else { action = InventoryAction.PICKUP_SINGLE; } } - if( Ae2ReflectClient.getDragClick(this).size() > 1 ) - { + if (Ae2ReflectClient.getDragClick(this).size() > 1) { return; } - final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 ); - NetworkHandler.instance.sendToServer( p ); + final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0); + NetworkHandler.instance.sendToServer(p); return; } - if( slot instanceof SlotPatternTerm) - { - if( mouseButton == 6 ) - { + if (slot instanceof SlotPatternTerm) { + if (mouseButton == 6) { return; // prevent weird double clicks.. } - try - { - NetworkHandler.instance.sendToServer( ( (SlotPatternTerm) slot ).getRequest( isShiftKeyDown() ) ); + try { + NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown())); + } catch (final IOException e) { + AELog.debug(e); } - catch( final IOException e ) - { - AELog.debug( e ); - } - } - else if( slot instanceof SlotCraftingTerm ) - { - if( mouseButton == 6 ) - { + } else if (slot instanceof SlotCraftingTerm) { + if (mouseButton == 6) { return; // prevent weird double clicks.. } InventoryAction action; - if( isShiftKeyDown() ) - { + if (isShiftKeyDown()) { action = InventoryAction.CRAFT_SHIFT; - } - else - { + } else { // Craft stack on right-click, craft single on left-click - action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM; + action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM; } - final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 ); - NetworkHandler.instance.sendToServer( p ); + final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0); + NetworkHandler.instance.sendToServer(p); return; } - if( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) ) - { - if( this.enableSpaceClicking() && !( slot instanceof SlotPatternTerm ) ) - { + if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { + if (this.enableSpaceClicking() && !(slot instanceof SlotPatternTerm)) { IAEItemStack stack = null; - if( slot instanceof SlotME ) - { - stack = ( (SlotME) slot ).getAEStack(); + if (slot instanceof SlotME) { + stack = ((SlotME) slot).getAEStack(); } int slotNum = Ae2ReflectClient.getInventorySlots(this).size(); - if( !( slot instanceof SlotME ) && slot != null ) - { + if (!(slot instanceof SlotME) && slot != null) { slotNum = slot.slotNumber; } - ( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack ); - final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 ); - NetworkHandler.instance.sendToServer( p ); + ((AEBaseContainer) this.inventorySlots).setTargetStack(stack); + final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0); + NetworkHandler.instance.sendToServer(p); return; } } - if( slot instanceof SlotDisconnected) - { - if( Ae2ReflectClient.getDragClick(this).size() > 1 ) - { + if (slot instanceof SlotDisconnected) { + if (Ae2ReflectClient.getDragClick(this).size() > 1) { return; } InventoryAction action = null; - switch( mouseButton ) - { + switch (mouseButton) { case 0: // pickup / set-down. - { - ItemStack heldStack = player.inventory.getItemStack(); - if (slot.getStack() == null && heldStack != null) - action = InventoryAction.SPLIT_OR_PLACE_SINGLE; - else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1)) - action = InventoryAction.PICKUP_OR_SET_DOWN; - } - break; + { + ItemStack heldStack = player.inventory.getItemStack(); + if (slot.getStack() == null && heldStack != null) + action = InventoryAction.SPLIT_OR_PLACE_SINGLE; + else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1)) + action = InventoryAction.PICKUP_OR_SET_DOWN; + } + break; case 1: action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; break; case 3: // creative dupe: - - if( player.capabilities.isCreativeMode ) - { + if (player.capabilities.isCreativeMode) { action = InventoryAction.CREATIVE_DUPLICATE; } @@ -504,49 +483,46 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi case 6: } - if( action != null ) - { - final PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() ); - NetworkHandler.instance.sendToServer( p ); + if (action != null) { + final PacketInventoryAction p = new PacketInventoryAction( + action, + slot.getSlotIndex(), + ((SlotDisconnected) slot).getSlot().getId()); + NetworkHandler.instance.sendToServer(p); } return; } - if( slot instanceof SlotME ) - { + if (slot instanceof SlotME) { InventoryAction action = null; IAEItemStack stack = null; - switch( mouseButton ) - { + switch (mouseButton) { case 0: // pickup / set-down. action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; - stack = ( (SlotME) slot ).getAEStack(); + stack = ((SlotME) slot).getAEStack(); - if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null ) - { + if (stack != null + && action == InventoryAction.PICKUP_OR_SET_DOWN + && stack.getStackSize() == 0 + && player.inventory.getItemStack() == null) { action = InventoryAction.AUTO_CRAFT; } break; case 1: action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; - stack = ( (SlotME) slot ).getAEStack(); + stack = ((SlotME) slot).getAEStack(); break; case 3: // creative dupe: - - stack = ( (SlotME) slot ).getAEStack(); - if( stack != null && stack.isCraftable() ) - { + stack = ((SlotME) slot).getAEStack(); + if (stack != null && stack.isCraftable()) { action = InventoryAction.AUTO_CRAFT; - } - else if( player.capabilities.isCreativeMode ) - { - final IAEItemStack slotItem = ( (SlotME) slot ).getAEStack(); - if( slotItem != null ) - { + } else if (player.capabilities.isCreativeMode) { + final IAEItemStack slotItem = ((SlotME) slot).getAEStack(); + if (slotItem != null) { action = InventoryAction.CREATIVE_DUPLICATE; } } @@ -558,214 +534,189 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi } if (action == InventoryAction.AUTO_CRAFT) { - ((AEBaseContainer) this.inventorySlots).setTargetStack( stack ); - FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack)); - } - else if( action != null ) - { - ( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack ); - final PacketInventoryAction p = new PacketInventoryAction( action, Ae2ReflectClient.getInventorySlots(this).size(), 0 ); - NetworkHandler.instance.sendToServer( p ); + ((AEBaseContainer) this.inventorySlots).setTargetStack(stack); + FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction( + action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack)); + } else if (action != null) { + ((AEBaseContainer) this.inventorySlots).setTargetStack(stack); + final PacketInventoryAction p = new PacketInventoryAction( + action, Ae2ReflectClient.getInventorySlots(this).size(), 0); + NetworkHandler.instance.sendToServer(p); } return; } - super.handleMouseClick( slot, slotIdx, ctrlDown, mouseButton ); + super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); } @Override - public void onGuiClosed() - { + public void onGuiClosed() { super.onGuiClosed(); - Keyboard.enableRepeatEvents( false ); + Keyboard.enableRepeatEvents(false); memoryText = this.searchField.getText(); } - public void bindTextureBack( final String file ) - { - final ResourceLocation loc = new ResourceLocation( FluidCraft.MODID, "textures/" + file ); - this.mc.getTextureManager().bindTexture( loc ); + public void bindTextureBack(final String file) { + final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file); + this.mc.getTextureManager().bindTexture(loc); } @Override - public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.bindTextureBack( this.getBackground() ); + this.bindTextureBack(this.getBackground()); final int x_width = 195; - this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 ); + this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18); - if( this.viewCell ) - { - this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 ); + if (this.viewCell) { + this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 46, 128); } - for( int x = 0; x < this.rows; x++ ) - { - this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 ); + for (int x = 0; x < this.rows; x++) { + this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18); } - this.drawTexturedModalRect( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset ); + this.drawTexturedModalRect( + offsetX, + offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, + 0, + 106 - 18 - 18, + x_width, + 99 + this.reservedSpace - this.lowerTextureOffset); - if( this.viewCell ) - { + if (this.viewCell) { boolean update = false; - for( int i = 0; i < 5; i++ ) - { - if( this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot( i ).getStack() ) - { + for (int i = 0; i < 5; i++) { + if (this.myCurrentViewCells[i] + != this.monitorableContainer.getCellViewSlot(i).getStack()) { update = true; - this.myCurrentViewCells[i] = this.monitorableContainer.getCellViewSlot( i ).getStack(); + this.myCurrentViewCells[i] = + this.monitorableContainer.getCellViewSlot(i).getStack(); } } - if( update ) - { - this.repo.setViewCell( this.myCurrentViewCells ); + if (update) { + this.repo.setViewCell(this.myCurrentViewCells); } } - if( this.searchField != null ) - { + if (this.searchField != null) { this.searchField.drawTextBox(); } } - protected String getBackground() - { + protected String getBackground() { return "gui/terminal.png"; } @Override - protected boolean isPowered() - { + protected boolean isPowered() { return this.repo.hasPower(); } - int getMaxRows() - { - return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE; + int getMaxRows() { + return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL + ? 6 + : Integer.MAX_VALUE; } - protected void repositionSlot( final AppEngSlot s ) - { + protected void repositionSlot(final AppEngSlot s) { s.yDisplayPosition = s.getY() + this.ySize - 78 - 5; } @Override - protected void keyTyped( final char character, final int key ) - { - if( !this.checkHotbarKeys( key ) ) - { - if( character == ' ' && this.searchField.getText().isEmpty() ) - { + protected void keyTyped(final char character, final int key) { + if (!this.checkHotbarKeys(key)) { + if (character == ' ' && this.searchField.getText().isEmpty()) { return; } - if( this.searchField.textboxKeyTyped( character, key ) ) - { - this.repo.setSearchString( this.searchField.getText() ); + if (this.searchField.textboxKeyTyped(character, key)) { + this.repo.setSearchString(this.searchField.getText()); this.repo.updateView(); this.setScrollBar(); - } - else - { - super.keyTyped( character, key ); + } else { + super.keyTyped(character, key); } } } @Override - public void updateScreen() - { - this.repo.setPower( this.monitorableContainer.isPowered() ); + public void updateScreen() { + this.repo.setPower(this.monitorableContainer.isPowered()); super.updateScreen(); } @Override - public Enum getSortBy() - { - return this.configSrc.getSetting( Settings.SORT_BY ); + public Enum getSortBy() { + return this.configSrc.getSetting(Settings.SORT_BY); } @Override - public Enum getSortDir() - { - return this.configSrc.getSetting( Settings.SORT_DIRECTION ); + public Enum getSortDir() { + return this.configSrc.getSetting(Settings.SORT_DIRECTION); } @Override - public Enum getSortDisplay() - { - return this.configSrc.getSetting( Settings.VIEW_MODE ); + public Enum getSortDisplay() { + return this.configSrc.getSetting(Settings.VIEW_MODE); } @Override - public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue ) - { - if( this.SortByBox != null ) - { - this.SortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) ); + public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) { + if (this.SortByBox != null) { + this.SortByBox.set(this.configSrc.getSetting(Settings.SORT_BY)); } - if( this.SortDirBox != null ) - { - this.SortDirBox.set( this.configSrc.getSetting( Settings.SORT_DIRECTION ) ); + if (this.SortDirBox != null) { + this.SortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION)); } - if( this.ViewBox != null ) - { - this.ViewBox.set( this.configSrc.getSetting( Settings.VIEW_MODE ) ); + if (this.ViewBox != null) { + this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE)); } this.repo.updateView(); } - public int getReservedSpace() - { + public int getReservedSpace() { return this.reservedSpace; } - public void setReservedSpace( final int reservedSpace ) - { + public void setReservedSpace(final int reservedSpace) { this.reservedSpace = reservedSpace; } - public boolean isCustomSortOrder() - { + public boolean isCustomSortOrder() { return this.customSortOrder; } - public void setCustomSortOrder( final boolean customSortOrder ) - { + public void setCustomSortOrder(final boolean customSortOrder) { this.customSortOrder = customSortOrder; } - public int getStandardSize() - { + public int getStandardSize() { return this.standardSize; } - public void setStandardSize( final int standardSize ) - { + public void setStandardSize(final int standardSize) { this.standardSize = standardSize; } @Override - public void drawScreen( final int mouseX, final int mouseY, final float btn ) { + public void drawScreen(final int mouseX, final int mouseY, final float btn) { super.drawScreen(mouseX, mouseY, btn); if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null) handleTooltip(mouseX, mouseY, searchField.new TooltipProvider()); } - public boolean isOverSearchField(int x, int y) - { - return searchField.isMouseIn(x,y); + + public boolean isOverSearchField(int x, int y) { + return searchField.isMouseIn(x, y); } - public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) - { + public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) { if (this.viewCell) { int rw = 33; @@ -789,5 +740,4 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi return false; } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java b/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java index e405c881..a11d36d4 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java @@ -3,19 +3,18 @@ package com.glodblock.github.client.gui; import appeng.client.gui.widgets.ITooltip; import com.glodblock.github.FluidCraft; import com.glodblock.github.util.NameConst; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - public class GuiFCImgButton extends GuiButton implements ITooltip { - private static final Pattern COMPILE = Pattern.compile( "%s" ); - private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL ); + private static final Pattern COMPILE = Pattern.compile("%s"); + private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL); private static Map appearances; private final String buttonSetting; private boolean halfSize = false; @@ -23,7 +22,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { private String currentValue; private static final String prefix = NameConst.TT_KEY; - public GuiFCImgButton( final int x, final int y, final String idx, final String val ) { + public GuiFCImgButton(final int x, final int y, final String idx, final String val) { super(0, 0, 16, ""); this.buttonSetting = idx; @@ -33,37 +32,32 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { this.width = 16; this.height = 16; - if( appearances == null ) { + if (appearances == null) { appearances = new HashMap<>(); - this.registerApp( 0, "NOT_COMBINE", "DONT_COMBINE", "not_combine" ); - this.registerApp( 1, "FORCE_COMBINE", "DO_COMBINE", "combine" ); - this.registerApp( 2, "FORCE_PRIO", "DO_PRIO", "prio" ); - this.registerApp( 3, "NOT_PRIO", "DONT_PRIO", "not_prio" ); + this.registerApp(0, "NOT_COMBINE", "DONT_COMBINE", "not_combine"); + this.registerApp(1, "FORCE_COMBINE", "DO_COMBINE", "combine"); + this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio"); + this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio"); } } - private void registerApp(final int iconIndex, final String setting, final String val, final String title ) - { + private void registerApp(final int iconIndex, final String setting, final String val, final String title) { final ButtonAppearance a = new ButtonAppearance(); a.displayName = StatCollector.translateToLocal(prefix + title); a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint"); a.index = iconIndex; - appearances.put( new EnumPair( setting, val ), a ); + appearances.put(new EnumPair(setting, val), a); } - public void setVisibility( final boolean vis ) - { + public void setVisibility(final boolean vis) { this.visible = vis; this.enabled = vis; } - private int getIconIndex() - { - if( this.buttonSetting != null && this.currentValue != null ) - { - final ButtonAppearance app = appearances.get(new EnumPair( this.buttonSetting, this.currentValue )); - if( app == null ) - { + private int getIconIndex() { + if (this.buttonSetting != null && this.currentValue != null) { + final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue)); + if (app == null) { return 8; } return app.index; @@ -71,121 +65,100 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { return 8; } - public String getSetting() - { + public String getSetting() { return this.buttonSetting; } - public String getCurrentValue() - { + public String getCurrentValue() { return this.currentValue; } - public void set( final String e ) - { - if(!this.currentValue.equals(e)) - { + public void set(final String e) { + if (!this.currentValue.equals(e)) { this.currentValue = e; } } - public boolean isHalfSize() - { + public boolean isHalfSize() { return this.halfSize; } - public void setHalfSize( final boolean halfSize ) - { + public void setHalfSize(final boolean halfSize) { this.halfSize = halfSize; } - public String getFillVar() - { + public String getFillVar() { return this.fillVar; } - public void setFillVar( final String fillVar ) - { + public void setFillVar(final String fillVar) { this.fillVar = fillVar; } @Override - public int xPos() - { + public int xPos() { return this.xPosition; } @Override - public int yPos() - { + public int yPos() { return this.yPosition; } @Override - public int getWidth() - { + public int getWidth() { return this.halfSize ? 8 : 16; } @Override - public int getHeight() - { + public int getHeight() { return this.halfSize ? 8 : 16; } @Override - public boolean isVisible() - { + public boolean isVisible() { return this.visible; } @Override - public String getMessage() - { + public String getMessage() { String displayName = null; String displayValue = null; - if( this.buttonSetting != null && this.currentValue != null ) - { - final ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) ); - if( buttonAppearance == null ) - { + if (this.buttonSetting != null && this.currentValue != null) { + final ButtonAppearance buttonAppearance = + appearances.get(new EnumPair(this.buttonSetting, this.currentValue)); + if (buttonAppearance == null) { return "No Such Message"; } displayName = buttonAppearance.displayName; displayValue = buttonAppearance.displayValue; } - if( displayName != null ) - { - String name = StatCollector.translateToLocal( displayName ); - String value = StatCollector.translateToLocal( displayValue ); + if (displayName != null) { + String name = StatCollector.translateToLocal(displayName); + String value = StatCollector.translateToLocal(displayValue); - if( name == null || name.isEmpty() ) - { + if (name == null || name.isEmpty()) { name = displayName; } - if( value == null || value.isEmpty() ) - { + if (value == null || value.isEmpty()) { value = displayValue; } - if( this.fillVar != null ) - { - value = COMPILE.matcher( value ).replaceFirst( this.fillVar ); + if (this.fillVar != null) { + value = COMPILE.matcher(value).replaceFirst(this.fillVar); } - value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" ); - final StringBuilder sb = new StringBuilder( value ); + value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n"); + final StringBuilder sb = new StringBuilder(value); - int i = sb.lastIndexOf( "\n" ); - if( i <= 0 ) - { + int i = sb.lastIndexOf("\n"); + if (i <= 0) { i = 0; } - while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 ) - { - sb.replace( i, i + 1, "\n" ); + while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) { + sb.replace(i, i + 1, "\n"); } return name + '\n' + sb; @@ -194,94 +167,95 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { } @Override - public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3 ) - { - if( this.visible ) - { + public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) { + if (this.visible) { final int iconIndex = this.getIconIndex(); - if( this.halfSize ) - { + if (this.halfSize) { this.width = 8; this.height = 8; GL11.glPushMatrix(); - GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F ); - GL11.glScalef( 0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3 ); + GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F); + GL11.glScalef(0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3); - if( this.enabled ) - { - GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); - } - else - { - GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); + if (this.enabled) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } else { + GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f); } - par1Minecraft.renderEngine.bindTexture( FluidCraft.resource("textures/gui/states.png") ); - this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; + par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states.png")); + this.field_146123_n = par2 >= this.xPosition + && par3 >= this.yPosition + && par2 < this.xPosition + this.width + && par3 < this.yPosition + this.height; - final int uv_y = (int) Math.floor( iconIndex / 3.0 ); + final int uv_y = (int) Math.floor(iconIndex / 3.0); final int uv_x = iconIndex - uv_y * 3; - this.drawTexturedModalRect( 0, 0, Math.round(32F * 16F / 3F), Math.round(32F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F) ); - this.drawTexturedModalRect( 0, 0, Math.round(uv_x * 16F * 16F / 3F), Math.round(uv_y * 16F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F) ); - this.mouseDragged( par1Minecraft, par2, par3 ); + this.drawTexturedModalRect( + 0, + 0, + Math.round(32F * 16F / 3F), + Math.round(32F * 16F / 3F), + Math.round(16F * 16F / 3F), + Math.round(16F * 16F / 3F)); + this.drawTexturedModalRect( + 0, + 0, + Math.round(uv_x * 16F * 16F / 3F), + Math.round(uv_y * 16F * 16F / 3F), + Math.round(16F * 16F / 3F), + Math.round(16F * 16F / 3F)); + this.mouseDragged(par1Minecraft, par2, par3); GL11.glPopMatrix(); - } - else - { - if( this.enabled ) - { - GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); - } - else - { - GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); + } else { + if (this.enabled) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } else { + GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f); } - par1Minecraft.renderEngine.bindTexture( FluidCraft.resource("textures/gui/states.png") ); - this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; + par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states.png")); + this.field_146123_n = par2 >= this.xPosition + && par3 >= this.yPosition + && par2 < this.xPosition + this.width + && par3 < this.yPosition + this.height; - final int uv_y = (int) Math.floor( iconIndex / 3.0 ); + final int uv_y = (int) Math.floor(iconIndex / 3.0); final int uv_x = iconIndex - uv_y * 3; - this.drawTexturedModalRect( this.xPosition, this.yPosition, 32, 32, 16, 16 ); - this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 ); - this.mouseDragged( par1Minecraft, par2, par3 ); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 32, 32, 16, 16); + this.drawTexturedModalRect(this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16); + this.mouseDragged(par1Minecraft, par2, par3); } } - GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } - private static final class EnumPair - { + private static final class EnumPair { final String setting; final String value; - EnumPair( final String a, final String b ) - { + EnumPair(final String a, final String b) { this.setting = a; this.value = b; } @Override - public int hashCode() - { + public int hashCode() { return this.setting.hashCode() ^ this.value.hashCode(); } @Override - public boolean equals( final Object obj ) - { - if( obj == null ) - { + public boolean equals(final Object obj) { + if (obj == null) { return false; } - if( this.getClass() != obj.getClass() ) - { + if (this.getClass() != obj.getClass()) { return false; } final EnumPair other = (EnumPair) obj; @@ -289,12 +263,9 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { } } - - private static class ButtonAppearance - { + private static class ButtonAppearance { public int index; public String displayName; public String displayValue; } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCPriority.java b/src/main/java/com/glodblock/github/client/gui/GuiFCPriority.java index 86e002b4..8596d984 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCPriority.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCPriority.java @@ -17,14 +17,12 @@ import com.glodblock.github.common.tile.TileFluidInterface; import com.glodblock.github.inventory.gui.GuiType; import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.network.CPacketSwitchGuis; +import java.io.IOException; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import java.io.IOException; - -public class GuiFCPriority extends AEBaseGui -{ +public class GuiFCPriority extends AEBaseGui { private GuiNumberBox priority; private GuiTabButton originalGuiBtn; @@ -40,180 +38,162 @@ public class GuiFCPriority extends AEBaseGui private GuiType OriginalGui; - public GuiFCPriority( final InventoryPlayer inventoryPlayer, final IPriorityHost te ) - { - super( new ContainerPriority( inventoryPlayer, te ) ); + public GuiFCPriority(final InventoryPlayer inventoryPlayer, final IPriorityHost te) { + super(new ContainerPriority(inventoryPlayer, te)); } @Override @SuppressWarnings("unchecked") - public void initGui() - { + public void initGui() { super.initGui(); - final int a = AEConfig.instance.priorityByStacksAmounts( 0 ); - final int b = AEConfig.instance.priorityByStacksAmounts( 1 ); - final int c = AEConfig.instance.priorityByStacksAmounts( 2 ); - final int d = AEConfig.instance.priorityByStacksAmounts( 3 ); + final int a = AEConfig.instance.priorityByStacksAmounts(0); + final int b = AEConfig.instance.priorityByStacksAmounts(1); + final int c = AEConfig.instance.priorityByStacksAmounts(2); + final int d = AEConfig.instance.priorityByStacksAmounts(3); - this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) ); - this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) ); - this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) ); - this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) ); + this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a)); + this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b)); + this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c)); + this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d)); - - this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) ); - this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) ); - this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) ); - this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) ); + this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a)); + this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b)); + this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c)); + this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d)); ItemStack myIcon = null; - final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget(); + final Object target = ((AEBaseContainer) this.inventorySlots).getTarget(); - if( target instanceof TileFluidInterface) - { + if (target instanceof TileFluidInterface) { myIcon = ItemAndBlockHolder.INTERFACE.stack(); this.OriginalGui = GuiType.DUAL_INTERFACE; - } - else if (target instanceof PartFluidInterface) - { + } else if (target instanceof PartFluidInterface) { myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack(); this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART; } - if( this.OriginalGui != null && myIcon != null ) - { - this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) ); + if (this.OriginalGui != null && myIcon != null) { + this.buttonList.add( + this.originalGuiBtn = new GuiTabButton( + this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender)); } - this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class ); - this.priority.setEnableBackgroundDrawing( false ); - this.priority.setMaxStringLength( 16 ); - this.priority.setTextColor( 0xFFFFFF ); - this.priority.setVisible( true ); - this.priority.setFocused( true ); - ( (ContainerPriority) this.inventorySlots ).setTextField( this.priority ); + this.priority = new GuiNumberBox( + this.fontRendererObj, + this.guiLeft + 62, + this.guiTop + 57, + 59, + this.fontRendererObj.FONT_HEIGHT, + Long.class); + this.priority.setEnableBackgroundDrawing(false); + this.priority.setMaxStringLength(16); + this.priority.setTextColor(0xFFFFFF); + this.priority.setVisible(true); + this.priority.setFocused(true); + ((ContainerPriority) this.inventorySlots).setTextField(this.priority); } @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 ); + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 4210752); } @Override - public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.bindTexture( getBackground() ); - this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize ); + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.bindTexture(getBackground()); + this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize); this.priority.drawTextBox(); } @Override - protected void actionPerformed( final GuiButton btn ) - { - super.actionPerformed( btn ); + protected void actionPerformed(final GuiButton btn) { + super.actionPerformed(btn); - if( btn == this.originalGuiBtn ) - { + if (btn == this.originalGuiBtn) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui)); } final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000; - final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; + final boolean isMinus = + btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; - if( isPlus || isMinus ) - { - this.addQty( this.getQty( btn ) ); + if (isPlus || isMinus) { + this.addQty(this.getQty(btn)); } } - private void addQty( final int i ) - { - try - { + private void addQty(final int i) { + try { String out = this.priority.getText(); boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); fixed = true; } - if( fixed ) - { - this.priority.setText( out ); + if (fixed) { + this.priority.setText(out); } - if( out.isEmpty() ) - { + if (out.isEmpty()) { out = "0"; } - long result = Long.parseLong( out ); + long result = Long.parseLong(out); result += i; - this.priority.setText( out = Long.toString( result ) ); + this.priority.setText(out = Long.toString(result)); - NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); - } - catch( final NumberFormatException e ) - { + NetworkHandler.instance.sendToServer(new PacketValueConfig("PriorityHost.Priority", out)); + } catch (final NumberFormatException e) { // nope.. - this.priority.setText( "0" ); - } - catch( final IOException e ) - { - AELog.debug( e ); + this.priority.setText("0"); + } catch (final IOException e) { + AELog.debug(e); } } @Override - protected void keyTyped( final char character, final int key ) - { - if( !this.checkHotbarKeys( key ) ) - { - if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority.textboxKeyTyped( character, key ) ) - { - try - { + protected void keyTyped(final char character, final int key) { + if (!this.checkHotbarKeys(key)) { + if ((key == 211 + || key == 205 + || key == 203 + || key == 14 + || character == '-' + || Character.isDigit(character)) + && this.priority.textboxKeyTyped(character, key)) { + try { String out = this.priority.getText(); boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); fixed = true; } - if( fixed ) - { - this.priority.setText( out ); + if (fixed) { + this.priority.setText(out); } - if( out.isEmpty() ) - { + if (out.isEmpty()) { out = "0"; } - NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); + NetworkHandler.instance.sendToServer(new PacketValueConfig("PriorityHost.Priority", out)); + } catch (final IOException e) { + AELog.debug(e); } - catch( final IOException e ) - { - AELog.debug( e ); - } - } - else - { - super.keyTyped( character, key ); + } else { + super.keyTyped(character, key); } } } - protected String getBackground() - { + protected String getBackground() { return "guis/priority.png"; } } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftAmount.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftAmount.java index fd2cb71d..b0f8da59 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftAmount.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftAmount.java @@ -23,8 +23,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -public class GuiFluidCraftAmount extends AEBaseGui -{ +public class GuiFluidCraftAmount extends AEBaseGui { private GuiNumberBox amountToCraft; private GuiTabButton originalGuiBtn; @@ -42,40 +41,38 @@ public class GuiFluidCraftAmount extends AEBaseGui private GuiType originalGui; @Reflected - public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te ) - { - super( new ContainerCraftAmount( inventoryPlayer, te ) ); + public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { + super(new ContainerCraftAmount(inventoryPlayer, te)); } @Override - public void initGui() - { + public void initGui() { super.initGui(); - final int a = AEConfig.instance.craftItemsByStackAmounts( 0 ); - final int b = AEConfig.instance.craftItemsByStackAmounts( 1 ); - final int c = AEConfig.instance.craftItemsByStackAmounts( 2 ); - final int d = AEConfig.instance.craftItemsByStackAmounts( 3 ); + final int a = AEConfig.instance.craftItemsByStackAmounts(0); + final int b = AEConfig.instance.craftItemsByStackAmounts(1); + final int c = AEConfig.instance.craftItemsByStackAmounts(2); + final int d = AEConfig.instance.craftItemsByStackAmounts(3); - this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) ); - this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) ); - this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) ); - this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) ); + this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a)); + this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b)); + this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c)); + this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d)); - this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) ); - this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) ); - this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) ); - this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) ); + this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a)); + this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b)); + this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c)); + this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d)); - this.buttonList.add( this.next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) ); + this.buttonList.add( + this.next = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal())); ItemStack myIcon = null; - final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget(); + final Object target = ((AEBaseContainer) this.inventorySlots).getTarget(); final IDefinitions definitions = AEApi.instance().definitions(); final IParts parts = definitions.parts(); - if( target instanceof PartFluidPatternTerminal) - { + if (target instanceof PartFluidPatternTerminal) { myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1); this.originalGui = GuiType.FLUID_PATTERN_TERMINAL; } @@ -84,42 +81,44 @@ public class GuiFluidCraftAmount extends AEBaseGui this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX; } - if( this.originalGui != null && myIcon != null ) - { - this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) ); + if (this.originalGui != null && myIcon != null) { + this.buttonList.add( + this.originalGuiBtn = new GuiTabButton( + this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender)); } - this.amountToCraft = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class ); - this.amountToCraft.setEnableBackgroundDrawing( false ); - this.amountToCraft.setMaxStringLength( 16 ); - this.amountToCraft.setTextColor( 0xFFFFFF ); - this.amountToCraft.setVisible( true ); - this.amountToCraft.setFocused( true ); - this.amountToCraft.setText( "1" ); + this.amountToCraft = new GuiNumberBox( + this.fontRendererObj, + this.guiLeft + 62, + this.guiTop + 57, + 59, + this.fontRendererObj.FONT_HEIGHT, + Integer.class); + this.amountToCraft.setEnableBackgroundDrawing(false); + this.amountToCraft.setMaxStringLength(16); + this.amountToCraft.setTextColor(0xFFFFFF); + this.amountToCraft.setVisible(true); + this.amountToCraft.setFocused(true); + this.amountToCraft.setText("1"); this.amountToCraft.setSelectionPos(0); } @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 ); + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752); } @Override - public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal(); - this.bindTexture( "guis/craftAmt.png" ); - this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize ); + this.bindTexture("guis/craftAmt.png"); + this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize); - try - { - Long.parseLong( this.amountToCraft.getText() ); + try { + Long.parseLong(this.amountToCraft.getText()); this.next.enabled = this.amountToCraft.getText().length() > 0; - } - catch( final NumberFormatException e ) - { + } catch (final NumberFormatException e) { this.next.enabled = false; } @@ -127,132 +126,110 @@ public class GuiFluidCraftAmount extends AEBaseGui } @Override - protected void keyTyped( final char character, final int key ) - { - if( !this.checkHotbarKeys( key ) ) - { - if( key == 28 ) - { - this.actionPerformed( this.next ); + protected void keyTyped(final char character, final int key) { + if (!this.checkHotbarKeys(key)) { + if (key == 28) { + this.actionPerformed(this.next); } - if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.amountToCraft.textboxKeyTyped( character, key ) ) - { - try - { + if ((key == 211 + || key == 205 + || key == 203 + || key == 14 + || character == '-' + || Character.isDigit(character)) + && this.amountToCraft.textboxKeyTyped(character, key)) { + try { String out = this.amountToCraft.getText(); boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); fixed = true; } - if( fixed ) - { - this.amountToCraft.setText( out ); + if (fixed) { + this.amountToCraft.setText(out); } - if( out.isEmpty() ) - { + if (out.isEmpty()) { out = "0"; } - final long result = Long.parseLong( out ); - if( result < 0 ) - { - this.amountToCraft.setText( "1" ); + final long result = Long.parseLong(out); + if (result < 0) { + this.amountToCraft.setText("1"); } - } - catch( final NumberFormatException e ) - { + } catch (final NumberFormatException e) { // :P } - } - else - { - super.keyTyped( character, key ); + } else { + super.keyTyped(character, key); } } } @Override - protected void actionPerformed( final GuiButton btn ) - { - super.actionPerformed( btn ); + protected void actionPerformed(final GuiButton btn) { + super.actionPerformed(btn); - try - { + try { - if( btn == this.originalGuiBtn ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketSwitchGuis( this.originalGui ) ); + if (btn == this.originalGuiBtn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui)); } - if( btn == this.next ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) ); + if (btn == this.next) { + FluidCraft.proxy.netHandler.sendToServer( + new CPacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown())); } - } - catch( final NumberFormatException e ) - { + } catch (final NumberFormatException e) { // nope.. - this.amountToCraft.setText( "1" ); + this.amountToCraft.setText("1"); } final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000; - final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; + final boolean isMinus = + btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; - if( isPlus || isMinus ) - { - this.addQty( this.getQty( btn ) ); + if (isPlus || isMinus) { + this.addQty(this.getQty(btn)); } } - private void addQty( final int i ) - { - try - { + private void addQty(final int i) { + try { String out = this.amountToCraft.getText(); boolean fixed = false; - while( out.startsWith( "0" ) && out.length() > 1 ) - { - out = out.substring( 1 ); + while (out.startsWith("0") && out.length() > 1) { + out = out.substring(1); fixed = true; } - if( fixed ) - { - this.amountToCraft.setText( out ); + if (fixed) { + this.amountToCraft.setText(out); } - if( out.isEmpty() ) - { + if (out.isEmpty()) { out = "0"; } - long result = Integer.parseInt( out ); + long result = Integer.parseInt(out); - if( result == 1 && i > 1 ) - { + if (result == 1 && i > 1) { result = 0; } result += i; - if( result < 1 ) - { + if (result < 1) { result = 1; } - out = Long.toString( result ); - Integer.parseInt( out ); - this.amountToCraft.setText( out ); - } - catch( final NumberFormatException e ) - { + out = Long.toString(result); + Integer.parseInt(out); + this.amountToCraft.setText(out); + } catch (final NumberFormatException e) { // :P } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftConfirm.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftConfirm.java index 5c29c1e6..f3faf886 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftConfirm.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftConfirm.java @@ -19,17 +19,16 @@ import com.glodblock.github.network.CPacketFluidPatternTermBtns; import com.glodblock.github.network.CPacketSwitchGuis; import com.glodblock.github.util.ModAndClassUtil; import com.google.common.base.Joiner; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - import java.text.NumberFormat; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; public class GuiFluidCraftConfirm extends AEBaseGui { @@ -51,78 +50,76 @@ public class GuiFluidCraftConfirm extends AEBaseGui { private ItemStack hoveredStack; - public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te ) - { - super( new ContainerFluidCraftConfirm( inventoryPlayer, te ) ); + public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { + super(new ContainerFluidCraftConfirm(inventoryPlayer, te)); this.xSize = 238; this.ySize = 206; final GuiScrollbar scrollbar = new GuiScrollbar(); - this.setScrollBar( scrollbar ); + this.setScrollBar(scrollbar); this.ccc = (ContainerFluidCraftConfirm) this.inventorySlots; - if( te instanceof PartFluidPatternTerminal) - { + if (te instanceof PartFluidPatternTerminal) { this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL; } - if( te instanceof PartFluidPatternTerminalEx) - { + if (te instanceof PartFluidPatternTerminalEx) { this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX; } } - boolean isAutoStart() - { - return ( (ContainerFluidCraftConfirm) this.inventorySlots ).isAutoStart(); + boolean isAutoStart() { + return ((ContainerFluidCraftConfirm) this.inventorySlots).isAutoStart(); } @Override - public void initGui() - { + public void initGui() { super.initGui(); - this.start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal() ); + this.start = + new GuiButton(0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal()); this.start.enabled = false; - this.buttonList.add( this.start ); + this.buttonList.add(this.start); - this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic ); + this.selectCPU = new GuiButton( + 0, + this.guiLeft + (219 - 180) / 2, + this.guiTop + this.ySize - 68, + 180, + 20, + GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic); this.selectCPU.enabled = false; - this.buttonList.add( this.selectCPU ); + this.buttonList.add(this.selectCPU); - if( this.OriginalGui != null ) - { - this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() ); + if (this.OriginalGui != null) { + this.cancel = new GuiButton( + 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal()); } - this.buttonList.add( this.cancel ); + this.buttonList.add(this.cancel); } @Override - public void drawScreen( final int mouseX, final int mouseY, final float btn ) - { + public void drawScreen(final int mouseX, final int mouseY, final float btn) { this.updateCPUButtonText(); - this.start.enabled = !( this.ccc.hasNoCPU() || this.isSimulation() ); + this.start.enabled = !(this.ccc.hasNoCPU() || this.isSimulation()); this.selectCPU.enabled = !this.isSimulation(); - final int gx = ( this.width - this.xSize ) / 2; - final int gy = ( this.height - this.ySize ) / 2; + final int gx = (this.width - this.xSize) / 2; + final int gy = (this.height - this.ySize) / 2; this.tooltip = -1; final int offY = 23; int y = 0; int x = 0; - for( int z = 0; z <= 4 * 5; z++ ) - { + for (int z = 0; z <= 4 * 5; z++) { final int minX = gx + 9 + x * 67; final int minY = gy + 22 + y * offY; - if( minX < mouseX && minX + 67 > mouseX ) - { - if( minY < mouseY && minY + offY - 2 > mouseY ) - { + if (minX < mouseX && minX + 67 > mouseX) { + if (minY < mouseY && minY + offY - 2 > mouseY) { this.tooltip = z; break; } @@ -130,66 +127,61 @@ public class GuiFluidCraftConfirm extends AEBaseGui { x++; - if( x > 2 ) - { + if (x > 2) { y++; x = 0; } } - super.drawScreen( mouseX, mouseY, btn ); + super.drawScreen(mouseX, mouseY, btn); } - private void updateCPUButtonText() - { + private void updateCPUButtonText() { String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal(); - if( this.ccc.getSelectedCpu() >= 0 )// && status.selectedCpu < status.cpus.size() ) + if (this.ccc.getSelectedCpu() >= 0) // && status.selectedCpu < status.cpus.size() ) { - if( this.ccc.getName().length() > 0 ) - { - final String name = this.ccc.getName().substring( 0, Math.min( 20, this.ccc.getName().length() ) ); + if (this.ccc.getName().length() > 0) { + final String name = this.ccc + .getName() + .substring(0, Math.min(20, this.ccc.getName().length())); btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name; - } - else - { + } else { btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.getSelectedCpu(); } } - if( this.ccc.hasNoCPU() ) - { + if (this.ccc.hasNoCPU()) { btnTextText = GuiText.NoCraftingCPUs.getLocal(); } this.selectCPU.displayString = btnTextText; } - private boolean isSimulation() - { - return ( (ContainerFluidCraftConfirm) this.inventorySlots ).isSimulation(); + private boolean isSimulation() { + return ((ContainerFluidCraftConfirm) this.inventorySlots).isSimulation(); } @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { final long BytesUsed = this.ccc.getUsedBytes(); - final String byteUsed = NumberFormat.getInstance().format( BytesUsed ); - final String Add = BytesUsed > 0 ? ( byteUsed + ' ' + GuiText.BytesUsed.getLocal() ) : GuiText.CalculatingWait.getLocal(); - this.fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 ); + final String byteUsed = NumberFormat.getInstance().format(BytesUsed); + final String Add = + BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal(); + this.fontRendererObj.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752); String dsp = null; - if( this.isSimulation() ) - { + if (this.isSimulation()) { dsp = GuiText.Simulation.getLocal(); - } - else - { - dsp = this.ccc.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; + } else { + dsp = this.ccc.getCpuAvailableBytes() > 0 + ? (GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + + GuiText.CoProcessors.getLocal() + ": " + this.ccc.getCpuCoProcessors()) + : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; } - final int offset = ( 219 - this.fontRendererObj.getStringWidth( dsp ) ) / 2; - this.fontRendererObj.drawString( dsp, offset, 165, 4210752 ); + final int offset = (219 - this.fontRendererObj.getStringWidth(dsp)) / 2; + this.fontRendererObj.drawString(dsp, offset, 165, 4210752); final int sectionLength = 67; @@ -207,353 +199,302 @@ public class GuiFluidCraftConfirm extends AEBaseGui { hoveredStack = null; final int offY = 23; - for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ ) - { - final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z ); - if( refStack != null ) - { + for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) { + final IAEItemStack refStack = this.visual.get(z); // repo.getReferenceItem( z ); + if (refStack != null) { GL11.glPushMatrix(); - GL11.glScaled( 0.5, 0.5, 0.5 ); + GL11.glScaled(0.5, 0.5, 0.5); - final IAEItemStack stored = this.storage.findPrecise( refStack ); - final IAEItemStack pendingStack = this.pending.findPrecise( refStack ); - final IAEItemStack missingStack = this.missing.findPrecise( refStack ); + final IAEItemStack stored = this.storage.findPrecise(refStack); + final IAEItemStack pendingStack = this.pending.findPrecise(refStack); + final IAEItemStack missingStack = this.missing.findPrecise(refStack); int lines = 0; - if( stored != null && stored.getStackSize() > 0 ) - { + if (stored != null && stored.getStackSize() > 0) { lines++; } - if( pendingStack != null && pendingStack.getStackSize() > 0 ) - { + if (pendingStack != null && pendingStack.getStackSize() > 0) { lines++; } - if( pendingStack != null && pendingStack.getStackSize() > 0 ) - { + if (pendingStack != null && pendingStack.getStackSize() > 0) { lines++; } - final int negY = ( ( lines - 1 ) * 5 ) / 2; + final int negY = ((lines - 1) * 5) / 2; int downY = 0; - if( stored != null && stored.getStackSize() > 0 ) - { - String str = Long.toString( stored.getStackSize() ); - if( stored.getStackSize() >= 10000 ) - { - str = Long.toString( stored.getStackSize() / 1000 ) + 'k'; + if (stored != null && stored.getStackSize() > 0) { + String str = Long.toString(stored.getStackSize()); + if (stored.getStackSize() >= 10000) { + str = Long.toString(stored.getStackSize() / 1000) + 'k'; } - if( stored.getStackSize() >= 10000000 ) - { - str = Long.toString( stored.getStackSize() / 1000000 ) + 'm'; + if (stored.getStackSize() >= 10000000) { + str = Long.toString(stored.getStackSize() / 1000000) + 'm'; } str = GuiText.FromStorage.getLocal() + ": " + str; - final int w = 4 + this.fontRendererObj.getStringWidth( str ); - this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); + final int w = 4 + this.fontRendererObj.getStringWidth(str); + this.fontRendererObj.drawString( + str, + (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), + (y * offY + yo + 6 - negY + downY) * 2, + 4210752); - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.FromStorage.getLocal() + ": " + stored.getStackSize()); + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.FromStorage.getLocal() + ": " + stored.getStackSize()); } downY += 5; } boolean red = false; - if( missingStack != null && missingStack.getStackSize() > 0 ) - { - String str = Long.toString( missingStack.getStackSize() ); - if( missingStack.getStackSize() >= 10000 ) - { - str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k'; + if (missingStack != null && missingStack.getStackSize() > 0) { + String str = Long.toString(missingStack.getStackSize()); + if (missingStack.getStackSize() >= 10000) { + str = Long.toString(missingStack.getStackSize() / 1000) + 'k'; } - if( missingStack.getStackSize() >= 10000000 ) - { - str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm'; + if (missingStack.getStackSize() >= 10000000) { + str = Long.toString(missingStack.getStackSize() / 1000000) + 'm'; } str = GuiText.Missing.getLocal() + ": " + str; - final int w = 4 + this.fontRendererObj.getStringWidth( str ); - this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); + final int w = 4 + this.fontRendererObj.getStringWidth(str); + this.fontRendererObj.drawString( + str, + (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), + (y * offY + yo + 6 - negY + downY) * 2, + 4210752); - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.Missing.getLocal() + ": " + missingStack.getStackSize()); + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.Missing.getLocal() + ": " + missingStack.getStackSize()); } red = true; downY += 5; } - if( pendingStack != null && pendingStack.getStackSize() > 0 ) - { - String str = Long.toString( pendingStack.getStackSize() ); - if( pendingStack.getStackSize() >= 10000 ) - { - str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k'; + if (pendingStack != null && pendingStack.getStackSize() > 0) { + String str = Long.toString(pendingStack.getStackSize()); + if (pendingStack.getStackSize() >= 10000) { + str = Long.toString(pendingStack.getStackSize() / 1000) + 'k'; } - if( pendingStack.getStackSize() >= 10000000 ) - { - str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm'; + if (pendingStack.getStackSize() >= 10000000) { + str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm'; } str = GuiText.ToCraft.getLocal() + ": " + str; - final int w = 4 + this.fontRendererObj.getStringWidth( str ); - this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); + final int w = 4 + this.fontRendererObj.getStringWidth(str); + this.fontRendererObj.drawString( + str, + (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), + (y * offY + yo + 6 - negY + downY) * 2, + 4210752); - if( this.tooltip == z - viewStart ) - { - lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) ); + if (this.tooltip == z - viewStart) { + lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize())); } } GL11.glPopMatrix(); - final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19; + final int posX = x * (1 + sectionLength) + xo + sectionLength - 19; final int posY = y * offY + yo; final ItemStack is = CoreModHooks.displayFluid(refStack.copy()); - if( this.tooltip == z - viewStart ) - { - dspToolTip = Platform.getItemDisplayName( is ); - if( lineList.size() > 0 ) - { + if (this.tooltip == z - viewStart) { + dspToolTip = Platform.getItemDisplayName(is); + if (lineList.size() > 0) { addItemTooltip(is, lineList); - dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList ); + dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList); } - toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8; + toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8; toolPosY = y * offY + yo; hoveredStack = is; } - this.drawItem( posX, posY, is ); + this.drawItem(posX, posY, is); - if( red ) - { - final int startX = x * ( 1 + sectionLength ) + xo; + if (red) { + final int startX = x * (1 + sectionLength) + xo; final int startY = posY - 4; - drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 ); + drawRect(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000); } x++; - if( x > 2 ) - { + if (x > 2) { y++; x = 0; } } } - if( this.tooltip >= 0 && dspToolTip.length() > 0 ) - { - this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip ); + if (this.tooltip >= 0 && dspToolTip.length() > 0) { + this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip); } } @Override - public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { + public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { this.setScrollBar(); - this.bindTexture( "guis/craftingreport.png" ); - this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize ); + this.bindTexture("guis/craftingreport.png"); + this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize); } - private void setScrollBar() - { + private void setScrollBar() { final int size = this.visual.size(); - this.getScrollBar().setTop( 19 ).setLeft( 218 ).setHeight( 114 ); - this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - this.rows, 1 ); + this.getScrollBar().setTop(19).setLeft(218).setHeight(114); + this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1); } - public void postUpdate( final List list, final byte ref ) - { - switch( ref ) - { + public void postUpdate(final List list, final byte ref) { + switch (ref) { case 0: - for( final IAEItemStack l : list ) - { - this.handleInput( this.storage, l ); + for (final IAEItemStack l : list) { + this.handleInput(this.storage, l); } break; case 1: - for( final IAEItemStack l : list ) - { - this.handleInput( this.pending, l ); + for (final IAEItemStack l : list) { + this.handleInput(this.pending, l); } break; case 2: - for( final IAEItemStack l : list ) - { - this.handleInput( this.missing, l ); + for (final IAEItemStack l : list) { + this.handleInput(this.missing, l); } break; } - for( final IAEItemStack l : list ) - { - final long amt = this.getTotal( l ); + for (final IAEItemStack l : list) { + final long amt = this.getTotal(l); - if( amt <= 0 ) - { - this.deleteVisualStack( l ); - } - else - { - final IAEItemStack is = this.findVisualStack( l ); - is.setStackSize( amt ); + if (amt <= 0) { + this.deleteVisualStack(l); + } else { + final IAEItemStack is = this.findVisualStack(l); + is.setStackSize(amt); } } this.setScrollBar(); } - private void handleInput( final IItemList s, final IAEItemStack l ) - { - IAEItemStack a = s.findPrecise( l ); + private void handleInput(final IItemList s, final IAEItemStack l) { + IAEItemStack a = s.findPrecise(l); - if( l.getStackSize() <= 0 ) - { - if( a != null ) - { + if (l.getStackSize() <= 0) { + if (a != null) { a.reset(); } - } - else - { - if( a == null ) - { - s.add( l.copy() ); - a = s.findPrecise( l ); + } else { + if (a == null) { + s.add(l.copy()); + a = s.findPrecise(l); } - if( a != null ) - { - a.setStackSize( l.getStackSize() ); + if (a != null) { + a.setStackSize(l.getStackSize()); } } } - private long getTotal( final IAEItemStack is ) - { - final IAEItemStack a = this.storage.findPrecise( is ); - final IAEItemStack c = this.pending.findPrecise( is ); - final IAEItemStack m = this.missing.findPrecise( is ); + private long getTotal(final IAEItemStack is) { + final IAEItemStack a = this.storage.findPrecise(is); + final IAEItemStack c = this.pending.findPrecise(is); + final IAEItemStack m = this.missing.findPrecise(is); long total = 0; - if( a != null ) - { + if (a != null) { total += a.getStackSize(); } - if( c != null ) - { + if (c != null) { total += c.getStackSize(); } - if( m != null ) - { + if (m != null) { total += m.getStackSize(); } return total; } - private void deleteVisualStack( final IAEItemStack l ) - { + private void deleteVisualStack(final IAEItemStack l) { final Iterator i = this.visual.iterator(); - while( i.hasNext() ) - { + while (i.hasNext()) { final IAEItemStack o = i.next(); - if( o.equals( l ) ) - { + if (o.equals(l)) { i.remove(); return; } } } - private IAEItemStack findVisualStack( final IAEItemStack l ) - { - for( final IAEItemStack o : this.visual ) - { - if( o.equals( l ) ) - { + private IAEItemStack findVisualStack(final IAEItemStack l) { + for (final IAEItemStack o : this.visual) { + if (o.equals(l)) { return o; } } final IAEItemStack stack = l.copy(); - this.visual.add( stack ); + this.visual.add(stack); return stack; } @Override - protected void keyTyped( final char character, final int key ) - { - if( !this.checkHotbarKeys( key ) ) - { - if( key == 28 ) - { - this.actionPerformed( this.start ); + protected void keyTyped(final char character, final int key) { + if (!this.checkHotbarKeys(key)) { + if (key == 28) { + this.actionPerformed(this.start); } - super.keyTyped( character, key ); + super.keyTyped(character, key); } } @Override - protected void actionPerformed( final GuiButton btn ) - { - super.actionPerformed( btn ); + protected void actionPerformed(final GuiButton btn) { + super.actionPerformed(btn); - final boolean backwards = Mouse.isButtonDown( 1 ); + final boolean backwards = Mouse.isButtonDown(1); - if( btn == this.selectCPU ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "Terminal.Cpu", backwards ? "Prev" : "Next" ) ); + if (btn == this.selectCPU) { + FluidCraft.proxy.netHandler.sendToServer( + new CPacketFluidPatternTermBtns("Terminal.Cpu", backwards ? "Prev" : "Next")); } - if( btn == this.cancel ) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketSwitchGuis( this.OriginalGui ) ); + if (btn == this.cancel) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui)); } - if( btn == this.start ) - { - try - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "Terminal.Start", "Start" ) ); - } - catch( final Throwable e ) - { - AELog.debug( e ); + if (btn == this.start) { + try { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("Terminal.Start", "Start")); + } catch (final Throwable e) { + AELog.debug(e); } } } @SuppressWarnings({"rawtypes", "unchecked"}) - protected void addItemTooltip(ItemStack is, List lineList) - { - if (isShiftKeyDown()) - { + protected void addItemTooltip(ItemStack is, List lineList) { + if (isShiftKeyDown()) { List l = is.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); - if (!l.isEmpty()) - l.remove(0); + if (!l.isEmpty()) l.remove(0); lineList.addAll(l); - } - else if (ModAndClassUtil.isShiftTooltip) - { + } else if (ModAndClassUtil.isShiftTooltip) { lineList.add(GuiText.HoldShiftForTooltip.getLocal()); } } + public ItemStack getHoveredStack() { return hoveredStack; } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidIO.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidIO.java index 4a6baab0..22acc6c9 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidIO.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidIO.java @@ -10,50 +10,49 @@ import com.glodblock.github.util.NameConst; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; -public class GuiFluidIO extends GuiUpgradeable -{ +public class GuiFluidIO extends GuiUpgradeable { private final PartSharedFluidBus bus; - public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te ) - { - super( new ContainerFluidIO( inventoryPlayer, te ) ); + public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te) { + super(new ContainerFluidIO(inventoryPlayer, te)); this.bus = te; } - @Override - protected GuiText getName() - { + protected GuiText getName() { return this.bus instanceof PartFluidImportBus ? GuiText.ImportBus : GuiText.ExportBus; } public void update(int id, IAEFluidStack stack) { - ((ContainerFluidIO)this.cvb).getBus().setFluidInSlot(id, stack); + ((ContainerFluidIO) this.cvb).getBus().setFluidInSlot(id, stack); } + @Override - public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) - { - this.fontRendererObj.drawString( this.getGuiDisplayName(I18n.format(this.bus instanceof PartFluidImportBus ? NameConst.GUI_FLUID_IMPORT : NameConst.GUI_FLUID_EXPORT)), 8, 6, 4210752 ); - this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); + public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { + this.fontRendererObj.drawString( + this.getGuiDisplayName(I18n.format( + this.bus instanceof PartFluidImportBus + ? NameConst.GUI_FLUID_IMPORT + : NameConst.GUI_FLUID_EXPORT)), + 8, + 6, + 4210752); + this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); - if( this.redstoneMode != null ) - { - this.redstoneMode.set( this.cvb.getRedStoneMode() ); + if (this.redstoneMode != null) { + this.redstoneMode.set(this.cvb.getRedStoneMode()); } - if( this.fuzzyMode != null ) - { - this.fuzzyMode.set( this.cvb.getFuzzyMode() ); + if (this.fuzzyMode != null) { + this.fuzzyMode.set(this.cvb.getFuzzyMode()); } - if( this.craftMode != null ) - { - this.craftMode.set( this.cvb.getCraftingMode() ); + if (this.craftMode != null) { + this.craftMode.set(this.cvb.getCraftingMode()); } - if( this.schedulingMode != null ) - { - this.schedulingMode.set( this.cvb.getSchedulingMode() ); + if (this.schedulingMode != null) { + this.schedulingMode.set(this.cvb.getSchedulingMode()); } } } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java index 13f84f6f..cc79cb87 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java @@ -13,6 +13,7 @@ import com.glodblock.github.inventory.gui.GuiType; import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.network.CPacketSwitchGuis; import com.glodblock.github.util.NameConst; +import javax.annotation.Nullable; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.texture.TextureMap; @@ -24,8 +25,6 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; -import javax.annotation.Nullable; - public class GuiFluidInterface extends AEBaseGui { private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/interface_fluid.png"); @@ -50,11 +49,15 @@ public class GuiFluidInterface extends AEBaseGui { @Override @SuppressWarnings("unchecked") - public void initGui() - { + public void initGui() { super.initGui(); - this.switcher = new GuiTabButton( this.guiLeft + 154, this.guiTop, isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender ); - this.buttonList.add( this.switcher ); + this.switcher = new GuiTabButton( + this.guiLeft + 154, + this.guiTop, + isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), + StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), + itemRender); + this.buttonList.add(this.switcher); } @Override @@ -75,8 +78,13 @@ public class GuiFluidInterface extends AEBaseGui { if (!isPart()) { fontRendererObj.drawString(dirName(i), TANK_X + i * TANK_X_OFF + 5, 22, 0x404040); } - renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT, - fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity); + renderFluidIntoGui( + TANK_X + i * TANK_X_OFF, + TANK_Y, + TANK_WIDTH, + TANK_HEIGHT, + fluidInv.getFluidInSlot(i), + fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity); } GL11.glColor4f(1F, 1F, 1F, 1F); } @@ -91,8 +99,8 @@ public class GuiFluidInterface extends AEBaseGui { drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize); } - public void renderFluidIntoGui(int x, int y, int width, int height, - @Nullable IAEFluidStack aeFluidStack, int capacity) { + public void renderFluidIntoGui( + int x, int y, int width, int height, @Nullable IAEFluidStack aeFluidStack, int capacity) { if (aeFluidStack != null) { GL11.glDisable(2896); GL11.glColor3f(1.0F, 1.0F, 1.0F); @@ -100,10 +108,14 @@ public class GuiFluidInterface extends AEBaseGui { if (aeFluidStack.getStackSize() > 0 && hi > 0) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon(); - GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F); + GL11.glColor3f( + (float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, + (float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, + (float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F); for (int th = 0; th <= hi; th += 16) { if (hi - th <= 0) break; - this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th)); + this.drawTexturedModelRectFromIcon( + x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th)); } GL11.glColor3f(1.0F, 1.0F, 1.0F); } @@ -111,11 +123,11 @@ public class GuiFluidInterface extends AEBaseGui { } @Override - protected void actionPerformed( final GuiButton btn ) - { + protected void actionPerformed(final GuiButton btn) { super.actionPerformed(btn); if (btn == this.switcher) { - FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE)); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE)); } } @@ -127,9 +139,8 @@ public class GuiFluidInterface extends AEBaseGui { } else { ((TileFluidInterface) cont.getTile()).setConfig(id, stack); } - } - else { - if(isPart()) { + } else { + if (isPart()) { ((PartFluidInterface) cont.getTile()).setFluidInv(id, stack); } else { ((TileFluidInterface) cont.getTile()).setFluidInv(id, stack); @@ -140,6 +151,4 @@ public class GuiFluidInterface extends AEBaseGui { private boolean isPart() { return this.cont.getTile() instanceof PartFluidInterface; } - } - diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidPacketDecoder.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidPacketDecoder.java index 989a439d..cb031b32 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidPacketDecoder.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidPacketDecoder.java @@ -29,5 +29,4 @@ public class GuiFluidPacketDecoder extends AEBaseGui { fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_PACKET_DECODER)), 8, 6, 0x404040); fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternEncoder.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternEncoder.java index 308d6c8e..c03cc1a8 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternEncoder.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternEncoder.java @@ -14,6 +14,9 @@ import com.glodblock.github.inventory.slot.SlotSingleItem; import com.glodblock.github.network.CPacketEncodePattern; import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.NameConst; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; @@ -23,10 +26,6 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - public class GuiFluidPatternEncoder extends AEBaseGui { private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_pattern_encoder.png"); @@ -37,7 +36,7 @@ public class GuiFluidPatternEncoder extends AEBaseGui { public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) { super(new ContainerFluidPatternEncoder(ipl, tile)); - this.cont = (ContainerFluidPatternEncoder)inventorySlots; + this.cont = (ContainerFluidPatternEncoder) inventorySlots; mouseRegions.addRegion(141, 38, 10, 10, new MouseRegionManager.Handler() { @Override public List getTooltip() { @@ -78,14 +77,13 @@ public class GuiFluidPatternEncoder extends AEBaseGui { } @Override - public void func_146977_a( final Slot s ) - { - this.drawSlot0( s ); + public void func_146977_a(final Slot s) { + this.drawSlot0(s); } public void drawSlot0(Slot slot) { if (slot instanceof SlotFluid) { - IAEItemStack stack = ((SlotFluid)slot).getAeStack(); + IAEItemStack stack = ((SlotFluid) slot).getAeStack(); super.func_146977_a(new SlotSingleItem(slot)); if (stack == null) return; IAEItemStack fake = stack.copy(); @@ -94,7 +92,12 @@ public class GuiFluidPatternEncoder extends AEBaseGui { fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount); } stackSizeRenderer.setAeStack(fake); - stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition); + stackSizeRenderer.renderItemOverlayIntoGUI( + fontRendererObj, + mc.getTextureManager(), + stack.getItemStack(), + slot.xDisplayPosition, + slot.yDisplayPosition); } else { super.func_146977_a(slot); } @@ -107,29 +110,23 @@ public class GuiFluidPatternEncoder extends AEBaseGui { if (stack.getItem() instanceof ItemFluidPacket) { FluidStack fluid = ItemFluidPacket.getFluidStack(stack); if (fluid != null) { - list = Arrays.asList(fluid.getLocalizedName(), String.format(EnumChatFormatting.GRAY + "%,d mB", fluid.amount)); - } - else { + list = Arrays.asList( + fluid.getLocalizedName(), String.format(EnumChatFormatting.GRAY + "%,d mB", fluid.amount)); + } else { list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); } - } - else { + } else { list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); } - for (int k = 0; k < list.size(); ++k) - { - if (k == 0) - { - list.set(k, stack.getRarity().rarityColor + (String)list.get(k)); - } - else - { - list.set(k, EnumChatFormatting.GRAY + (String)list.get(k)); + for (int k = 0; k < list.size(); ++k) { + if (k == 0) { + list.set(k, stack.getRarity().rarityColor + (String) list.get(k)); + } else { + list.set(k, EnumChatFormatting.GRAY + (String) list.get(k)); } } FontRenderer font = stack.getItem().getFontRenderer(stack); drawHoveringText(list, x, y, (font == null ? fontRendererObj : font)); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminal.java index 9ece7e85..e789f4b9 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminal.java @@ -38,10 +38,8 @@ public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal { } @Override - public void func_146977_a( final Slot s ) - { - if (drawSlot0(s)) - super.func_146977_a( s ); + public void func_146977_a(final Slot s) { + if (drawSlot0(s)) super.func_146977_a(s); } public boolean drawSlot0(Slot slot) { @@ -53,11 +51,14 @@ public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal { if (fake.getItemStack().getItem() instanceof ItemFluidPacket) { if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0) fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount); - } - else - return true; + } else return true; stackSizeRenderer.setAeStack(fake); - stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition); + stackSizeRenderer.renderItemOverlayIntoGUI( + fontRendererObj, + mc.getTextureManager(), + stack.getItemStack(), + slot.xDisplayPosition, + slot.yDisplayPosition); return false; } return true; @@ -71,5 +72,4 @@ public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal { super.actionPerformed(btn); } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalCraftingStatus.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalCraftingStatus.java index 78fd304a..ea4daf1b 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalCraftingStatus.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalCraftingStatus.java @@ -36,13 +36,11 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus { @Override protected void actionPerformed(final GuiButton btn) { if (btn == originalGuiBtn) { - if (host instanceof PartFluidPatternTerminal) - InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL); + if (host instanceof PartFluidPatternTerminal) InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL); else if (host instanceof PartFluidPatternTerminalEx) InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX); } else { super.actionPerformed(btn); } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalEx.java index f05f0e5e..179bd132 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalEx.java @@ -38,10 +38,8 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx { } @Override - public void func_146977_a( final Slot s ) - { - if (drawSlot0(s)) - super.func_146977_a( s ); + public void func_146977_a(final Slot s) { + if (drawSlot0(s)) super.func_146977_a(s); } public boolean drawSlot0(Slot slot) { @@ -53,11 +51,14 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx { if (fake.getItemStack().getItem() instanceof ItemFluidPacket) { if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0) fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount); - } - else - return true; + } else return true; stackSizeRenderer.setAeStack(fake); - stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition); + stackSizeRenderer.renderItemOverlayIntoGUI( + fontRendererObj, + mc.getTextureManager(), + stack.getItemStack(), + slot.xDisplayPosition, + slot.yDisplayPosition); return false; } return true; @@ -71,5 +72,4 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx { super.actionPerformed(btn); } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java b/src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java index 0c038ec4..0f3f991a 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiIngredientBuffer.java @@ -11,6 +11,7 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler; import com.glodblock.github.inventory.gui.MouseRegionManager; import com.glodblock.github.inventory.gui.TankMouseHandler; import com.glodblock.github.util.NameConst; +import javax.annotation.Nullable; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.I18n; @@ -20,8 +21,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; -import javax.annotation.Nullable; - public class GuiIngredientBuffer extends AEBaseGui { private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/ingredient_buffer.png"); @@ -36,10 +35,14 @@ public class GuiIngredientBuffer extends AEBaseGui { this.cont = (ContainerIngredientBuffer) inventorySlots; this.ySize = 222; for (int i = 0; i < 4; i++) { - mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT, - new TankMouseHandler(cont.getTile().getFluidInventory(), i)); - mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, - ButtonMouseHandler.dumpTank(cont, i)); + mouseRegions.addRegion( + TANK_X + TANK_X_OFF * i, + TANK_Y, + TANK_WIDTH, + TANK_HEIGHT, + new TankMouseHandler(cont.getTile().getFluidInventory(), i)); + mouseRegions.addRegion( + TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i)); } } @@ -65,16 +68,21 @@ public class GuiIngredientBuffer extends AEBaseGui { IAEFluidTank fluidInv = cont.getTile().getFluidInventory(); mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); for (int i = 0; i < 4; i++) { - renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT, - fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity); + renderFluidIntoGui( + TANK_X + i * TANK_X_OFF, + TANK_Y, + TANK_WIDTH, + TANK_HEIGHT, + fluidInv.getFluidInSlot(i), + fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity); } GL11.glColor4f(1F, 1F, 1F, 1F); mouseRegions.render(mouseX, mouseY); } - public void renderFluidIntoGui(int x, int y, int width, int height, - @Nullable IAEFluidStack aeFluidStack, int capacity) { + public void renderFluidIntoGui( + int x, int y, int width, int height, @Nullable IAEFluidStack aeFluidStack, int capacity) { if (aeFluidStack != null) { GL11.glDisable(2896); GL11.glColor3f(1.0F, 1.0F, 1.0F); @@ -82,10 +90,14 @@ public class GuiIngredientBuffer extends AEBaseGui { if (aeFluidStack.getStackSize() > 0 && hi > 0) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon(); - GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F); + GL11.glColor3f( + (float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, + (float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, + (float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F); for (int th = 0; th <= hi; th += 16) { if (hi - th <= 0) break; - this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th)); + this.drawTexturedModelRectFromIcon( + x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th)); } GL11.glColor3f(1.0F, 1.0F, 1.0F); } @@ -95,5 +107,4 @@ public class GuiIngredientBuffer extends AEBaseGui { public void update(int slot, IAEFluidStack aeFluidStack) { cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiLargeIngredientBuffer.java b/src/main/java/com/glodblock/github/client/gui/GuiLargeIngredientBuffer.java index ad332291..8d1b4924 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiLargeIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiLargeIngredientBuffer.java @@ -11,6 +11,7 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler; import com.glodblock.github.inventory.gui.MouseRegionManager; import com.glodblock.github.inventory.gui.TankMouseHandler; import com.glodblock.github.util.NameConst; +import javax.annotation.Nullable; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.I18n; @@ -20,8 +21,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; -import javax.annotation.Nullable; - public class GuiLargeIngredientBuffer extends AEBaseGui { private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/large_ingredient_buffer.png"); @@ -36,10 +35,14 @@ public class GuiLargeIngredientBuffer extends AEBaseGui { this.cont = (ContainerLargeIngredientBuffer) inventorySlots; this.ySize = 222; for (int i = 0; i < 7; i++) { - mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT, - new TankMouseHandler(cont.getTile().getFluidInventory(), i)); - mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, - ButtonMouseHandler.dumpTank(cont, i)); + mouseRegions.addRegion( + TANK_X + TANK_X_OFF * i, + TANK_Y, + TANK_WIDTH, + TANK_HEIGHT, + new TankMouseHandler(cont.getTile().getFluidInventory(), i)); + mouseRegions.addRegion( + TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i)); } } @@ -58,23 +61,29 @@ public class GuiLargeIngredientBuffer extends AEBaseGui { @Override public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { - fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LARGE_INGREDIENT_BUFFER)), 8, 6, 0x404040); + fontRendererObj.drawString( + getGuiDisplayName(I18n.format(NameConst.GUI_LARGE_INGREDIENT_BUFFER)), 8, 6, 0x404040); fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040); GL11.glColor4f(1F, 1F, 1F, 1F); IAEFluidTank fluidInv = cont.getTile().getFluidInventory(); mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); for (int i = 0; i < 7; i++) { - renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT, - fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity); + renderFluidIntoGui( + TANK_X + i * TANK_X_OFF, + TANK_Y, + TANK_WIDTH, + TANK_HEIGHT, + fluidInv.getFluidInSlot(i), + fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity); } GL11.glColor4f(1F, 1F, 1F, 1F); mouseRegions.render(mouseX, mouseY); } - public void renderFluidIntoGui(int x, int y, int width, int height, - @Nullable IAEFluidStack aeFluidStack, int capacity) { + public void renderFluidIntoGui( + int x, int y, int width, int height, @Nullable IAEFluidStack aeFluidStack, int capacity) { if (aeFluidStack != null) { GL11.glDisable(2896); GL11.glColor3f(1.0F, 1.0F, 1.0F); @@ -82,10 +91,14 @@ public class GuiLargeIngredientBuffer extends AEBaseGui { if (aeFluidStack.getStackSize() > 0 && hi > 0) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon(); - GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F); + GL11.glColor3f( + (float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, + (float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, + (float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F); for (int th = 0; th <= hi; th += 16) { if (hi - th <= 0) break; - this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th)); + this.drawTexturedModelRectFromIcon( + x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th)); } GL11.glColor3f(1.0F, 1.0F, 1.0F); } @@ -95,5 +108,4 @@ public class GuiLargeIngredientBuffer extends AEBaseGui { public void update(int slot, IAEFluidStack aeFluidStack) { cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiPatternValueAmount.java b/src/main/java/com/glodblock/github/client/gui/GuiPatternValueAmount.java index babdbf4a..e546ccb6 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiPatternValueAmount.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiPatternValueAmount.java @@ -85,8 +85,8 @@ public class GuiPatternValueAmount extends AEBaseGui { this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c)); this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d)); - this.buttonList.add(this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal())); - + this.buttonList.add( + this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal())); ItemStack myIcon = null; final Object target = ((AEBaseContainer) this.inventorySlots).getTarget(); @@ -104,10 +104,13 @@ public class GuiPatternValueAmount extends AEBaseGui { } if (this.originalGui != null && myIcon != null) { - this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender)); + this.buttonList.add( + this.originalGuiBtn = new GuiTabButton( + this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender)); } - this.amountToSet = new GuiTextField(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT); + this.amountToSet = new GuiTextField( + this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT); this.amountToSet.setEnableBackgroundDrawing(false); this.amountToSet.setMaxStringLength(16); this.amountToSet.setTextColor(0xFFFFFF); @@ -115,10 +118,8 @@ public class GuiPatternValueAmount extends AEBaseGui { this.amountToSet.setFocused(true); this.amountToSet.setText(String.valueOf(originalAmount)); this.amountToSet.setSelectionPos(0); - } - @Override public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 0x404040); @@ -183,7 +184,8 @@ public class GuiPatternValueAmount extends AEBaseGui { resultI = (int) ArithHelper.round(resultD, 0); } - FluidCraft.proxy.netHandler.sendToServer(new CPacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex)); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex)); } } catch (final NumberFormatException e) { // nope.. @@ -191,7 +193,8 @@ public class GuiPatternValueAmount extends AEBaseGui { } final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000; - final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; + final boolean isMinus = + btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; if (isPlus || isMinus) { this.addQty(this.getQty(btn)); @@ -236,5 +239,4 @@ public class GuiPatternValueAmount extends AEBaseGui { return stack.stackSize; } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/TankDumpable.java b/src/main/java/com/glodblock/github/client/gui/TankDumpable.java index b71f2fe3..79b217c4 100644 --- a/src/main/java/com/glodblock/github/client/gui/TankDumpable.java +++ b/src/main/java/com/glodblock/github/client/gui/TankDumpable.java @@ -5,5 +5,4 @@ public interface TankDumpable { boolean canDumpTank(int index); void dumpTank(int index); - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidConfigurable.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidConfigurable.java index 657a461a..b279d91a 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidConfigurable.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidConfigurable.java @@ -14,58 +14,54 @@ import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly; import com.glodblock.github.network.SPacketFluidUpdate; import com.glodblock.github.util.Ae2Reflect; import com.glodblock.github.util.Util; +import java.util.HashMap; +import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import java.util.HashMap; -import java.util.Map; - public abstract class ContainerFluidConfigurable extends ContainerUpgradeable { - public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) - { - super( ip, te ); + public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) { + super(ip, te); } public abstract AppEngInternalAEInventory getFakeFluidInv(); @Override - public ItemStack transferStackInSlot(final EntityPlayer p, final int idx ) - { - AppEngSlot clickSlot = (AppEngSlot)this.inventorySlots.get(idx); + public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) { + AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); if (clickSlot == null || !clickSlot.getHasStack()) return null; ItemStack tis = clickSlot.getStack(); FluidStack fs = Util.getFluidFromItem(tis); - if( fs != null ) - { + if (fs != null) { final AppEngInternalAEInventory inv = this.getFakeFluidInv(); - final IAEFluidStack stack = AEFluidStack.create( fs ); - for( int i = 0; i < inv.getSizeInventory(); ++i ) - { - if( inv.getStackInSlot(i) == null && this.isValidForConfig( i, stack ) ) - { + final IAEFluidStack stack = AEFluidStack.create(fs); + for (int i = 0; i < inv.getSizeInventory(); ++i) { + if (inv.getStackInSlot(i) == null && this.isValidForConfig(i, stack)) { ItemStack tmp = ItemFluidPacket.newStack(fs); if (tmp != null) { tmp.setStackDisplayName(fs.getLocalizedName()); } - inv.setInventorySlotContents( i, tmp ); + inv.setInventorySlotContents(i, tmp); break; } } this.standardDetectAndSendChanges(); return null; } else { - if(idx < this.availableUpgrades()){ - if(!mergeItemStack(tis, this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades(), this.inventorySlots.size(), false)) return null; - }else if(idx>=this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades()){ - if(!mergeItemStack(tis, 0, this.availableUpgrades(), false)) return null; + if (idx < this.availableUpgrades()) { + if (!mergeItemStack( + tis, + this.getFakeFluidInv().getSizeInventory() + this.availableUpgrades(), + this.inventorySlots.size(), + false)) return null; + } else if (idx >= this.getFakeFluidInv().getSizeInventory() + this.availableUpgrades()) { + if (!mergeItemStack(tis, 0, this.availableUpgrades(), false)) return null; } if (tis.stackSize == 0) { clickSlot.putStack(null); @@ -77,37 +73,32 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable { } } - protected void setupConfig() - { + protected void setupConfig() { this.setupUpgrades(); - final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName( "config" ); + final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName("config"); final int y = 40; final int x = 80; - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 0, x, y, 0, 0, 0 ) ); - if( this.supportCapacity() ) - { - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 1, x, y, -1, 0, 1 ) ); - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 2, x, y, 1, 0, 1 ) ); - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 3, x, y, 0, -1, 1 ) ); - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 4, x, y, 0, 1, 1 ) ); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, x, y, 0, 0, 0)); + if (this.supportCapacity()) { + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 1, x, y, -1, 0, 1)); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 2, x, y, 1, 0, 1)); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 3, x, y, 0, -1, 1)); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 4, x, y, 0, 1, 1)); - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 5, x, y, -1, -1, 2 ) ); - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 6, x, y, 1, -1, 2 ) ); - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 7, x, y, -1, 1, 2 ) ); - this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 8, x, y, 1, 1, 2 ) ); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 5, x, y, -1, -1, 2)); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 6, x, y, 1, -1, 2)); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 7, x, y, -1, 1, 2)); + this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 8, x, y, 1, 1, 2)); } } - protected boolean isValidForConfig( int slot, IAEFluidStack fs ) - { - if( this.supportCapacity() ) - { + protected boolean isValidForConfig(int slot, IAEFluidStack fs) { + if (this.supportCapacity()) { // assumes 4 slots per upgrade - final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades( Upgrades.CAPACITY ); + final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY); - if( slot > 0 && upgrades < 1 ) - { + if (slot > 0 && upgrades < 1) { return false; } return slot <= 4 || upgrades >= 2; @@ -117,30 +108,25 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable { } @Override - protected void standardDetectAndSendChanges() - { - if( Platform.isServer() ) - { + protected void standardDetectAndSendChanges() { + if (Platform.isServer()) { // clear out config items that are no longer valid (eg capacity upgrade removed) final AppEngInternalAEInventory inv = this.getFakeFluidInv(); final Map tmp = new HashMap<>(); - for( int i = 0; i < inv.getSizeInventory(); ++i ) - { - if( inv.getStackInSlot( i ) != null && !this.isValidForConfig( i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i )))) ) - { - inv.setInventorySlotContents( i, null ); + for (int i = 0; i < inv.getSizeInventory(); ++i) { + if (inv.getStackInSlot(i) != null + && !this.isValidForConfig( + i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot(i))))) { + inv.setInventorySlotContents(i, null); } - tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i )))); + tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot(i)))); } - for( final Object g : this.crafters ) - { - if( g instanceof EntityPlayer) - { + for (final Object g : this.crafters) { + if (g instanceof EntityPlayer) { FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g); } } } super.standardDetectAndSendChanges(); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidCraftConfirm.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidCraftConfirm.java index 42fd7edb..d5c31ef8 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidCraftConfirm.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidCraftConfirm.java @@ -31,6 +31,11 @@ import com.glodblock.github.util.Ae2Reflect; import com.glodblock.github.util.BlockPos; import com.glodblock.github.util.Util; import com.google.common.collect.ImmutableSet; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Objects; +import java.util.concurrent.Future; +import javax.annotation.Nonnull; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -38,67 +43,58 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Objects; -import java.util.concurrent.Future; - public class ContainerFluidCraftConfirm extends AEBaseContainer { private final ArrayList cpus = new ArrayList(); private Future job; private ICraftingJob result; - @GuiSync( 0 ) + + @GuiSync(0) public long bytesUsed; - @GuiSync( 1 ) + + @GuiSync(1) public long cpuBytesAvail; - @GuiSync( 2 ) + + @GuiSync(2) public int cpuCoProcessors; - @GuiSync( 3 ) + + @GuiSync(3) public boolean autoStart = false; - @GuiSync( 4 ) + + @GuiSync(4) public boolean simulation = true; - @GuiSync( 5 ) + + @GuiSync(5) public int selectedCpu = -1; - @GuiSync( 6 ) + + @GuiSync(6) public boolean noCPU = true; - @GuiSync( 7 ) + + @GuiSync(7) public String myName = ""; - public ContainerFluidCraftConfirm(final InventoryPlayer ip, final ITerminalHost te ) - { - super( ip, te ); + public ContainerFluidCraftConfirm(final InventoryPlayer ip, final ITerminalHost te) { + super(ip, te); } - public void cycleCpu( final boolean next ) - { - if( next ) - { - this.setSelectedCpu( this.getSelectedCpu() + 1 ); - } - else - { - this.setSelectedCpu( this.getSelectedCpu() - 1 ); + public void cycleCpu(final boolean next) { + if (next) { + this.setSelectedCpu(this.getSelectedCpu() + 1); + } else { + this.setSelectedCpu(this.getSelectedCpu() - 1); } - if( this.getSelectedCpu() < -1 ) - { - this.setSelectedCpu( this.cpus.size() - 1 ); - } - else if( this.getSelectedCpu() >= this.cpus.size() ) - { - this.setSelectedCpu( -1 ); + if (this.getSelectedCpu() < -1) { + this.setSelectedCpu(this.cpus.size() - 1); + } else if (this.getSelectedCpu() >= this.cpus.size()) { + this.setSelectedCpu(-1); } - if( this.getSelectedCpu() == -1 ) - { - this.setCpuAvailableBytes( 0 ); - this.setCpuCoProcessors( 0 ); - this.setName( "" ); - } - else - { + if (this.getSelectedCpu() == -1) { + this.setCpuAvailableBytes(0); + this.setCpuCoProcessors(0); + this.setName(""); + } else { this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu()))); this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu()))); this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu()))); @@ -106,339 +102,286 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer { } @Override - public void detectAndSendChanges() - { - if( Platform.isClient() ) - { + public void detectAndSendChanges() { + if (Platform.isClient()) { return; } - if (getGrid() == null) - return; + if (getGrid() == null) return; - final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class ); + final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class); final ImmutableSet cpuSet = cc.getCpus(); int matches = 0; boolean changed = false; - for( final ICraftingCPU c : cpuSet ) - { + for (final ICraftingCPU c : cpuSet) { boolean found = false; - for( final CraftingCPURecord ccr : this.cpus ) - { - if( Ae2Reflect.getCPU(ccr) == c ) - { + for (final CraftingCPURecord ccr : this.cpus) { + if (Ae2Reflect.getCPU(ccr) == c) { found = true; } } - final boolean matched = this.cpuMatches( c ); + final boolean matched = this.cpuMatches(c); - if( matched ) - { + if (matched) { matches++; } - if( found == !matched ) - { + if (found == !matched) { changed = true; } } - if( changed || this.cpus.size() != matches ) - { + if (changed || this.cpus.size() != matches) { this.cpus.clear(); - for( final ICraftingCPU c : cpuSet ) - { - if( this.cpuMatches( c ) ) - { - this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) ); + for (final ICraftingCPU c : cpuSet) { + if (this.cpuMatches(c)) { + this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c)); } } this.sendCPUs(); } - this.setNoCPU( this.cpus.isEmpty() ); + this.setNoCPU(this.cpus.isEmpty()); super.detectAndSendChanges(); - if( this.getJob() != null && this.getJob().isDone() ) - { - try - { + if (this.getJob() != null && this.getJob().isDone()) { + try { this.result = this.getJob().get(); - if( !this.result.isSimulation() ) - { - this.setSimulation( false ); - if( this.isAutoStart() ) - { + if (!this.result.isSimulation()) { + this.setSimulation(false); + if (this.isAutoStart()) { this.startJob(); return; } - } - else - { - this.setSimulation( true ); + } else { + this.setSimulation(true); } - final SPacketMEInventoryUpdate a = new SPacketMEInventoryUpdate( (byte) 0 ); - final SPacketMEInventoryUpdate b = new SPacketMEInventoryUpdate( (byte) 1 ); - final SPacketMEInventoryUpdate c = this.result.isSimulation() ? new SPacketMEInventoryUpdate( (byte) 2 ) : null; + final SPacketMEInventoryUpdate a = new SPacketMEInventoryUpdate((byte) 0); + final SPacketMEInventoryUpdate b = new SPacketMEInventoryUpdate((byte) 1); + final SPacketMEInventoryUpdate c = + this.result.isSimulation() ? new SPacketMEInventoryUpdate((byte) 2) : null; final IItemList plan = AEApi.instance().storage().createItemList(); - this.result.populatePlan( plan ); + this.result.populatePlan(plan); - this.setUsedBytes( this.result.getByteTotal() ); + this.setUsedBytes(this.result.getByteTotal()); - for( final IAEItemStack out : plan ) - { + for (final IAEItemStack out : plan) { IAEItemStack o = out.copy(); o.reset(); - o.setStackSize( out.getStackSize() ); + o.setStackSize(out.getStackSize()); final IAEItemStack p = out.copy(); p.reset(); - p.setStackSize( out.getCountRequestable() ); + p.setStackSize(out.getCountRequestable()); - final IStorageGrid sg = this.getGrid().getCache( IStorageGrid.class ); + final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class); final IMEInventory items = sg.getItemInventory(); IAEItemStack m = null; - if( c != null && this.result.isSimulation() ) - { + if (c != null && this.result.isSimulation()) { m = o.copy(); - o = items.extractItems( o, Actionable.SIMULATE, this.getActionSource() ); + o = items.extractItems(o, Actionable.SIMULATE, this.getActionSource()); - if( o == null ) - { + if (o == null) { o = m.copy(); - o.setStackSize( 0 ); + o.setStackSize(0); } - m.setStackSize( m.getStackSize() - o.getStackSize() ); + m.setStackSize(m.getStackSize() - o.getStackSize()); } - if( o.getStackSize() > 0 ) - { - a.appendItem( o ); + if (o.getStackSize() > 0) { + a.appendItem(o); } - if( p.getStackSize() > 0 ) - { - b.appendItem( p ); + if (p.getStackSize() > 0) { + b.appendItem(p); } - if( c != null && m != null && m.getStackSize() > 0 ) - { - c.appendItem( m ); + if (c != null && m != null && m.getStackSize() > 0) { + c.appendItem(m); } } - for( final Object g : this.crafters ) - { - if( g instanceof EntityPlayer) - { - FluidCraft.proxy.netHandler.sendTo( a, (EntityPlayerMP) g ); - FluidCraft.proxy.netHandler.sendTo( b, (EntityPlayerMP) g ); - if( c != null ) - { - FluidCraft.proxy.netHandler.sendTo( c, (EntityPlayerMP) g ); + for (final Object g : this.crafters) { + if (g instanceof EntityPlayer) { + FluidCraft.proxy.netHandler.sendTo(a, (EntityPlayerMP) g); + FluidCraft.proxy.netHandler.sendTo(b, (EntityPlayerMP) g); + if (c != null) { + FluidCraft.proxy.netHandler.sendTo(c, (EntityPlayerMP) g); } } } - } - catch( final Throwable e ) - { - this.getPlayerInv().player.addChatMessage( new ChatComponentText( "Error: " + e.toString() ) ); - AELog.debug( e ); - this.setValidContainer( false ); + } catch (final Throwable e) { + this.getPlayerInv().player.addChatMessage(new ChatComponentText("Error: " + e.toString())); + AELog.debug(e); + this.setValidContainer(false); this.result = null; } - this.setJob( null ); + this.setJob(null); } - this.verifyPermissions( SecurityPermissions.CRAFT, false ); + this.verifyPermissions(SecurityPermissions.CRAFT, false); } - private IGrid getGrid() - { - final IActionHost h = ( (IActionHost) this.getTarget() ); - if (h == null || h.getActionableNode() == null) - return null; + private IGrid getGrid() { + final IActionHost h = ((IActionHost) this.getTarget()); + if (h == null || h.getActionableNode() == null) return null; return h.getActionableNode().getGrid(); } - private boolean cpuMatches( final ICraftingCPU c ) - { + private boolean cpuMatches(final ICraftingCPU c) { return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy(); } - private void sendCPUs() - { - Collections.sort( this.cpus ); + private void sendCPUs() { + Collections.sort(this.cpus); - if( this.getSelectedCpu() >= this.cpus.size() ) - { - this.setSelectedCpu( -1 ); - this.setCpuAvailableBytes( 0 ); - this.setCpuCoProcessors( 0 ); - this.setName( "" ); - } - else if( this.getSelectedCpu() != -1 ) - { + if (this.getSelectedCpu() >= this.cpus.size()) { + this.setSelectedCpu(-1); + this.setCpuAvailableBytes(0); + this.setCpuCoProcessors(0); + this.setName(""); + } else if (this.getSelectedCpu() != -1) { this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu()))); this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu()))); this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu()))); } } - public void startJob() - { + public void startJob() { GuiType originalGui = null; final IActionHost ah = this.getActionHost(); - if( ah instanceof PartFluidPatternTerminal) - { + if (ah instanceof PartFluidPatternTerminal) { originalGui = GuiType.FLUID_PATTERN_TERMINAL; } - if( ah instanceof PartFluidPatternTerminalEx) - { + if (ah instanceof PartFluidPatternTerminalEx) { originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX; } - if( this.result != null && !this.isSimulation() && getGrid() != null) - { - final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class ); - final ICraftingLink g = cc.submitJob( this.result, null, this.getSelectedCpu() == -1 ? null : Ae2Reflect.getCPU(this.cpus.get(this.getSelectedCpu())), true, this.getActionSrc() ); - this.setAutoStart( false ); - if( g != null && originalGui != null && this.getOpenContext() != null ) - { - InventoryHandler.openGui(this.getInventoryPlayer().player, getWorld(), new BlockPos(this.getOpenContext().getTile()), Objects.requireNonNull(Util.from(this.getOpenContext().getSide())), originalGui); + if (this.result != null && !this.isSimulation() && getGrid() != null) { + final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class); + final ICraftingLink g = cc.submitJob( + this.result, + null, + this.getSelectedCpu() == -1 ? null : Ae2Reflect.getCPU(this.cpus.get(this.getSelectedCpu())), + true, + this.getActionSrc()); + this.setAutoStart(false); + if (g != null && originalGui != null && this.getOpenContext() != null) { + InventoryHandler.openGui( + this.getInventoryPlayer().player, + getWorld(), + new BlockPos(this.getOpenContext().getTile()), + Objects.requireNonNull(Util.from(this.getOpenContext().getSide())), + originalGui); } } } - private BaseActionSource getActionSrc() - { - return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() ); + private BaseActionSource getActionSrc() { + return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget()); } @Override - public void removeCraftingFromCrafters( final ICrafting c ) - { - super.removeCraftingFromCrafters( c ); - if( this.getJob() != null ) - { - this.getJob().cancel( true ); - this.setJob( null ); + public void removeCraftingFromCrafters(final ICrafting c) { + super.removeCraftingFromCrafters(c); + if (this.getJob() != null) { + this.getJob().cancel(true); + this.setJob(null); } } @Override - public void onContainerClosed( final EntityPlayer par1EntityPlayer ) - { - super.onContainerClosed( par1EntityPlayer ); - if( this.getJob() != null ) - { - this.getJob().cancel( true ); - this.setJob( null ); + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + if (this.getJob() != null) { + this.getJob().cancel(true); + this.setJob(null); } } - public World getWorld() - { + public World getWorld() { return this.getPlayerInv().player.worldObj; } - public boolean isAutoStart() - { + public boolean isAutoStart() { return this.autoStart; } - public void setAutoStart( final boolean autoStart ) - { + public void setAutoStart(final boolean autoStart) { this.autoStart = autoStart; } - public long getUsedBytes() - { + public long getUsedBytes() { return this.bytesUsed; } - private void setUsedBytes( final long bytesUsed ) - { + private void setUsedBytes(final long bytesUsed) { this.bytesUsed = bytesUsed; } - public long getCpuAvailableBytes() - { + public long getCpuAvailableBytes() { return this.cpuBytesAvail; } - private void setCpuAvailableBytes( final long cpuBytesAvail ) - { + private void setCpuAvailableBytes(final long cpuBytesAvail) { this.cpuBytesAvail = cpuBytesAvail; } - public int getCpuCoProcessors() - { + public int getCpuCoProcessors() { return this.cpuCoProcessors; } - private void setCpuCoProcessors( final int cpuCoProcessors ) - { + private void setCpuCoProcessors(final int cpuCoProcessors) { this.cpuCoProcessors = cpuCoProcessors; } - public int getSelectedCpu() - { + public int getSelectedCpu() { return this.selectedCpu; } - private void setSelectedCpu( final int selectedCpu ) - { + private void setSelectedCpu(final int selectedCpu) { this.selectedCpu = selectedCpu; } - public String getName() - { + public String getName() { return this.myName; } - private void setName( @Nonnull final String myName ) - { + private void setName(@Nonnull final String myName) { this.myName = myName; } - public boolean hasNoCPU() - { + public boolean hasNoCPU() { return this.noCPU; } - private void setNoCPU( final boolean noCPU ) - { + private void setNoCPU(final boolean noCPU) { this.noCPU = noCPU; } - public boolean isSimulation() - { + public boolean isSimulation() { return this.simulation; } - private void setSimulation( final boolean simulation ) - { + private void setSimulation(final boolean simulation) { this.simulation = simulation; } - private Future getJob() - { + private Future getJob() { return this.job; } - public void setJob( final Future job ) - { + public void setJob(final Future job) { this.job = job; } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidIO.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidIO.java index dd923e8f..4cf0cece 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidIO.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidIO.java @@ -4,13 +4,11 @@ import appeng.tile.inventory.AppEngInternalAEInventory; import com.glodblock.github.common.parts.PartSharedFluidBus; import net.minecraft.entity.player.InventoryPlayer; -public class ContainerFluidIO extends ContainerFluidConfigurable -{ +public class ContainerFluidIO extends ContainerFluidConfigurable { private final PartSharedFluidBus bus; - public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te ) - { - super( ip, te ); + public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te) { + super(ip, te); this.bus = te; } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidInterface.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidInterface.java index 34f0599e..497296d7 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidInterface.java @@ -10,14 +10,13 @@ import com.glodblock.github.common.parts.PartFluidInterface; import com.glodblock.github.common.tile.TileFluidInterface; import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly; import com.glodblock.github.network.SPacketFluidUpdate; +import java.util.HashMap; +import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; -import java.util.HashMap; -import java.util.Map; - public class ContainerFluidInterface extends AEBaseContainer implements IOptionalSlotHost { private final Object tile; @@ -29,7 +28,8 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona final int y = 35; final int x = 35; for (int i = 0; i < 6; i++) { - addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0)); + addSlotToContainer(new OptionalFluidSlotFakeTypeOnly( + inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0)); } bindPlayerInventory(ipl, 0, 149); } @@ -41,7 +41,8 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona final int y = 35; final int x = 35; for (int i = 0; i < 6; i++) { - addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0)); + addSlotToContainer(new OptionalFluidSlotFakeTypeOnly( + inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0)); } bindPlayerInventory(ipl, 0, 149); } @@ -60,29 +61,31 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona super.detectAndSendChanges(); Map tmp = new HashMap<>(); if (tile instanceof TileFluidInterface) { - for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i ++) { + for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i++) { tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i)); } - for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i ++) { - tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((TileFluidInterface) tile).getConfig().getStackInSlot( i )))); + for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i++) { + tmp.put( + i + 100, + AEFluidStack.create(ItemFluidPacket.getFluidStack( + ((TileFluidInterface) tile).getConfig().getStackInSlot(i)))); } - } - else { - for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i ++) { + } else { + for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i++) { tmp.put(i, ((PartFluidInterface) tile).getInternalFluid().getFluidInSlot(i)); } - for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i ++) { - tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((PartFluidInterface) tile).getConfig().getStackInSlot( i )))); + for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i++) { + tmp.put( + i + 100, + AEFluidStack.create(ItemFluidPacket.getFluidStack( + ((PartFluidInterface) tile).getConfig().getStackInSlot(i)))); } } - for( final Object g : this.crafters ) - { - if( g instanceof EntityPlayer) - { + for (final Object g : this.crafters) { + if (g instanceof EntityPlayer) { FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g); } } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPacketDecoder.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPacketDecoder.java index 94adedee..40cbb401 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPacketDecoder.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPacketDecoder.java @@ -12,5 +12,4 @@ public class ContainerFluidPacketDecoder extends AEBaseContainer { addSlotToContainer(new SlotNormal(tile.getInventory(), 0, 80, 35)); bindPlayerInventory(ipl, 0, 84); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java index fe2d6dcf..59bbf995 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java @@ -18,6 +18,10 @@ import com.glodblock.github.inventory.slot.SlotFluid; import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.util.FluidPatternDetails; import com.glodblock.github.util.Util; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; @@ -26,11 +30,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - public class ContainerFluidPatternEncoder extends AEBaseContainer implements PatternConsumer { private final TileFluidPatternEncoder tile; @@ -47,9 +46,9 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat addSlotToContainer(new SlotFluidConvertingFake(output, y, 113, 17 + y * 18)); } addSlotToContainer(new SlotRestrictedInput( - SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, tile.getInventory(), 0, 138, 20, ipl)); + SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, tile.getInventory(), 0, 138, 20, ipl)); addSlotToContainer(new SlotRestrictedInput( - SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, tile.getInventory(), 1, 138, 50, ipl)); + SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, tile.getInventory(), 1, 138, 50, ipl)); bindPlayerInventory(ipl, 0, 84); } @@ -58,7 +57,8 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat } public boolean canEncodePattern() { - if (isNotPattern(tile.getInventory().getStackInSlot(0)) && isNotPattern(tile.getInventory().getStackInSlot(1))) { + if (isNotPattern(tile.getInventory().getStackInSlot(0)) + && isNotPattern(tile.getInventory().getStackInSlot(1))) { return false; } find_input: @@ -79,8 +79,9 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat } private static boolean isNotPattern(ItemStack stack) { - return stack == null || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack) - || (stack.getItem() instanceof ItemFluidEncodedPattern)); + return stack == null + || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack) + || (stack.getItem() instanceof ItemFluidEncodedPattern)); } public void encodePattern() { @@ -126,12 +127,13 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat if (stack == null) { slot.putStack(null); } else { - ((SlotFluidConvertingFake)slot).putConvertedStack(stack.copy()); + ((SlotFluidConvertingFake) slot).putConvertedStack(stack.copy()); } break; case PLACE_SINGLE: if (stack != null) { - ((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))); + ((SlotFluidConvertingFake) slot) + .putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))); } break; case SPLIT_OR_PLACE_SINGLE: @@ -140,13 +142,15 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat if (stack == null) { slot.putStack(Util.copyStackWithSize(inSlot, Math.max(1, inSlot.stackSize - 1))); } else if (stack.isItemEqual(inSlot)) { - slot.putStack(Util.copyStackWithSize(inSlot, - Math.min(inSlot.getMaxStackSize(), inSlot.stackSize + 1))); + slot.putStack(Util.copyStackWithSize( + inSlot, Math.min(inSlot.getMaxStackSize(), inSlot.stackSize + 1))); } else { - ((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))); + ((SlotFluidConvertingFake) slot) + .putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))); } } else if (stack != null) { - ((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))); + ((SlotFluidConvertingFake) slot) + .putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))); } break; } @@ -220,7 +224,5 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat public IAEItemStack getAeStack() { return inv.getStack(getSlotIndex()); } - } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java index f909d684..cdb56dd5 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java @@ -29,15 +29,15 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement super(ip, monitorable); } - public void encodeAllItemAndMoveToInventory(){ + public void encodeAllItemAndMoveToInventory() { encode(); ItemStack output = this.patternSlotOUT.getStack(); - if(output != null){ - if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize; - if (!getPlayerInv().addItemStackToInventory( output )){ + if (output != null) { + if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize; + if (!getPlayerInv().addItemStackToInventory(output)) { getPlayerInv().player.entityDropItem(output, 0); } - this.patternSlotOUT.putStack( null ); + this.patternSlotOUT.putStack(null); this.patternSlotIN.putStack(null); } } @@ -57,7 +57,7 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement if (stack.stackSize == 1) { this.patternSlotIN.putStack(null); } else { - stack.stackSize --; + stack.stackSize--; } encodeFluidPattern(); } else if (isPattern(stack)) { @@ -73,7 +73,8 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement return true; } final IDefinitions defs = AEApi.instance().definitions(); - return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output); + return defs.items().encodedPattern().isSameAs(output) + || defs.materials().blankPattern().isSameAs(output); } private boolean checkHasFluidPattern() { @@ -171,7 +172,8 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement super.doAction(player, action, slotId, id); return; } - if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) { + if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) + && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) { FluidStack fluid = null; switch (action) { case PICKUP_OR_SET_DOWN: @@ -196,5 +198,4 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement } super.doAction(player, action, slotId, id); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java index d1c02753..1a9fca64 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java @@ -28,15 +28,15 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple super(ip, monitorable); } - public void encodeAllItemAndMoveToInventory(){ + public void encodeAllItemAndMoveToInventory() { encode(); ItemStack output = this.patternSlotOUT.getStack(); - if(output != null){ - if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize; - if (!getPlayerInv().addItemStackToInventory( output )){ + if (output != null) { + if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize; + if (!getPlayerInv().addItemStackToInventory(output)) { getPlayerInv().player.entityDropItem(output, 0); } - this.patternSlotOUT.putStack( null ); + this.patternSlotOUT.putStack(null); this.patternSlotIN.putStack(null); } } @@ -56,7 +56,7 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple if (stack.stackSize == 1) { this.patternSlotIN.putStack(null); } else { - stack.stackSize --; + stack.stackSize--; } encodeFluidPattern(); } else if (isPattern(stack)) { @@ -72,7 +72,8 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple return true; } final IDefinitions defs = AEApi.instance().definitions(); - return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output); + return defs.items().encodedPattern().isSameAs(output) + || defs.materials().blankPattern().isSameAs(output); } private boolean checkHasFluidPattern() { @@ -111,8 +112,8 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple private void encodeFluidPattern() { ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN); FluidPatternDetails pattern = new FluidPatternDetails(patternStack); - pattern.setCombine(this.combine ? 1:0); - pattern.setPriority(this.prioritize? 1:0); + pattern.setCombine(this.combine ? 1 : 0); + pattern.setPriority(this.prioritize ? 1 : 0); pattern.setInputs(collectInventory(craftingSlots)); pattern.setOutputs(collectInventory(outputSlots)); patternSlotOUT.putStack(pattern.writeToStack()); @@ -165,7 +166,9 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple super.doAction(player, action, slotId, id); return; } - if ((slot instanceof OptionalSlotFake) && stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) { + if ((slot instanceof OptionalSlotFake) + && stack != null + && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) { FluidStack fluid = null; switch (action) { case PICKUP_OR_SET_DOWN: @@ -195,5 +198,4 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple } super.doAction(player, action, slotId, id); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java index c2f06be5..8b22a909 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerIngredientBuffer.java @@ -7,14 +7,13 @@ import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.TankDumpable; import com.glodblock.github.common.tile.TileIngredientBuffer; import com.glodblock.github.network.SPacketFluidUpdate; +import java.util.HashMap; +import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; -import java.util.HashMap; -import java.util.Map; - public class ContainerIngredientBuffer extends AEBaseContainer implements TankDumpable { private final TileIngredientBuffer tile; @@ -46,17 +45,14 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements TankDu } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); Map tmp = new HashMap<>(); - for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) { + for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) { tmp.put(i, tile.getFluidInventory().getFluidInSlot(i)); } - for( final Object g : this.crafters ) - { - if( g instanceof EntityPlayer) - { + for (final Object g : this.crafters) { + if (g instanceof EntityPlayer) { FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g); } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerLargeIngredientBuffer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerLargeIngredientBuffer.java index 3461a033..67b068c1 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerLargeIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerLargeIngredientBuffer.java @@ -7,14 +7,13 @@ import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.TankDumpable; import com.glodblock.github.common.tile.TileLargeIngredientBuffer; import com.glodblock.github.network.SPacketFluidUpdate; +import java.util.HashMap; +import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; -import java.util.HashMap; -import java.util.Map; - public class ContainerLargeIngredientBuffer extends AEBaseContainer implements TankDumpable { private final TileLargeIngredientBuffer tile; @@ -48,20 +47,16 @@ public class ContainerLargeIngredientBuffer extends AEBaseContainer implements T } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); Map tmp = new HashMap<>(); - for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) { + for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) { tmp.put(i, tile.getFluidInventory().getFluidInSlot(i)); } - for( final Object g : this.crafters ) - { - if( g instanceof EntityPlayer) - { + for (final Object g : this.crafters) { + if (g instanceof EntityPlayer) { FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g); } } } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerOCPatternEditor.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerOCPatternEditor.java index e80af736..cb1f00b7 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerOCPatternEditor.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerOCPatternEditor.java @@ -9,15 +9,17 @@ public class ContainerOCPatternEditor extends AEBaseContainer { public ContainerOCPatternEditor(InventoryPlayer ipl, TileOCPatternEditor tile) { super(ipl, tile); - for (int i = 0; i < 4; i ++) { - for (int j = 0; j < 4; j ++) { + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { addSlotToContainer(new SlotRestrictedInput( - SlotRestrictedInput.PlacableItemType.PATTERN, tile.getInternalInventory(), - j * 4 + i, 55 + i * 18, 17 + j * 18, ipl - )); + SlotRestrictedInput.PlacableItemType.PATTERN, + tile.getInternalInventory(), + j * 4 + i, + 55 + i * 18, + 17 + j * 18, + ipl)); } } bindPlayerInventory(ipl, 0, 104); } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerPatternValueAmount.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerPatternValueAmount.java index db1912c4..a8f2475a 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerPatternValueAmount.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerPatternValueAmount.java @@ -10,36 +10,30 @@ import net.minecraft.inventory.Slot; public class ContainerPatternValueAmount extends AEBaseContainer { - private final Slot patternValue; private int valueIndex; - public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te ) - { - super( ip, te ); - this.patternValue = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 ); - this.addSlotToContainer( patternValue ); + public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te) { + super(ip, te); + this.patternValue = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53); + this.addSlotToContainer(patternValue); } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - this.verifyPermissions( SecurityPermissions.CRAFT, false ); + this.verifyPermissions(SecurityPermissions.CRAFT, false); } - public Slot getPatternValue() - { + public Slot getPatternValue() { return patternValue; } - public int getValueIndex() - { + public int getValueIndex() { return valueIndex; } - public void setValueIndex( int valueIndex ) - { + public void setValueIndex(int valueIndex) { this.valueIndex = valueIndex; } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/FCBaseMonitorContain.java b/src/main/java/com/glodblock/github/client/gui/container/FCBaseMonitorContain.java index 27212654..7052648a 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBaseMonitorContain.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBaseMonitorContain.java @@ -33,6 +33,9 @@ import appeng.util.IConfigManagerHost; import appeng.util.Platform; import com.glodblock.github.FluidCraft; import com.glodblock.github.network.SPacketMEInventoryUpdate; +import java.io.IOException; +import java.nio.BufferOverflowException; +import javax.annotation.Nonnull; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -41,167 +44,142 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import javax.annotation.Nonnull; -import java.io.IOException; -import java.nio.BufferOverflowException; - -public class FCBaseMonitorContain extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver -{ +public class FCBaseMonitorContain extends AEBaseContainer + implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver { private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5]; private final IMEMonitor monitor; private final IItemList items = AEApi.instance().storage().createItemList(); private final IConfigManager clientCM; private final ITerminalHost host; - @GuiSync( 99 ) + + @GuiSync(99) public boolean canAccessViewCells = false; - @GuiSync( 98 ) + + @GuiSync(98) public boolean hasPower = false; + private IConfigManagerHost gui; private IConfigManager serverCM; private IGridNode networkNode; - public FCBaseMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable ) - { - this( ip, monitorable, true ); + public FCBaseMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable) { + this(ip, monitorable, true); } - protected FCBaseMonitorContain( final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory ) - { - super( ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null ); + protected FCBaseMonitorContain( + final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) { + super( + ip, + monitorable instanceof TileEntity ? (TileEntity) monitorable : null, + monitorable instanceof IPart ? (IPart) monitorable : null); this.host = monitorable; - this.clientCM = new ConfigManager( this ); + this.clientCM = new ConfigManager(this); - this.clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); + this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME); + this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); - if( Platform.isServer() ) - { + if (Platform.isServer()) { this.serverCM = monitorable.getConfigManager(); this.monitor = monitorable.getItemInventory(); - if( this.monitor != null ) - { - this.monitor.addListener( this, null ); + if (this.monitor != null) { + this.monitor.addListener(this, null); - this.setCellInventory( this.monitor ); + this.setCellInventory(this.monitor); - if( monitorable instanceof IPortableCell) - { - this.setPowerSource( (IEnergySource) monitorable ); - } - else if( monitorable instanceof IMEChest) - { - this.setPowerSource( (IEnergySource) monitorable ); - } - else if( monitorable instanceof IGridHost) - { - final IGridNode node = ( (IGridHost) monitorable ).getGridNode( ForgeDirection.UNKNOWN ); - if( node != null ) - { + if (monitorable instanceof IPortableCell) { + this.setPowerSource((IEnergySource) monitorable); + } else if (monitorable instanceof IMEChest) { + this.setPowerSource((IEnergySource) monitorable); + } else if (monitorable instanceof IGridHost) { + final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN); + if (node != null) { this.networkNode = node; final IGrid g = node.getGrid(); - if( g != null ) - { - this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) ); + if (g != null) { + this.setPowerSource(new ChannelPowerSrc( + this.networkNode, (IEnergySource) g.getCache(IEnergyGrid.class))); } } } + } else { + this.setValidContainer(false); } - else - { - this.setValidContainer( false ); - } - } - else - { + } else { this.monitor = null; } this.canAccessViewCells = false; - if( monitorable instanceof IViewCellStorage) - { - for( int y = 0; y < 5; y++ ) - { - this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ( (IViewCellStorage) monitorable ).getViewCellStorage(), y, 206, y * 18 + 8, this.getInventoryPlayer() ); - this.cellView[y].setAllowEdit( this.canAccessViewCells ); - this.addSlotToContainer( this.cellView[y] ); + if (monitorable instanceof IViewCellStorage) { + for (int y = 0; y < 5; y++) { + this.cellView[y] = new SlotRestrictedInput( + SlotRestrictedInput.PlacableItemType.VIEW_CELL, + ((IViewCellStorage) monitorable).getViewCellStorage(), + y, + 206, + y * 18 + 8, + this.getInventoryPlayer()); + this.cellView[y].setAllowEdit(this.canAccessViewCells); + this.addSlotToContainer(this.cellView[y]); } } - if( bindInventory ) - { - this.bindPlayerInventory( ip, 0, 0 ); + if (bindInventory) { + this.bindPlayerInventory(ip, 0, 0); } } - public IGridNode getNetworkNode() - { + public IGridNode getNetworkNode() { return this.networkNode; } @Override - public void detectAndSendChanges() - { - if( Platform.isServer() ) - { - if( this.monitor != this.host.getItemInventory() ) - { - this.setValidContainer( false ); + public void detectAndSendChanges() { + if (Platform.isServer()) { + if (this.monitor != this.host.getItemInventory()) { + this.setValidContainer(false); } - for( final Settings set : this.serverCM.getSettings() ) - { - final Enum sideLocal = this.serverCM.getSetting( set ); - final Enum sideRemote = this.clientCM.getSetting( set ); + for (final Settings set : this.serverCM.getSettings()) { + final Enum sideLocal = this.serverCM.getSetting(set); + final Enum sideRemote = this.clientCM.getSetting(set); - if( sideLocal != sideRemote ) - { - this.clientCM.putSetting( set, sideLocal ); - for( final Object crafter : this.crafters ) - { - try - { - NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) crafter ); - } - catch( final IOException e ) - { - AELog.debug( e ); + if (sideLocal != sideRemote) { + this.clientCM.putSetting(set, sideLocal); + for (final Object crafter : this.crafters) { + try { + NetworkHandler.instance.sendTo( + new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter); + } catch (final IOException e) { + AELog.debug(e); } } } } - if( !this.items.isEmpty() ) - { + if (!this.items.isEmpty()) { final IItemList monitorCache = this.monitor.getStorageList(); final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(); - for( final IAEItemStack is : this.items ) - { - final IAEItemStack send = monitorCache.findPrecise( is ); - if( send == null ) - { - is.setStackSize( 0 ); - piu.appendItem( is ); - } - else - { - piu.appendItem( send ); + for (final IAEItemStack is : this.items) { + final IAEItemStack send = monitorCache.findPrecise(is); + if (send == null) { + is.setStackSize(0); + piu.appendItem(is); + } else { + piu.appendItem(send); } } - if( !piu.isEmpty() ) - { + if (!piu.isEmpty()) { this.items.resetStatus(); - for( final Object c : this.crafters ) - { - if( c instanceof EntityPlayer) - { + for (final Object c : this.crafters) { + if (c instanceof EntityPlayer) { FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c); } } @@ -212,15 +190,11 @@ public class FCBaseMonitorContain extends AEBaseContainer implements IConfigMana final boolean oldAccessible = this.canAccessViewCells; this.canAccessViewCells = - this.host instanceof WirelessTerminalGuiObject - || this.hasAccess( SecurityPermissions.BUILD, false ); - if( this.canAccessViewCells != oldAccessible ) - { - for( int y = 0; y < 5; y++ ) - { - if( this.cellView[y] != null ) - { - this.cellView[y].setAllowEdit( this.canAccessViewCells ); + this.host instanceof WirelessTerminalGuiObject || this.hasAccess(SecurityPermissions.BUILD, false); + if (this.canAccessViewCells != oldAccessible) { + for (int y = 0; y < 5; y++) { + if (this.cellView[y] != null) { + this.cellView[y].setAllowEdit(this.canAccessViewCells); } } } @@ -229,180 +203,143 @@ public class FCBaseMonitorContain extends AEBaseContainer implements IConfigMana } } - protected void updatePowerStatus() - { - try - { - if( this.networkNode != null ) - { - this.setPowered( this.networkNode.isActive() ); + protected void updatePowerStatus() { + try { + if (this.networkNode != null) { + this.setPowered(this.networkNode.isActive()); + } else if (this.getPowerSource() instanceof IEnergyGrid) { + this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered()); + } else { + this.setPowered( + this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8); } - else if( this.getPowerSource() instanceof IEnergyGrid ) - { - this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() ); - } - else - { - this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 ); - } - } - catch( final Throwable t ) - { + } catch (final Throwable t) { // :P } } @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - if( field.equals( "canAccessViewCells" ) ) - { - for( int y = 0; y < 5; y++ ) - { - if( this.cellView[y] != null ) - { - this.cellView[y].setAllowEdit( this.canAccessViewCells ); + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + if (field.equals("canAccessViewCells")) { + for (int y = 0; y < 5; y++) { + if (this.cellView[y] != null) { + this.cellView[y].setAllowEdit(this.canAccessViewCells); } } } - super.onUpdate( field, oldValue, newValue ); + super.onUpdate(field, oldValue, newValue); } @Override - public void addCraftingToCrafters( final ICrafting c ) - { - super.addCraftingToCrafters( c ); - this.queueInventory( c ); + public void addCraftingToCrafters(final ICrafting c) { + super.addCraftingToCrafters(c); + this.queueInventory(c); } - private void queueInventory( final ICrafting c ) - { - if( Platform.isServer() && c instanceof EntityPlayer && this.monitor != null ) - { + private void queueInventory(final ICrafting c) { + if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) { SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(); final IItemList monitorCache = this.monitor.getStorageList(); - for( final IAEItemStack send : monitorCache ) - { - try - { - piu.appendItem( send ); - } - catch( final BufferOverflowException boe ) - { - FluidCraft.proxy.netHandler.sendTo( piu, (EntityPlayerMP) c ); + for (final IAEItemStack send : monitorCache) { + try { + piu.appendItem(send); + } catch (final BufferOverflowException boe) { + FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c); piu = new SPacketMEInventoryUpdate(); - piu.appendItem( send ); + piu.appendItem(send); } } - FluidCraft.proxy.netHandler.sendTo( piu, (EntityPlayerMP) c ); + FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c); } } @Override - public void removeCraftingFromCrafters( final ICrafting c ) - { - super.removeCraftingFromCrafters( c ); + public void removeCraftingFromCrafters(final ICrafting c) { + super.removeCraftingFromCrafters(c); - if( this.crafters.isEmpty() && this.monitor != null ) - { - this.monitor.removeListener( this ); + if (this.crafters.isEmpty() && this.monitor != null) { + this.monitor.removeListener(this); } } @Override - public void onContainerClosed( final EntityPlayer player ) - { - super.onContainerClosed( player ); - if( this.monitor != null ) - { - this.monitor.removeListener( this ); + public void onContainerClosed(final EntityPlayer player) { + super.onContainerClosed(player); + if (this.monitor != null) { + this.monitor.removeListener(this); } } @Override - public boolean isValid( final Object verificationToken ) - { + public boolean isValid(final Object verificationToken) { return true; } @Override - public void postChange(final IBaseMonitor monitor, final Iterable change, final BaseActionSource source ) - { - for( final IAEItemStack is : change ) - { - this.items.add( is ); + public void postChange( + final IBaseMonitor monitor, + final Iterable change, + final BaseActionSource source) { + for (final IAEItemStack is : change) { + this.items.add(is); } } @Override - public void onListUpdate() - { - for( final Object c : this.crafters ) - { - if( c instanceof ICrafting ) - { + public void onListUpdate() { + for (final Object c : this.crafters) { + if (c instanceof ICrafting) { final ICrafting cr = (ICrafting) c; - this.queueInventory( cr ); + this.queueInventory(cr); } } } @Override - public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue ) - { - if( this.getGui() != null ) - { - this.getGui().updateSetting( manager, settingName, newValue ); + public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) { + if (this.getGui() != null) { + this.getGui().updateSetting(manager, settingName, newValue); } } @Override - public IConfigManager getConfigManager() - { - if( Platform.isServer() ) - { + public IConfigManager getConfigManager() { + if (Platform.isServer()) { return this.serverCM; } return this.clientCM; } - public ItemStack[] getViewCells() - { + public ItemStack[] getViewCells() { final ItemStack[] list = new ItemStack[this.cellView.length]; - for( int x = 0; x < this.cellView.length; x++ ) - { + for (int x = 0; x < this.cellView.length; x++) { list[x] = this.cellView[x].getStack(); } return list; } - public SlotRestrictedInput getCellViewSlot( final int index ) - { + public SlotRestrictedInput getCellViewSlot(final int index) { return this.cellView[index]; } - public boolean isPowered() - { + public boolean isPowered() { return this.hasPower; } - private void setPowered( final boolean isPowered ) - { + private void setPowered(final boolean isPowered) { this.hasPower = isPowered; } - private IConfigManagerHost getGui() - { + private IConfigManagerHost getGui() { return this.gui; } - public void setGui( @Nonnull final IConfigManagerHost gui ) - { + public void setGui(@Nonnull final IConfigManagerHost gui) { this.gui = gui; } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java index 5dccd5b3..11b1cce9 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java @@ -25,6 +25,11 @@ import com.glodblock.github.common.item.ItemFluidEncodedPattern; import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.common.parts.PartFluidPatternTerminal; import com.glodblock.github.util.Util; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -38,184 +43,197 @@ import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - -public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket { +public class FCBasePartContainer extends FCBaseMonitorContain + implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket { private final PartFluidPatternTerminal patternTerminal; - private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 ); + private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1); private final IInventory crafting; protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9]; protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3]; protected final SlotPatternTerm craftSlot; protected final SlotRestrictedInput patternSlotIN; protected final SlotRestrictedInput patternSlotOUT; - @GuiSync( 97 ) + + @GuiSync(97) public boolean craftingMode = true; - @GuiSync( 96 ) + + @GuiSync(96) public boolean substitute = false; - @GuiSync( 95 ) + + @GuiSync(95) public boolean combine = false; - public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable ) - { - super( ip, monitorable, false ); + public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable) { + super(ip, monitorable, false); this.patternTerminal = (PartFluidPatternTerminal) monitorable; - final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" ); - final IInventory output = this.getPatternTerminal().getInventoryByName( "output" ); + final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern"); + final IInventory output = this.getPatternTerminal().getInventoryByName("output"); - this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" ); + this.crafting = this.getPatternTerminal().getInventoryByName("crafting"); - for( int y = 0; y < 3; y++ ) - { - for( int x = 0; x < 3; x++ ) - { - this.addSlotToContainer( this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) ); + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 3; x++) { + this.addSlotToContainer( + this.craftingSlots[x + y * 3] = + new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18)); } } - this.addSlotToContainer( this.craftSlot = new SlotPatternTerm( ip.player, this.getActionSource(), this.getPowerSource(), monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this ) ); - this.craftSlot.setIIcon( -1 ); + this.addSlotToContainer( + this.craftSlot = new SlotPatternTerm( + ip.player, + this.getActionSource(), + this.getPowerSource(), + monitorable, + this.crafting, + patternInv, + this.cOut, + 110, + -76 + 18, + this, + 2, + this)); + this.craftSlot.setIIcon(-1); - for( int y = 0; y < 3; y++ ) - { - this.addSlotToContainer( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) ); - this.outputSlots[y].setRenderDisabled( false ); + for (int y = 0; y < 3; y++) { + this.addSlotToContainer( + this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1)); + this.outputSlots[y].setRenderDisabled(false); } - this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) ); - this.addSlotToContainer( this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this.getInventoryPlayer() ) ); + this.addSlotToContainer( + this.patternSlotIN = new SlotRestrictedInput( + SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, + patternInv, + 0, + 147, + -72 - 9, + this.getInventoryPlayer())); + this.addSlotToContainer( + this.patternSlotOUT = new SlotRestrictedInput( + SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, + patternInv, + 1, + 147, + -72 + 34, + this.getInventoryPlayer())); - this.patternSlotOUT.setStackLimit( 1 ); + this.patternSlotOUT.setStackLimit(1); - this.bindPlayerInventory( ip, 0, 0 ); + this.bindPlayerInventory(ip, 0, 0); this.updateOrderOfOutputSlots(); } - private void updateOrderOfOutputSlots() - { - if( !this.isCraftingMode() ) - { + private void updateOrderOfOutputSlots() { + if (!this.isCraftingMode()) { this.craftSlot.xDisplayPosition = -9000; - for( int y = 0; y < 3; y++ ) - { + for (int y = 0; y < 3; y++) { this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX(); } - } - else - { + } else { this.craftSlot.xDisplayPosition = this.craftSlot.getX(); - for( int y = 0; y < 3; y++ ) - { + for (int y = 0; y < 3; y++) { this.outputSlots[y].xDisplayPosition = -9000; } } } @Override - public void putStackInSlot( final int par1, final ItemStack par2ItemStack ) - { - super.putStackInSlot( par1, par2ItemStack ); + public void putStackInSlot(final int par1, final ItemStack par2ItemStack) { + super.putStackInSlot(par1, par2ItemStack); this.getAndUpdateOutput(); } @Override - public void putStacksInSlots( final ItemStack[] par1ArrayOfItemStack ) - { - super.putStacksInSlots( par1ArrayOfItemStack ); + public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) { + super.putStacksInSlots(par1ArrayOfItemStack); this.getAndUpdateOutput(); } - private ItemStack getAndUpdateOutput() - { - final InventoryCrafting ic = new InventoryCrafting( this, 3, 3 ); + private ItemStack getAndUpdateOutput() { + final InventoryCrafting ic = new InventoryCrafting(this, 3, 3); - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - ic.setInventorySlotContents( x, this.crafting.getStackInSlot( x ) ); + for (int x = 0; x < ic.getSizeInventory(); x++) { + ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x)); } - final ItemStack is = CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj ); - this.cOut.setInventorySlotContents( 0, is ); + final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj); + this.cOut.setInventorySlotContents(0, is); return is; } @Override - public void saveChanges() - { - - } + public void saveChanges() {} @Override - public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { + public void onChangeInventory( + final IInventory inv, + final int slot, + final InvOperation mc, + final ItemStack removedStack, + final ItemStack newStack) {} - } - - public void encodeAndMoveToInventory() - { + public void encodeAndMoveToInventory() { encode(); ItemStack output = this.patternSlotOUT.getStack(); - if ( output != null ) - { - if (!getPlayerInv().addItemStackToInventory( output )){ + if (output != null) { + if (!getPlayerInv().addItemStackToInventory(output)) { getPlayerInv().player.entityDropItem(output, 0); } - this.patternSlotOUT.putStack( null ); + this.patternSlotOUT.putStack(null); } } - public void encode() - { + public void encode() { ItemStack output = this.patternSlotOUT.getStack(); final ItemStack[] in = this.getInputs(); final ItemStack[] out = this.getOutputs(); // if there is no input, this would be silly. - if( in == null || out == null ) - { + if (in == null || out == null) { return; } // first check the output slots, should either be null, or a pattern - if( output != null && !this.isPattern( output ) ) - { + if (output != null && !this.isPattern(output)) { return; - }// if nothing is there we should snag a new pattern. - else if( output == null ) - { + } // if nothing is there we should snag a new pattern. + else if (output == null) { output = this.patternSlotIN.getStack(); - if (!this.isPattern( output )) - { + if (!this.isPattern(output)) { return; // no blanks. } // remove one, and clear the input slot. output.stackSize--; - if( output.stackSize == 0 ) - { - this.patternSlotIN.putStack( null ); + if (output.stackSize == 0) { + this.patternSlotIN.putStack(null); } // add a new encoded pattern. - for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() ) - { + for (final ItemStack encodedPatternStack : AEApi.instance() + .definitions() + .items() + .encodedPattern() + .maybeStack(1) + .asSet()) { output = encodedPatternStack; - this.patternSlotOUT.putStack( output ); + this.patternSlotOUT.putStack(output); } - } else if ( output.getItem() instanceof ItemFluidEncodedPattern ) { - for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() ) - { + } else if (output.getItem() instanceof ItemFluidEncodedPattern) { + for (final ItemStack encodedPatternStack : AEApi.instance() + .definitions() + .items() + .encodedPattern() + .maybeStack(1) + .asSet()) { output = encodedPatternStack; - this.patternSlotOUT.putStack( output ); + this.patternSlotOUT.putStack(output); } } @@ -225,86 +243,70 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE final NBTTagList tagIn = new NBTTagList(); final NBTTagList tagOut = new NBTTagList(); - for( final ItemStack i : in ) - { - tagIn.appendTag( this.createItemTag( i ) ); + for (final ItemStack i : in) { + tagIn.appendTag(this.createItemTag(i)); } - for( final ItemStack i : out ) - { - tagOut.appendTag( this.createItemTag( i ) ); + for (final ItemStack i : out) { + tagOut.appendTag(this.createItemTag(i)); } - encodedValue.setTag( "in", tagIn ); - encodedValue.setTag( "out", tagOut ); - encodedValue.setBoolean( "crafting", this.isCraftingMode() ); - encodedValue.setBoolean( "substitute", this.isSubstitute() ); + encodedValue.setTag("in", tagIn); + encodedValue.setTag("out", tagOut); + encodedValue.setBoolean("crafting", this.isCraftingMode()); + encodedValue.setBoolean("substitute", this.isSubstitute()); - output.setTagCompound( encodedValue ); + output.setTagCompound(encodedValue); } - private ItemStack[] getInputs() - { + private ItemStack[] getInputs() { final ItemStack[] input = new ItemStack[9]; boolean hasValue = false; - for( int x = 0; x < this.craftingSlots.length; x++ ) - { + for (int x = 0; x < this.craftingSlots.length; x++) { input[x] = this.craftingSlots[x].getStack(); - if( input[x] != null ) - { + if (input[x] != null) { hasValue = true; } } - if( hasValue ) - { + if (hasValue) { return input; } return null; } - private ItemStack[] getOutputs() - { - if( this.isCraftingMode() ) - { + private ItemStack[] getOutputs() { + if (this.isCraftingMode()) { final ItemStack out = this.getAndUpdateOutput(); - if( out != null && out.stackSize > 0 ) - { - return new ItemStack[] { out }; + if (out != null && out.stackSize > 0) { + return new ItemStack[] {out}; } - } - else - { - final List list = new ArrayList<>( 3 ); + } else { + final List list = new ArrayList<>(3); boolean hasValue = false; - for( final OptionalSlotFake outputSlot : this.outputSlots ) - { + for (final OptionalSlotFake outputSlot : this.outputSlots) { final ItemStack out = outputSlot.getStack(); - if( out != null && out.stackSize > 0 ) - { - list.add( out ); + if (out != null && out.stackSize > 0) { + list.add(out); hasValue = true; } } - if( hasValue ) - { - return list.toArray( new ItemStack[list.size()] ); + if (hasValue) { + return list.toArray(new ItemStack[list.size()]); } } return null; } - private boolean isPattern( final ItemStack output ) - { - if( output == null ) - { + private boolean isPattern(final ItemStack output) { + if (output == null) { return false; } if (output.getItem() instanceof ItemFluidEncodedPattern) { @@ -312,134 +314,127 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE } final IDefinitions definitions = AEApi.instance().definitions(); - boolean isPattern = definitions.items().encodedPattern().isSameAs( output ); - isPattern |= definitions.materials().blankPattern().isSameAs( output ); + boolean isPattern = definitions.items().encodedPattern().isSameAs(output); + isPattern |= definitions.materials().blankPattern().isSameAs(output); return isPattern; } - private NBTBase createItemTag(final ItemStack i ) - { + private NBTBase createItemTag(final ItemStack i) { final NBTTagCompound c = new NBTTagCompound(); - if( i != null ) - { - i.writeToNBT( c ); + if (i != null) { + i.writeToNBT(c); } return c; } @Override - public boolean isSlotEnabled( final int idx ) - { - if( idx == 1 ) - { + public boolean isSlotEnabled(final int idx) { + if (idx == 1) { return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode(); - } - else if( idx == 2 ) - { + } else if (idx == 2) { return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode(); - } - else - { + } else { return false; } } - public void craftOrGetItem( final PacketPatternSlot packetPatternSlot ) - { - if( packetPatternSlot.slotItem != null && this.getCellInventory() != null ) - { + public void craftOrGetItem(final PacketPatternSlot packetPatternSlot) { + if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) { final IAEItemStack out = packetPatternSlot.slotItem.copy(); - InventoryAdaptor inv = new AdaptorPlayerHand( this.getPlayerInv().player ); - final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player, ForgeDirection.UNKNOWN ); + InventoryAdaptor inv = new AdaptorPlayerHand(this.getPlayerInv().player); + final InventoryAdaptor playerInv = + InventoryAdaptor.getAdaptor(this.getPlayerInv().player, ForgeDirection.UNKNOWN); - if( packetPatternSlot.shift ) - { + if (packetPatternSlot.shift) { inv = playerInv; } - if( inv.simulateAdd( out.getItemStack() ) != null ) - { + if (inv.simulateAdd(out.getItemStack()) != null) { return; } - final IAEItemStack extracted = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), out, this.getActionSource() ); + final IAEItemStack extracted = Platform.poweredExtraction( + this.getPowerSource(), this.getCellInventory(), out, this.getActionSource()); final EntityPlayer p = this.getPlayerInv().player; - if( extracted != null ) - { - inv.addItems( extracted.getItemStack() ); - if( p instanceof EntityPlayerMP) - { - this.updateHeld( (EntityPlayerMP) p ); + if (extracted != null) { + inv.addItems(extracted.getItemStack()); + if (p instanceof EntityPlayerMP) { + this.updateHeld((EntityPlayerMP) p); } this.detectAndSendChanges(); return; } - final InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 ); - final InventoryCrafting real = new InventoryCrafting( new ContainerNull(), 3, 3 ); + final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3); + final InventoryCrafting real = new InventoryCrafting(new ContainerNull(), 3, 3); - for( int x = 0; x < 9; x++ ) - { - ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack() ); + for (int x = 0; x < 9; x++) { + ic.setInventorySlotContents( + x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack()); } - final IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj ); + final IRecipe r = Platform.findMatchingRecipe(ic, p.worldObj); - if( r == null ) - { + if (r == null) { return; } final IMEMonitor storage = this.getPatternTerminal().getItemInventory(); final IItemList all = storage.getStorageList(); - final ItemStack is = r.getCraftingResult( ic ); + final ItemStack is = r.getCraftingResult(ic); - for( int x = 0; x < ic.getSizeInventory(); x++ ) - { - if( ic.getStackInSlot( x ) != null ) - { - final ItemStack pulled = Platform.extractItemsByRecipe( this.getPowerSource(), this.getActionSource(), storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) ); - real.setInventorySlotContents( x, pulled ); + for (int x = 0; x < ic.getSizeInventory(); x++) { + if (ic.getStackInSlot(x) != null) { + final ItemStack pulled = Platform.extractItemsByRecipe( + this.getPowerSource(), + this.getActionSource(), + storage, + p.worldObj, + r, + is, + ic, + ic.getStackInSlot(x), + x, + all, + Actionable.MODULATE, + ItemViewCell.createFilter(this.getViewCells())); + real.setInventorySlotContents(x, pulled); } } - final IRecipe rr = Platform.findMatchingRecipe( real, p.worldObj ); + final IRecipe rr = Platform.findMatchingRecipe(real, p.worldObj); - if( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) ) - { - final SlotCrafting sc = new SlotCrafting( p, real, this.cOut, 0, 0, 0 ); - sc.onPickupFromSlot( p, is ); + if (rr == r && Platform.isSameItemPrecise(rr.getCraftingResult(real), is)) { + final SlotCrafting sc = new SlotCrafting(p, real, this.cOut, 0, 0, 0); + sc.onPickupFromSlot(p, is); - for( int x = 0; x < real.getSizeInventory(); x++ ) - { - final ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) ); + for (int x = 0; x < real.getSizeInventory(); x++) { + final ItemStack failed = playerInv.addItems(real.getStackInSlot(x)); - if( failed != null ) - { - p.dropPlayerItemWithRandomChoice( failed, false ); + if (failed != null) { + p.dropPlayerItemWithRandomChoice(failed, false); } } - inv.addItems( is ); - if( p instanceof EntityPlayerMP ) - { - this.updateHeld( (EntityPlayerMP) p ); + inv.addItems(is); + if (p instanceof EntityPlayerMP) { + this.updateHeld((EntityPlayerMP) p); } this.detectAndSendChanges(); - } - else - { - for( int x = 0; x < real.getSizeInventory(); x++ ) - { - final ItemStack failed = real.getStackInSlot( x ); - if( failed != null ) - { - this.getCellInventory().injectItems( AEItemStack.create( failed ), Actionable.MODULATE, new MachineSource( this.getPatternTerminal() ) ); + } else { + for (int x = 0; x < real.getSizeInventory(); x++) { + final ItemStack failed = real.getStackInSlot(x); + if (failed != null) { + this.getCellInventory() + .injectItems( + AEItemStack.create(failed), + Actionable.MODULATE, + new MachineSource(this.getPatternTerminal())); } } } @@ -447,14 +442,11 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - if( Platform.isServer() ) - { - if( this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe() ) - { - this.setCraftingMode( this.getPatternTerminal().isCraftingRecipe() ); + if (Platform.isServer()) { + if (this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe()) { + this.setCraftingMode(this.getPatternTerminal().isCraftingRecipe()); this.updateOrderOfOutputSlots(); } @@ -464,50 +456,40 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE } @Override - public void onUpdate( final String field, final Object oldValue, final Object newValue ) - { - super.onUpdate( field, oldValue, newValue ); + public void onUpdate(final String field, final Object oldValue, final Object newValue) { + super.onUpdate(field, oldValue, newValue); - if( field.equals( "craftingMode" ) ) - { + if (field.equals("craftingMode")) { this.getAndUpdateOutput(); this.updateOrderOfOutputSlots(); } } @Override - public void onSlotChange( final Slot s ) - { - if( s == this.patternSlotOUT && Platform.isServer() ) - { - for( final Object crafter : this.crafters ) - { + public void onSlotChange(final Slot s) { + if (s == this.patternSlotOUT && Platform.isServer()) { + for (final Object crafter : this.crafters) { final ICrafting icrafting = (ICrafting) crafter; - for( final Object g : this.inventorySlots ) - { - if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix ) - { + for (final Object g : this.inventorySlots) { + if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) { final Slot sri = (Slot) g; - icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() ); + icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack()); } } - ( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false; + ((EntityPlayerMP) icrafting).isChangingQuantityOnly = false; } this.detectAndSendChanges(); } } - public void clear() - { - for( final Slot s : this.craftingSlots ) - { - s.putStack( null ); + public void clear() { + for (final Slot s : this.craftingSlots) { + s.putStack(null); } - for( final Slot s : this.outputSlots ) - { - s.putStack( null ); + for (final Slot s : this.outputSlots) { + s.putStack(null); } this.detectAndSendChanges(); @@ -515,111 +497,92 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE } @Override - public IInventory getInventoryByName( final String name ) - { - if( name.equals( "player" ) ) - { + public IInventory getInventoryByName(final String name) { + if (name.equals("player")) { return this.getInventoryPlayer(); } - return this.getPatternTerminal().getInventoryByName( name ); + return this.getPatternTerminal().getInventoryByName(name); } @Override - public boolean useRealItems() - { + public boolean useRealItems() { return false; } - public void toggleSubstitute() - { + public void toggleSubstitute() { this.substitute = !this.substitute; this.detectAndSendChanges(); this.getAndUpdateOutput(); } - public boolean isCraftingMode() - { + public boolean isCraftingMode() { return this.craftingMode; } - private void setCraftingMode( final boolean craftingMode ) - { + private void setCraftingMode(final boolean craftingMode) { this.craftingMode = craftingMode; } - public PartFluidPatternTerminal getPatternTerminal() - { + public PartFluidPatternTerminal getPatternTerminal() { return this.patternTerminal; } - private boolean isSubstitute() - { + private boolean isSubstitute() { return this.substitute; } - public void setSubstitute( final boolean substitute ) - { + public void setSubstitute(final boolean substitute) { this.substitute = substitute; } - static boolean canDoubleStacks(SlotFake[] slots) - { - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count(); - long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count(); + static boolean canDoubleStacks(SlotFake[] slots) { + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long emptyStots = + enabledSlots.stream().filter(s -> s.getStack() == null).count(); + long fullSlots = enabledSlots.stream() + .filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127) + .count(); return fullSlots <= emptyStots && emptyStots < enabledSlots.size(); } - static void doubleStacksInternal(SlotFake[] slots) - { + static void doubleStacksInternal(SlotFake[] slots) { List overFlowStacks = new ArrayList<>(); - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - for (final Slot s : enabledSlots) - { + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + for (final Slot s : enabledSlots) { ItemStack st = s.getStack(); - if (st == null) - continue; + if (st == null) continue; if (Util.isFluidPacket(st)) { FluidStack fluidStack = ItemFluidPacket.getFluidStack(st); if (fluidStack != null) { fluidStack = ItemFluidPacket.getFluidStack(st).copy(); - if (fluidStack.amount < Integer.MAX_VALUE / 2) - fluidStack.amount *= 2; + if (fluidStack.amount < Integer.MAX_VALUE / 2) fluidStack.amount *= 2; } s.putStack(ItemFluidPacket.newStack(fluidStack)); - } - else if (st.stackSize * 2 > 127) - { + } else if (st.stackSize * 2 > 127) { overFlowStacks.add(st.copy()); - } - else - { + } else { st.stackSize *= 2; s.putStack(st); } } Iterator ow = overFlowStacks.iterator(); for (final Slot s : enabledSlots) { - if (!ow.hasNext()) - break; - if (s.getStack() != null) - continue; + if (!ow.hasNext()) break; + if (s.getStack() != null) continue; s.putStack(ow.next()); } assert !ow.hasNext(); } - public void doubleStacks(boolean isShift) - { - if (!isCraftingMode() && canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { + public void doubleStacks(boolean isShift) { + if (!isCraftingMode() && canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { doubleStacksInternal(this.craftingSlots); doubleStacksInternal(this.outputSlots); - if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) - { - while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { + if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) { + while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { doubleStacksInternal(this.craftingSlots); doubleStacksInternal(this.outputSlots); } @@ -629,9 +592,11 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE } static boolean containsFluid(SlotFake[] slots) { - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count(); + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long fluid = enabledSlots.stream() + .filter(s -> Util.isFluidPacket(s.getStack())) + .count(); return fluid > 0; } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java index 299f0e26..cdf1e25f 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java @@ -16,6 +16,11 @@ import com.glodblock.github.common.item.ItemFluidEncodedPattern; import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.common.parts.PartFluidPatternTerminalEx; import com.glodblock.github.util.Util; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -27,13 +32,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - -public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket { +public class FCBasePartContainerEx extends FCBaseMonitorContain + implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket { private static final int CRAFTING_GRID_PAGES = 2; private static final int CRAFTING_GRID_WIDTH = 4; @@ -45,7 +45,15 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp private static final int POSITION_SHIFT = 9000; private boolean hidden = false; - public ProcessingSlotFake(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) { + public ProcessingSlotFake( + IInventory inv, + IOptionalSlotHost containerBus, + int idx, + int x, + int y, + int offX, + int offY, + int groupNum) { super(inv, containerBus, idx, x, y, offX, offY, groupNum); this.setRenderDisabled(false); } @@ -59,136 +67,172 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp } private final PartFluidPatternTerminalEx patternTerminal; - protected final ProcessingSlotFake[] craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; - protected final ProcessingSlotFake[] outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; + protected final ProcessingSlotFake[] craftingSlots = + new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; + protected final ProcessingSlotFake[] outputSlots = + new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; protected final SlotRestrictedInput patternSlotIN; protected final SlotRestrictedInput patternSlotOUT; - @GuiSync( 96 + (17-9) + 11 ) + + @GuiSync(96 + (17 - 9) + 11) public boolean combine = false; - @GuiSync( 96 + (17-9) + 12 ) + + @GuiSync(96 + (17 - 9) + 12) public boolean substitute = false; - @GuiSync( 96 + (17-9) + 16 ) + + @GuiSync(96 + (17 - 9) + 16) public boolean inverted; - @GuiSync( 96 + (17-9) + 17 ) + + @GuiSync(96 + (17 - 9) + 17) public int activePage = 0; - @GuiSync( 96 + (17-9) + 13 ) + + @GuiSync(96 + (17 - 9) + 13) public boolean prioritize = false; - public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable ) - { - super( ip, monitorable, false ); + public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable) { + super(ip, monitorable, false); this.patternTerminal = (PartFluidPatternTerminalEx) monitorable; this.inverted = patternTerminal.isInverted(); - final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" ); - final IInventory output = this.getPatternTerminal().getInventoryByName( "output" ); + final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern"); + final IInventory output = this.getPatternTerminal().getInventoryByName("output"); IInventory crafting = this.getPatternTerminal().getInventoryByName("crafting"); for (int page = 0; page < CRAFTING_GRID_PAGES; page++) { for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) { for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) { - this.addSlotToContainer(this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(crafting, this, x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS, 15, -83, x, y, x + 4)); + this.addSlotToContainer( + this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] = + new ProcessingSlotFake( + crafting, + this, + x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS, + 15, + -83, + x, + y, + x + 4)); } } for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) { for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) { - this.addSlotToContainer(this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(output, this, x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS, 112, -83, -x, y, x)); + this.addSlotToContainer( + this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] = + new ProcessingSlotFake( + output, + this, + x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS, + 112, + -83, + -x, + y, + x)); } } } - this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) ); - this.addSlotToContainer( this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this.getInventoryPlayer() ) ); + this.addSlotToContainer( + this.patternSlotIN = new SlotRestrictedInput( + SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, + patternInv, + 0, + 147, + -72 - 9, + this.getInventoryPlayer())); + this.addSlotToContainer( + this.patternSlotOUT = new SlotRestrictedInput( + SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, + patternInv, + 1, + 147, + -72 + 34, + this.getInventoryPlayer())); - this.patternSlotOUT.setStackLimit( 1 ); + this.patternSlotOUT.setStackLimit(1); - this.bindPlayerInventory( ip, 0, 0 ); + this.bindPlayerInventory(ip, 0, 0); } @Override - public void saveChanges() - { + public void saveChanges() {} - } - - public void clear() - { - for( final Slot s : this.craftingSlots ) - { - s.putStack( null ); + public void clear() { + for (final Slot s : this.craftingSlots) { + s.putStack(null); } - for( final Slot s : this.outputSlots ) - { - s.putStack( null ); + for (final Slot s : this.outputSlots) { + s.putStack(null); } this.detectAndSendChanges(); } @Override - public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { + public void onChangeInventory( + final IInventory inv, + final int slot, + final InvOperation mc, + final ItemStack removedStack, + final ItemStack newStack) {} - } - - public void encodeAndMoveToInventory() - { + public void encodeAndMoveToInventory() { encode(); ItemStack output = this.patternSlotOUT.getStack(); - if ( output != null ) - { - if (!getPlayerInv().addItemStackToInventory( output )){ + if (output != null) { + if (!getPlayerInv().addItemStackToInventory(output)) { getPlayerInv().player.entityDropItem(output, 0); } - this.patternSlotOUT.putStack( null ); + this.patternSlotOUT.putStack(null); } } - public void encode() - { + public void encode() { ItemStack output = this.patternSlotOUT.getStack(); final ItemStack[] in = this.getInputs(); final ItemStack[] out = this.getOutputs(); // if there is no input, this would be silly. - if( in == null || out == null ) - { + if (in == null || out == null) { return; } // first check the output slots, should either be null, or a pattern - if( output != null && !this.isPattern( output ) ) - { + if (output != null && !this.isPattern(output)) { return; - }// if nothing is there we should snag a new pattern. - else if( output == null ) - { + } // if nothing is there we should snag a new pattern. + else if (output == null) { output = this.patternSlotIN.getStack(); - if (!this.isPattern( output )) - { + if (!this.isPattern(output)) { return; // no blanks. } // remove one, and clear the input slot. output.stackSize--; - if( output.stackSize == 0 ) - { - this.patternSlotIN.putStack( null ); + if (output.stackSize == 0) { + this.patternSlotIN.putStack(null); } // add a new encoded pattern. - for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() ) - { + for (final ItemStack encodedPatternStack : AEApi.instance() + .definitions() + .items() + .encodedPattern() + .maybeStack(1) + .asSet()) { output = encodedPatternStack; - this.patternSlotOUT.putStack( output ); + this.patternSlotOUT.putStack(output); } - } else if ( output.getItem() instanceof ItemFluidEncodedPattern ) { - for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() ) - { + } else if (output.getItem() instanceof ItemFluidEncodedPattern) { + for (final ItemStack encodedPatternStack : AEApi.instance() + .definitions() + .items() + .encodedPattern() + .maybeStack(1) + .asSet()) { output = encodedPatternStack; - this.patternSlotOUT.putStack( output ); + this.patternSlotOUT.putStack(output); } } @@ -198,77 +242,65 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp final NBTTagList tagIn = new NBTTagList(); final NBTTagList tagOut = new NBTTagList(); - for( final ItemStack i : in ) - { - tagIn.appendTag( this.createItemTag( i ) ); + for (final ItemStack i : in) { + tagIn.appendTag(this.createItemTag(i)); } - for( final ItemStack i : out ) - { - tagOut.appendTag( this.createItemTag( i ) ); + for (final ItemStack i : out) { + tagOut.appendTag(this.createItemTag(i)); } - encodedValue.setTag( "in", tagIn ); - encodedValue.setTag( "out", tagOut ); - encodedValue.setBoolean( "substitute", this.isSubstitute() ); + encodedValue.setTag("in", tagIn); + encodedValue.setTag("out", tagOut); + encodedValue.setBoolean("substitute", this.isSubstitute()); - encodedValue.setTag( "in", tagIn ); - encodedValue.setTag( "out", tagOut ); - encodedValue.setBoolean( "prioritize", this.isPrioritize() ); + encodedValue.setTag("in", tagIn); + encodedValue.setTag("out", tagOut); + encodedValue.setBoolean("prioritize", this.isPrioritize()); - output.setTagCompound( encodedValue ); + output.setTagCompound(encodedValue); } - private ItemStack[] getInputs() - { + private ItemStack[] getInputs() { final ItemStack[] input = new ItemStack[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; boolean hasValue = false; - for( int x = 0; x < this.craftingSlots.length; x++ ) - { + for (int x = 0; x < this.craftingSlots.length; x++) { input[x] = this.craftingSlots[x].getStack(); - if( input[x] != null ) - { + if (input[x] != null) { hasValue = true; } } - if( hasValue ) - { + if (hasValue) { return input; } return null; } - private ItemStack[] getOutputs() - { - final List list = new ArrayList<>( CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES ); + private ItemStack[] getOutputs() { + final List list = new ArrayList<>(CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES); boolean hasValue = false; - for( final OptionalSlotFake outputSlot : this.outputSlots ) - { + for (final OptionalSlotFake outputSlot : this.outputSlots) { final ItemStack out = outputSlot.getStack(); - if( out != null && out.stackSize > 0 ) - { - list.add( out ); + if (out != null && out.stackSize > 0) { + list.add(out); hasValue = true; } } - if( hasValue ) - { + if (hasValue) { return list.toArray(new ItemStack[0]); } return null; } - private boolean isPattern( final ItemStack output ) - { - if( output == null ) - { + private boolean isPattern(final ItemStack output) { + if (output == null) { return false; } if (output.getItem() instanceof ItemFluidEncodedPattern) { @@ -276,45 +308,38 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp } final IDefinitions definitions = AEApi.instance().definitions(); - boolean isPattern = definitions.items().encodedPattern().isSameAs( output ); - isPattern |= definitions.materials().blankPattern().isSameAs( output ); + boolean isPattern = definitions.items().encodedPattern().isSameAs(output); + isPattern |= definitions.materials().blankPattern().isSameAs(output); return isPattern; } - private NBTBase createItemTag(final ItemStack i ) - { + private NBTBase createItemTag(final ItemStack i) { final NBTTagCompound c = new NBTTagCompound(); - if( i != null ) - { - i.writeToNBT( c ); + if (i != null) { + i.writeToNBT(c); } return c; } @Override - public boolean isSlotEnabled( final int idx ) - { + public boolean isSlotEnabled(final int idx) { if (idx < 4) // outputs { return inverted || idx == 0; - } - else - { + } else { return !inverted || idx == 4; } } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - if( Platform.isServer() ) - { + if (Platform.isServer()) { this.substitute = this.patternTerminal.isSubstitution(); - this.combine = this.patternTerminal.shouldCombine(); //Check out + this.combine = this.patternTerminal.shouldCombine(); // Check out this.prioritize = this.patternTerminal.isPrioritize(); if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) { inverted = patternTerminal.isInverted(); @@ -324,13 +349,14 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp } } - private void offsetSlots() - { + private void offsetSlots() { for (int page = 0; page < CRAFTING_GRID_PAGES; page++) { for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) { for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) { - this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && inverted); - this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && !inverted); + this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden( + page != activePage || x > 0 && inverted); + this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden( + page != activePage || x > 0 && !inverted); } } } @@ -338,123 +364,105 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp @Override public void onUpdate(String field, Object oldValue, Object newValue) { - super.onUpdate( field, oldValue, newValue ); + super.onUpdate(field, oldValue, newValue); - if (field.equals( "inverted" ) || field.equals( "activePage" )) { + if (field.equals("inverted") || field.equals("activePage")) { offsetSlots(); } } @Override - public void onSlotChange( final Slot s ) - { - if( s == this.patternSlotOUT && Platform.isServer() ) - { + public void onSlotChange(final Slot s) { + if (s == this.patternSlotOUT && Platform.isServer()) { inverted = patternTerminal.isInverted(); - for( final Object crafter : this.crafters ) - { + for (final Object crafter : this.crafters) { final ICrafting icrafting = (ICrafting) crafter; - for( final Object g : this.inventorySlots ) - { - if( g instanceof OptionalSlotFake ) - { + for (final Object g : this.inventorySlots) { + if (g instanceof OptionalSlotFake) { final Slot sri = (Slot) g; - icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() ); + icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack()); } } - ( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false; + ((EntityPlayerMP) icrafting).isChangingQuantityOnly = false; } this.detectAndSendChanges(); } } @Override - public IInventory getInventoryByName( final String name ) - { - if( name.equals( "player" ) ) - { + public IInventory getInventoryByName(final String name) { + if (name.equals("player")) { return this.getInventoryPlayer(); } - return this.getPatternTerminal().getInventoryByName( name ); + return this.getPatternTerminal().getInventoryByName(name); } @Override - public boolean useRealItems() - { + public boolean useRealItems() { return false; } - public PartFluidPatternTerminalEx getPatternTerminal() - { + public PartFluidPatternTerminalEx getPatternTerminal() { return this.patternTerminal; } - private boolean isSubstitute() - { + private boolean isSubstitute() { return this.substitute; } - private boolean isPrioritize() { return this.prioritize; } + private boolean isPrioritize() { + return this.prioritize; + } - static boolean canDoubleStacks(SlotFake[] slots) - { - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count(); - long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count(); + static boolean canDoubleStacks(SlotFake[] slots) { + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long emptyStots = + enabledSlots.stream().filter(s -> s.getStack() == null).count(); + long fullSlots = enabledSlots.stream() + .filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127) + .count(); return fullSlots <= emptyStots; } - static void doubleStacksInternal(SlotFake[] slots) - { + static void doubleStacksInternal(SlotFake[] slots) { List overFlowStacks = new ArrayList<>(); - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - for (final Slot s : enabledSlots) - { + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + for (final Slot s : enabledSlots) { ItemStack st = s.getStack(); - if (st == null) - continue; + if (st == null) continue; if (Util.isFluidPacket(st)) { FluidStack fluidStack = ItemFluidPacket.getFluidStack(st); if (fluidStack != null) { fluidStack = ItemFluidPacket.getFluidStack(st).copy(); - if (fluidStack.amount < Integer.MAX_VALUE / 2) - fluidStack.amount *= 2; + if (fluidStack.amount < Integer.MAX_VALUE / 2) fluidStack.amount *= 2; } s.putStack(ItemFluidPacket.newStack(fluidStack)); - } - else if (st.stackSize * 2 > 127) - { + } else if (st.stackSize * 2 > 127) { overFlowStacks.add(st.copy()); - } - else - { + } else { st.stackSize *= 2; s.putStack(st); } } Iterator ow = overFlowStacks.iterator(); for (final Slot s : enabledSlots) { - if (!ow.hasNext()) - break; - if (s.getStack() != null) - continue; + if (!ow.hasNext()) break; + if (s.getStack() != null) continue; s.putStack(ow.next()); } assert !ow.hasNext(); } - public void doubleStacks(boolean isShift) - { - if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { + public void doubleStacks(boolean isShift) { + if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { doubleStacksInternal(this.craftingSlots); doubleStacksInternal(this.outputSlots); - if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) - { - while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { + if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) { + while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { doubleStacksInternal(this.craftingSlots); doubleStacksInternal(this.outputSlots); } @@ -464,8 +472,11 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp } static boolean containsFluid(SlotFake[] slots) { - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count(); + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long fluid = enabledSlots.stream() + .filter(s -> Util.isFluidPacket(s.getStack())) + .count(); return fluid > 0; } @@ -476,5 +487,4 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp public int getActivePage() { return this.activePage; } - } diff --git a/src/main/java/com/glodblock/github/client/gui/container/FluidPrioritization.java b/src/main/java/com/glodblock/github/client/gui/container/FluidPrioritization.java index 985f1671..893d2dc0 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FluidPrioritization.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FluidPrioritization.java @@ -1,12 +1,6 @@ package com.glodblock.github.client.gui.container; - -import akka.actor.Status; - -import java.lang.reflect.Type; - public enum FluidPrioritization { ENABLED, DISABLED; - } diff --git a/src/main/java/com/glodblock/github/client/render/ItemDropRender.java b/src/main/java/com/glodblock/github/client/render/ItemDropRender.java index 78be0de4..3f13fb11 100644 --- a/src/main/java/com/glodblock/github/client/render/ItemDropRender.java +++ b/src/main/java/com/glodblock/github/client/render/ItemDropRender.java @@ -5,6 +5,8 @@ import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.util.RenderUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.Map; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -18,9 +20,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; -import java.util.HashMap; -import java.util.Map; - @SideOnly(Side.CLIENT) public class ItemDropRender implements IItemRenderer { @@ -62,7 +61,15 @@ public class ItemDropRender implements IItemRenderer { if (type.equals(ItemRenderType.INVENTORY)) { RenderUtil.renderItemIcon(shape, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { - ItemRenderer.renderItemIn2D(Tessellator.instance, shape.getMaxU(), shape.getMinV(), shape.getMinU(), shape.getMaxV(), shape.getIconWidth(), shape.getIconHeight(), 0.0625F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + shape.getMaxU(), + shape.getMinV(), + shape.getMinU(), + shape.getMaxV(), + shape.getIconWidth(), + shape.getIconHeight(), + 0.0625F); } GL11.glDisable(GL11.GL_ALPHA_TEST); @@ -84,8 +91,9 @@ public class ItemDropRender implements IItemRenderer { if (colour == 0xFFFFFF) { TextureAtlasSprite sprite; try { - sprite = Minecraft.getMinecraft().getTextureMapBlocks() - .getTextureExtry(fluid.getStillIcon().getIconName()); + sprite = Minecraft.getMinecraft() + .getTextureMapBlocks() + .getTextureExtry(fluid.getStillIcon().getIconName()); } catch (NullPointerException e) { colourCache.put(fluid.getName(), colour); return colour; diff --git a/src/main/java/com/glodblock/github/client/render/ItemPacketRender.java b/src/main/java/com/glodblock/github/client/render/ItemPacketRender.java index 978f7c25..252b4683 100644 --- a/src/main/java/com/glodblock/github/client/render/ItemPacketRender.java +++ b/src/main/java/com/glodblock/github/client/render/ItemPacketRender.java @@ -34,8 +34,7 @@ public class ItemPacketRender implements IItemRenderer { @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - if (item == null || item.getItem() == null || !(item.getItem() instanceof ItemFluidPacket)) - return; + if (item == null || item.getItem() == null || !(item.getItem() instanceof ItemFluidPacket)) return; GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); @@ -46,7 +45,9 @@ public class ItemPacketRender implements IItemRenderer { if (fluid != null) { RGB = fluid.getFluid().getColor(fluid); } - IIcon icon = fluid == null ? FluidRegistry.WATER.getStillIcon() : fluid.getFluid().getStillIcon(); + IIcon icon = fluid == null + ? FluidRegistry.WATER.getStillIcon() + : fluid.getFluid().getStillIcon(); if (RGB != 0xFFFFFF) { GL11.glColor3f((RGB >> 16 & 0xFF) / 255.0F, (RGB >> 8 & 0xFF) / 255.0F, (RGB & 0xFF) / 255.0F); @@ -55,11 +56,18 @@ public class ItemPacketRender implements IItemRenderer { if (type.equals(ItemRenderType.INVENTORY)) { RenderUtil.renderItemIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } else { - ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + ItemRenderer.renderItemIn2D( + Tessellator.instance, + icon.getMaxU(), + icon.getMinV(), + icon.getMinU(), + icon.getMaxV(), + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F); } GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); } - } diff --git a/src/main/java/com/glodblock/github/client/render/RenderBlockFluidInterface.java b/src/main/java/com/glodblock/github/client/render/RenderBlockFluidInterface.java index c86cef7f..fec17b0f 100644 --- a/src/main/java/com/glodblock/github/client/render/RenderBlockFluidInterface.java +++ b/src/main/java/com/glodblock/github/client/render/RenderBlockFluidInterface.java @@ -11,29 +11,32 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; -public class RenderBlockFluidInterface extends BaseBlockRender -{ +public class RenderBlockFluidInterface extends BaseBlockRender { - public RenderBlockFluidInterface() - { - super( false, 20 ); + public RenderBlockFluidInterface() { + super(false, 20); } @Override - public boolean renderInWorld(final BlockFluidInterface block, final IBlockAccess world, final int x, final int y, final int z, final RenderBlocks renderer ) - { - final TileInterface ti = block.getTileEntity( world, x, y, z ); + public boolean renderInWorld( + final BlockFluidInterface block, + final IBlockAccess world, + final int x, + final int y, + final int z, + final RenderBlocks renderer) { + final TileInterface ti = block.getTileEntity(world, x, y, z); final BlockRenderInfo info = block.getRendererInstance(); - if( ti != null && ti.getForward() != ForgeDirection.UNKNOWN ) - { + if (ti != null && ti.getForward() != ForgeDirection.UNKNOWN) { final IIcon side = FCPartsTexture.BlockFluidInterfaceAlternate_Arrow.getIcon(); - info.setTemporaryRenderIcons( FCPartsTexture.BlockInterfaceAlternate.getIcon(), block.getIcon( 0, 0 ), side, side, side, side ); + info.setTemporaryRenderIcons( + FCPartsTexture.BlockInterfaceAlternate.getIcon(), block.getIcon(0, 0), side, side, side, side); } - final boolean fz = super.renderInWorld( block, world, x, y, z, renderer ); + final boolean fz = super.renderInWorld(block, world, x, y, z, renderer); - info.setTemporaryRenderIcon( null ); + info.setTemporaryRenderIcon(null); return fz; } diff --git a/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java b/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java index 5027a355..b664d934 100644 --- a/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java +++ b/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java @@ -9,44 +9,42 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; public enum FCPartsTexture { - - PartFluidPatternTerminal_Bright("pattern_terminal_bright"), PartFluidPatternTerminal_Dark("pattern_terminal_dark"), - PartFluidPatternTerminal_Colored("pattern_terminal_medium"), PartTerminalBroad("terminal_broad"), - PartFluidImportBus("fluid_import_face"), PartFluidExportBus("fluid_export_face"), - BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"), BlockInterfaceAlternate("fluid_interface_a"), + PartFluidPatternTerminal_Bright("pattern_terminal_bright"), + PartFluidPatternTerminal_Dark("pattern_terminal_dark"), + PartFluidPatternTerminal_Colored("pattern_terminal_medium"), + PartTerminalBroad("terminal_broad"), + PartFluidImportBus("fluid_import_face"), + PartFluidExportBus("fluid_export_face"), + BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"), + BlockInterfaceAlternate("fluid_interface_a"), BlockInterface_Face("fluid_interface"); private final String name; public net.minecraft.util.IIcon IIcon; - FCPartsTexture( final String name ) - { + FCPartsTexture(final String name) { this.name = name; } - public static ResourceLocation GuiTexture(final String string) - { + public static ResourceLocation GuiTexture(final String string) { return null; } - @SideOnly( Side.CLIENT ) - public static IIcon getMissing() - { - return ( (TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture( TextureMap.locationBlocksTexture ) ).getAtlasSprite( "missingno" ); + @SideOnly(Side.CLIENT) + public static IIcon getMissing() { + return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)) + .getAtlasSprite("missingno"); } - public String getName() - { + public String getName() { return this.name; } - public IIcon getIcon() - { + public IIcon getIcon() { return this.IIcon; } - public void registerIcon( final TextureMap map ) - { - this.IIcon = map.registerIcon( NameConst.RES_KEY + this.name ); + public void registerIcon(final TextureMap map) { + this.IIcon = map.registerIcon(NameConst.RES_KEY + this.name); } } diff --git a/src/main/java/com/glodblock/github/common/Config.java b/src/main/java/com/glodblock/github/common/Config.java index 12267b84..dc9db3bf 100644 --- a/src/main/java/com/glodblock/github/common/Config.java +++ b/src/main/java/com/glodblock/github/common/Config.java @@ -1,13 +1,13 @@ package com.glodblock.github.common; import cpw.mods.fml.relauncher.FMLInjectionData; -import net.minecraftforge.common.config.Configuration; - import java.io.File; +import net.minecraftforge.common.config.Configuration; public class Config { - private static final Configuration Config = new Configuration(new File(new File((File) FMLInjectionData.data()[6], "config"), "ae2fc.cfg")); + private static final Configuration Config = + new Configuration(new File(new File((File) FMLInjectionData.data()[6], "config"), "ae2fc.cfg")); public static boolean fluidCells; public static boolean noFluidPacket; @@ -21,14 +21,30 @@ public class Config { } private static void loadProperty() { - fluidCells = Config.getBoolean("Enable Fluid Storage Cell", "Fluid Craft for AE2", true, "Enable this to generate the fluid storage cells. If you are playing with EC2, you can turn it off."); - noFluidPacket = Config.getBoolean("No Fluid Packet", "Fluid Craft for AE2", false, "Enable this to make normal ME Interface can emit fluid with fluid pattern, like the ME Dual Interface."); - fluidIOBus = Config.getBoolean("Enable AE2FC's Fluid I/O Bus", "Fluid Craft for AE2", true, "Enable this to add Fluid Import/Export Bus like EC2's one."); - removeRecipe = Config.getBoolean("Disable all recipes", "Fluid Craft for AE2", false, "Disable all recipes, for quick tweaker."); - blacklistEssentiaGas = Config.getBoolean("Blacklist Essentia Gas", "Fluid Craft for AE2", true, "Blacklist Essentia Gas from Thaumic Energistics, so they won't be stored in Fluid Storage Cells."); + fluidCells = Config.getBoolean( + "Enable Fluid Storage Cell", + "Fluid Craft for AE2", + true, + "Enable this to generate the fluid storage cells. If you are playing with EC2, you can turn it off."); + noFluidPacket = Config.getBoolean( + "No Fluid Packet", + "Fluid Craft for AE2", + false, + "Enable this to make normal ME Interface can emit fluid with fluid pattern, like the ME Dual Interface."); + fluidIOBus = Config.getBoolean( + "Enable AE2FC's Fluid I/O Bus", + "Fluid Craft for AE2", + true, + "Enable this to add Fluid Import/Export Bus like EC2's one."); + removeRecipe = Config.getBoolean( + "Disable all recipes", "Fluid Craft for AE2", false, "Disable all recipes, for quick tweaker."); + blacklistEssentiaGas = Config.getBoolean( + "Blacklist Essentia Gas", + "Fluid Craft for AE2", + true, + "Blacklist Essentia Gas from Thaumic Energistics, so they won't be stored in Fluid Storage Cells."); - if (Config.hasChanged()) - Config.save(); + if (Config.hasChanged()) Config.save(); } private static void loadCategory() { diff --git a/src/main/java/com/glodblock/github/common/block/BlockFluidDiscretizer.java b/src/main/java/com/glodblock/github/common/block/BlockFluidDiscretizer.java index 333979be..03ea759d 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockFluidDiscretizer.java +++ b/src/main/java/com/glodblock/github/common/block/BlockFluidDiscretizer.java @@ -31,5 +31,4 @@ public class BlockFluidDiscretizer extends FCBaseBlock { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/block/BlockFluidInterface.java b/src/main/java/com/glodblock/github/common/block/BlockFluidInterface.java index 7618e805..d3217f97 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/block/BlockFluidInterface.java @@ -15,6 +15,7 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.EnumSet; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -22,8 +23,6 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.EnumSet; - public class BlockFluidInterface extends FCBaseBlock { public BlockFluidInterface() { @@ -31,29 +30,34 @@ public class BlockFluidInterface extends FCBaseBlock { setFullBlock(true); setOpaque(true); setTileEntity(TileFluidInterface.class); - setFeature( EnumSet.of( AEFeature.Core ) ); + setFeature(EnumSet.of(AEFeature.Core)); } @Override - @SideOnly( Side.CLIENT ) - protected RenderBlockFluidInterface getRenderer() - { + @SideOnly(Side.CLIENT) + protected RenderBlockFluidInterface getRenderer() { return new RenderBlockFluidInterface(); } @Override - public boolean onActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int facing, final float hitX, final float hitY, final float hitZ ) - { - if( player.isSneaking() ) - { + public boolean onActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer player, + final int facing, + final float hitX, + final float hitY, + final float hitZ) { + if (player.isSneaking()) { return false; } - final TileInterface tg = this.getTileEntity( world, x, y, z ); - if( tg != null ) - { - if( Platform.isServer() ) - { - InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE); + final TileInterface tg = this.getTileEntity(world, x, y, z); + if (tg != null) { + if (Platform.isServer()) { + InventoryHandler.openGui( + player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE); } return true; } @@ -61,17 +65,14 @@ public class BlockFluidInterface extends FCBaseBlock { } @Override - protected boolean hasCustomRotation() - { + protected boolean hasCustomRotation() { return true; } @Override - protected void customRotateBlock(final IOrientable rotatable, final ForgeDirection axis ) - { - if( rotatable instanceof TileInterface ) - { - ( (TileInterface) rotatable ).setSide( axis ); + protected void customRotateBlock(final IOrientable rotatable, final ForgeDirection axis) { + if (rotatable instanceof TileInterface) { + ((TileInterface) rotatable).setSide(axis); } } @@ -89,5 +90,4 @@ public class BlockFluidInterface extends FCBaseBlock { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/block/BlockFluidPacketDecoder.java b/src/main/java/com/glodblock/github/common/block/BlockFluidPacketDecoder.java index e0be3d6a..d42f632b 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockFluidPacketDecoder.java +++ b/src/main/java/com/glodblock/github/common/block/BlockFluidPacketDecoder.java @@ -24,14 +24,20 @@ public class BlockFluidPacketDecoder extends FCBaseBlock { } @Override - public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { + public boolean onActivated( + World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { return false; } TileFluidPacketDecoder tile = getTileEntity(world, x, y, z); if (tile != null) { if (!world.isRemote) { - InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.FLUID_PACKET_DECODER); + InventoryHandler.openGui( + player, + world, + new BlockPos(x, y, z), + EnumFacing.getFront(facing), + GuiType.FLUID_PACKET_DECODER); } return true; } @@ -52,5 +58,4 @@ public class BlockFluidPacketDecoder extends FCBaseBlock { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/block/BlockFluidPatternEncoder.java b/src/main/java/com/glodblock/github/common/block/BlockFluidPatternEncoder.java index 524e3a0b..4e892d70 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockFluidPatternEncoder.java +++ b/src/main/java/com/glodblock/github/common/block/BlockFluidPatternEncoder.java @@ -24,14 +24,20 @@ public class BlockFluidPatternEncoder extends FCBaseBlock { } @Override - public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { + public boolean onActivated( + World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { return false; } TileFluidPatternEncoder tile = getTileEntity(world, x, y, z); if (tile != null) { if (!world.isRemote) { - InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.FLUID_PATTERN_ENCODER); + InventoryHandler.openGui( + player, + world, + new BlockPos(x, y, z), + EnumFacing.getFront(facing), + GuiType.FLUID_PATTERN_ENCODER); } return true; } @@ -52,5 +58,4 @@ public class BlockFluidPatternEncoder extends FCBaseBlock { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java b/src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java index ebe2b6d2..a57ac218 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/common/block/BlockIngredientBuffer.java @@ -25,14 +25,16 @@ public class BlockIngredientBuffer extends FCBaseBlock { } @Override - public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { + public boolean onActivated( + World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { return false; } TileIngredientBuffer tile = getTileEntity(world, x, y, z); if (tile != null) { if (!world.isRemote) { - InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER); + InventoryHandler.openGui( + player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER); } return true; } @@ -53,5 +55,4 @@ public class BlockIngredientBuffer extends FCBaseBlock { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/block/BlockLargeIngredientBuffer.java b/src/main/java/com/glodblock/github/common/block/BlockLargeIngredientBuffer.java index ffe9210a..a1d1474c 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockLargeIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/common/block/BlockLargeIngredientBuffer.java @@ -25,14 +25,20 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock { } @Override - public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { + public boolean onActivated( + World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { return false; } TileLargeIngredientBuffer tile = getTileEntity(world, x, y, z); if (tile != null) { if (!world.isRemote) { - InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.LARGE_INGREDIENT_BUFFER); + InventoryHandler.openGui( + player, + world, + new BlockPos(x, y, z), + EnumFacing.getFront(facing), + GuiType.LARGE_INGREDIENT_BUFFER); } return true; } @@ -53,5 +59,4 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/block/BlockOCPatternEditor.java b/src/main/java/com/glodblock/github/common/block/BlockOCPatternEditor.java index e64f29e8..dea07c46 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockOCPatternEditor.java +++ b/src/main/java/com/glodblock/github/common/block/BlockOCPatternEditor.java @@ -25,14 +25,16 @@ public class BlockOCPatternEditor extends FCBaseBlock { } @Override - public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { + public boolean onActivated( + World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { return false; } TileOCPatternEditor tile = getTileEntity(world, x, y, z); if (tile != null) { if (!world.isRemote) { - InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR); + InventoryHandler.openGui( + player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR); } return true; } @@ -56,5 +58,4 @@ public class BlockOCPatternEditor extends FCBaseBlock { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/block/FCBaseBlock.java b/src/main/java/com/glodblock/github/common/block/FCBaseBlock.java index 01805e37..94a1e936 100644 --- a/src/main/java/com/glodblock/github/common/block/FCBaseBlock.java +++ b/src/main/java/com/glodblock/github/common/block/FCBaseBlock.java @@ -3,11 +3,10 @@ package com.glodblock.github.common.block; import appeng.block.AEBaseTileBlock; import appeng.core.features.AEFeature; import com.glodblock.github.FluidCraft; +import java.util.EnumSet; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; -import java.util.EnumSet; - public class FCBaseBlock extends AEBaseTileBlock { public FCBaseBlock(Material mat, String name) { @@ -17,7 +16,7 @@ public class FCBaseBlock extends AEBaseTileBlock { } @Override - public void setTileEntity( final Class clazz ) { + public void setTileEntity(final Class clazz) { super.setTileEntity(clazz); } @@ -30,8 +29,7 @@ public class FCBaseBlock extends AEBaseTileBlock { } @Override - public void setFeature( final EnumSet f ) { + public void setFeature(final EnumSet f) { super.setFeature(f); } - } diff --git a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java index 2ba2bc2b..15dd3e34 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java +++ b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStorageCell.java @@ -30,6 +30,9 @@ import com.google.common.base.Optional; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -41,29 +44,22 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.ForgeEventFactory; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; - -public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFluidCell -{ +public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFluidCell { private final CellType component; private final int totalBytes; private final int perType; private final double idleDrain; - private final static HashMap icon = new HashMap<>(); + private static final HashMap icon = new HashMap<>(); - public ItemBasicFluidStorageCell( final CellType whichCell, final int kilobytes ) - { - super( Optional.of( kilobytes + "k" ) ); + public ItemBasicFluidStorageCell(final CellType whichCell, final int kilobytes) { + super(Optional.of(kilobytes + "k")); setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes); - this.setFeature( EnumSet.of( AEFeature.StorageCells ) ); - this.setMaxStackSize( 1 ); + this.setFeature(EnumSet.of(AEFeature.StorageCells)); + this.setMaxStackSize(1); this.totalBytes = kilobytes * 1024; this.component = whichCell; - switch( this.component ) - { + switch (this.component) { case Cell1kPart: this.idleDrain = 0.5; this.perType = 8; @@ -110,7 +106,10 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - icon.put(this.totalBytes / 1024, iconRegister.registerIcon(NameConst.RES_KEY + NameConst.ITEM_FLUID_STORAGE + "." + this.totalBytes / 1024)); + icon.put( + this.totalBytes / 1024, + iconRegister.registerIcon( + NameConst.RES_KEY + NameConst.ITEM_FLUID_STORAGE + "." + this.totalBytes / 1024)); } @Override @@ -121,24 +120,27 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu } @Override - public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List lines, final boolean displayMoreInfo ) - { - final IMEInventoryHandler inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.FLUIDS ); + public void addCheckedInformation( + final ItemStack stack, final EntityPlayer player, final List lines, final boolean displayMoreInfo) { + final IMEInventoryHandler inventory = + AEApi.instance().registries().cell().getCellInventory(stack, null, StorageChannel.FLUIDS); - if( inventory instanceof IFluidCellInventoryHandler) - { + if (inventory instanceof IFluidCellInventoryHandler) { final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory; final IFluidCellInventory cellInventory = handler.getCellInv(); - if( cellInventory != null ) - { - lines.add( cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal() ); + if (cellInventory != null) { + lines.add(cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + + cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal()); - lines.add( cellInventory.getStoredFluidTypes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalFluidTypes() + ' ' + GuiText.Types.getLocal() ); + lines.add(cellInventory.getStoredFluidTypes() + " " + GuiText.Of.getLocal() + ' ' + + cellInventory.getTotalFluidTypes() + ' ' + GuiText.Types.getLocal()); - if( handler.isPreformatted() ) - { - final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded).getLocal(); + if (handler.isPreformatted()) { + final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST + ? GuiText.Included + : GuiText.Excluded) + .getLocal(); lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal()); } } @@ -146,14 +148,12 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu } @Override - public int getBytes( final ItemStack cellItem ) - { + public int getBytes(final ItemStack cellItem) { return this.totalBytes; } @Override - public int getBytesPerType( final ItemStack cellItem ) - { + public int getBytesPerType(final ItemStack cellItem) { return this.perType; } @@ -166,131 +166,113 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu } @Override - public int getTotalTypes( final ItemStack cellItem ) - { + public int getTotalTypes(final ItemStack cellItem) { return 1; } @Override - public boolean storableInStorageCell() - { + public boolean storableInStorageCell() { return false; } @Override - public boolean isStorageCell( final ItemStack i ) - { + public boolean isStorageCell(final ItemStack i) { return true; } @Override - public double getIdleDrain() - { + public double getIdleDrain() { return this.idleDrain; } @Override - public boolean isEditable( final ItemStack is ) - { + public boolean isEditable(final ItemStack is) { return true; } @Override - public IInventory getUpgradesInventory(final ItemStack is ) - { - return new CellUpgrades( is, 0 ); + public IInventory getUpgradesInventory(final ItemStack is) { + return new CellUpgrades(is, 0); } @Override - public IInventory getConfigInventory( final ItemStack is ) - { - return new CellConfig( is ); + public IInventory getConfigInventory(final ItemStack is) { + return new CellConfig(is); } @Override - public FuzzyMode getFuzzyMode(final ItemStack is ) - { - final String fz = Platform.openNbtData( is ).getString( "FuzzyMode" ); - try - { - return FuzzyMode.valueOf( fz ); - } - catch( final Throwable t ) - { + public FuzzyMode getFuzzyMode(final ItemStack is) { + final String fz = Platform.openNbtData(is).getString("FuzzyMode"); + try { + return FuzzyMode.valueOf(fz); + } catch (final Throwable t) { return FuzzyMode.IGNORE_ALL; } } @Override - public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode ) - { - Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() ); + public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) { + Platform.openNbtData(is).setString("FuzzyMode", fzMode.name()); } public String getOreFilter(ItemStack is) { - return Platform.openNbtData( is ).getString( "OreFilter" ); + return Platform.openNbtData(is).getString("OreFilter"); } public void setOreFilter(ItemStack is, String filter) { - Platform.openNbtData( is ).setString("OreFilter", filter); + Platform.openNbtData(is).setString("OreFilter", filter); } @Override - public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player ) - { - this.disassembleDrive( stack, world, player ); + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) { + this.disassembleDrive(stack, world, player); return stack; } - private boolean disassembleDrive( final ItemStack stack, final World world, final EntityPlayer player ) - { - if( player.isSneaking() ) - { - if( Platform.isClient() ) - { + private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) { + if (player.isSneaking()) { + if (Platform.isClient()) { return false; } final InventoryPlayer playerInventory = player.inventory; - final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.FLUIDS ); - if( inv != null && playerInventory.getCurrentItem() == stack ) - { - final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN ); - final IItemList list = inv.getAvailableItems( StorageChannel.FLUIDS.createList() ); - if( list.isEmpty() && ia != null ) - { - playerInventory.setInventorySlotContents( playerInventory.currentItem, null ); + final IMEInventoryHandler inv = + AEApi.instance().registries().cell().getCellInventory(stack, null, StorageChannel.FLUIDS); + if (inv != null && playerInventory.getCurrentItem() == stack) { + final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN); + final IItemList list = inv.getAvailableItems(StorageChannel.FLUIDS.createList()); + if (list.isEmpty() && ia != null) { + playerInventory.setInventorySlotContents(playerInventory.currentItem, null); // drop core - final ItemStack extraB = ia.addItems( this.component.stack( 1 ) ); - if( extraB != null ) - { - player.dropPlayerItemWithRandomChoice( extraB, false ); + final ItemStack extraB = ia.addItems(this.component.stack(1)); + if (extraB != null) { + player.dropPlayerItemWithRandomChoice(extraB, false); } // drop upgrades - final IInventory upgradesInventory = this.getUpgradesInventory( stack ); - for( int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++ ) - { - final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex ); - final ItemStack leftStack = ia.addItems( upgradeStack ); - if( leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) - { - player.dropPlayerItemWithRandomChoice( upgradeStack, false ); + final IInventory upgradesInventory = this.getUpgradesInventory(stack); + for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++) { + final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex); + final ItemStack leftStack = ia.addItems(upgradeStack); + if (leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) { + player.dropPlayerItemWithRandomChoice(upgradeStack, false); } } // drop empty storage cell case - for( final ItemStack storageCellStack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() ) - { - final ItemStack extraA = ia.addItems( storageCellStack ); - if( extraA != null ) - { - player.dropPlayerItemWithRandomChoice( extraA, false ); + for (final ItemStack storageCellStack : AEApi.instance() + .definitions() + .materials() + .emptyStorageCell() + .maybeStack(1) + .asSet()) { + final ItemStack extraA = ia.addItems(storageCellStack); + if (extraA != null) { + player.dropPlayerItemWithRandomChoice(extraA, false); } } - if( player.inventoryContainer != null ) - { + if (player.inventoryContainer != null) { player.inventoryContainer.detectAndSendChanges(); } @@ -302,34 +284,44 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu } @Override - public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ ) - { - if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 ) - return true; + public boolean onItemUseFirst( + final ItemStack stack, + final EntityPlayer player, + final World world, + final int x, + final int y, + final int z, + final int side, + final float hitX, + final float hitY, + final float hitZ) { + if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true; - return this.disassembleDrive( stack, world, player ); + return this.disassembleDrive(stack, world, player); } @Override - public ItemStack getContainerItem( final ItemStack itemStack ) - { - for( final ItemStack stack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() ) - { + public ItemStack getContainerItem(final ItemStack itemStack) { + for (final ItemStack stack : AEApi.instance() + .definitions() + .materials() + .emptyStorageCell() + .maybeStack(1) + .asSet()) { return stack; } - throw new MissingDefinition( "Tried to use empty storage cells while basic storage cells are defined." ); + throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined."); } @Override - public boolean hasContainerItem( final ItemStack stack ) - { - return AEConfig.instance.isFeatureEnabled( AEFeature.EnableDisassemblyCrafting ); + public boolean hasContainerItem(final ItemStack stack) { + return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting); } public ItemBasicFluidStorageCell register() { if (!Config.fluidCells) return null; - GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024 , FluidCraft.MODID); + GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024, FluidCraft.MODID); setCreativeTab(FluidCraftingTabs.INSTANCE); return this; } @@ -341,5 +333,4 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java index 6b713d97..e4a59b96 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java +++ b/src/main/java/com/glodblock/github/common/item/ItemBasicFluidStoragePart.java @@ -7,6 +7,8 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -14,13 +16,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; -import java.util.HashMap; -import java.util.List; - public class ItemBasicFluidStoragePart extends Item { public static final int types = 7; - private final static HashMap icon = new HashMap<>(); + private static final HashMap icon = new HashMap<>(); public ItemBasicFluidStoragePart() { super(); @@ -46,7 +45,7 @@ public class ItemBasicFluidStoragePart extends Item { @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - for (int i = 0; i < types; i ++) { + for (int i = 0; i < types; i++) { icon.put(i, iconRegister.registerIcon(NameConst.RES_KEY + NameConst.ITEM_FLUID_PART + "." + i)); } } @@ -63,5 +62,4 @@ public class ItemBasicFluidStoragePart extends Item { setCreativeTab(FluidCraftingTabs.INSTANCE); return this; } - } diff --git a/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java b/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java index 7fad6363..c31e2c85 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java +++ b/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java @@ -10,6 +10,9 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -24,10 +27,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import javax.annotation.Nullable; -import java.util.List; -import java.util.Objects; - public class ItemFluidDrop extends Item { @SideOnly(Side.CLIENT) @@ -46,7 +45,8 @@ public class ItemFluidDrop extends Item { @Override public String getItemStackDisplayName(ItemStack stack) { FluidStack fluid = getFluidStack(stack); - return StatCollector.translateToLocalFormatted("item.fluid_drop.name", fluid == null ? "???" : fluid.getLocalizedName()); + return StatCollector.translateToLocalFormatted( + "item.fluid_drop.name", fluid == null ? "???" : fluid.getLocalizedName()); } @Override @@ -80,7 +80,7 @@ public class ItemFluidDrop extends Item { } public static FluidStack getFluidStack(ItemStack stack) { - if (stack == null|| stack.getItem() != ItemAndBlockHolder.DROP || !stack.hasTagCompound()) { + if (stack == null || stack.getItem() != ItemAndBlockHolder.DROP || !stack.hasTagCompound()) { return null; } NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound()); @@ -138,5 +138,4 @@ public class ItemFluidDrop extends Item { GameRegistry.registerItem(this, NameConst.ITEM_FLUID_DROP, FluidCraft.MODID); return this; } - } diff --git a/src/main/java/com/glodblock/github/common/item/ItemFluidEncodedPattern.java b/src/main/java/com/glodblock/github/common/item/ItemFluidEncodedPattern.java index b545bf31..b917874e 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemFluidEncodedPattern.java +++ b/src/main/java/com/glodblock/github/common/item/ItemFluidEncodedPattern.java @@ -1,18 +1,16 @@ package com.glodblock.github.common.item; import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.core.localization.GuiText; import appeng.items.misc.ItemEncodedPattern; import com.glodblock.github.FluidCraft; import com.glodblock.github.util.FluidPatternDetails; import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import java.util.List; public class ItemFluidEncodedPattern extends ItemEncodedPattern { @@ -32,19 +30,24 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern { GameRegistry.registerItem(this, NameConst.ITEM_FLUID_ENCODED_PATTERN, FluidCraft.MODID); return this; } + @Override - public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List lines, final boolean displayMoreInfo ) - { + public void addCheckedInformation( + final ItemStack stack, final EntityPlayer player, final List lines, final boolean displayMoreInfo) { NBTTagCompound data = stack.getTagCompound(); final boolean combine = data.getBoolean("combine"); final boolean prio = data.getBoolean("prioritize"); - super.addCheckedInformation(stack,player,lines,displayMoreInfo); -// lines.add(String.format("%s: %s",combine ? StatCollector.translateToLocal(NameConst.TT_KEY+"combine"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_combine"),combine ? GuiText.Yes.getLocal() : GuiText.No.getLocal())); -// lines.add(String.format("%s: %s",prio ? StatCollector.translateToLocal(NameConst.TT_KEY+"prio"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_prio"),prio ? GuiText.Yes.getLocal() : GuiText.No.getLocal())); + super.addCheckedInformation(stack, player, lines, displayMoreInfo); + // lines.add(String.format("%s: %s",combine ? + // StatCollector.translateToLocal(NameConst.TT_KEY+"combine"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_combine"),combine ? GuiText.Yes.getLocal() : GuiText.No.getLocal())); + // lines.add(String.format("%s: %s",prio ? + // StatCollector.translateToLocal(NameConst.TT_KEY+"prio"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_prio"),prio ? GuiText.Yes.getLocal() : GuiText.No.getLocal())); } + public ItemStack stack() { return new ItemStack(this, 1); } + public ItemStack stack(int size) { return new ItemStack(this, size); } diff --git a/src/main/java/com/glodblock/github/common/item/ItemFluidExportBus.java b/src/main/java/com/glodblock/github/common/item/ItemFluidExportBus.java index 0b96820c..a1da93d8 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemFluidExportBus.java +++ b/src/main/java/com/glodblock/github/common/item/ItemFluidExportBus.java @@ -10,14 +10,13 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import javax.annotation.Nullable; - public class ItemFluidExportBus extends Item implements IPartItem { public ItemFluidExportBus() { @@ -33,7 +32,17 @@ public class ItemFluidExportBus extends Item implements IPartItem { } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world); } @@ -45,8 +54,7 @@ public class ItemFluidExportBus extends Item implements IPartItem { } @Override - public void registerIcons(IIconRegister _iconRegister) { - } + public void registerIcons(IIconRegister _iconRegister) {} @Override @SideOnly(Side.CLIENT) @@ -61,6 +69,4 @@ public class ItemFluidExportBus extends Item implements IPartItem { public ItemStack stack() { return new ItemStack(this, 1); } - } - diff --git a/src/main/java/com/glodblock/github/common/item/ItemFluidImportBus.java b/src/main/java/com/glodblock/github/common/item/ItemFluidImportBus.java index 77a69b75..a85fdd9e 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemFluidImportBus.java +++ b/src/main/java/com/glodblock/github/common/item/ItemFluidImportBus.java @@ -10,14 +10,13 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import javax.annotation.Nullable; - public class ItemFluidImportBus extends Item implements IPartItem { public ItemFluidImportBus() { @@ -33,7 +32,17 @@ public class ItemFluidImportBus extends Item implements IPartItem { } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world); } @@ -45,8 +54,7 @@ public class ItemFluidImportBus extends Item implements IPartItem { } @Override - public void registerIcons(IIconRegister _iconRegister) { - } + public void registerIcons(IIconRegister _iconRegister) {} @Override @SideOnly(Side.CLIENT) @@ -61,5 +69,4 @@ public class ItemFluidImportBus extends Item implements IPartItem { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/item/ItemFluidPacket.java b/src/main/java/com/glodblock/github/common/item/ItemFluidPacket.java index 7cd67416..3e3f5634 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemFluidPacket.java +++ b/src/main/java/com/glodblock/github/common/item/ItemFluidPacket.java @@ -8,6 +8,9 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -20,10 +23,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import javax.annotation.Nullable; -import java.util.List; -import java.util.Objects; - public class ItemFluidPacket extends Item { public ItemFluidPacket() { @@ -38,8 +37,9 @@ public class ItemFluidPacket extends Item { if (display) { return fluid != null ? fluid.getLocalizedName() : super.getItemStackDisplayName(stack); } - return fluid != null ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount) - : super.getItemStackDisplayName(stack); + return fluid != null + ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount) + : super.getItemStackDisplayName(stack); } @Override @@ -49,7 +49,8 @@ public class ItemFluidPacket extends Item { boolean display = isDisplay(stack); if (display) return; if (fluid != null) { - for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET).split("\\\\n")) { + for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET) + .split("\\\\n")) { tooltip.add(EnumChatFormatting.GRAY + line); } } else { @@ -68,7 +69,8 @@ public class ItemFluidPacket extends Item { if (stack == null || !stack.hasTagCompound()) { return null; } - FluidStack fluid = FluidStack.loadFluidStackFromNBT(Objects.requireNonNull(stack.getTagCompound()).getCompoundTag("FluidStack")); + FluidStack fluid = FluidStack.loadFluidStackFromNBT( + Objects.requireNonNull(stack.getTagCompound()).getCompoundTag("FluidStack")); return (fluid != null && fluid.amount > 0) ? fluid : null; } @@ -117,8 +119,7 @@ public class ItemFluidPacket extends Item { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aIconRegister) { - } + public void registerIcons(IIconRegister aIconRegister) {} @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int p_77617_1_) { diff --git a/src/main/java/com/glodblock/github/common/item/ItemPartFluidInterface.java b/src/main/java/com/glodblock/github/common/item/ItemPartFluidInterface.java index cb837030..fe9e3723 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemPartFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/item/ItemPartFluidInterface.java @@ -9,14 +9,13 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import javax.annotation.Nullable; - public class ItemPartFluidInterface extends Item implements IPartItem { public ItemPartFluidInterface() { @@ -32,7 +31,17 @@ public class ItemPartFluidInterface extends Item implements IPartItem { } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world); } @@ -43,8 +52,7 @@ public class ItemPartFluidInterface extends Item implements IPartItem { } @Override - public void registerIcons(IIconRegister _iconRegister) { - } + public void registerIcons(IIconRegister _iconRegister) {} @Override @SideOnly(Side.CLIENT) @@ -59,5 +67,4 @@ public class ItemPartFluidInterface extends Item implements IPartItem { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminal.java b/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminal.java index 3b2e3a5f..4b0484bf 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminal.java @@ -9,14 +9,13 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import javax.annotation.Nullable; - public class ItemPartFluidPatternTerminal extends Item implements IPartItem { public ItemPartFluidPatternTerminal() { @@ -32,7 +31,17 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem { } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world); } @@ -43,8 +52,7 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem { } @Override - public void registerIcons(IIconRegister _iconRegister) { - } + public void registerIcons(IIconRegister _iconRegister) {} @Override @SideOnly(Side.CLIENT) @@ -59,5 +67,4 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminalEx.java index 7260744d..a6ecf940 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/common/item/ItemPartFluidPatternTerminalEx.java @@ -9,14 +9,13 @@ import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import javax.annotation.Nullable; - public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem { public ItemPartFluidPatternTerminalEx() { @@ -32,7 +31,17 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem { } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float xOffset, + float yOffset, + float zOffset) { return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world); } @@ -43,8 +52,7 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem { } @Override - public void registerIcons(IIconRegister _iconRegister) { - } + public void registerIcons(IIconRegister _iconRegister) {} @Override @SideOnly(Side.CLIENT) @@ -59,5 +67,4 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem { public ItemStack stack() { return new ItemStack(this, 1); } - } diff --git a/src/main/java/com/glodblock/github/common/parts/FCBasePart.java b/src/main/java/com/glodblock/github/common/parts/FCBasePart.java index 671412d2..71773450 100644 --- a/src/main/java/com/glodblock/github/common/parts/FCBasePart.java +++ b/src/main/java/com/glodblock/github/common/parts/FCBasePart.java @@ -31,6 +31,8 @@ import com.glodblock.github.client.textures.FCPartsTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; +import java.io.IOException; +import java.util.List; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.player.EntityPlayer; @@ -43,10 +45,8 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; -import java.io.IOException; -import java.util.List; - -public abstract class FCBasePart extends AEBasePart implements IPowerChannelState, ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory { +public abstract class FCBasePart extends AEBasePart + implements IPowerChannelState, ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory { protected static final int POWERED_FLAG = 4; protected static final int CHANNEL_FLAG = 16; @@ -56,172 +56,140 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat private int clientFlags = 0; // sent as byte. private float opacity = -1; - private final IConfigManager cm = new ConfigManager( this ); - private final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 ); + private final IConfigManager cm = new ConfigManager(this); + private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5); - public FCBasePart( final ItemStack is ) - { - this( is, false ); + public FCBasePart(final ItemStack is) { + this(is, false); } - protected FCBasePart( final ItemStack is, final boolean requireChannel ) - { - super( is ); + protected FCBasePart(final ItemStack is, final boolean requireChannel) { + super(is); - if( requireChannel ) - { - this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL ); - this.getProxy().setIdlePowerUsage( 1.0 / 2.0 ); + if (requireChannel) { + this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + this.getProxy().setIdlePowerUsage(1.0 / 2.0); + } else { + this.getProxy().setIdlePowerUsage(1.0 / 16.0); // lights drain a little bit. } - else - { - this.getProxy().setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit. - } - this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME ); - this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); - this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING ); + this.cm.registerSetting(Settings.SORT_BY, SortOrder.NAME); + this.cm.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); + this.cm.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING); } @MENetworkEventSubscribe - public final void bootingRender( final MENetworkBootingStatusChange c ) - { - if( !this.isLightSource() ) - { + public final void bootingRender(final MENetworkBootingStatusChange c) { + if (!this.isLightSource()) { this.getHost().markForUpdate(); } } @MENetworkEventSubscribe - public final void powerRender( final MENetworkPowerStatusChange c ) - { + public final void powerRender(final MENetworkPowerStatusChange c) { this.getHost().markForUpdate(); } @Override - public final void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 2, 2, 14, 14, 14, 16 ); - bch.addBox( 4, 4, 13, 12, 12, 14 ); + public final void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(2, 2, 14, 14, 14, 16); + bch.addBox(4, 4, 13, 12, 12, 14); } @Override - public void onNeighborChanged() - { + public void onNeighborChanged() { this.opacity = -1; this.getHost().markForUpdate(); } @Override - public void getDrops(final List drops, final boolean wrenched ) - { - super.getDrops( drops, wrenched ); + public void getDrops(final List drops, final boolean wrenched) { + super.getDrops(drops, wrenched); - for( final ItemStack is : this.viewCell ) - { - if( is != null ) - { - drops.add( is ); + for (final ItemStack is : this.viewCell) { + if (is != null) { + drops.add(is); } } } @Override - public IConfigManager getConfigManager() - { + public IConfigManager getConfigManager() { return this.cm; } @Override - public void readFromNBT( final NBTTagCompound data ) - { - super.readFromNBT( data ); - if( data.hasKey( "opacity" ) ) - { - this.opacity = data.getFloat( "opacity" ); + public void readFromNBT(final NBTTagCompound data) { + super.readFromNBT(data); + if (data.hasKey("opacity")) { + this.opacity = data.getFloat("opacity"); } - this.spin = data.getByte( "spin" ); - this.cm.readFromNBT( data ); - this.viewCell.readFromNBT( data, "viewCell" ); + this.spin = data.getByte("spin"); + this.cm.readFromNBT(data); + this.viewCell.readFromNBT(data, "viewCell"); } @Override - public void writeToNBT( final NBTTagCompound data ) - { - super.writeToNBT( data ); - data.setFloat( "opacity", this.opacity ); - data.setByte( "spin", this.getSpin() ); - this.cm.writeToNBT( data ); - this.viewCell.writeToNBT( data, "viewCell" ); + public void writeToNBT(final NBTTagCompound data) { + super.writeToNBT(data); + data.setFloat("opacity", this.opacity); + data.setByte("spin", this.getSpin()); + this.cm.writeToNBT(data); + this.viewCell.writeToNBT(data, "viewCell"); } - public GuiBridge getGui(final EntityPlayer player ) - { + public GuiBridge getGui(final EntityPlayer player) { return GuiBridge.GUI_ME; } - @Override - public void writeToStream( final ByteBuf data ) throws IOException - { - super.writeToStream( data ); + public void writeToStream(final ByteBuf data) throws IOException { + super.writeToStream(data); this.clientFlags = this.getSpin() & 3; - try - { - if( this.getProxy().getEnergy().isNetworkPowered() ) - { + try { + if (this.getProxy().getEnergy().isNetworkPowered()) { this.clientFlags = this.getClientFlags() | FCBasePart.POWERED_FLAG; } - if( this.getProxy().getPath().isNetworkBooting() ) - { + if (this.getProxy().getPath().isNetworkBooting()) { this.clientFlags = this.getClientFlags() | FCBasePart.BOOTING_FLAG; } - if( this.getProxy().getNode().meetsChannelRequirements() ) - { + if (this.getProxy().getNode().meetsChannelRequirements()) { this.clientFlags = this.getClientFlags() | FCBasePart.CHANNEL_FLAG; } - } - catch( final GridAccessException e ) - { + } catch (final GridAccessException e) { // um.. nothing. } - data.writeByte( (byte) this.getClientFlags() ); + data.writeByte((byte) this.getClientFlags()); } @Override - public boolean readFromStream( final ByteBuf data ) throws IOException - { - super.readFromStream( data ); + public boolean readFromStream(final ByteBuf data) throws IOException { + super.readFromStream(data); final int oldFlags = this.getClientFlags(); this.clientFlags = data.readByte(); - this.spin = (byte) ( this.getClientFlags() & 3 ); + this.spin = (byte) (this.getClientFlags() & 3); return this.getClientFlags() != oldFlags; } @Override - public final int getLightLevel() - { - return this.blockLight( this.isPowered() ? ( this.isLightSource() ? 15 : 9 ) : 0 ); + public final int getLightLevel() { + return this.blockLight(this.isPowered() ? (this.isLightSource() ? 15 : 9) : 0); } - public boolean onPartActivate0(final EntityPlayer player, final Vec3 pos ) - { + public boolean onPartActivate0(final EntityPlayer player, final Vec3 pos) { final TileEntity te = this.getTile(); - if( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord ) ) - { - if( Platform.isServer() ) - { - if( this.getSpin() > 3 ) - { + if (!player.isSneaking() + && Platform.isWrench(player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord)) { + if (Platform.isServer()) { + if (this.getSpin() > 3) { this.spin = 0; } - switch( this.getSpin() ) - { + switch (this.getSpin()) { case 0: this.spin = 1; break; @@ -240,26 +208,20 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat this.saveChanges(); } return true; - } - else - { - return super.onPartActivate( player, pos ); + } else { + return super.onPartActivate(player, pos); } } @Override - public boolean onPartActivate( final EntityPlayer player, final Vec3 pos ) - { - if( !onPartActivate0( player, pos ) ) - { - if( !player.isSneaking() ) - { - if( Platform.isClient() ) - { + public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) { + if (!onPartActivate0(player, pos)) { + if (!player.isSneaking()) { + if (Platform.isClient()) { return true; } - Platform.openGUI( player, this.getHost().getTile(), this.getSide(), this.getGui( player ) ); + Platform.openGUI(player, this.getHost().getTile(), this.getSide(), this.getGui(player)); return true; } @@ -268,213 +230,206 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat } @Override - public final void onPlacement( final EntityPlayer player, final ItemStack held, final ForgeDirection side ) - { - super.onPlacement( player, held, side ); + public final void onPlacement(final EntityPlayer player, final ItemStack held, final ForgeDirection side) { + super.onPlacement(player, held, side); - final byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 ); - if( side == ForgeDirection.UP ) - { + final byte rotation = (byte) (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 2.5D) & 3); + if (side == ForgeDirection.UP) { this.spin = rotation; - } - else if( side == ForgeDirection.DOWN ) - { + } else if (side == ForgeDirection.DOWN) { this.spin = rotation; } } - private int blockLight(final int emit ) - { - if( this.opacity < 0 ) - { + private int blockLight(final int emit) { + if (this.opacity < 0) { final TileEntity te = this.getTile(); - this.opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + this.getSide().offsetX, te.yCoord + this.getSide().offsetY, te.zCoord + this.getSide().offsetZ ); + this.opacity = 255 + - te.getWorldObj() + .getBlockLightOpacity( + te.xCoord + this.getSide().offsetX, + te.yCoord + this.getSide().offsetY, + te.zCoord + this.getSide().offsetZ); } - return (int) ( emit * ( this.opacity / 255.0f ) ); + return (int) (emit * (this.opacity / 255.0f)); } @Override - public final boolean isPowered() - { - try - { - if( Platform.isServer() ) - { + public final boolean isPowered() { + try { + if (Platform.isServer()) { return this.getProxy().getEnergy().isNetworkPowered(); + } else { + return ((this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG); } - else - { - return ( ( this.getClientFlags() & FCBasePart.POWERED_FLAG ) == FCBasePart.POWERED_FLAG ); - } - } - catch( final GridAccessException e ) - { + } catch (final GridAccessException e) { return false; } } @Override - public IMEMonitor getItemInventory() - { - try - { + public IMEMonitor getItemInventory() { + try { return this.getProxy().getStorage().getItemInventory(); - } - catch( final GridAccessException e ) - { + } catch (final GridAccessException e) { // err nope? } return null; } @Override - public IMEMonitor getFluidInventory() - { - try - { + public IMEMonitor getFluidInventory() { + try { return this.getProxy().getStorage().getFluidInventory(); - } - catch( final GridAccessException e ) - { + } catch (final GridAccessException e) { // err nope? } return null; } @Override - public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue ) - { - - } + public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {} @Override - public IInventory getViewCellStorage() - { + public IInventory getViewCellStorage() { return this.viewCell; } @Override - public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { + public void onChangeInventory( + final IInventory inv, + final int slot, + final InvOperation mc, + final ItemStack removedStack, + final ItemStack newStack) { this.getHost().markForSave(); } @Override - public final boolean isActive() - { - if( !this.isLightSource() ) - { - return ( ( this.getClientFlags() & ( FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG ) ) == ( FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG ) ); - } - else - { + public final boolean isActive() { + if (!this.isLightSource()) { + return ((this.getClientFlags() & (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG)) + == (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG)); + } else { return this.isPowered(); } } - public final int getClientFlags() - { + public final int getClientFlags() { return this.clientFlags; } - public final byte getSpin() - { + public final byte getSpin() { return this.spin; } @Override - @SideOnly( Side.CLIENT ) - public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer ) - { - rh.setBounds( 2, 2, 14, 14, 14, 16 ); + @SideOnly(Side.CLIENT) + public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) { + rh.setBounds(2, 2, 14, 14, 14, 16); final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon(); final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon(); - rh.setTexture( sideTexture, sideTexture, backTexture, FCPartsTexture.PartTerminalBroad.getIcon(), sideTexture, sideTexture ); - rh.renderInventoryBox( renderer ); + rh.setTexture( + sideTexture, + sideTexture, + backTexture, + FCPartsTexture.PartTerminalBroad.getIcon(), + sideTexture, + sideTexture); + rh.renderInventoryBox(renderer); - rh.setInvColor( this.getColor().whiteVariant ); - rh.renderInventoryFace( this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer ); + rh.setInvColor(this.getColor().whiteVariant); + rh.renderInventoryFace(this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer); - rh.setInvColor( this.getColor().mediumVariant ); - rh.renderInventoryFace( this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer ); + rh.setInvColor(this.getColor().mediumVariant); + rh.renderInventoryFace(this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer); - rh.setInvColor( this.getColor().blackVariant ); - rh.renderInventoryFace( this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer ); + rh.setInvColor(this.getColor().blackVariant); + rh.renderInventoryFace(this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer); - rh.setBounds( 4, 4, 13, 12, 12, 14 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(4, 4, 13, 12, 12, 14); + rh.renderInventoryBox(renderer); } @Override - @SideOnly( Side.CLIENT ) - public void renderStatic( final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer ) - { - this.setRenderCache( rh.useSimplifiedRendering( x, y, z, this, this.getRenderCache() ) ); + @SideOnly(Side.CLIENT) + public void renderStatic( + final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer) { + this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache())); final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon(); final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon(); - rh.setTexture( sideTexture, sideTexture, backTexture, FCPartsTexture.PartTerminalBroad.getIcon(), sideTexture, sideTexture ); + rh.setTexture( + sideTexture, + sideTexture, + backTexture, + FCPartsTexture.PartTerminalBroad.getIcon(), + sideTexture, + sideTexture); - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(2, 2, 14, 14, 14, 16); + rh.renderBlock(x, y, z, renderer); - if( this.getLightLevel() > 0 ) - { + if (this.getLightLevel() > 0) { final int l = 13; - Tessellator.instance.setBrightness( l << 20 | l << 4 ); + Tessellator.instance.setBrightness(l << 20 | l << 4); } - renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.getSpin(); + renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = + renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.getSpin(); - Tessellator.instance.setColorOpaque_I( this.getColor().whiteVariant ); - rh.renderFace( x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer ); + Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant); + rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer); - Tessellator.instance.setColorOpaque_I( this.getColor().mediumVariant ); - rh.renderFace( x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer ); + Tessellator.instance.setColorOpaque_I(this.getColor().mediumVariant); + rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer); - Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant ); - rh.renderFace( x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer ); + Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant); + rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer); - renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; + renderer.uvRotateBottom = renderer.uvRotateEast = + renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; final IIcon sideStatusTexture = CableBusTextures.PartMonitorSidesStatus.getIcon(); - rh.setTexture( sideStatusTexture, sideStatusTexture, backTexture, this.getItemStack().getIconIndex(), sideStatusTexture, sideStatusTexture ); + rh.setTexture( + sideStatusTexture, + sideStatusTexture, + backTexture, + this.getItemStack().getIconIndex(), + sideStatusTexture, + sideStatusTexture); - rh.setBounds( 4, 4, 13, 12, 12, 14 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(4, 4, 13, 12, 12, 14); + rh.renderBlock(x, y, z, renderer); - final boolean hasChan = ( this.getClientFlags() & ( FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG ) ) == ( FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG ); - final boolean hasPower = ( this.getClientFlags() & FCBasePart.POWERED_FLAG ) == FCBasePart.POWERED_FLAG; + final boolean hasChan = (this.getClientFlags() & (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG)) + == (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG); + final boolean hasPower = (this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG; - if( hasChan ) - { + if (hasChan) { final int l = 14; - Tessellator.instance.setBrightness( l << 20 | l << 4 ); - Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant ); - } - else if( hasPower ) - { + Tessellator.instance.setBrightness(l << 20 | l << 4); + Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant); + } else if (hasPower) { final int l = 9; - Tessellator.instance.setBrightness( l << 20 | l << 4 ); - Tessellator.instance.setColorOpaque_I( this.getColor().whiteVariant ); - } - else - { - Tessellator.instance.setBrightness( 0 ); - Tessellator.instance.setColorOpaque_I( 0x000000 ); + Tessellator.instance.setBrightness(l << 20 | l << 4); + Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant); + } else { + Tessellator.instance.setBrightness(0); + Tessellator.instance.setColorOpaque_I(0x000000); } final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon(); - rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.EAST, renderer ); - rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.WEST, renderer ); - rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.UP, renderer ); - rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.DOWN, renderer ); + rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.EAST, renderer); + rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.WEST, renderer); + rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.UP, renderer); + rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.DOWN, renderer); } /** @@ -503,5 +458,4 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat * light source 9. */ public abstract boolean isLightSource(); - } diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidExportBus.java b/src/main/java/com/glodblock/github/common/parts/PartFluidExportBus.java index 953a0055..59ca57d8 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidExportBus.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidExportBus.java @@ -27,14 +27,13 @@ public class PartFluidExportBus extends PartSharedFluidBus { private final BaseActionSource source; - public PartFluidExportBus( ItemStack is ) - { - super( is ); - this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO ); - this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT ); - this.source = new MachineSource( this ); + public PartFluidExportBus(ItemStack is) { + super(is); + this.getConfigManager().registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE); + this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL); + this.getConfigManager().registerSetting(Settings.CRAFT_ONLY, YesNo.NO); + this.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT); + this.source = new MachineSource(this); } @Override @@ -43,59 +42,50 @@ public class PartFluidExportBus extends PartSharedFluidBus { } @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return new TickingRequest( 5, 40, this.isSleeping(), false ); + public TickingRequest getTickingRequest(IGridNode node) { + return new TickingRequest(5, 40, this.isSleeping(), false); } @Override - public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall ) - { + public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) { return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE; } @Override - protected boolean canDoBusWork() - { + protected boolean canDoBusWork() { return this.getProxy().isActive(); } @Override - protected TickRateModulation doBusWork() - { - if( !this.canDoBusWork() ) - { + protected TickRateModulation doBusWork() { + if (!this.canDoBusWork()) { return TickRateModulation.IDLE; } final TileEntity te = this.getConnectedTE(); - if(te instanceof IFluidHandler) - { - try - { + if (te instanceof IFluidHandler) { + try { final IFluidHandler fh = (IFluidHandler) te; - final IMEMonitor inv = this.getProxy().getStorage().getFluidInventory(); + final IMEMonitor inv = + this.getProxy().getStorage().getFluidInventory(); - for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ ) - { - IAEFluidStack fluid = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i))); - if( fluid != null ) - { + for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) { + IAEFluidStack fluid = AEFluidStack.create(ItemFluidPacket.getFluidStack( + this.getInventoryByName("config").getStackInSlot(i))); + if (fluid != null) { final IAEFluidStack toExtract = fluid.copy(); - toExtract.setStackSize( this.calculateAmountToSend() ); + toExtract.setStackSize(this.calculateAmountToSend()); - final IAEFluidStack out = inv.extractItems( toExtract, Actionable.SIMULATE, this.source ); + final IAEFluidStack out = inv.extractItems(toExtract, Actionable.SIMULATE, this.source); - if( out != null ) - { - int wasInserted = fh.fill( this.getSide().getOpposite(), out.getFluidStack(), true ); + if (out != null) { + int wasInserted = fh.fill(this.getSide().getOpposite(), out.getFluidStack(), true); - if( wasInserted > 0 ) - { - toExtract.setStackSize( wasInserted ); - inv.extractItems( toExtract, Actionable.MODULATE, this.source ); + if (wasInserted > 0) { + toExtract.setStackSize(wasInserted); + inv.extractItems(toExtract, Actionable.MODULATE, this.source); return TickRateModulation.FASTER; } @@ -104,9 +94,7 @@ public class PartFluidExportBus extends PartSharedFluidBus { } return TickRateModulation.SLOWER; - } - catch( GridAccessException e ) - { + } catch (GridAccessException e) { // Ignore } } @@ -115,58 +103,72 @@ public class PartFluidExportBus extends PartSharedFluidBus { } @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 4, 4, 12, 12, 12, 14 ); - bch.addBox( 5, 5, 14, 11, 11, 15 ); - bch.addBox( 6, 6, 15, 10, 10, 16 ); - bch.addBox( 6, 6, 11, 10, 10, 12 ); + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(4, 4, 12, 12, 12, 14); + bch.addBox(5, 5, 14, 11, 11, 15); + bch.addBox(6, 6, 15, 10, 10, 16); + bch.addBox(6, 6, 11, 10, 10, 12); } @Override - @SideOnly( Side.CLIENT ) - public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer ) - { - rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() ); + @SideOnly(Side.CLIENT) + public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) { + rh.setTexture( + CableBusTextures.PartExportSides.getIcon(), + CableBusTextures.PartExportSides.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + this.getFaceIcon(), + CableBusTextures.PartExportSides.getIcon(), + CableBusTextures.PartExportSides.getIcon()); - rh.setBounds( 4, 4, 12, 12, 12, 14 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(4, 4, 12, 12, 12, 14); + rh.renderInventoryBox(renderer); - rh.setBounds( 5, 5, 14, 11, 11, 15 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(5, 5, 14, 11, 11, 15); + rh.renderInventoryBox(renderer); - rh.setBounds( 6, 6, 15, 10, 10, 16 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(6, 6, 15, 10, 10, 16); + rh.renderInventoryBox(renderer); } @Override - @SideOnly( Side.CLIENT ) - public void renderStatic( final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer ) - { - this.setRenderCache( rh.useSimplifiedRendering( x, y, z, this, this.getRenderCache() ) ); - rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() ); + @SideOnly(Side.CLIENT) + public void renderStatic( + final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer) { + this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache())); + rh.setTexture( + CableBusTextures.PartExportSides.getIcon(), + CableBusTextures.PartExportSides.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + this.getFaceIcon(), + CableBusTextures.PartExportSides.getIcon(), + CableBusTextures.PartExportSides.getIcon()); - rh.setBounds( 4, 4, 12, 12, 12, 14 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(4, 4, 12, 12, 12, 14); + rh.renderBlock(x, y, z, renderer); - rh.setBounds( 5, 5, 14, 11, 11, 15 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(5, 5, 14, 11, 11, 15); + rh.renderBlock(x, y, z, renderer); - rh.setBounds( 6, 6, 15, 10, 10, 16 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(6, 6, 15, 10, 10, 16); + rh.renderBlock(x, y, z, renderer); - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + rh.setTexture( + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + this.getFaceIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon()); - rh.setBounds( 6, 6, 11, 10, 10, 12 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(6, 6, 11, 10, 10, 12); + rh.renderBlock(x, y, z, renderer); - this.renderLights( x, y, z, rh, renderer ); + this.renderLights(x, y, z, rh, renderer); } @Override - public RedstoneMode getRSMode() - { - return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); + public RedstoneMode getRSMode() { + return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED); } - } diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java b/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java index 6cce7267..08b1201a 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java @@ -28,14 +28,13 @@ public class PartFluidImportBus extends PartSharedFluidBus { private final BaseActionSource source; - public PartFluidImportBus( ItemStack is ) - { - super( is ); - this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO ); - this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT ); - this.source = new MachineSource( this ); + public PartFluidImportBus(ItemStack is) { + super(is); + this.getConfigManager().registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE); + this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL); + this.getConfigManager().registerSetting(Settings.CRAFT_ONLY, YesNo.NO); + this.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT); + this.source = new MachineSource(this); } @Override @@ -44,61 +43,52 @@ public class PartFluidImportBus extends PartSharedFluidBus { } @Override - public TickingRequest getTickingRequest( IGridNode node ) - { - return new TickingRequest( 5, 40, this.isSleeping(), false ); + public TickingRequest getTickingRequest(IGridNode node) { + return new TickingRequest(5, 40, this.isSleeping(), false); } @Override - public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall ) - { + public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) { return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE; } @Override - protected TickRateModulation doBusWork() - { - if( !this.canDoBusWork() ) - { + protected TickRateModulation doBusWork() { + if (!this.canDoBusWork()) { return TickRateModulation.IDLE; } final TileEntity te = this.getConnectedTE(); - if(te instanceof IFluidHandler) - { - try - { + if (te instanceof IFluidHandler) { + try { final IFluidHandler fh = (IFluidHandler) te; - final IMEMonitor inv = this.getProxy().getStorage().getFluidInventory(); + final IMEMonitor inv = + this.getProxy().getStorage().getFluidInventory(); - final FluidStack fluidStack = fh.drain( this.getSide().getOpposite(), this.calculateAmountToSend(), false ); + final FluidStack fluidStack = + fh.drain(this.getSide().getOpposite(), this.calculateAmountToSend(), false); - if( this.filterEnabled() && !this.isInFilter( fluidStack ) ) - { + if (this.filterEnabled() && !this.isInFilter(fluidStack)) { return TickRateModulation.SLOWER; } - final AEFluidStack aeFluidStack = AEFluidStack.create( fluidStack ); + final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack); - if( aeFluidStack != null ) - { - final IAEFluidStack notInserted = inv.injectItems( aeFluidStack, Actionable.MODULATE, this.source ); + if (aeFluidStack != null) { + final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE, this.source); - if( notInserted != null && notInserted.getStackSize() > 0 ) - { - aeFluidStack.decStackSize( notInserted.getStackSize() ); + if (notInserted != null && notInserted.getStackSize() > 0) { + aeFluidStack.decStackSize(notInserted.getStackSize()); } - fh.drain( this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true ); + fh.drain(this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true); return TickRateModulation.FASTER; } return TickRateModulation.IDLE; - } - catch(GridAccessException e ) - { + } catch (GridAccessException e) { e.printStackTrace(); } } @@ -107,31 +97,26 @@ public class PartFluidImportBus extends PartSharedFluidBus { } @Override - protected boolean canDoBusWork() - { + protected boolean canDoBusWork() { return this.getProxy().isActive(); } - private boolean isInFilter( FluidStack fluid ) - { - for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ ) - { - final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i))); - if( stack != null && stack.getFluidStack().equals( fluid ) ) - { + private boolean isInFilter(FluidStack fluid) { + for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) { + final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack( + this.getInventoryByName("config").getStackInSlot(i))); + if (stack != null && stack.getFluidStack().equals(fluid)) { return true; } } return false; } - private boolean filterEnabled() - { - for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ ) - { - final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i))); - if( stack != null ) - { + private boolean filterEnabled() { + for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) { + final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack( + this.getInventoryByName("config").getStackInSlot(i))); + if (stack != null) { return true; } } @@ -139,56 +124,70 @@ public class PartFluidImportBus extends PartSharedFluidBus { } @Override - public RedstoneMode getRSMode() - { - return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); + public RedstoneMode getRSMode() { + return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED); } @Override - public void getBoxes( final IPartCollisionHelper bch ) - { - bch.addBox( 6, 6, 11, 10, 10, 13 ); - bch.addBox( 5, 5, 13, 11, 11, 14 ); - bch.addBox( 4, 4, 14, 12, 12, 16 ); + public void getBoxes(final IPartCollisionHelper bch) { + bch.addBox(6, 6, 11, 10, 10, 13); + bch.addBox(5, 5, 13, 11, 11, 14); + bch.addBox(4, 4, 14, 12, 12, 16); } @Override - @SideOnly( Side.CLIENT ) - public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer ) - { - rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() ); + @SideOnly(Side.CLIENT) + public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) { + rh.setTexture( + CableBusTextures.PartImportSides.getIcon(), + CableBusTextures.PartImportSides.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + this.getFaceIcon(), + CableBusTextures.PartImportSides.getIcon(), + CableBusTextures.PartImportSides.getIcon()); - rh.setBounds( 3, 3, 15, 13, 13, 16 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(3, 3, 15, 13, 13, 16); + rh.renderInventoryBox(renderer); - rh.setBounds( 4, 4, 14, 12, 12, 15 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(4, 4, 14, 12, 12, 15); + rh.renderInventoryBox(renderer); - rh.setBounds( 5, 5, 13, 11, 11, 14 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(5, 5, 13, 11, 11, 14); + rh.renderInventoryBox(renderer); } @Override - @SideOnly( Side.CLIENT ) - public void renderStatic( final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer ) - { - this.setRenderCache( rh.useSimplifiedRendering( x, y, z, this, this.getRenderCache() ) ); - rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() ); + @SideOnly(Side.CLIENT) + public void renderStatic( + final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer) { + this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache())); + rh.setTexture( + CableBusTextures.PartImportSides.getIcon(), + CableBusTextures.PartImportSides.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + this.getFaceIcon(), + CableBusTextures.PartImportSides.getIcon(), + CableBusTextures.PartImportSides.getIcon()); - rh.setBounds( 4, 4, 14, 12, 12, 16 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(4, 4, 14, 12, 12, 16); + rh.renderBlock(x, y, z, renderer); - rh.setBounds( 5, 5, 13, 11, 11, 14 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(5, 5, 13, 11, 11, 14); + rh.renderBlock(x, y, z, renderer); - rh.setBounds( 6, 6, 12, 10, 10, 13 ); - rh.renderBlock( x, y, z, renderer ); - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + rh.setBounds(6, 6, 12, 10, 10, 13); + rh.renderBlock(x, y, z, renderer); + rh.setTexture( + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + this.getFaceIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon()); - rh.setBounds( 6, 6, 11, 10, 10, 12 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(6, 6, 11, 10, 10, 12); + rh.renderBlock(x, y, z, renderer); - this.renderLights( x, y, z, rh, renderer ); + this.renderLights(x, y, z, rh, renderer); } - } diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidInterface.java b/src/main/java/com/glodblock/github/common/parts/PartFluidInterface.java index c4461687..ec969577 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidInterface.java @@ -35,6 +35,8 @@ import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; +import java.io.IOException; +import java.util.Objects; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -46,13 +48,10 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import java.io.IOException; -import java.util.Objects; - public class PartFluidInterface extends PartInterface implements IFluidHandler, IAEFluidInventory { private final BaseActionSource ownActionSource = new MachineSource(this); - private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 6 ); + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6); private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this); public PartFluidInterface(ItemStack is) { @@ -60,42 +59,65 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, } @Override - @SideOnly( Side.CLIENT ) - public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer ) - { - this.setRenderCache( rh.useSimplifiedRendering( x, y, z, this, this.getRenderCache() ) ); - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + @SideOnly(Side.CLIENT) + public void renderStatic( + final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer) { + this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache())); + rh.setTexture( + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + FCPartsTexture.BlockInterface_Face.getIcon(), + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorSides.getIcon()); - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(2, 2, 14, 14, 14, 16); + rh.renderBlock(x, y, z, renderer); - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + rh.setTexture( + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + FCPartsTexture.BlockInterface_Face.getIcon(), + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorSides.getIcon()); - rh.setBounds( 5, 5, 12, 11, 11, 13 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(5, 5, 12, 11, 11, 13); + rh.renderBlock(x, y, z, renderer); - rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); + rh.setTexture( + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + FCPartsTexture.BlockInterface_Face.getIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon(), + CableBusTextures.PartMonitorSidesStatus.getIcon()); - rh.setBounds( 5, 5, 13, 11, 11, 14 ); - rh.renderBlock( x, y, z, renderer ); + rh.setBounds(5, 5, 13, 11, 11, 14); + rh.renderBlock(x, y, z, renderer); - this.renderLights( x, y, z, rh, renderer ); + this.renderLights(x, y, z, rh, renderer); } @Override - @SideOnly( Side.CLIENT ) - public void renderInventory( final IPartRenderHelper rh, final RenderBlocks renderer ) - { - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); + @SideOnly(Side.CLIENT) + public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) { + rh.setTexture( + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorBack.getIcon(), + FCPartsTexture.BlockInterface_Face.getIcon(), + CableBusTextures.PartMonitorSides.getIcon(), + CableBusTextures.PartMonitorSides.getIcon()); - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(2, 2, 14, 14, 14, 16); + rh.renderInventoryBox(renderer); - rh.setBounds( 5, 5, 12, 11, 11, 13 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(5, 5, 12, 11, 11, 13); + rh.renderInventoryBox(renderer); - rh.setBounds( 5, 5, 13, 11, 11, 14 ); - rh.renderInventoryBox( renderer ); + rh.setBounds(5, 5, 13, 11, 11, 14); + rh.renderInventoryBox(renderer); } @MENetworkEventSubscribe @@ -123,12 +145,11 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, } public AppEngInternalAEInventory getConfig() { - for (int i = 0; i < fluidDuality.getConfig().getSlots(); i ++) { + for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) { IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i); if (fluid == null) { config.setInventorySlotContents(i, null); - } - else { + } else { config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack())); } } @@ -140,7 +161,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, super.writeToStream(data); for (int i = 0; i < config.getSizeInventory(); i++) { ByteBufUtils.writeItemStack(data, config.getStackInSlot(i)); - for (int j = 0; j < config.getSizeInventory(); j ++) { + for (int j = 0; j < config.getSizeInventory(); j++) { FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j)); fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid)); } @@ -170,7 +191,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, config.setInventorySlotContents(i, stack); changed = true; } - for (int j = 0; j < config.getSizeInventory(); j ++) { + for (int j = 0; j < config.getSizeInventory(); j++) { FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j)); fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid)); } @@ -195,10 +216,10 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, } @Override - public void readFromNBT( NBTTagCompound data ) { - super.readFromNBT( data ); + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); config.readFromNBT(data, "ConfigInv"); - for (int i = 0; i < config.getSizeInventory(); i ++) { + for (int i = 0; i < config.getSizeInventory(); i++) { FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i)); fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid)); } @@ -206,21 +227,23 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, } @Override - public void writeToNBT( NBTTagCompound data ) { + public void writeToNBT(NBTTagCompound data) { super.writeToNBT(data); config.writeToNBT(data, "ConfigInv"); getInternalFluid().writeToNBT(data, "FluidInv"); } @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return getInterfaceDuality().getInstalledUpgrades( u ); + public int getInstalledUpgrades(final Upgrades u) { + return getInterfaceDuality().getInstalledUpgrades(u); } private IMEMonitor getFluidGrid() { try { - return getProxy().getGrid().getCache(IStorageGrid.class).getFluidInventory(); + return getProxy() + .getGrid() + .getCache(IStorageGrid.class) + .getFluidInventory(); } catch (GridAccessException e) { return null; } @@ -238,8 +261,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { IMEMonitor fluidGrid = getFluidGrid(); IEnergyGrid energyGrid = getEnergyGrid(); - if (energyGrid == null || fluidGrid == null || resource == null) - return 0; + if (energyGrid == null || fluidGrid == null || resource == null) return 0; int ori = resource.amount; IAEFluidStack remove; if (doFill) { @@ -276,15 +298,17 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, } @Override - public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) - { - if( player.isSneaking() ) - { + public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) { + if (player.isSneaking()) { return false; } - if( Platform.isServer() ) - { - InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.DUAL_INTERFACE_PART); + if (Platform.isServer()) { + InventoryHandler.openGui( + player, + this.getHost().getTile().getWorldObj(), + new BlockPos(this.getHost().getTile()), + Objects.requireNonNull(Util.from(this.getSide())), + GuiType.DUAL_INTERFACE_PART); } return true; } @@ -298,7 +322,8 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, public void setConfig(int id, IAEFluidStack fluid) { if (id >= 0 && id < 6) { - config.setInventorySlotContents(id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack())); + config.setInventorySlotContents( + id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack())); fluidDuality.getConfig().setFluidInSlot(id, fluidDuality.getStandardFluid(fluid)); } } @@ -310,15 +335,14 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, } @Override - public TickingRequest getTickingRequest( final IGridNode node ) - { + public TickingRequest getTickingRequest(final IGridNode node) { TickingRequest item = super.getTickingRequest(node); TickingRequest fluid = fluidDuality.getTickingRequest(node); return new TickingRequest( - Math.min(item.minTickRate, fluid.minTickRate), - Math.max(item.maxTickRate, fluid.maxTickRate), - item.isSleeping && fluid.isSleeping, - true); + Math.min(item.minTickRate, fluid.minTickRate), + Math.max(item.maxTickRate, fluid.maxTickRate), + item.isSleeping && fluid.isSleeping, + true); } @Override @@ -331,5 +355,4 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler, return fluid; } } - } diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java index 031803f1..c1341ba2 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java @@ -17,6 +17,8 @@ import com.glodblock.github.inventory.InventoryHandler; import com.glodblock.github.inventory.gui.GuiType; import com.glodblock.github.util.BlockPos; import com.glodblock.github.util.Util; +import java.util.List; +import java.util.Objects; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -25,18 +27,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Vec3; -import java.util.List; -import java.util.Objects; - public class PartFluidPatternTerminal extends FCBasePart { private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright; private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored; private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark; - private final AppEngInternalInventory crafting = new BiggerAppEngInventory( this, 9 ); - private final AppEngInternalInventory output = new BiggerAppEngInventory( this, 3 ); - private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 ); + private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 9); + private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 3); + private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2); private boolean craftingMode = true; private boolean substitute = false; @@ -47,29 +46,31 @@ public class PartFluidPatternTerminal extends FCBasePart { } @Override - public void getDrops(final List drops, final boolean wrenched ) - { - for( final ItemStack is : this.pattern ) - { - if( is != null ) - { - drops.add( is ); + public void getDrops(final List drops, final boolean wrenched) { + for (final ItemStack is : this.pattern) { + if (is != null) { + drops.add(is); } } } @Override - public boolean onPartActivate( final EntityPlayer player, final Vec3 pos ) { + public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) { TileEntity te = this.getTile(); BlockPos tePos = new BlockPos(te); if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) { return super.onPartActivate(player, pos); } if (Platform.isServer()) { - if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this) || Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) { - InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(Util.from(getSide())), GuiType.FLUID_PATTERN_TERMINAL); - } - else { + if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this) + || Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) { + InventoryHandler.openGui( + player, + te.getWorldObj(), + tePos, + Objects.requireNonNull(Util.from(getSide())), + GuiType.FLUID_PATTERN_TERMINAL); + } else { player.addChatComponentMessage(new ChatComponentText("You don't have permission to view.")); } } @@ -77,64 +78,64 @@ public class PartFluidPatternTerminal extends FCBasePart { } @Override - public void readFromNBT( final NBTTagCompound data ) - { - super.readFromNBT( data ); - this.setCraftingRecipe( data.getBoolean( "craftingMode" ) ); - this.setSubstitution( data.getBoolean( "substitute" ) ); - this.setCombineMode( data.getBoolean("combine") ); - this.pattern.readFromNBT( data, "pattern" ); - this.output.readFromNBT( data, "outputList" ); - this.crafting.readFromNBT( data, "craftingGrid" ); + public void readFromNBT(final NBTTagCompound data) { + super.readFromNBT(data); + this.setCraftingRecipe(data.getBoolean("craftingMode")); + this.setSubstitution(data.getBoolean("substitute")); + this.setCombineMode(data.getBoolean("combine")); + this.pattern.readFromNBT(data, "pattern"); + this.output.readFromNBT(data, "outputList"); + this.crafting.readFromNBT(data, "craftingGrid"); } @Override - public void writeToNBT( final NBTTagCompound data ) - { - super.writeToNBT( data ); - data.setBoolean( "craftingMode", this.craftingMode ); - data.setBoolean( "substitute", this.substitute ); - data.setBoolean( "combine", this.combine ); - this.pattern.writeToNBT( data, "pattern" ); - this.output.writeToNBT( data, "outputList" ); - this.crafting.writeToNBT( data, "craftingGrid" ); + public void writeToNBT(final NBTTagCompound data) { + super.writeToNBT(data); + data.setBoolean("craftingMode", this.craftingMode); + data.setBoolean("substitute", this.substitute); + data.setBoolean("combine", this.combine); + this.pattern.writeToNBT(data, "pattern"); + this.output.writeToNBT(data, "outputList"); + this.crafting.writeToNBT(data, "craftingGrid"); } @Override - public GuiBridge getGui(final EntityPlayer p ) - { + public GuiBridge getGui(final EntityPlayer p) { int x = (int) p.posX; int y = (int) p.posY; int z = (int) p.posZ; - if( this.getHost().getTile() != null ) - { + if (this.getHost().getTile() != null) { x = this.getTile().xCoord; y = this.getTile().yCoord; z = this.getTile().zCoord; } - if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) ) - { + if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) { return GuiBridge.GUI_PATTERN_TERMINAL; } return GuiBridge.GUI_ME; } @Override - public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { + public void onChangeInventory( + final IInventory inv, + final int slot, + final InvOperation mc, + final ItemStack removedStack, + final ItemStack newStack) { if (inv == this.pattern && slot == 1) { final ItemStack is = inv.getStackInSlot(1); if (is != null && is.getItem() instanceof ICraftingPatternItem) { final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem(); - final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj()); + final ICraftingPatternDetails details = + pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj()); if (details != null) { final IAEItemStack[] inItems = details.getInputs(); final IAEItemStack[] outItems = details.getOutputs(); this.setCraftingRecipe(details.isCraftable()); this.setSubstitution(details.canSubstitute()); - if(newStack != null){ + if (newStack != null) { NBTTagCompound data = newStack.getTagCompound(); this.setCombineMode(data.getInteger("combine") == 1); } @@ -150,10 +151,10 @@ public class PartFluidPatternTerminal extends FCBasePart { if (inItems[i] != null) { final IAEItemStack item = inItems[i]; if (item != null && item.getItem() instanceof ItemFluidDrop) { - ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); + ItemStack packet = + ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); this.crafting.setInventorySlotContents(i, packet); - } else - this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack()); + } else this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack()); } } @@ -161,10 +162,10 @@ public class PartFluidPatternTerminal extends FCBasePart { if (outItems[i] != null) { final IAEItemStack item = outItems[i]; if (item != null && item.getItem() instanceof ItemFluidDrop) { - ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); + ItemStack packet = + ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); this.output.setInventorySlotContents(i, packet); - } else - this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack()); + } else this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack()); } } } @@ -173,49 +174,39 @@ public class PartFluidPatternTerminal extends FCBasePart { this.getHost().markForSave(); } - private void fixCraftingRecipes() - { - if( this.craftingMode ) - { - for( int x = 0; x < this.crafting.getSizeInventory(); x++ ) - { - final ItemStack is = this.crafting.getStackInSlot( x ); - if( is != null ) - { + private void fixCraftingRecipes() { + if (this.craftingMode) { + for (int x = 0; x < this.crafting.getSizeInventory(); x++) { + final ItemStack is = this.crafting.getStackInSlot(x); + if (is != null) { is.stackSize = 1; } } } } - public boolean isCraftingRecipe() - { + public boolean isCraftingRecipe() { return this.craftingMode; } - public void setCraftingRecipe( final boolean craftingMode ) - { + public void setCraftingRecipe(final boolean craftingMode) { this.craftingMode = craftingMode; this.fixCraftingRecipes(); } - public boolean isSubstitution() - { + public boolean isSubstitution() { return this.substitute; } - public boolean shouldCombine() - { + public boolean shouldCombine() { return this.combine; } - public void setSubstitution( boolean canSubstitute ) - { + public void setSubstitution(boolean canSubstitute) { this.substitute = canSubstitute; } - public void setCombineMode(boolean shouldCombine) - { + public void setCombineMode(boolean shouldCombine) { this.combine = shouldCombine; } @@ -225,7 +216,7 @@ public class PartFluidPatternTerminal extends FCBasePart { if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) { for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) { final IAEItemStack item = newCrafting[x]; - crafting.setInventorySlotContents(x, item == null ? null: item.getItemStack()); + crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack()); } for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) { final IAEItemStack item = newOutput[x]; @@ -235,24 +226,20 @@ public class PartFluidPatternTerminal extends FCBasePart { } @Override - public IInventory getInventoryByName( final String name ) - { - if( name.equals( "crafting" ) ) - { + public IInventory getInventoryByName(final String name) { + if (name.equals("crafting")) { return this.crafting; } - if( name.equals( "output" ) ) - { + if (name.equals("output")) { return this.output; } - if( name.equals( "pattern" ) ) - { + if (name.equals("pattern")) { return this.pattern; } - return super.getInventoryByName( name ); + return super.getInventoryByName(name); } @Override diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java index 9ed788ca..28cf237a 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java @@ -17,6 +17,8 @@ import com.glodblock.github.inventory.InventoryHandler; import com.glodblock.github.inventory.gui.GuiType; import com.glodblock.github.util.BlockPos; import com.glodblock.github.util.Util; +import java.util.List; +import java.util.Objects; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -25,18 +27,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Vec3; -import java.util.List; -import java.util.Objects; - public class PartFluidPatternTerminalEx extends FCBasePart { private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright; private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored; private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark; - private final AppEngInternalInventory crafting = new BiggerAppEngInventory( this, 32 ); - private final AppEngInternalInventory output = new BiggerAppEngInventory( this, 32 ); - private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 ); + private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 32); + private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 32); + private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2); private boolean substitute = false; private boolean combine = false; @@ -49,29 +48,31 @@ public class PartFluidPatternTerminalEx extends FCBasePart { } @Override - public void getDrops(final List drops, final boolean wrenched ) - { - for( final ItemStack is : this.pattern ) - { - if( is != null ) - { - drops.add( is ); + public void getDrops(final List drops, final boolean wrenched) { + for (final ItemStack is : this.pattern) { + if (is != null) { + drops.add(is); } } } @Override - public boolean onPartActivate(final EntityPlayer player, final Vec3 pos ) { + public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) { TileEntity te = this.getTile(); BlockPos tePos = new BlockPos(te); if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) { return super.onPartActivate(player, pos); } if (Platform.isServer()) { - if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this) || Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) { - InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(Util.from(getSide())), GuiType.FLUID_PATTERN_TERMINAL_EX); - } - else { + if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this) + || Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) { + InventoryHandler.openGui( + player, + te.getWorldObj(), + tePos, + Objects.requireNonNull(Util.from(getSide())), + GuiType.FLUID_PATTERN_TERMINAL_EX); + } else { player.addChatComponentMessage(new ChatComponentText("You don't have permission to view.")); } } @@ -79,67 +80,67 @@ public class PartFluidPatternTerminalEx extends FCBasePart { } @Override - public void readFromNBT( final NBTTagCompound data ) - { - super.readFromNBT( data ); + public void readFromNBT(final NBTTagCompound data) { + super.readFromNBT(data); - this.setSubstitution( data.getBoolean( "substitute" ) ); - this.setCombineMode( data.getBoolean("combine") ); - this.pattern.readFromNBT( data, "pattern" ); - this.output.readFromNBT( data, "outputList" ); - this.crafting.readFromNBT( data, "craftingGrid" ); + this.setSubstitution(data.getBoolean("substitute")); + this.setCombineMode(data.getBoolean("combine")); + this.pattern.readFromNBT(data, "pattern"); + this.output.readFromNBT(data, "outputList"); + this.crafting.readFromNBT(data, "craftingGrid"); - this.setSubstitution( data.getBoolean( "substitute" ) ); - this.setPrioritization( data.getBoolean( "priorization") ); - this.setInverted( data.getBoolean( "inverted" ) ); - this.setActivePage( data.getInteger( "activePage" ) ); + this.setSubstitution(data.getBoolean("substitute")); + this.setPrioritization(data.getBoolean("priorization")); + this.setInverted(data.getBoolean("inverted")); + this.setActivePage(data.getInteger("activePage")); } @Override - public void writeToNBT( final NBTTagCompound data ) - { - super.writeToNBT( data ); + public void writeToNBT(final NBTTagCompound data) { + super.writeToNBT(data); - data.setBoolean( "substitute", this.substitute ); - data.setBoolean( "combine", this.combine ); - this.pattern.writeToNBT( data, "pattern" ); - this.output.writeToNBT( data, "outputList" ); - this.crafting.writeToNBT( data, "craftingGrid" ); + data.setBoolean("substitute", this.substitute); + data.setBoolean("combine", this.combine); + this.pattern.writeToNBT(data, "pattern"); + this.output.writeToNBT(data, "outputList"); + this.crafting.writeToNBT(data, "craftingGrid"); data.setBoolean("priorization", this.prioritize); - data.setBoolean( "substitute", this.substitute ); - data.setBoolean( "inverted", this.inverted ); - data.setInteger( "activePage", this.activePage ); + data.setBoolean("substitute", this.substitute); + data.setBoolean("inverted", this.inverted); + data.setInteger("activePage", this.activePage); } @Override - public GuiBridge getGui(final EntityPlayer p ) - { + public GuiBridge getGui(final EntityPlayer p) { int x = (int) p.posX; int y = (int) p.posY; int z = (int) p.posZ; - if( this.getHost().getTile() != null ) - { + if (this.getHost().getTile() != null) { x = this.getTile().xCoord; y = this.getTile().yCoord; z = this.getTile().zCoord; } - if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) ) - { + if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) { return GuiBridge.GUI_PATTERN_TERMINAL; } return GuiBridge.GUI_ME; } @Override - public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) - { + public void onChangeInventory( + final IInventory inv, + final int slot, + final InvOperation mc, + final ItemStack removedStack, + final ItemStack newStack) { if (inv == this.pattern && slot == 1) { final ItemStack is = inv.getStackInSlot(1); if (is != null && is.getItem() instanceof ICraftingPatternItem) { final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem(); - final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj()); + final ICraftingPatternDetails details = + pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj()); if (details != null) { final IAEItemStack[] inItems = details.getInputs(); @@ -160,7 +161,7 @@ public class PartFluidPatternTerminalEx extends FCBasePart { } this.setSubstitution(details.canSubstitute()); - if(newStack != null){ + if (newStack != null) { NBTTagCompound data = newStack.getTagCompound(); this.setCombineMode(data.getInteger("combine") == 1); this.setPrioritization(data.getInteger("prioritize") == 1); @@ -180,7 +181,8 @@ public class PartFluidPatternTerminalEx extends FCBasePart { final IAEItemStack item = inItems[i]; if (item != null) { if (item.getItem() instanceof ItemFluidDrop) { - ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); + ItemStack packet = + ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); this.crafting.setInventorySlotContents(i, packet); } else this.crafting.setInventorySlotContents(i, item.getItemStack()); } @@ -191,7 +193,8 @@ public class PartFluidPatternTerminalEx extends FCBasePart { final IAEItemStack item = outItems[i]; if (item != null) { if (item.getItem() instanceof ItemFluidDrop) { - ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); + ItemStack packet = + ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); this.output.setInventorySlotContents(i, packet); } else this.output.setInventorySlotContents(i, item.getItemStack()); } @@ -201,10 +204,10 @@ public class PartFluidPatternTerminalEx extends FCBasePart { final IAEItemStack item = outItems[i]; if (item != null) { if (item.getItem() instanceof ItemFluidDrop) { - ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); + ItemStack packet = + ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack())); this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet); - } else - this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack()); + } else this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack()); } } } @@ -214,32 +217,27 @@ public class PartFluidPatternTerminalEx extends FCBasePart { this.getHost().markForSave(); } - public boolean shouldCombine() - { + public boolean shouldCombine() { return this.combine; } - public void setCombineMode(boolean shouldCombine) - { + public void setCombineMode(boolean shouldCombine) { this.combine = shouldCombine; } - public boolean isSubstitution() - { + public boolean isSubstitution() { return this.substitute; } - public boolean isPrioritize() - { + public boolean isPrioritize() { return this.prioritize; } - public void setSubstitution( boolean canSubstitute ) - { + public void setSubstitution(boolean canSubstitute) { this.substitute = canSubstitute; } - public void setPrioritization( boolean canPrioritize ) - { + + public void setPrioritization(boolean canPrioritize) { this.prioritize = canPrioritize; } @@ -249,7 +247,7 @@ public class PartFluidPatternTerminalEx extends FCBasePart { if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) { for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) { final IAEItemStack item = newCrafting[x]; - crafting.setInventorySlotContents(x, item == null ? null: item.getItemStack()); + crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack()); } for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) { final IAEItemStack item = newOutput[x]; @@ -259,24 +257,20 @@ public class PartFluidPatternTerminalEx extends FCBasePart { } @Override - public IInventory getInventoryByName( final String name ) - { - if( name.equals( "crafting" ) ) - { + public IInventory getInventoryByName(final String name) { + if (name.equals("crafting")) { return this.crafting; } - if( name.equals( "output" ) ) - { + if (name.equals("output")) { return this.output; } - if( name.equals( "pattern" ) ) - { + if (name.equals("pattern")) { return this.pattern; } - return super.getInventoryByName( name ); + return super.getInventoryByName(name); } @Override @@ -314,5 +308,4 @@ public class PartFluidPatternTerminalEx extends FCBasePart { public void setActivePage(int activePage) { this.activePage = activePage; } - } diff --git a/src/main/java/com/glodblock/github/common/parts/PartSharedFluidBus.java b/src/main/java/com/glodblock/github/common/parts/PartSharedFluidBus.java index 506a0b88..8af228b3 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartSharedFluidBus.java +++ b/src/main/java/com/glodblock/github/common/parts/PartSharedFluidBus.java @@ -16,6 +16,7 @@ import com.glodblock.github.inventory.InventoryHandler; import com.glodblock.github.inventory.gui.GuiType; import com.glodblock.github.util.BlockPos; import com.glodblock.github.util.Util; +import java.util.Objects; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -25,106 +26,87 @@ import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import java.util.Objects; +public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable { -public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable -{ - - private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 ); + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 9); private boolean lastRedstone; - public PartSharedFluidBus( ItemStack is ) - { - super( is ); + public PartSharedFluidBus(ItemStack is) { + super(is); } public abstract IIcon getFaceIcon(); @Override - public void upgradesChanged() - { + public void upgradesChanged() { this.updateState(); } @Override - public void onNeighborChanged() - { + public void onNeighborChanged() { this.updateState(); - if( this.lastRedstone != this.getHost().hasRedstone( this.getSide() ) ) - { + if (this.lastRedstone != this.getHost().hasRedstone(this.getSide())) { this.lastRedstone = !this.lastRedstone; - if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE ) - { + if (this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE) { this.doBusWork(); } } } - private void updateState() - { - try - { - if( !this.isSleeping() ) - { - this.getProxy().getTick().wakeDevice( this.getProxy().getNode() ); + private void updateState() { + try { + if (!this.isSleeping()) { + this.getProxy().getTick().wakeDevice(this.getProxy().getNode()); + } else { + this.getProxy().getTick().sleepDevice(this.getProxy().getNode()); } - else - { - this.getProxy().getTick().sleepDevice( this.getProxy().getNode() ); - } - } - catch( final GridAccessException e ) - { + } catch (final GridAccessException e) { // :P } } @Override - public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) - { - if( player.isSneaking() ) - { + public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) { + if (player.isSneaking()) { return false; } - if( Platform.isServer() ) - { - InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.FLUID_BUS_IO); + if (Platform.isServer()) { + InventoryHandler.openGui( + player, + this.getHost().getTile().getWorldObj(), + new BlockPos(this.getHost().getTile()), + Objects.requireNonNull(Util.from(this.getSide())), + GuiType.FLUID_BUS_IO); } return true; } @Override - public void getBoxes( IPartCollisionHelper bch ) - { - bch.addBox( 6, 6, 11, 10, 10, 13 ); - bch.addBox( 5, 5, 13, 11, 11, 14 ); - bch.addBox( 4, 4, 14, 12, 12, 16 ); + public void getBoxes(IPartCollisionHelper bch) { + bch.addBox(6, 6, 11, 10, 10, 13); + bch.addBox(5, 5, 13, 11, 11, 14); + bch.addBox(4, 4, 14, 12, 12, 16); } - protected TileEntity getConnectedTE() - { + protected TileEntity getConnectedTE() { TileEntity self = this.getHost().getTile(); - return this.getTileEntity( self, (new BlockPos(self)).getOffSet( this.getSide() ) ); + return this.getTileEntity(self, (new BlockPos(self)).getOffSet(this.getSide())); } - private TileEntity getTileEntity( final TileEntity self, final BlockPos pos ) - { + private TileEntity getTileEntity(final TileEntity self, final BlockPos pos) { final World w = self.getWorldObj(); - if( w.getChunkProvider().chunkExists( pos.getX() >> 4, pos.getZ() >> 4 ) ) - { - return w.getTileEntity( pos.getX(), pos.getY(), pos.getZ() ); + if (w.getChunkProvider().chunkExists(pos.getX() >> 4, pos.getZ() >> 4)) { + return w.getTileEntity(pos.getX(), pos.getY(), pos.getZ()); } return null; } - protected int calculateAmountToSend() - { + protected int calculateAmountToSend() { double amount = 1000D; - switch( this.getInstalledUpgrades( Upgrades.SPEED ) ) - { + switch (this.getInstalledUpgrades(Upgrades.SPEED)) { case 4: amount = amount * 1.5; case 3: @@ -135,22 +117,20 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri amount = amount * 8; case 0: default: - return (int) Math.floor( amount ); + return (int) Math.floor(amount); } } @Override - public void readFromNBT( NBTTagCompound extra ) - { - super.readFromNBT( extra ); - this.config.readFromNBT( extra, "config" ); + public void readFromNBT(NBTTagCompound extra) { + super.readFromNBT(extra); + this.config.readFromNBT(extra, "config"); } @Override - public void writeToNBT( NBTTagCompound extra ) - { - super.writeToNBT( extra ); - this.config.writeToNBT( extra, "config" ); + public void writeToNBT(NBTTagCompound extra) { + super.writeToNBT(extra); + this.config.writeToNBT(extra, "config"); } @Override @@ -166,8 +146,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri this.config.setInventorySlotContents(id, tmp); } - protected StorageChannel getChannel() - { + protected StorageChannel getChannel() { return StorageChannel.FLUIDS; } @@ -176,9 +155,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri protected abstract boolean canDoBusWork(); @Override - public int cableConnectionRenderTo() - { + public int cableConnectionRenderTo() { return 5; } - } diff --git a/src/main/java/com/glodblock/github/common/storage/CellType.java b/src/main/java/com/glodblock/github/common/storage/CellType.java index 7ca28158..ec856605 100644 --- a/src/main/java/com/glodblock/github/common/storage/CellType.java +++ b/src/main/java/com/glodblock/github/common/storage/CellType.java @@ -1,59 +1,49 @@ package com.glodblock.github.common.storage; import appeng.core.features.AEFeature; +import java.util.EnumSet; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import java.util.EnumSet; - public enum CellType { - - Cell1kPart( 0, AEFeature.StorageCells ), - Cell4kPart( 1, AEFeature.StorageCells ), - Cell16kPart( 2, AEFeature.StorageCells ), - Cell64kPart( 3, AEFeature.StorageCells ), - Cell256kPart( 4, AEFeature.StorageCells ), - Cell1024kPart( 5, AEFeature.StorageCells ), - Cell4096kPart( 6, AEFeature.StorageCells ); + Cell1kPart(0, AEFeature.StorageCells), + Cell4kPart(1, AEFeature.StorageCells), + Cell16kPart(2, AEFeature.StorageCells), + Cell64kPart(3, AEFeature.StorageCells), + Cell256kPart(4, AEFeature.StorageCells), + Cell1024kPart(5, AEFeature.StorageCells), + Cell4096kPart(6, AEFeature.StorageCells); private final EnumSet features; private int damageValue; private Item itemInstance; - CellType( final int metaValue, final AEFeature part ) - { - this.setDamageValue( metaValue ); - this.features = EnumSet.of( part ); + CellType(final int metaValue, final AEFeature part) { + this.setDamageValue(metaValue); + this.features = EnumSet.of(part); } - void setDamageValue( final int damageValue ) - { + void setDamageValue(final int damageValue) { this.damageValue = damageValue; } - public int getDamageValue() - { + public int getDamageValue() { return this.damageValue; } - EnumSet getFeature() - { + EnumSet getFeature() { return this.features; } - public ItemStack stack(final int size ) - { - return new ItemStack( this.getItemInstance(), size, this.getDamageValue() ); + public ItemStack stack(final int size) { + return new ItemStack(this.getItemInstance(), size, this.getDamageValue()); } - public Item getItemInstance() - { + public Item getItemInstance() { return this.itemInstance; } - public void setItemInstance( final Item itemInstance ) - { + public void setItemInstance(final Item itemInstance) { this.itemInstance = itemInstance; } - } diff --git a/src/main/java/com/glodblock/github/common/storage/FluidCellHandler.java b/src/main/java/com/glodblock/github/common/storage/FluidCellHandler.java index c11f324c..92f08d1a 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellHandler.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellHandler.java @@ -12,64 +12,63 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; -public class FluidCellHandler implements ICellHandler -{ +public class FluidCellHandler implements ICellHandler { @Override - public boolean isCell( final ItemStack is ) - { - return FluidCellInventory.isCell( is ); + public boolean isCell(final ItemStack is) { + return FluidCellInventory.isCell(is); } @Override - public IMEInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container, final StorageChannel channel ) - { - if( channel == StorageChannel.FLUIDS ) - { - return FluidCellInventory.getCell( is, container ); + public IMEInventoryHandler getCellInventory( + final ItemStack is, final ISaveProvider container, final StorageChannel channel) { + if (channel == StorageChannel.FLUIDS) { + return FluidCellInventory.getCell(is, container); } return null; } @Override - public IIcon getTopTexture_Light() - { + public IIcon getTopTexture_Light() { return ExtraBlockTextures.BlockMEChestItems_Light.getIcon(); } @Override - public IIcon getTopTexture_Medium() - { + public IIcon getTopTexture_Medium() { return ExtraBlockTextures.BlockMEChestItems_Medium.getIcon(); } @Override - public IIcon getTopTexture_Dark() - { + public IIcon getTopTexture_Dark() { return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon(); } @Override - public void openChestGui(final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final StorageChannel chan ) - { + public void openChestGui( + final EntityPlayer player, + final IChestOrDrive chest, + final ICellHandler cellHandler, + final IMEInventoryHandler inv, + final ItemStack is, + final StorageChannel chan) { if (ModAndClassUtil.EC2) { if (chan == StorageChannel.FLUIDS) { IStorageMonitorable monitorable = null; if (chest != null) { - monitorable = ((IMEChest)chest).getMonitorable(ForgeDirection.UNKNOWN, new PlayerSource(player, chest)); + monitorable = + ((IMEChest) chest).getMonitorable(ForgeDirection.UNKNOWN, new PlayerSource(player, chest)); } if (monitorable != null) { - GuiHandler.launchGui(GuiHandler.getGuiId(0), player, new Object[]{monitorable.getFluidInventory()}); + GuiHandler.launchGui( + GuiHandler.getGuiId(0), player, new Object[] {monitorable.getFluidInventory()}); } } } } @Override - public int getStatusForCell( final ItemStack is, final IMEInventory handler ) - { - if( handler instanceof FluidCellInventoryHandler) - { + public int getStatusForCell(final ItemStack is, final IMEInventory handler) { + if (handler instanceof FluidCellInventoryHandler) { final FluidCellInventoryHandler ci = (FluidCellInventoryHandler) handler; return ci.getStatusForCell(); } @@ -77,9 +76,8 @@ public class FluidCellHandler implements ICellHandler } @Override - public double cellIdleDrain( final ItemStack is, final IMEInventory handler ) - { - final IFluidCellInventory inv = ( (IFluidCellInventoryHandler) handler ).getCellInv(); + public double cellIdleDrain(final ItemStack is, final IMEInventory handler) { + final IFluidCellInventory inv = ((IFluidCellInventoryHandler) handler).getCellInv(); return inv.getIdleDrain(); } } diff --git a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java index 32c13194..d438bd7f 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java @@ -30,29 +30,26 @@ public class FluidCellInventory implements IFluidCellInventory { private static String[] fluidSlotCount; private final ItemStack cellItem; private final ISaveProvider container; - private final static int MAX_TYPE = 1; + private static final int MAX_TYPE = 1; private long storedFluidCount; private short storedFluids; private IItemList cellItems; private final NBTTagCompound tagCompound; - public FluidCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException { + public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException { - if( fluidSlots == null ) - { + if (fluidSlots == null) { fluidSlots = new String[MAX_TYPE]; fluidSlotCount = new String[MAX_TYPE]; - for( int x = 0; x < MAX_TYPE; x++ ) - { + for (int x = 0; x < MAX_TYPE; x++) { fluidSlots[x] = FLUID_SLOT + x; fluidSlotCount[x] = FLUID_SLOT_COUNT + x; } } - if( o == null ) - { - throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); + if (o == null) { + throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); } this.cellType = null; @@ -60,52 +57,42 @@ public class FluidCellInventory implements IFluidCellInventory { final Item type = this.cellItem.getItem(); - if( type instanceof IStorageFluidCell) - { + if (type instanceof IStorageFluidCell) { this.cellType = (IStorageFluidCell) this.cellItem.getItem(); } - if( this.cellType == null ) - { - throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); + if (this.cellType == null) { + throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); } - if( !this.cellType.isStorageCell( this.cellItem ) ) - { - throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" ); + if (!this.cellType.isStorageCell(this.cellItem)) { + throw new AppEngException("ItemStack was used as a cell, but was not a cell!"); } this.container = container; - this.tagCompound = Platform.openNbtData( o ); - this.storedFluids = this.tagCompound.getShort( FLUID_TYPE_TAG ); - this.storedFluidCount = this.tagCompound.getLong( FLUID_COUNT_TAG ); + this.tagCompound = Platform.openNbtData(o); + this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG); + this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG); this.cellItems = null; } - public static IMEInventoryHandler getCell(final ItemStack o, final ISaveProvider container2 ) - { - try - { - return new FluidCellInventoryHandler( new FluidCellInventory( o, container2 ) ); - } - catch( final AppEngException e ) - { + public static IMEInventoryHandler getCell(final ItemStack o, final ISaveProvider container2) { + try { + return new FluidCellInventoryHandler(new FluidCellInventory(o, container2)); + } catch (final AppEngException e) { return null; } } - public static boolean isCell( final ItemStack itemStack ) - { - if( itemStack == null ) - { + public static boolean isCell(final ItemStack itemStack) { + if (itemStack == null) { return false; } final Item type = itemStack.getItem(); - if( type instanceof IStorageFluidCell) - { - return ( (IStorageFluidCell) type ).isStorageCell( itemStack ); + if (type instanceof IStorageFluidCell) { + return ((IStorageFluidCell) type).isStorageCell(itemStack); } return false; @@ -123,24 +110,26 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public IInventory getConfigInventory() { - return this.cellType.getConfigInventory( this.cellItem ); + return this.cellType.getConfigInventory(this.cellItem); } @Override public int getBytesPerType() { - return this.cellType.getBytesPerType( this.cellItem ); + return this.cellType.getBytesPerType(this.cellItem); } @Override public boolean canHoldNewFluid() { final long bytesFree = this.getFreeBytes(); - return ( bytesFree > this.getBytesPerType() || ( bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0 ) ) && this.getRemainingFluidTypes() > 0; + return (bytesFree > this.getBytesPerType() + || (bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0)) + && this.getRemainingFluidTypes() > 0; } @Override public long getTotalBytes() { - return this.cellType.getBytes( this.cellItem ); + return this.cellType.getBytes(this.cellItem); } @Override @@ -150,7 +139,7 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public long getUsedBytes() { - final long bytesForItemCount = ( this.getStoredFluidCount() + this.getUnusedFluidCount() ) / 8 / 256; + final long bytesForItemCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / 8 / 256; return this.getStoredFluidTypes() * this.getBytesPerType() + bytesForItemCount; } @@ -184,10 +173,9 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public int getUnusedFluidCount() { - final int div = (int) ( this.getStoredFluidCount() % 8 ); + final int div = (int) (this.getStoredFluidCount() % 8); - if( div == 0 ) - { + if (div == 0) { return 0; } @@ -196,21 +184,17 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public int getStatusForCell() { - if( this.canHoldNewFluid() ) - { + if (this.canHoldNewFluid()) { return 1; } - if( this.getRemainingFluidCount() > 0 ) - { + if (this.getRemainingFluidCount() > 0) { return 2; } return 3; } - private void loadCellItems() - { - if( this.cellItems == null ) - { + private void loadCellItems() { + if (this.cellItems == null) { this.cellItems = AEApi.instance().storage().createFluidList(); } @@ -218,67 +202,56 @@ public class FluidCellInventory implements IFluidCellInventory { final int types = (int) this.getStoredFluidTypes(); - for( int x = 0; x < types; x++ ) - { - final FluidStack t = FluidStack.loadFluidStackFromNBT( this.tagCompound.getCompoundTag( fluidSlots[x] ) ); - final AEFluidStack aet = AEFluidStack.create( t ); + for (int x = 0; x < types; x++) { + final FluidStack t = FluidStack.loadFluidStackFromNBT(this.tagCompound.getCompoundTag(fluidSlots[x])); + final AEFluidStack aet = AEFluidStack.create(t); - if( aet != null ) - { - aet.setStackSize( this.tagCompound.getLong( fluidSlotCount[x] ) ); + if (aet != null) { + aet.setStackSize(this.tagCompound.getLong(fluidSlotCount[x])); - if( aet.getStackSize() > 0 ) - { - this.cellItems.add( aet ); + if (aet.getStackSize() > 0) { + this.cellItems.add(aet); } } } } - private IItemList getCellItems() - { - if( this.cellItems == null ) - { + private IItemList getCellItems() { + if (this.cellItems == null) { this.loadCellItems(); } return this.cellItems; } - private void updateFluidCount( final long delta ) - { + private void updateFluidCount(final long delta) { this.storedFluidCount += delta; - this.tagCompound.setLong( FLUID_COUNT_TAG, this.storedFluidCount ); + this.tagCompound.setLong(FLUID_COUNT_TAG, this.storedFluidCount); } - private void saveChanges() - { + private void saveChanges() { long itemCount = 0; int x = 0; - for( final IAEFluidStack v : this.cellItems ) - { + for (final IAEFluidStack v : this.cellItems) { itemCount += v.getStackSize(); - final NBTBase c = this.tagCompound.getTag( fluidSlots[x] ); + final NBTBase c = this.tagCompound.getTag(fluidSlots[x]); - if( c instanceof NBTTagCompound ) - { - v.writeToNBT( (NBTTagCompound) c ); - } - else - { + if (c instanceof NBTTagCompound) { + v.writeToNBT((NBTTagCompound) c); + } else { final NBTTagCompound g = new NBTTagCompound(); - v.writeToNBT( g ); - this.tagCompound.setTag( fluidSlots[x], g ); + v.writeToNBT(g); + this.tagCompound.setTag(fluidSlots[x], g); } /* * NBTBase tagSlotCount = tagCompound.getTag( itemSlotCount[x] ); if ( tagSlotCount instanceof * NBTTagInt ) ((NBTTagInt) tagSlotCount).data = (int) v.getStackSize(); else */ - this.tagCompound.setLong( fluidSlotCount[x], v.getStackSize() ); + this.tagCompound.setLong(fluidSlotCount[x], v.getStackSize()); x++; } @@ -293,13 +266,10 @@ public class FluidCellInventory implements IFluidCellInventory { */ this.storedFluids = (short) this.cellItems.size(); - if( this.cellItems.isEmpty() ) - { - this.tagCompound.removeTag( FLUID_TYPE_TAG ); - } - else - { - this.tagCompound.setShort( FLUID_TYPE_TAG, this.storedFluids ); + if (this.cellItems.isEmpty()) { + this.tagCompound.removeTag(FLUID_TYPE_TAG); + } else { + this.tagCompound.setShort(FLUID_TYPE_TAG, this.storedFluids); } /* @@ -307,78 +277,63 @@ public class FluidCellInventory implements IFluidCellInventory { */ this.storedFluidCount = itemCount; - if( itemCount == 0 ) - { - this.tagCompound.removeTag( FLUID_COUNT_TAG ); - } - else - { - this.tagCompound.setLong( FLUID_COUNT_TAG, itemCount ); + if (itemCount == 0) { + this.tagCompound.removeTag(FLUID_COUNT_TAG); + } else { + this.tagCompound.setLong(FLUID_COUNT_TAG, itemCount); } // clean any old crusty stuff... - for( ; x < oldStoredItems && x < MAX_TYPE; x++ ) - { - this.tagCompound.removeTag( fluidSlots[x] ); - this.tagCompound.removeTag( fluidSlotCount[x] ); + for (; x < oldStoredItems && x < MAX_TYPE; x++) { + this.tagCompound.removeTag(fluidSlots[x]); + this.tagCompound.removeTag(fluidSlotCount[x]); } - if( this.container != null ) - { - this.container.saveChanges( this ); + if (this.container != null) { + this.container.saveChanges(this); } } @Override public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src) { - if( input == null ) - { + if (input == null) { return null; } - if( input.getStackSize() == 0 ) - { + if (input.getStackSize() == 0) { return null; } - if(this.cellType.isBlackListed( this.cellItem, input )) - { + if (this.cellType.isBlackListed(this.cellItem, input)) { return input; } final FluidStack sharedFluidStack = input.getFluidStack(); - final IAEFluidStack l = this.getCellItems().findPrecise( input ); + final IAEFluidStack l = this.getCellItems().findPrecise(input); - if( l != null ) - { + if (l != null) { final long remainingItemSlots = this.getRemainingFluidCount(); - if( remainingItemSlots < 0 ) - { + if (remainingItemSlots < 0) { return input; } - if( input.getStackSize() > remainingItemSlots ) - { + if (input.getStackSize() > remainingItemSlots) { final IAEFluidStack r = input.copy(); - r.setStackSize( r.getStackSize() - remainingItemSlots ); + r.setStackSize(r.getStackSize() - remainingItemSlots); - if( mode == Actionable.MODULATE ) - { - l.setStackSize( l.getStackSize() + remainingItemSlots ); - this.updateFluidCount( remainingItemSlots ); + if (mode == Actionable.MODULATE) { + l.setStackSize(l.getStackSize() + remainingItemSlots); + this.updateFluidCount(remainingItemSlots); this.saveChanges(); } return r; - } - else - { - if( mode == Actionable.MODULATE ) - { - l.setStackSize( l.getStackSize() + input.getStackSize() ); - this.updateFluidCount( input.getStackSize() ); + } else { + if (mode == Actionable.MODULATE) { + l.setStackSize(l.getStackSize() + input.getStackSize()); + this.updateFluidCount(input.getStackSize()); this.saveChanges(); } @@ -386,35 +341,31 @@ public class FluidCellInventory implements IFluidCellInventory { } } - if( this.canHoldNewFluid() ) // room for new type, and for at least one item! + if (this.canHoldNewFluid()) // room for new type, and for at least one item! { final long remainingItemCount = this.getRemainingFluidCount() - this.getBytesPerType() * 8; - if( remainingItemCount > 0 ) - { - if( input.getStackSize() > remainingItemCount ) - { + if (remainingItemCount > 0) { + if (input.getStackSize() > remainingItemCount) { final FluidStack toReturn = Util.cloneFluidStack(sharedFluidStack); toReturn.amount = (int) (sharedFluidStack.amount - remainingItemCount); - if( mode == Actionable.MODULATE ) - { - final FluidStack toWrite = Util.cloneFluidStack( sharedFluidStack ); + if (mode == Actionable.MODULATE) { + final FluidStack toWrite = Util.cloneFluidStack(sharedFluidStack); toWrite.amount = (int) remainingItemCount; - this.cellItems.add( AEFluidStack.create( toWrite ) ); - this.updateFluidCount( toWrite.amount ); + this.cellItems.add(AEFluidStack.create(toWrite)); + this.updateFluidCount(toWrite.amount); this.saveChanges(); } - return AEFluidStack.create( toReturn ); + return AEFluidStack.create(toReturn); } - if( mode == Actionable.MODULATE ) - { - this.updateFluidCount( input.getStackSize() ); - this.cellItems.add( input ); + if (mode == Actionable.MODULATE) { + this.updateFluidCount(input.getStackSize()); + this.cellItems.add(input); this.saveChanges(); } @@ -427,40 +378,33 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) { - if( request == null ) - { + if (request == null) { return null; } - final long size = Math.min( Integer.MAX_VALUE, request.getStackSize() ); + final long size = Math.min(Integer.MAX_VALUE, request.getStackSize()); IAEFluidStack results = null; - final IAEFluidStack l = this.getCellItems().findPrecise( request ); + final IAEFluidStack l = this.getCellItems().findPrecise(request); - if( l != null ) - { + if (l != null) { results = l.copy(); - if( l.getStackSize() <= size ) - { - results.setStackSize( l.getStackSize() ); + if (l.getStackSize() <= size) { + results.setStackSize(l.getStackSize()); - if( mode == Actionable.MODULATE ) - { - this.updateFluidCount( -l.getStackSize() ); - l.setStackSize( 0 ); + if (mode == Actionable.MODULATE) { + this.updateFluidCount(-l.getStackSize()); + l.setStackSize(0); this.saveChanges(); } - } - else - { - results.setStackSize( size ); + } else { + results.setStackSize(size); - if( mode == Actionable.MODULATE ) - { - l.setStackSize( l.getStackSize() - size ); - this.updateFluidCount( -size ); + if (mode == Actionable.MODULATE) { + l.setStackSize(l.getStackSize() - size); + this.updateFluidCount(-size); this.saveChanges(); } } @@ -471,9 +415,8 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public IItemList getAvailableItems(IItemList out) { - for( final IAEFluidStack i : this.getCellItems() ) - { - out.add( i ); + for (final IAEFluidStack i : this.getCellItems()) { + out.add(i); } return out; diff --git a/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java b/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java index c1aede92..cc87899d 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventoryHandler.java @@ -17,17 +17,16 @@ import net.minecraft.item.ItemStack; public class FluidCellInventoryHandler extends MEInventoryHandler implements IFluidCellInventoryHandler { - FluidCellInventoryHandler( final IMEInventory c ) - { - super( c, StorageChannel.FLUIDS ); + FluidCellInventoryHandler(final IMEInventory c) { + super(c, StorageChannel.FLUIDS); final IFluidCellInventory ci = this.getCellInv(); - if( ci != null ) - { + if (ci != null) { final IInventory config = ci.getConfigInventory(); - final IItemList priorityList = AEApi.instance().storage().createFluidList(); + final IItemList priorityList = + AEApi.instance().storage().createFluidList(); for (int x = 0; x < config.getSizeInventory(); x++) { final ItemStack is = config.getStackInSlot(x); if (is != null && Util.getFluidFromItem(is) != null) { @@ -42,36 +41,30 @@ public class FluidCellInventoryHandler extends MEInventoryHandler } @Override - public IFluidCellInventory getCellInv() - { + public IFluidCellInventory getCellInv() { Object o = this.getInternal(); - if( o instanceof MEPassThrough) - { - o = Ae2Reflect.getInternal( (MEPassThrough) o ); + if (o instanceof MEPassThrough) { + o = Ae2Reflect.getInternal((MEPassThrough) o); } - return (IFluidCellInventory) ( o instanceof IFluidCellInventory ? o : null ); + return (IFluidCellInventory) (o instanceof IFluidCellInventory ? o : null); } @Override - public boolean isPreformatted() - { + public boolean isPreformatted() { return !Ae2Reflect.getPartitionList(this).isEmpty(); } @Override - public IncludeExclude getIncludeExcludeMode() - { + public IncludeExclude getIncludeExcludeMode() { return IncludeExclude.WHITELIST; } - public int getStatusForCell() - { + public int getStatusForCell() { int val = this.getCellInv().getStatusForCell(); - if( val == 1 && this.isPreformatted() ) - { + if (val == 1 && this.isPreformatted()) { val = 2; } diff --git a/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java b/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java index 288504ef..7adda2bb 100644 --- a/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/IFluidCellInventory.java @@ -5,8 +5,7 @@ import appeng.api.storage.data.IAEFluidStack; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -public interface IFluidCellInventory extends IMEInventory -{ +public interface IFluidCellInventory extends IMEInventory { /** * @return the item stack of this storage cell. diff --git a/src/main/java/com/glodblock/github/common/storage/IFluidCellInventoryHandler.java b/src/main/java/com/glodblock/github/common/storage/IFluidCellInventoryHandler.java index aedfb3e3..f403cb98 100644 --- a/src/main/java/com/glodblock/github/common/storage/IFluidCellInventoryHandler.java +++ b/src/main/java/com/glodblock/github/common/storage/IFluidCellInventoryHandler.java @@ -9,5 +9,4 @@ public interface IFluidCellInventoryHandler { boolean isPreformatted(); IncludeExclude getIncludeExcludeMode(); - } diff --git a/src/main/java/com/glodblock/github/common/storage/IStorageFluidCell.java b/src/main/java/com/glodblock/github/common/storage/IStorageFluidCell.java index 314b1c3b..90d076b9 100644 --- a/src/main/java/com/glodblock/github/common/storage/IStorageFluidCell.java +++ b/src/main/java/com/glodblock/github/common/storage/IStorageFluidCell.java @@ -6,18 +6,17 @@ import net.minecraft.item.ItemStack; public interface IStorageFluidCell extends ICellWorkbenchItem { - int getBytes( ItemStack cellItem ); + int getBytes(ItemStack cellItem); - int getBytesPerType( ItemStack cellItem ); + int getBytesPerType(ItemStack cellItem); - boolean isBlackListed( ItemStack cellItem, IAEFluidStack requestedAddition ); + boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition); boolean storableInStorageCell(); - boolean isStorageCell( ItemStack i ); + boolean isStorageCell(ItemStack i); double getIdleDrain(); - int getTotalTypes( ItemStack cellItem ); - + int getTotalTypes(ItemStack cellItem); } diff --git a/src/main/java/com/glodblock/github/common/tabs/FluidCraftingTabs.java b/src/main/java/com/glodblock/github/common/tabs/FluidCraftingTabs.java index 9cdf03b2..56e5e195 100644 --- a/src/main/java/com/glodblock/github/common/tabs/FluidCraftingTabs.java +++ b/src/main/java/com/glodblock/github/common/tabs/FluidCraftingTabs.java @@ -9,7 +9,7 @@ public class FluidCraftingTabs extends CreativeTabs { public static final FluidCraftingTabs INSTANCE = new FluidCraftingTabs(FluidCraft.MODID); - public FluidCraftingTabs(String name){ + public FluidCraftingTabs(String name) { super(name); } diff --git a/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java b/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java index 613dd20a..b3421376 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java @@ -20,7 +20,6 @@ import appeng.me.cache.CraftingGridCache; import appeng.me.storage.MEInventoryHandler; import appeng.tile.grid.AENetworkTile; import com.glodblock.github.common.item.ItemFluidDrop; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -41,7 +40,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost @Override public boolean canBeRotated() { return false; - //based + // based } @Override @@ -64,12 +63,12 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost @Override public void setPriority(int newValue) { - //do nothing + // do nothing } @Override public void blinkCell(int slot) { - //do nothing + // do nothing } @Override @@ -87,7 +86,10 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost private IMEMonitor getFluidGrid() { try { - return getProxy().getGrid().getCache(IStorageGrid.class).getFluidInventory(); + return getProxy() + .getGrid() + .getCache(IStorageGrid.class) + .getFluidInventory(); } catch (GridAccessException e) { return null; } @@ -128,7 +130,8 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost updateState(); } - private class FluidDiscretizingInventory implements IMEInventory, IMEMonitorHandlerReceiver { + private class FluidDiscretizingInventory + implements IMEInventory, IMEMonitorHandlerReceiver { private final MEInventoryHandler invHandler = new MEInventoryHandler<>(this, getChannel()); private List itemCache = null; @@ -153,8 +156,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost } if (type == Actionable.SIMULATE) { return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.SIMULATE, src)); - } - else { + } else { return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.MODULATE, src)); } } @@ -175,8 +177,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost } if (mode == Actionable.SIMULATE) { return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.SIMULATE, src)); - } - else { + } else { return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.MODULATE, src)); } } @@ -213,7 +214,8 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost } @Override - public void postChange(IBaseMonitor monitor, Iterable change, BaseActionSource actionSource) { + public void postChange( + IBaseMonitor monitor, Iterable change, BaseActionSource actionSource) { itemCache = null; try { List mappedChanges = new ArrayList<>(); @@ -223,8 +225,10 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost mappedChanges.add(itemStack); } } - getProxy().getGrid().getCache(IStorageGrid.class) - .postAlterationOfStoredItems(getChannel(), mappedChanges, ownActionSource); + getProxy() + .getGrid() + .getCache(IStorageGrid.class) + .postAlterationOfStoredItems(getChannel(), mappedChanges, ownActionSource); } catch (GridAccessException e) { // NO-OP } @@ -254,8 +258,8 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost return null; } if (craftingGrid instanceof CraftingGridCache) { - IAEStack remaining = ((CraftingGridCache)craftingGrid).injectItems( - ItemFluidDrop.newAeStack(input), type, ownActionSource); + IAEStack remaining = ((CraftingGridCache) craftingGrid) + .injectItems(ItemFluidDrop.newAeStack(input), type, ownActionSource); if (remaining instanceof IAEItemStack) { return ItemFluidDrop.getAeFluidStack((IAEItemStack) remaining); } @@ -277,7 +281,5 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost public StorageChannel getChannel() { return StorageChannel.FLUIDS; } - } - } diff --git a/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java b/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java index 143ce769..4d9860a7 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java @@ -21,6 +21,8 @@ import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.util.DualityFluidInterface; import cpw.mods.fml.common.network.ByteBufUtils; import io.netty.buffer.ByteBuf; +import java.io.IOException; +import javax.annotation.Nullable; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -29,11 +31,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import javax.annotation.Nullable; -import java.io.IOException; - -public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory -{ +public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory { private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) { @Override @@ -70,12 +68,11 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, } public AppEngInternalAEInventory getConfig() { - for (int i = 0; i < fluidDuality.getConfig().getSlots(); i ++) { + for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) { IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i); if (fluid == null) { config.setInventorySlotContents(i, null); - } - else { + } else { config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack())); } } @@ -87,10 +84,10 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, TickingRequest item = super.getTickingRequest(node); TickingRequest fluid = fluidDuality.getTickingRequest(node); return new TickingRequest( - Math.min(item.minTickRate, fluid.minTickRate), - Math.max(item.maxTickRate, fluid.maxTickRate), - item.isSleeping && fluid.isSleeping, - true); + Math.min(item.minTickRate, fluid.minTickRate), + Math.max(item.maxTickRate, fluid.maxTickRate), + item.isSleeping && fluid.isSleeping, + true); } @Override @@ -104,11 +101,11 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, } } - @TileEvent( TileEventType.NETWORK_WRITE ) + @TileEvent(TileEventType.NETWORK_WRITE) protected void writeToStream(ByteBuf data) throws IOException { for (int i = 0; i < config.getSizeInventory(); i++) { ByteBufUtils.writeItemStack(data, config.getStackInSlot(i)); - for (int j = 0; j < config.getSizeInventory(); j ++) { + for (int j = 0; j < config.getSizeInventory(); j++) { FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j)); fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid)); } @@ -128,7 +125,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, } } - @TileEvent( TileEventType.NETWORK_READ ) + @TileEvent(TileEventType.NETWORK_READ) protected boolean readFromStream(ByteBuf data) throws IOException { boolean changed = false; for (int i = 0; i < config.getSizeInventory(); i++) { @@ -137,7 +134,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, config.setInventorySlotContents(i, stack); changed = true; } - for (int j = 0; j < config.getSizeInventory(); j ++) { + for (int j = 0; j < config.getSizeInventory(); j++) { FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j)); fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid)); } @@ -161,17 +158,17 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, return changed; } - @TileEvent( TileEventType.WORLD_NBT_READ ) + @TileEvent(TileEventType.WORLD_NBT_READ) public void readFromNBTEvent(NBTTagCompound data) { config.readFromNBT(data, "ConfigInv"); - for (int i = 0; i < config.getSizeInventory(); i ++) { + for (int i = 0; i < config.getSizeInventory(); i++) { FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i)); fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid)); } getInternalFluid().readFromNBT(data, "FluidInv"); } - @TileEvent( TileEventType.WORLD_NBT_WRITE ) + @TileEvent(TileEventType.WORLD_NBT_WRITE) public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { config.writeToNBT(data, "ConfigInv"); getInternalFluid().writeToNBT(data, "FluidInv"); @@ -179,8 +176,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, } @Nullable - protected ItemStack getItemFromTile( final Object obj ) - { + protected ItemStack getItemFromTile(final Object obj) { if (obj instanceof TileFluidInterface) { return ItemAndBlockHolder.INTERFACE.stack(); } @@ -188,9 +184,8 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, } @Override - public int getInstalledUpgrades( final Upgrades u ) - { - return getInterfaceDuality().getInstalledUpgrades( u ); + public int getInstalledUpgrades(final Upgrades u) { + return getInterfaceDuality().getInstalledUpgrades(u); } @Override @@ -232,7 +227,8 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, public void setConfig(int id, IAEFluidStack fluid) { if (id >= 0 && id < 6) { - config.setInventorySlotContents(id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack())); + config.setInventorySlotContents( + id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack())); fluidDuality.getConfig().setFluidInSlot(id, fluidDuality.getStandardFluid(fluid)); } } @@ -242,5 +238,4 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, getInternalFluid().setFluidInSlot(id, fluid); } } - } diff --git a/src/main/java/com/glodblock/github/common/tile/TileFluidPacketDecoder.java b/src/main/java/com/glodblock/github/common/tile/TileFluidPacketDecoder.java index c31ce0da..b8e9e41f 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidPacketDecoder.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidPacketDecoder.java @@ -66,7 +66,8 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab } IAEFluidStack aeFluid = AEFluidStack.create(fluid); IEnergyGrid energyGrid = node.getGrid().getCache(IEnergyGrid.class); - IMEMonitor fluidGrid = node.getGrid().getCache(IStorageGrid.class).getFluidInventory(); + IMEMonitor fluidGrid = + node.getGrid().getCache(IStorageGrid.class).getFluidInventory(); IAEFluidStack remaining = Platform.poweredInsert(energyGrid, fluidGrid, aeFluid, ownActionSource); if (remaining != null) { if (remaining.getStackSize() == aeFluid.getStackSize()) { @@ -81,7 +82,8 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) { + public void onChangeInventory( + IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) { try { getProxy().getTick().alertDevice(getProxy().getNode()); } catch (GridAccessException e) { @@ -89,13 +91,13 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab } } - @TileEvent( TileEventType.WORLD_NBT_WRITE ) + @TileEvent(TileEventType.WORLD_NBT_WRITE) public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { inventory.writeToNBT(data, "Inventory"); return data; } - @TileEvent( TileEventType.WORLD_NBT_READ ) + @TileEvent(TileEventType.WORLD_NBT_READ) public void readFromNBTEvent(NBTTagCompound data) { inventory.readFromNBT(data, "Inventory"); } diff --git a/src/main/java/com/glodblock/github/common/tile/TileFluidPatternEncoder.java b/src/main/java/com/glodblock/github/common/tile/TileFluidPatternEncoder.java index 5b31c50c..cbaae436 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidPatternEncoder.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidPatternEncoder.java @@ -10,17 +10,17 @@ import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.InvOperation; import com.glodblock.github.inventory.AeStackInventory; import com.glodblock.github.inventory.AeStackInventoryImpl; +import java.util.List; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import java.util.List; - public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInventory { private final AppEngInternalInventory patternInv = new AppEngInternalInventory(this, 2); - private final AeStackInventoryImpl crafting = new AeStackInventoryImpl<>(StorageChannel.ITEMS, 9, this); + private final AeStackInventoryImpl crafting = + new AeStackInventoryImpl<>(StorageChannel.ITEMS, 9, this); private final AeStackInventoryImpl output = new AeStackInventoryImpl<>(StorageChannel.ITEMS, 3, this); public IInventory getInventory() { @@ -41,7 +41,7 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve } @Override - public void getDrops(final World w, final int x, final int y, final int z, final List drops ) { + public void getDrops(final World w, final int x, final int y, final int z, final List drops) { for (ItemStack stack : patternInv) { if (stack != null) { drops.add(stack); @@ -49,14 +49,14 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve } } - @TileEvent( TileEventType.WORLD_NBT_READ ) + @TileEvent(TileEventType.WORLD_NBT_READ) public void readFromNBTEvent(NBTTagCompound data) { patternInv.readFromNBT(data, "Inventory"); crafting.readFromNbt(data, "CraftingSlots"); output.readFromNbt(data, "OutputSlots"); } - @TileEvent( TileEventType.WORLD_NBT_WRITE ) + @TileEvent(TileEventType.WORLD_NBT_WRITE) public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { patternInv.writeToNBT(data, "Inventory"); crafting.writeToNbt(data, "CraftingSlots"); @@ -65,8 +65,6 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve } @Override - public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) { - - } - + public void onChangeInventory( + IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {} } diff --git a/src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java b/src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java index 37135e4d..08994934 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileIngredientBuffer.java @@ -12,6 +12,8 @@ import com.glodblock.github.inventory.IAEFluidInventory; import com.glodblock.github.inventory.IAEFluidTank; import cpw.mods.fml.common.network.ByteBufUtils; import io.netty.buffer.ByteBuf; +import java.io.IOException; +import javax.annotation.Nonnull; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -21,9 +23,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import javax.annotation.Nonnull; -import java.io.IOException; - public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler { private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 9); @@ -51,7 +50,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven @Override public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) { - return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8}; + return new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8}; } @Override @@ -60,7 +59,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven markForUpdate(); } - @TileEvent( TileEventType.NETWORK_WRITE ) + @TileEvent(TileEventType.NETWORK_WRITE) protected void writeToStream(ByteBuf data) throws IOException { for (int i = 0; i < invItems.getSizeInventory(); i++) { ByteBufUtils.writeItemStack(data, invItems.getStackInSlot(i)); @@ -80,7 +79,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven } } - @TileEvent( TileEventType.NETWORK_READ ) + @TileEvent(TileEventType.NETWORK_READ) protected boolean readFromStream(ByteBuf data) throws IOException { boolean changed = false; for (int i = 0; i < invItems.getSizeInventory(); i++) { @@ -109,13 +108,13 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven return changed; } - @TileEvent( TileEventType.WORLD_NBT_READ ) + @TileEvent(TileEventType.WORLD_NBT_READ) public void readFromNBTEvent(NBTTagCompound data) { invItems.readFromNBT(data, "ItemInv"); invFluids.readFromNBT(data, "FluidInv"); } - @TileEvent( TileEventType.WORLD_NBT_WRITE ) + @TileEvent(TileEventType.WORLD_NBT_WRITE) public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { invItems.writeToNBT(data, "ItemInv"); invFluids.writeToNBT(data, "FluidInv"); diff --git a/src/main/java/com/glodblock/github/common/tile/TileLargeIngredientBuffer.java b/src/main/java/com/glodblock/github/common/tile/TileLargeIngredientBuffer.java index 90fd2056..33f5ebce 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileLargeIngredientBuffer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileLargeIngredientBuffer.java @@ -12,6 +12,8 @@ import com.glodblock.github.inventory.IAEFluidInventory; import com.glodblock.github.inventory.IAEFluidTank; import cpw.mods.fml.common.network.ByteBufUtils; import io.netty.buffer.ByteBuf; +import java.io.IOException; +import javax.annotation.Nonnull; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -21,9 +23,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import javax.annotation.Nonnull; -import java.io.IOException; - public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler { private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 27); @@ -51,7 +50,9 @@ public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluid @Override public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) { - return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}; + return new int[] { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 + }; } @Override diff --git a/src/main/java/com/glodblock/github/common/tile/TileOCPatternEditor.java b/src/main/java/com/glodblock/github/common/tile/TileOCPatternEditor.java index 2342aec8..79472e18 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileOCPatternEditor.java +++ b/src/main/java/com/glodblock/github/common/tile/TileOCPatternEditor.java @@ -24,12 +24,11 @@ public class TileOCPatternEditor extends AEBaseInvTile { @Override public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) { - return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + return new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; } @Override - public boolean isItemValidForSlot( final int i, final ItemStack itemstack ) { + public boolean isItemValidForSlot(final int i, final ItemStack itemstack) { return itemstack == null || itemstack.getItem() instanceof ItemEncodedPattern; } - } diff --git a/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java b/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java index 9068d8fc..a46ba000 100644 --- a/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java @@ -1,5 +1,8 @@ package com.glodblock.github.coremod; +import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; +import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS; + import com.glodblock.github.coremod.transform.*; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassReader; @@ -7,9 +10,6 @@ import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.ClassNode; -import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; -import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS; - public class FCClassTransformer implements IClassTransformer { @Override @@ -46,10 +46,9 @@ public class FCClassTransformer implements IClassTransformer { public interface Transform { byte[] transformClass(byte[] code); - } - public static abstract class ClassMapper implements Transform { + public abstract static class ClassMapper implements Transform { @Override public byte[] transformClass(byte[] code) { @@ -57,12 +56,12 @@ public class FCClassTransformer implements IClassTransformer { ClassReader reader = new ClassReader(code); reader.accept(classNode, 0); ClassWriter writer = new ClassWriter(reader, getWriteFlags()); - classNode.accept(getClassMapper(writer,classNode)); + classNode.accept(getClassMapper(writer, classNode)); return writer.toByteArray(); } protected int getWriteFlags() { - return COMPUTE_FRAMES|COMPUTE_MAXS; + return COMPUTE_FRAMES | COMPUTE_MAXS; } protected abstract ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode); diff --git a/src/main/java/com/glodblock/github/coremod/FluidCraftCore.java b/src/main/java/com/glodblock/github/coremod/FluidCraftCore.java index b3af1584..b75a8940 100644 --- a/src/main/java/com/glodblock/github/coremod/FluidCraftCore.java +++ b/src/main/java/com/glodblock/github/coremod/FluidCraftCore.java @@ -1,9 +1,8 @@ package com.glodblock.github.coremod; import cpw.mods.fml.relauncher.IFMLLoadingPlugin; - -import javax.annotation.Nullable; import java.util.Map; +import javax.annotation.Nullable; @IFMLLoadingPlugin.Name("FluidCraftCore") @IFMLLoadingPlugin.MCVersion("1.7.10") @@ -12,7 +11,7 @@ public class FluidCraftCore implements IFMLLoadingPlugin { @Override public String[] getASMTransformerClass() { - return new String[] { FluidCraftCore.class.getPackage().getName() + ".FCClassTransformer" }; + return new String[] {FluidCraftCore.class.getPackage().getName() + ".FCClassTransformer"}; } @Nullable @@ -37,5 +36,4 @@ public class FluidCraftCore implements IFMLLoadingPlugin { public String getAccessTransformerClass() { return null; } - } diff --git a/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java b/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java index 14a31a65..d70304c3 100644 --- a/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java +++ b/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java @@ -29,6 +29,9 @@ import com.glodblock.github.util.Ae2Reflect; import com.glodblock.github.util.SetBackedMachineSet; import com.glodblock.github.util.Util; import com.google.common.collect.Sets; +import java.util.HashSet; +import java.util.Set; +import javax.annotation.Nullable; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; @@ -36,14 +39,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import javax.annotation.Nullable; -import java.util.HashSet; -import java.util.Set; - public class CoreModHooks { public static InventoryCrafting wrapCraftingBuffer(InventoryCrafting inv) { - return new FluidConvertingInventoryCrafting(inv.eventHandler, inv.inventoryWidth, inv.getSizeInventory()/inv.inventoryWidth); + return new FluidConvertingInventoryCrafting( + inv.eventHandler, inv.inventoryWidth, inv.getSizeInventory() / inv.inventoryWidth); } public static IAEItemStack wrapFluidPacketStack(IAEItemStack stack) { @@ -61,8 +61,7 @@ public class CoreModHooks { if (stack != null && stack.getItem() instanceof ItemFluidPacket) { FluidStack fluid = ItemFluidPacket.getFluidStack(stack); return ItemFluidDrop.newStack(fluid); - } - else { + } else { return stack; } } @@ -74,7 +73,8 @@ public class CoreModHooks { public static long getCraftingByteCost(IAEItemStack stack) { return stack.getItem() instanceof ItemFluidDrop - ? (long)Math.ceil(stack.getStackSize() / 1000D) : stack.getStackSize(); + ? (long) Math.ceil(stack.getStackSize() / 1000D) + : stack.getStackSize(); } public static IAEItemStack[] flattenFluidPackets(IAEItemStack[] stacks) { @@ -102,7 +102,7 @@ public class CoreModHooks { } else if (b.isEmpty()) { return a; } else if (a instanceof MachineSet && b instanceof MachineSet) { - return new SetBackedMachineSet(TileInterface.class, Sets.union((MachineSet)a, (MachineSet)b)); + return new SetBackedMachineSet(TileInterface.class, Sets.union((MachineSet) a, (MachineSet) b)); } else { Set union = new HashSet<>(); a.forEach(union::add); @@ -115,36 +115,31 @@ public class CoreModHooks { if (aeStack.getItemStack() != null && aeStack.getItemStack().getItem() instanceof ItemFluidDrop) { FluidStack fluid = ItemFluidDrop.getFluidStack(aeStack.getItemStack()); return ItemFluidPacket.newDisplayStack(fluid); - } - else return aeStack.getItemStack(); + } else return aeStack.getItemStack(); } public static long getFluidSize(IAEItemStack aeStack) { if (aeStack.getItemStack() != null && aeStack.getItemStack().getItem() instanceof ItemFluidDrop) { return (long) Math.max(aeStack.getStackSize() / 1000D, 1); - } - else return aeStack.getStackSize(); + } else return aeStack.getStackSize(); } public static void storeFluidItem(CraftingCPUCluster instance) { final IGrid g = Ae2Reflect.getGrid(instance); - if( g == null ) - { + if (g == null) { return; } - final IStorageGrid sg = g.getCache( IStorageGrid.class ); + final IStorageGrid sg = g.getCache(IStorageGrid.class); final IMEInventory ii = sg.getItemInventory(); final IMEInventory jj = sg.getFluidInventory(); final MECraftingInventory inventory = Ae2Reflect.getCPUInventory(instance); - for( IAEItemStack is : inventory.getItemList() ) - { - is = inventory.extractItems( is.copy(), Actionable.MODULATE, Ae2Reflect.getCPUSource(instance) ); + for (IAEItemStack is : inventory.getItemList()) { + is = inventory.extractItems(is.copy(), Actionable.MODULATE, Ae2Reflect.getCPUSource(instance)); - if( is != null ) - { + if (is != null) { Ae2Reflect.postCPUChange(instance, is, Ae2Reflect.getCPUSource(instance)); if (is.getItem() instanceof ItemFluidDrop) { IAEFluidStack fluidDrop = ItemFluidDrop.getAeFluidStack(is); @@ -159,14 +154,12 @@ public class CoreModHooks { } } - if( is != null ) - { - inventory.injectItems( is, Actionable.MODULATE, Ae2Reflect.getCPUSource(instance) ); + if (is != null) { + inventory.injectItems(is, Actionable.MODULATE, Ae2Reflect.getCPUSource(instance)); } } - if( inventory.getItemList().isEmpty() ) - { + if (inventory.getItemList().isEmpty()) { Ae2Reflect.setCPUInventory(instance, new MECraftingInventory()); } @@ -174,21 +167,19 @@ public class CoreModHooks { } public ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) { - if (gui instanceof GuiCraftConfirm){ - return ((GuiCraftConfirm)gui).getHoveredStack(); + if (gui instanceof GuiCraftConfirm) { + return ((GuiCraftConfirm) gui).getHoveredStack(); } else if (gui instanceof GuiFluidCraftConfirm) { - return ((GuiFluidCraftConfirm)gui).getHoveredStack(); - } else if (gui instanceof GuiCraftingCPU){ - return ((GuiCraftingCPU)gui).getHoveredStack(); + return ((GuiFluidCraftConfirm) gui).getHoveredStack(); + } else if (gui instanceof GuiCraftingCPU) { + return ((GuiCraftingCPU) gui).getHoveredStack(); } return null; } + public boolean shouldShowTooltip(GuiContainer gui) { - if (gui instanceof GuiCraftConfirm) - return ((GuiCraftConfirm)gui).getHoveredStack() == null; - if (gui instanceof GuiCraftingCPU) - return ((GuiCraftingCPU)gui).getHoveredStack() == null; + if (gui instanceof GuiCraftConfirm) return ((GuiCraftConfirm) gui).getHoveredStack() == null; + if (gui instanceof GuiCraftingCPU) return ((GuiCraftingCPU) gui).getHoveredStack() == null; return true; } - } diff --git a/src/main/java/com/glodblock/github/coremod/transform/ContainerInterfaceTerminalTransformer.java b/src/main/java/com/glodblock/github/coremod/transform/ContainerInterfaceTerminalTransformer.java index 6ba6891e..66d26b3d 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/ContainerInterfaceTerminalTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/ContainerInterfaceTerminalTransformer.java @@ -28,11 +28,11 @@ public class ContainerInterfaceTerminalTransformer extends FCClassTransformer.Cl @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (name.equals("detectAndSendChanges") || name.equals("func_75142_b") || name.equals("regenList")) { - return new TransformDetectAndSendChanges(api, super.visitMethod(access, name, desc, signature, exceptions)); + return new TransformDetectAndSendChanges( + api, super.visitMethod(access, name, desc, signature, exceptions)); } return super.visitMethod(access, name, desc, signature, exceptions); } - } private static class TransformDetectAndSendChanges extends MethodVisitor { @@ -44,16 +44,17 @@ public class ContainerInterfaceTerminalTransformer extends FCClassTransformer.Cl @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (opcode == Opcodes.INVOKEINTERFACE - && owner.equals("appeng/api/networking/IGrid") && name.equals("getMachines")) { - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "getMachines", - "(Lappeng/api/networking/IGrid;Ljava/lang/Class;)Lappeng/api/networking/IMachineSet;", - false); + && owner.equals("appeng/api/networking/IGrid") + && name.equals("getMachines")) { + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "getMachines", + "(Lappeng/api/networking/IGrid;Ljava/lang/Class;)Lappeng/api/networking/IMachineSet;", + false); } else { super.visitMethodInsn(opcode, owner, name, desc, itf); } } - } } diff --git a/src/main/java/com/glodblock/github/coremod/transform/CraftingCpuTransformer.java b/src/main/java/com/glodblock/github/coremod/transform/CraftingCpuTransformer.java index 706ef57b..941947ce 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/CraftingCpuTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/CraftingCpuTransformer.java @@ -35,7 +35,6 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper { } return super.visitMethod(access, name, desc, signature, exceptions); } - } private static class TransformExecuteCrafting extends MethodVisitor { @@ -50,7 +49,8 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper { @Override public void visitFieldInsn(int opcode, String owner, String name, String desc) { if (opcode == Opcodes.GETFIELD - && owner.equals("appeng/me/cluster/implementations/CraftingCPUCluster") && name.equals("inventory")) { + && owner.equals("appeng/me/cluster/implementations/CraftingCPUCluster") + && name.equals("inventory")) { gotInventory = true; } super.visitFieldInsn(opcode, owner, name, desc); @@ -74,46 +74,53 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper { public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (reach_stack == 1) { if (opcode == Opcodes.INVOKEINTERFACE - && owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getStackSize")) { + && owner.equals("appeng/api/storage/data/IAEItemStack") + && name.equals("getStackSize")) { reach_stack = 2; - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "getFluidSize", - "(Lappeng/api/storage/data/IAEItemStack;)J", - false); + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "getFluidSize", + "(Lappeng/api/storage/data/IAEItemStack;)J", + false); return; } } if (opcode == Opcodes.INVOKEVIRTUAL - && owner.equals("net/minecraft/inventory/InventoryCrafting") && (name.equals("getStackInSlot") || name.equals("func_70301_a"))) { - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "removeFluidPackets", - "(Lnet/minecraft/inventory/InventoryCrafting;I)Lnet/minecraft/item/ItemStack;", - false); + && owner.equals("net/minecraft/inventory/InventoryCrafting") + && (name.equals("getStackInSlot") || name.equals("func_70301_a"))) { + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "removeFluidPackets", + "(Lnet/minecraft/inventory/InventoryCrafting;I)Lnet/minecraft/item/ItemStack;", + false); return; } super.visitMethodInsn(opcode, owner, name, desc, itf); if (gotInventory) { if (opcode == Opcodes.INVOKESTATIC - && owner.equals("appeng/util/item/AEItemStack") && name.equals("create")) { + && owner.equals("appeng/util/item/AEItemStack") + && name.equals("create")) { gotInventory = false; - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "wrapFluidPacketStack", - "(Lappeng/api/storage/data/IAEItemStack;)Lappeng/api/storage/data/IAEItemStack;", - false); + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "wrapFluidPacketStack", + "(Lappeng/api/storage/data/IAEItemStack;)Lappeng/api/storage/data/IAEItemStack;", + false); } } else if (opcode == Opcodes.INVOKESPECIAL - && owner.equals("net/minecraft/inventory/InventoryCrafting") && name.equals("")) { - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "wrapCraftingBuffer", - "(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/inventory/InventoryCrafting;", - false); + && owner.equals("net/minecraft/inventory/InventoryCrafting") + && name.equals("")) { + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "wrapCraftingBuffer", + "(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/inventory/InventoryCrafting;", + false); } } - } private static class TransformStoreItems extends MethodVisitor { @@ -125,18 +132,17 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper { @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (opcode == Opcodes.INVOKESPECIAL - && owner.equals("appeng/me/cluster/implementations/CraftingCPUCluster") && name.equals("storeItems")) { - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "storeFluidItem", - "(Lappeng/me/cluster/implementations/CraftingCPUCluster;)V", - false - ); + && owner.equals("appeng/me/cluster/implementations/CraftingCPUCluster") + && name.equals("storeItems")) { + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "storeFluidItem", + "(Lappeng/me/cluster/implementations/CraftingCPUCluster;)V", + false); } else { super.visitMethodInsn(opcode, owner, name, desc, itf); } } - } - } diff --git a/src/main/java/com/glodblock/github/coremod/transform/CraftingTreeNodeTransformer.java b/src/main/java/com/glodblock/github/coremod/transform/CraftingTreeNodeTransformer.java index 7a0e9ab4..b2433954 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/CraftingTreeNodeTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/CraftingTreeNodeTransformer.java @@ -33,7 +33,6 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper } return super.visitMethod(access, name, desc, signature, exceptions); } - } private static class TransformRequest extends MethodVisitor { @@ -46,7 +45,9 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper @Override public void visitFieldInsn(int opcode, String owner, String name, String desc) { - if (opcode == Opcodes.GETFIELD && owner.equals("appeng/crafting/CraftingTreeNode") && name.equals("bytes")) { + if (opcode == Opcodes.GETFIELD + && owner.equals("appeng/crafting/CraftingTreeNode") + && name.equals("bytes")) { writingBytes = true; } super.visitFieldInsn(opcode, owner, name, desc); @@ -60,19 +61,20 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { - if (writingBytes && opcode == Opcodes.INVOKEINTERFACE - && owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getStackSize")) { + if (writingBytes + && opcode == Opcodes.INVOKEINTERFACE + && owner.equals("appeng/api/storage/data/IAEItemStack") + && name.equals("getStackSize")) { writingBytes = false; - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "getCraftingByteCost", - "(Lappeng/api/storage/data/IAEItemStack;)J", - false); + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "getCraftingByteCost", + "(Lappeng/api/storage/data/IAEItemStack;)J", + false); } else { super.visitMethodInsn(opcode, owner, name, desc, itf); } } - } - } diff --git a/src/main/java/com/glodblock/github/coremod/transform/DualityInterfaceTransformer.java b/src/main/java/com/glodblock/github/coremod/transform/DualityInterfaceTransformer.java index c4e4cb91..9ab85008 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/DualityInterfaceTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/DualityInterfaceTransformer.java @@ -31,12 +31,12 @@ public class DualityInterfaceTransformer extends FCClassTransformer.ClassMapper case "pushItemsOut": case "pushPattern": case "isBusy": - return new TransformInvAdaptorCalls(api, super.visitMethod(access, name, desc, signature, exceptions)); + return new TransformInvAdaptorCalls( + api, super.visitMethod(access, name, desc, signature, exceptions)); default: return super.visitMethod(access, name, desc, signature, exceptions); } } - } private static class TransformInvAdaptorCalls extends MethodVisitor { @@ -47,17 +47,18 @@ public class DualityInterfaceTransformer extends FCClassTransformer.ClassMapper @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { - if (opcode == Opcodes.INVOKESTATIC && owner.equals("appeng/util/InventoryAdaptor") && name.equals("getAdaptor")) { - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "wrapInventory", - "(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraftforge/common/util/ForgeDirection;)Lappeng/util/InventoryAdaptor;", - false); + if (opcode == Opcodes.INVOKESTATIC + && owner.equals("appeng/util/InventoryAdaptor") + && name.equals("getAdaptor")) { + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "wrapInventory", + "(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraftforge/common/util/ForgeDirection;)Lappeng/util/InventoryAdaptor;", + false); } else { super.visitMethodInsn(opcode, owner, name, desc, itf); } } - } - } diff --git a/src/main/java/com/glodblock/github/coremod/transform/GuiCraftingTransformer.java b/src/main/java/com/glodblock/github/coremod/transform/GuiCraftingTransformer.java index 9ec22c49..4cc8b593 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/GuiCraftingTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/GuiCraftingTransformer.java @@ -32,7 +32,6 @@ public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper { } return super.visitMethod(access, name, desc, signature, exceptions); } - } private static class TransformFluidIcon extends MethodVisitor { @@ -43,17 +42,18 @@ public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper { @Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { - if (opcode == Opcodes.INVOKEINTERFACE && owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getItemStack")) { - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "displayFluid", - "(Lappeng/api/storage/data/IAEItemStack;)Lnet/minecraft/item/ItemStack;", - false); - } - else { + if (opcode == Opcodes.INVOKEINTERFACE + && owner.equals("appeng/api/storage/data/IAEItemStack") + && name.equals("getItemStack")) { + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "displayFluid", + "(Lappeng/api/storage/data/IAEItemStack;)Lnet/minecraft/item/ItemStack;", + false); + } else { super.visitMethodInsn(opcode, owner, name, desc, itf); } } - } } diff --git a/src/main/java/com/glodblock/github/coremod/transform/NEITransfermer.java b/src/main/java/com/glodblock/github/coremod/transform/NEITransfermer.java index b1bf66be..69a6cfbf 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/NEITransfermer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/NEITransfermer.java @@ -1,29 +1,26 @@ package com.glodblock.github.coremod.transform; +import static org.objectweb.asm.Opcodes.*; + import com.glodblock.github.coremod.FCClassTransformer; import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.*; -import static org.objectweb.asm.Opcodes.*; - -public class NEITransfermer extends FCClassTransformer.ClassMapper{ +public class NEITransfermer extends FCClassTransformer.ClassMapper { public static final NEITransfermer INSTANCE = new NEITransfermer(); - private NEITransfermer(){} + private NEITransfermer() {} @Override protected ClassVisitor getClassMapper(ClassVisitor downstream, ClassNode classNode) { - for (MethodNode method : classNode.methods){ - if(method.name.equals("getStackUnderMouse") || method.name.equals("shouldShowTooltip")){ + for (MethodNode method : classNode.methods) { + if (method.name.equals("getStackUnderMouse") || method.name.equals("shouldShowTooltip")) { AbstractInsnNode targetNode = null; - for (AbstractInsnNode instruction : method.instructions.toArray()) - { - if (instruction.getOpcode() == ALOAD) - { + for (AbstractInsnNode instruction : method.instructions.toArray()) { + if (instruction.getOpcode() == ALOAD) { targetNode = instruction; break; } @@ -35,10 +32,15 @@ public class NEITransfermer extends FCClassTransformer.ClassMapper{ toInsert.add(new JumpInsnNode(IFEQ, label0)); toInsert.add(new VarInsnNode(ALOAD, 1)); toInsert.add(new TypeInsnNode(CHECKCAST, "com/glodblock/github/client/gui/GuiFluidCraftConfirm")); - toInsert.add(new MethodInsnNode(INVOKEVIRTUAL, "com/glodblock/github/client/gui/GuiFluidCraftConfirm", "getHoveredStack", "()Lnet/minecraft/item/ItemStack;", false)); - if(method.name.equals("getStackUnderMouse")){ + toInsert.add(new MethodInsnNode( + INVOKEVIRTUAL, + "com/glodblock/github/client/gui/GuiFluidCraftConfirm", + "getHoveredStack", + "()Lnet/minecraft/item/ItemStack;", + false)); + if (method.name.equals("getStackUnderMouse")) { toInsert.add(new InsnNode(ARETURN)); - }else{ + } else { LabelNode label1 = new LabelNode(); toInsert.add(new JumpInsnNode(IFNONNULL, label1)); toInsert.add(new InsnNode(ICONST_1)); @@ -50,15 +52,17 @@ public class NEITransfermer extends FCClassTransformer.ClassMapper{ toInsert.add(new InsnNode(IRETURN)); } toInsert.add(label0); - method.instructions.insertBefore(targetNode,toInsert); + method.instructions.insertBefore(targetNode, toInsert); } } return new NEITransfermer.TransformNEI(Opcodes.ASM5, downstream); } + private static class TransformNEI extends ClassVisitor { TransformNEI(int api, ClassVisitor cv) { super(api, cv); } + @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { return super.visitMethod(access, name, desc, signature, exceptions); diff --git a/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverOCPatternEditor.java b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverOCPatternEditor.java index 94e24055..d61a45e9 100644 --- a/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverOCPatternEditor.java +++ b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverOCPatternEditor.java @@ -29,8 +29,7 @@ import net.minecraftforge.fluids.FluidStack; public class DriverOCPatternEditor extends DriverSidedTileEntity { - public DriverOCPatternEditor() { - } + public DriverOCPatternEditor() {} @Override public Class getTileEntityClass() { @@ -42,8 +41,7 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { return new DriverOCPatternEditor.Environment((TileOCPatternEditor) world.getTileEntity(x, y, z)); } - public static class Environment extends ManagedTileEntityEnvironment - implements NamedBlock { + public static class Environment extends ManagedTileEntityEnvironment implements NamedBlock { public Environment(TileOCPatternEditor tileEntity) { super(tileEntity, NameConst.BLOCK_OC_PATTERN_EDITOR); @@ -56,8 +54,7 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { throw new IllegalArgumentException("invalid slot"); } return slot; - } - else { + } else { return def; } } @@ -69,8 +66,7 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { throw new IllegalArgumentException("invalid slot"); } return slot; - } - else { + } else { throw new IllegalArgumentException("invalid slot"); } } @@ -79,7 +75,8 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { if (pattern == null) { throw new IllegalArgumentException("No pattern here!"); } - if (pattern.getItem() instanceof ItemEncodedPattern && !(pattern.getItem() instanceof ItemFluidEncodedPattern)) { + if (pattern.getItem() instanceof ItemEncodedPattern + && !(pattern.getItem() instanceof ItemFluidEncodedPattern)) { ItemEncodedPattern iep = (ItemEncodedPattern) pattern.getItem(); return iep.getOutput(pattern) == null; } @@ -95,8 +92,7 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { address = args.checkString(0); entry = args.checkInteger(1); size = args.optInteger(2, 1); - } - else { + } else { address = args.checkString(1); entry = args.checkInteger(2); size = args.optInteger(3, 1); @@ -107,21 +103,17 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { ItemStack dbStack = ((Database) node.host()).getStackInSlot(entry - 1); if (dbStack == null || size < 1) { return null; - } - else { + } else { dbStack.stackSize = Math.min(size, dbStack.getMaxStackSize()); return dbStack; } - } - else { + } else { throw new IllegalArgumentException("not a database"); } - } - else { + } else { throw new IllegalArgumentException("no such component"); } - } - else { + } else { return null; } } @@ -132,12 +124,10 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { if (validPattern(pattern)) { NBTTagCompound encodedValue = pattern.getTagCompound(); int slot = checkSlot(args, inv, 0); - if (encodedValue == null) - throw new IllegalArgumentException("No pattern here!"); + if (encodedValue == null) throw new IllegalArgumentException("No pattern here!"); NBTTagList nbt = encodedValue.getTagList(tag, 10); int index = args.checkInteger(1) - 1; - if (index < 0) - throw new IllegalArgumentException("Invalid index!"); + if (index < 0) throw new IllegalArgumentException("Invalid index!"); nbt.removeTag(index); encodedValue.setTag(tag, nbt); pattern.setTagCompound(encodedValue); @@ -159,24 +149,20 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { stack = ItemFluidDrop.newStack(fluids); } int index = args.checkInteger(4) - 1; - if (index < 0 || index > 511) - throw new IllegalArgumentException("Invalid index!"); + if (index < 0 || index > 511) throw new IllegalArgumentException("Invalid index!"); ItemStack pattern = inv.getStackInSlot(slot); if (validPattern(pattern)) { NBTTagCompound encodedValue = pattern.getTagCompound(); - if (encodedValue == null) - throw new IllegalArgumentException("No pattern here!"); + if (encodedValue == null) throw new IllegalArgumentException("No pattern here!"); NBTTagList inTag = encodedValue.getTagList(tag, 10); - while (inTag.tagCount() <= index) - inTag.appendTag(new NBTTagCompound()); + while (inTag.tagCount() <= index) inTag.appendTag(new NBTTagCompound()); if (stack != null) { NBTTagCompound nbt = new NBTTagCompound(); AEItemStack aeStack = AEItemStack.create(stack); aeStack.writeToNBT(nbt); inTag.func_150304_a(index, nbt); - } - else { + } else { inTag.removeTag(index); } encodedValue.setTag(tag, inTag); @@ -194,14 +180,16 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { public Object[] getInterfaceConfiguration(Context context, Arguments args) { IInventory config = tileEntity.getInternalInventory(); int slot = optSlot(args, config, 0, 0); - ItemStack stack = config.getStackInSlot(slot); - if (!validPattern(stack )) { + ItemStack stack = config.getStackInSlot(slot); + if (!validPattern(stack)) { throw new IllegalArgumentException("Not Fluid Encoded pattern!"); } - return new Object[]{stack}; + return new Object[] {stack}; } - @Callback(doc = "function([slot:number][, database:address, entry:number[, size:number]]):boolean -- Configure the interface.") + @Callback( + doc = + "function([slot:number][, database:address, entry:number[, size:number]]):boolean -- Configure the interface.") public Object[] setInterfaceConfiguration(Context context, Arguments args) { IInventory config = tileEntity.getInternalInventory(); int slot = args.isString(0) ? 0 : optSlot(args, config, 0, 0); @@ -218,22 +206,30 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { return new Object[] {stack}; } - @Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item input at the given index.") + @Callback( + doc = + "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item input at the given index.") public Object[] setInterfacePatternItemInput(Context context, Arguments args) { return setPatternSlot(context, args, "in", false); } - @Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item output at the given index.") + @Callback( + doc = + "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item output at the given index.") public Object[] setInterfacePatternItemOutput(Context context, Arguments args) { return setPatternSlot(context, args, "out", false); } - @Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid input at the given index.") + @Callback( + doc = + "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid input at the given index.") public Object[] setInterfacePatternFluidInput(Context context, Arguments args) { return setPatternSlot(context, args, "in", true); } - @Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid output at the given index.") + @Callback( + doc = + "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid output at the given index.") public Object[] setInterfacePatternFluidOutput(Context context, Arguments args) { return setPatternSlot(context, args, "out", true); } @@ -260,8 +256,7 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { } public static class Provider implements EnvironmentProvider { - Provider() { - } + Provider() {} @Override public Class getEnvironment(ItemStack itemStack) { @@ -271,5 +266,4 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity { return null; } } - } diff --git a/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java b/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java index 35cd6554..b67b4ee0 100644 --- a/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java +++ b/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java @@ -8,5 +8,4 @@ public class OCDriverInit { Driver.add(new DriverOCPatternEditor()); Driver.add(new DriverOCPatternEditor.Provider()); } - } diff --git a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java index 7365fba2..5696c474 100644 --- a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java +++ b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java @@ -12,192 +12,154 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidTank; -public class AEFluidInventory implements IAEFluidTank -{ +public class AEFluidInventory implements IAEFluidTank { private final IAEFluidStack[] fluids; private final IAEFluidInventory handler; private final int capacity; - public AEFluidInventory( final IAEFluidInventory handler, final int slots, final int capcity ) - { + public AEFluidInventory(final IAEFluidInventory handler, final int slots, final int capcity) { this.fluids = new IAEFluidStack[slots]; this.handler = handler; this.capacity = capcity; } - public AEFluidInventory( final IAEFluidInventory handler, final int slots ) - { - this( handler, slots, Integer.MAX_VALUE ); + public AEFluidInventory(final IAEFluidInventory handler, final int slots) { + this(handler, slots, Integer.MAX_VALUE); } @Override - public void setFluidInSlot( final int slot, final IAEFluidStack fluid ) - { - if( slot >= 0 && slot < this.getSlots() ) - { - if( fluid != null && this.fluids[slot] != null && fluid.getFluidStack().isFluidEqual(this.fluids[slot].getFluidStack()) ) - { - if(fluid.getStackSize() != this.fluids[slot].getStackSize()) - { - this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) ); - this.onContentChanged( slot ); + public void setFluidInSlot(final int slot, final IAEFluidStack fluid) { + if (slot >= 0 && slot < this.getSlots()) { + if (fluid != null + && this.fluids[slot] != null + && fluid.getFluidStack().isFluidEqual(this.fluids[slot].getFluidStack())) { + if (fluid.getStackSize() != this.fluids[slot].getStackSize()) { + this.fluids[slot].setStackSize(Math.min(fluid.getStackSize(), this.capacity)); + this.onContentChanged(slot); } - } - else - { - if( fluid == null ) - { + } else { + if (fluid == null) { this.fluids[slot] = null; - } - else - { + } else { this.fluids[slot] = fluid.copy(); - this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) ); + this.fluids[slot].setStackSize(Math.min(fluid.getStackSize(), this.capacity)); } - this.onContentChanged( slot ); + this.onContentChanged(slot); } } } - private void onContentChanged( final int slot ) - { - if( this.handler != null && Platform.isServer() ) - { - this.handler.onFluidInventoryChanged( this, slot ); + private void onContentChanged(final int slot) { + if (this.handler != null && Platform.isServer()) { + this.handler.onFluidInventoryChanged(this, slot); } } @Override - public IAEFluidStack getFluidInSlot( final int slot ) - { - if( slot >= 0 && slot < this.getSlots() ) - { + public IAEFluidStack getFluidInSlot(final int slot) { + if (slot >= 0 && slot < this.getSlots()) { return this.fluids[slot]; } return null; } - public FluidStack getFluidStackInSlot( final int slot ) - { - if( getFluidInSlot(slot) != null ) - { + public FluidStack getFluidStackInSlot(final int slot) { + if (getFluidInSlot(slot) != null) { return getFluidInSlot(slot).getFluidStack(); } return null; } @Override - public int getSlots() - { + public int getSlots() { return this.fluids.length; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { + public FluidTankInfo[] getTankInfo(ForgeDirection from) { FluidTankInfo[] props = new FluidTankInfo[this.getSlots()]; - for( int i = 0; i < this.getSlots(); ++i ) - { - props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper( i )); + for (int i = 0; i < this.getSlots(); ++i) { + props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper(i)); } return props; } - public int fill( final int slot, final FluidStack resource, final boolean doFill ) - { - if( resource == null || resource.amount <= 0 ) - { + public int fill(final int slot, final FluidStack resource, final boolean doFill) { + if (resource == null || resource.amount <= 0) { return 0; } final IAEFluidStack fluid = this.fluids[slot]; - if( fluid != null && !fluid.getFluidStack().isFluidEqual( resource ) ) - { + if (fluid != null && !fluid.getFluidStack().isFluidEqual(resource)) { return 0; } int amountToStore = this.capacity; - if( fluid != null ) - { + if (fluid != null) { amountToStore -= fluid.getStackSize(); } - amountToStore = Math.min( amountToStore, resource.amount ); + amountToStore = Math.min(amountToStore, resource.amount); - if( doFill ) - { - if( fluid == null ) - { - this.setFluidInSlot( slot, AEFluidStack.create( resource ) ); - } - else - { - fluid.setStackSize( fluid.getStackSize() + amountToStore ); - this.onContentChanged( slot ); + if (doFill) { + if (fluid == null) { + this.setFluidInSlot(slot, AEFluidStack.create(resource)); + } else { + fluid.setStackSize(fluid.getStackSize() + amountToStore); + this.onContentChanged(slot); } } return amountToStore; } - public FluidStack drain( final int slot, final FluidStack resource, final boolean doDrain ) - { + public FluidStack drain(final int slot, final FluidStack resource, final boolean doDrain) { final IAEFluidStack fluid = this.fluids[slot]; - if(fluid == null || !fluid.getFluidStack().isFluidEqual(resource)) - { + if (fluid == null || !fluid.getFluidStack().isFluidEqual(resource)) { return null; } - return this.drain( slot, resource.amount, doDrain ); + return this.drain(slot, resource.amount, doDrain); } - public FluidStack drain( final int slot, final int maxDrain, boolean doDrain ) - { + public FluidStack drain(final int slot, final int maxDrain, boolean doDrain) { final IAEFluidStack fluid = this.fluids[slot]; - if( fluid == null || maxDrain <= 0 ) - { + if (fluid == null || maxDrain <= 0) { return null; } int drained = maxDrain; - if( fluid.getStackSize() < drained ) - { + if (fluid.getStackSize() < drained) { drained = (int) fluid.getStackSize(); } - FluidStack stack = new FluidStack( fluid.getFluid(), drained ); - if( doDrain ) - { - fluid.setStackSize( fluid.getStackSize() - drained ); - if( fluid.getStackSize() <= 0 ) - { + FluidStack stack = new FluidStack(fluid.getFluid(), drained); + if (doDrain) { + fluid.setStackSize(fluid.getStackSize() - drained); + if (fluid.getStackSize() <= 0) { this.fluids[slot] = null; } - this.onContentChanged( slot ); + this.onContentChanged(slot); } return stack; } @Override - public int fill(ForgeDirection from, final FluidStack fluid, final boolean doFill ) - { - if( fluid == null || fluid.amount <= 0 ) - { + public int fill(ForgeDirection from, final FluidStack fluid, final boolean doFill) { + if (fluid == null || fluid.amount <= 0) { return 0; } final FluidStack insert = fluid.copy(); int totalFillAmount = 0; - for( int slot = 0; slot < this.getSlots(); ++slot ) - { - int fillAmount = this.fill( slot, insert, doFill ); + for (int slot = 0; slot < this.getSlots(); ++slot) { + int fillAmount = this.fill(slot, insert, doFill); totalFillAmount += fillAmount; insert.amount -= fillAmount; - if( insert.amount <= 0 ) - { + if (insert.amount <= 0) { break; } } @@ -205,36 +167,28 @@ public class AEFluidInventory implements IAEFluidTank } @Override - public FluidStack drain(ForgeDirection from, final FluidStack fluid, final boolean doDrain ) - { - if( fluid == null || fluid.amount <= 0 ) - { + public FluidStack drain(ForgeDirection from, final FluidStack fluid, final boolean doDrain) { + if (fluid == null || fluid.amount <= 0) { return null; } final FluidStack resource = fluid.copy(); FluidStack totalDrained = null; - for( int slot = 0; slot < this.getSlots(); ++slot ) - { + for (int slot = 0; slot < this.getSlots(); ++slot) { if (!fluid.isFluidEqual(getFluidStackInSlot(slot))) { continue; } - FluidStack drain = this.drain( slot, resource, doDrain ); - if( drain != null ) - { - if( totalDrained == null ) - { + FluidStack drain = this.drain(slot, resource, doDrain); + if (drain != null) { + if (totalDrained == null) { totalDrained = drain; - } - else - { + } else { totalDrained.amount += drain.amount; } resource.amount -= drain.amount; - if( resource.amount <= 0 ) - { + if (resource.amount <= 0) { break; } } @@ -243,44 +197,35 @@ public class AEFluidInventory implements IAEFluidTank } @Override - public FluidStack drain( ForgeDirection from, final int maxDrain, final boolean doDrain ) - { - if( maxDrain == 0 ) - { + public FluidStack drain(ForgeDirection from, final int maxDrain, final boolean doDrain) { + if (maxDrain == 0) { return null; } FluidStack totalDrained = null; int toDrain = maxDrain; - for( int slot = 0; slot < this.getSlots(); ++slot ) - { + for (int slot = 0; slot < this.getSlots(); ++slot) { if (this.getFluidInSlot(slot) == null) { continue; } - if( totalDrained == null ) - { - totalDrained = this.drain( slot, toDrain, doDrain ); - if( totalDrained != null ) - { + if (totalDrained == null) { + totalDrained = this.drain(slot, toDrain, doDrain); + if (totalDrained != null) { toDrain -= totalDrained.amount; } - } - else - { + } else { FluidStack copy = totalDrained.copy(); copy.amount = toDrain; - FluidStack drain = this.drain( slot, copy, doDrain ); - if( drain != null ) - { + FluidStack drain = this.drain(slot, copy, doDrain); + if (drain != null) { totalDrained.amount += drain.amount; toDrain -= drain.amount; } } - if( toDrain <= 0 ) - { + if (toDrain <= 0) { break; } } @@ -297,76 +242,60 @@ public class AEFluidInventory implements IAEFluidTank return drain(from, new FluidStack(fluid, 1), false) != null; } - public void writeToNBT( final NBTTagCompound data, final String name ) - { + public void writeToNBT(final NBTTagCompound data, final String name) { final NBTTagCompound c = new NBTTagCompound(); - this.writeToNBT( c ); - data.setTag( name, c ); + this.writeToNBT(c); + data.setTag(name, c); } - private void writeToNBT( final NBTTagCompound target ) - { - for( int x = 0; x < this.fluids.length; x++ ) - { - try - { + private void writeToNBT(final NBTTagCompound target) { + for (int x = 0; x < this.fluids.length; x++) { + try { final NBTTagCompound c = new NBTTagCompound(); - if( this.fluids[x] != null ) - { - this.fluids[x].writeToNBT( c ); + if (this.fluids[x] != null) { + this.fluids[x].writeToNBT(c); } - target.setTag( "#" + x, c ); - } - catch( final Exception ignored ) - { + target.setTag("#" + x, c); + } catch (final Exception ignored) { } } } - public void readFromNBT( final NBTTagCompound data, final String name ) - { - final NBTTagCompound c = data.getCompoundTag( name ); - if( c != null ) - { - this.readFromNBT( c ); + public void readFromNBT(final NBTTagCompound data, final String name) { + final NBTTagCompound c = data.getCompoundTag(name); + if (c != null) { + this.readFromNBT(c); } } - private void readFromNBT( final NBTTagCompound target ) - { - for( int x = 0; x < this.fluids.length; x++ ) - { - try - { - final NBTTagCompound c = target.getCompoundTag( "#" + x ); + private void readFromNBT(final NBTTagCompound target) { + for (int x = 0; x < this.fluids.length; x++) { + try { + final NBTTagCompound c = target.getCompoundTag("#" + x); - if( c != null ) - { - this.fluids[x] = Util.loadFluidStackFromNBT( c ); + if (c != null) { + this.fluids[x] = Util.loadFluidStackFromNBT(c); } - } - catch( final Exception e ) - { - AELog.debug( e ); + } catch (final Exception e) { + AELog.debug(e); } } } - private class FluidTankPropertiesWrapper implements IFluidTank - { + private class FluidTankPropertiesWrapper implements IFluidTank { private final int slot; - public FluidTankPropertiesWrapper( final int slot ) - { + public FluidTankPropertiesWrapper(final int slot) { this.slot = slot; } @Override - public FluidStack getFluid() - { - return AEFluidInventory.this.fluids[this.slot] == null ? null : AEFluidInventory.this.fluids[this.slot].getFluidStack(); + public FluidStack getFluid() { + return AEFluidInventory.this.fluids[this.slot] == null + ? null + : AEFluidInventory.this.fluids[this.slot].getFluidStack(); } @Override @@ -375,9 +304,8 @@ public class AEFluidInventory implements IAEFluidTank } @Override - public int getCapacity() - { - return Math.min( AEFluidInventory.this.capacity, Integer.MAX_VALUE ); + public int getCapacity() { + return Math.min(AEFluidInventory.this.capacity, Integer.MAX_VALUE); } @Override @@ -397,7 +325,8 @@ public class AEFluidInventory implements IAEFluidTank } if (doFill) { if (getFluid() == null) - AEFluidInventory.this.setFluidInSlot(this.slot, AEFluidStack.create(new FluidStack(resource.getFluid(), acc))); + AEFluidInventory.this.setFluidInSlot( + this.slot, AEFluidStack.create(new FluidStack(resource.getFluid(), acc))); else getFluid().amount += acc; } return acc; @@ -412,8 +341,7 @@ public class AEFluidInventory implements IAEFluidTank if (doDrain) { if (amt == getFluid().amount) { AEFluidInventory.this.setFluidInSlot(this.slot, null); - } - else getFluid().amount -= amt; + } else getFluid().amount -= amt; } return remove; } diff --git a/src/main/java/com/glodblock/github/inventory/AeItemStackHandler.java b/src/main/java/com/glodblock/github/inventory/AeItemStackHandler.java index 01305c0f..c0d2640e 100644 --- a/src/main/java/com/glodblock/github/inventory/AeItemStackHandler.java +++ b/src/main/java/com/glodblock/github/inventory/AeItemStackHandler.java @@ -38,9 +38,7 @@ public class AeItemStackHandler implements IInventory { } @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - - } + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {} @Override public String getInventoryName() { @@ -58,8 +56,7 @@ public class AeItemStackHandler implements IInventory { } @Override - public void markDirty() { - } + public void markDirty() {} @Override public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { @@ -67,18 +64,13 @@ public class AeItemStackHandler implements IInventory { } @Override - public void openInventory() { - - } + public void openInventory() {} @Override - public void closeInventory() { - - } + public void closeInventory() {} @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { return false; } - } diff --git a/src/main/java/com/glodblock/github/inventory/AeStackInventory.java b/src/main/java/com/glodblock/github/inventory/AeStackInventory.java index 2dba2d2c..aac67dc0 100644 --- a/src/main/java/com/glodblock/github/inventory/AeStackInventory.java +++ b/src/main/java/com/glodblock/github/inventory/AeStackInventory.java @@ -1,9 +1,8 @@ package com.glodblock.github.inventory; import appeng.api.storage.data.IAEStack; - -import javax.annotation.Nullable; import java.util.stream.Stream; +import javax.annotation.Nullable; public interface AeStackInventory> extends Iterable { @@ -15,5 +14,4 @@ public interface AeStackInventory> extends Iterable { void setStack(int slot, @Nullable T stack); Stream stream(); - } diff --git a/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java b/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java index 4fc6feac..d7eb896f 100644 --- a/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java +++ b/src/main/java/com/glodblock/github/inventory/AeStackInventoryImpl.java @@ -6,16 +6,15 @@ import appeng.tile.inventory.IAEAppEngInventory; import appeng.util.item.AEItemStack; import com.glodblock.github.util.ObjectArrayIterator; import com.glodblock.github.util.Util; +import java.util.Arrays; +import java.util.Iterator; +import java.util.stream.Stream; +import javax.annotation.Nullable; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants; -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.Iterator; -import java.util.stream.Stream; - -public class AeStackInventoryImpl > implements AeStackInventory { +public class AeStackInventoryImpl> implements AeStackInventory { private final StorageChannel channel; private final T[] inv; @@ -24,7 +23,7 @@ public class AeStackInventoryImpl > implements AeStackInve @SuppressWarnings("unchecked") public AeStackInventoryImpl(StorageChannel channel, int slotCount, @Nullable IAEAppEngInventory owner) { this.channel = channel; - this.inv = (T[])new IAEStack[slotCount]; + this.inv = (T[]) new IAEStack[slotCount]; this.owner = owner; } @@ -88,8 +87,7 @@ public class AeStackInventoryImpl > implements AeStackInve NBTTagCompound stackTag = stacksTag.getCompoundTagAt(i); if (channel == StorageChannel.ITEMS) { inv[i] = stackTag == null ? null : (T) AEItemStack.loadItemStackFromNBT(stackTag); - } - else { + } else { inv[i] = stackTag == null ? null : (T) Util.loadFluidStackFromNBT(stackTag); } } @@ -98,5 +96,4 @@ public class AeStackInventoryImpl > implements AeStackInve public void readFromNbt(NBTTagCompound parentTag, String key) { readFromNbt(parentTag.getCompoundTag(key)); } - } diff --git a/src/main/java/com/glodblock/github/inventory/BiggerAppEngInventory.java b/src/main/java/com/glodblock/github/inventory/BiggerAppEngInventory.java index 43143dda..acef1370 100644 --- a/src/main/java/com/glodblock/github/inventory/BiggerAppEngInventory.java +++ b/src/main/java/com/glodblock/github/inventory/BiggerAppEngInventory.java @@ -53,5 +53,4 @@ public class BiggerAppEngInventory extends AppEngInternalInventory { } } } - } diff --git a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java index 4cdb6241..57426e51 100644 --- a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java +++ b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java @@ -12,6 +12,9 @@ import com.glodblock.github.common.parts.PartFluidInterface; import com.glodblock.github.common.tile.TileFluidInterface; import com.glodblock.github.util.Ae2Reflect; import com.glodblock.github.util.Util; +import java.util.Collections; +import java.util.Iterator; +import javax.annotation.Nullable; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -20,17 +23,19 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.Iterator; - public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { public static InventoryAdaptor wrap(TileEntity capProvider, EnumFacing face) { // sometimes i wish 1.7.10 has cap system. ForgeDirection f = Util.from(face); - TileEntity inter = capProvider.getWorldObj().getTileEntity(capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ); - if (!Config.noFluidPacket && !(inter instanceof TileFluidInterface || (inter instanceof TileCableBus && ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface))) + TileEntity inter = capProvider + .getWorldObj() + .getTileEntity( + capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ); + if (!Config.noFluidPacket + && !(inter instanceof TileFluidInterface + || (inter instanceof TileCableBus + && ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface))) return InventoryAdaptor.getAdaptor(capProvider, f); InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, f); IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null; @@ -41,13 +46,14 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { private final IFluidHandler invFluids; private final ForgeDirection side; - public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids, EnumFacing facing) { + public FluidConvertingInventoryAdaptor( + @Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids, EnumFacing facing) { this.invItems = invItems; this.invFluids = invFluids; this.side = Util.from(facing); } - public ItemStack addItems( ItemStack toBeAdded,InsertionMode insertionMode ) { + public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) { if (toBeAdded.getItem() instanceof ItemFluidPacket) { if (invFluids != null) { FluidStack fluid = ItemFluidPacket.getFluidStack(toBeAdded); @@ -61,19 +67,21 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } return toBeAdded; } - return invItems != null ? invItems.addItems(toBeAdded,insertionMode) : toBeAdded; + return invItems != null ? invItems.addItems(toBeAdded, insertionMode) : toBeAdded; } @Override public ItemStack addItems(ItemStack toBeAdded) { - return addItems(toBeAdded,InsertionMode.DEFAULT); + return addItems(toBeAdded, InsertionMode.DEFAULT); } + @Override public ItemStack simulateAdd(ItemStack toBeSimulated) { - return simulateAdd(toBeSimulated,InsertionMode.DEFAULT); + return simulateAdd(toBeSimulated, InsertionMode.DEFAULT); } + @Override - public ItemStack simulateAdd(ItemStack toBeSimulated,InsertionMode insertionMode) { + public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) { if (toBeSimulated.getItem() instanceof ItemFluidPacket) { if (invFluids != null) { FluidStack fluid = ItemFluidPacket.getFluidStack(toBeSimulated); @@ -87,7 +95,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } return toBeSimulated; } - return invItems != null ? invItems.simulateAdd(toBeSimulated,insertionMode) : toBeSimulated; + return invItems != null ? invItems.simulateAdd(toBeSimulated, insertionMode) : toBeSimulated; } @Override @@ -101,12 +109,14 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } @Override - public ItemStack removeSimilarItems(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) { + public ItemStack removeSimilarItems( + int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) { return invItems != null ? invItems.removeSimilarItems(amount, filter, fuzzyMode, destination) : null; } @Override - public ItemStack simulateSimilarRemove(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) { + public ItemStack simulateSimilarRemove( + int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) { return invItems != null ? invItems.simulateSimilarRemove(amount, filter, fuzzyMode, destination) : null; } @@ -124,15 +134,14 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } public boolean hasSlots() { - return (invFluids != null && invFluids.getTankInfo(side).length > 0) - || (invItems != null); + return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null); } @Override public Iterator iterator() { return new SlotIterator( - invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0], - invItems != null ? invItems.iterator() : Collections.emptyIterator()); + invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0], + invItems != null ? invItems.iterator() : Collections.emptyIterator()); } private static class SlotIterator implements Iterator { @@ -166,7 +175,5 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { return slot; } } - } - } diff --git a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryCrafting.java b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryCrafting.java index 7a3ab739..1b64c4f2 100644 --- a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryCrafting.java +++ b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryCrafting.java @@ -22,11 +22,11 @@ public class FluidConvertingInventoryCrafting extends InventoryCrafting { super.setInventorySlotContents(index, ItemFluidPacket.newStack(new FluidStack(fluid, stack.stackSize))); } else { // wtf? - super.setInventorySlotContents(index, ItemFluidPacket.newStack(new FluidStack(FluidRegistry.WATER, 1000))); + super.setInventorySlotContents( + index, ItemFluidPacket.newStack(new FluidStack(FluidRegistry.WATER, 1000))); } } else { super.setInventorySlotContents(index, stack); } } - } diff --git a/src/main/java/com/glodblock/github/inventory/IAEFluidInventory.java b/src/main/java/com/glodblock/github/inventory/IAEFluidInventory.java index 79ed92c7..6918e789 100644 --- a/src/main/java/com/glodblock/github/inventory/IAEFluidInventory.java +++ b/src/main/java/com/glodblock/github/inventory/IAEFluidInventory.java @@ -1,7 +1,6 @@ package com.glodblock.github.inventory; @FunctionalInterface -public interface IAEFluidInventory -{ - void onFluidInventoryChanged( final IAEFluidTank inv, final int slot ); +public interface IAEFluidInventory { + void onFluidInventoryChanged(final IAEFluidTank inv, final int slot); } diff --git a/src/main/java/com/glodblock/github/inventory/IAEFluidTank.java b/src/main/java/com/glodblock/github/inventory/IAEFluidTank.java index 8fde96a1..1f83e690 100644 --- a/src/main/java/com/glodblock/github/inventory/IAEFluidTank.java +++ b/src/main/java/com/glodblock/github/inventory/IAEFluidTank.java @@ -4,10 +4,9 @@ import appeng.api.storage.data.IAEFluidStack; import net.minecraftforge.fluids.IFluidHandler; public interface IAEFluidTank extends IFluidHandler { - void setFluidInSlot( final int slot, final IAEFluidStack fluid ); + void setFluidInSlot(final int slot, final IAEFluidStack fluid); - IAEFluidStack getFluidInSlot( final int slot ); + IAEFluidStack getFluidInSlot(final int slot); int getSlots(); - } diff --git a/src/main/java/com/glodblock/github/inventory/InventoryHandler.java b/src/main/java/com/glodblock/github/inventory/InventoryHandler.java index 91193715..338e5940 100644 --- a/src/main/java/com/glodblock/github/inventory/InventoryHandler.java +++ b/src/main/java/com/glodblock/github/inventory/InventoryHandler.java @@ -7,12 +7,11 @@ import com.glodblock.github.util.BlockPos; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -import javax.annotation.Nullable; - public class InventoryHandler implements IGuiHandler { public static void switchGui(GuiType guiType) { @@ -20,8 +19,13 @@ public class InventoryHandler implements IGuiHandler { } public static void openGui(EntityPlayer player, World world, BlockPos pos, EnumFacing face, GuiType guiType) { - player.openGui(FluidCraft.INSTANCE, - (guiType.ordinal() << 3) | face.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); + player.openGui( + FluidCraft.INSTANCE, + (guiType.ordinal() << 3) | face.ordinal(), + world, + pos.getX(), + pos.getY(), + pos.getZ()); } @Nullable diff --git a/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java b/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java index 4a260af6..8a51607d 100644 --- a/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java +++ b/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java @@ -12,13 +12,12 @@ import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IItemList; import appeng.util.item.AEFluidStack; +import java.util.*; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import java.util.*; - public class MEMonitorIFluidHandler implements IMEMonitor { private final IFluidHandler handler; private IItemList cache = AEApi.instance().storage().createFluidList(); @@ -43,11 +42,11 @@ public class MEMonitorIFluidHandler implements IMEMonitor { int filled = this.handler.fill(ForgeDirection.UNKNOWN, input.getFluidStack(), type == Actionable.MODULATE); if (filled == 0) { return input.copy(); - } else if ((long)filled == input.getStackSize()) { + } else if ((long) filled == input.getStackSize()) { return null; } else { IAEFluidStack o = input.copy(); - o.setStackSize(input.getStackSize() - (long)filled); + o.setStackSize(input.getStackSize() - (long) filled); if (type == Actionable.MODULATE) { IAEFluidStack added = o.copy(); this.cache.add(added); @@ -59,7 +58,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor { } public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) { - FluidStack removed = this.handler.drain(ForgeDirection.UNKNOWN, request.getFluidStack(), type == Actionable.MODULATE); + FluidStack removed = + this.handler.drain(ForgeDirection.UNKNOWN, request.getFluidStack(), type == Actionable.MODULATE); if (removed != null && removed.amount != 0) { IAEFluidStack o = request.copy(); o.setStackSize(removed.amount); @@ -77,12 +77,11 @@ public class MEMonitorIFluidHandler implements IMEMonitor { } @Override - public StorageChannel getChannel() - { + public StorageChannel getChannel() { return StorageChannel.FLUIDS; } - //*Decompiled Stuff*// + // *Decompiled Stuff*// public TickRateModulation onTick() { boolean changed = false; @@ -91,7 +90,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor { IItemList currentlyOnStorage = AEApi.instance().storage().createFluidList(); for (FluidTankInfo tankProperty : tankProperties) { - if (this.mode != StorageFilter.EXTRACTABLE_ONLY || this.handler.drain(ForgeDirection.UNKNOWN, 1, false) != null) { + if (this.mode != StorageFilter.EXTRACTABLE_ONLY + || this.handler.drain(ForgeDirection.UNKNOWN, 1, false) != null) { currentlyOnStorage.add(AEFluidStack.create(tankProperty.fluid)); } } @@ -99,22 +99,22 @@ public class MEMonitorIFluidHandler implements IMEMonitor { Iterator var9 = this.cache.iterator(); IAEFluidStack is; - while(var9.hasNext()) { - is = (IAEFluidStack)var9.next(); + while (var9.hasNext()) { + is = (IAEFluidStack) var9.next(); is.setStackSize(-is.getStackSize()); } var9 = currentlyOnStorage.iterator(); - while(var9.hasNext()) { - is = (IAEFluidStack)var9.next(); + while (var9.hasNext()) { + is = (IAEFluidStack) var9.next(); this.cache.add(is); } var9 = this.cache.iterator(); - while(var9.hasNext()) { - is = (IAEFluidStack)var9.next(); + while (var9.hasNext()) { + is = (IAEFluidStack) var9.next(); if (is.getStackSize() != 0L) { changes.add(is); } @@ -133,8 +133,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor { if (a != null) { Iterator i = this.listeners.entrySet().iterator(); - while(i.hasNext()) { - Map.Entry, Object> l = (Map.Entry)i.next(); + while (i.hasNext()) { + Map.Entry, Object> l = (Map.Entry) i.next(); IMEMonitorHandlerReceiver key = l.getKey(); if (key.isValid(l.getValue())) { key.postChange(this, a, this.getActionSource()); @@ -143,7 +143,6 @@ public class MEMonitorIFluidHandler implements IMEMonitor { } } } - } public AccessRestriction getAccess() { @@ -173,8 +172,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor { public IItemList getAvailableItems(IItemList out) { Iterator var2 = this.cache.iterator(); - while(var2.hasNext()) { - IAEFluidStack fs = (IAEFluidStack)var2.next(); + while (var2.hasNext()) { + IAEFluidStack fs = (IAEFluidStack) var2.next(); out.addStorage(fs); } diff --git a/src/main/java/com/glodblock/github/inventory/PatternConsumer.java b/src/main/java/com/glodblock/github/inventory/PatternConsumer.java index ae8ce6d8..935d1e1a 100644 --- a/src/main/java/com/glodblock/github/inventory/PatternConsumer.java +++ b/src/main/java/com/glodblock/github/inventory/PatternConsumer.java @@ -5,5 +5,4 @@ import appeng.api.storage.data.IAEItemStack; public interface PatternConsumer { void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs); - } diff --git a/src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java b/src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java index 33e354cb..783ea61a 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java +++ b/src/main/java/com/glodblock/github/inventory/gui/ButtonMouseHandler.java @@ -4,16 +4,16 @@ import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.TankDumpable; import com.glodblock.github.network.CPacketDumpTank; import com.glodblock.github.util.NameConst; -import net.minecraft.client.resources.I18n; - -import javax.annotation.Nullable; import java.util.Collections; import java.util.List; +import javax.annotation.Nullable; +import net.minecraft.client.resources.I18n; public class ButtonMouseHandler implements MouseRegionManager.Handler { @Nullable private final String tooltipKey; + private final Runnable callback; public ButtonMouseHandler(@Nullable String tooltipKey, Runnable callback) { @@ -43,5 +43,4 @@ public class ButtonMouseHandler implements MouseRegionManager.Handler { } }); } - } diff --git a/src/main/java/com/glodblock/github/inventory/gui/GuiFactory.java b/src/main/java/com/glodblock/github/inventory/gui/GuiFactory.java index df59218e..06697afd 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/GuiFactory.java +++ b/src/main/java/com/glodblock/github/inventory/gui/GuiFactory.java @@ -2,12 +2,11 @@ package com.glodblock.github.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -import javax.annotation.Nullable; - public interface GuiFactory { @Nullable @@ -16,5 +15,4 @@ public interface GuiFactory { @SideOnly(Side.CLIENT) @Nullable Object createClientGui(EntityPlayer player, World world, int x, int y, int z, EnumFacing face); - } diff --git a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java index b2a36436..958660ad 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java +++ b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java @@ -13,13 +13,11 @@ import com.glodblock.github.common.parts.PartFluidInterface; import com.glodblock.github.common.parts.PartSharedFluidBus; import com.glodblock.github.common.tile.*; import com.google.common.collect.ImmutableList; +import java.util.List; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayer; -import javax.annotation.Nullable; -import java.util.List; - public enum GuiType { - OC_PATTERN_EDITOR(new TileGuiFactory(TileOCPatternEditor.class) { @Override protected Object createServerGui(EntityPlayer player, TileOCPatternEditor inv) { @@ -248,5 +246,4 @@ public enum GuiType { GuiType(GuiFactory guiFactory) { this.guiFactory = guiFactory; } - } diff --git a/src/main/java/com/glodblock/github/inventory/gui/MouseRegionManager.java b/src/main/java/com/glodblock/github/inventory/gui/MouseRegionManager.java index 15cd3c3b..d3a884cb 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/MouseRegionManager.java +++ b/src/main/java/com/glodblock/github/inventory/gui/MouseRegionManager.java @@ -1,13 +1,12 @@ package com.glodblock.github.inventory.gui; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nullable; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.util.ResourceLocation; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; - public class MouseRegionManager { private final GuiContainer gui; private final List regions = new ArrayList<>(); @@ -25,7 +24,9 @@ public class MouseRegionManager { mY -= gui.guiTop; for (Region region : regions) { if (region.containsMouse(mX, mY) && region.handler.onClick(button)) { - gui.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1F)); + gui.mc + .getSoundHandler() + .playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1F)); return false; } } @@ -61,7 +62,6 @@ public class MouseRegionManager { boolean containsMouse(int mX, int mY) { return mX >= x && mX < x + width && mY >= y && mY < y + height; } - } public interface Handler { @@ -74,7 +74,5 @@ public class MouseRegionManager { default boolean onClick(int button) { return false; } - } - } diff --git a/src/main/java/com/glodblock/github/inventory/gui/PartGuiFactory.java b/src/main/java/com/glodblock/github/inventory/gui/PartGuiFactory.java index 11e5a725..afb9c47e 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/PartGuiFactory.java +++ b/src/main/java/com/glodblock/github/inventory/gui/PartGuiFactory.java @@ -3,11 +3,10 @@ package com.glodblock.github.inventory.gui; import appeng.api.parts.IPart; import appeng.api.parts.IPartHost; import com.glodblock.github.util.Util; +import javax.annotation.Nullable; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; -import javax.annotation.Nullable; - public abstract class PartGuiFactory extends TileGuiFactory { PartGuiFactory(Class invClass) { @@ -18,7 +17,7 @@ public abstract class PartGuiFactory extends TileGuiFactory { @Override protected T getInventory(TileEntity tile, EnumFacing face) { if (tile instanceof IPartHost) { - IPart part = ((IPartHost)tile).getPart(Util.from(face)); + IPart part = ((IPartHost) tile).getPart(Util.from(face)); if (invClass.isInstance(part)) { return invClass.cast(part); } diff --git a/src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java b/src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java index 369fe21c..fceb6b29 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java +++ b/src/main/java/com/glodblock/github/inventory/gui/TankMouseHandler.java @@ -3,14 +3,13 @@ package com.glodblock.github.inventory.gui; import appeng.api.storage.data.IAEFluidStack; import com.glodblock.github.inventory.IAEFluidTank; import com.glodblock.github.util.NameConst; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Nullable; import net.minecraft.client.resources.I18n; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.List; - public class TankMouseHandler implements MouseRegionManager.Handler { private final IAEFluidTank tank; @@ -26,9 +25,11 @@ public class TankMouseHandler implements MouseRegionManager.Handler { public List getTooltip() { IAEFluidStack fluid = tank.getFluidInSlot(index); return Arrays.asList( - fluid != null ? fluid.getFluidStack().getLocalizedName() : I18n.format(NameConst.TT_EMPTY), - EnumChatFormatting.GRAY + String.format("%,d / %,d mB", - fluid != null ? fluid.getStackSize() : 0L, tank.getTankInfo(ForgeDirection.UNKNOWN)[index].capacity)); + fluid != null ? fluid.getFluidStack().getLocalizedName() : I18n.format(NameConst.TT_EMPTY), + EnumChatFormatting.GRAY + + String.format( + "%,d / %,d mB", + fluid != null ? fluid.getStackSize() : 0L, + tank.getTankInfo(ForgeDirection.UNKNOWN)[index].capacity)); } - } diff --git a/src/main/java/com/glodblock/github/inventory/gui/TileGuiFactory.java b/src/main/java/com/glodblock/github/inventory/gui/TileGuiFactory.java index 4ac4eab1..bc740be6 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/TileGuiFactory.java +++ b/src/main/java/com/glodblock/github/inventory/gui/TileGuiFactory.java @@ -3,13 +3,12 @@ package com.glodblock.github.inventory.gui; import appeng.container.AEBaseContainer; import appeng.container.ContainerOpenContext; import com.glodblock.github.util.Util; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -import javax.annotation.Nullable; - public abstract class TileGuiFactory implements GuiFactory { protected final Class invClass; @@ -42,7 +41,7 @@ public abstract class TileGuiFactory implements GuiFactory { ctx.setY(y); ctx.setZ(z); ctx.setSide(Util.from(face)); - ((AEBaseContainer)gui).setOpenContext(ctx); + ((AEBaseContainer) gui).setOpenContext(ctx); } return gui; } diff --git a/src/main/java/com/glodblock/github/inventory/slot/OptionalFluidSlotFakeTypeOnly.java b/src/main/java/com/glodblock/github/inventory/slot/OptionalFluidSlotFakeTypeOnly.java index 9eeaa70b..c1e1d74b 100644 --- a/src/main/java/com/glodblock/github/inventory/slot/OptionalFluidSlotFakeTypeOnly.java +++ b/src/main/java/com/glodblock/github/inventory/slot/OptionalFluidSlotFakeTypeOnly.java @@ -14,14 +14,22 @@ public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly { AEFluidInventory fluidInv; - public OptionalFluidSlotFakeTypeOnly(IInventory inv, AEFluidInventory fluidInv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) { + public OptionalFluidSlotFakeTypeOnly( + IInventory inv, + AEFluidInventory fluidInv, + IOptionalSlotHost containerBus, + int idx, + int x, + int y, + int offX, + int offY, + int groupNum) { super(inv, containerBus, idx, x, y, offX, offY, groupNum); this.fluidInv = fluidInv; } @Override - public void putStack( ItemStack is ) - { + public void putStack(ItemStack is) { FluidStack fluidStack = Util.getFluidFromItem(is); if (fluidStack != null) { ItemStack tmp = ItemFluidPacket.newDisplayStack(fluidStack); @@ -31,13 +39,11 @@ public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly { fluidInv.setFluidInSlot(getSlotIndex(), AEFluidStack.create(standard)); } super.putStack(tmp); - } - else { + } else { super.putStack(null); if (fluidInv != null) { fluidInv.setFluidInSlot(getSlotIndex(), null); } } } - } diff --git a/src/main/java/com/glodblock/github/inventory/slot/SlotFluid.java b/src/main/java/com/glodblock/github/inventory/slot/SlotFluid.java index 9390a301..76b30618 100644 --- a/src/main/java/com/glodblock/github/inventory/slot/SlotFluid.java +++ b/src/main/java/com/glodblock/github/inventory/slot/SlotFluid.java @@ -1,7 +1,6 @@ package com.glodblock.github.inventory.slot; import appeng.api.storage.data.IAEItemStack; - import javax.annotation.Nullable; public interface SlotFluid { @@ -10,6 +9,4 @@ public interface SlotFluid { IAEItemStack getAeStack(); void setAeStack(@Nullable IAEItemStack stack, boolean sync); - - } diff --git a/src/main/java/com/glodblock/github/inventory/slot/SlotSingleItem.java b/src/main/java/com/glodblock/github/inventory/slot/SlotSingleItem.java index f664ec39..b3b65890 100644 --- a/src/main/java/com/glodblock/github/inventory/slot/SlotSingleItem.java +++ b/src/main/java/com/glodblock/github/inventory/slot/SlotSingleItem.java @@ -98,5 +98,4 @@ public class SlotSingleItem extends Slot { public int getSlotIndex() { return delegate.getSlotIndex(); } - } diff --git a/src/main/java/com/glodblock/github/loader/ChannelLoader.java b/src/main/java/com/glodblock/github/loader/ChannelLoader.java index 0f84e232..dfa8ffd8 100644 --- a/src/main/java/com/glodblock/github/loader/ChannelLoader.java +++ b/src/main/java/com/glodblock/github/loader/ChannelLoader.java @@ -9,17 +9,29 @@ public class ChannelLoader implements Runnable { @SuppressWarnings("all") public void run() { int id = 0; - FluidCraft.proxy.netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new CPacketFluidPatternTermBtns.Handler(), CPacketFluidPatternTermBtns.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new CPacketEncodePattern.Handler(), CPacketEncodePattern.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new SPacketMEInventoryUpdate.Handler(), SPacketMEInventoryUpdate.class, id ++, Side.CLIENT); - FluidCraft.proxy.netHandler.registerMessage(new CPacketCraftRequest.Handler(), CPacketCraftRequest.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new CPacketInventoryAction.Handler(), CPacketInventoryAction.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new CPacketSetTargetItem.Handler(), CPacketSetTargetItem.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id ++, Side.CLIENT); - FluidCraft.proxy.netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id ++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT); - FluidCraft.proxy.netHandler.registerMessage(new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id ++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketFluidPatternTermBtns.Handler(), CPacketFluidPatternTermBtns.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketEncodePattern.Handler(), CPacketEncodePattern.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new SPacketMEInventoryUpdate.Handler(), SPacketMEInventoryUpdate.class, id++, Side.CLIENT); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketCraftRequest.Handler(), CPacketCraftRequest.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketInventoryAction.Handler(), CPacketInventoryAction.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketSetTargetItem.Handler(), CPacketSetTargetItem.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.CLIENT); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketDumpTank.Handler(), CPacketDumpTank.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id++, Side.CLIENT); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id++, Side.SERVER); } } diff --git a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java index dbf9b94d..d2fcd3c7 100644 --- a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java +++ b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java @@ -25,11 +25,16 @@ public class ItemAndBlockHolder { public static ItemFluidPacket PACKET = new ItemFluidPacket().register(); public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register(); public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register(); - public static ItemBasicFluidStorageCell CELL16K = new ItemBasicFluidStorageCell(CellType.Cell16kPart, 16).register(); - public static ItemBasicFluidStorageCell CELL64K = new ItemBasicFluidStorageCell(CellType.Cell64kPart, 64).register(); - public static ItemBasicFluidStorageCell CELL256K = new ItemBasicFluidStorageCell(CellType.Cell256kPart, 256).register(); - public static ItemBasicFluidStorageCell CELL1024K = new ItemBasicFluidStorageCell(CellType.Cell1024kPart, 1024).register(); - public static ItemBasicFluidStorageCell CELL4096K = new ItemBasicFluidStorageCell(CellType.Cell4096kPart, 4096).register(); + public static ItemBasicFluidStorageCell CELL16K = + new ItemBasicFluidStorageCell(CellType.Cell16kPart, 16).register(); + public static ItemBasicFluidStorageCell CELL64K = + new ItemBasicFluidStorageCell(CellType.Cell64kPart, 64).register(); + public static ItemBasicFluidStorageCell CELL256K = + new ItemBasicFluidStorageCell(CellType.Cell256kPart, 256).register(); + public static ItemBasicFluidStorageCell CELL1024K = + new ItemBasicFluidStorageCell(CellType.Cell1024kPart, 1024).register(); + public static ItemBasicFluidStorageCell CELL4096K = + new ItemBasicFluidStorageCell(CellType.Cell4096kPart, 4096).register(); public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register(); public static void loadSetting() { @@ -42,5 +47,4 @@ public class ItemAndBlockHolder { CellType.Cell1024kPart.setItemInstance(CELL_PART); CellType.Cell4096kPart.setItemInstance(CELL_PART); } - } diff --git a/src/main/java/com/glodblock/github/loader/ListenerLoader.java b/src/main/java/com/glodblock/github/loader/ListenerLoader.java index 16fd725f..04ed38ba 100644 --- a/src/main/java/com/glodblock/github/loader/ListenerLoader.java +++ b/src/main/java/com/glodblock/github/loader/ListenerLoader.java @@ -8,5 +8,4 @@ public class ListenerLoader implements Runnable { public void run() { ClientHelper.register(); } - } diff --git a/src/main/java/com/glodblock/github/loader/RecipeLoader.java b/src/main/java/com/glodblock/github/loader/RecipeLoader.java index 6adb76af..b7cd9bf2 100644 --- a/src/main/java/com/glodblock/github/loader/RecipeLoader.java +++ b/src/main/java/com/glodblock/github/loader/RecipeLoader.java @@ -1,5 +1,7 @@ package com.glodblock.github.loader; +import static com.glodblock.github.loader.ItemAndBlockHolder.*; + import com.glodblock.github.common.Config; import com.glodblock.github.common.item.ItemBasicFluidStorageCell; import com.glodblock.github.common.storage.CellType; @@ -12,76 +14,276 @@ import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import static com.glodblock.github.loader.ItemAndBlockHolder.*; - public class RecipeLoader implements Runnable { - public final static ItemStack AE2_INTERFACE = GameRegistry.findItemStack("appliedenergistics2", "tile.BlockInterface", 1); - public final static ItemStack AE2_PROCESS_ENG = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 24); - public final static ItemStack AE2_STORAGE_BUS = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 220); - public final static ItemStack AE2_CONDENSER = GameRegistry.findItemStack("appliedenergistics2", "tile.BlockCondenser", 1); - public final static ItemStack AE2_GLASS_CABLE = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 16); - public final static ItemStack AE2_PROCESS_CAL = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 23); - public final static ItemStack AE2_WORK_BENCH = GameRegistry.findItemStack("appliedenergistics2", "tile.BlockCellWorkbench", 1); - public final static ItemStack AE2_PATTERN_TERM = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 340); - public final static ItemStack AE2_PROCESS_LOG = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 22); - public final static ItemStack AE2_PURE_CERTUS = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 10); - public final static ItemStack AE2_QUARTZ_GLASS = GameRegistry.findItemStack("appliedenergistics2", "tile.BlockQuartzGlass", 1); - public final static ItemStack AE2_LAMP_GLASS = GameRegistry.findItemStack("appliedenergistics2", "tile.BlockQuartzLamp", 1); - public final static ItemStack AE2_CELL_HOUSING = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 39); - public final static ItemStack AE2_CELL_1K = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 35); - public final static ItemStack AE2_CORE_ANN = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 44); - public final static ItemStack AE2_CORE_FOM = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 43); - public final static ItemStack PISTON = new ItemStack(Blocks.piston, 1); - public final static ItemStack AE2_BLANK_PATTERN = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 52); - public final static ItemStack BUCKET = new ItemStack(Items.bucket, 1); - public final static ItemStack IRON_BAR = new ItemStack(Blocks.iron_bars, 1); + public static final ItemStack AE2_INTERFACE = + GameRegistry.findItemStack("appliedenergistics2", "tile.BlockInterface", 1); + public static final ItemStack AE2_PROCESS_ENG = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 24); + public static final ItemStack AE2_STORAGE_BUS = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 220); + public static final ItemStack AE2_CONDENSER = + GameRegistry.findItemStack("appliedenergistics2", "tile.BlockCondenser", 1); + public static final ItemStack AE2_GLASS_CABLE = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 16); + public static final ItemStack AE2_PROCESS_CAL = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 23); + public static final ItemStack AE2_WORK_BENCH = + GameRegistry.findItemStack("appliedenergistics2", "tile.BlockCellWorkbench", 1); + public static final ItemStack AE2_PATTERN_TERM = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 340); + public static final ItemStack AE2_PROCESS_LOG = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 22); + public static final ItemStack AE2_PURE_CERTUS = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 10); + public static final ItemStack AE2_QUARTZ_GLASS = + GameRegistry.findItemStack("appliedenergistics2", "tile.BlockQuartzGlass", 1); + public static final ItemStack AE2_LAMP_GLASS = + GameRegistry.findItemStack("appliedenergistics2", "tile.BlockQuartzLamp", 1); + public static final ItemStack AE2_CELL_HOUSING = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 39); + public static final ItemStack AE2_CELL_1K = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 35); + public static final ItemStack AE2_CORE_ANN = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 44); + public static final ItemStack AE2_CORE_FOM = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 43); + public static final ItemStack PISTON = new ItemStack(Blocks.piston, 1); + public static final ItemStack AE2_BLANK_PATTERN = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 52); + public static final ItemStack BUCKET = new ItemStack(Items.bucket, 1); + public static final ItemStack IRON_BAR = new ItemStack(Blocks.iron_bars, 1); @Override public void run() { - GameRegistry.addRecipe(new ShapedOreRecipe(INTERFACE.stack(), "IPI", "GEG", "IPI", 'I', "ingotIron", 'P', "dyeBlue", 'G', "blockGlass", 'E', AE2_INTERFACE)); + GameRegistry.addRecipe(new ShapedOreRecipe( + INTERFACE.stack(), + "IPI", + "GEG", + "IPI", + 'I', + "ingotIron", + 'P', + "dyeBlue", + 'G', + "blockGlass", + 'E', + AE2_INTERFACE)); GameRegistry.addShapelessRecipe(FLUID_INTERFACE.stack(), INTERFACE.stack()); GameRegistry.addShapelessRecipe(INTERFACE.stack(), FLUID_INTERFACE.stack()); - GameRegistry.addRecipe(new ShapedOreRecipe(DISCRETIZER.stack(), "IPI", "TMT", "IPI", 'I', "ingotIron", 'P', AE2_PROCESS_ENG, 'T', AE2_STORAGE_BUS, 'M', AE2_CONDENSER)); - GameRegistry.addRecipe(new ShapedOreRecipe(DECODER.stack(), "IHI", "CFC", "IPI", 'I', "ingotIron", 'H', Blocks.hopper, 'C', AE2_GLASS_CABLE, 'F', INTERFACE, 'P', AE2_PROCESS_CAL)); - GameRegistry.addRecipe(new ShapedOreRecipe(ENCODER.stack(), "LPL", "IWI", "III", 'I', "ingotIron", 'L', "blockLapis", 'P', AE2_PROCESS_ENG, 'W', AE2_WORK_BENCH)); + GameRegistry.addRecipe(new ShapedOreRecipe( + DISCRETIZER.stack(), + "IPI", + "TMT", + "IPI", + 'I', + "ingotIron", + 'P', + AE2_PROCESS_ENG, + 'T', + AE2_STORAGE_BUS, + 'M', + AE2_CONDENSER)); + GameRegistry.addRecipe(new ShapedOreRecipe( + DECODER.stack(), + "IHI", + "CFC", + "IPI", + 'I', + "ingotIron", + 'H', + Blocks.hopper, + 'C', + AE2_GLASS_CABLE, + 'F', + INTERFACE, + 'P', + AE2_PROCESS_CAL)); + GameRegistry.addRecipe(new ShapedOreRecipe( + ENCODER.stack(), + "LPL", + "IWI", + "III", + 'I', + "ingotIron", + 'L', + "blockLapis", + 'P', + AE2_PROCESS_ENG, + 'W', + AE2_WORK_BENCH)); GameRegistry.addShapelessRecipe(FLUID_TERMINAL.stack(), AE2_PATTERN_TERM, ENCODER); - GameRegistry.addShapelessRecipe(FLUID_TERMINAL_EX.stack(), FLUID_TERMINAL.stack(), AE2_PROCESS_CAL, AE2_PROCESS_ENG, AE2_PROCESS_LOG); - GameRegistry.addRecipe(new ShapedOreRecipe(BUFFER.stack(), "ILI", "AGF", "IBI", 'I', "ingotIron", 'G', AE2_QUARTZ_GLASS, 'L', AE2_CELL_1K, 'A', AE2_CORE_ANN, 'F', AE2_CORE_FOM, 'B', BUCKET)); - GameRegistry.addRecipe(new ShapedOreRecipe(LARGE_BUFFER.stack(), "BGB", "GEG", "BGB", 'B', BUFFER.stack(), 'G', AE2_QUARTZ_GLASS, 'E', AE2_PROCESS_ENG)); - GameRegistry.addShapelessRecipe(AE2_BLANK_PATTERN,PATTERN.stack()); + GameRegistry.addShapelessRecipe( + FLUID_TERMINAL_EX.stack(), FLUID_TERMINAL.stack(), AE2_PROCESS_CAL, AE2_PROCESS_ENG, AE2_PROCESS_LOG); + GameRegistry.addRecipe(new ShapedOreRecipe( + BUFFER.stack(), + "ILI", + "AGF", + "IBI", + 'I', + "ingotIron", + 'G', + AE2_QUARTZ_GLASS, + 'L', + AE2_CELL_1K, + 'A', + AE2_CORE_ANN, + 'F', + AE2_CORE_FOM, + 'B', + BUCKET)); + GameRegistry.addRecipe(new ShapedOreRecipe( + LARGE_BUFFER.stack(), + "BGB", + "GEG", + "BGB", + 'B', + BUFFER.stack(), + 'G', + AE2_QUARTZ_GLASS, + 'E', + AE2_PROCESS_ENG)); + GameRegistry.addShapelessRecipe(AE2_BLANK_PATTERN, PATTERN.stack()); if (Config.fluidCells) { OreDictionary.registerOre("anyCertusCrystal", AE2_PURE_CERTUS); for (ItemStack it : OreDictionary.getOres("crystalCertusQuartz")) OreDictionary.registerOre("anyCertusCrystal", it); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell1kPart.stack(1), "DCD", "CEC", "DCD", 'D', "dyeBlue", 'C', "anyCertusCrystal", 'E', AE2_PROCESS_ENG)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell4kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell1kPart.stack(1), 'P', AE2_PROCESS_CAL, 'G', AE2_QUARTZ_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell16kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell4kPart.stack(1), 'P', AE2_PROCESS_LOG, 'G', AE2_QUARTZ_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell64kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell16kPart.stack(1), 'P', AE2_PROCESS_ENG, 'G', AE2_QUARTZ_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell256kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell64kPart.stack(1), 'P', AE2_PROCESS_CAL, 'G', AE2_LAMP_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell1024kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell256kPart.stack(1), 'P', AE2_PROCESS_LOG, 'G', AE2_LAMP_GLASS)); - GameRegistry.addRecipe(new ShapedOreRecipe(CellType.Cell4096kPart.stack(1), "DPD", "CGC", "DCD", 'D', "dyeBlue", 'C', CellType.Cell1024kPart.stack(1), 'P', AE2_PROCESS_ENG, 'G', AE2_LAMP_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe( + CellType.Cell1kPart.stack(1), + "DCD", + "CEC", + "DCD", + 'D', + "dyeBlue", + 'C', + "anyCertusCrystal", + 'E', + AE2_PROCESS_ENG)); + GameRegistry.addRecipe(new ShapedOreRecipe( + CellType.Cell4kPart.stack(1), + "DPD", + "CGC", + "DCD", + 'D', + "dyeBlue", + 'C', + CellType.Cell1kPart.stack(1), + 'P', + AE2_PROCESS_CAL, + 'G', + AE2_QUARTZ_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe( + CellType.Cell16kPart.stack(1), + "DPD", + "CGC", + "DCD", + 'D', + "dyeBlue", + 'C', + CellType.Cell4kPart.stack(1), + 'P', + AE2_PROCESS_LOG, + 'G', + AE2_QUARTZ_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe( + CellType.Cell64kPart.stack(1), + "DPD", + "CGC", + "DCD", + 'D', + "dyeBlue", + 'C', + CellType.Cell16kPart.stack(1), + 'P', + AE2_PROCESS_ENG, + 'G', + AE2_QUARTZ_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe( + CellType.Cell256kPart.stack(1), + "DPD", + "CGC", + "DCD", + 'D', + "dyeBlue", + 'C', + CellType.Cell64kPart.stack(1), + 'P', + AE2_PROCESS_CAL, + 'G', + AE2_LAMP_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe( + CellType.Cell1024kPart.stack(1), + "DPD", + "CGC", + "DCD", + 'D', + "dyeBlue", + 'C', + CellType.Cell256kPart.stack(1), + 'P', + AE2_PROCESS_LOG, + 'G', + AE2_LAMP_GLASS)); + GameRegistry.addRecipe(new ShapedOreRecipe( + CellType.Cell4096kPart.stack(1), + "DPD", + "CGC", + "DCD", + 'D', + "dyeBlue", + 'C', + CellType.Cell1024kPart.stack(1), + 'P', + AE2_PROCESS_ENG, + 'G', + AE2_LAMP_GLASS)); - ItemBasicFluidStorageCell[] cells = new ItemBasicFluidStorageCell[]{ - CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K, CELL4096K - }; + ItemBasicFluidStorageCell[] cells = + new ItemBasicFluidStorageCell[] {CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K, CELL4096K}; for (ItemBasicFluidStorageCell cell : cells) { - GameRegistry.addRecipe(new ShapedOreRecipe(cell, "GDG", "DCD", "III", 'D', "dustRedstone", 'G', AE2_QUARTZ_GLASS, 'C', cell.getComponent(), 'I', "ingotIron")); + GameRegistry.addRecipe(new ShapedOreRecipe( + cell, + "GDG", + "DCD", + "III", + 'D', + "dustRedstone", + 'G', + AE2_QUARTZ_GLASS, + 'C', + cell.getComponent(), + 'I', + "ingotIron")); GameRegistry.addRecipe(new ShapelessOreRecipe(cell, AE2_CELL_HOUSING, cell.getComponent())); } } if (Config.fluidIOBus) { - GameRegistry.addRecipe(new ShapedOreRecipe(FLUID_EXPORT_BUS, "ICI", "BPB", 'B', "dyeBlue", 'I', "ingotIron", 'P', PISTON, 'C', AE2_CORE_FOM)); - GameRegistry.addRecipe(new ShapedOreRecipe(FLUID_IMPORT_BUS, "BCB", "IPI", 'B', "dyeBlue", 'I', "ingotIron", 'P', PISTON, 'C', AE2_CORE_ANN)); + GameRegistry.addRecipe(new ShapedOreRecipe( + FLUID_EXPORT_BUS, "ICI", "BPB", 'B', "dyeBlue", 'I', "ingotIron", 'P', PISTON, 'C', AE2_CORE_FOM)); + GameRegistry.addRecipe(new ShapedOreRecipe( + FLUID_IMPORT_BUS, "BCB", "IPI", 'B', "dyeBlue", 'I', "ingotIron", 'P', PISTON, 'C', AE2_CORE_ANN)); } if (ModAndClassUtil.OC) { ItemStack CHIP_T1 = new ItemStack(GameRegistry.findItem("OpenComputers", "item"), 1, 24); - GameRegistry.addRecipe(new ShapedOreRecipe(OC_EDITOR, "IMI", "CBC", "IPI", 'I', IRON_BAR, 'M', CHIP_T1, 'C', "oc:cable", 'B', BUCKET, 'P', AE2_BLANK_PATTERN)); + GameRegistry.addRecipe(new ShapedOreRecipe( + OC_EDITOR, + "IMI", + "CBC", + "IPI", + 'I', + IRON_BAR, + 'M', + CHIP_T1, + 'C', + "oc:cable", + 'B', + BUCKET, + 'P', + AE2_BLANK_PATTERN)); } - } } diff --git a/src/main/java/com/glodblock/github/loader/RenderLoader.java b/src/main/java/com/glodblock/github/loader/RenderLoader.java index 8ecf61b2..bfd5ff21 100644 --- a/src/main/java/com/glodblock/github/loader/RenderLoader.java +++ b/src/main/java/com/glodblock/github/loader/RenderLoader.java @@ -10,5 +10,4 @@ public class RenderLoader implements Runnable { new ItemDropRender(); new ItemPacketRender(); } - } diff --git a/src/main/java/com/glodblock/github/nei/FluidPatternTerminalRecipeTransferHandler.java b/src/main/java/com/glodblock/github/nei/FluidPatternTerminalRecipeTransferHandler.java index b337ff11..2f15d0f4 100644 --- a/src/main/java/com/glodblock/github/nei/FluidPatternTerminalRecipeTransferHandler.java +++ b/src/main/java/com/glodblock/github/nei/FluidPatternTerminalRecipeTransferHandler.java @@ -7,18 +7,17 @@ import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.GuiBaseFluidPatternTerminalEx; import com.glodblock.github.client.gui.GuiFluidPatternTerminal; import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx; -import com.glodblock.github.client.gui.container.FluidPrioritization; import com.glodblock.github.nei.object.OrderStack; import com.glodblock.github.nei.recipes.FluidRecipe; import com.glodblock.github.network.CPacketTransferRecipe; -import net.minecraft.client.gui.inventory.GuiContainer; - import java.util.HashSet; import java.util.List; +import net.minecraft.client.gui.inventory.GuiContainer; public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandler { - public static final FluidPatternTerminalRecipeTransferHandler INSTANCE = new FluidPatternTerminalRecipeTransferHandler(); + public static final FluidPatternTerminalRecipeTransferHandler INSTANCE = + new FluidPatternTerminalRecipeTransferHandler(); public static final HashSet notOtherSet = new HashSet<>(); public static final HashSet craftSet = new HashSet<>(); @@ -34,7 +33,7 @@ public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandle if (isCorrectGui(firstGui)) { boolean priority = false; if (firstGui instanceof GuiBaseFluidPatternTerminalEx) { - priority = ((GuiBaseFluidPatternTerminalEx)firstGui).container.prioritize; + priority = ((GuiBaseFluidPatternTerminalEx) firstGui).container.prioritize; } List> in = FluidRecipe.getPackageInputs(recipe, recipeIndex, priority); List> out = FluidRecipe.getPackageOutputs(recipe, recipeIndex, !notUseOther(recipe)); @@ -56,5 +55,4 @@ public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandle TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipeHandler; return craftSet.contains(tRecipe.getOverlayIdentifier()); } - } diff --git a/src/main/java/com/glodblock/github/nei/NEIGuiHandler.java b/src/main/java/com/glodblock/github/nei/NEIGuiHandler.java index 0929e400..8517ef11 100644 --- a/src/main/java/com/glodblock/github/nei/NEIGuiHandler.java +++ b/src/main/java/com/glodblock/github/nei/NEIGuiHandler.java @@ -13,5 +13,4 @@ public class NEIGuiHandler extends INEIGuiAdapter { } return false; } - } diff --git a/src/main/java/com/glodblock/github/nei/NEIUtils.java b/src/main/java/com/glodblock/github/nei/NEIUtils.java index 79cd45ce..52fe0db0 100644 --- a/src/main/java/com/glodblock/github/nei/NEIUtils.java +++ b/src/main/java/com/glodblock/github/nei/NEIUtils.java @@ -1,14 +1,13 @@ package com.glodblock.github.nei; import com.glodblock.github.nei.object.OrderStack; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; public class NEIUtils { @@ -26,8 +25,10 @@ public class NEIUtils { for (OrderStack storedStack : comp) { if (storedStack == null || !(storedStack.getStack() instanceof ItemStack)) continue; ItemStack firstStack = (ItemStack) storedStack.getStack(); - boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack); - if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) { + boolean areItemStackEqual = firstStack.isItemEqual(currentStack) + && ItemStack.areItemStackTagsEqual(firstStack, currentStack); + if (areItemStackEqual + && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) { find = true; ((ItemStack) storedStack.getStack()).stackSize = firstStack.stackSize + currentStack.stackSize; } @@ -52,13 +53,12 @@ public class NEIUtils { } } int id = 0; - for (int i = 0; i <= upper; i ++) { + for (int i = 0; i <= upper; i++) { if (map.containsKey(i)) { cleared.add(new OrderStack<>(map.get(i), id)); - id ++; + id++; } } return cleared; } - } diff --git a/src/main/java/com/glodblock/github/nei/NEI_FC_Config.java b/src/main/java/com/glodblock/github/nei/NEI_FC_Config.java index a6a9970b..eec4eb04 100644 --- a/src/main/java/com/glodblock/github/nei/NEI_FC_Config.java +++ b/src/main/java/com/glodblock/github/nei/NEI_FC_Config.java @@ -14,8 +14,10 @@ public class NEI_FC_Config implements IConfigureNEI { API.registerNEIGuiHandler(new NEIGuiHandler()); for (String identifier : FluidRecipe.getSupportRecipes()) { - API.registerGuiOverlayHandler(GuiFluidPatternTerminal.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier); - API.registerGuiOverlayHandler(GuiFluidPatternTerminalEx.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier); + API.registerGuiOverlayHandler( + GuiFluidPatternTerminal.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier); + API.registerGuiOverlayHandler( + GuiFluidPatternTerminalEx.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier); } } diff --git a/src/main/java/com/glodblock/github/nei/object/IFluidDummy.java b/src/main/java/com/glodblock/github/nei/object/IFluidDummy.java index acc7d17a..8c1ef09a 100644 --- a/src/main/java/com/glodblock/github/nei/object/IFluidDummy.java +++ b/src/main/java/com/glodblock/github/nei/object/IFluidDummy.java @@ -5,5 +5,4 @@ import net.minecraftforge.fluids.FluidStack; public interface IFluidDummy { FluidStack getFluidStack(); - } diff --git a/src/main/java/com/glodblock/github/nei/object/IRecipeExtractor.java b/src/main/java/com/glodblock/github/nei/object/IRecipeExtractor.java index ff344c33..1ab41795 100644 --- a/src/main/java/com/glodblock/github/nei/object/IRecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/object/IRecipeExtractor.java @@ -2,7 +2,6 @@ package com.glodblock.github.nei.object; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.IRecipeHandler; - import java.util.List; public interface IRecipeExtractor { @@ -15,8 +14,8 @@ public interface IRecipeExtractor { return getInputIngredients(rawInputs); } - default List> getOutputIngredients(List rawOutputs, IRecipeHandler recipe, int index) { + default List> getOutputIngredients( + List rawOutputs, IRecipeHandler recipe, int index) { return getOutputIngredients(rawOutputs); } - } diff --git a/src/main/java/com/glodblock/github/nei/object/IRecipeExtractorLegacy.java b/src/main/java/com/glodblock/github/nei/object/IRecipeExtractorLegacy.java index 8bca0304..c69c7f83 100644 --- a/src/main/java/com/glodblock/github/nei/object/IRecipeExtractorLegacy.java +++ b/src/main/java/com/glodblock/github/nei/object/IRecipeExtractorLegacy.java @@ -3,5 +3,4 @@ package com.glodblock.github.nei.object; public interface IRecipeExtractorLegacy extends IRecipeExtractor { String getClassName(); - } diff --git a/src/main/java/com/glodblock/github/nei/object/IllegalOrderStackID.java b/src/main/java/com/glodblock/github/nei/object/IllegalOrderStackID.java index 203d3a0d..e5dda209 100644 --- a/src/main/java/com/glodblock/github/nei/object/IllegalOrderStackID.java +++ b/src/main/java/com/glodblock/github/nei/object/IllegalOrderStackID.java @@ -5,5 +5,4 @@ public class IllegalOrderStackID extends RuntimeException { public IllegalOrderStackID(int id) { super("Illegal type id: " + id); } - } diff --git a/src/main/java/com/glodblock/github/nei/object/OrderStack.java b/src/main/java/com/glodblock/github/nei/object/OrderStack.java index 76747576..877b359d 100644 --- a/src/main/java/com/glodblock/github/nei/object/OrderStack.java +++ b/src/main/java/com/glodblock/github/nei/object/OrderStack.java @@ -2,22 +2,21 @@ package com.glodblock.github.nei.object; import codechicken.nei.PositionedStack; import com.glodblock.github.util.Util; +import javax.annotation.Nullable; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import javax.annotation.Nullable; - public class OrderStack { private final T RealStack; private final int index; - public final static int ITEM = 1; - public final static int FLUID = 2; - public final static int CUSTOM = 3; + public static final int ITEM = 1; + public static final int FLUID = 2; + public static final int CUSTOM = 3; public OrderStack(T stack, int order) { if (stack == null || order < 0) @@ -40,8 +39,7 @@ public class OrderStack { ItemStack tmp = stack.items[0].copy(); tmp.setItemDamage(0); return new OrderStack<>(tmp, index); - } - else return new OrderStack<>(stack.items[0].copy(), index); + } else return new OrderStack<>(stack.items[0].copy(), index); } return null; } @@ -55,8 +53,7 @@ public class OrderStack { return null; } - protected void customNBTWriter(NBTTagCompound buf) { - } + protected void customNBTWriter(NBTTagCompound buf) {} protected T customNBTReader(NBTTagCompound buf) { return null; @@ -68,14 +65,12 @@ public class OrderStack { tmp.setByte("t", (byte) ITEM); ((ItemStack) RealStack).writeToNBT(tmp); buf.setTag(index + ":", tmp); - } - else if (RealStack instanceof FluidStack) { + } else if (RealStack instanceof FluidStack) { NBTTagCompound tmp = new NBTTagCompound(); tmp.setByte("t", (byte) FLUID); ((FluidStack) RealStack).writeToNBT(tmp); buf.setTag(index + ":", tmp); - } - else { + } else { NBTTagCompound tmp = new NBTTagCompound(); tmp.setByte("t", (byte) CUSTOM); customNBTWriter(tmp); @@ -99,5 +94,4 @@ public class OrderStack { throw new IllegalOrderStackID(id); } } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java b/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java index e292d635..20c1d246 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java +++ b/src/main/java/com/glodblock/github/nei/recipes/DefaultExtractorLoader.java @@ -18,7 +18,10 @@ public class DefaultExtractorLoader implements Runnable { if (ModAndClassUtil.GT5) { for (GT_Recipe.GT_Recipe_Map tMap : GT_Recipe.GT_Recipe_Map.sMappings) { - FluidRecipe.addRecipeMap(tMap.mNEIName, new GregTech5RecipeExtractor(tMap.mNEIName.equals("gt.recipe.scanner") || tMap.mNEIName.equals("gt.recipe.fakeAssemblylineProcess"))); + FluidRecipe.addRecipeMap( + tMap.mNEIName, + new GregTech5RecipeExtractor(tMap.mNEIName.equals("gt.recipe.scanner") + || tMap.mNEIName.equals("gt.recipe.fakeAssemblylineProcess"))); } } @@ -79,7 +82,5 @@ public class DefaultExtractorLoader implements Runnable { FluidRecipe.addRecipeMap("oreWashing", new IndustrialCraftRecipeExtractor()); FluidRecipe.addRecipeMap("solidcanner", new IndustrialCraftRecipeExtractor()); } - } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/FluidRecipe.java b/src/main/java/com/glodblock/github/nei/recipes/FluidRecipe.java index 4a528b9e..25ad6ffd 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/FluidRecipe.java +++ b/src/main/java/com/glodblock/github/nei/recipes/FluidRecipe.java @@ -6,16 +6,12 @@ import codechicken.nei.recipe.TemplateRecipeHandler; import com.glodblock.github.nei.object.IRecipeExtractor; import com.glodblock.github.nei.object.IRecipeExtractorLegacy; import com.glodblock.github.nei.object.OrderStack; -import gregtech.common.items.GT_FluidDisplayItem; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.fluids.FluidStack; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; public final class FluidRecipe { @@ -86,6 +82,4 @@ public final class FluidRecipe { if (useOther) tmp.addAll(recipe.getOtherStacks(index)); return extractor.getOutputIngredients(tmp, recipe, index); } - - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/EnderIORecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/EnderIORecipeExtractor.java index 3c1b79b9..04ddd6bf 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/EnderIORecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/EnderIORecipeExtractor.java @@ -8,22 +8,20 @@ import com.glodblock.github.nei.object.OrderStack; import com.glodblock.github.util.Ae2Reflect; import crazypants.enderio.machine.crusher.CrusherRecipeManager; import crazypants.enderio.nei.VatRecipeHandler; -import net.minecraftforge.fluids.FluidStack; - import java.lang.reflect.Field; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import net.minecraftforge.fluids.FluidStack; public class EnderIORecipeExtractor implements IRecipeExtractor { - public EnderIORecipeExtractor() { - } + public EnderIORecipeExtractor() {} @Override public List> getInputIngredients(List rawInputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawInputs.size(); i ++) { + for (int i = 0; i < rawInputs.size(); i++) { if (rawInputs.get(i) == null) continue; OrderStack stack = OrderStack.pack(rawInputs.get(i), i); if (stack != null) tmp.add(stack); @@ -34,7 +32,7 @@ public class EnderIORecipeExtractor implements IRecipeExtractor { @Override public List> getOutputIngredients(List rawOutputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawOutputs.size(); i ++) { + for (int i = 0; i < rawOutputs.size(); i++) { if (rawOutputs.get(i) == null) continue; OrderStack stack = OrderStack.pack(rawOutputs.get(i), i); if (stack != null) tmp.add(stack); @@ -49,7 +47,7 @@ public class EnderIORecipeExtractor implements IRecipeExtractor { if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) { VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index); ArrayList inputs = ReflectEIO.getInputs(vatRecipe); - for (int i = 0; i < inputs.size(); i ++) { + for (int i = 0; i < inputs.size(); i++) { if (inputs.get(i) == null) continue; OrderStack stack = OrderStack.pack(rawInputs.get(i), i); if (stack != null) tmp.add(stack); @@ -60,7 +58,7 @@ public class EnderIORecipeExtractor implements IRecipeExtractor { } return tmp; } else if (tRecipe.getOverlayIdentifier().equals("EnderIOSagMill")) { - for (int i = rawInputs.size() - 1; i >= 0; i --) { + for (int i = rawInputs.size() - 1; i >= 0; i--) { PositionedStack stack = rawInputs.get(i); if (stack != null && CrusherRecipeManager.getInstance().isValidSagBall(stack.items[0])) { rawInputs.remove(i); @@ -68,14 +66,14 @@ public class EnderIORecipeExtractor implements IRecipeExtractor { } } return getInputIngredients(rawInputs); - } - else { + } else { return getInputIngredients(rawInputs); } } @Override - public List> getOutputIngredients(List rawOutputs, IRecipeHandler recipe, int index) { + public List> getOutputIngredients( + List rawOutputs, IRecipeHandler recipe, int index) { TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe; List> tmp = new LinkedList<>(); if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) { @@ -85,17 +83,16 @@ public class EnderIORecipeExtractor implements IRecipeExtractor { tmp.add(new OrderStack<>(result, 0)); } return tmp; - } - else { + } else { return getOutputIngredients(rawOutputs); } } private static class ReflectEIO { - private final static Field inputsF; - private final static Field resultF; - private final static Field inFluidF; + private static final Field inputsF; + private static final Field resultF; + private static final Field inFluidF; static { try { @@ -118,7 +115,5 @@ public class EnderIORecipeExtractor implements IRecipeExtractor { private static FluidStack getInputFluid(VatRecipeHandler.InnerVatRecipe vat) { return Ae2Reflect.readField(vat, inFluidF); } - } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java index ac8ce26c..3e32e64a 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/ForestryRecipeExtractor.java @@ -9,11 +9,10 @@ import forestry.core.recipes.nei.PositionedFluidTank; import forestry.core.recipes.nei.RecipeHandlerBase; import forestry.factory.recipes.nei.NEIHandlerFabricator; import forestry.factory.recipes.nei.NEIHandlerSqueezer; -import net.minecraftforge.fluids.FluidStack; - import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import net.minecraftforge.fluids.FluidStack; public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { @@ -31,7 +30,7 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { @Override public List> getInputIngredients(List rawInputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawInputs.size(); i ++) { + for (int i = 0; i < rawInputs.size(); i++) { if (rawInputs.get(i) == null) continue; OrderStack stack = OrderStack.pack(rawInputs.get(i), i); if (stack != null) tmp.add(stack); @@ -42,7 +41,7 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { @Override public List> getOutputIngredients(List rawOutputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawOutputs.size(); i ++) { + for (int i = 0; i < rawOutputs.size(); i++) { if (rawOutputs.get(i) == null) continue; OrderStack stack = OrderStack.pack(rawOutputs.get(i), i); if (stack != null) tmp.add(stack); @@ -56,7 +55,8 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { List> tmp = new ArrayList<>(); if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) { tmp = getInputIngredients(rawInputs); - List tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks(); + List tanks = + ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks(); if (tanks.size() > 0 && !(handler instanceof NEIHandlerSqueezer)) { FluidStack fluid = tanks.get(0).tank.getFluid(); if (fluid != null) { @@ -68,20 +68,21 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { } @Override - public List> getOutputIngredients(List rawOutputs, IRecipeHandler recipe, int index) { + public List> getOutputIngredients( + List rawOutputs, IRecipeHandler recipe, int index) { TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe; removeGlass(rawOutputs); List> tmp = new ArrayList<>(); if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) { tmp = getOutputIngredients(rawOutputs); - List tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks(); + List tanks = + ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index)).getFluidTanks(); if (tanks.size() > 0 && handler instanceof NEIHandlerSqueezer) { FluidStack fluid = tanks.get(0).tank.getFluid(); if (fluid != null) { tmp.add(new OrderStack<>(fluid, rawOutputs.size())); } - } - else if (tanks.size() > 1) { + } else if (tanks.size() > 1) { FluidStack fluid = tanks.get(1).tank.getFluid(); if (fluid != null) { tmp.add(new OrderStack<>(fluid, rawOutputs.size())); @@ -96,5 +97,4 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy { list.remove(list.size() - 1); } } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/GTPPRecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/GTPPRecipeExtractor.java index 56149a46..43f10f61 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/GTPPRecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/GTPPRecipeExtractor.java @@ -9,5 +9,4 @@ public class GTPPRecipeExtractor extends GregTech5RecipeExtractor { public GTPPRecipeExtractor(boolean removeSpecial) { super(removeSpecial); } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java index 21251c85..c6612127 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech5RecipeExtractor.java @@ -5,14 +5,13 @@ import com.glodblock.github.nei.object.IRecipeExtractor; import com.glodblock.github.nei.object.OrderStack; import gregtech.api.enums.ItemList; import gregtech.common.items.GT_FluidDisplayItem; +import java.util.LinkedList; +import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import java.util.LinkedList; -import java.util.List; - public class GregTech5RecipeExtractor implements IRecipeExtractor { boolean removeSpecial; @@ -25,7 +24,7 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor { public List> getInputIngredients(List rawInputs) { if (removeSpecial) removeSpecial(rawInputs); List> tmp = new LinkedList<>(); - for (int i = 0; i < rawInputs.size(); i ++) { + for (int i = 0; i < rawInputs.size(); i++) { if (rawInputs.get(i) == null) continue; ItemStack item = rawInputs.get(i).items[0].copy(); OrderStack stack; @@ -46,7 +45,7 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor { @Override public List> getOutputIngredients(List rawOutputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawOutputs.size(); i ++) { + for (int i = 0; i < rawOutputs.size(); i++) { if (rawOutputs.get(i) == null) continue; ItemStack item = rawOutputs.get(i).items[0].copy(); OrderStack stack; @@ -65,14 +64,14 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor { } private void removeSpecial(List list) { - for (int i = list.size() - 1; i >= 0; i --) { + for (int i = list.size() - 1; i >= 0; i--) { PositionedStack positionedStack = list.get(i); - if (positionedStack != null && - (positionedStack.items[0].isItemEqual(ItemList.Tool_DataStick.get(1)) || positionedStack.items[0].isItemEqual(ItemList.Tool_DataOrb.get(1)))) { + if (positionedStack != null + && (positionedStack.items[0].isItemEqual(ItemList.Tool_DataStick.get(1)) + || positionedStack.items[0].isItemEqual(ItemList.Tool_DataOrb.get(1)))) { list.remove(i); break; } } } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java index 5ffa5956..55eb2d41 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/GregTech6RecipeExtractor.java @@ -5,11 +5,10 @@ import com.glodblock.github.nei.object.IRecipeExtractor; import com.glodblock.github.nei.object.OrderStack; import gregapi.item.ItemFluidDisplay; import gregapi.recipes.Recipe; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - import java.util.LinkedList; import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; public class GregTech6RecipeExtractor implements IRecipeExtractor { @@ -23,7 +22,7 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor { public List> getInputIngredients(List rawInputs) { this.removeMachine(rawInputs); List> tmp = new LinkedList<>(); - for (int i = 0; i < rawInputs.size(); i ++) { + for (int i = 0; i < rawInputs.size(); i++) { if (rawInputs.get(i) == null) continue; ItemStack item = rawInputs.get(i).items[0].copy(); OrderStack stack; @@ -43,7 +42,7 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor { @Override public List> getOutputIngredients(List rawOutputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawOutputs.size(); i ++) { + for (int i = 0; i < rawOutputs.size(); i++) { if (rawOutputs.get(i) == null) continue; ItemStack item = rawOutputs.get(i).items[0].copy(); OrderStack stack; @@ -61,7 +60,7 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor { } private void removeMachine(List list) { - for (int i = list.size() - 1; i >= 0; i --) { + for (int i = list.size() - 1; i >= 0; i--) { PositionedStack positionedStack = list.get(i); if (positionedStack != null) { for (ItemStack machine : this.Recipes.mRecipeMachineList) { @@ -73,5 +72,4 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor { } } } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/IndustrialCraftRecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/IndustrialCraftRecipeExtractor.java index 88343e44..495ef00f 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/IndustrialCraftRecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/IndustrialCraftRecipeExtractor.java @@ -7,22 +7,21 @@ import com.glodblock.github.nei.object.OrderStack; import com.glodblock.github.util.Ae2Reflect; import ic2.neiIntegration.core.recipehandler.FluidCannerRecipeHandler; import ic2.neiIntegration.core.recipehandler.OreWashingRecipeHandler; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; public class IndustrialCraftRecipeExtractor implements IRecipeExtractor { @Override public List> getInputIngredients(List rawInputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawInputs.size(); i ++) { + for (int i = 0; i < rawInputs.size(); i++) { if (rawInputs.get(i) == null) continue; tmp.add(OrderStack.pack(rawInputs.get(i), i)); } @@ -32,7 +31,7 @@ public class IndustrialCraftRecipeExtractor implements IRecipeExtractor { @Override public List> getOutputIngredients(List rawOutputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawOutputs.size(); i ++) { + for (int i = 0; i < rawOutputs.size(); i++) { if (rawOutputs.get(i) == null) continue; tmp.add(OrderStack.pack(rawOutputs.get(i), i)); } @@ -44,13 +43,14 @@ public class IndustrialCraftRecipeExtractor implements IRecipeExtractor { List> stacks = new LinkedList<>(); if (recipe instanceof FluidCannerRecipeHandler) { - FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = (FluidCannerRecipeHandler.CachedFluidCannerRecipe) ((FluidCannerRecipeHandler) recipe).arecipes.get(index); + FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = + (FluidCannerRecipeHandler.CachedFluidCannerRecipe) + ((FluidCannerRecipeHandler) recipe).arecipes.get(index); FluidStack input = ReflectIC2.getInputFluid(cachedRecipe); PositionedStack add = rawInputs.size() > 1 ? rawInputs.get(1) : null; stacks.add(OrderStack.pack(add, 0)); stacks.add(new OrderStack<>(input, 1)); - } - else if (recipe instanceof OreWashingRecipeHandler) { + } else if (recipe instanceof OreWashingRecipeHandler) { stacks = getInputIngredients(rawInputs); int water = ReflectIC2.getOreWasherWater((OreWashingRecipeHandler) recipe, index); stacks.add(new OrderStack<>(new FluidStack(FluidRegistry.WATER, water), stacks.size())); @@ -62,11 +62,14 @@ public class IndustrialCraftRecipeExtractor implements IRecipeExtractor { } @Override - public List> getOutputIngredients(List rawOutputs, IRecipeHandler recipe, int index) { + public List> getOutputIngredients( + List rawOutputs, IRecipeHandler recipe, int index) { List> stacks = new LinkedList<>(); if (recipe instanceof FluidCannerRecipeHandler) { - FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = (FluidCannerRecipeHandler.CachedFluidCannerRecipe) ((FluidCannerRecipeHandler) recipe).arecipes.get(index); + FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = + (FluidCannerRecipeHandler.CachedFluidCannerRecipe) + ((FluidCannerRecipeHandler) recipe).arecipes.get(index); FluidStack output = ReflectIC2.getOutputFluid(cachedRecipe); stacks.add(new OrderStack<>(output, 0)); } else { @@ -78,15 +81,16 @@ public class IndustrialCraftRecipeExtractor implements IRecipeExtractor { private static class ReflectIC2 { - private final static Field inputsF; - private final static Field resultF; + private static final Field inputsF; + private static final Field resultF; - private final static Method oreWasherWater; + private static final Method oreWasherWater; static { try { inputsF = Ae2Reflect.reflectField(FluidCannerRecipeHandler.CachedFluidCannerRecipe.class, "fluidInput"); - resultF = Ae2Reflect.reflectField(FluidCannerRecipeHandler.CachedFluidCannerRecipe.class, "fluidOutput"); + resultF = + Ae2Reflect.reflectField(FluidCannerRecipeHandler.CachedFluidCannerRecipe.class, "fluidOutput"); oreWasherWater = Ae2Reflect.reflectMethod(OreWashingRecipeHandler.class, "getreqWater", int.class); } catch (NoSuchFieldException | NoSuchMethodException e) { throw new IllegalStateException("Failed to initialize IC2 reflection hacks!", e); @@ -108,7 +112,5 @@ public class IndustrialCraftRecipeExtractor implements IRecipeExtractor { throw new IllegalStateException("Failed to invoke method: " + oreWasherWater, e); } } - } - } diff --git a/src/main/java/com/glodblock/github/nei/recipes/extractor/VanillaRecipeExtractor.java b/src/main/java/com/glodblock/github/nei/recipes/extractor/VanillaRecipeExtractor.java index a278bbfa..75b7a965 100644 --- a/src/main/java/com/glodblock/github/nei/recipes/extractor/VanillaRecipeExtractor.java +++ b/src/main/java/com/glodblock/github/nei/recipes/extractor/VanillaRecipeExtractor.java @@ -3,7 +3,6 @@ package com.glodblock.github.nei.recipes.extractor; import codechicken.nei.PositionedStack; import com.glodblock.github.nei.object.IRecipeExtractor; import com.glodblock.github.nei.object.OrderStack; - import java.util.LinkedList; import java.util.List; @@ -18,7 +17,7 @@ public class VanillaRecipeExtractor implements IRecipeExtractor { @Override public List> getInputIngredients(List rawInputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawInputs.size(); i ++) { + for (int i = 0; i < rawInputs.size(); i++) { if (rawInputs.get(i) == null) continue; final int col = (rawInputs.get(i).relx - 25) / 18; final int row = (rawInputs.get(i).rely - 6) / 18; @@ -32,7 +31,7 @@ public class VanillaRecipeExtractor implements IRecipeExtractor { @Override public List> getOutputIngredients(List rawOutputs) { List> tmp = new LinkedList<>(); - for (int i = 0; i < rawOutputs.size(); i ++) { + for (int i = 0; i < rawOutputs.size(); i++) { if (rawOutputs.get(i) == null) continue; final int col = (rawOutputs.get(i).relx - 25) / 18; final int row = (rawOutputs.get(i).rely - 6) / 18; @@ -42,5 +41,4 @@ public class VanillaRecipeExtractor implements IRecipeExtractor { } return tmp; } - } diff --git a/src/main/java/com/glodblock/github/network/CPacketCraftRequest.java b/src/main/java/com/glodblock/github/network/CPacketCraftRequest.java index d93a60b4..64033401 100644 --- a/src/main/java/com/glodblock/github/network/CPacketCraftRequest.java +++ b/src/main/java/com/glodblock/github/network/CPacketCraftRequest.java @@ -17,23 +17,21 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; +import java.util.Objects; +import java.util.concurrent.Future; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import javax.annotation.Nullable; -import java.util.Objects; -import java.util.concurrent.Future; - public class CPacketCraftRequest implements IMessage { private long amount; private boolean heldShift; - public CPacketCraftRequest() { - } + public CPacketCraftRequest() {} - public CPacketCraftRequest( final int craftAmt, final boolean shift ) { + public CPacketCraftRequest(final int craftAmt, final boolean shift) { amount = craftAmt; heldShift = shift; } @@ -55,64 +53,60 @@ public class CPacketCraftRequest implements IMessage { @Nullable @Override public IMessage onMessage(CPacketCraftRequest message, MessageContext ctx) { - if( ctx.getServerHandler().playerEntity.openContainer instanceof ContainerCraftAmount) - { + if (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerCraftAmount) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; - final ContainerCraftAmount cca = (ContainerCraftAmount) ctx.getServerHandler().playerEntity.openContainer; + final ContainerCraftAmount cca = + (ContainerCraftAmount) ctx.getServerHandler().playerEntity.openContainer; final Object target = cca.getTarget(); - if( target instanceof IGridHost) - { + if (target instanceof IGridHost) { final IGridHost gh = (IGridHost) target; - final IGridNode gn = gh.getGridNode( ForgeDirection.UNKNOWN ); + final IGridNode gn = gh.getGridNode(ForgeDirection.UNKNOWN); - if( gn == null ) - { + if (gn == null) { return null; } final IGrid g = gn.getGrid(); - if( g == null || cca.getItemToCraft() == null ) - { + if (g == null || cca.getItemToCraft() == null) { return null; } - cca.getItemToCraft().setStackSize( message.amount ); + cca.getItemToCraft().setStackSize(message.amount); Future futureJob = null; - try - { - final ICraftingGrid cg = g.getCache( ICraftingGrid.class ); - futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null ); + try { + final ICraftingGrid cg = g.getCache(ICraftingGrid.class); + futureJob = cg.beginCraftingJob( + cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null); final ContainerOpenContext context = cca.getOpenContext(); - if( context != null ) - { + if (context != null) { final TileEntity te = context.getTile(); - InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), GuiType.FLUID_CRAFTING_CONFIRM); + InventoryHandler.openGui( + player, + player.worldObj, + new BlockPos(te), + Objects.requireNonNull(Util.from(context.getSide())), + GuiType.FLUID_CRAFTING_CONFIRM); - if( player.openContainer instanceof ContainerFluidCraftConfirm) - { - final ContainerFluidCraftConfirm ccc = (ContainerFluidCraftConfirm) player.openContainer; - ccc.setAutoStart( message.heldShift ); - ccc.setJob( futureJob ); + if (player.openContainer instanceof ContainerFluidCraftConfirm) { + final ContainerFluidCraftConfirm ccc = + (ContainerFluidCraftConfirm) player.openContainer; + ccc.setAutoStart(message.heldShift); + ccc.setJob(futureJob); cca.detectAndSendChanges(); } } - } - catch( final Throwable e ) - { - if( futureJob != null ) - { - futureJob.cancel( true ); + } catch (final Throwable e) { + if (futureJob != null) { + futureJob.cancel(true); } - AELog.debug( e ); + AELog.debug(e); } } } return null; } - } - } diff --git a/src/main/java/com/glodblock/github/network/CPacketDumpTank.java b/src/main/java/com/glodblock/github/network/CPacketDumpTank.java index 8906b074..afa2c4c3 100644 --- a/src/main/java/com/glodblock/github/network/CPacketDumpTank.java +++ b/src/main/java/com/glodblock/github/network/CPacketDumpTank.java @@ -5,9 +5,8 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; - import javax.annotation.Nullable; +import net.minecraft.entity.player.EntityPlayerMP; public class CPacketDumpTank implements IMessage { @@ -38,11 +37,9 @@ public class CPacketDumpTank implements IMessage { public IMessage onMessage(CPacketDumpTank message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; if (player.openContainer instanceof TankDumpable) { - ((TankDumpable)player.openContainer).dumpTank(message.index); + ((TankDumpable) player.openContainer).dumpTank(message.index); } return null; } - } - } diff --git a/src/main/java/com/glodblock/github/network/CPacketEncodePattern.java b/src/main/java/com/glodblock/github/network/CPacketEncodePattern.java index b025844c..3cd62fe3 100644 --- a/src/main/java/com/glodblock/github/network/CPacketEncodePattern.java +++ b/src/main/java/com/glodblock/github/network/CPacketEncodePattern.java @@ -5,9 +5,8 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; - import javax.annotation.Nullable; +import net.minecraft.entity.player.EntityPlayerMP; public class CPacketEncodePattern implements IMessage { @@ -28,11 +27,9 @@ public class CPacketEncodePattern implements IMessage { public IMessage onMessage(CPacketEncodePattern message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; if (player.openContainer instanceof ContainerFluidPatternEncoder) { - ((ContainerFluidPatternEncoder)player.openContainer).encodePattern(); + ((ContainerFluidPatternEncoder) player.openContainer).encodePattern(); } return null; } - } - } diff --git a/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java b/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java index eb8530cf..9416940c 100644 --- a/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java +++ b/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java @@ -14,12 +14,12 @@ public class CPacketFluidPatternTermBtns implements IMessage { private String Name = ""; private String Value = ""; - public CPacketFluidPatternTermBtns( final String name, final String value ) { + public CPacketFluidPatternTermBtns(final String name, final String value) { Name = name; Value = value; } - public CPacketFluidPatternTermBtns( final String name, final Integer value ) { + public CPacketFluidPatternTermBtns(final String name, final Integer value) { Name = name; Value = value.toString(); } @@ -33,12 +33,12 @@ public class CPacketFluidPatternTermBtns implements IMessage { int leName = buf.readInt(); int leVal = buf.readInt(); StringBuilder sb = new StringBuilder(); - for (int i = 0; i < leName; i ++) { + for (int i = 0; i < leName; i++) { sb.append(buf.readChar()); } Name = sb.toString(); sb = new StringBuilder(); - for (int i = 0; i < leVal; i ++) { + for (int i = 0; i < leVal; i++) { sb.append(buf.readChar()); } Value = sb.toString(); @@ -48,10 +48,10 @@ public class CPacketFluidPatternTermBtns implements IMessage { public void toBytes(ByteBuf buf) { buf.writeInt(Name.length()); buf.writeInt(Value.length()); - for (int i = 0; i < Name.length(); i ++) { + for (int i = 0; i < Name.length(); i++) { buf.writeChar(Name.charAt(i)); } - for (int i = 0; i < Value.length(); i ++) { + for (int i = 0; i < Value.length(); i++) { buf.writeChar(Value.charAt(i)); } } @@ -63,8 +63,7 @@ public class CPacketFluidPatternTermBtns implements IMessage { String Name = message.Name; String Value = message.Value; final Container c = ctx.getServerHandler().playerEntity.openContainer; - if( Name.startsWith( "PatternTerminal." ) && (c instanceof ContainerFluidPatternTerminal)) - { + if (Name.startsWith("PatternTerminal.") && (c instanceof ContainerFluidPatternTerminal)) { final ContainerFluidPatternTerminal cpt = (ContainerFluidPatternTerminal) c; switch (Name) { case "PatternTerminal.CraftMode": @@ -96,8 +95,7 @@ public class CPacketFluidPatternTermBtns implements IMessage { cpt.getPatternTerminal().setCombineMode(Value.equals("1")); break; } - } else if( Name.startsWith( "PatternTerminalEx." ) && (c instanceof ContainerFluidPatternTerminalEx)) - { + } else if (Name.startsWith("PatternTerminalEx.") && (c instanceof ContainerFluidPatternTerminalEx)) { final ContainerFluidPatternTerminalEx cpt = (ContainerFluidPatternTerminalEx) c; switch (Name) { case "PatternTerminalEx.Encode": @@ -135,16 +133,14 @@ public class CPacketFluidPatternTermBtns implements IMessage { cpt.getPatternTerminal().setPrioritization(Value.equals("1")); break; } - } else if(Name.equals( "Terminal.Cpu" ) && c instanceof ContainerFluidCraftConfirm) { + } else if (Name.equals("Terminal.Cpu") && c instanceof ContainerFluidCraftConfirm) { final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c; - qk.cycleCpu( Value.equals( "Next" ) ); - } - else if( Name.equals( "Terminal.Start" ) && c instanceof ContainerFluidCraftConfirm ) { + qk.cycleCpu(Value.equals("Next")); + } else if (Name.equals("Terminal.Start") && c instanceof ContainerFluidCraftConfirm) { final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c; qk.startJob(); } return null; } - } } diff --git a/src/main/java/com/glodblock/github/network/CPacketInventoryAction.java b/src/main/java/com/glodblock/github/network/CPacketInventoryAction.java index 40b66be9..68312c24 100644 --- a/src/main/java/com/glodblock/github/network/CPacketInventoryAction.java +++ b/src/main/java/com/glodblock/github/network/CPacketInventoryAction.java @@ -4,9 +4,7 @@ import appeng.api.storage.data.IAEItemStack; import appeng.container.AEBaseContainer; import appeng.container.ContainerOpenContext; import appeng.container.implementations.ContainerCraftAmount; -import appeng.core.sync.GuiBridge; import appeng.helpers.InventoryAction; -import appeng.util.Platform; import appeng.util.item.AEItemStack; import com.glodblock.github.client.gui.container.ContainerPatternValueAmount; import com.glodblock.github.inventory.InventoryHandler; @@ -17,12 +15,11 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.tileentity.TileEntity; - -import javax.annotation.Nullable; import java.io.IOException; import java.util.Objects; +import javax.annotation.Nullable; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; public class CPacketInventoryAction implements IMessage { @@ -32,10 +29,9 @@ public class CPacketInventoryAction implements IMessage { private IAEItemStack stack; private boolean isEmpty; - public CPacketInventoryAction() { - } + public CPacketInventoryAction() {} - public CPacketInventoryAction( final InventoryAction action, final int slot, final int id ) { + public CPacketInventoryAction(final InventoryAction action, final int slot, final int id) { this.action = action; this.slot = slot; this.id = id; @@ -43,7 +39,7 @@ public class CPacketInventoryAction implements IMessage { this.isEmpty = true; } - public CPacketInventoryAction(final InventoryAction action, final int slot, final int id , IAEItemStack stack) { + public CPacketInventoryAction(final InventoryAction action, final int slot, final int id, IAEItemStack stack) { this.action = action; this.slot = slot; this.id = id; @@ -87,57 +83,58 @@ public class CPacketInventoryAction implements IMessage { @Override public IMessage onMessage(CPacketInventoryAction message, MessageContext ctx) { final EntityPlayerMP sender = ctx.getServerHandler().playerEntity; - if( sender.openContainer instanceof AEBaseContainer ) - { + if (sender.openContainer instanceof AEBaseContainer) { final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer; - if( message.action == InventoryAction.AUTO_CRAFT ) - { + if (message.action == InventoryAction.AUTO_CRAFT) { final ContainerOpenContext context = baseContainer.getOpenContext(); - if( context != null ) - { + if (context != null) { final TileEntity te = context.getTile(); - InventoryHandler.openGui( sender, te.getWorldObj(), new BlockPos(te), Objects.requireNonNull(Util.from(baseContainer.getOpenContext().getSide())), GuiType.FLUID_CRAFTING_AMOUNT ); + InventoryHandler.openGui( + sender, + te.getWorldObj(), + new BlockPos(te), + Objects.requireNonNull( + Util.from(baseContainer.getOpenContext().getSide())), + GuiType.FLUID_CRAFTING_AMOUNT); - if( sender.openContainer instanceof ContainerCraftAmount ) - { + if (sender.openContainer instanceof ContainerCraftAmount) { final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer; - if( baseContainer.getTargetStack() != null ) - { - cca.getCraftingItem().putStack( baseContainer.getTargetStack().getItemStack() ); - cca.setItemToCraft( baseContainer.getTargetStack() ); + if (baseContainer.getTargetStack() != null) { + cca.getCraftingItem() + .putStack(baseContainer.getTargetStack().getItemStack()); + cca.setItemToCraft(baseContainer.getTargetStack()); } cca.detectAndSendChanges(); } } - }else if (message.action == InventoryAction.valueOf("SET_PATTERN_VALUE")) - { + } else if (message.action == InventoryAction.valueOf("SET_PATTERN_VALUE")) { final ContainerOpenContext context = baseContainer.getOpenContext(); - if( context != null ) - { + if (context != null) { final TileEntity te = context.getTile(); - InventoryHandler.openGui(sender, te.getWorldObj(), new BlockPos(te), Objects.requireNonNull(Util.from(baseContainer.getOpenContext().getSide())), GuiType.PATTERN_VALUE_SET ); - if( sender.openContainer instanceof ContainerPatternValueAmount) - { + InventoryHandler.openGui( + sender, + te.getWorldObj(), + new BlockPos(te), + Objects.requireNonNull( + Util.from(baseContainer.getOpenContext().getSide())), + GuiType.PATTERN_VALUE_SET); + if (sender.openContainer instanceof ContainerPatternValueAmount) { final ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) sender.openContainer; - if( baseContainer.getTargetStack() != null ) - { - cpv.setValueIndex( message.slot ); - cpv.getPatternValue().putStack( baseContainer.getTargetStack().getItemStack() ); + if (baseContainer.getTargetStack() != null) { + cpv.setValueIndex(message.slot); + cpv.getPatternValue() + .putStack(baseContainer.getTargetStack().getItemStack()); } cpv.detectAndSendChanges(); } } - } - else - { - baseContainer.doAction( sender, message.action, message.slot, message.id ); + } else { + baseContainer.doAction(sender, message.action, message.slot, message.id); } } return null; } - } - } diff --git a/src/main/java/com/glodblock/github/network/CPacketPatternValueSet.java b/src/main/java/com/glodblock/github/network/CPacketPatternValueSet.java index f9881952..d04a8389 100644 --- a/src/main/java/com/glodblock/github/network/CPacketPatternValueSet.java +++ b/src/main/java/com/glodblock/github/network/CPacketPatternValueSet.java @@ -14,26 +14,22 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; +import java.util.Objects; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.FluidStack; -import java.util.Objects; - public class CPacketPatternValueSet implements IMessage { - private GuiType originGui; private int amount; private int valueIndex; - public CPacketPatternValueSet() { + public CPacketPatternValueSet() {} - } - - public CPacketPatternValueSet( int originalGui, int amount, int valueIndex ){ + public CPacketPatternValueSet(int originalGui, int amount, int valueIndex) { this.originGui = GuiType.getByOrdinal(originalGui); this.amount = amount; this.valueIndex = valueIndex; @@ -65,15 +61,22 @@ public class CPacketPatternValueSet implements IMessage { final ContainerOpenContext context = cpv.getOpenContext(); if (context != null) { final TileEntity te = context.getTile(); - InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), message.originGui); - if (player.openContainer instanceof ContainerFluidPatternTerminal || player.openContainer instanceof ContainerFluidPatternTerminalEx) { + InventoryHandler.openGui( + player, + player.worldObj, + new BlockPos(te), + Objects.requireNonNull(Util.from(context.getSide())), + message.originGui); + if (player.openContainer instanceof ContainerFluidPatternTerminal + || player.openContainer instanceof ContainerFluidPatternTerminalEx) { Slot slot = player.openContainer.getSlot(message.valueIndex); if (slot != null && slot.getHasStack()) { ItemStack stack = slot.getStack().copy(); if (Util.isFluidPacket(stack)) { FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack); if (fluidStack != null) { - fluidStack = ItemFluidPacket.getFluidStack(stack).copy(); + fluidStack = ItemFluidPacket.getFluidStack(stack) + .copy(); fluidStack.amount = message.amount; } slot.putStack(ItemFluidPacket.newStack(fluidStack)); @@ -82,13 +85,11 @@ public class CPacketPatternValueSet implements IMessage { slot.putStack(stack); } } - } } } } return null; } - } } diff --git a/src/main/java/com/glodblock/github/network/CPacketSetTargetItem.java b/src/main/java/com/glodblock/github/network/CPacketSetTargetItem.java index 2e9f6cbf..82a19f0c 100644 --- a/src/main/java/com/glodblock/github/network/CPacketSetTargetItem.java +++ b/src/main/java/com/glodblock/github/network/CPacketSetTargetItem.java @@ -7,16 +7,14 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.inventory.Container; - import java.io.IOException; +import net.minecraft.inventory.Container; public class CPacketSetTargetItem implements IMessage { private IAEItemStack stack; - public CPacketSetTargetItem() { - } + public CPacketSetTargetItem() {} public CPacketSetTargetItem(IAEItemStack stack) { this.stack = stack; @@ -50,7 +48,5 @@ public class CPacketSetTargetItem implements IMessage { } return null; } - } - } diff --git a/src/main/java/com/glodblock/github/network/CPacketSwitchGuis.java b/src/main/java/com/glodblock/github/network/CPacketSwitchGuis.java index c2b37e12..196d4755 100644 --- a/src/main/java/com/glodblock/github/network/CPacketSwitchGuis.java +++ b/src/main/java/com/glodblock/github/network/CPacketSwitchGuis.java @@ -10,13 +10,12 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; +import java.util.Objects; +import javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; -import javax.annotation.Nullable; -import java.util.Objects; - public class CPacketSwitchGuis implements IMessage { private GuiType guiType; @@ -51,7 +50,7 @@ public class CPacketSwitchGuis implements IMessage { if (!(cont instanceof AEBaseContainer)) { return null; } - ContainerOpenContext context = ((AEBaseContainer)cont).getOpenContext(); + ContainerOpenContext context = ((AEBaseContainer) cont).getOpenContext(); if (context == null) { return null; } @@ -59,9 +58,13 @@ public class CPacketSwitchGuis implements IMessage { if (te == null) { return null; } - InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), message.guiType); + InventoryHandler.openGui( + player, + player.worldObj, + new BlockPos(te), + Objects.requireNonNull(Util.from(context.getSide())), + message.guiType); return null; } } } - diff --git a/src/main/java/com/glodblock/github/network/CPacketTransferRecipe.java b/src/main/java/com/glodblock/github/network/CPacketTransferRecipe.java index 97a968cc..ac4b2031 100644 --- a/src/main/java/com/glodblock/github/network/CPacketTransferRecipe.java +++ b/src/main/java/com/glodblock/github/network/CPacketTransferRecipe.java @@ -10,25 +10,23 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; +import java.util.LinkedList; +import java.util.List; +import javax.annotation.Nullable; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -import javax.annotation.Nullable; -import java.util.LinkedList; -import java.util.List; - public class CPacketTransferRecipe implements IMessage { private List> inputs; private List> outputs; private boolean isCraft; - private final static int MAX_INDEX = 32; + private static final int MAX_INDEX = 32; - public CPacketTransferRecipe(){ - } + public CPacketTransferRecipe() {} public CPacketTransferRecipe(List> IN, List> OUT, boolean craft) { this.inputs = IN; @@ -36,8 +34,8 @@ public class CPacketTransferRecipe implements IMessage { this.isCraft = craft; } - //I should use GZIP to compress the message, but i'm too lazy. - //NBT to ByteBuf has a compress stream + // I should use GZIP to compress the message, but i'm too lazy. + // NBT to ByteBuf has a compress stream @Override public void toBytes(ByteBuf buf) { buf.writeBoolean(isCraft); @@ -63,11 +61,11 @@ public class CPacketTransferRecipe implements IMessage { NBTTagCompound nbt_m = ByteBufUtils.readTag(buf); NBTTagCompound nbt_i = nbt_m.getCompoundTag("i"); NBTTagCompound nbt_o = nbt_m.getCompoundTag("o"); - for (int i = 0; i < MAX_INDEX; i ++) { + for (int i = 0; i < MAX_INDEX; i++) { OrderStack tmp = OrderStack.readFromNBT(nbt_i, null, i); if (tmp != null) inputs.add(tmp); } - for (int i = 0; i < MAX_INDEX; i ++) { + for (int i = 0; i < MAX_INDEX; i++) { OrderStack tmp = OrderStack.readFromNBT(nbt_o, null, i); if (tmp != null) outputs.add(tmp); } @@ -85,10 +83,10 @@ public class CPacketTransferRecipe implements IMessage { cf.getPatternTerminal().setCraftingRecipe(message.isCraft); IInventory inputSlot = cf.getInventoryByName("crafting"); IInventory outputSlot = cf.getInventoryByName("output"); - for (int i = 0; i < inputSlot.getSizeInventory(); i ++) { + for (int i = 0; i < inputSlot.getSizeInventory(); i++) { inputSlot.setInventorySlotContents(i, null); } - for (int i = 0; i < outputSlot.getSizeInventory(); i ++) { + for (int i = 0; i < outputSlot.getSizeInventory(); i++) { outputSlot.setInventorySlotContents(i, null); } @@ -107,13 +105,10 @@ public class CPacketTransferRecipe implements IMessage { ItemStack stack1; if (stack.getStack() instanceof ItemStack) { stack1 = ((ItemStack) stack.getStack()).copy(); - } - else if (stack.getStack() instanceof FluidStack) { + } else if (stack.getStack() instanceof FluidStack) { stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack()); - } - else throw new UnsupportedOperationException("Trying to get an unsupported item!"); - if (index < inputSlot.getSizeInventory()) - inputSlot.setInventorySlotContents(index, stack1); + } else throw new UnsupportedOperationException("Trying to get an unsupported item!"); + if (index < inputSlot.getSizeInventory()) inputSlot.setInventorySlotContents(index, stack1); } } for (OrderStack stack : message.outputs) { @@ -122,13 +117,10 @@ public class CPacketTransferRecipe implements IMessage { ItemStack stack1; if (stack.getStack() instanceof ItemStack) { stack1 = ((ItemStack) stack.getStack()).copy(); - } - else if (stack.getStack() instanceof FluidStack) { + } else if (stack.getStack() instanceof FluidStack) { stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack()); - } - else throw new UnsupportedOperationException("Trying to get an unsupported item!"); - if (index < outputSlot.getSizeInventory()) - outputSlot.setInventorySlotContents(index, stack1); + } else throw new UnsupportedOperationException("Trying to get an unsupported item!"); + if (index < outputSlot.getSizeInventory()) outputSlot.setInventorySlotContents(index, stack1); } } c.onCraftMatrixChanged(inputSlot); @@ -138,10 +130,10 @@ public class CPacketTransferRecipe implements IMessage { boolean combine = cf.combine; IInventory inputSlot = cf.getInventoryByName("crafting"); IInventory outputSlot = cf.getInventoryByName("output"); - for (int i = 0; i < inputSlot.getSizeInventory(); i ++) { + for (int i = 0; i < inputSlot.getSizeInventory(); i++) { inputSlot.setInventorySlotContents(i, null); } - for (int i = 0; i < outputSlot.getSizeInventory(); i ++) { + for (int i = 0; i < outputSlot.getSizeInventory(); i++) { outputSlot.setInventorySlotContents(i, null); } @@ -158,13 +150,10 @@ public class CPacketTransferRecipe implements IMessage { ItemStack stack1; if (stack.getStack() instanceof ItemStack) { stack1 = ((ItemStack) stack.getStack()).copy(); - } - else if (stack.getStack() instanceof FluidStack) { + } else if (stack.getStack() instanceof FluidStack) { stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack()); - } - else throw new UnsupportedOperationException("Trying to get an unsupported item!"); - if (index < inputSlot.getSizeInventory()) - inputSlot.setInventorySlotContents(index, stack1); + } else throw new UnsupportedOperationException("Trying to get an unsupported item!"); + if (index < inputSlot.getSizeInventory()) inputSlot.setInventorySlotContents(index, stack1); } } for (OrderStack stack : message.outputs) { @@ -173,13 +162,10 @@ public class CPacketTransferRecipe implements IMessage { ItemStack stack1; if (stack.getStack() instanceof ItemStack) { stack1 = ((ItemStack) stack.getStack()).copy(); - } - else if (stack.getStack() instanceof FluidStack) { + } else if (stack.getStack() instanceof FluidStack) { stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack()); - } - else throw new UnsupportedOperationException("Trying to get an unsupported item!"); - if (index < outputSlot.getSizeInventory()) - outputSlot.setInventorySlotContents(index, stack1); + } else throw new UnsupportedOperationException("Trying to get an unsupported item!"); + if (index < outputSlot.getSizeInventory()) outputSlot.setInventorySlotContents(index, stack1); } } c.onCraftMatrixChanged(inputSlot); @@ -188,5 +174,4 @@ public class CPacketTransferRecipe implements IMessage { return null; } } - } diff --git a/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java b/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java index 1ff35a64..7f8ec770 100644 --- a/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java +++ b/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java @@ -10,19 +10,17 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; - import java.io.IOException; import java.util.HashMap; import java.util.Map; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; public class SPacketFluidUpdate implements IMessage { private Map list; - public SPacketFluidUpdate() { - } + public SPacketFluidUpdate() {} public SPacketFluidUpdate(Map data) { this.list = data; @@ -33,11 +31,10 @@ public class SPacketFluidUpdate implements IMessage { int size = buf.readInt(); this.list = new HashMap<>(); try { - for (int i = 0; i < size; i ++) { + for (int i = 0; i < size; i++) { int id = buf.readInt(); boolean isNull = buf.readBoolean(); - if (!isNull) - list.put(id, null); + if (!isNull) list.put(id, null); else { IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf); list.put(id, fluid); @@ -54,8 +51,7 @@ public class SPacketFluidUpdate implements IMessage { try { for (Map.Entry fs : list.entrySet()) { buf.writeInt(fs.getKey()); - if (fs.getValue() == null) - buf.writeBoolean(false); + if (fs.getValue() == null) buf.writeBoolean(false); else { buf.writeBoolean(true); fs.getValue().writeToPacket(buf); @@ -71,27 +67,24 @@ public class SPacketFluidUpdate implements IMessage { @Override public IMessage onMessage(SPacketFluidUpdate message, MessageContext ctx) { final GuiScreen gs = Minecraft.getMinecraft().currentScreen; - if( gs instanceof GuiIngredientBuffer) - { - for (Map.Entry e : message.list.entrySet() ) { - ( (GuiIngredientBuffer) gs ).update(e.getKey(), e.getValue()); + if (gs instanceof GuiIngredientBuffer) { + for (Map.Entry e : message.list.entrySet()) { + ((GuiIngredientBuffer) gs).update(e.getKey(), e.getValue()); } } else if (gs instanceof GuiLargeIngredientBuffer) { - for (Map.Entry e : message.list.entrySet() ) { - ( (GuiLargeIngredientBuffer) gs ).update(e.getKey(), e.getValue()); + for (Map.Entry e : message.list.entrySet()) { + ((GuiLargeIngredientBuffer) gs).update(e.getKey(), e.getValue()); } - } else if( gs instanceof GuiFluidIO) - { - for (Map.Entry e : message.list.entrySet() ) { - ( (GuiFluidIO) gs ).update(e.getKey(), e.getValue()); + } else if (gs instanceof GuiFluidIO) { + for (Map.Entry e : message.list.entrySet()) { + ((GuiFluidIO) gs).update(e.getKey(), e.getValue()); } } else if (gs instanceof GuiFluidInterface) { - for (Map.Entry e : message.list.entrySet() ) { - ( (GuiFluidInterface) gs ).update(e.getKey(), e.getValue()); + for (Map.Entry e : message.list.entrySet()) { + ((GuiFluidInterface) gs).update(e.getKey(), e.getValue()); } } return null; } - } } diff --git a/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java b/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java index 271ec56c..78837b76 100644 --- a/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java +++ b/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java @@ -8,13 +8,12 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; - import java.io.IOException; import java.nio.BufferOverflowException; import java.util.LinkedList; import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; public class SPacketMEInventoryUpdate implements IMessage { @@ -37,7 +36,7 @@ public class SPacketMEInventoryUpdate implements IMessage { ref = buf.readByte(); list = new LinkedList<>(); try { - for (int i = 0; i < amount; i ++) { + for (int i = 0; i < amount; i++) { list.add(AEItemStack.loadItemStackFromPacket(buf)); } } catch (IOException io) { @@ -58,7 +57,7 @@ public class SPacketMEInventoryUpdate implements IMessage { } } - public void appendItem( final IAEItemStack is ) throws BufferOverflowException { + public void appendItem(final IAEItemStack is) throws BufferOverflowException { list.add(is); } @@ -71,12 +70,10 @@ public class SPacketMEInventoryUpdate implements IMessage { @Override public IMessage onMessage(SPacketMEInventoryUpdate message, MessageContext ctx) { final GuiScreen gs = Minecraft.getMinecraft().currentScreen; - if( gs instanceof GuiFCBaseMonitor) - { - ( (GuiFCBaseMonitor) gs ).postUpdate(message.list); - } - else if ( gs instanceof GuiFluidCraftConfirm) { - ( (GuiFluidCraftConfirm) gs ).postUpdate( message.list, message.ref ); + if (gs instanceof GuiFCBaseMonitor) { + ((GuiFCBaseMonitor) gs).postUpdate(message.list); + } else if (gs instanceof GuiFluidCraftConfirm) { + ((GuiFluidCraftConfirm) gs).postUpdate(message.list, message.ref); } return null; } diff --git a/src/main/java/com/glodblock/github/proxy/ClientProxy.java b/src/main/java/com/glodblock/github/proxy/ClientProxy.java index e8e3e427..24f2cd17 100644 --- a/src/main/java/com/glodblock/github/proxy/ClientProxy.java +++ b/src/main/java/com/glodblock/github/proxy/ClientProxy.java @@ -11,19 +11,19 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; public class ClientProxy extends CommonProxy { @Override - public void preInit(FMLPreInitializationEvent event){ + public void preInit(FMLPreInitializationEvent event) { super.preInit(event); } @Override - public void init(FMLInitializationEvent event){ + public void init(FMLInitializationEvent event) { super.init(event); (new ListenerLoader()).run(); (new RenderLoader()).run(); } @Override - public void postInit(FMLPostInitializationEvent event){ + public void postInit(FMLPostInitializationEvent event) { super.postInit(event); if (ModAndClassUtil.NEI) { (new DefaultExtractorLoader()).run(); diff --git a/src/main/java/com/glodblock/github/proxy/CommonProxy.java b/src/main/java/com/glodblock/github/proxy/CommonProxy.java index 1b02c687..aab07044 100644 --- a/src/main/java/com/glodblock/github/proxy/CommonProxy.java +++ b/src/main/java/com/glodblock/github/proxy/CommonProxy.java @@ -11,10 +11,9 @@ public class CommonProxy { public final SimpleNetworkWrapper netHandler = NetworkRegistry.INSTANCE.newSimpleChannel(FluidCraft.MODID); - public void preInit(FMLPreInitializationEvent event){} + public void preInit(FMLPreInitializationEvent event) {} - public void init(FMLInitializationEvent event){} - - public void postInit(FMLPostInitializationEvent event){} + public void init(FMLInitializationEvent event) {} + public void postInit(FMLPostInitializationEvent event) {} } diff --git a/src/main/java/com/glodblock/github/util/Ae2Reflect.java b/src/main/java/com/glodblock/github/util/Ae2Reflect.java index 1ca3c2d5..29a1c4ad 100644 --- a/src/main/java/com/glodblock/github/util/Ae2Reflect.java +++ b/src/main/java/com/glodblock/github/util/Ae2Reflect.java @@ -15,7 +15,6 @@ import appeng.me.storage.MEInventoryHandler; import appeng.me.storage.MEPassThrough; import appeng.util.inv.ItemSlot; import appeng.util.prioitylist.IPartitionList; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Arrays; @@ -49,27 +48,28 @@ public class Ae2Reflect { fCPU_machineSrc = Ae2Reflect.reflectField(CraftingCPUCluster.class, "machineSrc"); mItemSlot_setExtractable = reflectMethod(ItemSlot.class, "setExtractable", boolean.class); mCPU_getGrid = reflectMethod(CraftingCPUCluster.class, "getGrid"); - mCPU_postChange = reflectMethod(CraftingCPUCluster.class, "postChange", IAEItemStack.class, BaseActionSource.class); + mCPU_postChange = + reflectMethod(CraftingCPUCluster.class, "postChange", IAEItemStack.class, BaseActionSource.class); mCPU_markDirty = reflectMethod(CraftingCPUCluster.class, "markDirty"); } catch (Exception e) { throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e); } } - public static Method reflectMethod(Class owner, String name, Class... paramTypes) throws NoSuchMethodException { + public static Method reflectMethod(Class owner, String name, Class... paramTypes) + throws NoSuchMethodException { Method m = owner.getDeclaredMethod(name, paramTypes); m.setAccessible(true); return m; } - public static Field reflectField(Class owner, String ...names) throws NoSuchFieldException { + public static Field reflectField(Class owner, String... names) throws NoSuchFieldException { Field f = null; for (String name : names) { try { f = owner.getDeclaredField(name); if (f != null) break; - } - catch (NoSuchFieldException ignore) { + } catch (NoSuchFieldException ignore) { } } if (f == null) throw new NoSuchFieldException("Can't find field from " + Arrays.toString(names)); @@ -80,7 +80,7 @@ public class Ae2Reflect { @SuppressWarnings("unchecked") public static T readField(Object owner, Field field) { try { - return (T)field.get(owner); + return (T) field.get(owner); } catch (Exception e) { throw new IllegalStateException("Failed to read field: " + field); } @@ -165,5 +165,4 @@ public class Ae2Reflect { throw new IllegalStateException("Failed to invoke method: " + mCPU_markDirty, e); } } - } diff --git a/src/main/java/com/glodblock/github/util/Ae2ReflectClient.java b/src/main/java/com/glodblock/github/util/Ae2ReflectClient.java index f40278ff..04c2221f 100644 --- a/src/main/java/com/glodblock/github/util/Ae2ReflectClient.java +++ b/src/main/java/com/glodblock/github/util/Ae2ReflectClient.java @@ -6,13 +6,12 @@ import appeng.client.gui.widgets.GuiTabButton; import appeng.client.render.AppEngRenderItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.List; import java.util.Set; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; @SideOnly(Side.CLIENT) public class Ae2ReflectClient { @@ -23,7 +22,6 @@ public class Ae2ReflectClient { private static final Field fGui_drag; private static final Method mGuiPatternTerm_inventorySlots; - static { try { fAEBaseGui_stackSizeRenderer = Ae2Reflect.reflectField(AEBaseGui.class, "aeRenderItem"); @@ -60,5 +58,4 @@ public class Ae2ReflectClient { public static GuiTabButton getOriginalGuiButton(GuiCraftingStatus gui) { return Ae2Reflect.readField(gui, fGuiCraftingStatus_originalGuiBtn); } - } diff --git a/src/main/java/com/glodblock/github/util/BlockPos.java b/src/main/java/com/glodblock/github/util/BlockPos.java index d0f706ea..24c3db0c 100644 --- a/src/main/java/com/glodblock/github/util/BlockPos.java +++ b/src/main/java/com/glodblock/github/util/BlockPos.java @@ -1,10 +1,9 @@ package com.glodblock.github.util; +import javax.annotation.Nonnull; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import javax.annotation.Nonnull; - public class BlockPos { private final int x; @@ -47,5 +46,4 @@ public class BlockPos { } return false; } - } diff --git a/src/main/java/com/glodblock/github/util/DualityFluidInterface.java b/src/main/java/com/glodblock/github/util/DualityFluidInterface.java index 50febdf1..40a9e337 100644 --- a/src/main/java/com/glodblock/github/util/DualityFluidInterface.java +++ b/src/main/java/com/glodblock/github/util/DualityFluidInterface.java @@ -34,6 +34,7 @@ import com.glodblock.github.inventory.AEFluidInventory; import com.glodblock.github.inventory.IAEFluidInventory; import com.glodblock.github.inventory.IAEFluidTank; import com.glodblock.github.inventory.MEMonitorIFluidHandler; +import java.util.Objects; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -43,9 +44,13 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import java.util.Objects; - -public class DualityFluidInterface implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IUpgradeableHost, IConfigManagerHost, IFluidHandler { +public class DualityFluidInterface + implements IGridTickable, + IStorageMonitorable, + IAEFluidInventory, + IUpgradeableHost, + IConfigManagerHost, + IFluidHandler { public static final int NUMBER_OF_TANKS = 6; public static final long TANK_CAPACITY = 16000; @@ -55,11 +60,13 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable private final BaseActionSource mySource; private boolean hasConfig = false; private final AEFluidInventory tanks = new AEFluidInventory(this, NUMBER_OF_TANKS, (int) TANK_CAPACITY); - private final AEFluidInventory config = new AEFluidInventory( this, NUMBER_OF_TANKS, Integer.MAX_VALUE ); + private final AEFluidInventory config = new AEFluidInventory(this, NUMBER_OF_TANKS, Integer.MAX_VALUE); private final IAEFluidStack[] requireWork; private int isWorking = -1; - private final MEMonitorPassThrough items = new MEMonitorPassThrough( new NullInventory(), StorageChannel.ITEMS ); - private final MEMonitorPassThrough fluids = new MEMonitorPassThrough(new NullInventory<>(), StorageChannel.FLUIDS ); + private final MEMonitorPassThrough items = + new MEMonitorPassThrough(new NullInventory(), StorageChannel.ITEMS); + private final MEMonitorPassThrough fluids = + new MEMonitorPassThrough(new NullInventory<>(), StorageChannel.FLUIDS); private boolean resetConfigCache = true; public DualityFluidInterface(final AENetworkProxy networkProxy, final IInterfaceHost ih) { @@ -71,7 +78,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable this.items.setChangeSource(this.mySource); this.requireWork = new IAEFluidStack[6]; - for(int i = 0; i < 6; ++i) { + for (int i = 0; i < 6; ++i) { this.requireWork[i] = null; } } @@ -79,8 +86,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable public IAEFluidStack getStandardFluid(IAEFluidStack fluid) { if (fluid == null) { return null; - } - else { + } else { return AEFluidStack.create(new FluidStack(fluid.getFluid(), 8000)); } } @@ -88,8 +94,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable public IAEFluidStack getStandardFluid(FluidStack fluid) { if (fluid == null) { return null; - } - else { + } else { return AEFluidStack.create(new FluidStack(fluid.getFluid(), 8000)); } } @@ -134,7 +139,10 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable private IMEMonitor getFluidGrid() { try { - return gridProxy.getGrid().getCache(IStorageGrid.class).getFluidInventory(); + return gridProxy + .getGrid() + .getCache(IStorageGrid.class) + .getFluidInventory(); } catch (GridAccessException e) { return null; } @@ -161,7 +169,8 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable @Override public TickingRequest getTickingRequest(IGridNode node) { - return new TickingRequest(TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), true); + return new TickingRequest( + TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), true); } @Override @@ -170,14 +179,15 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable return TickRateModulation.SLEEP; } else { boolean couldDoWork = this.updateStorage(); - return this.hasWorkToDo() ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) : TickRateModulation.SLEEP; + return this.hasWorkToDo() + ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) + : TickRateModulation.SLEEP; } } @Override public IMEMonitor getItemInventory() { - if( this.hasConfig ) - { + if (this.hasConfig) { return null; } return this.items; @@ -185,8 +195,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable @Override public IMEMonitor getFluidInventory() { - if( this.hasConfig ) - { + if (this.hasConfig) { if (this.resetConfigCache) { this.resetConfigCache = false; return new InterfaceInventory(this); @@ -201,9 +210,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable } @Override - public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) { - - } + public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) {} @Override public void onFluidInventoryChanged(IAEFluidTank inventory, int slot) { @@ -232,7 +239,6 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable } } } - } } @@ -247,7 +253,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable private boolean updateStorage() { boolean didSomething = false; - for(int x = 0; x < 6; ++x) { + for (int x = 0; x < 6; ++x) { if (this.requireWork[x] != null) { didSomething = this.usePlan(x) || didSomething; } @@ -267,14 +273,14 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable } IAEFluidStack toStore; if (work.getStackSize() > 0L) { - if ((long)this.tanks.fill(slot, work.getFluidStack(), false) != work.getStackSize()) { + if ((long) this.tanks.fill(slot, work.getFluidStack(), false) != work.getStackSize()) { changed = true; } else if (Objects.requireNonNull(getFluidGrid()).getStorageList().findPrecise(work) != null) { toStore = dest.extractItems(work, Actionable.MODULATE, this.mySource); if (toStore != null) { changed = true; int filled = this.tanks.fill(slot, toStore.getFluidStack(), true); - if ((long)filled != toStore.getStackSize()) { + if ((long) filled != toStore.getStackSize()) { throw new IllegalStateException("bad attempt at managing tanks. ( fill )"); } } @@ -283,13 +289,14 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable toStore = work.copy(); toStore.setStackSize(-toStore.getStackSize()); FluidStack canExtract = this.tanks.drain(slot, toStore.getFluidStack(), false); - if (canExtract != null && (long)canExtract.amount == toStore.getStackSize()) { - IAEFluidStack notStored = dest.injectItems(toStore, Actionable.MODULATE, this.mySource);; + if (canExtract != null && (long) canExtract.amount == toStore.getStackSize()) { + IAEFluidStack notStored = dest.injectItems(toStore, Actionable.MODULATE, this.mySource); + ; toStore.setStackSize(toStore.getStackSize() - (notStored == null ? 0L : notStored.getStackSize())); if (toStore.getStackSize() > 0L) { changed = true; FluidStack removed = this.tanks.drain(slot, toStore.getFluidStack(), true); - if (removed == null || toStore.getStackSize() != (long)removed.amount) { + if (removed == null || toStore.getStackSize() != (long) removed.amount) { throw new IllegalStateException("bad attempt at managing tanks. ( drain )"); } } @@ -357,7 +364,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable private void readConfig() { this.hasConfig = false; - for(int i = 0; i < this.config.getSlots(); ++i) { + for (int i = 0; i < this.config.getSlots(); ++i) { if (this.config.getFluidInSlot(i) != null) { this.hasConfig = true; break; @@ -366,7 +373,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable boolean had = this.hasWorkToDo(); - for(int x = 0; x < 6; ++x) { + for (int x = 0; x < 6; ++x) { this.updatePlan(x); } @@ -388,8 +395,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { IMEMonitor fluidGrid = getFluidGrid(); - if (fluidGrid == null || resource == null) - return 0; + if (fluidGrid == null || resource == null) return 0; int ori = resource.amount; IAEFluidStack remove; if (doFill) { @@ -430,5 +436,4 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable super(tileInterface.tanks); } } - } diff --git a/src/main/java/com/glodblock/github/util/FluidPatternDetails.java b/src/main/java/com/glodblock/github/util/FluidPatternDetails.java index e5f7da3b..7c35448d 100644 --- a/src/main/java/com/glodblock/github/util/FluidPatternDetails.java +++ b/src/main/java/com/glodblock/github/util/FluidPatternDetails.java @@ -3,6 +3,11 @@ package com.glodblock.github.util; import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.storage.data.IAEItemStack; import appeng.util.item.AEItemStack; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Nullable; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -10,13 +15,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -public class FluidPatternDetails implements ICraftingPatternDetails, Comparable{ +public class FluidPatternDetails implements ICraftingPatternDetails, Comparable { private final ItemStack patternStack; private IAEItemStack patternStackAe; @@ -43,8 +42,14 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< public void setPriority(int priority) { this.priority = priority; } - public void setCombine(int combine){ this.combine = combine;} - public int getCombine(){return combine;} + + public void setCombine(int combine) { + this.combine = combine; + } + + public int getCombine() { + return combine; + } @Override public boolean isCraftable() { @@ -91,9 +96,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< if (condensed.length == 0) { return false; } - this.outputs = Arrays.stream(outputs) - .filter(Objects::nonNull) - .toArray(IAEItemStack[]::new); + this.outputs = Arrays.stream(outputs).filter(Objects::nonNull).toArray(IAEItemStack[]::new); this.outputsCond = condensed; return true; } @@ -142,7 +145,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< // ae2 null-checks the pattern stack here for some reason, but doesn't null-check in hashCode() // this is inconsistent, so i've just decided to assert non-null in the constructor, which is to say that // the pattern stack can never be null here - return obj instanceof FluidPatternDetails && patternStackAe.equals(((FluidPatternDetails)obj).patternStackAe); + return obj instanceof FluidPatternDetails && patternStackAe.equals(((FluidPatternDetails) obj).patternStackAe); } @Override @@ -154,11 +157,11 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< NBTTagCompound tag = new NBTTagCompound(); tag.setTag("Inputs", writeStackArray(checkInitialized(inputs))); tag.setTag("Outputs", writeStackArray(checkInitialized(outputs))); - //Shits + // Shits tag.setTag("in", writeStackArray(checkInitialized(inputs))); tag.setTag("out", writeStackArray(checkInitialized(outputs))); - tag.setInteger("prioritize",this.getPriority()); - tag.setInteger("combine",this.getCombine()); + tag.setInteger("prioritize", this.getPriority()); + tag.setInteger("combine", this.getCombine()); patternStack.setTagCompound(tag); patternStackAe = Objects.requireNonNull(AEItemStack.create(patternStack)); return patternStack; @@ -184,7 +187,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< // may be possible to enter a partially-correct state if setInputs succeeds but setOutputs failed // but outside code should treat it as completely incorrect and not attempt to make calls return setInputs(readStackArray(tag.getTagList("in", Constants.NBT.TAG_COMPOUND))) - && setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND))); + && setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND))); } public static IAEItemStack[] readStackArray(NBTTagList listTag) { @@ -195,5 +198,4 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< } return stacks; } - } diff --git a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java index 1757afb2..8054c18c 100644 --- a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java +++ b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java @@ -7,7 +7,6 @@ import appeng.core.AEConfig; import appeng.core.localization.ButtonToolTips; import appeng.core.localization.GuiText; import cpw.mods.fml.common.Loader; - import java.lang.reflect.Field; public final class ModAndClassUtil { @@ -99,27 +98,16 @@ public final class ModAndClassUtil { essentiaGas = null; } - if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) - GT5 = true; - if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) - GT6 = true; - if (Loader.isModLoaded("extracells")) - EC2 = true; - if (Loader.isModLoaded("EnderIO")) - EIO = true; - if (Loader.isModLoaded("Forestry")) - FTR = true; - if (Loader.isModLoaded("OpenComputers")) - OC = true; - if (Loader.isModLoaded("thaumicenergistics")) - ThE = true; - if (Loader.isModLoaded("ae2wct")) - WCT = true; - if (Loader.isModLoaded("IC2")) - IC2 = true; - if (Loader.isModLoaded("NotEnoughItems")) - NEI = true; - if (Loader.isModLoaded("miscutils")) - GTPP = true; + if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) GT5 = true; + if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) GT6 = true; + if (Loader.isModLoaded("extracells")) EC2 = true; + if (Loader.isModLoaded("EnderIO")) EIO = true; + if (Loader.isModLoaded("Forestry")) FTR = true; + if (Loader.isModLoaded("OpenComputers")) OC = true; + if (Loader.isModLoaded("thaumicenergistics")) ThE = true; + if (Loader.isModLoaded("ae2wct")) WCT = true; + if (Loader.isModLoaded("IC2")) IC2 = true; + if (Loader.isModLoaded("NotEnoughItems")) NEI = true; + if (Loader.isModLoaded("miscutils")) GTPP = true; } } diff --git a/src/main/java/com/glodblock/github/util/NameConst.java b/src/main/java/com/glodblock/github/util/NameConst.java index ae0c3061..5e6c395a 100644 --- a/src/main/java/com/glodblock/github/util/NameConst.java +++ b/src/main/java/com/glodblock/github/util/NameConst.java @@ -43,5 +43,4 @@ public class NameConst { public static final String GUI_OC_PATTERN_EDITOR = GUI_KEY + BLOCK_OC_PATTERN_EDITOR; public static final String GUI_FLUID_IMPORT = GUI_KEY + ITEM_PART_FLUID_IMPORT; public static final String GUI_FLUID_EXPORT = GUI_KEY + ITEM_PART_FLUID_EXPORT; - } diff --git a/src/main/java/com/glodblock/github/util/ObjectArrayIterator.java b/src/main/java/com/glodblock/github/util/ObjectArrayIterator.java index 7f86db6d..4d27b3f6 100644 --- a/src/main/java/com/glodblock/github/util/ObjectArrayIterator.java +++ b/src/main/java/com/glodblock/github/util/ObjectArrayIterator.java @@ -27,7 +27,7 @@ public class ObjectArrayIterator implements /*Resettable*/ Iterator { /** The current iterator index */ int index = 0; - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- /** * Constructs an ObjectArrayIterator that will iterate over the values in the * specified array. @@ -85,7 +85,7 @@ public class ObjectArrayIterator implements /*Resettable*/ Iterator { } // Iterator interface - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- /** * Returns true if there are more elements to return from the array. @@ -123,7 +123,7 @@ public class ObjectArrayIterator implements /*Resettable*/ Iterator { } // Properties - //------------------------------------------------------------------------- + // ------------------------------------------------------------------------- /** * Gets the array that this iterator is iterating over. @@ -155,9 +155,8 @@ public class ObjectArrayIterator implements /*Resettable*/ Iterator { /** * Resets the iterator back to the start index. */ - //@Override + // @Override public void reset() { this.index = this.startIndex; } - } diff --git a/src/main/java/com/glodblock/github/util/RenderUtil.java b/src/main/java/com/glodblock/github/util/RenderUtil.java index a0ef8c1d..d8f06af9 100644 --- a/src/main/java/com/glodblock/github/util/RenderUtil.java +++ b/src/main/java/com/glodblock/github/util/RenderUtil.java @@ -9,7 +9,16 @@ public final class RenderUtil { renderItemIcon(icon, 0.0D, 0.0D, size, size, z, nx, ny, nz); } - public static void renderItemIcon(IIcon icon, double xStart, double yStart, double xEnd, double yEnd, double z, float nx, float ny, float nz) { + public static void renderItemIcon( + IIcon icon, + double xStart, + double yStart, + double xEnd, + double yEnd, + double z, + float nx, + float ny, + float nz) { if (icon == null) { return; } @@ -28,5 +37,4 @@ public final class RenderUtil { } Tessellator.instance.draw(); } - } diff --git a/src/main/java/com/glodblock/github/util/SetBackedMachineSet.java b/src/main/java/com/glodblock/github/util/SetBackedMachineSet.java index 6336362b..2f905a03 100644 --- a/src/main/java/com/glodblock/github/util/SetBackedMachineSet.java +++ b/src/main/java/com/glodblock/github/util/SetBackedMachineSet.java @@ -3,12 +3,11 @@ package com.glodblock.github.util; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.networking.IMachineSet; - -import javax.annotation.Nonnull; import java.util.Iterator; import java.util.Set; import java.util.Spliterator; import java.util.function.Consumer; +import javax.annotation.Nonnull; public class SetBackedMachineSet implements IMachineSet { @@ -56,5 +55,4 @@ public class SetBackedMachineSet implements IMachineSet { public Spliterator spliterator() { return backingSet.spliterator(); } - } diff --git a/src/main/java/com/glodblock/github/util/Util.java b/src/main/java/com/glodblock/github/util/Util.java index fb8e8471..ca49778c 100644 --- a/src/main/java/com/glodblock/github/util/Util.java +++ b/src/main/java/com/glodblock/github/util/Util.java @@ -23,9 +23,12 @@ public final class Util { public static EnumFacing from(ForgeDirection direction) { switch (direction) { - case WEST: return EnumFacing.EAST; - case EAST: return EnumFacing.WEST; - case UNKNOWN: return null; + case WEST: + return EnumFacing.EAST; + case EAST: + return EnumFacing.WEST; + case UNKNOWN: + return null; default: { int o = direction.ordinal(); return EnumFacing.values()[o]; @@ -35,8 +38,10 @@ public final class Util { public static ForgeDirection from(EnumFacing direction) { switch (direction) { - case WEST: return ForgeDirection.EAST; - case EAST: return ForgeDirection.WEST; + case WEST: + return ForgeDirection.EAST; + case EAST: + return ForgeDirection.WEST; default: { int o = direction.ordinal(); return ForgeDirection.values()[o]; @@ -52,7 +57,8 @@ public final class Util { return hasPermission(player, permission, host, ForgeDirection.UNKNOWN); } - public static boolean hasPermission(EntityPlayer player, SecurityPermissions permission, IGridHost host, ForgeDirection side) { + public static boolean hasPermission( + EntityPlayer player, SecurityPermissions permission, IGridHost host, ForgeDirection side) { return host == null || hasPermission(player, permission, host.getGridNode(side)); } @@ -64,21 +70,24 @@ public final class Util { return part == null || hasPermission(player, permission, part.getGridNode()); } - public static boolean hasPermission(EntityPlayer player, SecurityPermissions permission, ISecurityGrid securityGrid) { - return player == null || permission == null || securityGrid == null || securityGrid.hasPermission(player, permission); + public static boolean hasPermission( + EntityPlayer player, SecurityPermissions permission, ISecurityGrid securityGrid) { + return player == null + || permission == null + || securityGrid == null + || securityGrid.hasPermission(player, permission); } - public static ItemStack copyStackWithSize(ItemStack itemStack, int size) - { - if (size == 0 || itemStack == null) - return null; + public static ItemStack copyStackWithSize(ItemStack itemStack, int size) { + if (size == 0 || itemStack == null) return null; ItemStack copy = itemStack.copy(); copy.stackSize = size; return copy; } public static FluidStack getFluidFromItem(ItemStack stack) { - if (stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) { + if (stack != null + && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) { if (stack.getItem() instanceof IFluidContainerItem) { FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack); if (fluid != null) { @@ -108,14 +117,13 @@ public final class Util { return null; } - public static IAEFluidStack loadFluidStackFromNBT( final NBTTagCompound i ) - { - //Fuck ae2 + public static IAEFluidStack loadFluidStackFromNBT(final NBTTagCompound i) { + // Fuck ae2 final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1); - final AEFluidStack fluid = AEFluidStack.create( t ); - fluid.setStackSize( i.getLong( "Cnt" ) ); - fluid.setCountRequestable( i.getLong( "Req" ) ); - fluid.setCraftable( i.getBoolean( "Craft" ) ); + final AEFluidStack fluid = AEFluidStack.create(t); + fluid.setStackSize(i.getLong("Cnt")); + fluid.setCountRequestable(i.getLong("Req")); + fluid.setCraftable(i.getBoolean("Craft")); return fluid; } @@ -123,5 +131,4 @@ public final class Util { if (fluid1 == null || fluid2 == null) return false; return fluid1.isFluidEqual(fluid2); } - }