mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 10:55:06 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
a9591a031e
39 files changed
+860
-634
No files matched your search
+23
-42
@@ -1,4 +1,4 @@
|
||||
//version: 1697697256
|
||||
//version: 1704650211
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -28,27 +28,11 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name 'forge'
|
||||
url 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
// GTNH RetroFuturaGradle and ASM Fork
|
||||
name "GTNH Maven"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
}
|
||||
maven {
|
||||
name 'sonatype'
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
maven {
|
||||
name 'Scala CI dependencies'
|
||||
url 'https://repo1.maven.org/maven2/'
|
||||
}
|
||||
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
@@ -64,12 +48,12 @@ plugins {
|
||||
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||
id 'com.palantir.git-version' version '3.0.0' apply false
|
||||
id 'de.undercouch.download' version '5.4.0'
|
||||
id 'de.undercouch.download' version '5.5.0'
|
||||
id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false // Unused, available for addon.gradle
|
||||
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
|
||||
id 'com.modrinth.minotaur' version '2.+' apply false
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.27'
|
||||
}
|
||||
|
||||
print("You might want to check out './gradlew :faq' if your build fails.\n")
|
||||
@@ -133,7 +117,7 @@ propertyDefaultIfUnset("forceEnableMixins", false)
|
||||
propertyDefaultIfUnset("channel", "stable")
|
||||
propertyDefaultIfUnset("mappingsVersion", "12")
|
||||
propertyDefaultIfUnset("usesMavenPublishing", true)
|
||||
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
|
||||
propertyDefaultIfUnset("mavenPublishUrl", "https://nexus.gtnewhorizons.com/repository/releases/")
|
||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||
propertyDefaultIfUnset("modrinthRelations", "")
|
||||
propertyDefaultIfUnset("curseForgeProjectId", "")
|
||||
@@ -302,7 +286,7 @@ if (apiPackage) {
|
||||
}
|
||||
|
||||
if (accessTransformersFile) {
|
||||
for (atFile in accessTransformersFile.split(",")) {
|
||||
for (atFile in accessTransformersFile.split(" ")) {
|
||||
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
|
||||
if (!getFile(targetFile).exists()) {
|
||||
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
||||
@@ -588,13 +572,15 @@ afterEvaluate {
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
name = "GTNH Maven"
|
||||
url = "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
// Links for convenience:
|
||||
// Simple HTML browsing: https://nexus.gtnewhorizons.com/service/rest/repository/browse/releases/
|
||||
// Rich web UI browsing: https://nexus.gtnewhorizons.com/#browse/browse:releases
|
||||
}
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
}
|
||||
maven {
|
||||
name 'sonatype'
|
||||
@@ -628,7 +614,7 @@ repositories {
|
||||
}
|
||||
maven {
|
||||
name = "ic2"
|
||||
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
|
||||
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
|
||||
content {
|
||||
includeGroup "net.industrial-craft"
|
||||
}
|
||||
@@ -646,7 +632,7 @@ repositories {
|
||||
|
||||
def mixinProviderGroup = "io.github.legacymoddingmc"
|
||||
def mixinProviderModule = "unimixins"
|
||||
def mixinProviderVersion = "0.1.7.1"
|
||||
def mixinProviderVersion = "0.1.13"
|
||||
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
|
||||
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
||||
ext.mixinProviderSpec = mixinProviderSpec
|
||||
@@ -687,6 +673,8 @@ configurations.all {
|
||||
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
|
||||
|
||||
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,12 +781,12 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lwjgl3ifyVersion = '1.5.1'
|
||||
def lwjgl3ifyVersion = '1.5.7'
|
||||
if (modId != 'lwjgl3ify') {
|
||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||
}
|
||||
if (modId != 'hodgepodge') {
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.17')
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.35')
|
||||
}
|
||||
|
||||
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
||||
@@ -973,8 +961,7 @@ if (usesShadowedDependencies.toBoolean()) {
|
||||
configurations.runtimeElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||
configurations.apiElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||
tasks.named("jar", Jar) {
|
||||
enabled = false
|
||||
finalizedBy(tasks.shadowJar)
|
||||
archiveClassifier.set('dev-preshadow')
|
||||
}
|
||||
tasks.named("reobfJar", ReobfuscatedJar) {
|
||||
inputJar.set(tasks.named("shadowJar", ShadowJar).flatMap({it.archiveFile}))
|
||||
@@ -983,11 +970,6 @@ if (usesShadowedDependencies.toBoolean()) {
|
||||
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) {
|
||||
tasks.named(runTask).configure {
|
||||
dependsOn("shadowJar")
|
||||
}
|
||||
}
|
||||
}
|
||||
ext.publishableDevJar = usesShadowedDependencies.toBoolean() ? tasks.shadowJar : tasks.jar
|
||||
ext.publishableObfJar = tasks.reobfJar
|
||||
@@ -1187,12 +1169,11 @@ publishing {
|
||||
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
if (usesMavenPublishing.toBoolean()) {
|
||||
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
|
||||
maven {
|
||||
url = mavenPublishUrl
|
||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
|
||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://")
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||
@@ -1311,7 +1292,7 @@ def addCurseForgeRelation(String type, String name) {
|
||||
|
||||
// Updating
|
||||
|
||||
def buildscriptGradleVersion = "8.2.1"
|
||||
def buildscriptGradleVersion = "8.5"
|
||||
|
||||
tasks.named('wrapper', Wrapper).configure {
|
||||
gradleVersion = buildscriptGradleVersion
|
||||
|
||||
+10
-11
@@ -34,26 +34,25 @@
|
||||
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
|
||||
*/
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:NotEnoughItems:2.4.5-GTNH:dev')
|
||||
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-277-GTNH:dev')
|
||||
api('com.github.GTNewHorizons:NotEnoughItems:2.4.13-GTNH:dev')
|
||||
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-307-GTNH:dev')
|
||||
api('curse.maven:cofh-core-69162:2388751')
|
||||
api('com.github.GTNewHorizons:waila:1.6.2:dev')
|
||||
api('com.github.GTNewHorizons:waila:1.6.5:dev')
|
||||
|
||||
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.1:dev")
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
|
||||
compileOnly('com.github.GTNewHorizons:Baubles:1.0.3:dev')
|
||||
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:ForestryMC:4.6.14:dev')
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.5.3:dev')
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.71:dev') {
|
||||
compileOnly('com.github.GTNewHorizons:ForestryMC:4.8.1:dev')
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.6.2:dev')
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.15:dev') {
|
||||
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
|
||||
}
|
||||
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.19-GTNH:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.13-GTNH:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.24:dev') { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.22:dev") { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:OpenComputers:1.10.1-GTNH:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.6.1-GTNH:dev') { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.4.5:dev") { transitive = false }
|
||||
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.1.7:dev")
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -83,7 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -130,10 +131,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -198,11 +202,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
+4
-5
@@ -4,10 +4,9 @@ pluginManagement {
|
||||
maven {
|
||||
// RetroFuturaGradle
|
||||
name "GTNH Maven"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
mavenContent {
|
||||
includeGroup("com.gtnewhorizons.retrofuturagradle")
|
||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
||||
}
|
||||
}
|
||||
gradlePluginPortal()
|
||||
@@ -17,8 +16,8 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.diffplug.blowdryerSetup' version '1.6.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
|
||||
id 'com.diffplug.blowdryerSetup' version '1.7.1'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' // Provides java toolchains
|
||||
}
|
||||
|
||||
blowdryerSetup {
|
||||
|
||||
@@ -57,7 +57,6 @@ public class FluidCraft {
|
||||
|
||||
@Mod.EventHandler
|
||||
public static void init(FMLInitializationEvent event) {
|
||||
ModAndClassUtil.init();
|
||||
if (ModAndClassUtil.OC) {
|
||||
OCDriverInit.run();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.config.AdvancedBlockingMode;
|
||||
import appeng.api.config.InsertionMode;
|
||||
import appeng.api.config.LockCraftingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SidelessMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
@@ -40,6 +41,7 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
private GuiImgButton insertionMode;
|
||||
private GuiImgButton sidelessMode;
|
||||
private GuiImgButton advancedBlockingMode;
|
||||
private GuiImgButton lockCraftingMode;
|
||||
private final IInterfaceHost host;
|
||||
|
||||
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
|
||||
@@ -103,6 +105,14 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
SidelessMode.SIDELESS);
|
||||
this.buttonList.add(this.sidelessMode);
|
||||
}
|
||||
|
||||
this.lockCraftingMode = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.guiTop + 98,
|
||||
Settings.LOCK_CRAFTING_MODE,
|
||||
LockCraftingMode.NONE);
|
||||
this.lockCraftingMode.visible = this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0;
|
||||
this.buttonList.add(lockCraftingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,6 +133,9 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
if (this.advancedBlockingMode != null) {
|
||||
this.advancedBlockingMode.set(((ContainerDualInterface) this.cvb).getAdvancedBlockingMode());
|
||||
}
|
||||
if (this.lockCraftingMode != null) {
|
||||
this.lockCraftingMode.set(((ContainerInterface) this.cvb).getLockCraftingMode());
|
||||
}
|
||||
this.fontRendererObj.drawString(
|
||||
getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)),
|
||||
8,
|
||||
@@ -161,6 +174,8 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
} else if (btn == this.advancedBlockingMode) {
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketConfigButton(this.advancedBlockingMode.getSetting(), backwards));
|
||||
} else if (btn == this.lockCraftingMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.lockCraftingMode.getSetting(), backwards));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,5 +193,8 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
if (this.advancedBlockingMode != null) {
|
||||
this.advancedBlockingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0);
|
||||
}
|
||||
if (this.lockCraftingMode != null) {
|
||||
this.lockCraftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -80,13 +78,8 @@ public class GuiEssentiaTerminal extends GuiFluidMonitor {
|
||||
@Override
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
if (slot instanceof SlotME && AspectUtil.isEssentiaContainer(player.inventory.getItemStack())) {
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
ItemStack itemStack = this.player.inventory.getItemStack().copy();
|
||||
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
|
||||
if (!isShiftKeyDown()) {
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
|
||||
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
|
||||
}
|
||||
if (mouseButton == 3 && slot instanceof SlotME) {
|
||||
return;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
@@ -121,13 +118,8 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
|
||||
@Override
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
if (slot instanceof SlotME && Util.FluidUtil.isFluidContainer(player.inventory.getItemStack())) {
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
ItemStack itemStack = this.player.inventory.getItemStack().copy();
|
||||
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
|
||||
if (!isShiftKeyDown()) {
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
|
||||
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
|
||||
}
|
||||
if (mouseButton == 3 && slot instanceof SlotME) {
|
||||
return;
|
||||
|
||||
@@ -41,6 +41,7 @@ import appeng.api.AEApi;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.client.gui.IInterfaceTerminalPostUpdate;
|
||||
@@ -88,6 +89,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
private final GuiImgButton guiButtonAssemblersOnly;
|
||||
private final GuiImgButton guiButtonBrokenRecipes;
|
||||
private final GuiImgButton terminalStyleBox;
|
||||
private final GuiImgButton searchStringSave;
|
||||
private boolean onlyMolecularAssemblers = false;
|
||||
private boolean onlyBrokenRecipes = false;
|
||||
private boolean online;
|
||||
@@ -96,6 +98,9 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
private final List<String> extraOptionsText;
|
||||
private ItemStack tooltipStack;
|
||||
private final boolean neiPresent;
|
||||
protected static String searchFieldInputsText = "";
|
||||
protected static String searchFieldOutputsText = "";
|
||||
protected static String searchFieldNamesText = "";
|
||||
/*
|
||||
* Z-level Map (FLOATS) 0.0 - BACKGROUND 1.0 - ItemStacks 2.0 - Slot color overlays 20.0 - ItemStack overlays 21.0 -
|
||||
* Slot mouse hover overlay 200.0 - Tooltips
|
||||
@@ -143,6 +148,11 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
};
|
||||
searchFieldNames.setFocused(true);
|
||||
|
||||
searchStringSave = new GuiImgButton(
|
||||
0,
|
||||
0,
|
||||
Settings.SAVE_SEARCH,
|
||||
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO);
|
||||
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
@@ -196,8 +206,11 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
terminalStyleBox.xPosition = guiLeft - 18;
|
||||
terminalStyleBox.yPosition = guiTop + 8;
|
||||
|
||||
searchStringSave.xPosition = guiLeft - 18;
|
||||
searchStringSave.yPosition = terminalStyleBox.yPosition + 18;
|
||||
|
||||
guiButtonBrokenRecipes.xPosition = guiLeft - 18;
|
||||
guiButtonBrokenRecipes.yPosition = terminalStyleBox.yPosition + 18;
|
||||
guiButtonBrokenRecipes.yPosition = searchStringSave.yPosition + 18;
|
||||
|
||||
guiButtonHideFull.xPosition = guiLeft - 18;
|
||||
guiButtonHideFull.yPosition = guiButtonBrokenRecipes.yPosition + 18;
|
||||
@@ -207,12 +220,17 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
|
||||
offsetY = guiButtonAssemblersOnly.yPosition + 18;
|
||||
|
||||
if (AEConfig.instance.preserveSearchBar || isSubGui()) {
|
||||
setSearchString();
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
this.repositionSlots();
|
||||
|
||||
buttonList.add(guiButtonAssemblersOnly);
|
||||
buttonList.add(guiButtonHideFull);
|
||||
buttonList.add(guiButtonBrokenRecipes);
|
||||
buttonList.add(searchStringSave);
|
||||
buttonList.add(terminalStyleBox);
|
||||
initGuiDone();
|
||||
addSwitchGuiBtns();
|
||||
@@ -306,6 +324,8 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
if (btn == this.terminalStyleBox) {
|
||||
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
|
||||
initGui();
|
||||
} else if (btn == searchStringSave) {
|
||||
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
|
||||
}
|
||||
|
||||
iBtn.set(next);
|
||||
@@ -315,6 +335,20 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
searchFieldInputsText = searchFieldInputs.getText();
|
||||
searchFieldOutputsText = searchFieldOutputs.getText();
|
||||
searchFieldNamesText = searchFieldNames.getText();
|
||||
}
|
||||
|
||||
public void setSearchString() {
|
||||
searchFieldInputs.setText(searchFieldInputsText);
|
||||
searchFieldOutputs.setText(searchFieldOutputsText);
|
||||
searchFieldNames.setText(searchFieldNamesText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.bindTexture(BACKGROUND);
|
||||
@@ -567,7 +601,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
|
||||
translatedRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
|
||||
translatedRenderItem
|
||||
.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
|
||||
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
|
||||
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z);
|
||||
aeRenderItem.setAeStack(AEItemStack.create(toRender));
|
||||
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
|
||||
aeRenderItem.zLevel = 0.0f;
|
||||
|
||||
@@ -318,19 +318,18 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public GuiType getOriginalGui() {
|
||||
return originalGui;
|
||||
}
|
||||
|
||||
public void switchGui() {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketLevelTerminalCommands(
|
||||
CPacketLevelTerminalCommands.Action.BACK,
|
||||
originalBlockPos.x,
|
||||
originalBlockPos.y,
|
||||
originalBlockPos.z,
|
||||
originalBlockPos.getDimension(),
|
||||
originalBlockPos.getSide()));
|
||||
CPacketLevelTerminalCommands message = new CPacketLevelTerminalCommands(
|
||||
CPacketLevelTerminalCommands.Action.BACK,
|
||||
originalBlockPos.x,
|
||||
originalBlockPos.y,
|
||||
originalBlockPos.z,
|
||||
originalBlockPos.getDimension(),
|
||||
originalBlockPos.getSide());
|
||||
if (originalGui != null) {
|
||||
message.setOriginalGui(originalGui.ordinal());
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -538,7 +537,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
this.textField = textField;
|
||||
this.textField.setEnableBackgroundDrawing(false);
|
||||
this.textField.setText("0");
|
||||
this.textField.setMaxStringLength(10); // this length is enough to useful
|
||||
this.textField.setMaxStringLength(16); // this length is enough to be useful
|
||||
this.idx = idx;
|
||||
this.action = action;
|
||||
this.tooltip = tooltip;
|
||||
|
||||
@@ -1386,7 +1386,8 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
|
||||
if (action != null) {
|
||||
ItemStack itemStack = getInventory().getStackInSlot(slotIdx);
|
||||
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
|
||||
if (itemStack != null && itemStack.hasTagCompound()
|
||||
&& itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
|
||||
long batch = itemStack.getTagCompound().getLong(TLMTags.Batch.tagName);
|
||||
NBTTagCompound stackData = itemStack.getTagCompound().getCompoundTag(TLMTags.Stack.tagName);
|
||||
ItemStack is = ItemStack.loadItemStackFromNBT(stackData);
|
||||
|
||||
@@ -35,6 +35,8 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
|
||||
protected ItemStack icon = null;
|
||||
|
||||
protected GuiType originalGui;
|
||||
|
||||
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(new ContainerRenamer(ip, monitorable));
|
||||
this.host = monitorable;
|
||||
@@ -51,12 +53,16 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
|
||||
if (host instanceof PartLevelTerminal) {
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
} else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host)) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
} else if (host instanceof WirelessLevelTerminalInventory) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
} else if (host instanceof WirelessInterfaceTerminalInventory) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack();
|
||||
originalGui = GuiType.WIRELESS_INTERFACE_TERMINAL;
|
||||
}
|
||||
if (this.icon != null) {
|
||||
this.buttonList.add(
|
||||
@@ -114,13 +120,9 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
}
|
||||
|
||||
public void switchGui() {
|
||||
if (host instanceof PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
|
||||
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
|
||||
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(terminal.getItemStack()));
|
||||
else if (host instanceof WirelessInterfaceTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
else if (host instanceof WirelessLevelTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
if (originalGui != null) {
|
||||
InventoryHandler.switchGui(originalGui);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
|
||||
|
||||
@@ -101,6 +101,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
||||
protected GuiImgButton terminalStyleBox;
|
||||
protected GuiImgButton searchStringSave;
|
||||
protected GuiImgButton typeFilter;
|
||||
protected boolean hasShiftKeyDown = false;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
|
||||
@@ -772,4 +773,14 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
||||
public boolean isOverTextField(int mousex, int mousey) {
|
||||
return searchField.isMouseIn(mousex, mousey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleKeyboardInput() {
|
||||
super.handleKeyboardInput();
|
||||
hasShiftKeyDown |= isShiftKeyDown();
|
||||
if (hasShiftKeyDown && !Keyboard.getEventKeyState()) { // keyup
|
||||
this.repo.updateView();
|
||||
hasShiftKeyDown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+100
-94
@@ -1,7 +1,6 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -23,7 +22,6 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
|
||||
|
||||
@@ -37,110 +35,118 @@ public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
|
||||
&& AspectUtil.isEssentiaContainer(clickSlot.getStack())) {
|
||||
ItemStack tis = clickSlot.getStack();
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
tmp.put(0, null);
|
||||
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(index));
|
||||
}
|
||||
}
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(Iterable<IAEFluidStack> 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 (AspectUtil.isEmptyEssentiaContainer(fluidContainer) && AspectUtil.isEssentiaGas(fluid)) {
|
||||
// add essentia to jars
|
||||
if (nfluid.getStackSize() / AspectUtil.R <= 0) continue;
|
||||
final IAEFluidStack toExtract = nfluid.copy();
|
||||
MutablePair<Integer, ItemStack> fillStack = AspectUtil
|
||||
.fillEssentiaFromGas(out, toExtract.getFluidStack());
|
||||
if (fillStack == null || 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());
|
||||
if (tmp == null) continue;
|
||||
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
|
||||
this.dropItem(fillStack.right);
|
||||
out.stackSize = fillStack.right.stackSize;
|
||||
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
|
||||
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
|
||||
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
|
||||
this.dropItem(
|
||||
AspectUtil.setAspectAmount(
|
||||
fillStack.right,
|
||||
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
|
||||
AspectUtil.getAspectFromGas(toExtract)),
|
||||
1);
|
||||
out.stackSize++;
|
||||
}
|
||||
}
|
||||
} else if (!AspectUtil.isEmptyEssentiaContainer(fluidContainer)) {
|
||||
// add essentia to ae network
|
||||
AEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(fluidContainer);
|
||||
if (fluidStack == null) {
|
||||
continue;
|
||||
}
|
||||
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<Integer, ItemStack> drainStack = AspectUtil
|
||||
.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
|
||||
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
|
||||
if (fluidStack.getStackSize() == notInserted.getStackSize()) continue;
|
||||
aeFluidStack.decStackSize(notInserted.getStackSize());
|
||||
public void postChange(IAEFluidStack clientSelectedFluid, EntityPlayer player, int slotIndex, boolean shift) {
|
||||
ItemStack targetStack;
|
||||
if (slotIndex == -1) {
|
||||
targetStack = player.inventory.getItemStack();
|
||||
} else {
|
||||
targetStack = player.inventory.getStackInSlot(slotIndex);
|
||||
}
|
||||
final int containersRequested = shift ? targetStack.stackSize : 1;
|
||||
|
||||
if (drainStack.left > aeFluidStack.getStackSize()
|
||||
&& AspectUtil.isEssentiaContainer(drainStack.right)) {
|
||||
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
|
||||
this.host.getFluidInventory()
|
||||
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
|
||||
continue;
|
||||
}
|
||||
|
||||
// drop empty item
|
||||
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
|
||||
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
|
||||
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
|
||||
if (notInserted.getStackSize() % drainStack.left > 0) {
|
||||
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
|
||||
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
|
||||
this.dropItem(drainStack.right, 1);
|
||||
}
|
||||
}
|
||||
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
|
||||
} else if (drainStack != null) {
|
||||
if (slotIndex == -1) {
|
||||
out.stackSize = fluidContainer.stackSize;
|
||||
} else {
|
||||
out.stackSize = (int) (fluidContainer.stackSize
|
||||
- (aeFluidStack.getStackSize() / drainStack.left));
|
||||
}
|
||||
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
IAEFluidStack storedFluid = this.monitor.getStorageList().findPrecise(clientSelectedFluid);
|
||||
ItemStack out = targetStack.copy();
|
||||
out.stackSize = 1;
|
||||
if (AspectUtil.isEmptyEssentiaContainer(targetStack) && AspectUtil.isEssentiaGas(storedFluid)) {
|
||||
// add essentia to jars
|
||||
if (storedFluid.getStackSize() / AspectUtil.R <= 0) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
final IAEFluidStack toExtract = storedFluid.copy();
|
||||
MutablePair<Integer, ItemStack> fillStack = AspectUtil.fillEssentiaFromGas(out, toExtract.getFluidStack());
|
||||
if (fillStack == null || fillStack.right == null || fillStack.left <= 0) {
|
||||
return;
|
||||
}
|
||||
toExtract.setStackSize((long) fillStack.left * containersRequested);
|
||||
IAEFluidStack tmp = this.host.getFluidInventory()
|
||||
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
|
||||
if (tmp == null) {
|
||||
return;
|
||||
}
|
||||
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
|
||||
this.dropItem(fillStack.right);
|
||||
out.stackSize = fillStack.right.stackSize;
|
||||
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
|
||||
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
|
||||
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
|
||||
this.dropItem(
|
||||
AspectUtil.setAspectAmount(
|
||||
fillStack.right,
|
||||
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
|
||||
AspectUtil.getAspectFromGas(toExtract)),
|
||||
1);
|
||||
out.stackSize++;
|
||||
}
|
||||
}
|
||||
} else if (!AspectUtil.isEmptyEssentiaContainer(targetStack)) {
|
||||
// add essentia to ae network
|
||||
ItemStack containerStack = targetStack.copy();
|
||||
containerStack.stackSize = containersRequested;
|
||||
IAEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(containerStack);
|
||||
if (fluidStack == null) {
|
||||
return;
|
||||
}
|
||||
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<Integer, ItemStack> drainStack = AspectUtil
|
||||
.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
|
||||
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
|
||||
if (fluidStack.getStackSize() == notInserted.getStackSize()) {
|
||||
return;
|
||||
}
|
||||
aeFluidStack.decStackSize(notInserted.getStackSize());
|
||||
|
||||
if (drainStack.left > aeFluidStack.getStackSize() && AspectUtil.isEssentiaContainer(drainStack.right)) {
|
||||
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
|
||||
this.host.getFluidInventory()
|
||||
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
|
||||
return;
|
||||
}
|
||||
|
||||
// drop empty item
|
||||
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
|
||||
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
|
||||
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
|
||||
if (notInserted.getStackSize() % drainStack.left > 0) {
|
||||
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
|
||||
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
|
||||
this.dropItem(drainStack.right, 1);
|
||||
}
|
||||
}
|
||||
if (slotIndex == -1) out.stackSize = targetStack.stackSize - out.stackSize;
|
||||
} else if (drainStack != null) {
|
||||
if (slotIndex == -1) {
|
||||
out.stackSize = targetStack.stackSize;
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
|
||||
out.stackSize = (int) (targetStack.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
|
||||
}
|
||||
} else {
|
||||
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
|
||||
this.dropItem(drainStack.right, targetStack.stackSize); // drop empty item
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
|
||||
}
|
||||
} else {
|
||||
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
+235
-230
@@ -3,7 +3,6 @@ package com.glodblock.github.client.gui.container;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -18,7 +17,7 @@ import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketMEUpdateBuffer;
|
||||
@@ -44,7 +43,6 @@ import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.me.helpers.ChannelPowerSrc;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
|
||||
@@ -124,11 +122,8 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
|
||||
&& Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
|
||||
ItemStack tis = clickSlot.getStack();
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
tmp.put(0, ItemFluidDrop.getAeFluidStack(AEItemStack.create(tis)));
|
||||
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(index));
|
||||
}
|
||||
}
|
||||
return super.transferStackInSlot(p, idx);
|
||||
@@ -211,72 +206,26 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
* @param slotIndex The slot. If index == -1, the cursor held itemstack. Else, slotIndex indicates which slot was
|
||||
* shift clicked on.
|
||||
*/
|
||||
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player,
|
||||
int slotIndex) {
|
||||
int cursorItems;
|
||||
public void postChange(IAEFluidStack fluid, EntityPlayer player, int slotIndex, boolean shift) {
|
||||
ItemStack targetStack;
|
||||
if (slotIndex == -1) {
|
||||
cursorItems = player.inventory.getItemStack().stackSize;
|
||||
targetStack = player.inventory.getItemStack();
|
||||
} else {
|
||||
cursorItems = player.inventory.getStackInSlot(slotIndex).stackSize;
|
||||
targetStack = player.inventory.getStackInSlot(slotIndex);
|
||||
}
|
||||
for (IAEFluidStack fluid : change) {
|
||||
// The primary output itemstack
|
||||
if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) {
|
||||
// Situation 1.a: Empty fluid container, and nonnull slot
|
||||
extractFluid(fluid, fluidContainer, player, cursorItems);
|
||||
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
|
||||
// Situation 2.a: We are holding a non-empty container.
|
||||
insertFluid(fluidContainer, player, slotIndex, cursorItems);
|
||||
// End of situation 2.a
|
||||
}
|
||||
// No op (Any other situation)
|
||||
// The primary output itemstack
|
||||
if (Util.FluidUtil.isEmpty(targetStack) && fluid != null) {
|
||||
// Situation 1.a: Empty fluid container, and nonnull slot
|
||||
extractFluid(fluid, player, slotIndex, shift);
|
||||
} else if (!Util.FluidUtil.isEmpty(targetStack)) {
|
||||
// Situation 2.a: We are holding a non-empty container.
|
||||
insertFluid(player, slotIndex, shift);
|
||||
// End of situation 2.a
|
||||
}
|
||||
// No op (Any other situation)
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert fluid into the ME system
|
||||
*
|
||||
* @param canSend the fluidstack to insert
|
||||
* @param results a tuple of at least size 3 to indicate outputs (1), (2), (3). This will be mutated!
|
||||
* @param numTanks number of tanks involved in the operation
|
||||
* @param fluidInTank how much fluid is in the tank initially
|
||||
* @return the amount of fluid remaining in output (3)
|
||||
* @see #insertFluid(ItemStack, EntityPlayer, int, int)
|
||||
*/
|
||||
private int insertME(IAEFluidStack canSend, int[] results, int numTanks, int fluidInTank) {
|
||||
final IAEFluidStack notInserted = this.host.getFluidInventory()
|
||||
.injectItems(canSend, Actionable.MODULATE, this.getActionSource());
|
||||
|
||||
// Check if we need to handle partial insertion.
|
||||
if (notInserted != null && notInserted.getStackSize() > 0) {
|
||||
if (canSend.getStackSize() == notInserted.getStackSize()) {
|
||||
// No-op for when system is full
|
||||
results[REM_IDX] = numTanks;
|
||||
return fluidInTank;
|
||||
}
|
||||
// Populate result list with outputs (1), (2), (3).
|
||||
results[REM_IDX] = (int) (notInserted.getStackSize() / fluidInTank);
|
||||
results[ACT_IDX] = numTanks - results[REM_IDX];
|
||||
|
||||
// If there is remaining fluid, set partial.
|
||||
final int remainder = (int) (notInserted.getStackSize() % fluidInTank);
|
||||
if (remainder > 0) {
|
||||
results[PARTIAL_IDX] = 1;
|
||||
results[ACT_IDX]--;
|
||||
return remainder;
|
||||
} else {
|
||||
results[PARTIAL_IDX] = 0;
|
||||
}
|
||||
} else {
|
||||
// Full operation successful
|
||||
results[REM_IDX] = 0;
|
||||
results[ACT_IDX] = numTanks;
|
||||
results[PARTIAL_IDX] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The insert operation. For input, we have a filled container stack. For outputs, we have the following:
|
||||
* <ol>
|
||||
@@ -286,119 +235,153 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
* </ol>
|
||||
* In order above, the itemstack at `slotIndex` is transformed into the output.
|
||||
*/
|
||||
private void insertFluid(ItemStack fluidContainer, EntityPlayer player, int slotIndex, int heldContainers) {
|
||||
IAEFluidStack canSend;
|
||||
int fluidPerContainer;
|
||||
ItemStack partialStack = null;
|
||||
ItemStack emptyStack = null;
|
||||
int[] insertionResults = new int[3];
|
||||
private void insertFluid(EntityPlayer player, int slotIndex, boolean shift) {
|
||||
final ItemStack targetStack;
|
||||
if (slotIndex == -1) {
|
||||
targetStack = player.inventory.getItemStack();
|
||||
} else {
|
||||
targetStack = player.inventory.getStackInSlot(slotIndex);
|
||||
}
|
||||
final int containersRequestedToInsert = shift ? targetStack.stackSize : 1;
|
||||
|
||||
// 2 types of containers: IFluidContainerItem and FluidContainerRegistry
|
||||
// IFluidContainerItem - items are filled w/ volume (portable tanks)
|
||||
// FluidContainerRegistry - items are filled, or not (buckets)
|
||||
// The former is easy, the latter takes a bit more work.
|
||||
if (fluidContainer.getItem() instanceof IFluidContainerItem fcItem) {
|
||||
// Step 1: Find out how much fluid we can insert.
|
||||
canSend = AEFluidStack.create(fcItem.getFluid(fluidContainer));
|
||||
fluidPerContainer = (int) canSend.getStackSize();
|
||||
canSend.setStackSize((long) fluidPerContainer * fluidContainer.stackSize);
|
||||
|
||||
// Step 2: Find out how much fluid we can extract from the container. If this is null or 0, return.
|
||||
ItemStack test = fluidContainer.copy();
|
||||
// Step 1: Determine container characteristics and verify fluid to be extractable
|
||||
final int fluidPerContainer;
|
||||
final FluidStack fluidStackPerContainer;
|
||||
final boolean partialInsertSupported;
|
||||
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
|
||||
ItemStack test = targetStack.copy();
|
||||
test.stackSize = 1;
|
||||
FluidStack fluidStack = fcItem.drain(test, fluidPerContainer, false);
|
||||
if (fluidStack == null || fluidStack.amount == 0) {
|
||||
fluidStackPerContainer = fcItem.drain(test, Integer.MAX_VALUE, false);
|
||||
if (fluidStackPerContainer == null || fluidStackPerContainer.amount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 3: Find out how much fluid we can insert into the ME system
|
||||
int partialAmount = insertME(canSend, insertionResults, fluidContainer.stackSize, fluidPerContainer);
|
||||
|
||||
// Step 4: Separate the outputs into no drain (1), fully drained (2), and partially drained (3)
|
||||
// 4.1: Handle the partial stack
|
||||
if (insertionResults[PARTIAL_IDX] > 0) {
|
||||
partialStack = fluidContainer.copy();
|
||||
partialStack.stackSize = 1;
|
||||
fcItem.drain(partialStack, fluidPerContainer - partialAmount, true);
|
||||
}
|
||||
|
||||
// 4.2: Handle empty output
|
||||
if (insertionResults[ACT_IDX] > 0) {
|
||||
emptyStack = fluidContainer.copy();
|
||||
emptyStack.stackSize = 1;
|
||||
fcItem.drain(emptyStack, fluidPerContainer, true);
|
||||
emptyStack.stackSize = insertionResults[ACT_IDX];
|
||||
}
|
||||
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
|
||||
// Step 1: Find out how much fluid we can insert.
|
||||
canSend = AEFluidStack.create(FluidContainerRegistry.getFluidForFilledItem(fluidContainer));
|
||||
fluidPerContainer = (int) canSend.getStackSize();
|
||||
canSend.setStackSize((long) fluidPerContainer * fluidContainer.stackSize);
|
||||
// Step 2: Find out how much fluid we can extract from the container. If this is null or 0, return.
|
||||
ItemStack emptyTank = FluidContainerRegistry.drainFluidContainer(fluidContainer);
|
||||
fluidPerContainer = fluidStackPerContainer.amount;
|
||||
partialInsertSupported = true;
|
||||
} else if (FluidContainerRegistry.isContainer(targetStack)) {
|
||||
ItemStack emptyTank = FluidContainerRegistry.drainFluidContainer(targetStack);
|
||||
if (emptyTank == null) {
|
||||
return;
|
||||
}
|
||||
// Step 3: Find out how much fluid we can insert into the ME system
|
||||
int partialAmount = insertME(canSend, insertionResults, fluidContainer.stackSize, fluidPerContainer);
|
||||
|
||||
// Step 4: Separate the outputs into no drain (1), fully drained (2), and partially drained (3)
|
||||
// 4.1: Handle the partial stack
|
||||
if (partialAmount > 0) {
|
||||
// We now extract the extra amount from the ME system. Blame simulate not working :P
|
||||
int extract = FluidContainerRegistry.getContainerCapacity(fluidContainer) - partialAmount;
|
||||
if (extract > 0) {
|
||||
IAEFluidStack toExtract = canSend.copy().setStackSize(extract);
|
||||
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
|
||||
}
|
||||
insertionResults[PARTIAL_IDX] = 0;
|
||||
}
|
||||
|
||||
// 4.2: Handle empty output
|
||||
if (insertionResults[ACT_IDX] > 0) {
|
||||
emptyStack = FluidContainerRegistry.drainFluidContainer(fluidContainer);
|
||||
emptyStack.stackSize = insertionResults[ACT_IDX];
|
||||
}
|
||||
fluidStackPerContainer = FluidContainerRegistry.getFluidForFilledItem(targetStack);
|
||||
fluidPerContainer = fluidStackPerContainer.amount;
|
||||
partialInsertSupported = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2: determine network capacity
|
||||
final IAEFluidStack totalFluid = AEFluidStack.create(fluidStackPerContainer);
|
||||
totalFluid.setStackSize((long) fluidPerContainer * containersRequestedToInsert);
|
||||
|
||||
final IAEFluidStack notInsertable = this.host.getFluidInventory()
|
||||
.injectItems(totalFluid, Actionable.SIMULATE, this.getActionSource());
|
||||
|
||||
final long insertableFluid;
|
||||
if (notInsertable == null || notInsertable.getStackSize() == 0) {
|
||||
insertableFluid = totalFluid.getStackSize();
|
||||
} else {
|
||||
long insertable = totalFluid.getStackSize() - notInsertable.getStackSize();
|
||||
if (partialInsertSupported) {
|
||||
insertableFluid = insertable;
|
||||
} else {
|
||||
// avoid remainder
|
||||
insertableFluid = insertable - (insertable % fluidPerContainer);
|
||||
}
|
||||
}
|
||||
totalFluid.setStackSize(insertableFluid);
|
||||
|
||||
// Step 3: perform insert
|
||||
final long totalInserted;
|
||||
final IAEFluidStack notInserted = this.host.getFluidInventory()
|
||||
.injectItems(totalFluid, Actionable.MODULATE, this.getActionSource());
|
||||
if (notInserted != null && notInserted.getStackSize() > 0) {
|
||||
// User has a setup that causes discrepancy between simulation and modulation. Likely double storage bus.
|
||||
long total = totalFluid.getStackSize() - notInserted.getStackSize();
|
||||
if (partialInsertSupported) {
|
||||
totalInserted = total;
|
||||
} else {
|
||||
// We cant have partially filled containers -> user will receive a fluid packet as last resort
|
||||
long overflowAmount = fluidPerContainer - (total % fluidPerContainer);
|
||||
IAEFluidStack overflow = AEFluidStack.create(fluidStackPerContainer);
|
||||
overflow.setStackSize(overflowAmount);
|
||||
dropItem(ItemFluidPacket.newStack(overflow));
|
||||
totalInserted = total + overflowAmount;
|
||||
}
|
||||
} else {
|
||||
totalInserted = totalFluid.getStackSize();
|
||||
}
|
||||
|
||||
// Step 4: calculate outputs
|
||||
final int emptiedTanks = (int) (totalInserted / fluidPerContainer);
|
||||
final int partialDrain = (int) (totalInserted % fluidPerContainer);
|
||||
final int partialTanks = partialDrain > 0 && partialInsertSupported ? 1 : 0;
|
||||
final int usedTanks = emptiedTanks + partialTanks;
|
||||
final int untouchedTanks = targetStack.stackSize - usedTanks;
|
||||
|
||||
final ItemStack emptiedTanksStack;
|
||||
final ItemStack partialTanksStack;
|
||||
|
||||
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
|
||||
if (emptiedTanks > 0) {
|
||||
emptiedTanksStack = targetStack.copy();
|
||||
emptiedTanksStack.stackSize = 1;
|
||||
fcItem.drain(emptiedTanksStack, fluidPerContainer, true);
|
||||
emptiedTanksStack.stackSize = emptiedTanks;
|
||||
} else {
|
||||
emptiedTanksStack = null;
|
||||
}
|
||||
if (partialTanks > 0) {
|
||||
partialTanksStack = targetStack.copy();
|
||||
partialTanksStack.stackSize = 1;
|
||||
fcItem.drain(partialTanksStack, partialDrain, true);
|
||||
} else {
|
||||
partialTanksStack = null;
|
||||
}
|
||||
} else {
|
||||
if (emptiedTanks > 0) {
|
||||
emptiedTanksStack = FluidContainerRegistry.drainFluidContainer(targetStack);
|
||||
emptiedTanksStack.stackSize = emptiedTanks;
|
||||
} else {
|
||||
emptiedTanksStack = null;
|
||||
}
|
||||
// Not possible > see Step 2 and Step 3
|
||||
partialTanksStack = null;
|
||||
}
|
||||
|
||||
// Done. Put the output in the inventory or ground, and update stack size.
|
||||
boolean shouldSendStack = true;
|
||||
int emptyTanks = insertionResults[ACT_IDX];
|
||||
int extraTanks = heldContainers - emptyTanks - insertionResults[PARTIAL_IDX];
|
||||
if (slotIndex == -1) {
|
||||
// Item is in mouse hand
|
||||
if (extraTanks > 0) {
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
stack.stackSize = extraTanks;
|
||||
adjustStack(stack);
|
||||
dropItem(emptyStack);
|
||||
dropItem(partialStack);
|
||||
} else if (emptyTanks != 0) {
|
||||
adjustStack(emptyStack);
|
||||
player.inventory.setItemStack(emptyStack);
|
||||
dropItem(partialStack);
|
||||
} else if (partialStack != null) {
|
||||
player.inventory.setItemStack(partialStack);
|
||||
if (untouchedTanks > 0) {
|
||||
targetStack.stackSize = untouchedTanks;
|
||||
adjustStack(targetStack);
|
||||
dropItem(emptiedTanksStack);
|
||||
dropItem(partialTanksStack);
|
||||
} else if (emptiedTanksStack != null) {
|
||||
adjustStack(emptiedTanksStack);
|
||||
player.inventory.setItemStack(emptiedTanksStack);
|
||||
dropItem(partialTanksStack);
|
||||
} else if (partialTanksStack != null) {
|
||||
player.inventory.setItemStack(partialTanksStack);
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
shouldSendStack = false;
|
||||
}
|
||||
} else {
|
||||
// Shift clicked in
|
||||
ItemStack stack = player.inventory.getStackInSlot(slotIndex);
|
||||
if (extraTanks > 0) {
|
||||
stack.stackSize = extraTanks;
|
||||
adjustStack(stack);
|
||||
dropItem(emptyStack);
|
||||
dropItem(partialStack);
|
||||
} else if (emptyTanks != 0) {
|
||||
adjustStack(emptyStack);
|
||||
player.inventory.setInventorySlotContents(slotIndex, emptyStack);
|
||||
dropItem(partialStack);
|
||||
} else if (partialStack != null) {
|
||||
player.inventory.setInventorySlotContents(slotIndex, partialStack);
|
||||
if (untouchedTanks > 0) {
|
||||
targetStack.stackSize = untouchedTanks;
|
||||
adjustStack(targetStack);
|
||||
dropItem(emptiedTanksStack);
|
||||
dropItem(partialTanksStack);
|
||||
} else if (emptiedTanksStack != null) {
|
||||
adjustStack(emptiedTanksStack);
|
||||
player.inventory.setInventorySlotContents(slotIndex, emptiedTanksStack);
|
||||
dropItem(partialTanksStack);
|
||||
} else if (partialTanksStack != null) {
|
||||
player.inventory.setInventorySlotContents(slotIndex, partialTanksStack);
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
shouldSendStack = false;
|
||||
@@ -422,97 +405,119 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
* </ol>
|
||||
* In order above, the itemstack at `slotIndex` is transformed into the output.
|
||||
*/
|
||||
private void extractFluid(IAEFluidStack fluid, ItemStack fluidContainer, EntityPlayer player, int heldContainers) {
|
||||
// Step 1: Check if fluid can actually get filled into the fluidContainer
|
||||
if (fluidContainer.getItem() instanceof IFluidContainerItem fcItem) {
|
||||
ItemStack testStack = fluidContainer.copy();
|
||||
private void extractFluid(IAEFluidStack clientRequestedFluid, EntityPlayer player, int slotIndex, boolean shift) {
|
||||
if (slotIndex != -1) {
|
||||
// shift-click from inventory cant fill fluids
|
||||
return;
|
||||
}
|
||||
final ItemStack targetStack = player.inventory.getItemStack();
|
||||
final int containersRequestedToExtract = shift ? targetStack.stackSize : 1;
|
||||
|
||||
final FluidStack clientRequestedFluidStack = clientRequestedFluid.getFluidStack();
|
||||
clientRequestedFluidStack.amount = Integer.MAX_VALUE;
|
||||
|
||||
// Step 1: Determine container characteristics and verify fluid to be insertable
|
||||
final int fluidPerContainer;
|
||||
final boolean partialInsertSupported;
|
||||
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
|
||||
ItemStack testStack = targetStack.copy();
|
||||
testStack.stackSize = 1;
|
||||
int test = fcItem.fill(testStack, fluid.getFluidStack(), false);
|
||||
if (test == 0) {
|
||||
return;
|
||||
}
|
||||
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
|
||||
ItemStack test = FluidContainerRegistry.fillFluidContainer(fluid.getFluidStack(), fluidContainer);
|
||||
if (test == null) {
|
||||
fluidPerContainer = fcItem.fill(testStack, clientRequestedFluidStack, false);
|
||||
if (fluidPerContainer == 0) {
|
||||
return;
|
||||
}
|
||||
partialInsertSupported = true;
|
||||
} else if (FluidContainerRegistry.isContainer(targetStack)) {
|
||||
fluidPerContainer = FluidContainerRegistry.getContainerCapacity(clientRequestedFluidStack, targetStack);
|
||||
partialInsertSupported = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
IAEFluidStack storedFluid = this.monitor.getStorageList().findPrecise(fluid);
|
||||
if (storedFluid == null || storedFluid.getStackSize() <= 0) return;
|
||||
int capacity = Util.FluidUtil.getCapacity(fluidContainer, storedFluid.getFluid());
|
||||
if (capacity == 0) return;
|
||||
// The fluidstack that we will try to extract from the system.
|
||||
final IAEFluidStack canExtract = storedFluid.copy();
|
||||
// Maximum amount of fluid we can extract with the given container(s). Guarantees that we won't
|
||||
// run into issues w/ remainder fluid later.
|
||||
canExtract.setStackSize((long) capacity * fluidContainer.stackSize);
|
||||
IAEFluidStack actualExtract = this.host.getFluidInventory()
|
||||
.extractItems(canExtract, Actionable.MODULATE, this.getActionSource());
|
||||
if (actualExtract == null) return;
|
||||
// Calculate the number of full fluid containers we extracted
|
||||
long toExtract = actualExtract.getStackSize();
|
||||
int filledTanks = (int) (toExtract / capacity);
|
||||
int remainder = (int) (toExtract % capacity);
|
||||
int emptyTanks = heldContainers - filledTanks;
|
||||
// Fill the filled tanks
|
||||
ItemStack filledStack = fluidContainer.copy();
|
||||
filledStack.stackSize = 1;
|
||||
if (filledTanks > 0) {
|
||||
if (filledStack.getItem() instanceof IFluidContainerItem) {
|
||||
int amt = ((IFluidContainerItem) filledStack.getItem())
|
||||
.fill(filledStack, actualExtract.getFluidStack(), true);
|
||||
assert amt == capacity;
|
||||
} else {
|
||||
// Should not be NPE since we affirmed that we have enough capacity.
|
||||
filledStack = FluidContainerRegistry.fillFluidContainer(actualExtract.getFluidStack(), filledStack);
|
||||
assert capacity == FluidContainerRegistry.getContainerCapacity(filledStack);
|
||||
}
|
||||
filledStack.stackSize = filledTanks;
|
||||
} else {
|
||||
filledStack.stackSize = 0;
|
||||
|
||||
// Step 2: determine fluid in network
|
||||
final IAEFluidStack totalRequestedFluid = clientRequestedFluid.copy();
|
||||
totalRequestedFluid.setStackSize((long) fluidPerContainer * containersRequestedToExtract);
|
||||
|
||||
final IAEFluidStack availableFluid = this.host.getFluidInventory()
|
||||
.extractItems(totalRequestedFluid, Actionable.SIMULATE, this.getActionSource());
|
||||
if (availableFluid == null || availableFluid.getStackSize() == 0) {
|
||||
return;
|
||||
}
|
||||
// Calculate the remaining fluid to extract, if any
|
||||
ItemStack partialStack = fluidContainer.copy();
|
||||
if (remainder > 0) {
|
||||
actualExtract.setStackSize(remainder);
|
||||
partialStack.stackSize = 1;
|
||||
if (partialStack.getItem() instanceof IFluidContainerItem) {
|
||||
int amt = ((IFluidContainerItem) partialStack.getItem())
|
||||
.fill(partialStack, actualExtract.getFluidStack(), true);
|
||||
assert amt == remainder;
|
||||
emptyTanks--;
|
||||
|
||||
if (availableFluid.getStackSize() != totalRequestedFluid.getStackSize() && !partialInsertSupported) {
|
||||
availableFluid.decStackSize(availableFluid.getStackSize() % fluidPerContainer);
|
||||
}
|
||||
|
||||
// Step 3: perform extract
|
||||
final IAEFluidStack extracted = this.host.getFluidInventory()
|
||||
.extractItems(availableFluid, Actionable.MODULATE, this.getActionSource());
|
||||
final long totalExtracted = extracted != null ? extracted.getStackSize() : 0;
|
||||
|
||||
// Step 4: calculate outputs
|
||||
final int filledTanks = (int) (totalExtracted / fluidPerContainer);
|
||||
final int partialFill = (int) (totalExtracted % fluidPerContainer);
|
||||
final int partialTanks = partialFill > 0 && partialInsertSupported ? 1 : 0;
|
||||
final int usedTanks = filledTanks + partialTanks;
|
||||
final int untouchedTanks = targetStack.stackSize - usedTanks;
|
||||
|
||||
final ItemStack filledTanksStack;
|
||||
final ItemStack partialTanksStack;
|
||||
|
||||
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
|
||||
if (filledTanks > 0) {
|
||||
filledTanksStack = targetStack.copy();
|
||||
filledTanksStack.stackSize = 1;
|
||||
FluidStack toInsert = extracted.getFluidStack().copy();
|
||||
toInsert.amount = fluidPerContainer;
|
||||
fcItem.fill(filledTanksStack, toInsert, true);
|
||||
filledTanksStack.stackSize = filledTanks;
|
||||
} else {
|
||||
ItemStack dummy = FluidContainerRegistry
|
||||
.fillFluidContainer(actualExtract.getFluidStack(), partialStack);
|
||||
if (dummy == null) {
|
||||
// Failed to fill partial...
|
||||
partialStack.stackSize = 0;
|
||||
} else {
|
||||
partialStack = dummy;
|
||||
emptyTanks--;
|
||||
}
|
||||
filledTanksStack = null;
|
||||
}
|
||||
if (partialTanks > 0) {
|
||||
partialTanksStack = targetStack.copy();
|
||||
partialTanksStack.stackSize = 1;
|
||||
FluidStack toInsert = extracted.getFluidStack().copy();
|
||||
toInsert.amount = partialFill;
|
||||
fcItem.fill(partialTanksStack, toInsert, true);
|
||||
} else {
|
||||
partialTanksStack = null;
|
||||
}
|
||||
} else {
|
||||
partialStack.stackSize = 0;
|
||||
if (filledTanks > 0) {
|
||||
FluidStack toInsert = extracted.getFluidStack().copy();
|
||||
toInsert.amount = fluidPerContainer;
|
||||
filledTanksStack = FluidContainerRegistry.fillFluidContainer(toInsert, targetStack);
|
||||
filledTanksStack.stackSize = filledTanks;
|
||||
} else {
|
||||
filledTanksStack = null;
|
||||
}
|
||||
if (partialFill > 0) {
|
||||
// User has a setup that causes discrepancy between simulation and modulation. Likely double storage
|
||||
// bus.
|
||||
// We cant have partially filled containers -> user will receive a fluid packet as last resort
|
||||
IAEFluidStack overflow = extracted.copy();
|
||||
overflow.setStackSize(partialFill);
|
||||
dropItem(ItemFluidPacket.newStack(overflow));
|
||||
}
|
||||
partialTanksStack = null;
|
||||
}
|
||||
|
||||
// Done. Put the output in the inventory or ground, and update stack size.
|
||||
// We can assume slotIndex == -1, since we don't actually allow extraction via shift click.
|
||||
boolean shouldSendStack = true;
|
||||
if (emptyTanks > 0) {
|
||||
if (untouchedTanks > 0) {
|
||||
ItemStack emptyStack = player.inventory.getItemStack();
|
||||
emptyStack.stackSize = emptyTanks;
|
||||
emptyStack.stackSize = untouchedTanks;
|
||||
adjustStack(emptyStack);
|
||||
dropItem(filledStack);
|
||||
dropItem(partialStack);
|
||||
} else if (filledStack.stackSize != 0) {
|
||||
adjustStack(filledStack);
|
||||
player.inventory.setItemStack(filledStack);
|
||||
dropItem(partialStack);
|
||||
} else if (partialStack.stackSize != 0) {
|
||||
player.inventory.setItemStack(partialStack);
|
||||
dropItem(filledTanksStack);
|
||||
dropItem(partialTanksStack);
|
||||
} else if (filledTanksStack != null) {
|
||||
adjustStack(filledTanksStack);
|
||||
player.inventory.setItemStack(filledTanksStack);
|
||||
dropItem(partialTanksStack);
|
||||
} else if (partialTanksStack != null) {
|
||||
player.inventory.setItemStack(partialTanksStack);
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
shouldSendStack = false;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class EssentiaRepo extends FluidRepo {
|
||||
|
||||
@Override
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
if (needUpdateView()) this.view.clear();
|
||||
this.dsp.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
@@ -58,7 +58,7 @@ public class EssentiaRepo extends FluidRepo {
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack is : this.list) {
|
||||
for (IAEItemStack is : needUpdateView() ? this.list : this.cache) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
@@ -87,26 +87,30 @@ public class EssentiaRepo extends FluidRepo {
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
if (needUpdateView()) {
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
this.cache.clear();
|
||||
}
|
||||
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
this.lastSearchString = this.searchString;
|
||||
Iterator<IAEItemStack> it1 = this.view.iterator();
|
||||
while (it1.hasNext()) {
|
||||
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(it1.next());
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
package com.glodblock.github.client.me;
|
||||
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@@ -45,12 +47,14 @@ public class FluidRepo implements IDisplayRepo {
|
||||
protected final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
protected final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
protected final ArrayList<ItemStack> dsp = new ArrayList<>();
|
||||
protected final ArrayList<IAEItemStack> cache = new ArrayList<>();
|
||||
protected final IScrollSource src;
|
||||
protected final ISortSource sortSrc;
|
||||
|
||||
protected int rowSize = 9;
|
||||
|
||||
protected String searchString = "";
|
||||
protected String lastSearchString = "";
|
||||
protected IPartitionList<IAEItemStack> myPartitionList;
|
||||
private String NEIWord = null;
|
||||
private boolean hasPower;
|
||||
@@ -86,11 +90,19 @@ public class FluidRepo implements IDisplayRepo {
|
||||
if (st != null) {
|
||||
st.reset();
|
||||
st.add(is);
|
||||
if (isShiftKeyDown() && this.view.contains(st)) {
|
||||
this.view.get(this.view.indexOf(st)).setStackSize(st.getStackSize());
|
||||
}
|
||||
} else {
|
||||
if (isShiftKeyDown()) this.cache.add(is);
|
||||
this.list.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean needUpdateView() {
|
||||
return !isShiftKeyDown() || !this.lastSearchString.equals(this.searchString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViewCell(final ItemStack[] list) {
|
||||
this.myPartitionList = ItemViewCell.createFilter(list);
|
||||
@@ -99,7 +111,7 @@ public class FluidRepo implements IDisplayRepo {
|
||||
|
||||
@Override
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
if (needUpdateView()) this.view.clear();
|
||||
this.dsp.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
@@ -130,7 +142,7 @@ public class FluidRepo implements IDisplayRepo {
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack is : this.list) {
|
||||
for (IAEItemStack is : needUpdateView() ? this.list : this.cache) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
@@ -167,26 +179,30 @@ public class FluidRepo implements IDisplayRepo {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (needUpdateView()) {
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
final Enum<?> SortBy = this.sortSrc.getSortBy();
|
||||
final Enum<?> SortDir = this.sortSrc.getSortDir();
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
} else {
|
||||
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
this.cache.clear();
|
||||
}
|
||||
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
this.lastSearchString = this.searchString;
|
||||
}
|
||||
|
||||
protected void updateNEI(final String filter) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.common.block;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
@@ -61,6 +62,14 @@ public class BlockFluidInterface extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor) {
|
||||
TileFluidInterface tile = this.getTileEntity(worldIn, x, y, z);
|
||||
if (tile != null) {
|
||||
tile.getInterfaceDuality().updateRedstoneState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasCustomRotation() {
|
||||
return true;
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
|
||||
if (cellInventory != null) {
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
@@ -114,7 +114,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ GuiText.BytesUsed.getLocal());
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,7 +83,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
if (cellInventory != null) {
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
@@ -93,7 +94,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ GuiText.BytesUsed.getLocal());
|
||||
lines.add(
|
||||
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
|
||||
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ " "
|
||||
+ GuiText.Of.getLocal()
|
||||
|
||||
@@ -24,27 +24,19 @@ import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.DualityFluidInterface;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -52,7 +44,6 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this);
|
||||
|
||||
@@ -201,35 +192,9 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
return getInterfaceDuality().getInstalledUpgrades(u);
|
||||
}
|
||||
|
||||
private IMEMonitor<IAEFluidStack> getFluidGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnergyGrid getEnergyGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().getCache(IEnergyGrid.class);
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
|
||||
int ori = resource.amount;
|
||||
IAEFluidStack remove;
|
||||
if (doFill) {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
|
||||
} else {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
|
||||
}
|
||||
return remove == null ? ori : (int) (ori - remove.getStackSize());
|
||||
return fluidDuality.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,12 +209,12 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return fluidDuality.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return fluidDuality.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,14 +38,11 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
@@ -68,7 +65,6 @@ import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
|
||||
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
|
||||
@@ -108,7 +104,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
};
|
||||
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
|
||||
public PartFluidP2PInterface(ItemStack is) {
|
||||
super(is);
|
||||
@@ -132,6 +127,11 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
dualityFluid.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
this.duality.updateRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
AppEngInternalInventory patterns = (AppEngInternalInventory) duality.getPatterns();
|
||||
@@ -350,35 +350,9 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
return true;
|
||||
}
|
||||
|
||||
private IMEMonitor<IAEFluidStack> getFluidGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnergyGrid getEnergyGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().getCache(IEnergyGrid.class);
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
|
||||
int ori = resource.amount;
|
||||
IAEFluidStack remove;
|
||||
if (doFill) {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
|
||||
} else {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
|
||||
}
|
||||
return remove == null ? ori : (int) (ori - remove.getStackSize());
|
||||
return dualityFluid.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -393,12 +367,12 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return dualityFluid.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return dualityFluid.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -530,6 +504,54 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay() {
|
||||
return IInterfaceHost.super.shouldDisplay() && !isOutput();
|
||||
return IInterfaceHost.super.shouldDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getPatterns() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.getPatterns();
|
||||
}
|
||||
return IInterfaceHost.super.getPatterns();
|
||||
}
|
||||
return IInterfaceHost.super.getPatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int rows() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.rows();
|
||||
}
|
||||
return IInterfaceHost.super.rows();
|
||||
}
|
||||
return IInterfaceHost.super.rows();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int rowSize() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.rowSize();
|
||||
}
|
||||
return IInterfaceHost.super.rowSize();
|
||||
}
|
||||
return IInterfaceHost.super.rowSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (isOutput()) {
|
||||
PartFluidP2PInterface input = getInput();
|
||||
if (input != null) {
|
||||
return input.getName();
|
||||
}
|
||||
return IInterfaceHost.super.getName();
|
||||
}
|
||||
return IInterfaceHost.super.getName();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.ICellCacheRegistry;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
@@ -19,7 +20,8 @@ import appeng.me.storage.MEPassThrough;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack> implements IFluidCellInventoryHandler {
|
||||
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
|
||||
implements IFluidCellInventoryHandler, ICellCacheRegistry {
|
||||
|
||||
protected FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
|
||||
super(c, StorageChannel.FLUIDS);
|
||||
@@ -95,4 +97,54 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGetInv() {
|
||||
IFluidCellInventory cellInv = this.getCellInv();
|
||||
if (cellInv instanceof CreativeFluidCellInventory) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalBytes() {
|
||||
return this.getCellInv().getTotalBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeBytes() {
|
||||
return this.getCellInv().getFreeBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedBytes() {
|
||||
return this.getCellInv().getUsedBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalTypes() {
|
||||
return this.getCellInv().getTotalFluidTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFreeTypes() {
|
||||
return this.getCellInv().getRemainingFluidTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUsedTypes() {
|
||||
return this.getCellInv().getStoredFluidTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellStatus() {
|
||||
return this.getStatusForCell();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TYPE getCellType() {
|
||||
return TYPE.FLUID;
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return true;
|
||||
return fluidDuality.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,6 +60,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
public static final int REQ_COUNT = 5;
|
||||
public final InventoryRequest requests = new InventoryRequest(this);
|
||||
private int firstRequest = 0;
|
||||
private final BaseActionSource source;
|
||||
private final IInventory inv = new AeItemStackHandler(requests.requestStacks);
|
||||
private boolean isPowered = false;
|
||||
@@ -139,7 +140,17 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
final ICraftingGrid craftingGrid = getProxy().getCrafting();
|
||||
final IGrid grid = getProxy().getGrid();
|
||||
final IItemList<IAEItemStack> inv = getProxy().getStorage().getItemInventory().getStorageList();
|
||||
for (int i = 0; i < REQ_COUNT; i++) {
|
||||
|
||||
// Find a request that we can submit to the network.
|
||||
// If there is none, find the next request we can begin calculating.
|
||||
ICraftingJob jobToSubmit = null;
|
||||
int jobToSubmitIdx = -1;
|
||||
IAEItemStack itemToBegin = null;
|
||||
int itemToBeginIdx = -1;
|
||||
|
||||
for (int j = 0; j < REQ_COUNT; ++j) {
|
||||
int i = (firstRequest + j) % REQ_COUNT;
|
||||
|
||||
long quantity = requests.getQuantity(i);
|
||||
long batchSize = requests.getBatchSize(i);
|
||||
boolean isEnable = requests.isEnable(i);
|
||||
@@ -159,28 +170,18 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
// do crafting
|
||||
Future<ICraftingJob> jobTask = requests.getJob(i);
|
||||
if (jobTask == null) {
|
||||
requests.updateJob(
|
||||
i,
|
||||
craftingGrid.beginCraftingJob(getWorldObj(), grid, source, craftItem, null));
|
||||
requests.updateState(i, State.Craft);
|
||||
|
||||
// calculate only one job per tick request
|
||||
return TickRateModulation.SAME;
|
||||
if (itemToBegin == null) {
|
||||
itemToBegin = craftItem;
|
||||
itemToBeginIdx = i;
|
||||
}
|
||||
} else if (jobTask.isDone()) {
|
||||
requests.updateState(i, State.Craft);
|
||||
try {
|
||||
ICraftingJob job = jobTask.get();
|
||||
if (job != null) {
|
||||
ICraftingLink link = craftingGrid.submitJob(job, this, null, false, source);
|
||||
requests.updateJob(i, null);
|
||||
if (link != null) {
|
||||
requests.updateState(i, State.Craft);
|
||||
requests.updateLink(i, link);
|
||||
|
||||
// submit only one job per tick request
|
||||
return TickRateModulation.SAME;
|
||||
} else {
|
||||
requests.updateState(i, State.Error);
|
||||
if (jobToSubmit == null) {
|
||||
jobToSubmit = job;
|
||||
jobToSubmitIdx = i;
|
||||
}
|
||||
} else {
|
||||
requests.updateState(i, State.Error);
|
||||
@@ -191,6 +192,31 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jobToSubmit != null) {
|
||||
// Finished calculating a request, try to submit it.
|
||||
ICraftingLink link = craftingGrid.submitJob(jobToSubmit, this, null, false, source);
|
||||
requests.updateJob(jobToSubmitIdx, null);
|
||||
if (link != null) {
|
||||
requests.updateState(jobToSubmitIdx, State.Craft);
|
||||
requests.updateLink(jobToSubmitIdx, link);
|
||||
} else {
|
||||
requests.updateState(jobToSubmitIdx, State.Error);
|
||||
}
|
||||
} else if (itemToBegin != null) {
|
||||
// No jobs to submit, start calculating some item.
|
||||
requests.updateJob(
|
||||
itemToBeginIdx,
|
||||
craftingGrid.beginCraftingJob(getWorldObj(), grid, source, itemToBegin, null));
|
||||
requests.updateState(itemToBeginIdx, State.Craft);
|
||||
|
||||
// Try the next item next time.
|
||||
firstRequest = (firstRequest + 1) % REQ_COUNT;
|
||||
} else {
|
||||
// No work to be done:
|
||||
// Every item is at desired quantity, being crafted, or has no patterns.
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
} catch (final GridAccessException ignore) {
|
||||
|
||||
}
|
||||
@@ -348,7 +374,8 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
|
||||
private ItemStack removeRecursion(ItemStack itemStack) {
|
||||
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
|
||||
if (itemStack != null && itemStack.hasTagCompound()
|
||||
&& itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
|
||||
return removeRecursion(loadItemStackFromTag(itemStack));
|
||||
}
|
||||
return itemStack;
|
||||
|
||||
+1
-5
@@ -10,11 +10,9 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import li.cil.oc.api.driver.EnvironmentProvider;
|
||||
import li.cil.oc.api.driver.NamedBlock;
|
||||
@@ -124,9 +122,7 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity {
|
||||
if (dbStack == null) {
|
||||
throw new IllegalArgumentException("Invalid slot");
|
||||
}
|
||||
dbStack.stackSize = 1;
|
||||
((AeItemStackHandler) tileEntity.getInventory()).getAeInventory()
|
||||
.setStack(slot, AEItemStack.create(dbStack));
|
||||
tileEntity.requests.updateStack(slot, dbStack);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Not a database");
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.glodblock.github.network.SPacketMEFluidInvUpdate;
|
||||
import com.glodblock.github.network.SPacketMEItemInvUpdate;
|
||||
import com.glodblock.github.network.SPacketSetItemAmount;
|
||||
import com.glodblock.github.network.SPacketStringUpdate;
|
||||
import com.glodblock.github.network.SPacketSwitchBack;
|
||||
import com.glodblock.github.network.wrapper.FCNetworkWrapper;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -66,6 +67,7 @@ public class ChannelLoader implements Runnable {
|
||||
netHandler.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
|
||||
netHandler.registerMessage(new CPacketRenamer.Handler(), CPacketRenamer.class, id++, Side.SERVER);
|
||||
netHandler.registerMessage(new SPacketStringUpdate.Handler(), SPacketStringUpdate.class, id++, Side.CLIENT);
|
||||
netHandler.registerMessage(new SPacketSwitchBack.Handler(), SPacketSwitchBack.class, id++, Side.CLIENT);
|
||||
netHandler.registerMessage(
|
||||
new SPacketLevelTerminalUpdate.Handler(),
|
||||
SPacketLevelTerminalUpdate.class,
|
||||
|
||||
@@ -47,6 +47,8 @@ import com.glodblock.github.util.NameConst;
|
||||
|
||||
public class ItemAndBlockHolder {
|
||||
|
||||
public static void init() {}
|
||||
|
||||
public static BlockCertusQuartzTank CERTUS_QUARTZ_TANK = new BlockCertusQuartzTank().register();
|
||||
public static BlockFluidAutoFiller FLUID_AUTO_FILLER = new BlockFluidAutoFiller().register();
|
||||
public static BlockFluidDiscretizer DISCRETIZER = new BlockFluidDiscretizer().register();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.nei.recipes;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.glodblock.github.nei.recipes.extractor.AvaritiaRecipeExtractor;
|
||||
import com.glodblock.github.nei.recipes.extractor.EnderIORecipeExtractor;
|
||||
import com.glodblock.github.nei.recipes.extractor.ForestryRecipeExtractor;
|
||||
@@ -19,8 +21,6 @@ import forestry.factory.recipes.nei.NEIHandlerMoistener;
|
||||
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
|
||||
import forestry.factory.recipes.nei.NEIHandlerStill;
|
||||
import gregapi.recipes.Recipe;
|
||||
import gregtech.api.util.GTPP_Recipe;
|
||||
import gregtech.api.util.GT_Recipe;
|
||||
|
||||
public class DefaultExtractorLoader implements Runnable {
|
||||
|
||||
@@ -32,12 +32,19 @@ public class DefaultExtractorLoader implements Runnable {
|
||||
FluidRecipe.addRecipeMap("crafting2x2", new VanillaRecipeExtractor(true));
|
||||
|
||||
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")));
|
||||
try {
|
||||
Class<?> recipeMapClazz = Class.forName("gregtech.api.util.GT_Recipe$GT_Recipe_Map");
|
||||
Collection<?> sMappings = (Collection<?>) recipeMapClazz.getDeclaredField("sMappings").get(null);
|
||||
for (Object tMap : sMappings) {
|
||||
String mNEIName = (String) recipeMapClazz.getDeclaredField("mNEIName").get(tMap);
|
||||
FluidRecipe.addRecipeMap(
|
||||
mNEIName,
|
||||
new GregTech5RecipeExtractor(
|
||||
mNEIName.equals("gt.recipe.scanner")
|
||||
|| mNEIName.equals("gt.recipe.fakeAssemblylineProcess")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +54,21 @@ public class DefaultExtractorLoader implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (ModAndClassUtil.GTPP) {
|
||||
for (GTPP_Recipe.GTPP_Recipe_Map_Internal gtppMap : GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx) {
|
||||
if (gtppMap.mNEIAllowed) {
|
||||
FluidRecipe.addRecipeMap(gtppMap.mNEIName, new GTPPRecipeExtractor());
|
||||
if (ModAndClassUtil.GTPP && !ModAndClassUtil.GT5NH) {
|
||||
try {
|
||||
Class<?> gtRecipeMapClazz = Class.forName("gregtech.api.util.GT_Recipe$GT_Recipe_Map");
|
||||
Class<?> gtppRecipeMapClazz = Class.forName("gregtech.api.util.GTPP_Recipe$GTPP_Recipe_Map_Internal");
|
||||
Collection<?> sMappingsEx = (Collection<?>) gtppRecipeMapClazz.getDeclaredField("sMappingsEx")
|
||||
.get(null);
|
||||
for (Object gtppMap : sMappingsEx) {
|
||||
boolean mNEIAllowed = gtRecipeMapClazz.getDeclaredField("mNEIAllowed").getBoolean(gtppMap);
|
||||
if (mNEIAllowed) {
|
||||
String mNEIName = (String) gtRecipeMapClazz.getDeclaredField("mNEIName").get(gtppMap);
|
||||
FluidRecipe.addRecipeMap(mNEIName, new GTPPRecipeExtractor());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
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;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -21,37 +16,42 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class CPacketFluidUpdate implements IMessage {
|
||||
|
||||
private Map<Integer, IAEFluidStack> list;
|
||||
private ItemStack itemStack;
|
||||
private IAEFluidStack fluid;
|
||||
private boolean shift;
|
||||
private int slotIndex;
|
||||
|
||||
public CPacketFluidUpdate() {}
|
||||
|
||||
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack) {
|
||||
this.list = data;
|
||||
this.itemStack = itemStack;
|
||||
this.slotIndex = -1;
|
||||
/**
|
||||
* Used by transferStackInSlot. No clicked fluid, always shift.
|
||||
*/
|
||||
public CPacketFluidUpdate(int slotIndex) {
|
||||
this(null, slotIndex, true);
|
||||
}
|
||||
|
||||
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data) {
|
||||
this.list = data;
|
||||
/**
|
||||
* Used by handleMouseClick. Always uses mouse stack.
|
||||
*/
|
||||
public CPacketFluidUpdate(IAEFluidStack fluid, boolean shift) {
|
||||
this(fluid, -1, shift);
|
||||
}
|
||||
|
||||
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack, int slotIndex) {
|
||||
this.list = data;
|
||||
this.itemStack = itemStack;
|
||||
private CPacketFluidUpdate(IAEFluidStack fluid, int slotIndex, boolean shift) {
|
||||
this.fluid = fluid;
|
||||
this.slotIndex = slotIndex;
|
||||
this.shift = shift;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.list = new HashMap<>();
|
||||
try {
|
||||
Util.readFluidMapFromBuf(this.list, buf);
|
||||
if (buf.readBoolean()) {
|
||||
this.itemStack = AEItemStack.loadItemStackFromPacket(buf).getItemStack();
|
||||
this.slotIndex = buf.readInt();
|
||||
this.fluid = AEFluidStack.loadFluidStackFromPacket(buf);
|
||||
} else {
|
||||
this.fluid = null;
|
||||
}
|
||||
this.slotIndex = buf.readInt();
|
||||
this.shift = buf.readBoolean();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -60,14 +60,14 @@ public class CPacketFluidUpdate implements IMessage {
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
try {
|
||||
Util.writeFluidMapToBuf(this.list, buf);
|
||||
if (this.itemStack != null) {
|
||||
buf.writeBoolean(true);
|
||||
AEItemStack.create(itemStack).writeToPacket(buf);
|
||||
buf.writeInt(this.slotIndex);
|
||||
} else {
|
||||
if (fluid == null) {
|
||||
buf.writeBoolean(false);
|
||||
} else {
|
||||
buf.writeBoolean(true);
|
||||
fluid.writeToPacket(buf);
|
||||
}
|
||||
buf.writeInt(this.slotIndex);
|
||||
buf.writeBoolean(this.shift);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -80,12 +80,7 @@ public class CPacketFluidUpdate implements IMessage {
|
||||
Container container = ctx.getServerHandler().playerEntity.openContainer;
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (container instanceof ContainerFluidMonitor) {
|
||||
ItemStack item = player.inventory.getItemStack();
|
||||
((ContainerFluidMonitor) container).postChange(
|
||||
new ArrayList<>(message.list.values()),
|
||||
message.itemStack == null ? item : message.itemStack,
|
||||
player,
|
||||
message.slotIndex);
|
||||
((ContainerFluidMonitor) container).postChange(message.fluid, player, message.slotIndex, message.shift);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiLevelMaintainer;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IClickableInTerminal;
|
||||
@@ -28,6 +25,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
private int z;
|
||||
private int dim;
|
||||
private ForgeDirection side;
|
||||
private int originalGui = -1;
|
||||
|
||||
public enum Action {
|
||||
EDIT,
|
||||
@@ -49,17 +47,30 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public CPacketLevelTerminalCommands setOriginalGui(int originalGui) {
|
||||
this.originalGui = originalGui;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
action = Action.values()[buf.readInt()];
|
||||
switch (action) {
|
||||
case EDIT, BACK -> {
|
||||
case EDIT -> {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
dim = buf.readInt();
|
||||
side = ForgeDirection.getOrientation(buf.readInt());
|
||||
}
|
||||
case BACK -> {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
dim = buf.readInt();
|
||||
side = ForgeDirection.getOrientation(buf.readInt());
|
||||
originalGui = buf.readInt();
|
||||
}
|
||||
case ENABLE -> {}
|
||||
case DISABLE -> {}
|
||||
case ENABLE_ALL -> {}
|
||||
@@ -71,13 +82,21 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(action.ordinal());
|
||||
switch (action) {
|
||||
case EDIT, BACK -> {
|
||||
case EDIT -> {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
}
|
||||
case BACK -> {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
buf.writeInt(originalGui);
|
||||
}
|
||||
case ENABLE -> {}
|
||||
case DISABLE -> {}
|
||||
case ENABLE_ALL -> {}
|
||||
@@ -103,11 +122,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
}
|
||||
case BACK -> {
|
||||
GuiType originalGui = null;
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiLevelMaintainer guiLevelMaintainer) {
|
||||
originalGui = guiLevelMaintainer.getOriginalGui();
|
||||
}
|
||||
GuiType originalGui = GuiType.getByOrdinal(message.originalGui);
|
||||
if (originalGui == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiRenamer;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IClickableInTerminal;
|
||||
@@ -179,10 +176,7 @@ public class CPacketRenamer implements IMessage {
|
||||
.getTileEntity(intMsg.x, intMsg.y, intMsg.z);
|
||||
this.setName(tile, intMsg.getSide(), message.text);
|
||||
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiRenamer guiRenamer) {
|
||||
guiRenamer.switchGui();
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketSwitchBack(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiRenamer;
|
||||
|
||||
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;
|
||||
|
||||
public class SPacketSwitchBack implements IMessage {
|
||||
|
||||
public SPacketSwitchBack() {}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {}
|
||||
|
||||
public static class Handler implements IMessageHandler<SPacketSwitchBack, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(SPacketSwitchBack message, MessageContext ctx) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiRenamer) {
|
||||
((GuiRenamer) gs).switchGui();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,10 @@ public class CommonProxy {
|
||||
|
||||
public final FCNetworkWrapper netHandler = new FCNetworkWrapper(FluidCraft.MODID);
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {}
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
ModAndClassUtil.init();
|
||||
ItemAndBlockHolder.init();
|
||||
}
|
||||
|
||||
public void init(FMLInitializationEvent event) {
|
||||
this.registerMovables();
|
||||
@@ -51,8 +54,12 @@ public class CommonProxy {
|
||||
}
|
||||
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_P2P), 1);
|
||||
Upgrades.ADVANCED_BLOCKING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
|
||||
Upgrades.ADVANCED_BLOCKING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
|
||||
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
|
||||
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
|
||||
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P), 1);
|
||||
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 5);
|
||||
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 1);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidInventory;
|
||||
@@ -408,6 +409,13 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
IAEFluidStack remove;
|
||||
if (doFill) {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, this.mySource);
|
||||
if (remove == null) {
|
||||
onStackReturnedToNetwork(resource);
|
||||
} else {
|
||||
FluidStack copy = resource.copy();
|
||||
copy.amount -= (int) remove.getStackSize();
|
||||
onStackReturnedToNetwork(copy);
|
||||
}
|
||||
} else {
|
||||
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, this.mySource);
|
||||
}
|
||||
@@ -439,6 +447,10 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
return this.tanks.getTankInfo(from);
|
||||
}
|
||||
|
||||
private void onStackReturnedToNetwork(FluidStack fluidStack) {
|
||||
this.iHost.getInterfaceDuality().onStackReturnedToNetwork(ItemFluidDrop.newAeStack(fluidStack));
|
||||
}
|
||||
|
||||
private static class InterfaceInventory extends MEMonitorIFluidHandler {
|
||||
|
||||
InterfaceInventory(DualityFluidInterface tileInterface) {
|
||||
|
||||
@@ -12,6 +12,13 @@ import cpw.mods.fml.common.Loader;
|
||||
|
||||
public final class ModAndClassUtil {
|
||||
|
||||
/**
|
||||
* GTNH fork of GregTech5 Unofficial
|
||||
*/
|
||||
public static boolean GT5NH = false;
|
||||
/**
|
||||
* GregTech5 / GregTech5 Unofficial (Blood-Asp's "official" GT5u)
|
||||
*/
|
||||
public static boolean GT5 = false;
|
||||
public static boolean GT6 = false;
|
||||
public static boolean EC2 = false;
|
||||
@@ -119,7 +126,14 @@ public final class ModAndClassUtil {
|
||||
isTypeFilter = false;
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) GT5 = true;
|
||||
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) {
|
||||
try {
|
||||
Class.forName("gregtech.api.recipe.RecipeMap");
|
||||
GT5NH = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
GT5 = true;
|
||||
}
|
||||
}
|
||||
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) GT6 = true;
|
||||
if (Loader.isModLoaded("extracells")) EC2 = true;
|
||||
if (Loader.isModLoaded("EnderIO")) EIO = true;
|
||||
|
||||
@@ -229,8 +229,7 @@ public final class Util {
|
||||
}
|
||||
|
||||
public static AEFluidStack getAEFluidFromItem(ItemStack stack) {
|
||||
if (stack != null
|
||||
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
if (fluid != null) {
|
||||
@@ -252,8 +251,7 @@ public final class Util {
|
||||
}
|
||||
|
||||
public static FluidStack getFluidFromItem(ItemStack stack) {
|
||||
if (stack != null
|
||||
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
if (fluid != null) {
|
||||
|
||||
Reference in new issue
Block a user