From bcb688c0798195c9bd06af28af9babb929a7a6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Dip=C4=8D=C3=A1r?= Date: Fri, 7 Oct 2022 16:23:15 +0200 Subject: [PATCH 1/9] Remove sides from fluid interface --- .../com/glodblock/github/client/gui/GuiFluidInterface.java | 3 --- .../com/glodblock/github/common/tile/TileFluidInterface.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) 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 b08677c0..b8a50d3a 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java @@ -84,9 +84,6 @@ public class GuiFluidInterface extends AEBaseGui { mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); for (int i = 0; i < 6; i++) { - 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); } 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..8fb21347 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java @@ -38,7 +38,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) { @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return this.getTanks().drain(from.ordinal(), maxDrain, doDrain); + return this.getTanks().drain(from, maxDrain, doDrain); } }; private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6); From d28ffa6adceb9987ecabbf3acc1d1d207f739308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Dip=C4=8D=C3=A1r?= Date: Fri, 7 Oct 2022 23:39:00 +0200 Subject: [PATCH 2/9] Fix Fluid Import Bus to be able to import multiple fluids just like EIO conduits --- .../common/parts/PartFluidImportBus.java | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) 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..b2ede2e2 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java @@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; public class PartFluidImportBus extends PartSharedFluidBus { @@ -72,30 +73,35 @@ public class PartFluidImportBus extends PartSharedFluidBus { final IFluidHandler fh = (IFluidHandler) te; final IMEMonitor inv = this.getProxy().getStorage().getFluidInventory(); - final FluidStack fluidStack = fh.drain( this.getSide().getOpposite(), this.calculateAmountToSend(), false ); - - if( this.filterEnabled() && !this.isInFilter( fluidStack ) ) - { - return TickRateModulation.SLOWER; - } - - final AEFluidStack aeFluidStack = AEFluidStack.create( fluidStack ); - - if( aeFluidStack != null ) - { - final IAEFluidStack notInserted = inv.injectItems( aeFluidStack, Actionable.MODULATE, this.source ); - - if( notInserted != null && notInserted.getStackSize() > 0 ) - { - aeFluidStack.decStackSize( notInserted.getStackSize() ); + int maxDrain = this.calculateAmountToSend(); + boolean drained = false; + FluidTankInfo[] tanksInfo = fh.getTankInfo(this.getSide().getOpposite()); + for (FluidTankInfo tankInfo : tanksInfo) { + if (tankInfo.fluid == null) { + continue; } - fh.drain( this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true ); + FluidStack fluidStack = new FluidStack(tankInfo.fluid, Math.min(tankInfo.fluid.amount, maxDrain)); + fluidStack = fh.drain(this.getSide().getOpposite(), fluidStack, false); + if (this.filterEnabled() && !this.isInFilter(fluidStack)) { + continue; + } - return TickRateModulation.FASTER; + final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack); + if (aeFluidStack != null) { + final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE, this.source); + + if (notInserted != null && notInserted.getStackSize() > 0) { + aeFluidStack.decStackSize(notInserted.getStackSize()); + } + + fh.drain(this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true); + maxDrain -= aeFluidStack.getFluidStack().amount; + drained = true; + } } - return TickRateModulation.IDLE; + return drained ? TickRateModulation.FASTER : TickRateModulation.SLOWER; } catch(GridAccessException e ) { From 18b67f804b02fb1fe45ad4d42c8987bc1be89d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Dip=C4=8D=C3=A1r?= <492666@mail.muni.cz> Date: Mon, 28 Nov 2022 01:53:10 +0100 Subject: [PATCH 3/9] Update buildscript --- .gitattributes | 44 ++++ build.gradle | 652 +++++++++++++++++++++++++++++++++++++----------- settings.gradle | 10 + 3 files changed, 558 insertions(+), 148 deletions(-) create mode 100644 .gitattributes create mode 100644 settings.gradle 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 ef6d0f45..89350b8a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,25 +1,40 @@ -//version: 1650343995 +//version: 1669411416 /* -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/master/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.11' + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.11' } } - 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,63 +133,79 @@ 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/" 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())) { + +final String modGroupPath = modGroup.toString().replaceAll("\\.", "/") +final String apiPackagePath = apiPackage.toString().replaceAll("\\.", "/") + +String targetPackageJava = javaSourceDir + modGroupPath +String targetPackageScala = scalaSourceDir + modGroupPath +String targetPackageKotlin = kotlinSourceDir + modGroupPath +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) { - 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 (apiPackage) { + targetPackageJava = javaSourceDir + modGroupPath + "/" + apiPackagePath + targetPackageScala = scalaSourceDir + modGroupPath + "/" + apiPackagePath + targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + apiPackagePath + 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()) { - throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!") +if (usesMixins.toBoolean()) { + if (mixinsPackage.isEmpty()) { + throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!") + } + final String mixinPackagePath = mixinsPackage.toString().replaceAll("\\.", "/") + final String mixinPluginPath = mixinPlugin.toString().replaceAll("\\.", "/") + + targetPackageJava = javaSourceDir + modGroupPath + "/" + mixinPackagePath + targetPackageScala = scalaSourceDir + modGroupPath + "/" + mixinPackagePath + targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPackagePath + 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) } - 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) - } - - 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())) { - throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin) + if (!mixinPlugin.isEmpty()) { + String targetFileJava = javaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java" + String targetFileScala = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".scala" + String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java" + String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPluginPath + ".kt" + 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) { - 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 (coreModClass) { + final String coreModPath = coreModClass.toString().replaceAll("\\.", "/") + String targetFileJava = javaSourceDir + modGroupPath + "/" + coreModPath + ".java" + String targetFileScala = scalaSourceDir + modGroupPath + "/" + coreModPath + ".scala" + String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + coreModPath + ".java" + String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + coreModPath + ".kt" + 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 +235,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 +246,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.toBoolean()) { arguments += [ "--tweakClass org.spongepowered.asm.launch.MixinTweaker" ] @@ -233,16 +279,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 +297,7 @@ minecraft { args(arguments) jvmArgs(jvmArguments) - if(developmentEnvironmentUserName) { + if (developmentEnvironmentUserName) { args("--username", developmentEnvironmentUserName) } } @@ -262,7 +308,7 @@ minecraft { } } -if(file('addon.gradle').exists()) { +if (file('addon.gradle').exists()) { apply from: 'addon.gradle' } @@ -279,33 +325,23 @@ repositories { name 'Overmind forge repo mirror' url 'https://gregtech.overminddl1.com/' } - if(usesMixins.toBoolean()) { + if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) { maven { - name 'sponge' - url 'https://repo.spongepowered.org/repository/maven-public' - } - maven { - url 'https://jitpack.io' + name = "GTNH Maven" + url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" } } } 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') - // 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 - exclude module: 'launchwrapper' - exclude module: 'guava' - exclude module: 'gson' - exclude module: 'commons-io' - exclude module: 'log4j-core' - } - compile('com.github.GTNewHorizons:SpongeMixins:1.5.0') + annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.1:processor') + } + if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) { + compile('com.gtnewhorizon:gtnhmixins:2.1.1') } } @@ -317,13 +353,18 @@ def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" task generateAssets { if (usesMixins.toBoolean()) { - def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json"); + def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json") if (!mixinConfigFile.exists()) { + def mixinPluginLine = "" + if(!mixinPlugin.isEmpty()) { + // We might not have a mixin plugin if we're using early/late mixins + mixinPluginLine += """\n "plugin": "${modGroup}.${mixinPlugin}", """ + } + mixinConfigFile.text = """{ "required": true, - "minVersion": "0.7.11", - "package": "${modGroup}.${mixinsPackage}", - "plugin": "${modGroup}.${mixinPlugin}", + "minVersion": "0.8.5-GTNH", + "package": "${modGroup}.${mixinsPackage}",${mixinPluginLine} "refmap": "${mixingConfigRefMap}", "target": "@env(DEFAULT)", "compatibilityLevel": "JAVA_8", @@ -353,7 +394,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 +412,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 +458,9 @@ runServer { tasks.withType(JavaExec).configureEach { javaLauncher.set( - javaToolchains.launcherFor { - languageVersion = projectJavaVersion - } + javaToolchains.launcherFor { + languageVersion = projectJavaVersion + } ) } @@ -424,6 +468,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 +481,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 +537,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 +568,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) { - include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' + from(sourceSets.main.allSource) { + include modGroupPath + "/" + apiPackagePath + '/**' } - from (sourceSets.main.output) { - include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**' + from(sourceSets.main.output) { + include modGroupPath + "/" + apiPackagePath + '/**' } - from (sourceSets.main.resources.srcDirs) { + from(sourceSets.main.resources.srcDirs) { include("LICENSE") } @@ -542,11 +591,11 @@ task apiJar(type: Jar) { } artifacts { - if(!noPublishedSources) { + if (!noPublishedSources) { archives sourcesJar } archives devJar - if(apiPackage) { + if (apiPackage) { archives apiJar } } @@ -564,10 +613,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 +631,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 +664,113 @@ publishing { } } +if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) { + apply plugin: 'com.modrinth.minotaur' + + File changelogFile = new File(System.getenv("CHANGELOG_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]) + } + } + if (usesMixins.toBoolean()) { + addModrinthDep("required", "version", "gtnhmixins") + } + tasks.modrinth.dependsOn(build) + tasks.publish.dependsOn(tasks.modrinth) +} + +if (curseForgeProjectId.size() != 0 && System.getenv("CURSEFORGE_TOKEN") != null) { + apply plugin: 'com.matthewprenger.cursegradle' + + File changelogFile = new File(System.getenv("CHANGELOG_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]) + } + } + if (usesMixins.toBoolean()) { + addCurseForgeRelation("requiredDependency", "gtnhmixins") + } + 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 +780,7 @@ task updateBuildScript { } } -if (isNewBuildScriptVersionAvailable(projectDir.toString())) { +if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAvailable(projectDir.toString())) { if (autoUpdateBuildScript.toBoolean()) { performBuildScriptUpdate(projectDir.toString()) } else { @@ -630,7 +789,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,6 +830,10 @@ 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 @@ -657,7 +853,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 +864,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 +969,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 +1033,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 +1083,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 +} From 05485ddaa66f68bb7d79dc0e363781b0ea96312a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Dip=C4=8D=C3=A1r?= <492666@mail.muni.cz> Date: Sat, 3 Dec 2022 21:08:31 +0100 Subject: [PATCH 4/9] Add SidelessMode button to FluidInterface --- .../github/client/gui/GuiDualInterface.java | 15 +++++++++- .../gui/container/ContainerDualInterface.java | 30 +++++++++++++++++++ .../common/tile/TileFluidInterface.java | 7 +++++ .../github/inventory/gui/GuiType.java | 2 +- 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/glodblock/github/client/gui/container/ContainerDualInterface.java 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..6a1835ef 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java @@ -2,6 +2,7 @@ package com.glodblock.github.client.gui; import appeng.api.config.InsertionMode; import appeng.api.config.Settings; +import appeng.api.config.SidelessMode; import appeng.api.config.YesNo; import appeng.client.gui.implementations.GuiUpgradeable; import appeng.client.gui.widgets.GuiImgButton; @@ -13,6 +14,7 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketConfigButton; import appeng.helpers.IInterfaceHost; import com.glodblock.github.FluidCraft; +import com.glodblock.github.client.gui.container.ContainerDualInterface; import com.glodblock.github.common.parts.PartFluidInterface; import com.glodblock.github.common.tile.TileFluidInterface; import com.glodblock.github.inventory.gui.GuiType; @@ -32,10 +34,11 @@ public class GuiDualInterface extends GuiUpgradeable { private GuiImgButton BlockMode; private GuiToggleButton interfaceMode; private GuiImgButton insertionMode; + private GuiImgButton sidelessMode; private final IInterfaceHost host; public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) { - super(new ContainerInterface(inventoryPlayer, te)); + super(new ContainerDualInterface(inventoryPlayer, te)); this.host = te; this.ySize = 211; } @@ -58,6 +61,9 @@ public class GuiDualInterface extends GuiUpgradeable { this.insertionMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT ); this.buttonList.add( this.insertionMode ); + + this.sidelessMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 62, Settings.SIDELESS_MODE, SidelessMode.SIDELESS); + this.buttonList.add( this.sidelessMode ); } @Override @@ -76,6 +82,9 @@ public class GuiDualInterface extends GuiUpgradeable { { this.insertionMode.set( ( (ContainerInterface) this.cvb ).getInsertionMode()); } + if (this.sidelessMode != null) { + this.sidelessMode.set( ( (ContainerDualInterface) this.cvb ).getSidelessMode()); + } this.fontRendererObj.drawString( getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752 ); } @@ -137,5 +146,9 @@ public class GuiDualInterface extends GuiUpgradeable { { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.insertionMode.getSetting(), backwards ) ); } + if (btn == this.sidelessMode) + { + NetworkHandler.instance.sendToServer( new PacketConfigButton( this.sidelessMode.getSetting(), backwards ) ); + } } } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerDualInterface.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerDualInterface.java new file mode 100644 index 00000000..77baccaf --- /dev/null +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerDualInterface.java @@ -0,0 +1,30 @@ +package com.glodblock.github.client.gui.container; + +import appeng.api.config.Settings; +import appeng.api.config.SidelessMode; +import appeng.api.util.IConfigManager; +import appeng.container.guisync.GuiSync; +import appeng.container.implementations.ContainerInterface; +import appeng.helpers.IInterfaceHost; +import net.minecraft.entity.player.InventoryPlayer; + +public class ContainerDualInterface extends ContainerInterface { + + @GuiSync(10) + public SidelessMode sidelessMode; + + public ContainerDualInterface(InventoryPlayer ip, IInterfaceHost te) { + super(ip, te); + this.sidelessMode = SidelessMode.SIDELESS; + } + + public SidelessMode getSidelessMode() { + return this.sidelessMode; + } + + @Override + protected void loadSettingsFromHost(IConfigManager cm) { + super.loadSettingsFromHost(cm); + this.sidelessMode = (SidelessMode) cm.getSetting(Settings.SIDELESS_MODE); + } +} 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 8fb21347..d04240a9 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java @@ -1,5 +1,7 @@ package com.glodblock.github.common.tile; +import appeng.api.config.Settings; +import appeng.api.config.SidelessMode; import appeng.api.config.Upgrades; import appeng.api.networking.IGridNode; import appeng.api.networking.events.MENetworkChannelsChanged; @@ -35,6 +37,11 @@ import java.io.IOException; public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory { + public TileFluidInterface() { + super.getInterfaceDuality().getConfigManager() + .registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS); + } + private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) { @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { 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 4d8c972d..a1291629 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java +++ b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java @@ -69,7 +69,7 @@ public enum GuiType { DUAL_INTERFACE(new TileGuiFactory(TileFluidInterface.class) { @Override protected Object createServerGui(EntityPlayer player, TileFluidInterface inv) { - return new ContainerInterface(player.inventory, inv); + return new ContainerDualInterface(player.inventory, inv); } @Override From d712c01657f5ed631d6faa3cfc98be1a1588352f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Dip=C4=8D=C3=A1r?= <492666@mail.muni.cz> Date: Sat, 3 Dec 2022 23:28:20 +0100 Subject: [PATCH 5/9] Make DualInterface behaviour correspond to sideless setting --- .../glodblock/github/client/gui/GuiFluidInterface.java | 3 +++ .../github/common/tile/TileFluidInterface.java | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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 b8a50d3a..b08677c0 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java @@ -84,6 +84,9 @@ public class GuiFluidInterface extends AEBaseGui { mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); for (int i = 0; i < 6; i++) { + 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); } 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 d04240a9..7e8fbe3c 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java @@ -10,6 +10,7 @@ import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; import appeng.api.storage.data.IAEFluidStack; +import appeng.api.util.IConfigManager; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; import appeng.tile.inventory.AppEngInternalAEInventory; @@ -43,9 +44,16 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, } private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) { + private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager(); + @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return this.getTanks().drain(from, maxDrain, doDrain); + SidelessMode mode = (SidelessMode) dualityConfigManager.getSetting(Settings.SIDELESS_MODE); + if (mode == SidelessMode.SIDELESS) { + return this.getTanks().drain(from, maxDrain, doDrain); + } + + return this.getTanks().drain(from.ordinal(), maxDrain, doDrain); } }; private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6); From e8a0523d56e540321bbae49847081caa94116560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Dip=C4=8D=C3=A1r?= <492666@mail.muni.cz> Date: Sun, 4 Dec 2022 13:00:47 +0100 Subject: [PATCH 6/9] Update ae2 version --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index 2e6b4529..c68f2f33 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { compile('com.github.GTNewHorizons:NotEnoughItems:2.3.10-GTNH:dev') - compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-117-GTNH:dev') + compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-121-GTNH:dev') compile('curse.maven:cofh-core-69162:2388751') compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false } compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev") From e54d274b887b1484a601fceb7b4f5ee06bd70334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Dip=C4=8D=C3=A1r?= <492666@mail.muni.cz> Date: Sun, 4 Dec 2022 13:16:26 +0100 Subject: [PATCH 7/9] Fix button visible in part interface --- .../github/client/gui/GuiDualInterface.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) 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 6a1835ef..07dca5cb 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java @@ -62,8 +62,10 @@ public class GuiDualInterface extends GuiUpgradeable { this.insertionMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT ); this.buttonList.add( this.insertionMode ); - this.sidelessMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 62, Settings.SIDELESS_MODE, SidelessMode.SIDELESS); - this.buttonList.add( this.sidelessMode ); + if (isTile()) { + this.sidelessMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 62, Settings.SIDELESS_MODE, SidelessMode.SIDELESS); + this.buttonList.add( this.sidelessMode ); + } } @Override @@ -115,20 +117,20 @@ public class GuiDualInterface extends GuiUpgradeable { if( btn == this.priority ) { - if (host instanceof TileFluidInterface) { + if (isTile()) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY)); } - else if(host instanceof PartFluidInterface) { + else if(isPart()) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART)); } } if( btn == this.switcher ) { - if (host instanceof TileFluidInterface) { + if (isTile()) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID)); } - else if (host instanceof PartFluidInterface) { + else if (isPart()) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART)); } } @@ -146,9 +148,17 @@ public class GuiDualInterface extends GuiUpgradeable { { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.insertionMode.getSetting(), backwards ) ); } - if (btn == this.sidelessMode) + if (btn == this.sidelessMode && this.sidelessMode != null) { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.sidelessMode.getSetting(), backwards ) ); } } + + private boolean isPart() { + return this.host instanceof PartFluidInterface; + } + + private boolean isTile() { + return this.host instanceof TileFluidInterface; + } } From 6acf2bace1d66cb8b9e64ea5cbe501f3bbe8acb5 Mon Sep 17 00:00:00 2001 From: asdflj <854865755@qq.com> Date: Mon, 5 Dec 2022 10:57:27 +0800 Subject: [PATCH 8/9] uh --- .../com/glodblock/github/crossmod/waila/Tooltip.java | 11 ++++++----- .../crossmod/waila/part/SpeedWailaDataProvider.java | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java b/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java index e5b23016..2bbdc363 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java @@ -1,28 +1,29 @@ package com.glodblock.github.crossmod.waila; -import appeng.util.Utility; import com.glodblock.github.util.NameConst; import com.glodblock.github.util.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; import net.minecraftforge.fluids.FluidStack; +import java.text.NumberFormat; + public class Tooltip { public static String fluidFormat(String name, int amount) { - return String.format("%s: %s mB", name, Utility.formatNumbers(amount)); + return String.format("%s: %s mB", name, NumberFormat.getInstance().format(amount)); } public static String partFluidBusFormat(int amount) { - return String.format("%s: %s mB/t", I18n.format(NameConst.WAILA_SPEED), Utility.formatNumbers(amount / 5)); + return String.format("%s: %s mB/t", I18n.format(NameConst.WAILA_SPEED), NumberFormat.getInstance().format(amount)); } public static String tileFluidInterfaceFormat(String name, int amount, int face) { - return String.format("%s %s: %s mB", I18n.format(NameConst.GUI_FLUID_INTERFACE + "." + face), name, Utility.formatNumbers(amount)); + return String.format("%s %s: %s mB", I18n.format(NameConst.GUI_FLUID_INTERFACE + "." + face), name, NumberFormat.getInstance().format(amount)); } public static String tileLevelMaintainerFormat(String name, long quantity, long batch, boolean isEnable) { return String.format("%s: %s / %s %s", - name, Utility.formatNumbers(quantity), Utility.formatNumbers(batch), + name, NumberFormat.getInstance().format(quantity), NumberFormat.getInstance().format(batch), isEnable ? I18n.format(NameConst.WAILA_ENABLE) : I18n.format(NameConst.WAILA_DISABLE) ); } diff --git a/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java index 329c8941..fad23841 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java @@ -23,7 +23,7 @@ public class SpeedWailaDataProvider extends BasePartWailaDataProvider { final IWailaConfigHandler config) { if (part instanceof PartSharedFluidBus) { part.readFromNBT(accessor.getNBTData()); - currentToolTip.add(Tooltip.partFluidBusFormat(((PartSharedFluidBus) part).calculateAmountToSend())); + currentToolTip.add(Tooltip.partFluidBusFormat(((PartSharedFluidBus) part).calculateAmountToSend() / 5)); } return currentToolTip; } From 5e31096c7e0e4b9a97f8a9dfb4efccefdd2ac21c Mon Sep 17 00:00:00 2001 From: asdflj <854865755@qq.com> Date: Mon, 5 Dec 2022 14:31:09 +0800 Subject: [PATCH 9/9] spotless apply --- dependencies.gradle | 2 +- .../java/com/glodblock/github/FluidCraft.java | 36 +- .../glodblock/github/client/ClientHelper.java | 12 +- .../github/client/gui/FCGuiTextField.java | 31 +- .../gui/GuiBaseFluidPatternTerminal.java | 189 +++--- .../gui/GuiBaseFluidPatternTerminalEx.java | 210 +++--- .../client/gui/GuiBaseFluidTerminal.java | 2 - .../github/client/gui/GuiDualInterface.java | 114 ++-- .../client/gui/GuiFCBaseFluidMonitor.java | 163 +++-- .../github/client/gui/GuiFCBaseMonitor.java | 600 ++++++++--------- .../github/client/gui/GuiFCImgButton.java | 177 +++-- .../github/client/gui/GuiFCPriority.java | 188 +++--- .../client/gui/GuiFluidCraftAmount.java | 203 +++--- .../client/gui/GuiFluidCraftConfirm.java | 446 ++++++------- .../github/client/gui/GuiFluidIO.java | 48 +- .../github/client/gui/GuiFluidInterface.java | 67 +- .../client/gui/GuiFluidPacketDecoder.java | 1 - .../client/gui/GuiFluidPatternEncoder.java | 47 +- .../client/gui/GuiFluidPatternTerminal.java | 18 +- ...GuiFluidPatternTerminalCraftingStatus.java | 7 +- .../client/gui/GuiFluidPatternTerminalEx.java | 18 +- .../github/client/gui/GuiFluidTerminal.java | 27 +- .../client/gui/GuiIngredientBuffer.java | 37 +- .../client/gui/GuiLargeIngredientBuffer.java | 40 +- .../github/client/gui/GuiLevelMaintainer.java | 78 ++- .../client/gui/GuiPatternValueAmount.java | 20 +- .../github/client/gui/TankDumpable.java | 1 - .../container/ContainerFluidConfigurable.java | 104 ++- .../container/ContainerFluidCraftConfirm.java | 365 +++++------ .../gui/container/ContainerFluidIO.java | 10 +- .../container/ContainerFluidInterface.java | 39 +- .../ContainerFluidPacketDecoder.java | 5 +- .../ContainerFluidPatternEncoder.java | 44 +- .../ContainerFluidPatternTerminal.java | 45 +- .../ContainerFluidPatternTerminalEx.java | 48 +- .../container/ContainerIngredientBuffer.java | 16 +- .../ContainerLargeIngredientBuffer.java | 17 +- .../container/ContainerLevelMaintainer.java | 1 - .../container/ContainerOCPatternEditor.java | 14 +- .../ContainerPatternValueAmount.java | 24 +- .../container/FCBaseFluidMonitorContain.java | 99 ++- .../gui/container/FCBaseMonitorContain.java | 349 +++++----- .../gui/container/FCBasePartContainer.java | 603 +++++++++--------- .../gui/container/FCBasePartContainerEx.java | 473 +++++++------- .../gui/container/FluidPrioritization.java | 6 - .../glodblock/github/client/me/FluidRepo.java | 16 +- .../github/client/render/ItemDropRender.java | 20 +- .../client/render/ItemPacketRender.java | 18 +- .../render/RenderBlockFluidInterface.java | 29 +- .../render/RenderBlockLevelMaintainer.java | 9 +- .../client/textures/FCPartsTexture.java | 39 +- .../com/glodblock/github/common/Config.java | 36 +- .../common/block/BlockFluidDiscretizer.java | 1 - .../common/block/BlockFluidInterface.java | 48 +- .../common/block/BlockFluidPacketDecoder.java | 11 +- .../block/BlockFluidPatternEncoder.java | 11 +- .../common/block/BlockIngredientBuffer.java | 7 +- .../block/BlockLargeIngredientBuffer.java | 11 +- .../common/block/BlockLevelMaintainer.java | 10 +- .../common/block/BlockOCPatternEditor.java | 7 +- .../github/common/block/FCBaseBlock.java | 8 +- .../item/ItemBasicFluidStorageCell.java | 223 ++++--- .../item/ItemBasicFluidStoragePart.java | 10 +- .../github/common/item/ItemFluidDrop.java | 11 +- .../common/item/ItemFluidEncodedPattern.java | 14 +- .../common/item/ItemFluidExportBus.java | 20 +- .../common/item/ItemFluidImportBus.java | 19 +- .../github/common/item/ItemFluidPacket.java | 57 +- .../common/item/ItemPartFluidInterface.java | 19 +- .../item/ItemPartFluidPatternTerminal.java | 19 +- .../item/ItemPartFluidPatternTerminalEx.java | 19 +- .../common/item/ItemPartFluidTerminal.java | 26 +- .../github/common/parts/FCBasePart.java | 408 ++++++------ .../common/parts/PartFluidExportBus.java | 221 ++++--- .../common/parts/PartFluidImportBus.java | 154 ++--- .../common/parts/PartFluidInterface.java | 139 ++-- .../parts/PartFluidPatternTerminal.java | 139 ++-- .../parts/PartFluidPatternTerminalEx.java | 134 ++-- .../common/parts/PartFluidTerminal.java | 14 +- .../common/parts/PartSharedFluidBus.java | 107 ++-- .../github/common/storage/CellType.java | 52 +- .../common/storage/FluidCellHandler.java | 52 +- .../common/storage/FluidCellInventory.java | 260 +++----- .../storage/FluidCellInventoryHandler.java | 33 +- .../common/storage/IFluidCellInventory.java | 3 +- .../storage/IFluidCellInventoryHandler.java | 1 - .../common/storage/IStorageFluidCell.java | 11 +- .../github/common/tabs/FluidCraftingTabs.java | 2 +- .../common/tile/TileFluidDiscretizer.java | 36 +- .../common/tile/TileFluidInterface.java | 60 +- .../common/tile/TileFluidPacketDecoder.java | 10 +- .../common/tile/TileFluidPatternEncoder.java | 18 +- .../common/tile/TileIngredientBuffer.java | 13 +- .../tile/TileLargeIngredientBuffer.java | 9 +- .../common/tile/TileLevelMaintainer.java | 38 +- .../common/tile/TileOCPatternEditor.java | 5 +- .../github/coremod/FCClassTransformer.java | 4 +- .../github/coremod/FluidCraftCore.java | 6 +- .../github/coremod/hooker/CoreModHooks.java | 49 +- ...ContainerInterfaceTerminalTransformer.java | 19 +- .../transform/CraftingCpuTransformer.java | 78 +-- .../CraftingTreeNodeTransformer.java | 49 +- .../DualityInterfaceTransformer.java | 30 +- .../transform/GuiCraftingTransformer.java | 20 +- .../coremod/transform/NEITransfermer.java | 33 +- .../transform/TitleIOPortTransformer.java | 14 +- .../DriverDualFluidInterface.java | 28 +- .../opencomputers/DriverLevelMaintainer.java | 38 +- .../opencomputers/DriverOCPatternEditor.java | 78 ++- .../crossmod/opencomputers/OCDriverInit.java | 1 - .../crossmod/waila/FCTooltipHandlerWaila.java | 15 +- .../crossmod/waila/PartWailaDataProvider.java | 41 +- .../crossmod/waila/TileWailaDataProvider.java | 41 +- .../github/crossmod/waila/Tooltip.java | 23 +- .../github/crossmod/waila/WailaInit.java | 1 - .../waila/part/FluidInvWailaDataProvider.java | 27 +- .../waila/part/SpeedWailaDataProvider.java | 27 +- .../waila/tile/FluidInvWailaDataProvider.java | 28 +- .../tile/LevelMaintainerWailaDataProvide.java | 38 +- .../github/inventory/AEFluidInventory.java | 284 +++------ .../github/inventory/AeItemStackHandler.java | 16 +- .../github/inventory/AeStackInventory.java | 4 +- .../inventory/AeStackInventoryImpl.java | 17 +- .../inventory/BiggerAppEngInventory.java | 1 - .../FluidConvertingInventoryAdaptor.java | 98 +-- .../FluidConvertingInventoryCrafting.java | 4 +- .../github/inventory/IAEFluidInventory.java | 3 +- .../github/inventory/IAEFluidTank.java | 5 +- .../github/inventory/InventoryHandler.java | 12 +- .../inventory/MEMonitorIFluidHandler.java | 39 +- .../github/inventory/PatternConsumer.java | 1 - .../inventory/gui/ButtonMouseHandler.java | 7 +- .../github/inventory/gui/GuiFactory.java | 4 +- .../github/inventory/gui/GuiType.java | 6 +- .../inventory/gui/MouseRegionManager.java | 16 +- .../github/inventory/gui/PartGuiFactory.java | 5 +- .../inventory/gui/TankMouseHandler.java | 17 +- .../github/inventory/gui/TileGuiFactory.java | 5 +- .../slot/OptionalFluidSlotFakeTypeOnly.java | 18 +- .../github/inventory/slot/SlotFluid.java | 3 - .../github/inventory/slot/SlotSingleItem.java | 1 - .../github/loader/ChannelLoader.java | 42 +- .../github/loader/ItemAndBlockHolder.java | 16 +- .../github/loader/ListenerLoader.java | 1 - .../glodblock/github/loader/RecipeLoader.java | 302 +++++++-- .../glodblock/github/loader/RenderLoader.java | 1 - ...dPatternTerminalRecipeTransferHandler.java | 10 +- .../glodblock/github/nei/NEIGuiHandler.java | 1 - .../com/glodblock/github/nei/NEIUtils.java | 16 +- .../glodblock/github/nei/NEI_FC_Config.java | 6 +- .../github/nei/object/IFluidDummy.java | 1 - .../github/nei/object/IRecipeExtractor.java | 5 +- .../nei/object/IRecipeExtractorLegacy.java | 1 - .../nei/object/IllegalOrderStackID.java | 1 - .../github/nei/object/OrderStack.java | 22 +- .../nei/recipes/DefaultExtractorLoader.java | 7 +- .../github/nei/recipes/FluidRecipe.java | 10 +- .../extractor/EnderIORecipeExtractor.java | 31 +- .../extractor/ForestryRecipeExtractor.java | 20 +- .../extractor/GTPPRecipeExtractor.java | 1 - .../extractor/GregTech5RecipeExtractor.java | 17 +- .../extractor/GregTech6RecipeExtractor.java | 12 +- .../IndustrialCraftRecipeExtractor.java | 34 +- .../extractor/VanillaRecipeExtractor.java | 6 +- .../github/network/CPacketCraftRequest.java | 72 +-- .../github/network/CPacketDumpTank.java | 7 +- .../github/network/CPacketEncodePattern.java | 7 +- .../network/CPacketFluidPatternTermBtns.java | 26 +- .../github/network/CPacketFluidUpdate.java | 24 +- .../network/CPacketInventoryAction.java | 77 ++- .../network/CPacketLevelMaintainer.java | 12 +- .../network/CPacketPatternValueSet.java | 25 +- .../github/network/CPacketSetTargetItem.java | 8 +- .../github/network/CPacketSwitchGuis.java | 15 +- .../github/network/CPacketTransferRecipe.java | 65 +- .../github/network/SPacketFluidUpdate.java | 35 +- .../network/SPacketMEInventoryUpdate.java | 7 +- .../glodblock/github/proxy/ClientProxy.java | 6 +- .../glodblock/github/proxy/CommonProxy.java | 7 +- .../com/glodblock/github/util/Ae2Reflect.java | 17 +- .../github/util/Ae2ReflectClient.java | 7 +- .../com/glodblock/github/util/BlockPos.java | 6 +- .../github/util/DualityFluidInterface.java | 71 ++- .../github/util/FluidPatternDetails.java | 20 +- .../glodblock/github/util/FluidSorters.java | 6 +- .../github/util/ModAndClassUtil.java | 42 +- .../com/glodblock/github/util/NameConst.java | 1 - .../github/util/ObjectArrayIterator.java | 9 +- .../com/glodblock/github/util/RenderUtil.java | 12 +- .../github/util/SetBackedMachineSet.java | 4 +- .../java/com/glodblock/github/util/Util.java | 125 ++-- 191 files changed, 5046 insertions(+), 5165 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 0b823203..b81df083 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -21,7 +21,7 @@ dependencies { compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.29:dev') { transitive = false } - compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.49:dev') {transitive = false} + compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.49:dev') { transitive = false } runtime('com.github.GTNewHorizons:Baubles:1.0.1.14:dev') } diff --git a/src/main/java/com/glodblock/github/FluidCraft.java b/src/main/java/com/glodblock/github/FluidCraft.java index 6cd1ae38..195e2295 100644 --- a/src/main/java/com/glodblock/github/FluidCraft.java +++ b/src/main/java/com/glodblock/github/FluidCraft.java @@ -22,7 +22,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;after:waila") +@Mod( + modid = FluidCraft.MODID, + version = FluidCraft.VERSION, + name = FluidCraft.MODNAME, + dependencies = "required-after:appliedenergistics2;after:waila") public class FluidCraft { public static final String MODID = "GRADLETOKEN_MODID"; @@ -32,7 +36,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 @@ -66,31 +72,29 @@ 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.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1 ); + 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.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1); } 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 c7147969..bf4bc141 100644 --- a/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java +++ b/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java @@ -26,8 +26,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; @@ -41,12 +47,11 @@ public class FCGuiTextField extends GuiTextField { super.drawTextBox(); if (this.getBorder() > 0 && this.getVisible()) { GuiTextField.drawRect( - this._xPos - this.getBorder(), - this._yPos - this.getBorder(), - this._width - 2 * PADDING - this._fontRender.getCharWidth('_') + this.getBorder(), - this._height - 2 * PADDING + this.getBorder(), - this.getColor() - ); + this._xPos - this.getBorder(), + this._yPos - this.getBorder(), + this._width - 2 * PADDING - this._fontRender.getCharWidth('_') + this.getBorder(), + this._height - 2 * PADDING + this.getBorder(), + this.getColor()); } } @@ -100,13 +105,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; @@ -128,7 +131,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 233b88a8..0b5b939f 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java @@ -50,132 +50,136 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { } @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")); } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) { - FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "1")); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "1")); } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) { - FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0")); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "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.encodeBtn = new GuiImgButton( + this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE); this.buttonList.add(this.encodeBtn); int combineLeft = 74; int combineTop = 153; if (ModAndClassUtil.isDoubleButton) { - this.doubleBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE); + 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; } -// if (ModAndClassUtil.isBeSubstitutionsButton) { -// combineLeft = 74; -// combineTop -= 11; -// this.beSubstitutionsEnabledBtn = new GuiImgButton( -// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.ENABLED); -// this.beSubstitutionsEnabledBtn.setHalfSize(true); -// this.buttonList.add(this.beSubstitutionsEnabledBtn); -// -// this.beSubstitutionsDisabledBtn = new GuiImgButton( -// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.DISABLED); -// this.beSubstitutionsDisabledBtn.setHalfSize(true); -// this.buttonList.add(this.beSubstitutionsDisabledBtn); -// } - this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "FORCE_COMBINE", "DO_COMBINE"); + // if (ModAndClassUtil.isBeSubstitutionsButton) { + // combineLeft = 74; + // combineTop -= 11; + // this.beSubstitutionsEnabledBtn = new GuiImgButton( + // this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, + // PatternBeSubstitution.ENABLED); + // this.beSubstitutionsEnabledBtn.setHalfSize(true); + // this.buttonList.add(this.beSubstitutionsEnabledBtn); + // + // this.beSubstitutionsDisabledBtn = new GuiImgButton( + // this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, + // PatternBeSubstitution.DISABLED); + // this.beSubstitutionsDisabledBtn.setHalfSize(true); + // this.buttonList.add(this.beSubstitutionsDisabledBtn); + // } + this.combineEnableBtn = new GuiFCImgButton( + this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "FORCE_COMBINE", "DO_COMBINE"); this.combineEnableBtn.setHalfSize(true); this.buttonList.add(this.combineEnableBtn); - this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "NOT_COMBINE", "DONT_COMBINE"); + this.combineDisableBtn = new GuiFCImgButton( + this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "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; } @@ -194,30 +198,27 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { } super.drawFG(offsetX, offsetY, mouseX, mouseY); - this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752); + 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 5102b5a4..af023dd9 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java @@ -53,126 +53,128 @@ 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")); } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) { - FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "1")); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "1")); } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) { - FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "0")); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "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 - 114, "FORCE_PRIO", "DO_PRIO"); + this.fluidPrioritizedEnabledBtn = + new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "FORCE_PRIO", "DO_PRIO"); this.fluidPrioritizedEnabledBtn.setHalfSize(true); - this.buttonList.add( this.fluidPrioritizedEnabledBtn ); + this.buttonList.add(this.fluidPrioritizedEnabledBtn); - this.fluidPrioritizedDisabledBtn = new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "NOT_PRIO", "DONT_PRIO"); + this.fluidPrioritizedDisabledBtn = + new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "NOT_PRIO", "DONT_PRIO"); this.fluidPrioritizedDisabledBtn.setHalfSize(true); - this.buttonList.add( this.fluidPrioritizedDisabledBtn ); + 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.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 - 114, "FORCE_COMBINE", "DO_COMBINE"); + this.combineEnableBtn = + new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "FORCE_COMBINE", "DO_COMBINE"); this.combineEnableBtn.setHalfSize(true); this.buttonList.add(this.combineEnableBtn); - this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "NOT_COMBINE", "DONT_COMBINE"); + this.combineDisableBtn = + new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "NOT_COMBINE", "DONT_COMBINE"); this.combineDisableBtn.setHalfSize(true); this.buttonList.add(this.combineDisableBtn); -// if (ModAndClassUtil.isBeSubstitutionsButton) { -// this.beSubstitutionsEnabledBtn = new GuiImgButton( -// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.ENABLED); -// this.beSubstitutionsEnabledBtn.setHalfSize(true); -// this.buttonList.add(this.beSubstitutionsEnabledBtn); -// -// this.beSubstitutionsDisabledBtn = new GuiImgButton( -// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.DISABLED); -// this.beSubstitutionsDisabledBtn.setHalfSize(true); -// this.buttonList.add(this.beSubstitutionsDisabledBtn); -// } + // if (ModAndClassUtil.isBeSubstitutionsButton) { + // this.beSubstitutionsEnabledBtn = new GuiImgButton( + // this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, + // PatternBeSubstitution.ENABLED); + // this.beSubstitutionsEnabledBtn.setHalfSize(true); + // this.buttonList.add(this.beSubstitutionsEnabledBtn); + // + // this.beSubstitutionsDisabledBtn = new GuiImgButton( + // this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, + // PatternBeSubstitution.DISABLED); + // this.beSubstitutionsDisabledBtn.setHalfSize(true); + // this.buttonList.add(this.beSubstitutionsDisabledBtn); + // } 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; } @@ -195,32 +197,30 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { } 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.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; @@ -237,14 +237,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; @@ -255,8 +255,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); @@ -267,10 +266,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()) { @@ -279,8 +277,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { } @Override - public void handleMouseInput() - { + public void handleMouseInput() { super.handleMouseInput(); final int wheel = Mouse.getEventDWheel(); @@ -296,15 +293,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/GuiBaseFluidTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidTerminal.java index 0b4f0630..83f36269 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidTerminal.java @@ -9,7 +9,6 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; - public class GuiBaseFluidTerminal extends GuiFCBaseFluidMonitor { protected EntityPlayer player; @@ -51,5 +50,4 @@ public class GuiBaseFluidTerminal extends GuiFCBaseFluidMonitor { super.actionPerformed(btn); } } - } 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 07dca5cb..f7478cd1 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiDualInterface.java @@ -45,59 +45,68 @@ 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); if (isTile()) { - this.sidelessMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 62, Settings.SIDELESS_MODE, SidelessMode.SIDELESS); - this.buttonList.add( this.sidelessMode ); + this.sidelessMode = new GuiImgButton( + this.guiLeft - 18, this.guiTop + 62, Settings.SIDELESS_MODE, SidelessMode.SIDELESS); + this.buttonList.add(this.sidelessMode); } } @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()); } if (this.sidelessMode != null) { - this.sidelessMode.set( ( (ContainerDualInterface) this.cvb ).getSidelessMode()); + this.sidelessMode.set(((ContainerDualInterface) this.cvb).getSidelessMode()); } - 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: @@ -109,48 +118,39 @@ 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 (isTile()) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY)); - } - else if(isPart()) { + } else if (isPart()) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART)); } } - if( btn == this.switcher ) - { + if (btn == this.switcher) { if (isTile()) { FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID)); - } - else if (isPart()) { + } else if (isPart()) { 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)); } - if (btn == this.sidelessMode && this.sidelessMode != null) - { - NetworkHandler.instance.sendToServer( new PacketConfigButton( this.sidelessMode.getSetting(), backwards ) ); + if (btn == this.sidelessMode && this.sidelessMode != null) { + NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards)); } } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java index df9342c3..7e3492e2 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java @@ -40,6 +40,9 @@ import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.ModAndClassUtil; import com.glodblock.github.util.NameConst; import com.glodblock.github.util.Util; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; @@ -51,11 +54,8 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.List; - -public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost, IDropToFillTextField { +public class GuiFCBaseFluidMonitor extends AEBaseMEGui + implements ISortSource, IConfigManagerHost, IDropToFillTextField { public static int craftingGridOffsetX; public static int craftingGridOffsetY; @@ -84,7 +84,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I private GuiImgButton terminalStyleBox; private GuiImgButton searchStringSave; - public GuiFCBaseFluidMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseFluidMonitorContain c) { + public GuiFCBaseFluidMonitor( + final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseFluidMonitorContain c) { super(c); @@ -101,7 +102,6 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I (this.monitorableContainer = (FCBaseFluidMonitorContain) this.inventorySlots).setGui(this); this.viewCell = te instanceof IViewCellStorage; - } public void postUpdate(final List list) { @@ -117,7 +117,9 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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)); + this.getScrollBar() + .setRange( + 0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6)); } @Override @@ -133,7 +135,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I final GuiImgButton iBtn = (GuiImgButton) btn; 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); @@ -143,7 +146,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I AEConfig.instance.preserveSearchBar = next == YesNo.YES; } else { try { - NetworkHandler.instance.sendToServer(new PacketValueConfig(iBtn.getSetting().name(), next.name())); + NetworkHandler.instance.sendToServer( + new PacketValueConfig(iBtn.getSetting().name(), next.name())); } catch (final IOException e) { AELog.debug(e); } @@ -169,7 +173,9 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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); @@ -196,7 +202,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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)); + this.getMeSlots() + .add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18)); } } @@ -219,28 +226,52 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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))); + 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 ) ) ); -// offset += 20; + // 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 = 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); @@ -249,10 +280,25 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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 (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.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 // } } @@ -303,7 +349,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I @Override public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.fontRendererObj.drawString(this.getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_TERMINAL)), 8, 6, 4210752); + this.fontRendererObj.drawString( + this.getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_TERMINAL)), 8, 6, 4210752); this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); } @@ -340,11 +387,11 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I direction = TextHistory.Direction.NEXT; } history.get(direction, this.searchField.getText()) - .map(newText -> { - setSearchString(newText, true); - return true; - }) - .orElse(false); + .map(newText -> { + setSearchString(newText, true); + return true; + }) + .orElse(false); return; } catch (NoSuchFieldException | IllegalAccessException e) { } @@ -364,14 +411,16 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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; + 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) { @@ -449,20 +498,19 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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) { action = InventoryAction.CREATIVE_DUPLICATE; } @@ -475,7 +523,10 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I } if (action != null) { - final PacketInventoryAction p = new PacketInventoryAction(action, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId()); + final PacketInventoryAction p = new PacketInventoryAction( + action, + slot.getSlotIndex(), + ((SlotDisconnected) slot).getSlot().getId()); NetworkHandler.instance.sendToServer(p); } @@ -491,7 +542,10 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; 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; } @@ -502,7 +556,6 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I break; case 3: // creative dupe: - stack = ((SlotME) slot).getAEStack(); if (stack.getItem() instanceof ItemFluidDrop) { stack = ItemFluidDrop.newAeStack(ItemFluidDrop.getAeFluidStack(stack)); @@ -524,10 +577,12 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I if (action == InventoryAction.AUTO_CRAFT) { ((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)); } else if (action != null) { ((AEBaseContainer) this.inventorySlots).setTargetStack(stack); - final PacketInventoryAction p = new PacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0); + final PacketInventoryAction p = new PacketInventoryAction( + action, Ae2ReflectClient.getInventorySlots(this).size(), 0); NetworkHandler.instance.sendToServer(p); } @@ -564,15 +619,23 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I 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) { boolean update = false; for (int i = 0; i < 5; i++) { - if (this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot(i).getStack()) { + 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(); } } @@ -596,7 +659,9 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I } int getMaxRows() { - return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE; + return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL + ? 6 + : Integer.MAX_VALUE; } protected void repositionSlot(final AppEngSlot s) { 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 374363ba..ccef4c07 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java @@ -36,6 +36,9 @@ 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.lang.reflect.Field; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; @@ -46,10 +49,6 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.List; - public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost, IDropToFillTextField { public static int craftingGridOffsetX; @@ -79,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; @@ -193,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; } @@ -236,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(); } @@ -298,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); } } } @@ -323,26 +331,23 @@ 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 ) { + protected void mouseClicked(final int xCoord, final int yCoord, final int btn) { final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); final EntityPlayer player = Minecraft.getMinecraft().thePlayer; ItemStack is = player.inventory.getItemStack(); @@ -376,11 +381,11 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi direction = TextHistory.Direction.NEXT; } history.get(direction, this.searchField.getText()) - .map(newText -> { - setSearchString(newText, true); - return true; - }) - .orElse(false); + .map(newText -> { + setSearchString(newText, true); + return true; + }) + .orElse(false); return; } catch (NoSuchFieldException | IllegalAccessException e) { } @@ -395,7 +400,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi if (mouseButton == 3) { if (this instanceof GuiBaseFluidPatternTerminal - && ((GuiBaseFluidPatternTerminal) this).container.isCraftingMode()) { + && ((GuiBaseFluidPatternTerminal) this).container.isCraftingMode()) { return; } if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) { @@ -404,128 +409,107 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi 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; } @@ -536,49 +520,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; } } @@ -590,214 +571,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; 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 60bbca6d..e109a087 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,7 +32,7 @@ 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"); @@ -45,7 +44,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { } } - 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); if (StatCollector.translateToLocal(prefix + title + ".hint").equals(prefix + title + ".hint")) { @@ -57,19 +56,15 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { 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; @@ -77,92 +72,77 @@ 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 ) { + if (displayName != null) { String name = StatCollector.translateToLocal(displayName); if (name == null || name.isEmpty()) { name = displayName; @@ -192,38 +172,47 @@ 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_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.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(); @@ -238,47 +227,56 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { } 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; + 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_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.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(); } } - 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; @@ -286,12 +284,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 43838a8c..4fa7af8b 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftAmount.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidCraftAmount.java @@ -24,8 +24,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; @@ -43,35 +42,34 @@ 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(); @@ -89,40 +87,43 @@ public class GuiFluidCraftAmount 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.amountToCraft = new GuiNumberBox(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class); + 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.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; } @@ -130,132 +131,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 d32c3757..5cf084cd 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 { @@ -50,78 +49,76 @@ public class GuiFluidCraftConfirm extends AEBaseGui { private int tooltip = -1; 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; } @@ -129,66 +126,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; @@ -206,349 +198,297 @@ 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()); } } 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 1284126c..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,51 +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 52779754..cf84540d 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidInterface.java @@ -15,6 +15,7 @@ import com.glodblock.github.inventory.gui.TankMouseHandler; 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.gui.inventory.GuiContainer; @@ -28,8 +29,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"); @@ -57,10 +56,16 @@ public class GuiFluidInterface extends AEBaseGui { private void addMouseRegin() { for (int i = 0; i < 6; i++) { - mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT, - new TankMouseHandler( - isPart() ? ((PartFluidInterface) cont.getTile()).getInternalFluid() : ((TileFluidInterface) cont.getTile()).getInternalFluid(), - i)); + mouseRegions.addRegion( + TANK_X + TANK_X_OFF * i, + TANK_Y, + TANK_WIDTH, + TANK_HEIGHT, + new TankMouseHandler( + isPart() + ? ((PartFluidInterface) cont.getTile()).getInternalFluid() + : ((TileFluidInterface) cont.getTile()).getInternalFluid(), + i)); } } @@ -68,19 +73,23 @@ public class GuiFluidInterface extends AEBaseGui { public void func_146977_a(final Slot s) { try { GuiContainer.class - .getDeclaredMethod("func_146977_a_original", Slot.class) - .invoke(this, s); + .getDeclaredMethod("func_146977_a_original", Slot.class) + .invoke(this, s); } catch (final Exception ignore) { } } @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 @@ -101,8 +110,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); mouseRegions.render(mouseX, mouseY); @@ -118,8 +132,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); @@ -127,10 +141,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); } @@ -138,11 +156,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)); } } @@ -154,9 +172,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); @@ -167,6 +184,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 997537d4..4cf7278a 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalCraftingStatus.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidPatternTerminalCraftingStatus.java @@ -40,15 +40,12 @@ 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 if (host instanceof PartFluidTerminal) - InventoryHandler.switchGui(GuiType.FLUID_TERMINAL); + else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL); } 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/GuiFluidTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiFluidTerminal.java index 3b752a8f..f10cd973 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFluidTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFluidTerminal.java @@ -12,6 +12,8 @@ import com.glodblock.github.common.item.ItemFluidDrop; import com.glodblock.github.network.CPacketFluidUpdate; import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.Util; +import java.util.HashMap; +import java.util.Map; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; @@ -21,9 +23,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; -import java.util.HashMap; -import java.util.Map; - public class GuiFluidTerminal extends GuiBaseFluidTerminal { private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this); public ContainerFluidTerminal container; @@ -40,11 +39,9 @@ public class GuiFluidTerminal extends GuiBaseFluidTerminal { @Override public void func_146977_a(final Slot s) { - if (drawSlot0(s)) - super.func_146977_a(s); + if (drawSlot0(s)) super.func_146977_a(s); } - public boolean drawSlot0(Slot slot) { if (slot instanceof SlotME) { IAEItemStack stack = ((SlotME) slot).getAEStack(); @@ -52,23 +49,29 @@ public class GuiFluidTerminal extends GuiBaseFluidTerminal { FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack()); this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid()); stackSizeRenderer.setAeStack(stack); - 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; } private void drawWidget(int posX, int posY, Fluid fluid) { - Minecraft.getMinecraft().renderEngine - .bindTexture(TextureMap.locationBlocksTexture); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor3f(1, 1, 1); if (fluid != null && fluid.getIcon() != null) { - GL11.glColor3f((fluid.getColor() >> 16 & 0xFF) / 255.0F, (fluid.getColor() >> 8 & 0xFF) / 255.0F, (fluid.getColor() & 0xFF) / 255.0F); - drawTexturedModelRectFromIcon(posX, posY, - fluid.getIcon(), 16, 16); + GL11.glColor3f( + (fluid.getColor() >> 16 & 0xFF) / 255.0F, + (fluid.getColor() >> 8 & 0xFF) / 255.0F, + (fluid.getColor() & 0xFF) / 255.0F); + drawTexturedModelRectFromIcon(posX, posY, fluid.getIcon(), 16, 16); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); 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/GuiLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java index ff6cbefd..c2324ad8 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java @@ -19,6 +19,9 @@ import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.ModAndClassUtil; import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.Optional; +import java.awt.*; +import java.util.Collections; +import java.util.List; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; @@ -28,10 +31,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; -import java.awt.*; -import java.util.Collections; -import java.util.List; - @Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler") public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { @@ -76,18 +75,21 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { super.initGui(); for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { component[i] = new Component( - new Widget( - new FCGuiTextField(this.fontRendererObj, guiLeft + 37, guiTop + 21 + 20 * i, 52, 16), - new GuiFCImgButton(guiLeft + 37 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_REQUEST_SIZE), - i, "TileLevelMaintainer.Quantity"), - new Widget( - new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 21 + 20 * i, 52, 16), - new GuiFCImgButton(guiLeft + 100 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_BATCH_SIZE), - i, "TileLevelMaintainer.Batch"), - new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "ENABLE", "ENABLE"), - new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "DISABLE", "DISABLE"), - this.buttonList - ); + new Widget( + new FCGuiTextField(this.fontRendererObj, guiLeft + 37, guiTop + 21 + 20 * i, 52, 16), + new GuiFCImgButton(guiLeft + 37 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), + I18n.format(NameConst.TT_REQUEST_SIZE), + i, + "TileLevelMaintainer.Quantity"), + new Widget( + new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 21 + 20 * i, 52, 16), + new GuiFCImgButton(guiLeft + 100 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), + I18n.format(NameConst.TT_BATCH_SIZE), + i, + "TileLevelMaintainer.Batch"), + new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "ENABLE", "ENABLE"), + new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "DISABLE", "DISABLE"), + this.buttonList); } FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh")); } @@ -109,8 +111,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { @Override public void func_146977_a(final Slot s) { - if (drawSlot0(s)) - super.func_146977_a(s); + if (drawSlot0(s)) super.func_146977_a(s); } public boolean drawSlot0(Slot slot) { @@ -120,12 +121,18 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { if (stack == null) return true; IAEItemStack fake = stack.copy(); if (this.component[slot.getSlotIndex()].getQty().textField.getText().matches("[0-9]+")) { - fake.setStackSize(Long.parseLong(this.component[slot.getSlotIndex()].getQty().textField.getText())); + fake.setStackSize(Long.parseLong( + this.component[slot.getSlotIndex()].getQty().textField.getText())); } else { fake.setStackSize(0); } 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; @@ -176,8 +183,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { @Override protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) { - if (slot instanceof ContainerLevelMaintainer.FakeSlot && this.cont.getPlayerInv().getItemStack() != null) { - this.component[slot.getSlotIndex()].getQty().textField.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize)); + if (slot instanceof ContainerLevelMaintainer.FakeSlot + && this.cont.getPlayerInv().getItemStack() != null) { + this.component[slot.getSlotIndex()] + .getQty() + .textField + .setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize)); return; } super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); @@ -187,7 +198,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { this.component[idx].getQty().textField.setText(String.valueOf(stackSize)); } - @Override protected void actionPerformed(final GuiButton btn) { super.actionPerformed(btn); @@ -248,7 +258,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { private GuiFCImgButton disable; private GuiFCImgButton enable; - public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton enableBtn, GuiFCImgButton disableBtn, List buttonList) { + public Component( + Widget qtyInput, + Widget batchInput, + GuiFCImgButton enableBtn, + GuiFCImgButton disableBtn, + List buttonList) { this.qty = qtyInput; this.batch = batchInput; this.enable = enableBtn; @@ -271,10 +286,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { private boolean send(Widget widget) { if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) { - if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("^[0-9]+")) { + if (!widget.textField.getText().isEmpty() + && widget.textField.getText().matches("^[0-9]+")) { String str = widget.textField.getText().replaceAll("^(0+)", ""); widget.textField.setText(str.isEmpty() ? "0" : str); - FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText())); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText())); widget.textField.setTextColor(0xFFFFFF); return true; } else { @@ -293,9 +310,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { return this.send(this.getBatch()); } if (this.enable == btn) { - FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex())); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex())); } else if (this.disable == btn) { - FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex())); + FluidCraft.proxy.netHandler.sendToServer( + new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex())); } return false; } @@ -325,7 +344,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { this.disable.visible = true; } } - } private class Widget { @@ -356,7 +374,5 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { public void setTooltip(String message) { this.textField.setMessage(message); } - } - } 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 c8ce8afb..d4c56c41 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 @@ -9,13 +9,11 @@ import com.glodblock.github.common.parts.PartSharedFluidBus; import com.glodblock.github.util.Ae2Reflect; 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; } @@ -32,7 +30,7 @@ public class ContainerFluidIO extends ContainerFluidConfigurable protected void loadSettingsFromHost(IConfigManager cm) { super.loadSettingsFromHost(cm); if (Ae2Reflect.getUpgradeableHost(this) instanceof PartFluidExportBus) { - this.setCraftingMode((YesNo)cm.getSetting(Settings.CRAFT_ONLY)); + this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY)); } } } 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 39c14c12..fe8b9963 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 @@ -1,12 +1,12 @@ package com.glodblock.github.client.gui.container; +import static com.glodblock.github.loader.ItemAndBlockHolder.PACKET; + import appeng.container.AEBaseContainer; import com.glodblock.github.common.tile.TileFluidPacketDecoder; import com.glodblock.github.inventory.slot.FCSlotRestrictedInput; import net.minecraft.entity.player.InventoryPlayer; -import static com.glodblock.github.loader.ItemAndBlockHolder.PACKET; - public class ContainerFluidPacketDecoder extends AEBaseContainer { public ContainerFluidPacketDecoder(InventoryPlayer ipl, TileFluidPacketDecoder tile) { @@ -14,5 +14,4 @@ public class ContainerFluidPacketDecoder extends AEBaseContainer { addSlotToContainer(new FCSlotRestrictedInput(PACKET.stack(), tile.getInventory(), 0, 80, 35, ipl)); 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 5fe9e0e4..8b41691c 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); } @@ -57,8 +56,15 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat return tile; } + private static boolean isNotPattern(ItemStack stack) { + return stack == null + || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack) + || (stack.getItem() instanceof ItemFluidEncodedPattern)); + } + 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: @@ -78,11 +84,6 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat return false; } - private static boolean isNotPattern(ItemStack stack) { - return stack == null || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack) - || (stack.getItem() instanceof ItemFluidEncodedPattern)); - } - public void encodePattern() { if (canEncodePattern()) { // if there is an encoded pattern, overwrite it; otherwise, consume a blank @@ -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 be5a58d4..5ce99e73 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 @@ -31,15 +31,27 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement super(ip, monitorable); } - public void encodeAllItemAndMoveToInventory(){ + private static boolean isPattern(final ItemStack output) { + if (output == null) { + return false; + } + if (output.getItem() instanceof ItemFluidEncodedPattern) { + return true; + } + final IDefinitions defs = AEApi.instance().definitions(); + return defs.items().encodedPattern().isSameAs(output) + || defs.materials().blankPattern().isSameAs(output); + } + + 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); } } @@ -59,7 +71,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)) { @@ -67,17 +79,6 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement } } - private static boolean isPattern(final ItemStack output) { - if (output == null) { - return false; - } - if (output.getItem() instanceof ItemFluidEncodedPattern) { - return true; - } - final IDefinitions defs = AEApi.instance().definitions(); - return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output); - } - private boolean checkHasFluidPattern() { if (this.craftingMode) { return false; @@ -119,7 +120,7 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement FluidPatternDetails pattern = new FluidPatternDetails(patternStack); pattern.setInputs(collectInventory(craftingSlots)); pattern.setOutputs(collectInventory(outputSlots)); -// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); + // pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); patternSlotOUT.putStack(pattern.writeToStack()); } @@ -174,7 +175,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: @@ -204,7 +206,10 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement public ItemStack transferStackInSlot(EntityPlayer p, int idx) { Slot clickSlot = (Slot) this.inventorySlots.get(idx); ItemStack is = clickSlot.getStack(); - if (is != null && !patternSlotOUT.getHasStack() && is.stackSize == 1 && (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) { + if (is != null + && !patternSlotOUT.getHasStack() + && is.stackSize == 1 + && (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) { ItemStack output = is.copy(); patternSlotOUT.putStack(output); p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null); 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 95645a9d..a7ea9f97 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 @@ -30,15 +30,27 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple super(ip, monitorable); } - public void encodeAllItemAndMoveToInventory(){ + private static boolean isPattern(final ItemStack output) { + if (output == null) { + return false; + } + if (output.getItem() instanceof ItemFluidEncodedPattern) { + return true; + } + final IDefinitions defs = AEApi.instance().definitions(); + return defs.items().encodedPattern().isSameAs(output) + || defs.materials().blankPattern().isSameAs(output); + } + + 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); } } @@ -58,7 +70,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)) { @@ -66,17 +78,6 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple } } - private static boolean isPattern(final ItemStack output) { - if (output == null) { - return false; - } - if (output.getItem() instanceof ItemFluidEncodedPattern) { - return true; - } - final IDefinitions defs = AEApi.instance().definitions(); - return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output); - } - private boolean checkHasFluidPattern() { boolean hasFluid = false, search = false; for (Slot craftingSlot : this.craftingSlots) { @@ -113,10 +114,10 @@ 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.setCombine(this.combine ? 1 : 0); pattern.setInputs(collectInventory(craftingSlots)); pattern.setOutputs(collectInventory(outputSlots)); -// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); + // pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); patternSlotOUT.putStack(pattern.writeToStack()); } @@ -167,7 +168,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: @@ -202,7 +205,10 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple public ItemStack transferStackInSlot(EntityPlayer p, int idx) { Slot clickSlot = (Slot) this.inventorySlots.get(idx); ItemStack is = clickSlot.getStack(); - if (is != null && !patternSlotOUT.getHasStack() && is.stackSize == 1 && (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) { + if (is != null + && !patternSlotOUT.getHasStack() + && is.stackSize == 1 + && (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) { ItemStack output = is.copy(); patternSlotOUT.putStack(output); p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null); 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/ContainerLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java index 3be49d0c..8f86c3a4 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java @@ -9,7 +9,6 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - public class ContainerLevelMaintainer extends AEBaseContainer { private final TileLevelMaintainer tile; private final FakeSlot[] requestSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT]; 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/FCBaseFluidMonitorContain.java b/src/main/java/com/glodblock/github/client/gui/container/FCBaseFluidMonitorContain.java index e45703d4..af190db6 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBaseFluidMonitorContain.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBaseFluidMonitorContain.java @@ -41,6 +41,11 @@ import com.glodblock.github.network.CPacketFluidUpdate; import com.glodblock.github.network.SPacketFluidUpdate; import com.glodblock.github.network.SPacketMEInventoryUpdate; import com.glodblock.github.util.Util; +import java.io.IOException; +import java.nio.BufferOverflowException; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nonnull; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -53,22 +58,20 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.IFluidContainerItem; import org.apache.commons.lang3.tuple.MutablePair; -import javax.annotation.Nonnull; -import java.io.IOException; -import java.nio.BufferOverflowException; -import java.util.HashMap; -import java.util.Map; - -public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver { +public class FCBaseFluidMonitorContain extends AEBaseContainer + implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver { private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5]; private final IMEMonitor monitor; private final IItemList items = AEApi.instance().storage().createFluidList(); private final IConfigManager clientCM; private final ITerminalHost host; + @GuiSync(99) public boolean canAccessViewCells = false; + @GuiSync(98) public boolean hasPower = false; + private IConfigManagerHost gui; private IConfigManager serverCM; private IGridNode networkNode; @@ -77,8 +80,12 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi this(ip, monitorable, true); } - protected FCBaseFluidMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) { - super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null); + protected FCBaseFluidMonitorContain( + 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); @@ -92,7 +99,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi 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); @@ -118,7 +125,13 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi 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] = 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]); } @@ -137,7 +150,9 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) { if (Platform.isClient()) { Slot clickSlot = (Slot) this.inventorySlots.get(idx); - if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack() && Util.FluidUtil.isFluidContainer(clickSlot.getStack())) { + if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) + && clickSlot.getHasStack() + && Util.FluidUtil.isFluidContainer(clickSlot.getStack())) { ItemStack tis = clickSlot.getStack(); Map tmp = new HashMap<>(); tmp.put(0, ItemFluidDrop.getAeFluidStack(AEItemStack.create(tis))); @@ -163,7 +178,8 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi this.clientCM.putSetting(set, sideLocal); for (final Object crafter : this.crafters) { try { - NetworkHandler.instance.sendTo(new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter); + NetworkHandler.instance.sendTo( + new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter); } catch (final IOException e) { AELog.debug(e); } @@ -201,8 +217,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi final boolean oldAccessible = this.canAccessViewCells; this.canAccessViewCells = - this.host instanceof WirelessTerminalGuiObject - || this.hasAccess(SecurityPermissions.BUILD, false); + 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) { @@ -221,7 +236,8 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi } 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); + this.setPowered( + this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8); } } catch (final Throwable t) { // :P @@ -318,7 +334,8 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi } @Override - public void postChange(IBaseMonitor monitor, Iterable change, BaseActionSource actionSource) { + public void postChange( + IBaseMonitor monitor, Iterable change, BaseActionSource actionSource) { for (final IAEFluidStack is : change) { this.items.add(is); } @@ -352,26 +369,33 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi this.dropItem(is); } - public void postChange(Iterable change, ItemStack fluidContainer, EntityPlayer player, int slotIndex) { + public void postChange( + Iterable change, ItemStack fluidContainer, EntityPlayer player, int slotIndex) { for (IAEFluidStack fluid : change) { IAEFluidStack nfluid = this.monitor.getStorageList().findPrecise(fluid); ItemStack out = fluidContainer.copy(); out.stackSize = 1; if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) { -// add fluid to tanks + // add fluid to tanks if (nfluid.getStackSize() <= 0) continue; final IAEFluidStack toExtract = nfluid.copy(); MutablePair fillStack = Util.FluidUtil.fillStack(out, toExtract.getFluidStack()); if (fillStack.right == null || fillStack.left <= 0) continue; toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize); - IAEFluidStack tmp = this.host.getFluidInventory().extractItems(toExtract, Actionable.SIMULATE, this.getActionSource()); + IAEFluidStack tmp = this.host + .getFluidInventory() + .extractItems(toExtract, Actionable.SIMULATE, this.getActionSource()); fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left); this.dropItem(fillStack.right); out.stackSize = fillStack.right.stackSize; if (fillStack.right.getItem() instanceof IFluidContainerItem) { this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource()); if ((int) (tmp.getStackSize() % fillStack.left) > 0) { - ((IFluidContainerItem) fillStack.right.getItem()).drain(fillStack.right, fillStack.left - (int) (tmp.getStackSize() % fillStack.left), true); + ((IFluidContainerItem) fillStack.right.getItem()) + .drain( + fillStack.right, + fillStack.left - (int) (tmp.getStackSize() % fillStack.left), + true); this.dropItem(fillStack.right, 1); out.stackSize++; } @@ -380,34 +404,44 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource()); } } else if (!Util.FluidUtil.isEmpty(fluidContainer)) { -// add fluid to ae network + // add fluid to ae network AEFluidStack fluidStack = Util.getAEFluidFromItem(fluidContainer); final IAEFluidStack aeFluidStack = fluidStack.copy(); // simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues - final IAEFluidStack notInserted = this.host.getFluidInventory().injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource()); - MutablePair drainStack = Util.FluidUtil.drainStack(out.copy(), aeFluidStack.getFluidStack()); + final IAEFluidStack notInserted = this.host + .getFluidInventory() + .injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource()); + MutablePair drainStack = + Util.FluidUtil.drainStack(out.copy(), aeFluidStack.getFluidStack()); if (notInserted != null && notInserted.getStackSize() > 0) { if (fluidStack.getStackSize() == notInserted.getStackSize()) continue; aeFluidStack.decStackSize(notInserted.getStackSize()); - if (drainStack.left > aeFluidStack.getStackSize() && FluidContainerRegistry.isContainer(drainStack.right)) { + if (drainStack.left > aeFluidStack.getStackSize() + && FluidContainerRegistry.isContainer(drainStack.right)) { aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize()); - this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource()); + this.host + .getFluidInventory() + .extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource()); continue; } - this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left)); // drop empty item + this.dropItem( + drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left)); // drop empty item out.stackSize = (int) (notInserted.getStackSize() / drainStack.left); if (drainStack.right.getItem() instanceof IFluidContainerItem) { if (notInserted.getStackSize() % drainStack.left > 0) { fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left)); - ((IFluidContainerItem) drainStack.right.getItem()).fill(drainStack.right, fluidStack.getFluidStack(), true); + ((IFluidContainerItem) drainStack.right.getItem()) + .fill(drainStack.right, fluidStack.getFluidStack(), true); this.dropItem(drainStack.right, 1); } } else if (FluidContainerRegistry.isContainer(drainStack.right)) { if (notInserted.getStackSize() % drainStack.left > 0) { aeFluidStack.setStackSize(aeFluidStack.getStackSize() % drainStack.left); - this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource()); + this.host + .getFluidInventory() + .extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource()); out.stackSize++; } } @@ -423,10 +457,13 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi if (slotIndex == -1) { player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize; if (player.inventory.getItemStack().stackSize > 0) { - FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()), (EntityPlayerMP) player); + FluidCraft.proxy.netHandler.sendTo( + new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()), + (EntityPlayerMP) player); } else { player.inventory.setItemStack(null); - FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player); + FluidCraft.proxy.netHandler.sendTo( + new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player); } } else { player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null); 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 5e729316..32d1d025 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,32 +43,30 @@ 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) public boolean craftingMode = true; + @GuiSync(96) public boolean substitute = false; + @GuiSync(95) public boolean combine = false; + @GuiSync(94) public boolean beSubstitute = false; - public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable) { super(ip, monitorable, false); this.patternTerminal = (PartFluidPatternTerminal) monitorable; @@ -71,153 +74,228 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE 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() ) - { - this.craftSlot.xDisplayPosition = -9000; + 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(); + } - for( int y = 0; y < 3; y++ ) - { - this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX(); + 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) { + ItemStack st = s.getStack(); + 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; + } + s.putStack(ItemFluidPacket.newStack(fluidStack)); + } else if (st.stackSize * 2 > 127) { + overFlowStacks.add(st.copy()); + } else { + st.stackSize *= 2; + s.putStack(st); } } - else - { + Iterator ow = overFlowStacks.iterator(); + for (final Slot s : enabledSlots) { + if (!ow.hasNext()) break; + if (s.getStack() != null) continue; + s.putStack(ow.next()); + } + assert !ow.hasNext(); + } + + static boolean containsItem(SlotFake[] slots) { + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long item = enabledSlots.stream() + .filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())) + .count(); + return item > 0; + } + + 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(); + return fluid > 0; + } + + private void updateOrderOfOutputSlots() { + if (!this.isCraftingMode()) { + this.craftSlot.xDisplayPosition = -9000; + + for (int y = 0; y < 3; y++) { + this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX(); + } + } 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); } } @@ -227,86 +305,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.setTag("in", tagIn); + encodedValue.setTag("out", tagOut); + encodedValue.setBoolean("crafting", this.isCraftingMode()); encodedValue.setBoolean("substitute", this.isSubstitute()); encodedValue.setBoolean("beSubstitute", this.canBeSubstitute()); 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) { @@ -314,134 +376,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())); } } } @@ -449,14 +504,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(); } @@ -467,85 +519,46 @@ 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(); this.getAndUpdateOutput(); } - @Override - public IInventory getInventoryByName( final String name ) - { - if( name.equals( "player" ) ) - { - return this.getInventoryPlayer(); - } - return this.getPatternTerminal().getInventoryByName( name ); - } - - @Override - public boolean useRealItems() - { - return false; - } - - public void toggleSubstitute() - { - this.substitute = !this.substitute; - - this.detectAndSendChanges(); - this.getAndUpdateOutput(); - } - - public boolean isCraftingMode() - { - return this.craftingMode; - } - private void setCraftingMode(final boolean craftingMode) { this.craftingMode = craftingMode; } @@ -566,63 +579,28 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE 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(); - return fullSlots <= emptyStots && emptyStots < enabledSlots.size(); - } - - 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) - { - ItemStack st = s.getStack(); - 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; - } - s.putStack(ItemFluidPacket.newStack(fluidStack)); - } - else if (st.stackSize * 2 > 127) - { - overFlowStacks.add(st.copy()); - } - else - { - st.stackSize *= 2; - s.putStack(st); - } + @Override + public IInventory getInventoryByName(final String name) { + if (name.equals("player")) { + return this.getInventoryPlayer(); } - Iterator ow = overFlowStacks.iterator(); - for (final Slot s : enabledSlots) { - if (!ow.hasNext()) - break; - if (s.getStack() != null) - continue; - s.putStack(ow.next()); - } - assert !ow.hasNext(); + return this.getPatternTerminal().getInventoryByName(name); } - static boolean containsItem(SlotFake[] slots) { - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - long item = enabledSlots.stream().filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())).count(); - return item > 0; + @Override + public boolean useRealItems() { + return false; } - 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(); - return fluid > 0; + public void toggleSubstitute() { + this.substitute = !this.substitute; + + this.detectAndSendChanges(); + this.getAndUpdateOutput(); + } + + public boolean isCraftingMode() { + return this.craftingMode; } public void doubleStacks(boolean isShift) { @@ -638,5 +616,4 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE this.detectAndSendChanges(); } } - } 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 72e394f6..c447fdbb 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,54 +32,20 @@ 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; private static final int CRAFTING_GRID_HEIGHT = 4; private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT; - private static class ProcessingSlotFake extends OptionalSlotFake { - - 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) { - super(inv, containerBus, idx, x, y, offX, offY, groupNum); - this.setRenderDisabled(false); - } - - public void setHidden(boolean hide) { - if (this.hidden != hide) { - this.hidden = hide; - this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT; - } - } - } + protected final ProcessingSlotFake[] craftingSlots = + new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; 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 SlotRestrictedInput patternSlotIN; - protected final SlotRestrictedInput patternSlotOUT; - @GuiSync(96 + (17 - 9) + 11) - public boolean combine = false; - @GuiSync(96 + (17 - 9) + 12) - public boolean substitute = false; - @GuiSync(96 + (17 - 9) + 16) - public boolean inverted; - @GuiSync(96 + (17 - 9) + 17) - public int activePage = 0; - @GuiSync(96 + (17 - 9) + 13) - public boolean prioritize = false; - @GuiSync(96 + (17 - 9) + 14) - public boolean beSubstitute = false; + protected final ProcessingSlotFake[] outputSlots = + new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable) { super(ip, monitorable, false); @@ -88,108 +59,218 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp 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); + } + + protected final SlotRestrictedInput patternSlotIN; + protected final SlotRestrictedInput patternSlotOUT; + + @GuiSync(96 + (17 - 9) + 11) + public boolean combine = false; + + @GuiSync(96 + (17 - 9) + 12) + public boolean substitute = false; + + @GuiSync(96 + (17 - 9) + 16) + public boolean inverted; + + @GuiSync(96 + (17 - 9) + 17) + public int activePage = 0; + + @GuiSync(96 + (17 - 9) + 13) + public boolean prioritize = false; + + @GuiSync(96 + (17 - 9) + 14) + public boolean beSubstitute = false; + + 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) { + List overFlowStacks = new ArrayList<>(); + 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 (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; + } + s.putStack(ItemFluidPacket.newStack(fluidStack)); + } else if (st.stackSize * 2 > 127) { + overFlowStacks.add(st.copy()); + } 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; + s.putStack(ow.next()); + } + assert !ow.hasNext(); + } + + static boolean containsItem(SlotFake[] slots) { + List enabledSlots = + Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long item = enabledSlots.stream() + .filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())) + .count(); + return item > 0; + } + + 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(); + return fluid > 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); } } @@ -199,77 +280,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.setTag("in", tagIn); + encodedValue.setTag("out", tagOut); encodedValue.setBoolean("substitute", this.isSubstitute()); encodedValue.setBoolean("beSubstitute", this.canBeSubstitute()); encodedValue.setTag("in", tagIn); - encodedValue.setTag( "out", tagOut ); - encodedValue.setBoolean( "prioritize", this.isPrioritize() ); + 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) { @@ -277,45 +346,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.beSubstitute = this.patternTerminal.canBeSubstitute(); this.prioritize = this.patternTerminal.isPrioritize(); if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) { @@ -326,13 +388,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); } } } @@ -340,127 +403,86 @@ 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; } - - 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) - { - List overFlowStacks = new ArrayList<>(); - 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 (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; - } - s.putStack(ItemFluidPacket.newStack(fluidStack)); - } - else if (st.stackSize * 2 > 127) - { - overFlowStacks.add(st.copy()); - } - 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; - s.putStack(ow.next()); - } - assert !ow.hasNext(); - } - - static boolean containsItem(SlotFake[] slots) { - List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); - long item = enabledSlots.stream().filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())).count(); - return item > 0; + private boolean isPrioritize() { + return this.prioritize; } private boolean canBeSubstitute() { return this.beSubstitute; } - 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(); - return fluid > 0; + private static class ProcessingSlotFake extends OptionalSlotFake { + + 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) { + super(inv, containerBus, idx, x, y, offX, offY, groupNum); + this.setRenderDisabled(false); + } + + public void setHidden(boolean hide) { + if (this.hidden != hide) { + this.hidden = hide; + this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT; + } + } } public void doubleStacks(boolean isShift) { @@ -484,5 +506,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/me/FluidRepo.java b/src/main/java/com/glodblock/github/client/me/FluidRepo.java index e3ec051d..473607d8 100644 --- a/src/main/java/com/glodblock/github/client/me/FluidRepo.java +++ b/src/main/java/com/glodblock/github/client/me/FluidRepo.java @@ -32,16 +32,14 @@ import com.glodblock.github.common.item.ItemFluidDrop; import com.glodblock.github.util.FluidSorters; import com.glodblock.github.util.Util; import cpw.mods.fml.relauncher.ReflectionHelper; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; - -import javax.annotation.Nonnull; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.regex.Pattern; - +import javax.annotation.Nonnull; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; public class FluidRepo extends ItemRepo { @@ -117,7 +115,7 @@ public class FluidRepo extends ItemRepo { this.innerSearch = this.searchString; final boolean terminalSearchToolTips = - AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO; + AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO; // boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO; boolean searchMod = false; @@ -159,8 +157,8 @@ public class FluidRepo extends ItemRepo { } Fluid fluid = ItemFluidDrop.getAeFluidStack(is).getFluid(); if (searchMod) { - if (m.matcher(Util.getFluidModID(fluid).toLowerCase()).find() || - m.matcher(Util.getFluidModName(fluid).toLowerCase()).find()) { + if (m.matcher(Util.getFluidModID(fluid).toLowerCase()).find() + || m.matcher(Util.getFluidModName(fluid).toLowerCase()).find()) { this.view.add(is); } } else { @@ -200,7 +198,7 @@ public class FluidRepo extends ItemRepo { try { if (this.NEIWord == null || !this.NEIWord.equals(filter)) { final Class c = - ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager"); + ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager"); final Field fldSearchField = c.getField("searchField"); final Object searchField = fldSearchField.get(c); 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/render/RenderBlockLevelMaintainer.java b/src/main/java/com/glodblock/github/client/render/RenderBlockLevelMaintainer.java index 24d23c78..ba30e978 100644 --- a/src/main/java/com/glodblock/github/client/render/RenderBlockLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/render/RenderBlockLevelMaintainer.java @@ -15,9 +15,14 @@ public class RenderBlockLevelMaintainer extends BaseBlockRender 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 26a8ad24..704f6004 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.gui.GuiScreen; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -42,29 +45,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; @@ -111,7 +107,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 @@ -122,31 +121,34 @@ 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()); - if (GuiScreen.isShiftKeyDown()) - { + if (GuiScreen.isShiftKeyDown()) { lines.add(GuiText.Filter.getLocal() + ": "); for (IAEFluidStack aeFluidStack : handler.getPartitionInv()) { - if (aeFluidStack != null) lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName()); + if (aeFluidStack != null) + lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName()); } } } @@ -155,14 +157,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; } @@ -175,131 +175,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(); } @@ -311,34 +293,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; } @@ -350,5 +342,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 1389b413..f47a2dd5 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) @@ -49,7 +48,8 @@ public class ItemFluidDrop extends Item { if (ItemFluidPacket.isDisplay(stack)) { return fluid != null ? fluid.getLocalizedName() : StatCollector.translateToLocalFormatted("error.unknown"); } - return StatCollector.translateToLocalFormatted("item.fluid_drop.name", fluid == null ? "???" : fluid.getLocalizedName()); + return StatCollector.translateToLocalFormatted( + "item.fluid_drop.name", fluid == null ? "???" : fluid.getLocalizedName()); } @Override @@ -173,5 +173,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 3f93532f..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 { @@ -34,14 +32,16 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern { } @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())); + // 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() { 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 42c7065b..cb4ad769 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() { @@ -31,6 +30,15 @@ public class ItemFluidPacket extends Item { setMaxStackSize(1); } + public static FluidStack getFluidStack(ItemStack stack) { + if (stack == null || !stack.hasTagCompound()) { + return null; + } + FluidStack fluid = FluidStack.loadFluidStackFromNBT( + Objects.requireNonNull(stack.getTagCompound()).getCompoundTag("FluidStack")); + return (fluid != null && fluid.amount > 0) ? fluid : null; + } + @Override public String getItemStackDisplayName(ItemStack stack) { FluidStack fluid = getFluidStack(stack); @@ -38,23 +46,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); - } - - @Override - @SuppressWarnings("unchecked") - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) { - FluidStack fluid = getFluidStack(stack); - boolean display = isDisplay(stack); - if (display) return; - if (fluid != null) { - for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET).split("\\\\n")) { - tooltip.add(EnumChatFormatting.GRAY + line); - } - } else { - tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted(NameConst.TT_INVALID_FLUID)); - } + return fluid != null + ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount) + : super.getItemStackDisplayName(stack); } public static boolean isDisplay(ItemStack stack) { @@ -64,12 +58,20 @@ public class ItemFluidPacket extends Item { return stack.getTagCompound().getBoolean("DisplayOnly"); } - public static FluidStack getFluidStack(ItemStack stack) { - if (stack == null || !stack.hasTagCompound()) { - return null; + @Override + @SuppressWarnings("unchecked") + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) { + FluidStack fluid = getFluidStack(stack); + boolean display = isDisplay(stack); + if (display) return; + if (fluid != null) { + for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET) + .split("\\\\n")) { + tooltip.add(EnumChatFormatting.GRAY + line); + } + } else { + tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted(NameConst.TT_INVALID_FLUID)); } - FluidStack fluid = FluidStack.loadFluidStackFromNBT(Objects.requireNonNull(stack.getTagCompound()).getCompoundTag("FluidStack")); - return (fluid != null && fluid.amount > 0) ? fluid : null; } public static FluidStack getFluidStack(@Nullable IAEItemStack stack) { @@ -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/item/ItemPartFluidTerminal.java b/src/main/java/com/glodblock/github/common/item/ItemPartFluidTerminal.java index d5b06a6d..e6a2570c 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemPartFluidTerminal.java +++ b/src/main/java/com/glodblock/github/common/item/ItemPartFluidTerminal.java @@ -1,5 +1,7 @@ package com.glodblock.github.common.item; +import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown; + import appeng.api.AEApi; import appeng.api.parts.IPartItem; import com.glodblock.github.FluidCraft; @@ -9,6 +11,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.List; +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -16,12 +20,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import javax.annotation.Nullable; -import java.util.List; - -import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown; - - public class ItemPartFluidTerminal extends Item implements IPartItem { public ItemPartFluidTerminal() { this.setMaxStackSize(64); @@ -36,7 +34,17 @@ public class ItemPartFluidTerminal 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); } @@ -54,8 +62,7 @@ public class ItemPartFluidTerminal extends Item implements IPartItem { } @Override - public void registerIcons(IIconRegister _iconRegister) { - } + public void registerIcons(IIconRegister _iconRegister) {} @Override @SideOnly(Side.CLIENT) @@ -70,5 +77,4 @@ public class ItemPartFluidTerminal 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 97e1c6db..b81d2320 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidExportBus.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidExportBus.java @@ -26,7 +26,6 @@ import com.glodblock.github.client.textures.FCPartsTexture; import com.glodblock.github.common.item.ItemFluidDrop; import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor; -import com.glodblock.github.util.BlockPos; import com.glodblock.github.util.Util; import com.google.common.collect.ImmutableSet; import cpw.mods.fml.relauncher.Side; @@ -40,16 +39,15 @@ import net.minecraftforge.fluids.IFluidHandler; public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingRequester { private final BaseActionSource source; - private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 ); + private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9); - 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 @@ -58,83 +56,87 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR } @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 InventoryAdaptor destination = this.getHandler(te); final ICraftingGrid cg = this.getProxy().getCrafting(); 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) { boolean isAllowed = true; final IAEFluidStack toExtract = fluid.copy(); - toExtract.setStackSize( this.calculateAmountToSend() ); + toExtract.setStackSize(this.calculateAmountToSend()); - if( this.craftOnly() ) - { - isAllowed = this.craftingTracker.handleCrafting( i, toExtract.getStackSize(), ItemFluidDrop.newAeStack(toExtract), destination, this.getTile().getWorldObj(), this.getProxy().getGrid(), cg, this.source ); + if (this.craftOnly()) { + isAllowed = this.craftingTracker.handleCrafting( + i, + toExtract.getStackSize(), + ItemFluidDrop.newAeStack(toExtract), + destination, + this.getTile().getWorldObj(), + this.getProxy().getGrid(), + cg, + this.source); } - final IAEFluidStack out = inv.extractItems( toExtract, Actionable.SIMULATE, this.source ); + final IAEFluidStack out = inv.extractItems(toExtract, Actionable.SIMULATE, this.source); - if( out != null && isAllowed ) - { - int wasInserted = fh.fill( this.getSide().getOpposite(), out.getFluidStack(), true ); + if (out != null && isAllowed) { + 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; } } - if( this.isCraftingEnabled() ) { - this.craftingTracker.handleCrafting( i, toExtract.getStackSize(), ItemFluidDrop.newAeStack(toExtract), destination, this.getTile().getWorldObj(), this.getProxy().getGrid(), cg, this.source ); + if (this.isCraftingEnabled()) { + this.craftingTracker.handleCrafting( + i, + toExtract.getStackSize(), + ItemFluidDrop.newAeStack(toExtract), + destination, + this.getTile().getWorldObj(), + this.getProxy().getGrid(), + cg, + this.source); } } } return TickRateModulation.SLOWER; - } - catch( GridAccessException e ) - { + } catch (GridAccessException e) { // Ignore } } @@ -143,67 +145,81 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR } @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); } private boolean craftOnly() { return this.getConfigManager().getSetting(Settings.CRAFT_ONLY) == YesNo.YES; } - private boolean isCraftingEnabled() - { - return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0; + private boolean isCraftingEnabled() { + return this.getInstalledUpgrades(Upgrades.CRAFTING) > 0; } @Override @@ -212,42 +228,37 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR } protected InventoryAdaptor getHandler(TileEntity target) { - return target != null ? FluidConvertingInventoryAdaptor.wrap(target, Util.from(this.getSide().getOpposite())) : null; + return target != null + ? FluidConvertingInventoryAdaptor.wrap( + target, Util.from(this.getSide().getOpposite())) + : null; } @Override public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) { final InventoryAdaptor d = this.getHandler(getConnectedTE()); - try - { - if( d != null && this.getProxy().isActive() ) - { + try { + if (d != null && this.getProxy().isActive()) { final IEnergyGrid energy = this.getProxy().getEnergy(); final double power = Math.ceil(items.getStackSize() / 1000D); - if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 ) - { + if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) { ItemStack inputStack = items.getItemStack(); ItemStack remaining; - if( mode == Actionable.SIMULATE ) - { - remaining = d.simulateAdd( inputStack ); - } - else - { - remaining = d.addItems( inputStack ); + if (mode == Actionable.SIMULATE) { + remaining = d.simulateAdd(inputStack); + } else { + remaining = d.addItems(inputStack); } - return AEItemStack.create( remaining ); + return AEItemStack.create(remaining); } } - } - catch( final GridAccessException e ) - { - AELog.debug( e ); + } catch (final GridAccessException e) { + AELog.debug(e); } return items; @@ -255,6 +266,6 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR @Override public void jobStateChange(ICraftingLink link) { - this.craftingTracker.jobStateChange( link ); + this.craftingTracker.jobStateChange(link); } } 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 b2ede2e2..74d2653d 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidImportBus.java @@ -29,14 +29,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 @@ -45,33 +44,28 @@ 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(); int maxDrain = this.calculateAmountToSend(); boolean drained = false; @@ -89,7 +83,8 @@ public class PartFluidImportBus extends PartSharedFluidBus { final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack); if (aeFluidStack != null) { - final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE, this.source); + final IAEFluidStack notInserted = + inv.injectItems(aeFluidStack, Actionable.MODULATE, this.source); if (notInserted != null && notInserted.getStackSize() > 0) { aeFluidStack.decStackSize(notInserted.getStackSize()); @@ -102,9 +97,7 @@ public class PartFluidImportBus extends PartSharedFluidBus { } return drained ? TickRateModulation.FASTER : TickRateModulation.SLOWER; - } - catch(GridAccessException e ) - { + } catch (GridAccessException e) { e.printStackTrace(); } } @@ -113,31 +106,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; } } @@ -145,56 +133,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 e6611ddb..070b27f7 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; @@ -48,29 +47,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.")); } } @@ -78,69 +79,69 @@ 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" ) ); + 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.setBeSubstitute(data.getBoolean("beSubstitute")); this.pattern.readFromNBT(data, "pattern"); - this.output.readFromNBT( data, "outputList" ); - this.crafting.readFromNBT( data, "craftingGrid" ); + 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 ); + public void writeToNBT(final NBTTagCompound data) { + super.writeToNBT(data); + data.setBoolean("craftingMode", this.craftingMode); + data.setBoolean("substitute", this.substitute); data.setBoolean("combine", this.combine); data.setBoolean("beSubstitute", this.beSubstitute); this.pattern.writeToNBT(data, "pattern"); - this.output.writeToNBT( data, "outputList" ); - this.crafting.writeToNBT( data, "craftingGrid" ); + 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); -// this.setBeSubstitute(data.getBoolean("beSubstitute")); + // this.setBeSubstitute(data.getBoolean("beSubstitute")); } for (int i = 0; i < this.crafting.getSizeInventory(); i++) { this.crafting.setInventorySlotContents(i, null); @@ -154,10 +155,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()); } } @@ -165,10 +166,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()); } } } @@ -177,39 +178,31 @@ 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; } @@ -245,24 +238,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 47fdee81..a1d03f07 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; @@ -50,29 +49,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.")); } } @@ -80,68 +81,68 @@ 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.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.setBeSubstitute(data.getBoolean("beSubstitute")); this.setSubstitution(data.getBoolean("substitute")); - this.setPrioritization( data.getBoolean( "priorization") ); - this.setInverted( data.getBoolean( "inverted" ) ); - this.setActivePage( data.getInteger( "activePage" ) ); + 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" ); + 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("beSubstitute", this.beSubstitute); 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(); @@ -162,10 +163,10 @@ 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.setBeSubstitute(data.getBoolean("beSubstitute")); + // this.setBeSubstitute(data.getBoolean("beSubstitute")); } this.setInverted(inputsCount <= 8 && outputCount > 8); this.setActivePage(0); @@ -182,7 +183,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()); } @@ -193,7 +195,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()); } @@ -203,10 +206,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()); } } } @@ -216,13 +219,11 @@ 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; } @@ -256,7 +257,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]; @@ -266,24 +267,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 @@ -321,5 +318,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/PartFluidTerminal.java b/src/main/java/com/glodblock/github/common/parts/PartFluidTerminal.java index 655f036a..002a97a7 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidTerminal.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidTerminal.java @@ -9,14 +9,13 @@ 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.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Vec3; -import java.util.Objects; - public class PartFluidTerminal extends FCBasePart { private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidTerminal_Bright; private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Colored; @@ -59,8 +58,14 @@ public class PartFluidTerminal extends FCBasePart { 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_TERMINAL); + 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_TERMINAL); } else { player.addChatComponentMessage(new ChatComponentText("You don't have permission to view.")); } @@ -84,5 +89,4 @@ public class PartFluidTerminal extends FCBasePart { } return GuiBridge.GUI_ME; } - } 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 1a096c30..c9517dfb 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,96 +26,79 @@ 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; @@ -133,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 @@ -164,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; } @@ -174,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..d52b4dfc 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 ) - { - this.damageValue = damageValue; - } - - public int getDamageValue() - { + public int getDamageValue() { return this.damageValue; } - EnumSet getFeature() - { + void setDamageValue(final int damageValue) { + this.damageValue = damageValue; + } + + 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 3ec27129..15272c77 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java @@ -29,30 +29,27 @@ 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 static final int singleByteAmount = 256 * 8; - 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,12 +110,12 @@ 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 @@ -138,7 +125,7 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public long getTotalBytes() { - return this.cellType.getBytes( this.cellItem ); + return this.cellType.getBytes(this.cellItem); } @Override @@ -185,26 +172,21 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public int getUnusedFluidCount() { return (int) (this.getStoredFluidCount() % singleByteAmount); - } @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(); } @@ -212,67 +194,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++; } @@ -287,13 +258,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); } /* @@ -301,75 +269,61 @@ 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 IAEFluidStack l = this.getCellItems().findPrecise( input ); + final IAEFluidStack l = this.getCellItems().findPrecise(input); - if( l != null ) - { - final long remainingItemSlots = this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount; + if (l != null) { + final long remainingItemSlots = + this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount; - 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(); } @@ -377,14 +331,13 @@ 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() - ((long) this.getBytesPerType() * singleByteAmount); + final long remainingItemCount = + this.getRemainingFluidCount() - ((long) this.getBytesPerType() * singleByteAmount); - if( remainingItemCount > 0 ) - { - if( input.getStackSize() > remainingItemCount ) - { + if (remainingItemCount > 0) { + if (input.getStackSize() > remainingItemCount) { final IAEFluidStack toReturn = input.copy(); toReturn.decStackSize(remainingItemCount); @@ -401,10 +354,9 @@ public class FluidCellInventory implements IFluidCellInventory { return 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(); } @@ -417,8 +369,7 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) { - if( request == null ) - { + if (request == null) { return null; } @@ -426,31 +377,25 @@ public class FluidCellInventory implements IFluidCellInventory { 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(); } } @@ -461,9 +406,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 dd60f416..cc3ddfb4 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,16 +41,14 @@ 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 @@ -60,23 +57,19 @@ public class FluidCellInventoryHandler extends MEInventoryHandler } @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 c2f6bf4d..6018b71c 100644 --- a/src/main/java/com/glodblock/github/common/storage/IFluidCellInventoryHandler.java +++ b/src/main/java/com/glodblock/github/common/storage/IFluidCellInventoryHandler.java @@ -12,5 +12,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 7e8fbe3c..f16e2dbf 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidInterface.java @@ -24,6 +24,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; @@ -32,19 +34,11 @@ 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 TileFluidInterface() { - super.getInterfaceDuality().getConfigManager() - .registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS); - } +public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory { private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) { - private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager(); + private final IConfigManager dualityConfigManager = + getInterfaceDuality().getConfigManager(); @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { @@ -56,6 +50,11 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler, return this.getTanks().drain(from.ordinal(), maxDrain, doDrain); } }; + + public TileFluidInterface() { + super.getInterfaceDuality().getConfigManager().registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS); + } + private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6); @MENetworkEventSubscribe @@ -85,12 +84,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())); } } @@ -102,10 +100,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 @@ -119,11 +117,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)); } @@ -143,7 +141,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++) { @@ -152,7 +150,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)); } @@ -176,17 +174,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"); @@ -194,8 +192,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(); } @@ -203,9 +200,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 @@ -247,7 +243,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)); } } @@ -257,5 +254,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 897e76af..c0477b48 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.copy()); 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()) { @@ -82,7 +83,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) { @@ -90,13 +92,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 6727b29a..2a69991a 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 @@ -85,7 +84,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++) { @@ -114,13 +113,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 d4de15cb..23ce811b 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/TileLevelMaintainer.java b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java index bdfbe672..07ec40f6 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java @@ -40,13 +40,13 @@ import com.glodblock.github.inventory.AeStackInventory; import com.glodblock.github.inventory.AeStackInventoryImpl; import com.google.common.collect.ImmutableSet; import io.netty.buffer.ByteBuf; +import java.util.concurrent.Future; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import java.util.concurrent.Future; - -public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInventory, IGridTickable, ICraftingRequester, IPowerChannelState { +public class TileLevelMaintainer extends AENetworkTile + implements IAEAppEngInventory, IGridTickable, ICraftingRequester, IPowerChannelState { public static final int REQ_COUNT = 5; public final InventoryRequest requests = new InventoryRequest(this); @@ -74,10 +74,14 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven try { if (this.getProxy().isActive()) { final IEnergyGrid energy = this.getProxy().getEnergy(); - final double power = Math.ceil(ItemFluidDrop.isFluidStack(items) ? items.getStackSize() / 1000D : items.getStackSize()); + final double power = Math.ceil( + ItemFluidDrop.isFluidStack(items) ? items.getStackSize() / 1000D : items.getStackSize()); if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) { if (ItemFluidDrop.isFluidStack(items)) { - IAEFluidStack notInserted = this.getProxy().getStorage().getFluidInventory().injectItems(ItemFluidDrop.getAeFluidStack(items), mode, this.source); + IAEFluidStack notInserted = this.getProxy() + .getStorage() + .getFluidInventory() + .injectItems(ItemFluidDrop.getAeFluidStack(items), mode, this.source); items.setStackSize(notInserted.getStackSize()); return items; } else { @@ -90,6 +94,7 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven } return items; } + @Override public void jobStateChange(ICraftingLink link) { if (this.requests.getLinks() != null) { @@ -120,15 +125,17 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven try { ICraftingGrid cg = this.getProxy().getCrafting(); IGrid grid = this.getProxy().getGrid(); - final IItemList inv = this.getProxy().getStorage().getItemInventory().getStorageList(); + final IItemList inv = + this.getProxy().getStorage().getItemInventory().getStorageList(); for (int i = 0; i < REQ_COUNT; i++) { IAEItemStack is = requests.getRequestQtyStack(i); if (is != null && requests.getBatchSize(i) > 0) { IAEItemStack craftItem = requests.getCraftItem(i); - if (cg.canEmitFor(craftItem) || cg.isRequesting(craftItem) || - (inv.findPrecise(is) != null && inv.findPrecise(is).getStackSize() >= is.getStackSize()) || !this.requests.isDone(i) - ) - continue; + if (cg.canEmitFor(craftItem) + || cg.isRequesting(craftItem) + || (inv.findPrecise(is) != null + && inv.findPrecise(is).getStackSize() >= is.getStackSize()) + || !this.requests.isDone(i)) continue; // do crafting Future jobTask = requests.getJobs()[i]; if (jobTask == null) { @@ -162,7 +169,8 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven } @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) { @@ -175,9 +183,7 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven } @Override - public void gridChanged() { - - } + public void gridChanged() {} @Override public boolean isPowered() { @@ -279,8 +285,8 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven try { newState = this.getProxy().isActive() - && this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) - > 0.0001; + && this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) + > 0.0001; } catch (final GridAccessException ignored) { } 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 a742faa5..fc743e75 100644 --- a/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java @@ -45,10 +45,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) { @@ -63,6 +62,5 @@ public class FCClassTransformer implements IClassTransformer { } protected abstract ClassVisitor getClassMapper(ClassVisitor downstream); - } } 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 2c157c52..7f070209 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 long getFluidDropsByteCost(long totalBytes, long originByte, IAEItemStack stack) { @@ -109,7 +109,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); @@ -122,36 +122,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); @@ -166,14 +161,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()); } @@ -201,6 +194,8 @@ public class CoreModHooks { } public static long IOPortMinSpeed(long possible, long itemsToMove, final StorageChannel chan) { - return chan == StorageChannel.FLUIDS ? Math.min(possible, itemsToMove * FluidCellInventory.singleByteAmount) : Math.min(possible, itemsToMove); + return chan == StorageChannel.FLUIDS + ? Math.min(possible, itemsToMove * FluidCellInventory.singleByteAmount) + : Math.min(possible, itemsToMove); } } 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 a2cfd941..99c02401 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/ContainerInterfaceTerminalTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/ContainerInterfaceTerminalTransformer.java @@ -27,11 +27,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 { @@ -43,16 +43,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 21c8c25b..7973bc48 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/CraftingCpuTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/CraftingCpuTransformer.java @@ -34,7 +34,6 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper { } return super.visitMethod(access, name, desc, signature, exceptions); } - } private static class TransformExecuteCrafting extends MethodVisitor { @@ -49,7 +48,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); @@ -73,46 +73,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 { @@ -124,18 +131,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 908abec6..5fe6ed38 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/CraftingTreeNodeTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/CraftingTreeNodeTransformer.java @@ -32,7 +32,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,15 +61,18 @@ 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; - cnt ++; - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "getCraftingByteCost", - "(Lappeng/api/storage/data/IAEItemStack;)J", - false); + cnt++; + 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); } @@ -78,23 +82,22 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper public void visitInsn(int opcode) { if (writingBytes && cnt == 5 && opcode == Opcodes.LADD) { super.visitVarInsn(Opcodes.ALOAD, 0); - super.visitFieldInsn(Opcodes.GETFIELD, - "appeng/crafting/CraftingTreeNode", - "what", - "Lappeng/api/storage/data/IAEItemStack;" - ); - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "getFluidDropsByteCost", - "(JJLappeng/api/storage/data/IAEItemStack;)J", - false); + super.visitFieldInsn( + Opcodes.GETFIELD, + "appeng/crafting/CraftingTreeNode", + "what", + "Lappeng/api/storage/data/IAEItemStack;"); + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "getFluidDropsByteCost", + "(JJLappeng/api/storage/data/IAEItemStack;)J", + false); writingBytes = false; - cnt ++; + cnt++; return; } super.visitInsn(opcode); } - } - } 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 14dd6d67..d38eb482 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/DualityInterfaceTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/DualityInterfaceTransformer.java @@ -30,12 +30,12 @@ public class DualityInterfaceTransformer extends FCClassTransformer.ClassMapper case "pushItemsOut": case "pushPattern": case "isBusy": - return new TransformInvAdaptorCalls(api, super.visitMethod(access, name, desc, signature, exceptions), name); + return new TransformInvAdaptorCalls( + api, super.visitMethod(access, name, desc, signature, exceptions), name); default: return super.visitMethod(access, name, desc, signature, exceptions); } } - } private static class TransformInvAdaptorCalls extends MethodVisitor { @@ -51,27 +51,33 @@ public class DualityInterfaceTransformer extends FCClassTransformer.ClassMapper public void visitFieldInsn(int opcode, String owner, String name, String desc) { super.visitFieldInsn(opcode, owner, name, desc); if (this.name.equals("pushItemsOut") && opcode == Opcodes.PUTFIELD && const_1 == 0) { -// update fluid tag + // update fluid tag super.visitVarInsn(Opcodes.ALOAD, 5); super.visitVarInsn(Opcodes.ALOAD, 10); - super.visitMethodInsn(Opcodes.INVOKESTATIC, "com/glodblock/github/coremod/hooker/CoreModHooks", "updateFluidTag", "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)V", false); + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "updateFluidTag", + "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)V", + false); const_1++; } } @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 5fb3344d..4cc3568d 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/GuiCraftingTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/GuiCraftingTransformer.java @@ -31,7 +31,6 @@ public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper { } return super.visitMethod(access, name, desc, signature, exceptions); } - } private static class TransformFluidIcon extends MethodVisitor { @@ -42,17 +41,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 95c28705..bf216e71 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/NEITransfermer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/NEITransfermer.java @@ -28,7 +28,8 @@ public class NEITransfermer extends FCClassTransformer.ClassMapper { public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { switch (name) { case "getStackUnderMouse": - return new TransformStackUnderMouse(api, super.visitMethod(access, name, desc, signature, exceptions)); + return new TransformStackUnderMouse( + api, super.visitMethod(access, name, desc, signature, exceptions)); case "shouldShowTooltip": return new TransformShowTooltip(api, super.visitMethod(access, name, desc, signature, exceptions)); default: @@ -49,12 +50,12 @@ public class NEITransfermer extends FCClassTransformer.ClassMapper { super.visitVarInsn(Opcodes.ALOAD, 1); super.visitVarInsn(Opcodes.ILOAD, 2); super.visitVarInsn(Opcodes.ILOAD, 3); - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "getStackUnderMouse", - "(Lnet/minecraft/client/gui/inventory/GuiContainer;II)Lnet/minecraft/item/ItemStack;", - false - ); + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "getStackUnderMouse", + "(Lnet/minecraft/client/gui/inventory/GuiContainer;II)Lnet/minecraft/item/ItemStack;", + false); return; } super.visitInsn(opcode); @@ -73,21 +74,19 @@ public class NEITransfermer extends FCClassTransformer.ClassMapper { public void visitInsn(int opcode) { if (opcode == Opcodes.ICONST_1 && const_1 == 2) { super.visitVarInsn(Opcodes.ALOAD, 1); - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "shouldShowTooltip", - "(Lnet/minecraft/client/gui/inventory/GuiContainer;)Z", - false - ); - const_1 ++; + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "shouldShowTooltip", + "(Lnet/minecraft/client/gui/inventory/GuiContainer;)Z", + false); + const_1++; return; } if (opcode == Opcodes.ICONST_1) { - const_1 ++; + const_1++; } super.visitInsn(opcode); } - } - } diff --git a/src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java b/src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java index 8adf6e74..bdc35e4a 100644 --- a/src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java @@ -26,7 +26,8 @@ public class TitleIOPortTransformer extends FCClassTransformer.ClassMapper { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if (name.equals("transferContents")) { - return new TitleIOPortTransformer.TransformTransferContents(api, super.visitMethod(access, name, desc, signature, exceptions)); + return new TitleIOPortTransformer.TransformTransferContents( + api, super.visitMethod(access, name, desc, signature, exceptions)); } return super.visitMethod(access, name, desc, signature, exceptions); } @@ -42,11 +43,12 @@ public class TitleIOPortTransformer extends FCClassTransformer.ClassMapper { public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (opcode == Opcodes.INVOKESTATIC && owner.equals("java/lang/Math") && name.equals("min")) { super.visitVarInsn(Opcodes.ALOAD, 6); - super.visitMethodInsn(Opcodes.INVOKESTATIC, - "com/glodblock/github/coremod/hooker/CoreModHooks", - "IOPortMinSpeed", - "(JJLappeng/api/storage/StorageChannel;)J", - false); + super.visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "IOPortMinSpeed", + "(JJLappeng/api/storage/StorageChannel;)J", + false); } else { super.visitMethodInsn(opcode, owner, name, desc, itf); } diff --git a/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverDualFluidInterface.java b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverDualFluidInterface.java index c20797fc..257020e6 100644 --- a/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverDualFluidInterface.java +++ b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverDualFluidInterface.java @@ -44,7 +44,9 @@ public class DriverDualFluidInterface implements SidedBlock { super(tileEntity, NameConst.BLOCK_FLUID_INTERFACE); } - @Callback(doc = "function(index:number):table -- Get the configuration of the dual fluid interface on the specified slot.") + @Callback( + doc = + "function(index:number):table -- Get the configuration of the dual fluid interface on the specified slot.") public Object[] getFluidInterfaceConfiguration(Context context, Arguments args) { int index = args.checkInteger(0); if (index >= 0 && index < DualityFluidInterface.NUMBER_OF_TANKS) { @@ -54,12 +56,14 @@ public class DriverDualFluidInterface implements SidedBlock { throw new IllegalArgumentException("invalid slot"); } - @Callback(doc = "function(index:number[, database:address, entry:number]):boolean -- Configure the filter in fluid interface on the specified slot.") + @Callback( + doc = + "function(index:number[, database:address, entry:number]):boolean -- Configure the filter in fluid interface on the specified slot.") public Object[] setFluidInterfaceConfiguration(Context context, Arguments args) { int index = args.checkInteger(0); String address; int entry; - if (args.count() == 3){ + if (args.count() == 3) { address = args.checkString(1); entry = args.checkInteger(2); } else { @@ -68,17 +72,14 @@ public class DriverDualFluidInterface implements SidedBlock { return new Object[] {true}; } Node node = node().network().node(address); - if (!(node instanceof Component)) - throw new IllegalArgumentException("no such component"); - if (!(node.host() instanceof Database)) - throw new IllegalArgumentException("not a database"); + if (!(node instanceof Component)) throw new IllegalArgumentException("no such component"); + if (!(node.host() instanceof Database)) throw new IllegalArgumentException("not a database"); Database database = (Database) node.host(); if (index >= 0 && index < DualityFluidInterface.NUMBER_OF_TANKS) { ItemStack data = database.getStackInSlot(entry - 1); if (data == null) { tileEntity.getConfig().setFluidInSlot(index, null); - } - else { + } else { FluidStack fluid = Util.getFluidFromItem(data); tileEntity.getConfig().setFluidInSlot(index, tileEntity.getStandardFluid(fluid)); } @@ -124,17 +125,16 @@ public class DriverDualFluidInterface implements SidedBlock { } public static class Provider implements EnvironmentProvider { - Provider() { - } + Provider() {} @Override public Class getEnvironment(ItemStack itemStack) { - if (itemStack != null && (itemStack.isItemEqual(ItemAndBlockHolder.FLUID_INTERFACE.stack()) - || itemStack.isItemEqual(ItemAndBlockHolder.INTERFACE.stack()))) { + if (itemStack != null + && (itemStack.isItemEqual(ItemAndBlockHolder.FLUID_INTERFACE.stack()) + || itemStack.isItemEqual(ItemAndBlockHolder.INTERFACE.stack()))) { return DriverDualFluidInterface.Environment.class; } return null; } } - } diff --git a/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java index dc884b49..fa4c9c9b 100644 --- a/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java @@ -7,6 +7,8 @@ import com.glodblock.github.inventory.AeItemStackHandler; import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; +import java.util.HashMap; +import java.util.Map; import li.cil.oc.api.driver.EnvironmentProvider; import li.cil.oc.api.driver.NamedBlock; import li.cil.oc.api.internal.Database; @@ -23,10 +25,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.HashMap; -import java.util.Map; - - public class DriverLevelMaintainer extends DriverSidedTileEntity { @Override public Class getTileEntityClass() { @@ -38,8 +36,7 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity { return new DriverLevelMaintainer.Environment((TileLevelMaintainer) world.getTileEntity(x, y, z)); } - public static class Environment extends ManagedTileEntityEnvironment - implements NamedBlock { + public static class Environment extends ManagedTileEntityEnvironment implements NamedBlock { public Environment(TileLevelMaintainer tileEntity) { super(tileEntity, NameConst.BLOCK_LEVEL_MAINTAINER); @@ -103,16 +100,18 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity { result.put("hasTag", stack.hasTagCompound()); result.put("label", stack.getDisplayName()); result.put("maxDamage", stack.getMaxDamage()); - result.put("name", GameRegistry.findUniqueIdentifierFor(stack.getItem()).toString()); + result.put( + "name", + GameRegistry.findUniqueIdentifierFor(stack.getItem()).toString()); result.put("quantity", tileEntity.requests.getQuantity(slot)); result.put("batch", tileEntity.requests.getBatchSize(slot)); result.put("isFluid", ItemFluidDrop.isFluidStack(stack)); if (ItemFluidDrop.isFluidStack(stack)) result.put("fluid", ItemFluidDrop.getFluidStack(stack)); result.put("isEnable", tileEntity.requests.isEnable(slot)); result.put("isDone", tileEntity.requests.isDone(slot)); - return new Object[]{result}; + return new Object[] {result}; } - return new Object[]{null}; + return new Object[] {null}; } private void setSlot(int slot, String address, int index) { @@ -124,7 +123,9 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity { throw new IllegalArgumentException("Invalid slot"); } dbStack.stackSize = 1; - ((AeItemStackHandler) tileEntity.getInventory()).getAeInventory().setStack(slot, AEItemStack.create(dbStack)); + ((AeItemStackHandler) tileEntity.getInventory()) + .getAeInventory() + .setStack(slot, AEItemStack.create(dbStack)); } else { throw new IllegalArgumentException("Not a database"); } @@ -133,7 +134,9 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity { } } - @Callback(doc = "function(slot:number[,database:address[,index:number]],quantity:number,batch:number):boolean -- Configuration the slot.") + @Callback( + doc = + "function(slot:number[,database:address[,index:number]],quantity:number,batch:number):boolean -- Configuration the slot.") public Object[] setSlot(Context context, Arguments args) { int slot; String address; @@ -159,7 +162,7 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity { } else { throw new IllegalArgumentException("Invalid args"); } - return new Object[]{true}; + return new Object[] {true}; } private boolean isActive() { @@ -168,22 +171,22 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity { @Callback(doc = "function(slot:number):boolean -- Get the crafting task state.") public Object[] isDone(Context context, Arguments args) { - return new Object[]{this.isDone(args)}; + return new Object[] {this.isDone(args)}; } @Callback(doc = "function(slot:number):boolean -- Get the crafting state of slot.") public Object[] isEnable(Context context, Arguments args) { - return new Object[]{this.isEnable(args)}; + return new Object[] {this.isEnable(args)}; } @Callback(doc = "function(slot:number,value:boolean):boolean -- Set the crafting state of slot.") public Object[] setEnable(Context context, Arguments args) { - return new Object[]{this.setEnable(args)}; + return new Object[] {this.setEnable(args)}; } @Callback(doc = "function():boolean Get Level Maintainer state") public Object[] active(Context context, Arguments args) { - return new Object[]{this.isActive()}; + return new Object[] {this.isActive()}; } @Override @@ -198,8 +201,7 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity { } public static class Provider implements EnvironmentProvider { - Provider() { - } + Provider() {} @Override public Class getEnvironment(ItemStack itemStack) { 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 d63a4ecc..b742dacf 100644 --- a/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java +++ b/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java @@ -12,5 +12,4 @@ public class OCDriverInit { Driver.add(new DriverDualFluidInterface()); Driver.add(new DriverDualFluidInterface.Provider()); } - } diff --git a/src/main/java/com/glodblock/github/crossmod/waila/FCTooltipHandlerWaila.java b/src/main/java/com/glodblock/github/crossmod/waila/FCTooltipHandlerWaila.java index c38752d7..88af835e 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/FCTooltipHandlerWaila.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/FCTooltipHandlerWaila.java @@ -2,6 +2,7 @@ package com.glodblock.github.crossmod.waila; import com.glodblock.github.common.item.ItemFluidDrop; import com.glodblock.github.util.Util; +import java.util.List; import mcp.mobius.waila.handlers.nei.TooltipHandlerWaila; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; @@ -9,8 +10,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; -import java.util.List; - public class FCTooltipHandlerWaila extends TooltipHandlerWaila { @Override public List handleItemDisplayName(GuiContainer arg0, ItemStack itemstack, List currenttip) { @@ -18,13 +17,21 @@ public class FCTooltipHandlerWaila extends TooltipHandlerWaila { } @Override - public List handleItemTooltip(GuiContainer arg0, ItemStack itemstack, int arg2, int arg3, List currenttip) { + public List handleItemTooltip( + GuiContainer arg0, ItemStack itemstack, int arg2, int arg3, List currenttip) { if (itemstack != null && itemstack.getItem() instanceof ItemFluidDrop && currenttip.size() > 0) { FluidStack fs = ItemFluidDrop.getFluidStack(itemstack); if (fs == null) return currenttip; currenttip.set(0, Tooltip.partFluidTerminalFluidFormat(fs)); if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips) { - currenttip.set(1, EnumChatFormatting.GRAY + String.format("%s:%s", Util.getFluidModID(fs.getFluid()), fs.getFluid().getName()) + EnumChatFormatting.RESET); + currenttip.set( + 1, + EnumChatFormatting.GRAY + + String.format( + "%s:%s", + Util.getFluidModID(fs.getFluid()), + fs.getFluid().getName()) + + EnumChatFormatting.RESET); } String modName = Util.getFluidModName(fs.getFluid()); if (modName != null && !modName.equals("")) diff --git a/src/main/java/com/glodblock/github/crossmod/waila/PartWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/PartWailaDataProvider.java index ec1cbdc9..4e969ff7 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/PartWailaDataProvider.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/PartWailaDataProvider.java @@ -8,6 +8,7 @@ import com.glodblock.github.crossmod.waila.part.FluidInvWailaDataProvider; import com.glodblock.github.crossmod.waila.part.SpeedWailaDataProvider; import com.google.common.base.Optional; import com.google.common.collect.Lists; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -18,8 +19,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import java.util.List; - public class PartWailaDataProvider implements IWailaDataProvider { private final List providers; private final PartAccessor accessor = new PartAccessor(); @@ -55,10 +54,10 @@ public class PartWailaDataProvider implements IWailaDataProvider { @Override public List getWailaHead( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { final TileEntity te = accessor.getTileEntity(); final MovingObjectPosition mop = accessor.getPosition(); @@ -77,10 +76,10 @@ public class PartWailaDataProvider implements IWailaDataProvider { @Override public List getWailaBody( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { final TileEntity te = accessor.getTileEntity(); final MovingObjectPosition mop = accessor.getPosition(); @@ -99,10 +98,10 @@ public class PartWailaDataProvider implements IWailaDataProvider { @Override public List getWailaTail( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { final TileEntity te = accessor.getTileEntity(); final MovingObjectPosition mop = accessor.getPosition(); @@ -121,13 +120,13 @@ public class PartWailaDataProvider implements IWailaDataProvider { @Override public NBTTagCompound getNBTData( - final EntityPlayerMP player, - final TileEntity te, - final NBTTagCompound tag, - final World world, - final int x, - final int y, - final int z) { + final EntityPlayerMP player, + final TileEntity te, + final NBTTagCompound tag, + final World world, + final int x, + final int y, + final int z) { final MovingObjectPosition mop = this.tracer.retraceBlock(world, player, x, y, z); if (mop != null) { diff --git a/src/main/java/com/glodblock/github/crossmod/waila/TileWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/TileWailaDataProvider.java index b8d8dffe..11fc32fb 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/TileWailaDataProvider.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/TileWailaDataProvider.java @@ -3,6 +3,7 @@ package com.glodblock.github.crossmod.waila; import com.glodblock.github.crossmod.waila.tile.FluidInvWailaDataProvider; import com.glodblock.github.crossmod.waila.tile.LevelMaintainerWailaDataProvide; import com.google.common.collect.Lists; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -12,8 +13,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import java.util.List; - public class TileWailaDataProvider implements IWailaDataProvider { private final List providers; @@ -30,10 +29,10 @@ public class TileWailaDataProvider implements IWailaDataProvider { @Override public List getWailaHead( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { for (final IWailaDataProvider provider : this.providers) { provider.getWailaHead(itemStack, currentToolTip, accessor, config); } @@ -43,10 +42,10 @@ public class TileWailaDataProvider implements IWailaDataProvider { @Override public List getWailaBody( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { for (final IWailaDataProvider provider : this.providers) { provider.getWailaBody(itemStack, currentToolTip, accessor, config); } @@ -56,10 +55,10 @@ public class TileWailaDataProvider implements IWailaDataProvider { @Override public List getWailaTail( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { for (final IWailaDataProvider provider : this.providers) { provider.getWailaTail(itemStack, currentToolTip, accessor, config); } @@ -69,13 +68,13 @@ public class TileWailaDataProvider implements IWailaDataProvider { @Override public NBTTagCompound getNBTData( - final EntityPlayerMP player, - final TileEntity te, - final NBTTagCompound tag, - final World world, - final int x, - final int y, - final int z) { + final EntityPlayerMP player, + final TileEntity te, + final NBTTagCompound tag, + final World world, + final int x, + final int y, + final int z) { for (final IWailaDataProvider provider : this.providers) { provider.getNBTData(player, te, tag, world, x, y, z); } diff --git a/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java b/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java index 2bbdc363..0ae77dce 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/Tooltip.java @@ -2,30 +2,37 @@ package com.glodblock.github.crossmod.waila; import com.glodblock.github.util.NameConst; import com.glodblock.github.util.Util; +import java.text.NumberFormat; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; import net.minecraftforge.fluids.FluidStack; -import java.text.NumberFormat; - public class Tooltip { public static String fluidFormat(String name, int amount) { return String.format("%s: %s mB", name, NumberFormat.getInstance().format(amount)); } public static String partFluidBusFormat(int amount) { - return String.format("%s: %s mB/t", I18n.format(NameConst.WAILA_SPEED), NumberFormat.getInstance().format(amount)); + return String.format( + "%s: %s mB/t", + I18n.format(NameConst.WAILA_SPEED), NumberFormat.getInstance().format(amount)); } public static String tileFluidInterfaceFormat(String name, int amount, int face) { - return String.format("%s %s: %s mB", I18n.format(NameConst.GUI_FLUID_INTERFACE + "." + face), name, NumberFormat.getInstance().format(amount)); + return String.format( + "%s %s: %s mB", + I18n.format(NameConst.GUI_FLUID_INTERFACE + "." + face), + name, + NumberFormat.getInstance().format(amount)); } public static String tileLevelMaintainerFormat(String name, long quantity, long batch, boolean isEnable) { - return String.format("%s: %s / %s %s", - name, NumberFormat.getInstance().format(quantity), NumberFormat.getInstance().format(batch), - isEnable ? I18n.format(NameConst.WAILA_ENABLE) : I18n.format(NameConst.WAILA_DISABLE) - ); + return String.format( + "%s: %s / %s %s", + name, + NumberFormat.getInstance().format(quantity), + NumberFormat.getInstance().format(batch), + isEnable ? I18n.format(NameConst.WAILA_ENABLE) : I18n.format(NameConst.WAILA_DISABLE)); } public static String partFluidTerminalFluidFormat(FluidStack fs) { diff --git a/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java b/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java index 6f9166ff..219ba015 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/WailaInit.java @@ -23,5 +23,4 @@ public class WailaInit { registrar.registerBodyProvider(tile, AEBaseTile.class); registrar.registerNBTProvider(tile, AEBaseTile.class); } - } diff --git a/src/main/java/com/glodblock/github/crossmod/waila/part/FluidInvWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/part/FluidInvWailaDataProvider.java index 4de650c0..a1162153 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/part/FluidInvWailaDataProvider.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/part/FluidInvWailaDataProvider.java @@ -5,6 +5,7 @@ import appeng.integration.modules.waila.part.BasePartWailaDataProvider; import com.glodblock.github.crossmod.waila.Tooltip; import com.glodblock.github.inventory.AEFluidInventory; import com.glodblock.github.inventory.IAEFluidInventory; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayerMP; @@ -13,15 +14,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; -import java.util.List; - public class FluidInvWailaDataProvider extends BasePartWailaDataProvider { @Override public List getWailaBody( - final IPart part, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final IPart part, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { if (part instanceof IAEFluidInventory) { ((IAEFluidInventory) part).getInternalFluid().readFromNBT(accessor.getNBTData(), "fluidInv"); AEFluidInventory fluidInventory = ((IAEFluidInventory) part).getInternalFluid(); @@ -36,14 +35,14 @@ public class FluidInvWailaDataProvider extends BasePartWailaDataProvider { @Override public NBTTagCompound getNBTData( - final EntityPlayerMP player, - final IPart part, - final TileEntity te, - final NBTTagCompound tag, - final World world, - final int x, - final int y, - final int z) { + final EntityPlayerMP player, + final IPart part, + final TileEntity te, + final NBTTagCompound tag, + final World world, + final int x, + final int y, + final int z) { if (part instanceof IAEFluidInventory) { ((IAEFluidInventory) part).getInternalFluid().writeToNBT(tag, "fluidInv"); } diff --git a/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java index fad23841..169b7444 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/part/SpeedWailaDataProvider.java @@ -4,6 +4,7 @@ import appeng.api.parts.IPart; import appeng.integration.modules.waila.part.BasePartWailaDataProvider; import com.glodblock.github.common.parts.PartSharedFluidBus; import com.glodblock.github.crossmod.waila.Tooltip; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayerMP; @@ -11,16 +12,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import java.util.List; - public class SpeedWailaDataProvider extends BasePartWailaDataProvider { @Override public List getWailaBody( - final IPart part, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final IPart part, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { if (part instanceof PartSharedFluidBus) { part.readFromNBT(accessor.getNBTData()); currentToolTip.add(Tooltip.partFluidBusFormat(((PartSharedFluidBus) part).calculateAmountToSend() / 5)); @@ -30,14 +29,14 @@ public class SpeedWailaDataProvider extends BasePartWailaDataProvider { @Override public NBTTagCompound getNBTData( - final EntityPlayerMP player, - final IPart part, - final TileEntity te, - final NBTTagCompound tag, - final World world, - final int x, - final int y, - final int z) { + final EntityPlayerMP player, + final IPart part, + final TileEntity te, + final NBTTagCompound tag, + final World world, + final int x, + final int y, + final int z) { if (part instanceof PartSharedFluidBus) { part.writeToNBT(tag); } diff --git a/src/main/java/com/glodblock/github/crossmod/waila/tile/FluidInvWailaDataProvider.java b/src/main/java/com/glodblock/github/crossmod/waila/tile/FluidInvWailaDataProvider.java index f88764de..2d432e28 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/tile/FluidInvWailaDataProvider.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/tile/FluidInvWailaDataProvider.java @@ -7,6 +7,7 @@ import com.glodblock.github.common.tile.TileFluidPacketDecoder; import com.glodblock.github.crossmod.waila.Tooltip; import com.glodblock.github.inventory.IAEFluidInventory; import com.glodblock.github.inventory.IAEFluidTank; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayerMP; @@ -17,16 +18,14 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; -import java.util.List; - public class FluidInvWailaDataProvider extends BaseWailaDataProvider { @Override public List getWailaBody( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { final TileEntity te = accessor.getTileEntity(); if (te instanceof TileFluidInterface) { ((IAEFluidInventory) te).getInternalFluid().readFromNBT(accessor.getNBTData(), "fluidInv"); @@ -53,7 +52,8 @@ public class FluidInvWailaDataProvider extends BaseWailaDataProvider { if (ft.getFluidInSlot(i) == null) continue; FluidStack fs = ft.getFluidInSlot(i).getFluidStack(); if (prefix) { - currentToolTip.add(Tooltip.tileFluidInterfaceFormat(fs.getFluid().getLocalizedName(), fs.amount, i)); + currentToolTip.add( + Tooltip.tileFluidInterfaceFormat(fs.getFluid().getLocalizedName(), fs.amount, i)); } else { currentToolTip.add(Tooltip.fluidFormat(fs.getFluid().getLocalizedName(), fs.amount)); } @@ -66,13 +66,13 @@ public class FluidInvWailaDataProvider extends BaseWailaDataProvider { @Override public NBTTagCompound getNBTData( - final EntityPlayerMP player, - final TileEntity te, - final NBTTagCompound tag, - final World world, - final int x, - final int y, - final int z) { + final EntityPlayerMP player, + final TileEntity te, + final NBTTagCompound tag, + final World world, + final int x, + final int y, + final int z) { if (te instanceof IAEFluidInventory) { ((IAEFluidInventory) te).getInternalFluid().writeToNBT(tag, "fluidInv"); } else if (te instanceof TileFluidPacketDecoder) { diff --git a/src/main/java/com/glodblock/github/crossmod/waila/tile/LevelMaintainerWailaDataProvide.java b/src/main/java/com/glodblock/github/crossmod/waila/tile/LevelMaintainerWailaDataProvide.java index 88692183..77db3979 100644 --- a/src/main/java/com/glodblock/github/crossmod/waila/tile/LevelMaintainerWailaDataProvide.java +++ b/src/main/java/com/glodblock/github/crossmod/waila/tile/LevelMaintainerWailaDataProvide.java @@ -4,6 +4,7 @@ import appeng.api.storage.data.IAEItemStack; import appeng.integration.modules.waila.BaseWailaDataProvider; import com.glodblock.github.common.tile.TileLevelMaintainer; import com.glodblock.github.crossmod.waila.Tooltip; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayerMP; @@ -12,43 +13,40 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import java.util.List; - public class LevelMaintainerWailaDataProvide extends BaseWailaDataProvider { @Override public List getWailaBody( - final ItemStack itemStack, - final List currentToolTip, - final IWailaDataAccessor accessor, - final IWailaConfigHandler config) { + final ItemStack itemStack, + final List currentToolTip, + final IWailaDataAccessor accessor, + final IWailaConfigHandler config) { final TileEntity te = accessor.getTileEntity(); if (te instanceof TileLevelMaintainer) { te.readFromNBT(accessor.getNBTData()); for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { - IAEItemStack ias = ((TileLevelMaintainer) te).requests.getRequestStacks().getStack(i); + IAEItemStack ias = + ((TileLevelMaintainer) te).requests.getRequestStacks().getStack(i); if (ias != null) { currentToolTip.add(Tooltip.tileLevelMaintainerFormat( - ias.getItemStack().getDisplayName(), - ((TileLevelMaintainer) te).requests.getQuantity(i), - ((TileLevelMaintainer) te).requests.getBatchSize(i), - ((TileLevelMaintainer) te).requests.isEnable(i) - )); + ias.getItemStack().getDisplayName(), + ((TileLevelMaintainer) te).requests.getQuantity(i), + ((TileLevelMaintainer) te).requests.getBatchSize(i), + ((TileLevelMaintainer) te).requests.isEnable(i))); } } } return currentToolTip; } - @Override public NBTTagCompound getNBTData( - final EntityPlayerMP player, - final TileEntity te, - final NBTTagCompound tag, - final World world, - final int x, - final int y, - final int z) { + final EntityPlayerMP player, + final TileEntity te, + final NBTTagCompound tag, + final World world, + final int x, + final int y, + final int z) { if (te instanceof TileLevelMaintainer) { te.writeToNBT(tag); } diff --git a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java index 6d24a806..d43845cc 100644 --- a/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java +++ b/src/main/java/com/glodblock/github/inventory/AEFluidInventory.java @@ -12,193 +12,155 @@ 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 int lastIndex; - 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; } } @@ -206,36 +168,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; } } @@ -244,46 +198,37 @@ 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 = lastIndex; slot < this.getSlots(); ++slot ) - { + for (int slot = lastIndex; slot < this.getSlots(); ++slot) { if (this.getFluidInSlot(slot) == null) { - if(slot == this.getSlots()-1) lastIndex = 0; + if (slot == this.getSlots() - 1) lastIndex = 0; 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) { lastIndex = slot; 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; } } @@ -300,77 +245,61 @@ 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 ) - { + } catch (final Exception e) { this.fluids[x] = null; 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 @@ -379,9 +308,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 @@ -401,7 +329,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; @@ -416,8 +345,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 961a1ec2..e4b7cf2f 100644 --- a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java +++ b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java @@ -20,6 +20,11 @@ import com.glodblock.github.util.Ae2Reflect; import com.glodblock.github.util.BlockPos; import com.glodblock.github.util.ModAndClassUtil; import com.glodblock.github.util.Util; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import javax.annotation.Nullable; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -28,20 +33,43 @@ 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; -import java.util.LinkedList; -import java.util.List; - public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { + public FluidConvertingInventoryAdaptor( + @Nullable InventoryAdaptor invItems, + @Nullable IFluidHandler invFluids, + EnumFacing facing, + BlockPos pos, + boolean isOnmi, + Object eioConduct) { + this.invItems = invItems; + this.invFluids = invFluids; + this.side = Util.from(facing); + this.posInterface = pos; + this.eioDuct = eioConduct; + this.onmi = isOnmi; + } + + private final InventoryAdaptor invItems; + private final IFluidHandler invFluids; + private final ForgeDirection side; + private final BlockPos posInterface; + private final Object eioDuct; + private final boolean onmi; + 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 || ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidExportBus)))) + 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 + || ((TileCableBus) inter).getPart(f.getOpposite()) + instanceof PartFluidExportBus)))) return InventoryAdaptor.getAdaptor(capProvider, f); InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, f); IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null; @@ -56,27 +84,11 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi, conduct); } - private final InventoryAdaptor invItems; - private final IFluidHandler invFluids; - private final ForgeDirection side; - private final BlockPos posInterface; - private final Object eioDuct; - private final boolean onmi; - - public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids, EnumFacing facing, BlockPos pos, boolean isOnmi, Object eioConduct) { - this.invItems = invItems; - this.invFluids = invFluids; - this.side = Util.from(facing); - this.posInterface = pos; - this.eioDuct = eioConduct; - this.onmi = isOnmi; - } - - public ItemStack addItems( ItemStack toBeAdded, InsertionMode insertionMode ) { + public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) { if (toBeAdded.getItem() instanceof ItemFluidPacket || toBeAdded.getItem() instanceof ItemFluidDrop) { if (invFluids != null) { FluidStack fluid; - if( toBeAdded.getItem() instanceof ItemFluidPacket ) { + if (toBeAdded.getItem() instanceof ItemFluidPacket) { fluid = ItemFluidPacket.getFluidStack(toBeAdded); } else { fluid = ItemFluidDrop.getFluidStack(toBeAdded); @@ -95,7 +107,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { if (eioDuct != null) { return ((IItemDuct) eioDuct).insertItem(side, toBeAdded); } - return invItems != null ? invItems.addItems(toBeAdded,insertionMode) : toBeAdded; + return invItems != null ? invItems.addItems(toBeAdded, insertionMode) : toBeAdded; } @Override @@ -114,7 +126,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { if (onmi) { boolean sus = false; FluidStack fluid; - if( toBeSimulated.getItem() instanceof ItemFluidPacket ) { + if (toBeSimulated.getItem() instanceof ItemFluidPacket) { fluid = ItemFluidPacket.getFluidStack(toBeSimulated); } else { fluid = ItemFluidDrop.getFluidStack(toBeSimulated); @@ -138,7 +150,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } if (invFluids != null) { FluidStack fluid; - if( toBeSimulated.getItem() instanceof ItemFluidPacket ) { + if (toBeSimulated.getItem() instanceof ItemFluidPacket) { fluid = ItemFluidPacket.getFluidStack(toBeSimulated); } else { fluid = ItemFluidDrop.getFluidStack(toBeSimulated); @@ -154,7 +166,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } return toBeSimulated; } - //Assert EIO conduct can hold all item, as it is the origin practice in AE2 + // Assert EIO conduct can hold all item, as it is the origin practice in AE2 if (eioDuct != null) { return null; } @@ -172,12 +184,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; } @@ -189,7 +203,8 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } if (invFluids != null && invFluids.getTankInfo(this.side) != null) { List tankInfos = new LinkedList<>(); - if (invFluids instanceof TileCableBus && ((TileCableBus) invFluids).getPart(this.side) instanceof PartP2PLiquids) { + if (invFluids instanceof TileCableBus + && ((TileCableBus) invFluids).getPart(this.side) instanceof PartP2PLiquids) { // read other ends of p2p for blocking mode PartP2PLiquids invFluidsP2P = (PartP2PLiquids) ((TileCableBus) invFluids).getPart(this.side); try { @@ -203,11 +218,9 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { p2p = invFluidsP2P.getInput(); checkedInput = true; } - if (p2p == invFluidsP2P || p2p == null) - continue; + if (p2p == invFluidsP2P || p2p == null) continue; IFluidHandler target = Ae2Reflect.getP2PLiquidTarget(p2p); - if (target == null) - continue; + if (target == null) continue; tankInfos.add(target.getTankInfo(p2p.getSide().getOpposite())); } } catch (GridAccessException e) { @@ -235,15 +248,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 { @@ -277,7 +289,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 0cf45f6a..26f3e2d1 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; -public interface IAEFluidInventory -{ +public interface IAEFluidInventory { void onFluidInventoryChanged(final IAEFluidTank inv, final int slot); AEFluidInventory getInternalFluid(); 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 a1291629..d9f912d3 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java +++ b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java @@ -13,10 +13,9 @@ 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 net.minecraft.entity.player.EntityPlayer; - -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; +import net.minecraft.entity.player.EntityPlayer; public enum GuiType { LEVEL_MAINTAINER(new TileGuiFactory(TileLevelMaintainer.class) { @@ -270,5 +269,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 a4609837..125d95ff 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/MouseRegionManager.java +++ b/src/main/java/com/glodblock/github/inventory/gui/MouseRegionManager.java @@ -1,14 +1,13 @@ package com.glodblock.github.inventory.gui; import appeng.client.gui.AEBaseGui; +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<>(); @@ -26,7 +25,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; } } @@ -40,7 +41,7 @@ public class MouseRegionManager { if (region.containsMouse(mX, mY)) { List tooltip = region.handler.getTooltip(); if (tooltip != null) { - ((AEBaseGui)gui).drawTooltip(mX,mY,0,String.join("\n",tooltip)); + ((AEBaseGui) gui).drawTooltip(mX, mY, 0, String.join("\n", tooltip)); return; } } @@ -63,7 +64,6 @@ public class MouseRegionManager { boolean containsMouse(int mX, int mY) { return mX >= x && mX < x + width && mY >= y && mY < y + height; } - } public interface Handler { @@ -76,7 +76,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 6fe5978a..0139b1a6 100644 --- a/src/main/java/com/glodblock/github/loader/ChannelLoader.java +++ b/src/main/java/com/glodblock/github/loader/ChannelLoader.java @@ -9,19 +9,33 @@ 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 CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER); - FluidCraft.proxy.netHandler.registerMessage(new CPacketLevelMaintainer.Handler(), CPacketLevelMaintainer.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); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage( + new CPacketLevelMaintainer.Handler(), CPacketLevelMaintainer.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 a627125d..5e6252ae 100644 --- a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java +++ b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java @@ -27,11 +27,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() { @@ -44,5 +49,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 7ea8bb96..400c23c9 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,81 +14,285 @@ 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 AE2_TERMINAL = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 380); - public final static ItemStack AE2_CRAFTING_CP_UNIT = new ItemStack(GameRegistry.findItem("appliedenergistics2", "tile.BlockCraftingUnit"), 1, 1); - public final static ItemStack AE2_PATTERN_CAPACITY_CARD = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 54); - 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 AE2_TERMINAL = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 380); + public static final ItemStack AE2_CRAFTING_CP_UNIT = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "tile.BlockCraftingUnit"), 1, 1); + public static final ItemStack AE2_PATTERN_CAPACITY_CARD = + new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 54); + 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( + 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_TERM.stack(), AE2_TERMINAL, BUFFER); - GameRegistry.addShapelessRecipe(LEVEL_MAINTAINER.stack(), AE2_CRAFTING_CP_UNIT, ENCODER, AE2_PATTERN_CAPACITY_CARD); + GameRegistry.addShapelessRecipe( + LEVEL_MAINTAINER.stack(), AE2_CRAFTING_CP_UNIT, ENCODER, AE2_PATTERN_CAPACITY_CARD); 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 f19de01d..3f28a9a6 100644 --- a/src/main/java/com/glodblock/github/nei/NEIGuiHandler.java +++ b/src/main/java/com/glodblock/github/nei/NEIGuiHandler.java @@ -16,5 +16,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 bf90a772..f548b472 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": @@ -99,8 +98,7 @@ public class CPacketFluidPatternTermBtns implements IMessage { cpt.getPatternTerminal().setBeSubstitute(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": @@ -141,16 +139,14 @@ public class CPacketFluidPatternTermBtns implements IMessage { cpt.getPatternTerminal().setBeSubstitute(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/CPacketFluidUpdate.java b/src/main/java/com/glodblock/github/network/CPacketFluidUpdate.java index 801dc1a3..90b1fd5f 100644 --- a/src/main/java/com/glodblock/github/network/CPacketFluidUpdate.java +++ b/src/main/java/com/glodblock/github/network/CPacketFluidUpdate.java @@ -8,14 +8,13 @@ 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.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.item.ItemStack; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; public class CPacketFluidUpdate implements IMessage { @@ -23,8 +22,7 @@ public class CPacketFluidUpdate implements IMessage { private ItemStack itemStack; private int slotIndex; - public CPacketFluidUpdate() { - } + public CPacketFluidUpdate() {} public CPacketFluidUpdate(Map data, ItemStack itemStack) { this.list = data; @@ -50,8 +48,7 @@ public class CPacketFluidUpdate implements IMessage { 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); @@ -73,8 +70,7 @@ public class CPacketFluidUpdate 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); @@ -100,10 +96,14 @@ public class CPacketFluidUpdate implements IMessage { EntityPlayer player = ctx.getServerHandler().playerEntity; if (container instanceof FCBaseFluidMonitorContain) { ItemStack item = player.inventory.getItemStack(); - ((FCBaseFluidMonitorContain) container).postChange(new ArrayList(message.list.values()), message.itemStack == null ? item : message.itemStack, player, message.slotIndex); + ((FCBaseFluidMonitorContain) container) + .postChange( + new ArrayList(message.list.values()), + message.itemStack == null ? item : message.itemStack, + player, + message.slotIndex); } 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/CPacketLevelMaintainer.java b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java index 0fa007c3..9b246582 100644 --- a/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java @@ -9,20 +9,18 @@ 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 javax.annotation.Nullable; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import javax.annotation.Nullable; - public class CPacketLevelMaintainer implements IMessage { private String action; private long size; private int slotIndex; - public CPacketLevelMaintainer() { - } + public CPacketLevelMaintainer() {} public CPacketLevelMaintainer(String action, int slotIndex) { this.action = action; @@ -104,9 +102,11 @@ public class CPacketLevelMaintainer implements IMessage { @Nullable @Override public IMessage onMessage(CPacketLevelMaintainer message, MessageContext ctx) { - if (message.action.startsWith("TileLevelMaintainer.") && ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) { + if (message.action.startsWith("TileLevelMaintainer.") + && ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; - final ContainerLevelMaintainer cca = (ContainerLevelMaintainer) ctx.getServerHandler().playerEntity.openContainer; + final ContainerLevelMaintainer cca = + (ContainerLevelMaintainer) ctx.getServerHandler().playerEntity.openContainer; switch (message.action) { case "TileLevelMaintainer.Quantity": cca.getTile().updateQuantity(message.slotIndex, message.size); diff --git a/src/main/java/com/glodblock/github/network/CPacketPatternValueSet.java b/src/main/java/com/glodblock/github/network/CPacketPatternValueSet.java index ac80e243..61ee16e2 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 75b24f34..5b0f343e 100644 --- a/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java +++ b/src/main/java/com/glodblock/github/network/SPacketFluidUpdate.java @@ -9,21 +9,19 @@ 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 net.minecraft.item.ItemStack; - import java.io.IOException; import java.util.HashMap; import java.util.Map; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.item.ItemStack; public class SPacketFluidUpdate implements IMessage { private Map list; private IAEItemStack itemStack; - public SPacketFluidUpdate() { - } + public SPacketFluidUpdate() {} public SPacketFluidUpdate(Map data) { this.list = data; @@ -48,8 +46,7 @@ public class SPacketFluidUpdate implements IMessage { 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); @@ -69,8 +66,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); @@ -93,19 +89,17 @@ 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()) { @@ -120,6 +114,5 @@ public class SPacketFluidUpdate implements IMessage { } 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 4bd67a0c..c09f8aae 100644 --- a/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java +++ b/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java @@ -12,13 +12,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 { @@ -49,7 +48,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++) { if (isFluid) { list.add(AEFluidStack.loadFluidStackFromPacket(buf)); } else { 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 185809cd..8f4d5e2f 100644 --- a/src/main/java/com/glodblock/github/util/Ae2Reflect.java +++ b/src/main/java/com/glodblock/github/util/Ae2Reflect.java @@ -16,11 +16,10 @@ import appeng.me.storage.MEPassThrough; import appeng.parts.p2p.PartP2PLiquids; import appeng.util.inv.ItemSlot; import appeng.util.prioitylist.IPartitionList; -import net.minecraftforge.fluids.IFluidHandler; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Arrays; +import net.minecraftforge.fluids.IFluidHandler; public class Ae2Reflect { @@ -54,7 +53,8 @@ public class Ae2Reflect { fContainerUpgradeable_upgradeable = Ae2Reflect.reflectField(ContainerUpgradeable.class, "upgradeable"); 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"); mP2PLiquids_getTarget = reflectMethod(PartP2PLiquids.class, "getTarget"); } catch (Exception e) { @@ -62,20 +62,20 @@ public class Ae2Reflect { } } - 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)); @@ -86,7 +86,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); } @@ -183,5 +183,4 @@ public class Ae2Reflect { throw new IllegalStateException("Failed to invoke method: " + mP2PLiquids_getTarget, 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 239d651a..92797088 100644 --- a/src/main/java/com/glodblock/github/util/BlockPos.java +++ b/src/main/java/com/glodblock/github/util/BlockPos.java @@ -1,12 +1,11 @@ package com.glodblock.github.util; +import java.util.Objects; +import javax.annotation.Nonnull; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import javax.annotation.Nonnull; -import java.util.Objects; - public class BlockPos { private final int x; @@ -70,5 +69,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 5b96cdf4..4e0ae1ee 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 } } } - } } @@ -252,7 +258,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; } @@ -272,14 +278,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 )"); } } @@ -288,13 +294,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 )"); } } @@ -362,7 +369,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; @@ -371,7 +378,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); } @@ -393,8 +400,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) { @@ -435,5 +441,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 11cf70ea..85fc0fa1 100644 --- a/src/main/java/com/glodblock/github/util/FluidPatternDetails.java +++ b/src/main/java/com/glodblock/github/util/FluidPatternDetails.java @@ -4,6 +4,9 @@ import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.storage.data.IAEItemStack; import appeng.helpers.PatternHelper; import appeng.util.item.AEItemStack; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -11,11 +14,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.Objects; - -public class FluidPatternDetails implements ICraftingPatternDetails, Comparable{ +public class FluidPatternDetails implements ICraftingPatternDetails, Comparable { private final ItemStack patternStack; private IAEItemStack patternStackAe; @@ -105,9 +104,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; } @@ -143,7 +140,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 @@ -155,7 +152,7 @@ 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("combine", this.getCombine()); @@ -184,7 +181,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 +192,4 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< } return stacks; } - } diff --git a/src/main/java/com/glodblock/github/util/FluidSorters.java b/src/main/java/com/glodblock/github/util/FluidSorters.java index dd940379..50a5c962 100644 --- a/src/main/java/com/glodblock/github/util/FluidSorters.java +++ b/src/main/java/com/glodblock/github/util/FluidSorters.java @@ -7,9 +7,8 @@ import appeng.integration.IntegrationType; import appeng.integration.abstraction.IInvTweaks; import appeng.util.Platform; import com.glodblock.github.common.item.ItemFluidDrop; -import net.minecraftforge.fluids.Fluid; - import java.util.Comparator; +import net.minecraftforge.fluids.Fluid; public class FluidSorters { private static SortDir Direction = SortDir.ASCENDING; @@ -20,7 +19,8 @@ public class FluidSorters { final Fluid f1 = ItemFluidDrop.getAeFluidStack(o1).getFluid(); final Fluid f2 = ItemFluidDrop.getAeFluidStack(o2).getFluid(); if (getDirection() == SortDir.ASCENDING) { - return this.secondarySort(Util.getFluidModName(f2).compareToIgnoreCase(Util.getFluidModName(f1)), f1, f2); + return this.secondarySort( + Util.getFluidModName(f2).compareToIgnoreCase(Util.getFluidModName(f1)), f1, f2); } return this.secondarySort(Util.getFluidModName(f1).compareToIgnoreCase(Util.getFluidModName(f2)), f2, f1); } diff --git a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java index d01680fa..9aa21c1e 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 { @@ -73,7 +72,7 @@ public final class ModAndClassUtil { } try { Field d = ButtonToolTips.class.getDeclaredField("BeSubstitutionsDescEnabled"); -// isBeSubstitutionsButton = true; + // isBeSubstitutionsButton = true; } catch (NoSuchFieldException e) { isBeSubstitutionsButton = false; } @@ -108,31 +107,18 @@ 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("CoFHCore")) - COFH = true; - if (Loader.isModLoaded("miscutils")) - GTPP = true; - if (Loader.isModLoaded("Waila")) - WAILA = 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("CoFHCore")) COFH = true; + if (Loader.isModLoaded("miscutils")) GTPP = true; + if (Loader.isModLoaded("Waila")) WAILA = true; } } diff --git a/src/main/java/com/glodblock/github/util/NameConst.java b/src/main/java/com/glodblock/github/util/NameConst.java index 79d8da28..30554a12 100644 --- a/src/main/java/com/glodblock/github/util/NameConst.java +++ b/src/main/java/com/glodblock/github/util/NameConst.java @@ -54,5 +54,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 e4cf68b1..918feed6 100644 --- a/src/main/java/com/glodblock/github/util/Util.java +++ b/src/main/java/com/glodblock/github/util/Util.java @@ -25,9 +25,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]; @@ -63,7 +66,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)); } @@ -75,20 +79,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; + if (size == 0 || itemStack == null) return null; ItemStack copy = itemStack.copy(); copy.stackSize = size; return copy; } public static AEFluidStack getAEFluidFromItem(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) { @@ -110,7 +118,8 @@ public final class Util { } 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) { @@ -164,11 +173,10 @@ public final class Util { } catch (Exception e) { return ""; } - } public static IAEFluidStack loadFluidStackFromNBT(final NBTTagCompound i) { - //Fuck ae2 + // Fuck ae2 final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1); final AEFluidStack fluid = AEFluidStack.create(t); fluid.setStackSize(i.getLong("Cnt")); @@ -184,8 +192,7 @@ public final class Util { public static class FluidUtil { public static IAEFluidStack createAEFluidStack(Fluid fluid) { - return createAEFluidStack(new FluidStack(fluid, - FluidContainerRegistry.BUCKET_VOLUME)); + return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME)); } public static IAEFluidStack createAEFluidStack(Fluid fluid, long amount) { @@ -197,45 +204,38 @@ public final class Util { } public static IAEFluidStack createAEFluidStack(int fluidId, long amount) { - return createAEFluidStack(new FluidStack(FluidRegistry.getFluid(fluidId), 1)).setStackSize( - amount); + return createAEFluidStack(new FluidStack(FluidRegistry.getFluid(fluidId), 1)) + .setStackSize(amount); } public static boolean isEmpty(ItemStack itemStack) { - if (itemStack == null) - return false; + if (itemStack == null) return false; Item item = itemStack.getItem(); if (item instanceof IFluidContainerItem) { - FluidStack content = ((IFluidContainerItem) item) - .getFluid(itemStack); + FluidStack content = ((IFluidContainerItem) item).getFluid(itemStack); return content == null || content.amount <= 0; } return FluidContainerRegistry.isEmptyContainer(itemStack); } public static boolean isFilled(ItemStack itemStack) { - if (itemStack == null) - return false; + if (itemStack == null) return false; Item item = itemStack.getItem(); if (item instanceof IFluidContainerItem) { - FluidStack content = ((IFluidContainerItem) item) - .getFluid(itemStack); + FluidStack content = ((IFluidContainerItem) item).getFluid(itemStack); return content != null && content.amount > 0; } return FluidContainerRegistry.isFilledContainer(itemStack); } public static boolean isFluidContainer(ItemStack itemStack) { - if (itemStack == null) - return false; + if (itemStack == null) return false; Item item = itemStack.getItem(); - return item instanceof IFluidContainerItem - || FluidContainerRegistry.isContainer(itemStack); + return item instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(itemStack); } public static FluidStack getFluidFromContainer(ItemStack itemStack) { - if (itemStack == null) - return null; + if (itemStack == null) return null; ItemStack container = itemStack.copy(); Item item = container.getItem(); @@ -247,8 +247,7 @@ public final class Util { } public static int getCapacity(ItemStack itemStack, Fluid fluid) { - if (itemStack == null) - return 0; + if (itemStack == null) return 0; Item item = itemStack.getItem(); if (item instanceof IFluidContainerItem) { IFluidContainerItem fluidContainerItem = (IFluidContainerItem) item; @@ -268,12 +267,11 @@ public final class Util { } public static ItemStack clearFluid(ItemStack itemStack) { - if (itemStack == null) - return null; + if (itemStack == null) return null; Item item = itemStack.getItem(); if (item instanceof IFluidContainerItem) { - ((IFluidContainerItem) item).drain(itemStack, - ((IFluidContainerItem) item).getFluid(itemStack).amount, true); + ((IFluidContainerItem) item) + .drain(itemStack, ((IFluidContainerItem) item).getFluid(itemStack).amount, true); return itemStack; } else if (FluidContainerRegistry.isContainer(itemStack)) { return FluidContainerRegistry.drainFluidContainer(itemStack); @@ -281,55 +279,40 @@ public final class Util { return null; } - public static MutablePair drainStack( - ItemStack itemStack, FluidStack fluid) { - if (itemStack == null) - return null; + public static MutablePair drainStack(ItemStack itemStack, FluidStack fluid) { + if (itemStack == null) return null; Item item = itemStack.getItem(); if (item instanceof IFluidContainerItem) { - FluidStack drained = ((IFluidContainerItem) item).drain(itemStack, - fluid.amount, true); - int amountDrained = drained != null - && drained.getFluid() == fluid.getFluid() ? drained.amount - : 0; + FluidStack drained = ((IFluidContainerItem) item).drain(itemStack, fluid.amount, true); + int amountDrained = drained != null && drained.getFluid() == fluid.getFluid() ? drained.amount : 0; return new MutablePair(amountDrained, itemStack); } else if (FluidContainerRegistry.isContainer(itemStack)) { - FluidStack content = FluidContainerRegistry - .getFluidForFilledItem(itemStack); - int amountDrained = content != null - && content.getFluid() == fluid.getFluid() ? content.amount - : 0; - return new MutablePair(amountDrained, - FluidContainerRegistry.drainFluidContainer(itemStack)); + FluidStack content = FluidContainerRegistry.getFluidForFilledItem(itemStack); + int amountDrained = content != null && content.getFluid() == fluid.getFluid() ? content.amount : 0; + return new MutablePair( + amountDrained, FluidContainerRegistry.drainFluidContainer(itemStack)); } return null; } - public static MutablePair fillStack( - ItemStack itemStack, FluidStack fluid) { - if (itemStack == null || itemStack.stackSize != 1) - return null; + public static MutablePair fillStack(ItemStack itemStack, FluidStack fluid) { + if (itemStack == null || itemStack.stackSize != 1) return null; Item item = itemStack.getItem(); - //If its a fluid container item instance + // If its a fluid container item instance if (item instanceof IFluidContainerItem) { - //Call the fill method on it. - int filled = ((IFluidContainerItem) item).fill(itemStack, fluid, - true); + // Call the fill method on it. + int filled = ((IFluidContainerItem) item).fill(itemStack, fluid, true); - //Return the filled itemstack. + // Return the filled itemstack. return new MutablePair(filled, itemStack); } else if (FluidContainerRegistry.isContainer(itemStack)) { - //Fill it through the fluidcontainer registry. - ItemStack filledContainer = FluidContainerRegistry - .fillFluidContainer(fluid, itemStack); - //get the filled fluidstack. - FluidStack filled = FluidContainerRegistry - .getFluidForFilledItem(filledContainer); - //Return filled container and fill amount. - return new MutablePair( - filled != null ? filled.amount : 0, filledContainer); - + // Fill it through the fluidcontainer registry. + ItemStack filledContainer = FluidContainerRegistry.fillFluidContainer(fluid, itemStack); + // get the filled fluidstack. + FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(filledContainer); + // Return filled container and fill amount. + return new MutablePair(filled != null ? filled.amount : 0, filledContainer); } return null; }