Compare commits

..
173 changed files with 4129 additions and 9608 deletions

No files matched your search

+6 -35
View File
@@ -1,38 +1,9 @@
.gradle
.settings
/.idea/
/.vscode/
/run/
/build/
/eclipse/
.classpath
.project
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.bat
.gradle/
.idea/
out/
*.iml
*.ipr
*.iws
src/main/resources/mixins.*([!.]).json
*.bat
*.DS_Store
!gradlew.bat
.factorypath
addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
run/
build/
+1510 -3
View File
File diff suppressed because it is too large. Load diff
+15 -52
View File
@@ -1,59 +1,22 @@
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
* Available at compiletime but not runtime for mods depending on this mod
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
* Not available at all for mods depending on this mod, only visible at runtime for this mod
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
*
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
*
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.6.11-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-405-GTNH:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.3.50-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-215-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.8.0:dev')
api('com.github.GTNewHorizons:waila:1.6.0:dev')
api('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.2:dev")
compileOnly("com.github.GTNewHorizons:GTNHLib:0.3.0:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.9.7:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.8.6:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.48.56:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
}
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.9.0:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.6.7:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.4.14:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.43.21:dev')
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.10.11-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.6.10-GTNH:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.20:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.0:dev")
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.5-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.2-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.9.4:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.2.10:dev") { transitive = false }
}
+28 -149
View File
@@ -1,192 +1,71 @@
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = Fluid Craft For AE2
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
modId = ae2fc
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = com.glodblock.github
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
useModGroupForPublishing = false
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
# Will update your build.gradle automatically whenever an update is available
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass =
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId = GRADLETOKEN_MODID
# [DEPRECATED] Mod name replacement token.
gradleTokenModName = GRADLETOKEN_MODNAME
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = FluidCraft.java
gradleTokenModId = GRADLETOKEN_MODID
gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
accessTransformersFile = ae2fc_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass = coremod.FluidCraftCore
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = false
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
#customArchiveBaseName =
# Optional parameter to prevent the source code from being published
# noPublishedSources =
Binary file not shown.
+1 -2
View File
@@ -1,7 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+13 -18
View File
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,8 +83,10 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# 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
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -131,13 +133,10 @@ location of your Java installation."
fi
else
JAVACMD=java
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.
which java >/dev/null 2>&1 || 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.
@@ -145,7 +144,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=SC2039,SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -153,7 +152,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=SC2039,SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,15 +197,11 @@ if "$cygwin" || "$msys" ; then
done
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, 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.
# 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.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Vendored
-92
View File
@@ -1,92 +0,0 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+10 -5
View File
@@ -4,10 +4,10 @@ pluginManagement {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "https://nexus.gtnewhorizons.com/repository/public/"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
includeGroup("com.gtnewhorizons.retrofuturagradle")
}
}
gradlePluginPortal()
@@ -17,7 +17,12 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.23'
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
@@ -20,20 +20,14 @@ import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.AEApi;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.NetworkRegistry;
@Mod(
modid = FluidCraft.MODID,
version = FluidCraft.VERSION,
name = FluidCraft.MODNAME,
dependencies = "required-after:appliedenergistics2@[rv3-beta-238,);required-after:CoFHCore;required-after:Baubles;after:waila;after:thaumicenergistics;after:ae2wct")
dependencies = "required-after:appliedenergistics2;required-after:CoFHCore;required-after:Baubles;after:waila;after:thaumicenergistics;after:ae2wct")
public class FluidCraft {
public static final String MODID = "GRADLETOKEN_MODID";
@@ -57,6 +51,7 @@ public class FluidCraft {
@Mod.EventHandler
public static void init(FMLInitializationEvent event) {
ModAndClassUtil.init();
if (ModAndClassUtil.OC) {
OCDriverInit.run();
}
@@ -76,10 +71,6 @@ public class FluidCraft {
if (!Config.removeRecipe) {
RecipeLoader.INSTANCE.run();
}
if (!ModAndClassUtil.NEW_HORIZONS_CORE_MOD) {
RecipeLoader.addTerminalCards();
RecipeLoader.addRecipesIfDreamCoreNotExist();
}
RecipeLoader.runTerminalRecipe();
if (ModAndClassUtil.isV2) {
@@ -92,11 +83,6 @@ public class FluidCraft {
proxy.postInit(event);
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {
proxy.onLoadComplete(event);
}
@Mod.EventHandler
public void onServerStart(FMLServerStartingEvent event) {
SPacketMEUpdateBuffer.init();
@@ -114,6 +100,9 @@ public class FluidCraft {
}
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {}
public static ResourceLocation resource(String path) {
return new ResourceLocation(MODID, path);
}
@@ -5,9 +5,6 @@ import java.util.Set;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
public final class FluidCraftAPI implements IFluidCraftAPI {
private static final FluidCraftAPI API = new FluidCraftAPI();
@@ -45,9 +42,4 @@ public final class FluidCraftAPI implements IFluidCraftAPI {
public boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid) {
return blacklistedDispFluids.contains(fluid);
}
@Override
public ILevelTerminalRegistry levelTerminalRegistry() {
return LevelTerminalRegistry.instance();
}
}
@@ -2,8 +2,6 @@ package com.glodblock.github.api;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
@SuppressWarnings("unused")
public interface IFluidCraftAPI {
@@ -26,9 +24,4 @@ public interface IFluidCraftAPI {
* Mostly for internal use; queries whether the fluid is blacklisted from being displayed.
*/
boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid);
/**
* Get instance of `ILevelTerminalRegistry` to add new supported machines into terminal
*/
ILevelTerminalRegistry levelTerminalRegistry();
}
@@ -1,8 +0,0 @@
package com.glodblock.github.api;
import net.minecraftforge.common.util.ForgeDirection;
public interface ISide {
ForgeDirection getSide();
}
@@ -1,20 +0,0 @@
package com.glodblock.github.api.registries;
import java.util.Set;
import appeng.api.networking.IGridHost;
public interface ILevelTerminalRegistry {
void register(Class<? extends ILevelViewable> clazz);
void register(Class<? extends IGridHost> aeClass, ILevelViewableAdapter adapter);
Set<Class<? extends ILevelViewable>> getSupportedClasses();
boolean isAdopted(Class<? extends ILevelViewable> clazz);
Class<? extends IGridHost> getAdopted(Class<? extends ILevelViewable> clazz);
ILevelViewableAdapter getAdapter(Class<? extends ILevelViewable> clazz);
}
@@ -1,53 +0,0 @@
package com.glodblock.github.api.registries;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import com.glodblock.github.api.ISide;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.networking.IGridHost;
import appeng.api.util.DimensionalCoord;
import appeng.helpers.ICustomNameObject;
public interface ILevelViewable extends IGridHost, ISide, ISegmentedInventory, ICustomNameObject {
DimensionalCoord getLocation();
TileEntity getTile();
default long getSortValue() {
TileEntity te = getTile();
return ((long) te.zCoord << 24) ^ ((long) te.xCoord << 8) ^ te.yCoord;
}
default boolean shouldDisplay() {
return true;
}
/**
* Number of rows to expect. This is used with {@link #rowSize()} to determine how to render the slots.
*/
default int rows() {
return 1;
};
/**
* Number of slots per row.
*/
default int rowSize() {
return 1;
};
default ItemStack getSelfItemStack() {
return null;
}
/**
* "Target" Display representation
*/
default ItemStack getDisplayItemStack() {
return null;
}
}
@@ -1,8 +0,0 @@
package com.glodblock.github.api.registries;
import appeng.api.networking.IGridHost;
public interface ILevelViewableAdapter extends ILevelViewable {
ILevelViewable adapt(IGridHost gridHost);
}
@@ -4,37 +4,27 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerDualInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
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;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSimpleImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerInterface;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IInterfaceHost;
public class GuiDualInterface extends GuiUpgradeable {
@@ -45,10 +35,7 @@ public class GuiDualInterface extends GuiUpgradeable {
private GuiToggleButton interfaceMode;
private GuiImgButton insertionMode;
private GuiImgButton sidelessMode;
private GuiSimpleImgButton doublePatterns;
private GuiToggleButton patternOptimization;
private GuiImgButton advancedBlockingMode;
private GuiImgButton lockCraftingMode;
private final IInterfaceHost host;
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
@@ -77,78 +64,40 @@ public class GuiDualInterface extends GuiUpgradeable {
itemRender);
this.buttonList.add(this.switcher);
int offset = 8;
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + offset, Settings.BLOCK, YesNo.NO);
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO);
this.buttonList.add(this.BlockMode);
offset += 18;
this.interfaceMode = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + offset,
this.guiTop + 26,
84,
85,
GuiText.InterfaceTerminal.getLocal(),
GuiText.InterfaceTerminalHint.getLocal());
this.buttonList.add(this.interfaceMode);
offset += 18;
this.insertionMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + offset,
this.guiTop + 44,
Settings.INSERTION_MODE,
InsertionMode.DEFAULT);
this.buttonList.add(this.insertionMode);
offset += 18;
this.doublePatterns = new GuiSimpleImgButton(this.guiLeft - 18, this.guiTop + offset, 71, "");
this.doublePatterns.enabled = false;
this.buttonList.add(this.doublePatterns);
offset += 18;
this.patternOptimization = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + offset,
178,
194,
GuiText.PatternOptimization.getLocal(),
GuiText.PatternOptimizationHint.getLocal());
this.buttonList.add(this.patternOptimization);
offset += 18;
this.advancedBlockingMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + offset,
this.guiTop + 62,
Settings.ADVANCED_BLOCKING_MODE,
AdvancedBlockingMode.DEFAULT);
this.buttonList.add(this.advancedBlockingMode);
this.advancedBlockingMode.visible = this.bc.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0;
offset += 18;
if (isTile()) {
this.sidelessMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + offset,
this.guiTop + 80,
Settings.SIDELESS_MODE,
SidelessMode.SIDELESS);
this.buttonList.add(this.sidelessMode);
offset += 18;
}
this.lockCraftingMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + offset,
Settings.LOCK_CRAFTING_MODE,
LockCraftingMode.NONE);
this.lockCraftingMode.visible = this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0;
this.buttonList.add(lockCraftingMode);
}
@Override
@@ -163,25 +112,12 @@ public class GuiDualInterface extends GuiUpgradeable {
if (this.insertionMode != null) {
this.insertionMode.set(((ContainerInterface) this.cvb).getInsertionMode());
}
if (this.doublePatterns != null) {
this.doublePatterns.enabled = ((ContainerInterface) this.cvb).isAllowedToMultiplyPatterns;
if (this.doublePatterns.enabled) this.doublePatterns.setTooltip(
ButtonToolTips.DoublePatterns.getLocal() + "\n" + ButtonToolTips.DoublePatternsHint.getLocal());
else this.doublePatterns.setTooltip(
ButtonToolTips.DoublePatterns.getLocal() + "\n" + ButtonToolTips.OptimizePatternsNoReq.getLocal());
}
if (this.patternOptimization != null) {
this.patternOptimization.setState(((ContainerInterface) this.cvb).getPatternOptimization() == YesNo.YES);
}
if (this.sidelessMode != null) {
this.sidelessMode.set(((ContainerDualInterface) this.cvb).getSidelessMode());
}
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,
@@ -193,7 +129,6 @@ public class GuiDualInterface extends GuiUpgradeable {
protected String getBackground() {
if (!ModAndClassUtil.isBigInterface) return "guis/interface.png";
return switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) {
case -1 -> "guis/interfacenone.png";
case 1 -> "guis/interface2.png";
case 2 -> "guis/interface3.png";
case 3 -> "guis/interface4.png";
@@ -205,34 +140,33 @@ public class GuiDualInterface extends GuiUpgradeable {
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == null) {
return;
}
if (btn == this.priority) {
InventoryHandler.switchGui(GuiType.PRIORITY);
} else if (btn == this.switcher) {
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE_FLUID);
} else if (btn == this.interfaceMode) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
}
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
}
if (btn == this.interfaceMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
} else if (btn == this.BlockMode) {
}
if (btn == this.BlockMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.BlockMode.getSetting(), backwards));
} else if (btn == this.insertionMode) {
}
if (btn == this.insertionMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.insertionMode.getSetting(), backwards));
} else if (btn == this.doublePatterns) {
try {
int val = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? 1 : 0;
if (backwards) val |= 0b10;
NetworkHandler.instance
.sendToServer(new PacketValueConfig("Interface.DoublePatterns", String.valueOf(val)));
} catch (final Throwable e) {
AELog.debug(e);
}
} else if (btn == this.patternOptimization) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.PATTERN_OPTIMIZATION, backwards));
} else if (btn == this.sidelessMode) {
}
if (btn == this.sidelessMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
} else if (btn == this.advancedBlockingMode) {
}
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));
}
}
@@ -243,15 +177,4 @@ public class GuiDualInterface extends GuiUpgradeable {
private boolean isTile() {
return this.host instanceof TileFluidInterface;
}
@Override
protected void handleButtonVisibility() {
super.handleButtonVisibility();
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,5 +1,7 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import net.minecraft.client.gui.GuiButton;
@@ -9,8 +11,6 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerEssentiaMonitor;
import com.glodblock.github.client.me.EssentiaRepo;
@@ -21,13 +21,16 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
public class GuiEssentiaTerminal extends GuiFluidMonitor {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
protected EntityPlayer player;
public GuiEssentiaTerminal(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
@@ -61,15 +64,13 @@ public class GuiEssentiaTerminal extends GuiFluidMonitor {
AspectUtil.getAspectFromGas(fluidStack),
fluidStack.amount);
IAEItemStack gas = stack.copy().setStackSize(stack.getStackSize() / AspectUtil.R);
aeRenderItem.setAeStack(gas);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
stackSizeRenderer.setAeStack(gas);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
gas.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
@@ -78,8 +79,13 @@ 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())) {
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
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));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
@@ -59,13 +59,6 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
this.registerApp(20, "LEVEL_TEM", "YES", "level_terminal_w");
this.registerApp(21, "SWITCH", "ON", "edit");
this.registerApp(22, "SWITCH", "OFF", "view");
this.registerApp(21, "SWITCH", "ENABLE", "enable");
this.registerApp(22, "SWITCH", "DISABLE", "disable");
this.registerApp(23, "CONFIG", "YES", "open_configuration");
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
}
}
@@ -117,10 +110,6 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
return this.currentValue;
}
public boolean getMouseIn() {
return this.field_146123_n;
}
public void set(final String e) {
if (!this.currentValue.equals(e)) {
this.currentValue = e;
@@ -11,7 +11,6 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import appeng.container.implementations.ContainerPriority;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
@@ -35,11 +34,6 @@ public class GuiFCPriority extends FCGuiAmount {
((ContainerPriority) this.inventorySlots).setTextField(this.amountBox);
}
@Override
protected int getIncrementQuantity(int i) {
return AEConfig.instance.priorityByStacksAmounts(i);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 0x404040);
@@ -2,6 +2,7 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
@@ -9,10 +10,8 @@ import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
@@ -66,26 +65,20 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (target instanceof PartFluidTerminal) {
this.myIcon = ItemAndBlockHolder.FLUID_TERM.stack();
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof PartLevelTerminal) {
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof WirelessLevelTerminalInventory) {
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}
@@ -2,42 +2,37 @@ package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.network.CPacketSwitchGuis;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftConfirm;
public class GuiFluidCraftConfirm extends GuiCraftConfirm {
private GuiType originalGui;
private GuiType OriginalGui;
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te);
if (te instanceof PartFluidPatternTerminal) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (te instanceof PartFluidPatternTerminalEx) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (te instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
} else if (te instanceof IWirelessTerminal terminal && terminal.isUniversal(te)) {
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (te instanceof IWirelessTerminal && ((IWirelessTerminal) te).isUniversal(te)) {
this.OriginalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) te).getItemStack());
} else if (te instanceof WirelessPatternTerminalInventory) {
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (te instanceof WirelessLevelTerminalInventory) {
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
this.OriginalGui = GuiType.FLUID_TERMINAL;
}
}
@Override
public void switchToOriginalGUI() {
InventoryHandler.switchGui(originalGui);
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
}
@@ -17,11 +17,11 @@ import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
@@ -117,7 +117,7 @@ public class GuiFluidInterface extends AEBaseGui {
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.switcher) {
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE);
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE));
}
}
@@ -7,14 +7,15 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.network.CPacketValueConfig;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.*;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.render.AppEngRenderItem;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiColors;
@@ -23,6 +24,7 @@ import appeng.core.localization.GuiText;
public class GuiFluidLevelEmitter extends GuiUpgradeable {
private GuiNumberBox level;
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
@@ -79,7 +81,7 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
getGuiDisplayName(NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER)),
NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER),
8,
6,
GuiColors.UpgradableTitle.getColor());
@@ -4,7 +4,6 @@ import java.util.List;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.client.gui.base.FCGuiMonitor;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
@@ -24,7 +23,6 @@ public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
final ContainerFluidMonitor c) {
super(inventoryPlayer, te, c);
this.repo = new FluidRepo(getScrollBar(), this);
this.setScrollBar();
}
@Override
@@ -56,9 +54,8 @@ public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
final FluidStack fluid = Util.getFluidFromItem(stack);
if (fluid != null) {
setSearchString(fluid.getLocalizedName(), true);
if (Util.getFluidFromItem(stack) != null) {
setSearchString(Util.getFluidFromItem(stack).getLocalizedName(), true);
}
}
}
@@ -1,49 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiOptimizePatterns;
import appeng.core.localization.GuiText;
public class GuiFluidOptimizePatterns extends GuiOptimizePatterns {
private GuiType originalGui;
public GuiFluidOptimizePatterns(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
if (te instanceof PartFluidPatternTerminal) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (te instanceof PartFluidPatternTerminalEx) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (te instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
} else if (te instanceof IWirelessTerminal terminal && terminal.isUniversal(te)) {
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (te instanceof WirelessPatternTerminalInventory) {
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (te instanceof WirelessLevelTerminalInventory) {
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}
@Override
protected void actionPerformed(GuiButton btn) {
if (btn.displayString.equals(GuiText.Cancel.getLocal())) {
InventoryHandler.switchGui(originalGui);
return;
}
super.actionPerformed(btn);
}
}
@@ -13,8 +13,6 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
import com.glodblock.github.common.item.ItemFluidPacket;
@@ -23,10 +21,12 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.ISlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.render.AppEngRenderItem;
import appeng.core.localization.GuiText;
public class GuiFluidPatternEncoder extends AEBaseGui {
@@ -35,6 +35,7 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
private final ContainerFluidPatternEncoder cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
super(new ContainerFluidPatternEncoder(ipl, tile));
@@ -94,15 +95,13 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
}
aeRenderItem.setAeStack(fake);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
} else {
super.func_146977_a(slot);
}
@@ -2,31 +2,31 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2ReflectClient;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {
public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
private GuiTabButton originalGuiBtn;
private final ITerminalHost host;
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
public GuiFluidPatternTerminalCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
host = te;
}
@@ -34,23 +34,20 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf
@Override
public void initGui() {
if (host instanceof PartFluidPatternTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL.stack());
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL_EX.stack());
else if (host instanceof PartFluidTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERM.stack());
else if (host instanceof PartLevelTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.LEVEL_TERMINAL.stack());
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack());
else if (host instanceof WirelessFluidTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_FLUID_TERM.stack());
else if (host instanceof WirelessPatternTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack());
else if (host instanceof WirelessInterfaceTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack());
else if (host instanceof WirelessLevelTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack());
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
else if (host instanceof PartFluidTerminal) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
} else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1));
} else if (host instanceof WirelessFluidTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
} else if (host instanceof WirelessPatternTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
} else if (host instanceof WirelessInterfaceTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
}
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@@ -62,17 +59,14 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
else if (host instanceof 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 IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
else if (host instanceof WirelessFluidTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
else if (host instanceof WirelessPatternTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
else if (host instanceof WirelessInterfaceTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
else if (host instanceof WirelessLevelTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_LEVEL_TERMINAL);
} else {
super.actionPerformed(btn);
}
@@ -14,11 +14,7 @@ import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.PatternBeSubstitution;
import appeng.api.config.PatternSlotConfig;
import appeng.api.config.Settings;
import appeng.api.config.*;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
@@ -9,9 +9,9 @@ import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import appeng.api.config.AccessRestriction;
@@ -93,7 +93,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
} else if (btn == this.clear) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
InventoryHandler.switchGui(GuiType.PRIORITY);
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
@@ -1,5 +1,8 @@
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;
@@ -7,7 +10,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
@@ -19,18 +21,19 @@ import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.Util;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.AppEngSlot;
public class GuiFluidTerminal extends GuiFluidMonitor {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
protected EntityPlayer player;
public ContainerFluidMonitor container;
@@ -78,48 +81,45 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
if (stack == null) return true;
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid());
aeRenderItem.setAeStack(stack);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
stackSizeRenderer.setAeStack(stack);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
}
private void drawWidget(int posX, int posY, Fluid fluid) {
if (fluid == null) return;
IIcon icon = fluid.getIcon();
if (icon == null) return;
if (ModAndClassUtil.HODGEPODGE && icon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) icon).markNeedsAnimationUpdate();
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor3f(
(fluid.getColor() >> 16 & 0xFF) / 255.0F,
(fluid.getColor() >> 8 & 0xFF) / 255.0F,
(fluid.getColor() & 0xFF) / 255.0F);
drawTexturedModelRectFromIcon(posX, posY, fluid.getIcon(), 16, 16);
GL11.glColor3f(1, 1, 1);
if (fluid != null && fluid.getIcon() != null) {
GL11.glColor3f(
(fluid.getColor() >> 16 & 0xFF) / 255.0F,
(fluid.getColor() >> 8 & 0xFF) / 255.0F,
(fluid.getColor() & 0xFF) / 255.0F);
drawTexturedModelRectFromIcon(posX, posY, fluid.getIcon(), 16, 16);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor3f(1, 1, 1);
}
@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())) {
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
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));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
@@ -0,0 +1,743 @@
package com.glodblock.github.client.gui;
import java.util.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCBaseMEGui;
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketRenamer;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import com.google.common.collect.HashMultimap;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.util.WorldCoord;
import appeng.client.gui.widgets.*;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.client.render.BlockPosHighlighter;
import appeng.container.slot.AppEngSlot;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.PatternHelper;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.Platform;
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
protected int offsetY;
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
private static final int offsetX = 21;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, Util.DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
protected static String searchFieldOutputsText = "";
protected static String searchFieldInputsText = "";
protected static String searchFieldNamesText = "";
private final MEGuiTextField searchFieldOutputs;
private final MEGuiTextField searchFieldInputs;
private final MEGuiTextField searchFieldNames;
private final GuiImgButton guiButtonHideFull;
private final GuiImgButton guiButtonAssemblersOnly;
private final GuiImgButton guiButtonBrokenRecipes;
private GuiImgButton searchStringSave;
private GuiImgButton terminalStyleBox;
private boolean refreshList = false;
protected static boolean onlyMolecularAssemblers = false;
protected static boolean onlyBrokenRecipes = false;
protected GuiTabButton craftingStatusBtn;
private int rows = 3;
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
public GuiInterfaceTerminalWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));
this.setScrollBar(new GuiScrollbar());
this.xSize = 208;
this.ySize = 255;
searchFieldInputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldOutputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames = new MEGuiTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames.setFocused(true);
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
}
@Override
public int getOffsetY() {
return this.offsetY;
}
@Override
public void setOffsetY(int y) {
this.offsetY = y;
}
private void setScrollBar() {
this.getScrollBar().setTop(52).setLeft(189).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, this.lines.size() - this.rows, 2);
}
@Override
public void initGui() {
super.initGui();
this.rows = calculateRowsCount();
this.ySize = MAGIC_HEIGHT_NUMBER + this.rows * 18;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
this.offsetY = this.guiTop + 8;
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
this.offsetY += 20;
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SAVE_SEARCH,
AEConfig.instance.settings.getSetting(Settings.SAVE_SEARCH)));
this.offsetY += 20;
searchFieldInputs.x = guiLeft + Math.max(32, offsetX);
searchFieldInputs.y = guiTop + 25;
searchFieldOutputs.x = guiLeft + Math.max(32, offsetX);
searchFieldOutputs.y = guiTop + 38;
searchFieldNames.x = guiLeft + Math.max(32, offsetX) + 99;
searchFieldNames.y = guiTop + 38;
guiButtonAssemblersOnly.xPosition = guiLeft + Math.max(32, offsetX) + 99;
guiButtonAssemblersOnly.yPosition = guiTop + 20;
guiButtonHideFull.xPosition = guiButtonAssemblersOnly.xPosition + 18;
guiButtonHideFull.yPosition = guiTop + 20;
guiButtonBrokenRecipes.xPosition = guiButtonHideFull.xPosition + 18;
guiButtonBrokenRecipes.yPosition = guiTop + 20;
terminalStyleBox.xPosition = guiLeft - 18;
terminalStyleBox.yPosition = guiTop + 8;
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + this.xSize - 24,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString();
}
this.setScrollBar();
this.repositionSlots();
this.initGuiDone();
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
searchFieldOutputsText = this.searchFieldOutputs.getText();
searchFieldInputsText = this.searchFieldInputs.getText();
searchFieldNamesText = this.searchFieldNames.getText();
}
public void setSearchString() {
this.searchFieldOutputs.setText(searchFieldOutputsText);
this.searchFieldInputs.setText(searchFieldInputsText);
this.searchFieldNames.setText(searchFieldNamesText);
}
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof final AppEngSlot slot) {
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
}
}
}
protected int calculateRowsCount() {
final int maxRows = this.getMaxRows();
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int input = 22;
final int topPanel = 18;
final int NEIPadding = hasNEI ? input + topPanel : 0;
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - NEIPadding;
return Math.max(3, Math.min(maxRows, extraSpace / 18));
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
fontRendererObj.drawString(
getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()),
8,
6,
GuiColors.InterfaceTerminalTitle.getColor());
fontRendererObj.drawString(
GuiText.inventory.getLocal(),
GuiInterfaceTerminalWireless.offsetX + 2,
this.ySize - 96,
GuiColors.InterfaceTerminalInventory.getColor());
int offset = 51;
final int ex = getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z))) drawRect(
z * 18 + 22,
1 + offset,
z * 18 + 22 + 16,
1 + offset + 16,
GuiColors.InterfaceTerminalMatch.getColor());
}
} else if (lineObj instanceof String name) {
final int rows = this.byName.get(name).size();
String postfix = "";
if (rows > 1) {
postfix = " (" + rows + ')';
}
while (name.length() > 2 && this.fontRendererObj.getStringWidth(name + postfix) > 158) {
name = name.substring(0, name.length() - 1);
}
this.fontRendererObj.drawString(
name + postfix,
GuiInterfaceTerminalWireless.offsetX + 3,
6 + offset,
GuiColors.InterfaceTerminalName.getColor());
}
offset += 18;
}
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
buttonList.clear();
inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
guiButtonAssemblersOnly.set(
onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLEERS_ON : ActionItems.MOLECULAR_ASSEMBLEERS_OFF);
guiButtonHideFull.set(
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF
: ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
guiButtonBrokenRecipes.set(
onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_OFF
: ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_ON);
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
buttonList.add(guiButtonAssemblersOnly);
buttonList.add(guiButtonHideFull);
buttonList.add(guiButtonBrokenRecipes);
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
this.guiButtonHashMap.clear();
addSwitchGuiBtns();
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 22, 1 + offset));
}
GuiButton guiButton = new GuiImgButton(
guiLeft + 4,
guiTop + offset + 1,
Settings.ACTIONS,
ActionItems.HIGHLIGHT_INTERFACE);
GuiFCImgButton editButton = new GuiFCImgButton(guiLeft + 4, guiTop + offset + 1, "EDIT", "YES");
guiButtonHashMap.put(guiButton, inv);
guiButtonHashMap.put(editButton, inv);
if (isShiftKeyDown()) {
buttonList.add(editButton);
} else {
buttonList.add(guiButton);
}
}
offset += 18;
}
super.drawScreen(mouseX, mouseY, btn);
handleTooltip(mouseX, mouseY, searchFieldInputs);
handleTooltip(mouseX, mouseY, searchFieldOutputs);
handleTooltip(mouseX, mouseY, searchFieldNames);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
searchFieldOutputs.mouseClicked(xCoord, yCoord, btn);
searchFieldNames.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (guiButtonHashMap.containsKey(btn)) {
Util.DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
if (btn instanceof GuiFCImgButton) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketRenamer(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
blockPos.getSide()));
} else {
WorldCoord blockPos2 = new WorldCoord(
(int) mc.thePlayer.posX,
(int) mc.thePlayer.posY,
(int) mc.thePlayer.posZ);
if (mc.theWorld.provider.dimensionId != blockPos.getDimension()) {
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceInOtherDim.getName(),
blockPos.getDimension()));
} else {
BlockPosHighlighter.highlightBlock(
blockPos,
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceHighlighted.getName(),
blockPos.x,
blockPos.y,
blockPos.z));
}
mc.thePlayer.closeScreen();
}
} else if (btn == guiButtonHideFull) {
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal = !AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal;
this.refreshList();
} else if (btn == guiButtonAssemblersOnly) {
onlyMolecularAssemblers = !onlyMolecularAssemblers;
this.refreshList();
} else if (btn == guiButtonBrokenRecipes) {
onlyBrokenRecipes = !onlyBrokenRecipes;
this.refreshList();
} else if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
AEConfig.instance.settings.putSetting(Settings.SAVE_SEARCH, next);
this.searchStringSave.set(next);
} else if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else if (btn instanceof final GuiImgButton iBtn) {
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final boolean backwards = Mouse.isButtonDown(1);
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
this.reinitialize();
}
iBtn.set(next);
}
}
super.actionPerformed(btn);
}
private void reinitialize() {
this.buttonList.clear();
this.initGui();
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/newinterfaceterminal.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 53);
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 53 + x * 18, 0, 52, this.xSize, 18);
}
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
GL11.glColor4f(1, 1, 1, 1);
final int width = inv.getInventory().getSizeInventory() * 18;
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18);
}
offset += 18;
}
this.drawTexturedModalRect(offsetX, offsetY + 50 + this.rows * 18, 0, 158, this.xSize, 99);
searchFieldInputs.drawTextBox();
searchFieldOutputs.drawTextBox();
searchFieldNames.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) {
if (!checkHotbarKeys(key)) {
if (character == ' ') {
if ((searchFieldInputs.getText().isEmpty() && searchFieldInputs.isFocused())
|| (searchFieldOutputs.getText().isEmpty() && searchFieldOutputs.isFocused())
|| (searchFieldNames.getText().isEmpty() && searchFieldNames.isFocused()))
return;
} else if (character == '\t') {
if (handleTab()) return;
}
if (searchFieldInputs.textboxKeyTyped(character, key) || searchFieldOutputs.textboxKeyTyped(character, key)
|| searchFieldNames.textboxKeyTyped(character, key)) {
refreshList();
} else {
super.keyTyped(character, key);
}
}
}
private boolean handleTab() {
if (searchFieldInputs.isFocused()) {
searchFieldInputs.setFocused(false);
if (isShiftKeyDown()) searchFieldNames.setFocused(true);
else searchFieldOutputs.setFocused(true);
return true;
} else if (searchFieldOutputs.isFocused()) {
searchFieldOutputs.setFocused(false);
if (isShiftKeyDown()) searchFieldInputs.setFocused(true);
else searchFieldNames.setFocused(true);
return true;
} else if (searchFieldNames.isFocused()) {
searchFieldNames.setFocused(false);
if (isShiftKeyDown()) searchFieldOutputs.setFocused(true);
else searchFieldInputs.setFocused(true);
return true;
}
return false;
}
public void postUpdate(final NBTTagCompound in) {
if (in.getBoolean("clear")) {
this.byId.clear();
this.refreshList = true;
}
for (final Object oKey : in.func_150296_c()) {
final String key = (String) oKey;
if (key.startsWith("=")) {
try {
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
final NBTTagCompound invData = in.getCompoundTag(key);
final ClientDCInternalInv current = this
.getById(id, invData.getLong("sortBy"), invData.getString("un"));
int X = invData.getInteger("x");
int Y = invData.getInteger("y");
int Z = invData.getInteger("z");
int dim = invData.getInteger("dim");
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
blockPosHashMap.put(
current,
new Util.DimensionalCoordSide(X, Y, Z, dim, side, current.getUnlocalizedName()));
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
final String which = Integer.toString(x);
if (invData.hasKey(which)) {
current.getInventory().setInventorySlotContents(
x,
ItemStack.loadItemStackFromNBT(invData.getCompoundTag(which)));
}
}
} catch (final NumberFormatException ignored) {}
}
}
if (this.refreshList) {
this.refreshList = false;
// invalidate caches on refresh
this.cachedSearches.clear();
this.refreshList();
}
}
/**
* Rebuilds the list of interfaces.
* <p>
* Respects a search term if present (ignores case) and adding only matching patterns.
*/
private void refreshList() {
this.byName.clear();
this.buttonList.clear();
this.matchedStacks.clear();
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
final String searchFieldNames = this.searchFieldNames.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm(
"IN:" + searchFieldInputs
+ "OUT:"
+ searchFieldOutputs
+ "NAME:"
+ searchFieldNames
+ AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
+ onlyMolecularAssemblers
+ onlyBrokenRecipes);
final boolean rebuild = cachedSearch.isEmpty();
for (final ClientDCInternalInv entry : this.byId.values()) {
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
if (!rebuild && !cachedSearch.contains(entry)) {
continue;
}
// Shortcut to skip any filter if search term is ""/empty
boolean found = searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty();
boolean interfaceHasFreeSlots = false;
boolean interfaceHasBrokenRecipes = false;
// Search if the current inventory holds a pattern containing the search term.
if (!found || AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || onlyBrokenRecipes) {
for (final ItemStack itemStack : entry.getInventory()) {
// If only Interfaces with empty slots should be shown, check that here
if (itemStack == null) {
interfaceHasFreeSlots = true;
continue;
}
if (onlyBrokenRecipes && recipeIsBroken(itemStack)) {
interfaceHasBrokenRecipes = true;
}
if ((!searchFieldInputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0))
|| (!searchFieldOutputs.isEmpty()
&& itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1))) {
found = true;
matchedStacks.add(itemStack);
}
}
}
if ((found && entry.getName().toLowerCase().contains(searchFieldNames))
&& (!onlyMolecularAssemblers || entry.getUnlocalizedName().contains(MOLECULAR_ASSEMBLER))
&& (!AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || interfaceHasFreeSlots)
&& (!onlyBrokenRecipes || interfaceHasBrokenRecipes)) {
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
} else {
cachedSearch.remove(entry);
}
}
this.names.clear();
this.names.addAll(this.byName.keySet());
Collections.sort(this.names);
this.lines.clear();
this.lines.ensureCapacity(this.names.size() + this.byId.size());
for (final String n : this.names) {
this.lines.add(n);
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
Collections.sort(clientInventories);
this.lines.addAll(clientInventories);
}
this.setScrollBar();
}
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm, int pass) {
if (itemStack == null) {
return false;
}
final NBTTagCompound encodedValue = itemStack.getTagCompound();
if (encodedValue == null) {
return false;
}
final NBTTagList tags = encodedValue.getTagList(pass == 0 ? "in" : "out", 10);
final boolean containsInvalidDisplayName = GuiText.UnknownItem.getLocal().toLowerCase().contains(searchTerm);
for (int i = 0; i < tags.tagCount(); i++) {
final NBTTagCompound tag = tags.getCompoundTagAt(i);
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT(tag);
if (parsedItemStack != null) {
final String displayName = Platform
.getItemDisplayName(AEApi.instance().storage().createItemStack(parsedItemStack)).toLowerCase();
if (displayName.contains(searchTerm)) {
return true;
}
} else if (containsInvalidDisplayName && !tag.hasNoTags()) {
return true;
}
}
return false;
}
private boolean recipeIsBroken(final ItemStack itemStack) {
if (itemStack == null) {
return false;
}
final NBTTagCompound encodedValue = itemStack.getTagCompound();
if (encodedValue == null) {
return true;
}
final World w = CommonHelper.proxy.getWorld();
if (w == null) {
return false;
}
try {
new PatternHelper(itemStack, w);
return false;
} catch (final Throwable t) {
return true;
}
}
/**
* Tries to retrieve a cache for a with search term as keyword.
* <p>
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
* the empty string.
*
* @param searchTerm the corresponding search
* @return a Set matching a superset of the search term
*/
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
if (!this.cachedSearches.containsKey(searchTerm)) {
this.cachedSearches.put(searchTerm, new HashSet<>());
}
final Set<Object> cache = this.cachedSearches.get(searchTerm);
if (cache.isEmpty() && searchTerm.length() > 1) {
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
return cache;
}
return cache;
}
private int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
? AEConfig.instance.InterfaceTerminalSmallSize
: Integer.MAX_VALUE;
}
private ClientDCInternalInv getById(final long id, final long sortBy, final String unlocalizedName) {
ClientDCInternalInv o = this.byId.get(id);
if (o == null) {
this.byId.put(id, o = new ClientDCInternalInv(9, id, sortBy, unlocalizedName));
this.refreshList = true;
}
return o;
}
public boolean isOverTextField(final int mousex, final int mousey) {
return searchFieldInputs.isMouseIn(mousex, mousey) || searchFieldOutputs.isMouseIn(mousex, mousey)
|| searchFieldNames.isMouseIn(mousex, mousey);
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
if (searchFieldInputs.isMouseIn(mousex, mousey)) {
searchFieldInputs.setText(displayName);
} else if (searchFieldOutputs.isMouseIn(mousex, mousey)) {
searchFieldOutputs.setText(displayName);
} else if (searchFieldNames.isMouseIn(mousex, mousey)) {
searchFieldNames.setText(displayName);
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,12 +1,9 @@
package com.glodblock.github.client.gui;
import static com.glodblock.github.client.gui.container.ContainerLevelMaintainer.createLevelValues;
import java.awt.Rectangle;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -16,49 +13,29 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketLevelMaintainer;
import com.glodblock.github.network.CPacketLevelMaintainer.Action;
import com.glodblock.github.network.CPacketLevelTerminalCommands;
import com.glodblock.github.util.FCGuiColors;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import com.gtnewhorizon.gtnhlib.util.parsing.MathExpressionParser;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.DimensionalCoord;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.SlotFake;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.AEFeature;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketNEIDragClick;
import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cofh.core.render.CoFHFontRenderer;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler")
@@ -68,19 +45,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private final ContainerLevelMaintainer cont;
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private FCGuiTextField input;
private int lastWorkingTick;
private int refreshTick;
private final CoFHFontRenderer render;
protected ItemStack icon = null;
protected GuiType originalGui;
protected Util.DimensionalCoordSide originalBlockPos;
protected GuiTabButton originalGuiBtn;
protected static final boolean isGTNHLibLoaded = Loader.isModLoaded("gtnhlib");
protected static final Pattern numberPattern = isGTNHLibLoaded ? MathExpressionParser.EXPRESSION_PATTERN
: Pattern.compile("^[0-9]+");
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(new ContainerLevelMaintainer(ipl, tile));
@@ -93,72 +62,27 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
Minecraft.getMinecraft().getTextureManager(),
true);
this.refreshTick = 0;
if (ipl.player.openContainer instanceof AEBaseContainer container) {
var target = container.getTarget();
if (target instanceof PartLevelTerminal terminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
DimensionalCoord blockPos = new DimensionalCoord(terminal.getTile());
originalBlockPos = new Util.DimensionalCoordSide(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
terminal.getSide(),
"");
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
ipl.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
ipl.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
}
}
}
public void postUpdate(List<IAEItemStack> list) {
for (Slot slot : this.cont.getRequestSlots()) {
if (!slot.getHasStack()) {
component[slot.getSlotIndex()].setState(State.None);
component[slot.getSlotIndex()].setState(TileLevelMaintainer.State.Nothing);
}
}
for (IAEItemStack is : list) {
NBTTagCompound data = is.getItemStack().getTagCompound();
if (data == null) {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info("Received empty configuration: ", is);
}
continue;
}
long batch = data.getLong(TLMTags.Batch.tagName);
long quantity = data.getLong(TLMTags.Quantity.tagName);
int idx = data.getInteger(TLMTags.Index.tagName);
boolean isEnable = data.getBoolean(TLMTags.Enable.tagName);
State state = State.values()[data.getInteger(TLMTags.State.tagName)];
component[idx].getQty().textField.setText(String.valueOf(quantity));
component[idx].getBatch().textField.setText(String.valueOf(batch));
component[idx].setEnable(isEnable);
component[idx].setState(state);
long size = data.getLong("Batch");
int i = data.getInteger("Index");
boolean isEnable = data.getBoolean("Enable");
TileLevelMaintainer.State state = TileLevelMaintainer.State.values()[data.getInteger("State")];
component[i].getQty().textField.setText(String.valueOf(is.getStackSize()));
component[i].getBatch().textField.setText(String.valueOf(size));
component[i].setEnable(isEnable);
component[i].setState(state);
}
}
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.lastWorkingTick = this.refreshTick;
@@ -168,29 +92,19 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
new FCGuiTextField(this.fontRendererObj, guiLeft + 46, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE,
i,
Action.Quantity),
"TileLevelMaintainer.Quantity"),
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE,
i,
Action.Batch),
"TileLevelMaintainer.Batch"),
new GuiFCImgButton(guiLeft + 105 + 47, guiTop + 17 + 19 * i, "SUBMIT", "SUBMIT", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "ENABLE", "ENABLE", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "DISABLE", "DISABLE", false),
new FCGuiLineField(fontRendererObj, guiLeft + 47, guiTop + 33 + 19 * i, 125),
this.buttonList);
}
if (this.icon != null) {
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 151,
this.guiTop - 4,
this.icon,
this.icon.getDisplayName(),
itemRender);
this.originalGuiBtn.setHideEdge(13);
this.buttonList.add(originalGuiBtn);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
}
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
@@ -210,7 +124,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
int tick = this.refreshTick;
int interval = 20;
if (tick > lastWorkingTick + interval && this.input == null) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
lastWorkingTick = this.refreshTick;
}
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
@@ -240,15 +154,13 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
} else {
fake.setStackSize(0);
}
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.setAeStack(fake);
aeRenderItem.renderItemOverlayIntoGUI(
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
fake.getItemStack(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
@@ -285,12 +197,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.input.textboxKeyTyped(character, key);
}
super.keyTyped(character, key);
if (!numberPattern.matcher(this.input.getText()).matches()) {
if (!this.input.getText().matches("^[0-9]+")) {
this.input.setTextColor(0xFF0000);
} else {
this.input.setTextColor(0xFFFFFF);
}
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
if (key == Keyboard.KEY_RETURN) {
this.input.setFocused(false);
this.input = null;
}
@@ -313,32 +225,14 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == originalGuiBtn) {
switchGui();
} else {
super.actionPerformed(btn);
for (Component com : this.component) {
if (com.sendToServer(btn)) {
break;
}
super.actionPerformed(btn);
for (Component com : this.component) {
if (com.sendToServer(btn)) {
break;
}
}
}
public void switchGui() {
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
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
return currentVisibility;
@@ -360,20 +254,20 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (draggedStack != null) {
draggedStack.stackSize = 0;
}
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
if (getSlotArea(slot).contains(mouseX, mouseY) && draggedStack != null) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) {
if (getSlotArea(slot).contains(mouseX, mouseY)) {
slot.putStack(draggedStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex()));
if (draggedStack != null) {
this.updateAmount(slot.getSlotIndex(), draggedStack.stackSize);
draggedStack.stackSize = 0;
}
return true;
}
}
if (draggedStack != null) {
draggedStack.stackSize = 0;
}
return false;
}
@@ -391,9 +285,8 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private final GuiFCImgButton enable;
private final GuiFCImgButton submit;
private final FCGuiLineField line;
private State state;
private TileLevelMaintainer.State state;
@SuppressWarnings("unchecked")
public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton submitBtn, GuiFCImgButton enableBtn,
GuiFCImgButton disableBtn, FCGuiLineField line, List buttonList) {
this.qty = qtyInput;
@@ -402,14 +295,14 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.disable = disableBtn;
this.submit = submitBtn;
this.line = line;
this.state = State.None;
this.state = TileLevelMaintainer.State.Nothing;
buttonList.add(this.submit);
buttonList.add(this.enable);
buttonList.add(this.disable);
}
public int getIndex() {
return this.qty.idx;
return this.getQty().idx;
}
public void setEnable(boolean enable) {
@@ -418,12 +311,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private boolean send(Widget widget) {
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (isGTNHLibLoaded) {
long value = (long) MathExpressionParser.parse(widget.textField.getText());
widget.textField.setText(String.valueOf(value));
}
if (!widget.textField.getText().isEmpty()
&& numberPattern.matcher(widget.textField.getText()).matches()) {
if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("^[0-9]+")) {
String str = widget.textField.getText().replaceAll("^(0+)", "");
widget.textField.setText(str.isEmpty() ? "0" : str);
FluidCraft.proxy.netHandler.sendToServer(
@@ -444,18 +332,20 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
if (this.send(this.getQty())) this.send(this.getBatch());
didSomething = true;
} else if (this.enable == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Enable, this.getIndex()));
FluidCraft.proxy.netHandler
.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex()));
didSomething = true;
} else if (this.disable == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Disable, this.getIndex()));
FluidCraft.proxy.netHandler
.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex()));
didSomething = true;
}
return didSomething;
}
public FCGuiTextField isMouseIn(final int xCoord, final int yCoord) {
if (this.qty.textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
if (this.batch.textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
if (this.getQty().textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
if (this.getBatch().textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
return null;
}
@@ -472,39 +362,33 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
public void draw() {
this.qty.draw();
this.batch.draw();
this.getQty().draw();
this.getBatch().draw();
ArrayList<String> message = new ArrayList<>();
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_TITLE) + "\n");
switch (this.state) {
case Idle -> {
this.line.setColor(FCGuiColors.StateIdle.getColor());
case Idling -> {
this.line.setColor(0xFF55FF55);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
}
case Craft -> {
this.line.setColor(FCGuiColors.StateCraft.getColor());
case Crafting -> {
this.line.setColor(0xFFFFFF55);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
}
case Export -> {
this.line.setColor(FCGuiColors.StateExport.getColor());
case Exporting -> {
this.line.setColor(0xFFAA00AA);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
}
case Error -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
}
default -> {
this.line.setColor(FCGuiColors.StateNone.getColor());
this.line.setColor(0);
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NONE));
}
}
@@ -515,9 +399,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR_DESC));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC));
} else {
message.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
@@ -533,7 +415,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
}
public void setState(State state) {
public void setState(TileLevelMaintainer.State state) {
this.state = state;
}
}
@@ -541,15 +423,15 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private class Widget {
public final int idx;
public final Action action;
public final String action;
private final FCGuiTextField textField;
private final String tooltip;
public Widget(FCGuiTextField textField, String tooltip, int idx, Action action) {
public Widget(FCGuiTextField textField, String tooltip, int idx, String action) {
this.textField = textField;
this.textField.setEnableBackgroundDrawing(false);
this.textField.setText("0");
this.textField.setMaxStringLength(16); // this length is enough to be useful
this.textField.setMaxStringLength(10); // this length is enough to useful
this.idx = idx;
this.action = action;
this.tooltip = tooltip;
File diff suppressed because it is too large. Load diff
@@ -1,24 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.client.gui.container.ContainerLevelWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.container.slot.AppEngSlot;
public class GuiLevelWireless extends GuiLevelTerminal {
public GuiLevelWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerLevelWireless(inventoryPlayer, te));
}
@Override
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof final AppEngSlot slot) {
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 4;
}
}
}
}
@@ -2,6 +2,7 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
@@ -66,16 +67,16 @@ public class GuiPatternValueAmount extends FCGuiAmount {
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
}
}
@@ -1,26 +1,14 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerRenamer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketRenamer;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.core.localization.GuiColors;
@@ -28,52 +16,20 @@ import appeng.core.localization.GuiText;
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
protected final MEGuiTextField textField;
protected final ITerminalHost host;
protected GuiTabButton originalGuiBtn;
protected ItemStack icon = null;
protected GuiType originalGui;
private final MEGuiTextField textField;
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(new ContainerRenamer(ip, monitorable));
this.host = monitorable;
this.xSize = 256;
this.textField = new MEGuiTextField(230, 12);
this.textField.setMaxStringLength(32);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
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(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 231,
this.guiTop - 4,
this.icon,
this.icon.getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13);
}
this.textField.x = this.guiLeft + 12;
this.textField.y = this.guiTop + 35;
this.textField.setFocused(true);
@@ -99,7 +55,7 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
@Override
protected void keyTyped(final char character, final int key) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
if (key == 28) { // Enter
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(this.textField.getText()));
} else if (!this.textField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
@@ -110,21 +66,6 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
return textField.isMouseIn(mousex, mousey);
}
@Override
protected void actionPerformed(GuiButton button) {
if (button == originalGuiBtn) {
switchGui();
} else {
super.actionPerformed(button);
}
}
public void switchGui() {
if (originalGui != null) {
InventoryHandler.switchGui(originalGui);
}
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
textField.setText(displayName);
}
@@ -7,14 +7,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import com.glodblock.github.client.gui.GuiEssentiaTerminal;
import com.glodblock.github.client.gui.GuiFCImgButton;
import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
import com.glodblock.github.client.gui.GuiFluidPatternExWireless;
import com.glodblock.github.client.gui.GuiFluidPatternWireless;
import com.glodblock.github.client.gui.GuiFluidPortableCell;
import com.glodblock.github.client.gui.GuiInterfaceWireless;
import com.glodblock.github.client.gui.GuiLevelWireless;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
@@ -30,8 +23,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
protected GuiFCImgButton PatternTerminal;
protected GuiFCImgButton EssentiaTerminal;
protected GuiFCImgButton InterfaceTerminal;
protected GuiFCImgButton LevelTerminal;
protected GuiFCImgButton PatternTerminalEx;
protected GuiFCImgButton PatternTerminaleEx;
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
protected boolean drawSwitchGuiBtn;
@@ -89,13 +81,13 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
}
if (!(this instanceof GuiFluidPatternExWireless)) {
this.buttonList.add(
this.PatternTerminalEx = new GuiFCImgButton(
this.PatternTerminaleEx = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"PATTERN_EX_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminalEx);
termBtns.add(this.PatternTerminaleEx);
}
if (!(this instanceof GuiFluidPortableCell)) {
this.buttonList.add(
@@ -103,7 +95,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.FluidTerminal);
}
if (!(this instanceof GuiInterfaceWireless)) {
if (!(this instanceof GuiInterfaceTerminalWireless)) {
this.buttonList.add(
this.InterfaceTerminal = new GuiFCImgButton(
this.guiLeft - 18,
@@ -113,12 +105,6 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.InterfaceTerminal);
}
if (!(this instanceof GuiLevelWireless)) {
this.buttonList.add(
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.LevelTerminal);
}
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
this.buttonList.add(
this.EssentiaTerminal = new GuiFCImgButton(
@@ -131,7 +117,6 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
}
}
@SuppressWarnings("unchecked")
protected void addSwitchGuiBtns() {
if (!drawSwitchGuiBtn) return;
this.buttonList.addAll(termBtns);
@@ -150,9 +135,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
} else if (btn == this.InterfaceTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
} else if (btn == this.LevelTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_LEVEL_TERMINAL);
} else if (btn == this.PatternTerminalEx) {
} else if (btn == this.PatternTerminaleEx) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
}
}
@@ -5,10 +5,9 @@ import net.minecraft.client.gui.GuiTextField;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
@@ -42,11 +41,10 @@ public abstract class FCGuiAmount extends AEBaseGui {
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
final int a = getIncrementQuantity(0);
final int b = getIncrementQuantity(1);
final int c = getIncrementQuantity(2);
final int d = getIncrementQuantity(3);
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
@@ -65,12 +63,11 @@ public abstract class FCGuiAmount extends AEBaseGui {
if (this.originalGui != null && this.myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 151,
this.guiTop - 4,
this.guiLeft + 154,
this.guiTop,
this.myIcon,
this.myIcon.getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13);
}
this.amountBox = new GuiTextField(
@@ -86,10 +83,6 @@ public abstract class FCGuiAmount extends AEBaseGui {
this.amountBox.setFocused(true);
}
protected int getIncrementQuantity(int i) {
return AEConfig.instance.craftItemsByStackAmounts(i);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(getBackground());
@@ -99,7 +92,7 @@ public abstract class FCGuiAmount extends AEBaseGui {
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
if (key == 28) {
this.actionPerformed(this.submit);
}
this.amountBox.textboxKeyTyped(character, key);
@@ -111,7 +104,7 @@ public abstract class FCGuiAmount extends AEBaseGui {
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.originalGuiBtn) {
InventoryHandler.switchGui(originalGui);
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10
@@ -5,7 +5,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFCImgButton;
@@ -16,6 +15,7 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.storage.ITerminalHost;
@@ -23,6 +23,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotFake;
import appeng.util.item.AEItemStack;
@@ -53,6 +54,7 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
protected GuiFCImgButton autoFillPatternEnableBtn;
protected GuiFCImgButton autoFillPatternDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public FCGuiEncodeTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te,
final FCContainerEncodeTerminal c) {
@@ -182,15 +184,13 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
} else return true;
aeRenderItem.setAeStack(fake);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
@@ -16,8 +16,7 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.FCGuiTextField;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -25,11 +24,7 @@ import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.config.CraftingStatus;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@@ -37,23 +32,12 @@ import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IDisplayRepo;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.*;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.container.AEBaseContainer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm;
import appeng.container.slot.SlotDisabled;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.*;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
@@ -101,8 +85,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
protected GuiImgButton terminalStyleBox;
protected GuiImgButton searchStringSave;
protected GuiImgButton typeFilter;
protected boolean hasShiftKeyDown = false;
private boolean reInitializationRequested = false;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
@@ -169,7 +151,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
protected void reInitalize() {
reInitializationRequested = true;
this.buttonList.clear();
this.initGui();
}
@Override
@@ -183,7 +166,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = hasNEI ? 1 : 0;
final int NEI = 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
@@ -217,7 +200,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
super.initGui();
this.setScrollBar();
// full size : 204
// extra slots : 72
// slot 18
@@ -668,11 +650,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
@Override
public void updateScreen() {
if (reInitializationRequested) {
reInitializationRequested = false;
this.buttonList.clear();
this.initGui();
}
this.repo.setPowered(this.monitorableContainer.isPowered());
super.updateScreen();
}
@@ -13,7 +13,7 @@ import appeng.helpers.IInterfaceHost;
public class ContainerDualInterface extends ContainerInterface {
@GuiSync(11)
@GuiSync(10)
public SidelessMode sidelessMode;
private final boolean isTile;
@@ -1,6 +1,7 @@
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;
@@ -22,6 +23,7 @@ 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 {
@@ -35,118 +37,110 @@ 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(index));
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
}
}
return super.transferStackInSlot(p, idx);
}
@Override
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;
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;
}
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);
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++;
}
}
if (slotIndex == -1) out.stackSize = targetStack.stackSize - out.stackSize;
} else if (drainStack != null) {
if (slotIndex == -1) {
out.stackSize = targetStack.stackSize;
} else {
out.stackSize = (int) (targetStack.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
} 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());
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
}
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);
continue;
}
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);
}
} else {
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
}
this.detectAndSendChanges();
}
@@ -9,21 +9,14 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerCraftConfirm;
import appeng.container.implementations.ContainerOptimizePatterns;
import appeng.crafting.v2.CraftingJobV2;
import appeng.tile.misc.TilePatternOptimizationMatrix;
public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
@@ -42,9 +35,6 @@ public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (ah instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
}
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
@@ -67,34 +57,4 @@ public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
originalGui);
}
}
@Override
public void optimizePatterns() {
// only V2 supported
IGrid grid = Ae2Reflect.getGrid(this);
ICraftingJob result = Ae2Reflect.getResult(this);
if (result instanceof CraftingJobV2 && !this.isSimulation()
&& grid != null
&& !grid.getMachines(TilePatternOptimizationMatrix.class).isEmpty()) {
final IActionHost ah = this.getActionHost();
if (ah instanceof IWirelessTerminal) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
GuiType.FLUID_OPTIMIZE_PATTERNS_ITEM);
} else if (this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
GuiType.FLUID_OPTIMIZE_PATTERNS);
}
if (this.getPlayerInv().player.openContainer instanceof ContainerOptimizePatterns cop) {
cop.setResult(result);
}
}
}
}
@@ -10,9 +10,7 @@ import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.*;
import appeng.api.implementations.IUpgradeableHost;
import appeng.container.guisync.GuiSync;
import appeng.tile.inventory.AppEngInternalAEInventory;
@@ -3,6 +3,7 @@ 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;
@@ -12,12 +13,11 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
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.ItemFluidPacket;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
@@ -43,22 +43,11 @@ 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> {
protected final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
/**
* Index of tuple which indicates remaining tanks that are remaining (not emptied/filled)
*/
protected static final int REM_IDX = 0;
/**
* Index of tuple which indicates remaining tanks that are acted upon (emptied/filled)
*/
protected static final int ACT_IDX = 1;
/**
* Index of tuple which indicates tanks that are partially emptied/filled
*/
protected static final int PARTIAL_IDX = 2;
public ContainerFluidMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
@@ -122,8 +111,11 @@ 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(index));
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
}
}
return super.transferStackInSlot(p, idx);
@@ -206,189 +198,130 @@ 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(IAEFluidStack fluid, EntityPlayer player, int slotIndex, boolean shift) {
ItemStack targetStack;
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player,
int slotIndex) {
int cursorItems;
if (slotIndex == -1) {
targetStack = player.inventory.getItemStack();
cursorItems = player.inventory.getItemStack().stackSize;
} else {
targetStack = player.inventory.getStackInSlot(slotIndex);
cursorItems = player.inventory.getStackInSlot(slotIndex).stackSize;
}
// 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
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)
}
// No op (Any other situation)
this.detectAndSendChanges();
}
/**
* The insert operation. For input, we have a filled container stack. For outputs, we have the following:
* <ol>
* <li>Leftover filled container stack</li>
* <li>Empty containers</li>
* <li>Partially filled container x1</li>
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
* The insert operation. For input, we have a filled container stack. For outputs, we have the following: 1.
* Leftover filled container stack - primary output. 2. Empty containers 3. Partially filled container x1 In order
* above, the itemstack at `slotIndex` is transformed into the output.
*/
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;
// 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;
fluidStackPerContainer = fcItem.drain(test, Integer.MAX_VALUE, false);
if (fluidStackPerContainer == null || fluidStackPerContainer.amount == 0) {
return;
}
fluidPerContainer = fluidStackPerContainer.amount;
partialInsertSupported = true;
} else if (FluidContainerRegistry.isContainer(targetStack)) {
ItemStack emptyTank = FluidContainerRegistry.drainFluidContainer(targetStack);
if (emptyTank == null) {
return;
}
fluidStackPerContainer = FluidContainerRegistry.getFluidForFilledItem(targetStack);
fluidPerContainer = fluidStackPerContainer.amount;
partialInsertSupported = false;
private void insertFluid(ItemStack fluidContainer, EntityPlayer player, int slotIndex, int heldContainers) {
IAEFluidStack fluid;
int fluidInTank;
if (fluidContainer.getItem() instanceof IFluidContainerItem) {
fluid = AEFluidStack.create(((IFluidContainerItem) fluidContainer.getItem()).getFluid(fluidContainer));
fluidInTank = (int) fluid.getStackSize();
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
fluid = AEFluidStack.create(FluidContainerRegistry.getFluidForFilledItem(fluidContainer));
fluidInTank = (int) fluid.getStackSize();
} 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;
// Simulate to know how much will not be inserted
IAEFluidStack canSend = fluid.copy();
canSend.setStackSize((long) fluidInTank * fluidContainer.stackSize);
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(totalFluid, Actionable.MODULATE, this.getActionSource());
.injectItems(canSend, Actionable.MODULATE, this.getActionSource());
int emptyTanks = fluidContainer.stackSize;
ItemStack partialStack = fluidContainer.copy();
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;
// Here, we cannot insert everything into the system.
if (canSend.getStackSize() == notInserted.getStackSize()) return; // System was full, no op
// Now "refill" the buckets that couldn't enter the system
int refilled = (int) (notInserted.getStackSize() / fluidInTank); // # of full tanks left
emptyTanks -= refilled;
final int remainder = (int) (notInserted.getStackSize() % fluidInTank); // partial tank
// Now handle remaining if applicable
if (remainder > 0) {
notInserted.setStackSize(remainder);
partialStack.stackSize = 1;
if (partialStack.getItem() instanceof IFluidContainerItem) {
((IFluidContainerItem) partialStack.getItem()).drain(partialStack, fluidInTank - remainder, true);
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
// For "whole containers" (need to round down, no remainders)
ItemStack container = FluidContainerRegistry
.fillFluidContainer(notInserted.getFluidStack(), fluidContainer);
if (container == null) {
// whatever, lets just not have the ME system get filled with any of its fluid
emptyTanks++;
notInserted.setStackSize(fluidInTank - remainder);
this.host.getFluidInventory()
.extractItems(notInserted, Actionable.MODULATE, this.getActionSource());
partialStack.stackSize = 0;
} else {
partialStack = container;
}
}
emptyTanks -= partialStack.stackSize;
} 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;
partialStack.stackSize = 0;
}
} else {
totalInserted = totalFluid.getStackSize();
partialStack.stackSize = 0;
}
// Step 4: calculate outputs
final int emptiedTanks;
final int partialDrain;
if (fluidPerContainer > 0) {
emptiedTanks = (int) (totalInserted / fluidPerContainer);
partialDrain = (int) (totalInserted % fluidPerContainer);
// Now that the 3 outputs are handled, we can now actually put the fluids in
ItemStack emptyStack = fluidContainer.copy();
emptyStack.stackSize = 1;
if (emptyStack.getItem() instanceof IFluidContainerItem) {
((IFluidContainerItem) emptyStack.getItem()).drain(emptyStack, fluidInTank, true);
} else {
emptiedTanks = containersRequestedToInsert;
partialDrain = 0;
emptyStack = FluidContainerRegistry.drainFluidContainer(emptyStack);
}
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;
}
emptyStack.stackSize = emptyTanks;
int extraTanks = heldContainers - emptyTanks - partialStack.stackSize;
// Done. Put the output in the inventory or ground, and update stack size.
boolean shouldSendStack = true;
if (slotIndex == -1) {
// Item is in mouse hand
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);
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.stackSize != 0) {
player.inventory.setItemStack(partialStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
}
} else {
// Shift clicked in
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);
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.stackSize != 0) {
player.inventory.setInventorySlotContents(slotIndex, partialStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
@@ -400,131 +333,104 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
(EntityPlayerMP) player);
} else {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
}
/**
* The extract operation. For input, we have an empty container stack. For outputs, we have the following:
* <ol>
* <li>Leftover empty container stack</li>
* <li>Filled containers (full)</li>
* <li>Partially filled container x1</li>
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
* The extract operation. For input, we have an empty container stack. For outputs, we have the following: 1.
* Leftover empty container stack - primary output. 2. Filled containers (full) 3. Partially filled container x1 In
* order above, the itemstack at `slotIndex` is transformed into the output.
*/
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;
fluidPerContainer = fcItem.fill(testStack, clientRequestedFluidStack, false);
if (fluidPerContainer == 0) {
return;
}
partialInsertSupported = true;
} else if (FluidContainerRegistry.isContainer(targetStack)) {
fluidPerContainer = FluidContainerRegistry.getContainerCapacity(clientRequestedFluidStack, targetStack);
partialInsertSupported = false;
private void extractFluid(IAEFluidStack fluid, ItemStack fluidContainer, EntityPlayer player, int heldContainers) {
IAEFluidStack storedFluid = this.monitor.getStorageList().findPrecise(fluid);
if (storedFluid == null || storedFluid.getStackSize() <= 0) return;
int capacity;
if (fluidContainer.getItem() instanceof IFluidContainerItem) {
capacity = ((IFluidContainerItem) fluidContainer.getItem()).getCapacity(fluidContainer);
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
// Fill with fluid container registry, or abort if it failed
ItemStack dummy = FluidContainerRegistry.fillFluidContainer(storedFluid.getFluidStack(), fluidContainer);
capacity = FluidContainerRegistry.getContainerCapacity(dummy);
} else {
return;
}
// 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;
}
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;
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.SIMULATE, 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 {
filledTanksStack = null;
// Should not be NPE since we affirmed that we have enough capacity.
filledStack = FluidContainerRegistry.fillFluidContainer(actualExtract.getFluidStack(), filledStack);
assert capacity == FluidContainerRegistry.getContainerCapacity(filledStack);
}
if (partialTanks > 0) {
partialTanksStack = targetStack.copy();
partialTanksStack.stackSize = 1;
FluidStack toInsert = extracted.getFluidStack().copy();
toInsert.amount = partialFill;
fcItem.fill(partialTanksStack, toInsert, true);
filledStack.stackSize = filledTanks;
} else {
filledStack.stackSize = 0;
}
// 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--;
} else {
partialTanksStack = null;
ItemStack dummy = FluidContainerRegistry
.fillFluidContainer(actualExtract.getFluidStack(), partialStack);
if (dummy == null) {
// Failed to fill partial...
partialStack.stackSize = 0;
toExtract -= remainder;
} else {
partialStack = dummy;
toExtract -= FluidContainerRegistry.getContainerCapacity(partialStack);
emptyTanks--;
}
}
} else {
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;
partialStack.stackSize = 0;
}
// Now perform the real extraction.
actualExtract.setStackSize(toExtract);
this.host.getFluidInventory().extractItems(canExtract, Actionable.MODULATE, this.getActionSource());
// 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 (untouchedTanks > 0) {
if (emptyTanks > 0) {
ItemStack emptyStack = player.inventory.getItemStack();
emptyStack.stackSize = untouchedTanks;
emptyStack.stackSize = emptyTanks;
adjustStack(emptyStack);
dropItem(filledTanksStack);
dropItem(partialTanksStack);
} else if (filledTanksStack != null) {
adjustStack(filledTanksStack);
player.inventory.setItemStack(filledTanksStack);
dropItem(partialTanksStack);
} else if (partialTanksStack != null) {
player.inventory.setItemStack(partialTanksStack);
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);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
@@ -535,11 +441,13 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
(EntityPlayerMP) player);
} else {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
}
void adjustStack(ItemStack stack) {
if (stack != null && stack.stackSize > stack.getMaxStackSize()) {
if (stack.stackSize > stack.getMaxStackSize()) {
dropItem(stack, stack.stackSize - stack.getMaxStackSize());
stack.stackSize = stack.getMaxStackSize();
}
@@ -1,69 +0,0 @@
package com.glodblock.github.client.gui.container;
import java.util.Objects;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerOptimizePatterns;
public class ContainerFluidOptimizePatterns extends ContainerOptimizePatterns {
public ContainerFluidOptimizePatterns(InventoryPlayer ip, ITerminalHost te) {
super(ip, te);
}
public World getWorld() {
return this.getPlayerInv().player.worldObj;
}
@Override
public void switchToOriginalGUI() {
GuiType originalGui = null;
final IActionHost ah = this.getActionHost();
if (ah instanceof PartFluidPatternTerminal) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (ah instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
}
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
originalGui = ((ItemBaseWirelessTerminal) terminal.getItem()).guiGuiType(terminal);
}
}
if (ah instanceof IWirelessTerminal) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
originalGui);
} else if (this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
}
}
}
@@ -12,11 +12,7 @@ import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.Upgrades;
import appeng.api.config.*;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
@@ -1,27 +1,75 @@
package com.glodblock.github.client.gui.container;
import java.io.IOException;
import java.util.*;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.api.config.*;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketCompressedNBT;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.parts.AEBasePart;
import appeng.parts.misc.PartInterface;
import appeng.parts.p2p.PartP2PInterface;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.TileInterface;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorIInventory;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.ItemSlot;
import appeng.util.inv.WrapperInvSlot;
public class ContainerInterfaceWireless extends FCBaseContainer {
ContainerInterfaceTerminal delegateContainer;
/**
* this stuff is all server side
*/
private static long autoBase = Long.MIN_VALUE;
private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<>();
private IGrid grid;
private NBTTagCompound data = new NBTTagCompound();
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable);
delegateContainer = new ContainerInterfaceTerminal(ip, monitorable);
if (Platform.isServer()) {
this.grid = monitorable.getActionableNode().getGrid();
}
this.bindPlayerInventory(ip, 14, 0);
}
private Set<IGridNode> getMachineNodes() {
Set<IGridNode> union = new HashSet<>();
this.grid.getMachines(TileFluidInterface.class).forEach(union::add);
this.grid.getMachines(TileInterface.class).forEach(union::add);
this.grid.getMachines(PartFluidInterface.class).forEach(union::add);
this.grid.getMachines(PartInterface.class).forEach(union::add);
this.grid.getMachines(PartP2PInterface.class).forEach(union::add);
return union;
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
@@ -29,16 +77,341 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
}
super.detectAndSendChanges();
delegateContainer.detectAndSendChanges();
if (this.grid == null) {
return;
}
int total = 0;
boolean missing = false;
final IActionHost host = this.getActionHost();
if (host != null) {
final IGridNode agn = host.getActionableNode();
if (agn != null && agn.isActive()) {
for (final IGridNode gn : this.getMachineNodes()) {
ContainerInterfaceWireless.InterfaceCheck interfaceCheck = new ContainerInterfaceWireless.InterfaceCheck()
.invoke(gn);
total += interfaceCheck.getTotal();
missing |= interfaceCheck.isMissing();
}
}
}
if (total != this.diList.size() || missing) {
this.regenList(this.data);
} else {
for (final ContainerInterfaceWireless.InvTracker inv : diList.values()) {
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
this.addItems(this.data, inv, x, 1);
}
}
}
}
if (!this.data.hasNoTags()) {
try {
NetworkHandler.instance
.sendTo(new PacketCompressedNBT(this.data), (EntityPlayerMP) this.getPlayerInv().player);
} catch (final IOException ignored) {}
this.data = new NBTTagCompound();
}
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slot, final long id) {
delegateContainer.doAction(player, action, slot, id);
final ContainerInterfaceWireless.InvTracker inv = this.byId.get(id);
if (inv != null) {
final ItemStack is = inv.server.getStackInSlot(slot + inv.offset);
final boolean hasItemInHand = player.inventory.getItemStack() != null;
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
final WrapperInvSlot slotInv = new ContainerInterfaceWireless.PatternInvSlot(inv.server);
final IInventory theSlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor interfaceSlot = new AdaptorIInventory(theSlot);
IInventory interfaceHandler = inv.server;
boolean canInsert = true;
switch (action) {
case PICKUP_OR_SET_DOWN -> {
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
interfaceHandler.getStackInSlot(s),
player.inventory.getItemStack())) {
canInsert = false;
break;
}
}
if (canInsert) {
ItemStack inSlot = theSlot.getStackInSlot(0);
if (inSlot == null) {
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
} else {
inSlot = inSlot.copy();
final ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents(0, null);
player.inventory.setItemStack(null);
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
if (player.inventory.getItemStack() == null) {
player.inventory.setItemStack(inSlot);
} else {
player.inventory.setItemStack(inHand);
theSlot.setInventorySlotContents(0, inSlot);
}
}
}
} else {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
mySlot.setInventorySlotContents(0, playerHand.addItems(mySlot.getStackInSlot(0)));
}
}
case SPLIT_OR_PLACE_SINGLE -> {
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
interfaceHandler.getStackInSlot(s),
player.inventory.getItemStack())) {
canInsert = false;
break;
}
}
if (canInsert) {
ItemStack extra = playerHand.removeItems(1, null, null);
if (extra != null && !interfaceSlot.containsItems()) {
extra = interfaceSlot.addItems(extra);
}
if (extra != null) {
playerHand.addItems(extra);
}
}
} else if (is != null) {
ItemStack extra = interfaceSlot.removeItems((is.stackSize + 1) / 2, null, null);
if (extra != null) {
extra = playerHand.addItems(extra);
}
if (extra != null) {
interfaceSlot.addItems(extra);
}
}
}
case SHIFT_CLICK -> {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
mySlot.setInventorySlotContents(0, mergeToPlayerInventory(playerInv, mySlot.getStackInSlot(0)));
}
case MOVE_REGION -> {
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
inv.server.setInventorySlotContents(
x + inv.offset,
mergeToPlayerInventory(playerInvAd, inv.server.getStackInSlot(x + inv.offset)));
}
}
case CREATIVE_DUPLICATE -> {
if (player.capabilities.isCreativeMode && !hasItemInHand) {
player.inventory.setItemStack(is == null ? null : is.copy());
}
}
default -> {
return;
}
}
this.updateHeld(player);
}
}
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
if (stack == null) return null;
for (ItemSlot slot : playerInv) {
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
++slot.getItemStack().stackSize;
return null;
}
}
}
return playerInv.addItems(stack);
}
private void regenList(final NBTTagCompound data) {
this.byId.clear();
this.diList.clear();
final IActionHost host = this.getActionHost();
if (host != null) {
final IGridNode agn = host.getActionableNode();
if (agn != null && agn.isActive()) {
for (final IGridNode gn : this.getMachineNodes()) {
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
final DualityInterface dual = ih.getInterfaceDuality();
if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) {
for (int i = 0; i <= dual.getInstalledUpgrades(Upgrades.PATTERN_CAPACITY); ++i) {
this.diList.put(
ih,
new ContainerInterfaceWireless.InvTracker(
dual,
dual.getPatterns(),
dual.getTermName(),
i * 9,
9));
}
}
}
}
}
data.setBoolean("clear", true);
for (final ContainerInterfaceWireless.InvTracker inv : this.diList.values()) {
this.byId.put(inv.which, inv);
this.addItems(data, inv, 0, inv.client.getSizeInventory());
}
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
private boolean isDifferent(final ItemStack a, final ItemStack b) {
if (a == null && b == null) {
return false;
}
if (a == null || b == null) {
return true;
}
return !ItemStack.areItemStacksEqual(a, b);
}
private void addItems(final NBTTagCompound data, final ContainerInterfaceWireless.InvTracker inv, final int offset,
final int length) {
final String name = '=' + Long.toString(inv.which, Character.MAX_RADIX);
final NBTTagCompound tag = data.getCompoundTag(name);
if (tag.hasNoTags()) {
tag.setLong("sortBy", inv.sortBy);
tag.setString("un", inv.unlocalizedName);
tag.setInteger("x", inv.X);
tag.setInteger("y", inv.Y);
tag.setInteger("z", inv.Z);
tag.setInteger("dim", inv.dim);
tag.setInteger("side", inv.side.ordinal());
}
for (int x = 0; x < length; x++) {
final NBTTagCompound itemNBT = new NBTTagCompound();
final ItemStack is = inv.server.getStackInSlot(x + offset + inv.offset);
// "update" client side.
inv.client.setInventorySlotContents(offset + x, is == null ? null : is.copy());
if (is != null) {
is.writeToNBT(itemNBT);
}
tag.setTag(Integer.toString(x + offset), itemNBT);
}
data.setTag(name, tag);
}
private static class InvTracker {
private final long sortBy;
private final long which = autoBase++;
private final String unlocalizedName;
private final IInventory client;
private final IInventory server;
private final int offset;
private final int X;
private final int Y;
private final int Z;
private final int dim;
private final ForgeDirection side;
public InvTracker(final DualityInterface dual, final IInventory patterns, final String unlocalizedName,
int offset, int size) {
this.server = patterns;
this.client = new AppEngInternalInventory(null, size);
this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue() + offset << 16;
this.offset = offset;
X = dual.getLocation().x;
Y = dual.getLocation().y;
Z = dual.getLocation().z;
dim = dual.getLocation().getDimension();
if (dual.getHost() instanceof AEBasePart) {
side = ((AEBasePart) dual.getHost()).getSide();
} else {
side = ForgeDirection.UNKNOWN;
}
}
}
private static class PatternInvSlot extends WrapperInvSlot {
public PatternInvSlot(final IInventory inv) {
super(inv);
}
@Override
public boolean isItemValid(final ItemStack itemstack) {
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
}
}
private class InterfaceCheck {
int total = 0;
boolean missing = false;
public InterfaceCheck() {}
public int getTotal() {
return total;
}
public boolean isMissing() {
return missing;
}
public ContainerInterfaceWireless.InterfaceCheck invoke(IGridNode gn) {
if (gn.isActive()) {
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO
|| ih instanceof PartP2PInterface && ((PartP2PInterface) ih).isOutput()) {
return this;
}
final Collection<ContainerInterfaceWireless.InvTracker> t = ContainerInterfaceWireless.this.diList
.get(ih);
if (t.isEmpty()) {
missing = true;
} else {
final DualityInterface dual = ih.getInterfaceDuality();
for (ContainerInterfaceWireless.InvTracker it : t) {
if (!it.unlocalizedName.equals(dual.getTermName())) {
missing = true;
}
}
}
total += (ih.getInterfaceDuality().getInstalledUpgrades(Upgrades.PATTERN_CAPACITY) + 1);
}
return this;
}
}
}
@@ -1,25 +1,16 @@
package com.glodblock.github.client.gui.container;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.util.Util;
import appeng.api.config.SecurityPermissions;
import appeng.container.AEBaseContainer;
import appeng.helpers.InventoryAction;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class ContainerLevelMaintainer extends AEBaseContainer {
@@ -46,111 +37,15 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
return this.requestSlots;
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
Slot slot = getSlot(slotId);
if (slot instanceof SlotFluidConvertingFake) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN -> {
if (stack == null) {
slot.putStack(null);
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(createLevelValues(stack.copy()));
}
}
case PLACE_SINGLE -> {
if (stack != null) {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
}
case SPLIT_OR_PLACE_SINGLE -> {
ItemStack inSlot = slot.getStack();
if (inSlot != null) {
if (stack == null) {
slot.putStack(
createLevelValues(
Objects.requireNonNull(
Util.copyStackWithSize(
inSlot,
Math.max(1, inSlot.stackSize - 1)))));
} else if (stack.isItemEqual(inSlot)) {
slot.putStack(
createLevelValues(
Objects.requireNonNull(
Util.copyStackWithSize(
inSlot,
Math.min(
inSlot.getMaxStackSize(),
inSlot.stackSize + 1)))));
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
} else if (stack != null) {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
}
}
} else {
super.doAction(player, action, slotId, id);
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
if (Platform.isClient()) {
return null;
}
for (int i = 0; i < this.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.getRequestSlots()[i];
for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
if (!slot.getHasStack()) {
ItemStack itemStack = ((Slot) this.inventorySlots.get(idx)).getStack();
ItemStack configuration = createLevelValues(itemStack.copy());
configuration.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putConvertedStack(configuration);
slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true);
break;
}
}
this.detectAndSendChanges();
return null;
}
@Override
public void detectAndSendChanges() {
this.verifyPermissions(SecurityPermissions.BUILD, false);
super.detectAndSendChanges();
}
public static ItemStack createLevelValues(ItemStack itemStack) {
var data = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
if (!data.hasKey(TLMTags.Stack.tagName)) {
var itemStackTag = new NBTTagCompound();
itemStack.copy().writeToNBT(itemStackTag);
data.setTag(TLMTags.Stack.tagName, itemStackTag);
}
if (!data.hasKey(TLMTags.Quantity.tagName)) {
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize > 0 ? itemStack.stackSize : 1);
}
if (!data.hasKey(TLMTags.Batch.tagName)) {
data.setLong(TLMTags.Batch.tagName, 1);
}
if (!data.hasKey(TLMTags.Enable.tagName)) {
data.setBoolean(TLMTags.Enable.tagName, false);
}
if (data.hasKey(TLMTags.Index.tagName)) {
data.removeTag(TLMTags.Index.tagName);
}
data.setInteger(TLMTags.State.tagName, State.None.ordinal());
itemStack.setTagCompound(data);
return itemStack;
}
}
@@ -1,406 +0,0 @@
package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
import com.google.common.primitives.Ints;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.api.util.DimensionalCoord;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.ItemSlot;
public class ContainerLevelTerminal extends FCBaseContainer {
/**
* this stuff is all server side
*/
private int nextId = 0;
private final Map<IGridHost, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
private IGrid grid;
private SPacketLevelTerminalUpdate dirty;
private boolean isDirty;
private boolean wasOff;
private int ticks = 0;
public ContainerLevelTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
if (Platform.isServer()) {
if (monitorable instanceof PartLevelTerminal terminal) {
grid = terminal.getActionableNode().getGrid();
} else if (monitorable instanceof IWirelessTerminal wirelessTerminal) {
grid = wirelessTerminal.getActionableNode().getGrid();
}
dirty = this.updateList();
if (dirty != null) {
this.isDirty = true;
} else {
dirty = new SPacketLevelTerminalUpdate();
}
}
this.bindPlayerInventory(ip, 14, 0);
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
super.detectAndSendChanges();
if (this.grid == null) {
return;
}
final IActionHost host = this.getActionHost();
if (!host.getActionableNode().isActive()) {
if (!wasOff) {
SPacketLevelTerminalUpdate update = new SPacketLevelTerminalUpdate();
update.setDisconnect();
wasOff = true;
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
return;
}
wasOff = false;
if (isDirty) {
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) this.getPlayerInv().player);
dirty = new SPacketLevelTerminalUpdate();
isDirty = false;
} else if (++ticks % 20 == 0) {
ticks = 0;
SPacketLevelTerminalUpdate update = this.updateList();
if (update != null) {
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
}
}
/**
* Merge from slot -> player inv. Returns the items not added.
*/
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
if (stack == null) return null;
for (ItemSlot slot : playerInv) {
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
++slot.getItemStack().stackSize;
return null;
}
}
}
return playerInv.addItems(stack);
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slotIdx, final long id) {
final ContainerLevelTerminal.InvTracker invTracker = this.trackedById.get(id);
if (invTracker != null) {
final ItemStack handStack = player.inventory.getItemStack();
if (handStack != null && !(handStack.getItem() instanceof ItemEncodedPattern)) {
// Why even bother if we're not dealing with an encoded pattern in hand
return;
}
final ItemStack slotStack = invTracker.requests.getStackInSlot(slotIdx);
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
switch (action) {
/* Set down/pickup. This is the same as SPLIT_OR_PLACE_SINGLE as our max stack sizes are 1 in slots. */
case PICKUP_OR_SET_DOWN -> {
if (handStack != null) {
for (int s = 0; s < invTracker.requests.getSizeInventory(); s++) {
/* Is there a duplicate pattern here? */
if (Platform.isSameItemPrecise(invTracker.requests.getStackInSlot(s), handStack)) {
/* We're done here - dupe found. */
return;
}
}
}
if (slotStack == null) {
/* Insert to container, if valid */
if (handStack == null) {
/* Nothing happens */
return;
}
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
} else {
/* Exchange? */
if (handStack != null && handStack.stackSize > 1) {
/* Exchange is impossible, abort */
return;
}
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
playerHand.addItems(slotStack.copy());
}
syncLevelTerminalSlot(invTracker, id, slotIdx, invTracker.requests.getStackInSlot(slotIdx));
}
/* Shift click from slotIdx -> player. Player -> slotIdx is not supported. */
case SHIFT_CLICK -> {
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player.inventory, ForgeDirection.UNKNOWN);
ItemStack leftOver = mergeToPlayerInventory(playerInv, slotStack);
if (leftOver == null) {
invTracker.requests.setInventorySlotContents(slotIdx, null);
syncLevelTerminalSlot(invTracker, id, slotIdx, null);
}
}
/* Move all blank patterns -> player */
case MOVE_REGION -> {
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
List<Integer> valid = new ArrayList<>();
for (int i = 0; i < invTracker.requests.getSizeInventory(); i++) {
ItemStack toExtract = invTracker.requests.getStackInSlot(i);
if (toExtract == null) {
continue;
}
ItemStack leftOver = mergeToPlayerInventory(playerInv, toExtract);
if (leftOver != null) {
break;
} else {
invTracker.requests.setInventorySlotContents(i, null);
}
valid.add(i);
}
if (!valid.isEmpty()) {
int[] validIndices = Ints.toArray(valid);
NBTTagList tag = new NBTTagList();
for (int i = 0; i < valid.size(); ++i) {
tag.appendTag(new NBTTagCompound());
}
dirty.addOverwriteEntry(id).setItems(validIndices, tag);
isDirty = true;
}
}
case CREATIVE_DUPLICATE -> {
if (player.capabilities.isCreativeMode) {
playerHand.addItems(handStack);
}
}
default -> {
return;
}
}
this.updateHeld(player);
}
}
private void syncLevelTerminalSlot(ContainerLevelTerminal.InvTracker inv, long id, int slot, ItemStack stack) {
int[] validIndices = { slot };
NBTTagList list = new NBTTagList();
NBTTagCompound item = new NBTTagCompound();
if (stack != null) {
stack.writeToNBT(item);
}
list.appendTag(item);
inv.updateNBT();
this.dirty.addOverwriteEntry(id).setItems(validIndices, list);
this.isDirty = true;
}
private SPacketLevelTerminalUpdate updateList() {
SPacketLevelTerminalUpdate update = null;
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
Set<IGridHost> visited = new HashSet<>();
for (Class<? extends ILevelViewable> clz : supported) {
boolean isAdopted = LevelTerminalRegistry.instance().isAdopted(clz);
Class<? extends IGridHost> machineClass = isAdopted ? LevelTerminalRegistry.instance().getAdopted(clz)
: clz;
for (IGridNode gridNode : grid.getMachines(machineClass)) {
final IGridHost gridHost = gridNode.getMachine();
final ILevelViewable machine = isAdopted
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridHost)
: (ILevelViewable) gridHost;
/* First check if we are already tracking this node */
if (tracked.containsKey(gridHost)) {
/* Check for updates */
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(gridHost);
/* Name changed? */
String name = machine.getCustomName();
if (!Objects.equals(knownTracker.name, name)) {
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addRenamedEntry(knownTracker.id, name);
knownTracker.name = name;
}
/* Status changed? */
boolean isActive = gridNode.isActive() || machine.shouldDisplay();
if (!knownTracker.online && isActive) {
/* Node offline -> online */
knownTracker.online = true;
if (update == null) update = new SPacketLevelTerminalUpdate();
knownTracker.updateNBT();
update.addOverwriteEntry(knownTracker.id).setOnline(true)
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
} else if (knownTracker.online && !isActive) {
/* Node online -> offline */
knownTracker.online = false;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteEntry(knownTracker.id).setOnline(false);
}
for (int i = 0; i < knownTracker.requests.getSizeInventory(); i++) {
ItemStack knowmItemStack = ItemStack
.loadItemStackFromNBT(knownTracker.inventoryNbt.getCompoundTagAt(i));
ItemStack machineItemStack = machine.getInventoryByName("config").getStackInSlot(i);
if (isDifferent(knowmItemStack, machineItemStack)) {
if (update == null) update = new SPacketLevelTerminalUpdate();
knownTracker.updateNBT();
update.addOverwriteEntry(knownTracker.id)
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
}
}
} else {
/* Add a new entry */
if (update == null) update = new SPacketLevelTerminalUpdate();
ContainerLevelTerminal.InvTracker entry = new ContainerLevelTerminal.InvTracker(
nextId++,
machine,
gridNode.isActive());
update.addNewEntry(entry.id, entry.name, entry.online)
.setLocation(entry.x, entry.y, entry.z, entry.dim, entry.side.ordinal())
.setItems(entry.rows, entry.rowSize, entry.inventoryNbt)
.setViewItemStack(machine.getSelfItemStack(), machine.getDisplayItemStack());
tracked.put(gridHost, entry);
trackedById.put(entry.id, entry);
}
visited.add(gridHost);
}
}
/* Now find any entries that we need to remove */
Iterator<Map.Entry<IGridHost, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
while (it.hasNext()) {
var entry = it.next();
if (visited.contains(entry.getKey())) {
continue;
}
if (update == null) update = new SPacketLevelTerminalUpdate();
trackedById.remove(entry.getValue().id);
it.remove();
update.addRemovalEntry(entry.getValue().id);
}
return update;
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
private boolean isDifferent(final ItemStack a, final ItemStack b) {
if (a == null && b == null) {
return false;
}
if (a == null || b == null) {
return true;
}
return !ItemStack.areItemStacksEqual(a, b);
}
private static class InvTracker {
private final long id;
private String name;
private final IInventory requests;
private final int rowSize;
private final int rows;
private final int x;
private final int y;
private final int z;
private final int dim;
private final ForgeDirection side;
private boolean online;
private NBTTagList inventoryNbt;
public InvTracker(long id, ILevelViewable machine, boolean online) {
DimensionalCoord location = machine.getLocation();
this.id = id;
this.name = machine.getCustomName();
this.requests = machine.getInventoryByName("config");
this.rowSize = machine.rowSize();
this.rows = machine.rows();
this.x = location.x;
this.y = location.y;
this.z = location.z;
this.dim = location.getDimension();
this.side = machine.getSide();
this.online = online;
this.inventoryNbt = new NBTTagList();
updateNBT();
}
private void updateNBT() {
this.inventoryNbt = new NBTTagList();
for (int i = 0; i < this.rows; ++i) {
for (int j = 0; j < this.rowSize; ++j) {
final int offset = this.rowSize * i;
ItemStack stack = this.requests.getStackInSlot(offset + j);
if (stack != null) {
this.inventoryNbt.appendTag(stack.writeToNBT(new NBTTagCompound()));
} else {
this.inventoryNbt.appendTag(new NBTTagCompound());
}
}
}
}
}
}
@@ -1,17 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class ContainerLevelWireless extends ContainerLevelTerminal {
public ContainerLevelWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
@@ -1,10 +1,6 @@
package com.glodblock.github.client.gui.container.base;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
import net.minecraft.entity.player.EntityPlayer;
@@ -17,7 +13,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
@@ -35,12 +33,7 @@ import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.*;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
@@ -122,7 +115,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.MOVE_REGION, slotId, id);
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
@@ -131,19 +124,17 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
FluidStack fluid = Util.getFluidFromItem(stack);
if (fluid == null || fluid.amount <= 0) {
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if (validPatternSlot(slot)) {
if (validPatternSlot(slot)
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN -> {
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
return;
}
case SPLIT_OR_PLACE_SINGLE -> {
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
@@ -153,10 +144,13 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
return;
}
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
super.doAction(player, action, slotId, id);
}
@@ -254,21 +248,13 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
return hasFluid && search; // search=false -> outputs were empty
}
protected ItemStack stampAuthor(ItemStack patternStack) {
if (patternStack.stackTagCompound == null) {
patternStack.stackTagCompound = new NBTTagCompound();
}
patternStack.stackTagCompound.setString("author", getPlayerInv().player.getCommandSenderName());
return patternStack;
}
protected void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(this.craftingSlots));
pattern.setOutputs(collectInventory(this.outputSlots));
pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(stampAuthor(pattern.writeToStack()));
patternSlotOUT.putStack(pattern.writeToStack());
}
protected static IAEItemStack[] collectInventory(Slot[] slots) {
@@ -445,7 +431,6 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
encodedValue.setBoolean("beSubstitute", this.beSubstitute);
encodedValue.setBoolean("prioritize", this.prioritize);
output.setTagCompound(encodedValue);
stampAuthor(output);
this.patternSlotOUT.putStack(output);
}
@@ -489,7 +474,8 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
protected NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
Util.writeItemStackToNBT(i, c);
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
}
return c;
}
@@ -537,51 +523,14 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
return false;
}
static boolean canDouble(SlotFake[] slots, int mult) {
for (Slot s : slots) {
ItemStack st = s.getStack();
if (st != null) {
if (st.getItem() instanceof ItemFluidPacket) {
long result = (long) ItemFluidPacket.getFluidAmount(st) * mult;
if (result > Integer.MAX_VALUE) {
return false;
}
} else {
long result = (long) s.getStack().stackSize * mult;
if (result > Integer.MAX_VALUE) {
return false;
}
}
}
}
return true;
}
static void doubleStacksInternal(SlotFake[] slots, int mult) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots) {
ItemStack st = s.getStack();
if (st != null) {
if (st.getItem() instanceof ItemFluidPacket) {
ItemFluidPacket.setFluidAmount(st, ItemFluidPacket.getFluidAmount(st) * mult);
} else {
st.stackSize *= mult;
}
}
}
}
public void doubleStacks(boolean isShift) {
if (!isCraftingMode()) {
if (isShift) {
if (canDouble(this.craftingSlots, 8) && canDouble(this.outputSlots, 8)) {
doubleStacksInternal(this.craftingSlots, 8);
doubleStacksInternal(this.outputSlots, 8);
}
} else {
if (canDouble(this.craftingSlots, 2) && canDouble(this.outputSlots, 2)) {
doubleStacksInternal(this.craftingSlots, 2);
doubleStacksInternal(this.outputSlots, 2);
if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
doubleStacksInternal(this.craftingSlots);
doubleStacksInternal(this.outputSlots);
if (isShift && (containsItem(outputSlots) || containsItem(craftingSlots))) {
while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
doubleStacksInternal(this.craftingSlots);
doubleStacksInternal(this.outputSlots);
}
}
this.detectAndSendChanges();
@@ -13,14 +13,7 @@ import net.minecraft.item.ItemStack;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.TypeFilter;
import appeng.api.config.ViewItems;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.storage.IMEMonitor;
@@ -26,10 +26,7 @@ import com.glodblock.github.util.FluidSorters;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.config.*;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IDisplayRepo;
import appeng.api.storage.data.IItemList;
@@ -19,8 +19,6 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.render.tank.ModelCertusTank;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import cpw.mods.fml.client.registry.ClientRegistry;
@@ -68,9 +66,6 @@ public class ItemCertusQuartzTankRender implements IItemRenderer {
if (storedFluid != null && storedFluid.getFluid() != null) {
IIcon fluidIcon = storedFluid.getFluid().getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
if (ModAndClassUtil.HODGEPODGE && fluidIcon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) fluidIcon).markNeedsAnimationUpdate();
}
Tessellator tessellator = Tessellator.instance;
RenderBlocks renderer = new RenderBlocks();
GL11.glScalef(1, 1, -1);
@@ -8,6 +8,8 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.block.BlockFluidBuffer;
import com.glodblock.github.common.tile.TileFluidBuffer;
@@ -36,6 +38,8 @@ public class RenderBlockFluidBuffer extends BaseBlockRender<BlockFluidBuffer, Ti
if (tileEntity != null && tileEntity.getFluidStack() != null) {
Fluid storedFluid = tileEntity.getFluidStack().getFluid();
if (storedFluid != null) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Block id = Block.getBlockById(FluidRegistry.WATER.getID());
IIcon fluidIcon = storedFluid.getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
@@ -56,6 +60,7 @@ public class RenderBlockFluidBuffer extends BaseBlockRender<BlockFluidBuffer, Ti
renderer.renderFaceXNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(id, x, y, z, fluidIcon);
GL11.glDisable(GL11.GL_BLEND);
}
}
}
@@ -118,5 +118,4 @@ public class FluidTankRenderer {
return diplayLists;
}
}
@@ -18,9 +18,6 @@ public enum FCPartsTexture {
PartFluidPatternTerminal_Bright("pattern_terminal_bright"),
PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
PartFluidPatternTerminal_Colored("pattern_terminal_medium"),
PartLevelTerminal_Bright("level_terminal_bright"),
PartLevelTerminal_Dark("level_terminal_dark"),
PartLevelTerminal_Colored("level_terminal_medium"),
PartTerminalBroad("terminal_broad"),
PartFluidImportBus("fluid_import_face"),
PartFluidExportBus("fluid_export_face"),
@@ -16,12 +16,9 @@ public class Config {
public static boolean fluidIOBus;
public static boolean removeRecipe;
public static double portableCellBattery;
public static boolean fluidP2PInterface;
public static int packetSize;
public static int packetRate;
public static boolean replaceEC2;
public static int levelMaintainerMinTicks;
public static int levelMaintainerMaxTicks;
public static void run() {
loadCategory();
@@ -44,11 +41,6 @@ public class Config {
"Fluid Craft for AE2",
true,
"Enable this to add Fluid Import/Export Bus like EC2's one.");
fluidP2PInterface = Config.getBoolean(
"fluidP2PInterface",
"Fluid Craft for AE2",
true,
"Enable the P2P Tunnel - ME Dual Interface feature.");
removeRecipe = Config.getBoolean(
"Disable all recipes",
"Fluid Craft for AE2",
@@ -68,12 +60,6 @@ public class Config {
"Fluid Craft for AE2",
true,
"Set true to handle missing item mappings from EC2. Note to work properly, you must have all relevant parts.");
levelMaintainerMinTicks = Config.get("LevelMaintainer", "minTick", 5, "Number on ticks for minimal request")
.getInt();
levelMaintainerMaxTicks = Config.get("LevelMaintainer", "maxTick", 120, "Number on ticks for maximal request")
.getInt();
if (Config.hasChanged()) Config.save();
}
@@ -2,7 +2,6 @@ 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;
@@ -62,14 +61,6 @@ 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;
@@ -16,8 +16,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.storage.FluidCellInventoryHandler;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
@@ -96,12 +96,12 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final FluidCellInventoryHandler handler) {
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -112,7 +112,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -155,9 +155,6 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
if (handler.getSticky()) {
lines.add(GuiText.Sticky.getLocal());
}
}
}
}
@@ -190,7 +187,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 2);
return new CellUpgrades(is, 0);
}
@Override
@@ -1,123 +0,0 @@
package com.glodblock.github.common.item;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellUpgrades;
import appeng.tile.inventory.AppEngInternalInventory;
public abstract class ItemBaseInfinityStorageCell extends AEBaseItem implements IStorageFluidCell {
protected static class InfinityConfig extends AppEngInternalInventory {
public InfinityConfig(final ItemStack is) {
super(null, 1);
this.setInventorySlotContents(0, is);
}
@Override
public void markDirty() {}
}
@Override
public long getBytes(ItemStack cellItem) {
return Integer.MAX_VALUE;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return 1;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@Override
public abstract IInventory getConfigInventory(ItemStack is);
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain(ItemStack is) {
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 0;
}
@Override
public boolean isEditable(ItemStack is) {
return false;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public FuzzyMode getFuzzyMode(ItemStack is) {
return null;
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (GuiScreen.isCtrlKeyDown()) {
if (!cellInventory.getContents().isEmpty()) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(String.format(" %s %s", StatCollector.translateToLocal(NameConst.TT_INFINITY_FLUID_STORAGE_TIPS), fluid.getFluidStack().getLocalizedName()));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
}
}
}
@@ -1,8 +1,6 @@
package com.glodblock.github.common.item;
import static com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe.getEnergyCard;
import static com.glodblock.github.loader.recipe.WirelessTerminalRecipe.getInfinityBoosterCard;
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
import java.util.List;
@@ -35,7 +33,6 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
protected GuiType type;
public static String infinityBoosterCard = "infinityBoosterCard";
public static String infinityEnergyCard = "InfinityEnergyCard";
public ItemBaseWirelessTerminal(GuiType t) {
super();
@@ -44,8 +41,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
// terminal
if (player.isSneaking()) return removeInfinityBoosterCard(player, item);
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
if (Platform.isClient()) {
return item;
@@ -102,9 +98,6 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
if (hasInfinityBoosterCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getInfinityBoosterCard().getDisplayName());
}
if (hasEnergyCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getEnergyCard().getDisplayName());
}
} else {
lines.add(NameConst.i18n(NameConst.TT_CTRL_FOR_MORE));
}
@@ -1,23 +1,36 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemCreativeFluidStorageCell extends ItemBaseInfinityStorageCell
public class ItemCreativeFluidStorageCell extends AEBaseItem
implements IStorageFluidCell, IRegister<ItemCreativeFluidStorageCell> {
public ItemCreativeFluidStorageCell() {
@@ -28,6 +41,52 @@ public class ItemCreativeFluidStorageCell extends ItemBaseInfinityStorageCell
this.setMaxStackSize(1);
}
@Override
public long getBytes(ItemStack cellItem) {
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return 0;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain(ItemStack is) {
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 0;
}
@Override
public boolean isEditable(ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
@@ -44,8 +103,29 @@ public class ItemCreativeFluidStorageCell extends ItemBaseInfinityStorageCell
}
@Override
public boolean isEditable(ItemStack is) {
return true;
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getContents().size() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(String.format(" %s", fluid.getFluidStack().getLocalizedName()));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
}
}
@Override
@@ -1,45 +0,0 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemEnergyCard extends FCBaseItem {
public ItemEnergyCard() {
super();
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_ENERGY_CARD);
this.setTextureName(FluidCraft.resource(NameConst.ITEM_ENERGY_CARD).toString());
}
@Override
public ItemEnergyCard register() {
GameRegistry.registerItem(this, NameConst.ITEM_ENERGY_CARD, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List toolTip, boolean flag) {
if (isShiftKeyDown()) {
toolTip.addAll(RenderUtil.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_ENERGY_CARD_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -12,7 +12,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -89,22 +88,6 @@ public class ItemFluidPacket extends FCBaseItem {
return stack != null ? getFluidStack(stack.getItemStack()) : null;
}
public static void setFluidAmount(ItemStack stack, int amount) {
if (stack == null || !stack.hasTagCompound()
|| !stack.getTagCompound().hasKey("FluidStack", Constants.NBT.TAG_COMPOUND)) {
return;
}
stack.getTagCompound().getCompoundTag("FluidStack").setInteger("Amount", amount);
}
public static int getFluidAmount(ItemStack stack) {
if (stack == null || !stack.hasTagCompound()) {
return 0;
}
// Default to 0 if no tag exists
return stack.getTagCompound().getCompoundTag("FluidStack").getInteger("Amount");
}
@Nullable
public static ItemStack newStack(@Nullable FluidStack fluid) {
if (fluid == null || fluid.amount == 0) {
@@ -1,41 +0,0 @@
package com.glodblock.github.common.item;
import static com.glodblock.github.util.Util.FluidUtil.water_bucket;
import java.util.EnumSet;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import appeng.core.features.AEFeature;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell
implements IStorageFluidCell, IRegister<ItemInfinityWaterStorageCell> {
@Override
public IInventory getConfigInventory(ItemStack is) {
return new InfinityConfig(water_bucket);
}
public ItemInfinityWaterStorageCell() {
super();
setUnlocalizedName(NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE);
setTextureName(FluidCraft.resource(NameConst.ITEM_INFINITY_FLUID_STORAGE).toString());
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
}
@Override
public ItemInfinityWaterStorageCell register() {
GameRegistry.registerItem(this, NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -1,71 +0,0 @@
package com.glodblock.github.common.item;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.parts.PartFluidP2PInterface;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartItem;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemPartFluidP2PInterface extends FCBaseItem implements IPartItem {
private IIcon icon;
public ItemPartFluidP2PInterface() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_P2P_INTERFACE);
AEApi.instance().partHelper().setItemBusRenderer(this);
}
@Nullable
@Override
public IPart createPartFromItemStack(ItemStack is) {
return new PartFluidP2PInterface(is);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float xOffset, float yOffset, float zOffset) {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemPartFluidP2PInterface register() {
if (!Config.fluidP2PInterface) return null;
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_P2P_INTERFACE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public IIcon getIconFromDamage(int dmg) {
return icon;
}
@Override
public void registerIcons(IIconRegister register) {
if (Config.fluidP2PInterface) {
this.icon = register.registerIcon("appliedenergistics2:ItemPart.P2PTunnel");
}
}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
}
@@ -1,71 +0,0 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemPartLevelTerminal extends FCBaseItem implements IPartItem {
public ItemPartLevelTerminal() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_LEVEL_TERMINAL);
AEApi.instance().partHelper().setItemBusRenderer(this);
}
@Nullable
@Override
public PartLevelTerminal createPartFromItemStack(ItemStack is) {
return new PartLevelTerminal(is);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float xOffset, float yOffset, float zOffset) {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List toolTip, boolean flag) {
if (isShiftKeyDown()) {
toolTip.add(NameConst.i18n(NameConst.TT_LEVEL_TERMINAL));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
@Override
public ItemPartLevelTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_LEVEL_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
}
@@ -1,6 +1,5 @@
package com.glodblock.github.common.item;
import java.text.NumberFormat;
import java.util.EnumSet;
import java.util.List;
@@ -83,7 +82,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -94,7 +93,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -1,46 +0,0 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemQuantumBridgeCard extends FCBaseItem {
public ItemQuantumBridgeCard() {
super();
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_QUANTUM_BRIDGE_CARD);
this.setTextureName(FluidCraft.resource(NameConst.ITEM_QUANTUM_BRIDGE_CARD).toString());
}
@Override
public ItemQuantumBridgeCard register() {
GameRegistry.registerItem(this, NameConst.ITEM_QUANTUM_BRIDGE_CARD, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List toolTip, boolean flag) {
if (isShiftKeyDown()) {
toolTip.addAll(
RenderUtil.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_QUANTUM_BRIDGE_CARD_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -1,51 +0,0 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemWirelessLevelTerminal extends ItemBaseWirelessTerminal
implements IRegister<ItemWirelessLevelTerminal> {
public ItemWirelessLevelTerminal() {
super(GuiType.WIRELESS_LEVEL_TERMINAL);
AEApi.instance().registries().wireless().registerWirelessHandler(this);
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
setUnlocalizedName(NameConst.ITEM_WIRELESS_LEVEL_TERMINAL);
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_LEVEL_TERMINAL).toString());
}
@Override
public ItemWirelessLevelTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_LEVEL_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
}
@@ -21,12 +21,7 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalExInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.inventory.item.*;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.BlockPos;
@@ -41,12 +36,10 @@ import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.IBauble;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles")
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
implements IBauble, IRegister<ItemWirelessUltraTerminal> {
@@ -64,7 +57,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
guis.add(GuiType.WIRELESS_FLUID_TERMINAL);
guis.add(GuiType.WIRELESS_INTERFACE_TERMINAL);
guis.add(GuiType.WIRELESS_LEVEL_TERMINAL);
if (ModAndClassUtil.ThE) {
guis.add(GuiType.WIRELESS_ESSENTIA_TERMINAL);
}
@@ -117,8 +109,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_INTERFACE_TERMINAL) {
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_LEVEL_TERMINAL) {
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) {
return new WirelessPatternTerminalExInventory(stack, x, gridNode, player);
} else {
@@ -201,15 +191,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
}
}
public static boolean hasInfinityBoosterCard(EntityPlayer player) {
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
if (term == null) return false;
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
return Util.hasInfinityBoosterCard(term.getRight());
}
return false;
}
public static List<GuiType> getGuis() {
return guis;
}
@@ -14,14 +14,7 @@ import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
import com.google.common.collect.ImmutableSet;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SchedulingMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingLink;
@@ -12,12 +12,7 @@ import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SchedulingMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
@@ -24,19 +24,27 @@ 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;
@@ -44,6 +52,7 @@ 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);
@@ -192,9 +201,35 @@ 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) {
return fluidDuality.fill(from, resource, 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());
}
@Override
@@ -209,12 +244,12 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return fluidDuality.canFill(from, fluid);
return true;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return fluidDuality.canDrain(from, fluid);
return true;
}
@Override
@@ -17,19 +17,15 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingWatcher;
import appeng.api.networking.crafting.ICraftingWatcherHost;
import appeng.api.networking.crafting.*;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
@@ -63,8 +59,8 @@ import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatcherHost, ICraftingWatcherHost,
IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable, ILevelViewable {
public class PartFluidLevelEmitter extends PartUpgradeable
implements IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable {
private static final int FLAG_ON = 8;
@@ -190,11 +186,6 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
if (this.myWatcher != null && myStack != null) {
this.myWatcher.add(myStack);
}
if (myStack == null) {
this.getProxy().getStorage().getFluidInventory().addListener(this, this.getProxy().getGrid());
}
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
} catch (final GridAccessException ignored) {}
}
@@ -1,557 +0,0 @@
package com.glodblock.github.common.parts;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.DualityFluidInterface;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.implementations.tiles.ITileStorageMonitorable;
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.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.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.parts.automation.UpgradeInventory;
import appeng.parts.p2p.PartP2PTunnel;
import appeng.parts.p2p.PartP2PTunnelStatic;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.inv.IInventoryDestination;
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost, IInterfaceHost {
private final DualityInterface duality = new DualityInterface(this.getProxy(), this) {
@Override
public void updateCraftingList() {
if (!isOutput()) {
super.updateCraftingList();
try {
for (PartFluidP2PInterface p2p : getOutputs()) p2p.duality.updateCraftingList();
} catch (GridAccessException e) {
// ?
}
} else {
PartFluidP2PInterface p2p = getInput();
if (p2p != null) {
this.craftingList = p2p.duality.craftingList;
try {
this.gridProxy.getGrid()
.postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
} catch (final GridAccessException e) {
// :P
}
}
}
}
@Override
public int getInstalledUpgrades(Upgrades u) {
if (isOutput() && u == Upgrades.PATTERN_CAPACITY) return -1;
return super.getInstalledUpgrades(u);
}
};
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
public PartFluidP2PInterface(ItemStack is) {
super(is);
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkChannelsChanged c) {
dualityFluid.onChannelStateChange(c);
duality.notifyNeighbors();
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkPowerStatusChange c) {
dualityFluid.onPowerStateChange(c);
duality.notifyNeighbors();
}
@Override
public void gridChanged() {
super.gridChanged();
dualityFluid.gridChanged();
}
@Override
public void onNeighborChanged() {
this.duality.updateRedstoneState();
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
AppEngInternalInventory patterns = (AppEngInternalInventory) duality.getPatterns();
if (super.onPartActivate(player, pos)) {
ArrayList<ItemStack> drops = new ArrayList<>();
for (int i = 0; i < patterns.getSizeInventory(); i++) {
if (patterns.getStackInSlot(i) == null) continue;
drops.add(patterns.getStackInSlot(i));
}
final IPart tile = this.getHost().getPart(this.getSide());
if (tile instanceof PartFluidP2PInterface dualTile) {
DualityInterface newDuality = dualTile.duality;
// Copy interface storage, upgrades, and settings over
UpgradeInventory upgrades = (UpgradeInventory) duality.getInventoryByName("upgrades");
dualTile.duality.getStorage();
UpgradeInventory newUpgrade = (UpgradeInventory) newDuality.getInventoryByName("upgrades");
for (int i = 0; i < upgrades.getSizeInventory(); ++i) {
newUpgrade.setInventorySlotContents(i, upgrades.getStackInSlot(i));
}
IInventory storage = duality.getStorage();
IInventory newStorage = newDuality.getStorage();
for (int i = 0; i < storage.getSizeInventory(); ++i) {
newStorage.setInventorySlotContents(i, storage.getStackInSlot(i));
}
IConfigManager config = duality.getConfigManager();
config.getSettings().forEach(
setting -> newDuality.getConfigManager().putSetting(setting, config.getSetting(setting)));
}
TileEntity te = getTileEntity();
Platform.spawnDrops(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, drops);
return true;
}
if (player.isSneaking()) {
return false;
}
if (Platform.isServer()) {
InventoryHandler.openGui(
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(this.getSide()),
GuiType.DUAL_INTERFACE);
}
return true;
}
@Override
public IIcon getTypeTexture() {
return ItemAndBlockHolder.INTERFACE.getBlockTextureFromSide(0);
}
@Override
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src) {
return duality.getMonitorable(side, src, this);
}
@Override
public TickingRequest getTickingRequest(IGridNode node) {
TickingRequest item = duality.getTickingRequest(node);
TickingRequest fluid = dualityFluid.getTickingRequest(node);
return new TickingRequest(
Math.min(item.minTickRate, fluid.minTickRate),
Math.max(item.maxTickRate, fluid.maxTickRate),
item.isSleeping && fluid.isSleeping,
true);
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
TickRateModulation item = duality.tickingRequest(node, ticksSinceLastCall);
TickRateModulation fluid = dualityFluid.tickingRequest(node, ticksSinceLastCall);
if (item.ordinal() >= fluid.ordinal()) {
return item;
} else {
return fluid;
}
}
@Override
public int getInstalledUpgrades(Upgrades u) {
return duality.getInstalledUpgrades(u);
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return duality.getItemInventory();
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return duality.getFluidInventory();
}
@Override
public int getPriority() {
return duality.getPriority();
}
@Override
public void setPriority(int newValue) {
duality.setPriority(newValue);
}
@Override
public void onTunnelNetworkChange() {
duality.updateCraftingList();
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation op, ItemStack removedStack,
ItemStack newStack) {
duality.onChangeInventory(inv, slot, op, removedStack, newStack);
}
@Override
public boolean canInsert(ItemStack stack) {
return duality.canInsert(stack);
}
@Override
public int getSizeInventory() {
return duality.getStorage().getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slotIn) {
return duality.getStorage().getStackInSlot(slotIn);
}
@Override
public ItemStack decrStackSize(int index, int count) {
return duality.getStorage().decrStackSize(index, count);
}
@Override
public ItemStack getStackInSlotOnClosing(int index) {
return duality.getStorage().getStackInSlotOnClosing(index);
}
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
duality.getStorage().setInventorySlotContents(index, stack);
}
@Override
public IInventory getInventoryByName(String name) {
return duality.getInventoryByName(name);
}
@Override
public IConfigManager getConfigManager() {
return duality.getConfigManager();
}
@Override
public IIcon getBreakingTexture() {
return getItemStack().getIconIndex();
}
@Override
public String getInventoryName() {
return duality.getStorage().getInventoryName();
}
@Override
public boolean hasCustomInventoryName() {
return duality.getStorage().hasCustomInventoryName();
}
@Override
public int getInventoryStackLimit() {
return duality.getStorage().getInventoryStackLimit();
}
@Override
public void markDirty() {
duality.markDirty();
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return duality.getStorage().isUseableByPlayer(player);
}
@Override
public void openInventory() {
duality.getStorage().openInventory();
}
@Override
public void closeInventory() {
duality.getStorage().closeInventory();
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
return duality.getStorage().isItemValidForSlot(index, stack);
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return duality.getAccessibleSlotsFromSide(side);
}
@Override
public boolean canInsertItem(int p_102007_1_, ItemStack itemStack, int p_102007_3_) {
return true;
}
@Override
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
return true;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return dualityFluid.fill(from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return dualityFluid.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return dualityFluid.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return dualityFluid.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return dualityFluid.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return dualityFluid.getTankInfo(from);
}
@Override
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
saveChanges();
getTileEntity().markDirty();
dualityFluid.onFluidInventoryChanged(inv, slot);
}
@Override
public AEFluidInventory getInternalFluid() {
return dualityFluid.getInternalFluid();
}
@Override
public DualityFluidInterface getDualityFluid() {
return dualityFluid;
}
@Override
public AppEngInternalAEInventory getConfig() {
Util.mirrorFluidToPacket(config, dualityFluid.getConfig());
return config;
}
@Override
public void setConfig(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
config.setInventorySlotContents(
id,
ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
dualityFluid.getConfig().setFluidInSlot(id, dualityFluid.getStandardFluid(fluid));
}
}
@Override
public void setFluidInv(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
dualityFluid.getInternalFluid().setFluidInSlot(id, fluid);
}
}
@Override
public DualityInterface getInterfaceDuality() {
return duality;
}
@Override
public EnumSet<ForgeDirection> getTargets() {
return EnumSet.of(this.getSide());
}
@Override
public TileEntity getTileEntity() {
return super.getHost().getTile();
}
@Override
public void provideCrafting(ICraftingProviderHelper craftingTracker) {
duality.provideCrafting(craftingTracker);
}
@Override
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) {
return duality.pushPattern(patternDetails, table);
}
@Override
public boolean isBusy() {
return duality.isBusy();
}
@Override
public ImmutableSet<ICraftingLink> getRequestedJobs() {
return duality.getRequestedJobs();
}
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
return duality.injectCraftedItems(link, items, mode);
}
@Override
public void jobStateChange(ICraftingLink link) {
duality.jobStateChange(link);
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
duality.readFromNBT(data);
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
duality.writeToNBT(data);
}
@Override
public NBTTagCompound getMemoryCardData() {
final NBTTagCompound output = super.getMemoryCardData();
this.duality.getConfigManager().writeToNBT(output);
return output;
}
@Override
public void pasteMemoryCardData(PartP2PTunnel newTunnel, NBTTagCompound data) throws GridAccessException {
this.duality.getConfigManager().readFromNBT(data);
super.pasteMemoryCardData(newTunnel, data);
}
@Override
public void addToWorld() {
super.addToWorld();
this.duality.initialize();
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched) {
super.getDrops(drops, wrenched);
duality.addDrops(drops);
}
@Override
public boolean shouldDisplay() {
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();
}
}
@@ -16,20 +16,13 @@ import net.minecraftforge.fluids.IFluidHandler;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.MEMonitorIFluidHandler;
import com.glodblock.github.inventory.*;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
@@ -46,13 +39,7 @@ import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.*;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@@ -94,7 +81,6 @@ public class PartFluidStorageBus extends PartUpgradeable
this.getConfigManager().registerSetting(Settings.ACCESS, AccessRestriction.READ_WRITE);
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.getConfigManager().registerSetting(Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
this.getConfigManager().registerSetting(Settings.STICKY_MODE, YesNo.NO);
this.source = new MachineSource(this);
}
@@ -373,7 +359,6 @@ public class PartFluidStorageBus extends PartUpgradeable
this.handler.setWhitelist(
this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST
: IncludeExclude.WHITELIST);
this.handler.setSticky(this.getInstalledUpgrades(Upgrades.STICKY) > 0);
this.handler.setPriority(this.priority);
if (inv instanceof IMEMonitor) {
((IBaseMonitor) inv).addListener(this, this.handler);
@@ -1,83 +0,0 @@
package com.glodblock.github.common.parts;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.parts.base.FCPart;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IClickableInTerminal;
import com.glodblock.github.util.Util;
public class PartLevelTerminal extends FCPart implements IClickableInTerminal {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartLevelTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartLevelTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartLevelTerminal_Dark;
private Util.DimensionalCoordSide tile;
public PartLevelTerminal(ItemStack is) {
super(is, true);
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
if (data.hasKey("clickedInterface")) {
NBTTagCompound tileMsg = (NBTTagCompound) data.getTag("clickedInterface");
this.tile = Util.DimensionalCoordSide.readFromNBT(tileMsg);
}
}
@Override
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
if (this.tile == null) return;
NBTTagCompound tileMsg = new NBTTagCompound();
tile.writeToNBT(tileMsg);
data.setTag("clickedInterface", tileMsg);
}
@Override
public FCPartsTexture getFrontBright() {
return FRONT_BRIGHT_ICON;
}
@Override
public FCPartsTexture getFrontColored() {
return FRONT_COLORED_ICON;
}
@Override
public FCPartsTexture getFrontDark() {
return FRONT_DARK_ICON;
}
@Override
public boolean isLightSource() {
return false;
}
@Override
public boolean isBooting() {
return super.isBooting();
}
@Override
public GuiType getGui() {
return GuiType.LEVEL_TERMINAL;
}
@Override
public void setClickedInterface(Util.DimensionalCoordSide tile) {
this.tile = tile;
this.getHost().markForSave();
}
@Override
public Util.DimensionalCoordSide getClickedInterface() {
return this.tile;
}
}
@@ -23,12 +23,7 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.TypeFilter;
import appeng.api.config.ViewItems;
import appeng.api.config.*;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.GridFlags;
@@ -61,7 +61,7 @@ public class CreativeFluidCellInventory extends FluidCellInventory {
if (fs == null) continue;
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
iaeFluidStack.setStackSize(Long.MAX_VALUE);
iaeFluidStack.setStackSize(Integer.MAX_VALUE);
this.cellFluids.add(iaeFluidStack);
}
}
@@ -10,11 +10,7 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.*;
import appeng.client.texture.ExtraBlockTextures;
public class FluidCellHandler implements ICellHandler {
@@ -3,8 +3,6 @@ package com.glodblock.github.common.storage;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -12,7 +10,7 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.common.item.ItemBaseInfinityStorageCell;
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
@@ -82,7 +80,7 @@ public class FluidCellInventory implements IFluidCellInventory {
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
try {
if (o.getItem() instanceof ItemBaseInfinityStorageCell) {
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
} else if (o.getItem() instanceof ProxyFluidStorageCell) {
return new FluidCellInventoryHandler(new ProxyFluidCellInventory(o, container2));
@@ -387,11 +385,6 @@ public class FluidCellInventory implements IFluidCellInventory {
return out;
}
@Override
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request) {
return this.getCellFluids().findPrecise(request);
}
@Override
public List<IAEFluidStack> getContents() {
List<IAEFluidStack> ret = new ArrayList<>();
@@ -401,11 +394,6 @@ public class FluidCellInventory implements IFluidCellInventory {
return ret;
}
@Override
public IInventory getUpgradesInventory() {
return this.cellType.getUpgradesInventory(this.cellItem);
}
@Override
public StorageChannel getChannel() {
return StorageChannel.FLUIDS;
@@ -2,16 +2,12 @@ package com.glodblock.github.common.storage;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.IncludeExclude;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.ICellCacheRegistry;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
@@ -21,8 +17,7 @@ import appeng.me.storage.MEPassThrough;
import appeng.util.item.AEFluidStack;
import appeng.util.prioitylist.PrecisePriorityList;
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
implements IFluidCellInventoryHandler, ICellCacheRegistry {
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack> implements IFluidCellInventoryHandler {
protected FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
super(c, StorageChannel.FLUIDS);
@@ -35,32 +30,13 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().createFluidList();
for (int x = 0; x < config.getSizeInventory(); x++) {
final ItemStack is = config.getStackInSlot(x);
final FluidStack fluid = Util.getFluidFromItem(is);
if (fluid != null) {
priorityList.add(AEFluidStack.create(fluid));
if (Util.getFluidFromItem(is) != null) {
priorityList.add(AEFluidStack.create(Util.getFluidFromItem(is)));
}
}
if (!priorityList.isEmpty()) {
this.setPartitionList(new PrecisePriorityList<>(priorityList));
}
final IInventory upgrades = ci.getUpgradesInventory();
boolean hasSticky = false;
for (int x = 0; x < upgrades.getSizeInventory(); x++) {
final ItemStack is = upgrades.getStackInSlot(x);
if (is != null && is.getItem() instanceof IUpgradeModule) {
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
if (u == Upgrades.STICKY) {
hasSticky = true;
break;
}
}
}
if (hasSticky) {
setSticky(true);
}
}
}
@@ -98,54 +74,4 @@ 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;
}
}
@@ -86,9 +86,4 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
long getTotalFluidTypes();
List<IAEFluidStack> getContents();
/**
* @return access installed upgrades.
*/
IInventory getUpgradesInventory();
}
@@ -8,11 +8,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.util.BlockPos;
@@ -180,7 +180,8 @@ public class TileFluidAutoFiller extends AENetworkInvTile
protected NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
Util.writeItemStackToNBT(i, c);
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
}
return c;
}
@@ -4,8 +4,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.item.ItemFluidDrop;
@@ -14,21 +12,12 @@ import appeng.api.config.Actionable;
import appeng.api.networking.GridFlags;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.events.MENetworkStorageEvent;
import appeng.api.networking.events.*;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.*;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
@@ -214,24 +203,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
return out;
}
@Override
public IAEItemStack getAvailableItem(@Nonnull IAEItemStack request) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
if (fluidGrid == null) {
return null;
}
IAEFluidStack fluidRequest = ItemFluidDrop.getAeFluidStack(request);
if (fluidRequest == null) {
return null;
}
IAEFluidStack availableFluid = fluidGrid.getAvailableItem(fluidRequest);
if (availableFluid == null || availableFluid.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInDisplay(availableFluid.getFluid().getClass())) {
return null;
}
return ItemFluidDrop.newAeStack(availableFluid);
}
@Override
public StorageChannel getChannel() {
return StorageChannel.ITEMS;
@@ -306,11 +277,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
return out;
}
@Override
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request) {
return null;
}
@Override
public StorageChannel getChannel() {
return StorageChannel.FLUIDS;
@@ -187,7 +187,7 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return fluidDuality.canDrain(from, fluid);
return true;
}
@Override
@@ -5,10 +5,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import com.glodblock.github.common.item.ItemFluidPacket;
@@ -1,18 +1,11 @@
package com.glodblock.github.common.tile;
import java.util.concurrent.Future;
import java.util.function.UnaryOperator;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.Nullable;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.AeStackInventory;
@@ -26,7 +19,6 @@ import appeng.api.implementations.IPowerChannelState;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
@@ -45,6 +37,7 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AELog;
import appeng.crafting.CraftingLink;
import appeng.helpers.NonNullArrayIterator;
import appeng.me.GridAccessException;
import appeng.tile.TileEvent;
@@ -52,189 +45,139 @@ import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkTile;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import io.netty.buffer.ByteBuf;
public class TileLevelMaintainer extends AENetworkTile
implements IAEAppEngInventory, IGridTickable, ICraftingRequester, IPowerChannelState, ILevelViewable {
implements IAEAppEngInventory, IGridTickable, ICraftingRequester, IPowerChannelState {
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 final IInventory inv = new AeItemStackHandler(requests.getRequestStacks());
private boolean isPowered = false;
public TileLevelMaintainer() {
getProxy().setIdlePowerUsage(1D);
getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
source = new MachineSource(this);
this.source = new MachineSource(this);
}
public AeStackInventory<IAEItemStack> getRequestSlots() {
return requests.requestStacks;
return requests.getRequestStacks();
}
@Override
public ImmutableSet<ICraftingLink> getRequestedJobs() {
return ImmutableSet.copyOf(new NonNullArrayIterator<>(requests.links));
return ImmutableSet.copyOf(new NonNullArrayIterator<>(this.requests.getLinks()));
}
private IAEItemStack setState(ICraftingLink link, IAEItemStack items) {
if (items != null) {
requests.setState(link, State.Exporting);
} else {
requests.setState(link, State.Crafting);
}
return items;
}
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
int idx = requests.getIdxByLink(link);
try {
if (getProxy().isActive()) {
final IEnergyGrid energy = getProxy().getEnergy();
if (this.getProxy().isActive()) {
final IEnergyGrid energy = this.getProxy().getEnergy();
final double power = Math
.ceil(ItemFluidDrop.isFluidStack(items) ? items.getStackSize() / 1000D : items.getStackSize());
if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) {
if (ItemFluidDrop.isFluidStack(items)) {
IAEFluidStack notInjectedItems = getProxy().getStorage().getFluidInventory()
.injectItems(ItemFluidDrop.getAeFluidStack(items), mode, source);
if (notInjectedItems != null) {
items.setStackSize(notInjectedItems.getStackSize());
requests.updateState(idx, State.Export);
return items;
IAEFluidStack notInserted = this.getProxy().getStorage().getFluidInventory()
.injectItems(ItemFluidDrop.getAeFluidStack(items), mode, this.source);
if (notInserted != null) {
items.setStackSize(notInserted.getStackSize());
return setState(link, items);
} else {
return null;
}
} else {
return getProxy().getStorage().getItemInventory().injectItems(items, mode, source);
return setState(
link,
this.getProxy().getStorage().getItemInventory().injectItems(items, mode, this.source));
}
}
}
} catch (GridAccessException e) {
AELog.debug(e);
}
return items;
return setState(link, items);
}
@Override
public void jobStateChange(ICraftingLink link) {
for (int x = 0; x < REQ_COUNT; x++) {
if (requests.getLink(x) == link) {
requests.updateLink(x, link);
return;
if (this.requests.getLinks() != null) {
for (int x = 0; x < this.requests.getLinks().length; x++) {
if (this.requests.getLinks()[x] == link) {
this.requests.getLinks()[x] = link;
return;
}
}
}
}
@Override
public TickingRequest getTickingRequest(IGridNode node) {
return new TickingRequest(Config.levelMaintainerMinTicks, Config.levelMaintainerMaxTicks, false, true);
return new TickingRequest(5, 120, false, true);
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
return canDoBusWork() ? doWork() : TickRateModulation.IDLE;
return this.canDoBusWork() ? this.doWork() : TickRateModulation.IDLE;
}
private TickRateModulation doWork() {
if (!getProxy().isActive() || !canDoBusWork()) {
if (!this.getProxy().isActive() || !this.canDoBusWork()) {
return TickRateModulation.IDLE;
}
boolean didSomething = false;
try {
final ICraftingGrid craftingGrid = getProxy().getCrafting();
final IGrid grid = getProxy().getGrid();
final IItemList<IAEItemStack> inv = getProxy().getStorage().getItemInventory().getStorageList();
// Check there are available crafting CPUs before doing any work.
// This hopefully stops level maintainers busy-looping calculating
// crafting tasks that cannot be successfully submitted.
boolean allBusy = true;
for (final ICraftingCPU cpu : craftingGrid.getCpus()) {
if (!cpu.isBusy()) {
allBusy = false;
break;
}
}
// 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);
if (!isEnable || batchSize == 0) requests.updateState(i, State.None);
if (batchSize > 0) {
ICraftingGrid cg = this.getProxy().getCrafting();
IGrid grid = this.getProxy().getGrid();
final IItemList<IAEItemStack> inv = this.getProxy().getStorage().getItemInventory().getStorageList();
for (int i = 0; i < REQ_COUNT; i++) {
IAEItemStack is = requests.getRequestQtyStack(i);
if (is != null && requests.getBatchSize(i) > 0) {
IAEItemStack craftItem = requests.getCraftItem(i);
IAEItemStack aeItem = inv.findPrecise(craftItem);
boolean isDone = requests.isDone(i);
boolean isCraftable = aeItem != null && aeItem.isCraftable();
boolean shouldCraft = isCraftable && aeItem.getStackSize() < quantity;
if (isDone) requests.updateState(i, State.Idle);
if (!isCraftable) requests.updateState(i, State.Error);
if (allBusy || !isDone
|| !shouldCraft
|| craftingGrid.canEmitFor(craftItem)
|| craftingGrid.isRequesting(craftItem))
if (this.requests.isDone(i)) this.requests.setState(i, State.Idling);
if (cg.canEmitFor(craftItem) || cg.isRequesting(craftItem)
|| inv.findPrecise(is) == null
|| !inv.findPrecise(is).isCraftable()
|| inv.findPrecise(is).getStackSize() >= is.getStackSize()
|| !this.requests.isDone(i))
continue;
// do crafting
Future<ICraftingJob> jobTask = requests.getJob(i);
Future<ICraftingJob> jobTask = requests.getJobs()[i];
if (jobTask == null) {
if (itemToBegin == null) {
itemToBegin = craftItem;
itemToBeginIdx = i;
}
requests.getJobs()[i] = cg.beginCraftingJob(getWorldObj(), grid, this.source, craftItem, null);
} else if (jobTask.isDone()) {
requests.updateState(i, State.Craft);
requests.setState(i, State.Idling);
try {
ICraftingJob job = jobTask.get();
if (job != null) {
if (jobToSubmit == null) {
jobToSubmit = job;
jobToSubmitIdx = i;
ICraftingLink link = cg.submitJob(job, this, null, false, this.source);
requests.jobs[i] = null;
if (link != null) {
didSomething = true;
requests.setState(i, State.Crafting);
requests.getLinks()[i] = link;
}
} else {
requests.updateState(i, State.Error);
}
} catch (Exception ignored) {
requests.updateState(i, State.Error);
}
}
}
}
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) {
}
return TickRateModulation.SAME;
} catch (final GridAccessException ignore) {}
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
}
@Override
@@ -253,7 +196,7 @@ public class TileLevelMaintainer extends AENetworkTile
}
protected boolean canDoBusWork() {
return getProxy().isActive();
return this.getProxy().isActive();
}
@Override
@@ -261,399 +204,275 @@ public class TileLevelMaintainer extends AENetworkTile
@Override
public boolean isPowered() {
return isPowered;
return this.isPowered;
}
@Override
public boolean isActive() {
return isPowered;
return this.isPowered;
}
public InventoryRequest getRequestInventory() {
return requests;
return this.requests;
}
public IInventory getInventory() {
return inv;
}
public IInventory getInventoryByName(String name) {
if (name == "config") return new AeItemStackHandler(requests.requestStacks);
return null;
}
public void updateQuantity(int idx, long size) {
requests.updateQuantity(idx, size);
this.requests.updateQuantity(idx, size);
}
public void updateBatchSize(int idx, long size) {
requests.updateBatchSize(idx, size);
this.requests.updateBatchSize(idx, size);
}
public void updateStatus(int idx, boolean enable) {
requests.updateStatus(idx, enable);
public void setRequestStatus(int idx, boolean enable) {
this.requests.setEnable(idx, enable);
}
private void readLinkFromNBT(NBTTagCompound data) {
for (int i = 0; i < REQ_COUNT; i++) {
final NBTTagCompound stackData = requests.getItemStack(i).getTagCompound();
if (stackData != null && stackData.hasNoTags()
&& !stackData.hasKey(TLMTags.Link.tagName)
&& stackData.getCompoundTag(TLMTags.Link.tagName).hasNoTags()) {
requests.updateLink(i, null);
requests.updateState(i, State.Idle);
} else {
NBTTagCompound linkData = stackData.getCompoundTag(TLMTags.Link.tagName);
requests.updateLink(i, AEApi.instance().storage().loadCraftingLink(linkData, this));
if (!requests.isDone(i)) requests.updateState(i, State.Craft);
}
}
}
/**
* @deprecated
*/
@Deprecated
private void readLinkFromNBT__old(NBTTagCompound data) {
try {
for (int i = 0; i < REQ_COUNT; i++) {
for (int i = 0; i < this.requests.getLinks().length; i++) {
final NBTTagCompound link = data.getCompoundTag("links-" + i);
if (link != null && link.hasNoTags()) {
requests.updateLink(i, null);
this.requests.getLinks()[i] = null;
} else {
requests.updateLink(i, AEApi.instance().storage().loadCraftingLink(link, this));
if (!requests.isDone(i)) requests.updateState(i, State.Craft);
this.requests.getLinks()[i] = AEApi.instance().storage().loadCraftingLink(link, this);
if (!this.requests.isDone(i)) this.requests.setState(i, State.Crafting);
}
}
} catch (Exception ignore) {}
}
private NBTTagCompound writeLinkToNBT(NBTTagCompound data) {
for (int i = 0; i < this.requests.getLinks().length; i++) {
if (this.requests.getLinks()[i] != null) {
CraftingLink link = (CraftingLink) this.requests.getLinks()[i];
NBTTagCompound linkData = new NBTTagCompound();
link.writeToNBT(linkData);
data.setTag("links-" + i, linkData);
}
}
return data;
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public void writeToNBTEvent(NBTTagCompound data) {
requests.requestStacks.writeToNbt(data, TLMTags.RequestStacks.tagName);
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
this.requests.requestStacks.writeToNbt(data, "Inventory");
this.requests.requestBatches.writeToNbt(data, "Batch");
this.requests.requestQtys.writeToNbt(data, "Count");
return writeLinkToNBT(data);
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
if (data.hasKey(TLMTags.RequestStacks.tagName)) {
requests.requestStacks.readFromNbt(data, TLMTags.RequestStacks.tagName);
if (Platform.isServer()) {
for (int i = 0; i < REQ_COUNT; i++) {
if (requests.requestStacks.getStack(i) != null) {
ItemStack storageStack = requests.requestStacks.getStack(i).getItemStack();
ItemStack itemStack = loadItemStackFromTag(storageStack);
ItemStack craftStack = removeRecursion(storageStack);
if (!ItemStack.areItemStacksEqual(itemStack, craftStack)) {
requests.updateStack(i, craftStack);
AELog.info(
"[TileLevelMaintainer] Replace craft stack from: " + itemStack.toString()
+ ":"
+ (itemStack.hasTagCompound() ? itemStack.getTagCompound() : "{no tags}")
+ "; with: "
+ craftStack
+ ":"
+ (craftStack.hasTagCompound() ? craftStack.getTagCompound()
: "{no tags}"));
}
}
}
}
} else {
// Migration from old data storage
long[] batches = new long[REQ_COUNT];
long[] quantyties = new long[REQ_COUNT];
requests.requestStacks.readFromNbt(data, "Batch");
for (int i = 0; i < REQ_COUNT; i++) {
IAEItemStack batchStack = requests.requestStacks.getStack(i);
batches[i] = batchStack != null ? batchStack.getStackSize() : 0;
}
requests.requestStacks.readFromNbt(data, "Count");
for (int i = 0; i < REQ_COUNT; i++) {
IAEItemStack quantityStack = requests.requestStacks.getStack(i);
quantyties[i] = quantityStack != null ? quantityStack.getStackSize() : 0;
}
requests.requestStacks.readFromNbt(data, "Inventory");
for (int i = 0; i < REQ_COUNT; i++) {
IAEItemStack requestsStack = requests.requestStacks.getStack(i);
if (requestsStack != null) {
requests.updateStack(i, requestsStack.getItemStack());
requests.updateBatchSize(i, batches[i]);
requests.updateQuantity(i, quantyties[i]);
}
}
readLinkFromNBT__old(data);
}
}
private ItemStack removeRecursion(ItemStack itemStack) {
if (itemStack != null && itemStack.hasTagCompound()
&& itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
return removeRecursion(loadItemStackFromTag(itemStack));
}
return itemStack;
}
@Nullable
private static ItemStack loadItemStackFromTag(ItemStack itemStack) {
return ItemStack.loadItemStackFromNBT(itemStack.getTagCompound().getCompoundTag(TLMTags.Stack.tagName));
this.requests.requestStacks.readFromNbt(data, "Inventory");
this.requests.requestBatches.readFromNbt(data, "Batch");
this.requests.requestQtys.readFromNbt(data, "Count");
this.readLinkFromNBT(data);
}
@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream(final ByteBuf data) {
final boolean oldPower = isPowered;
isPowered = data.readBoolean();
return isPowered != oldPower;
final boolean oldPower = this.isPowered;
this.isPowered = data.readBoolean();
return this.isPowered != oldPower;
}
@TileEvent(TileEventType.NETWORK_WRITE)
public void writeToStream(final ByteBuf data) {
data.writeBoolean(isActive());
data.writeBoolean(this.isActive());
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkPowerStatusChange p) {
updatePowerState();
this.updatePowerState();
}
@MENetworkEventSubscribe
public final void bootingRender(final MENetworkBootingStatusChange c) {
updatePowerState();
this.updatePowerState();
}
private void updatePowerState() {
boolean newState = false;
try {
newState = getProxy().isActive()
&& getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.0001;
newState = this.getProxy().isActive()
&& this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG)
> 0.0001;
} catch (final GridAccessException ignored) {
}
if (newState != isPowered) {
isPowered = newState;
markForUpdate();
if (newState != this.isPowered) {
this.isPowered = newState;
this.markForUpdate();
}
}
@Override
public TileEntity getTile() {
return this;
}
@Override
public ForgeDirection getSide() {
return ForgeDirection.UNKNOWN;
}
@Override
public int rowSize() {
return REQ_COUNT;
}
@Override
public ItemStack getSelfItemStack() {
return getItemFromTile(this);
}
public enum State {
None,
Idle,
Craft,
Export,
Error
Nothing,
Idling,
Crafting,
Exporting
}
public enum TLMTags {
RequestStacks("RequestStacks"),
Enable("Enable"),
Quantity("Quantity"),
Batch("Batch"),
Link("Link"),
State("State"),
Index("Index"),
Stack("Stack");
public final String tagName;
TLMTags(String tagName) {
this.tagName = tagName;
}
}
public static final class InventoryRequest {
public static class InventoryRequest {
private final AeStackInventoryImpl<IAEItemStack> requestStacks;
private final AeStackInventoryImpl<IAEItemStack> requestBatches;
private final AeStackInventoryImpl<IAEItemStack> requestQtys;
private final Future<ICraftingJob>[] jobs;
private final ICraftingLink[] links;
private final State[] state = new State[REQ_COUNT];
@SuppressWarnings("unchecked")
public InventoryRequest(TileLevelMaintainer tile) {
requestStacks = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
jobs = new Future[REQ_COUNT];
links = new ICraftingLink[REQ_COUNT];
this.requestStacks = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
this.requestBatches = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
this.requestQtys = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
this.jobs = new Future[REQ_COUNT];
this.links = new ICraftingLink[REQ_COUNT];
}
public State getState(int idx) {
IAEItemStack ias = requestStacks.getStack(idx);
if (ias == null) {
return State.None;
} else {
return state[idx] == null ? State.Idle : state[idx];
public void setEnable(int idx, boolean enable) {
IAEItemStack ias = this.getRequestStacks().getStack(idx);
IAEItemStack ias1 = this.getRequestBatches().getStack(idx);
if (ias != null && ias1 != null) {
ItemStack is = ias1.getItemStack();
NBTTagCompound data = new NBTTagCompound();
data.setBoolean("Enable", enable);
is.setTagCompound(data);
IAEItemStack i = AEItemStack.create(is);
i.setStackSize(ias1.getStackSize());
this.getRequestBatches().setStack(idx, i);
}
}
public int getIdxByLink(ICraftingLink link) {
for (int i = 0; i < REQ_COUNT; i++) {
if (links[i] == link) {
return i;
public State getState(int idx) {
IAEItemStack ias = this.getRequestStacks().getStack(idx);
if (ias == null) {
return State.Nothing;
} else {
return this.state[idx] == null ? State.Idling : this.state[idx];
}
}
public void setState(ICraftingLink link, State state) {
int i = 0;
for (ICraftingLink link1 : this.getLinks()) {
if (link == link1) {
this.setState(i, state);
break;
}
i++;
}
}
public void setState(int idx, State state) {
this.state[idx] = state;
}
public boolean isEnable(int idx) {
IAEItemStack ias = this.getRequestBatches().getStack(idx);
if (ias != null) {
ItemStack is = ias.getItemStack();
try {
return is.getTagCompound().getBoolean("Enable");
} catch (NullPointerException e) {
// support old version
return true;
}
} else {
return true;
}
}
public boolean isDone(int index) {
if (this.getLinks()[index] != null) {
return this.getLinks()[index].isDone() || this.getLinks()[index].isCanceled();
}
return true;
}
public Future<ICraftingJob>[] getJobs() {
return this.jobs;
}
public ICraftingLink[] getLinks() {
return links;
}
public AeStackInventory<IAEItemStack> getRequestQtys() {
return this.requestQtys;
}
public AeStackInventory<IAEItemStack> getRequestBatches() {
return this.requestBatches;
}
public AeStackInventory<IAEItemStack> getRequestStacks() {
return this.requestStacks;
}
public void updateQuantity(int idx, long size) {
IAEItemStack is = this.getRequestStacks().getStack(idx);
if (is != null) {
IAEItemStack i = is.copy();
i.setStackSize(size);
this.getRequestQtys().setStack(idx, i);
}
}
public void updateBatchSize(int idx, long size) {
IAEItemStack ias = this.getRequestStacks().getStack(idx);
if (ias != null) {
ItemStack is = ias.copy().getItemStack();
NBTTagCompound data = new NBTTagCompound();
data.setBoolean("Enable", true);
is.setTagCompound(data);
IAEItemStack i = AEItemStack.create(is);
i.setStackSize(size);
this.getRequestBatches().setStack(idx, i);
}
}
public IAEItemStack getRequestQtyStack(int idx) {
IAEItemStack is = this.getRequestStacks().getStack(idx);
if (is == null) return null;
IAEItemStack qis = this.getRequestQtys().getStack(idx);
if (qis == null || !is.isSameType(qis)) return null;
return this.getRequestQtys().getStack(idx);
}
public long getQuantity(int idx) {
IAEItemStack ias = this.getRequestQtyStack(idx);
if (ias == null) {
return 0;
}
return ias.getStackSize();
}
public long getBatchSize(int idx) {
if (!this.isEnable(idx)) return 0;
IAEItemStack is = this.getRequestStacks().getStack(idx);
IAEItemStack is1 = this.getRequestBatches().getStack(idx);
if (is != null && is1 != null) {
return is1.getStackSize();
}
return 0;
}
public boolean isEnable(int idx) {
IAEItemStack ias = requestStacks.getStack(idx);
if (ias == null) {
return true;
}
ItemStack is = ias.getItemStack();
return is.hasTagCompound() ? is.getTagCompound().getBoolean(TLMTags.Enable.tagName) : true;
}
public boolean isDone(int index) {
if (links[index] == null) {
return true;
}
return links[index].isDone() || links[index].isCanceled();
}
public Future<ICraftingJob> getJob(int idx) {
return jobs[idx];
}
public ICraftingLink getLink(int idx) {
return links[idx];
}
public void updateJob(int idx, Future<ICraftingJob> job) {
jobs[idx] = job;
}
private void updateField(int idx, UnaryOperator<NBTTagCompound> updater) {
IAEItemStack ias = requestStacks.getStack(idx);
if (ias == null) return;
ItemStack itemStack = ias.getItemStack();
NBTTagCompound data = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
data.setInteger(TLMTags.Index.tagName, idx);
itemStack.setTagCompound(updater.apply(data));
IAEItemStack newRequestStack = AEItemStack.create(itemStack);
newRequestStack.setStackSize(ias.getStackSize());
requestStacks.setStack(idx, newRequestStack);
}
public void updateLink(int idx, ICraftingLink link) {
links[idx] = link;
updateField(idx, data -> {
NBTTagCompound linkData = new NBTTagCompound();
if (link != null) link.writeToNBT(linkData);
data.setTag(TLMTags.Link.tagName, linkData);
return data;
});
}
public void updateState(int idx, State nextState) {
state[idx] = nextState;
updateField(idx, data -> {
data.setInteger(TLMTags.State.tagName, nextState.ordinal());
return data;
});
}
public void updateStatus(int idx, boolean enable) {
updateField(idx, data -> {
State nextState = enable ? State.Idle : State.None;
data.setBoolean(TLMTags.Enable.tagName, enable);
data.setInteger(TLMTags.State.tagName, nextState.ordinal());
return data;
});
}
public void updateQuantity(int idx, long quantity) {
updateField(idx, data -> {
data.setLong(TLMTags.Quantity.tagName, quantity);
return data;
});
}
public void updateBatchSize(int idx, long batch) {
updateField(idx, data -> {
data.setLong(TLMTags.Batch.tagName, batch);
data.setBoolean(TLMTags.Enable.tagName, true);
return data;
});
}
public void updateStack(int idx, ItemStack itemStack) {
updateField(idx, data -> {
NBTTagCompound stackData = new NBTTagCompound();
if (itemStack != null) itemStack.writeToNBT(stackData);
data.setTag(TLMTags.Stack.tagName, stackData);
return data;
});
}
public IAEItemStack getAEItemStack(int idx) {
return requestStacks.getStack(idx);
}
public ItemStack getItemStack(int idx) {
return requestStacks.getStack(idx).getItemStack();
}
public long getQuantity(int idx) {
if (!isEnable(idx)) return 0;
IAEItemStack ias = requestStacks.getStack(idx);
if (ias == null) return 0;
ItemStack itemStack = ias.getItemStack();
if (!itemStack.hasTagCompound()) return 0;
return itemStack.getTagCompound().getLong(TLMTags.Quantity.tagName);
}
public long getBatchSize(int idx) {
if (!isEnable(idx)) return 0;
IAEItemStack ias = requestStacks.getStack(idx);
if (ias == null) return 0;
ItemStack itemStack = ias.getItemStack();
if (!itemStack.hasTagCompound()) return 0;
return itemStack.getTagCompound().getLong(TLMTags.Batch.tagName);
}
public IAEItemStack getCraftItem(int idx) {
IAEItemStack is = requestStacks.getStack(idx);
if (is == null) return null;
if (is.getItemStack() == null) return null;
ItemStack qis = loadItemStackFromTag(is.getItemStack());
if (qis == null) return null;
IAEItemStack qais = AEItemStack.create(qis);
qais.setStackSize(getBatchSize(idx));
return qais;
IAEItemStack is = this.getRequestQtyStack(idx);
if (is != null) {
IAEItemStack ias = is.copy();
ias.setStackSize(this.getBatchSize(idx));
return ias;
}
return null;
}
}
}
@@ -6,12 +6,7 @@ import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import com.glodblock.github.coremod.transform.CraftingCpuTransformer;
import com.glodblock.github.coremod.transform.CraftingTreeNodeTransformer;
import com.glodblock.github.coremod.transform.DualityInterfaceTransformer;
import com.glodblock.github.coremod.transform.ExternalStorageRegistryTransformer;
import com.glodblock.github.coremod.transform.GuiCraftingTransformer;
import com.glodblock.github.coremod.transform.NEITransformer;
import com.glodblock.github.coremod.transform.*;
public class FCClassTransformer implements IClassTransformer {
@@ -22,9 +17,11 @@ public class FCClassTransformer implements IClassTransformer {
case "appeng.crafting.CraftingTreeNode" -> tform = CraftingTreeNodeTransformer.INSTANCE;
case "appeng.me.cluster.implementations.CraftingCPUCluster" -> tform = CraftingCpuTransformer.INSTANCE;
case "appeng.helpers.DualityInterface" -> tform = DualityInterfaceTransformer.INSTANCE;
case "appeng.client.gui.implementations.GuiCraftingCPU", "appeng.client.gui.implementations.GuiCraftConfirm", "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm", "appeng.client.gui.widgets.GuiCraftingTree" -> tform = GuiCraftingTransformer.INSTANCE;
case "appeng.integration.modules.NEI" -> tform = NEITransformer.INSTANCE;
case "appeng.container.implementations.ContainerInterfaceTerminal" -> tform = ContainerInterfaceTerminalTransformer.INSTANCE;
case "appeng.client.gui.implementations.GuiCraftingCPU", "appeng.client.gui.implementations.GuiCraftConfirm", "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm" -> tform = GuiCraftingTransformer.INSTANCE;
case "appeng.integration.modules.NEI" -> tform = NEITransfermer.INSTANCE;
case "appeng.core.features.registries.ExternalStorageRegistry" -> tform = ExternalStorageRegistryTransformer.INSTANCE;
case "appeng.core.sync.packets.PacketCompressedNBT" -> tform = PacketCompressedNBTTransformer.INSTANCE;
default -> {
return code;
}
@@ -33,7 +33,6 @@ import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.IGuiTooltipHandler;
import appeng.crafting.MECraftingInventory;
import appeng.me.MachineSet;
import appeng.me.cluster.implementations.CraftingCPUCluster;
@@ -177,15 +176,15 @@ public class CoreModHooks {
}
public static ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
if (gui instanceof IGuiTooltipHandler guiTooltipHandler) {
return guiTooltipHandler.getHoveredStack();
if (gui instanceof GuiFluidCraftConfirm) {
return ((GuiFluidCraftConfirm) gui).getHoveredStack();
}
return null;
}
public static boolean shouldShowTooltip(GuiContainer gui) {
if (gui instanceof GuiFluidCraftConfirm guiCraftConfirm) {
return guiCraftConfirm.getHoveredStack() == null;
if (gui instanceof GuiFluidCraftConfirm) {
return ((GuiFluidCraftConfirm) gui).getHoveredStack() == null;
}
return true;
}
@@ -1,9 +1,22 @@
package com.glodblock.github.coremod.hooker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class CoreModHooksClient {
public static void clientPacketData(NBTTagCompound data) {
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiInterfaceTerminalWireless) {
((GuiInterfaceTerminalWireless) gs).postUpdate(data);
}
}
}
@@ -1,71 +0,0 @@
package com.glodblock.github.coremod.registries;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.api.registries.ILevelViewableAdapter;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.coremod.registries.adapters.PartFluidLevelEmitterAdapter;
import com.glodblock.github.coremod.registries.adapters.PartLevelEmitterAdapter;
import appeng.api.networking.IGridHost;
import appeng.parts.automation.PartLevelEmitter;
public class LevelTerminalRegistry implements ILevelTerminalRegistry {
private final Set<Class<? extends ILevelViewable>> supportedClasses = new HashSet<>();
private final Map<Class<? extends ILevelViewable>, Class<? extends IGridHost>> adapterMap = new WeakHashMap<>();
private final Map<Class<? extends ILevelViewable>, ILevelViewableAdapter> adapterInstanceMap = new WeakHashMap<>();
private static class Singleton {
private static final ILevelTerminalRegistry INSTANCE = new LevelTerminalRegistry();
}
{
this.register(TileLevelMaintainer.class);
this.register(PartFluidLevelEmitter.class, new PartFluidLevelEmitterAdapter());
this.register(PartLevelEmitter.class, new PartLevelEmitterAdapter());
}
public Set<Class<? extends ILevelViewable>> getSupportedClasses() {
return supportedClasses;
}
@Override
public boolean isAdopted(Class<? extends ILevelViewable> clazz) {
return adapterMap.containsKey(clazz);
}
@Override
public Class<? extends IGridHost> getAdopted(Class<? extends ILevelViewable> clazz) {
return adapterMap.getOrDefault(clazz, null);
}
@Override
public ILevelViewableAdapter getAdapter(Class<? extends ILevelViewable> clazz) {
return adapterInstanceMap.getOrDefault(clazz, null);
}
public static ILevelTerminalRegistry instance() {
return Singleton.INSTANCE;
}
@Override
public void register(Class<? extends ILevelViewable> clazz) {
supportedClasses.add(clazz);
}
@Override
public void register(Class<? extends IGridHost> aeClass, ILevelViewableAdapter adapter) {
var aClass = adapter.getClass();
supportedClasses.add(aClass);
adapterMap.put(aClass, aeClass);
adapterInstanceMap.put(aClass, adapter);
}
}
@@ -1,88 +0,0 @@
package com.glodblock.github.coremod.registries.adapters;
import static com.glodblock.github.coremod.registries.adapters.PartLevelEmitterAdapter.getPatchedInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.api.registries.ILevelViewableAdapter;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord;
public class PartFluidLevelEmitterAdapter implements ILevelViewable, ILevelViewableAdapter {
private PartFluidLevelEmitter delegate;
public PartFluidLevelEmitterAdapter() {}
public ILevelViewable adapt(IGridHost gridHost) {
if (gridHost instanceof PartFluidLevelEmitter levelEmitter) this.delegate = levelEmitter;
return this;
};
@Override
public DimensionalCoord getLocation() {
return delegate.getLocation();
}
@Override
public TileEntity getTile() {
return delegate.getTile();
}
@Override
public ForgeDirection getSide() {
return delegate.getSide();
}
@Override
public IInventory getInventoryByName(String name) {
long value = delegate.getReportingValue();
State state = delegate.isProvidingStrongPower() > 0 ? State.Craft : State.Idle;
return getPatchedInventory(delegate.getInventoryByName(name), value, state);
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return delegate.getGridNode(dir);
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return delegate.getCableConnectionType(dir);
}
@Override
public void securityBreak() {
delegate.securityBreak();
}
@Override
public String getCustomName() {
return delegate.getCustomName();
}
@Override
public boolean hasCustomName() {
return delegate.hasCustomName();
}
@Override
public void setCustomName(String name) {
delegate.hasCustomName();
}
@Override
public ItemStack getSelfItemStack() {
return delegate.getItemStack();
}
}
@@ -1,117 +0,0 @@
package com.glodblock.github.coremod.registries.adapters;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.NotNull;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.api.registries.ILevelViewableAdapter;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.AeStackInventoryImpl;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord;
import appeng.parts.automation.PartLevelEmitter;
import appeng.util.item.AEItemStack;
public class PartLevelEmitterAdapter implements ILevelViewable, ILevelViewableAdapter {
private PartLevelEmitter delegate;
private static final int SLOT_IN = 0;
public PartLevelEmitterAdapter() {}
public ILevelViewable adapt(IGridHost gridHost) {
if (gridHost instanceof PartLevelEmitter levelEmitter) this.delegate = levelEmitter;
return this;
}
@NotNull
static public IInventory getPatchedInventory(IInventory inventory, long quantity, State state) {
ItemStack itemStack = inventory.getStackInSlot(SLOT_IN);
if (itemStack == null) return inventory;
NBTTagCompound data = !itemStack.hasTagCompound() ? new NBTTagCompound() : itemStack.getTagCompound();
data.setLong(TLMTags.Quantity.tagName, quantity);
data.setInteger(TLMTags.State.tagName, state.ordinal());
itemStack.setTagCompound(data);
AeStackInventoryImpl<IAEItemStack> inv = new AeStackInventoryImpl<>(StorageChannel.ITEMS, 1);
inv.setStack(SLOT_IN, AEItemStack.create(itemStack));
return new AeItemStackHandler(inv);
}
@Override
public DimensionalCoord getLocation() {
return delegate.getLocation();
}
@Override
public TileEntity getTile() {
return delegate.getTile();
}
@Override
public IInventory getInventoryByName(String name) {
long value = delegate.getReportingValue();
State state = delegate.isProvidingStrongPower() > 0 ? State.Craft : State.Idle;
return getPatchedInventory(delegate.getInventoryByName(name), value, state);
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return delegate.getGridNode(dir);
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return delegate.getCableConnectionType(dir);
}
@Override
public ForgeDirection getSide() {
return delegate.getSide();
}
@Override
public void securityBreak() {
delegate.securityBreak();
}
@Override
public String getCustomName() {
return delegate.getCustomName();
}
@Override
public boolean hasCustomName() {
return delegate.hasCustomName();
}
@Override
public void setCustomName(String name) {
delegate.hasCustomName();
}
@Override
public ItemStack getSelfItemStack() {
return delegate.getItemStack();
}
@Override
public ItemStack getDisplayItemStack() {
return delegate.getCrafterIcon();
}
}
Loaded 100 of 173 files, more files were not shown because too many files have changed in this diff. Show more