Compare commits

..
Author SHA1 Message Date
Martin Robertz 118df9e0b1 Merge branch 'master' into dev
# Conflicts:
#	dependencies.gradle
2024-06-07 12:00:30 +02:00
Martin Robertz 04cd7ed0b2 update 2024-06-07 11:59:58 +02:00
Smile Yik c1c6a03146 Remove 'setInterfacePattern' method (#209)
The 'setInterfacePattern' method can use OpenComputer to directly generate items in the game.
2024-06-07 05:46:04 +02:00
Martin Robertz e975035085 update 2024-06-05 22:46:06 +02:00
Martin Robertz 7f5b255500 Merge remote-tracking branch 'Quetz4l/infi_bridge_cards' into dev 2024-06-05 22:43:35 +02:00
Martin Robertz 5cf07245d6 Merge remote-tracking branch 'SmileYik/master' into dev 2024-06-05 22:43:26 +02:00
Zereff06 2a7ea5ceb0 add energy and quantum bridge cards 2024-06-05 19:09:32 +03:00
Martin Robertz 72ce3a0e2f update 2024-05-31 19:00:07 +02:00
Smile Yik 1de3ec161d Remove 'setInterfacePattern' method
The 'setInterfacePattern' method can use OpenComputer to directly generate items in the game.
2024-06-01 00:32:18 +08:00
Martin Robertz 0135a11ea1 Update dependencies.gradle 2024-05-31 11:29:07 +02:00
slprimeandslprime 6fc5951dbc Fix ScrollBar Position in Empty Terminal (#208)
Co-authored-by: slprime <[email protected]>
2024-05-31 10:38:35 +02:00
Martin Robertz afe7338b83 update 2024-05-29 17:06:17 +02:00
chochem f7b15d0283 fix divide by zero (#207) 2024-05-29 12:31:17 +02:00
Martin Robertz 84d5546758 update 2024-05-03 22:28:56 +02:00
Martin Robertz 90f586e55a update 2024-05-01 23:13:15 +02:00
Caedis 4ef743bb29 Revert "hold the shift to stop sort items (#188)" + update deps (#206)
* Revert "hold the shift to stop sort items (#188)"

This reverts commit 0bf904f2a4.

* update deps

* remove extra file
2024-05-01 08:58:42 -05:00
Martin Robertz 7a0656d0c3 update 2024-04-18 21:22:49 +02:00
slprimeandslprime b9b4211809 Optimize interface terminal gui (#205)
Co-authored-by: slprime <[email protected]>
2024-04-18 21:07:40 +02:00
Martin Robertz 8dbeee2f53 update 2024-04-09 16:50:11 +02:00
Glease d609bf3651 fix incorrect fluid caching (#204) 2024-04-09 14:34:02 +08:00
Martin Robertz 0a03bd99ae update 2024-03-27 16:06:55 +01:00
Alex Bee f7d25c6daa Level Maintainer: don't queue jobs when all CPUs are busy. (#203) 2024-03-27 15:59:20 +01:00
Abdiel Kavash f175d70f0c Use MathExpressionParser from GTNHLib. (#202)
* Use MathExpressionParser from GTNHLib.

* Defer to AE2 implementation + cache GTNHLib loaded.

* Reuse pattern.

* spotless
2024-03-24 08:40:07 +01:00
Martin Robertz 958393a4fe update 2024-03-23 12:32:09 +01:00
SKProCH 130626343b Fix wireless terminal gui (#201)
* Remove some space in NEI enabled

* Fix changing from small terminal to tall terminal also changes the terminal type if cursor over the terminal type button
2024-03-23 09:38:04 +01:00
Martin Robertz 3d3b842923 update 2024-03-22 18:31:43 +01:00
claimg 300f01be8b Fixed fluid emitter when there is no filter in it (#199) 2024-03-22 18:02:26 +01:00
Jakub a231e67167 Add full pattern optimizer support to dual interface and wireless terminal (#200)
* New buttons in dual interface + wireless terminal fix

* Update dependencies.gradle
2024-03-22 17:05:44 +01:00
Martin Robertz 960b8b43bf update 2024-03-21 20:21:05 +01:00
SKProCH 9668cffe59 Adds the sticky card support for fluid storage bus (#198)
* Adds the sticky card support for fluid storage bus

* Replace wildcard imports with regular one

* Apply spotless
2024-03-20 17:54:12 +01:00
Martin Robertz b6b110b63d update 2024-03-13 19:18:38 +01:00
Jason Mitchell 8ca32457d0 Remove Useless GL11 calls (#196)
* Remove Useless GL11 calls

Fixes compat with angelica.
2024-03-13 07:30:42 -07:00
Martin Robertz e095a6018a update 2024-03-12 19:13:06 +01:00
CaedisGitHub GTNH Actionsgithub-actions[bot]
29cb32b6ee Fix GT circuit detection with dual interfaces (#194)
* Also check machine if gt5nh

* Spotless apply for branch fixGTBlocking for #194 (#195)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-10 19:34:25 -05:00
Michael Doyle 5cc8488928 FIX: Use correct priority increment amounts (#192)
Adds an overridable method to FCGuiAmount to allow subclasses to specify
increment values other than the default.

AE2 has config values to set how much each button in the priority screen
should increment a fluid storage bus's (or other's) priorty by. Prior to this
change, the priority interface on fluid storage bus' were using the
increment values for crafting, instead of those for priority.
2024-02-28 20:16:50 -06:00
Martin Robertz 3e6ea173fc update 2024-02-28 08:13:51 +01:00
slprimeandslprime 198f7cb3e8 Fix Dynamic Font Size (#193)
Co-authored-by: slprime <[email protected]>
2024-02-28 07:16:21 +01:00
Martin Robertz 8a179dd206 update 2024-02-17 10:50:12 +01:00
Raven Szewczyk 6ebb3220dd [ci skip] upgraded build system 2024-02-04 19:56:16 +00:00
slprimeandslprime 0caf89e539 Use GT and ae2fс fluids in ME inputs/outputs and storagе (#191)
* use of GT and ae2fс fluids in inputs/outputs and storagе

* remove unused imports

---------

Co-authored-by: slprime <[email protected]>
2024-02-01 11:40:55 +01:00
Martin Robertz e3cc9352b1 update deps 2024-01-12 23:19:17 +01:00
Ryan Nasers b3e480a6cb Adding fluids to sticky card (#190)
* Adding sticky support for AE2-FC

* Spotless whoopsies
2024-01-12 22:18:05 +01:00
Martin Robertz 891fef6585 update deps+bs 2024-01-10 08:41:12 +01:00
Raven Szewczyk a81841bdfd [ci skip] upgraded build system 2024-01-08 21:23:17 +00:00
Martin Robertz 9fc2160965 update deps+bs 2024-01-02 11:46:12 +01:00
asdfljandzy 0bf904f2a4 hold the shift to stop sort items (#188)
Co-authored-by: zy <[email protected]>
2024-01-02 11:45:23 +01:00
Abdiel Kavash 6187a7306d Level Maintainer fulfills requests in a round robin pattern. (#187) 2024-01-01 11:25:01 +01:00
Martin Robertz 5b867c531f update deps 2023-12-29 12:41:34 +01:00
Caedis 745ef0841f Add null check to level terminal middle click (#186) 2023-12-29 11:48:19 +01:00
7dedef21fe Fix ability to configure TileLevelMaintainer using OC (#184)
* Fix ability to configure `TileLevelMaintainer` using OC

* Spotless apply for branch fix/tlm-oc-integration for #184 (#185)

Co-authored-by: Andrei Laiff <[email protected]>
Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-12-26 11:11:40 +01:00
Martin Robertz 20ebc18f6a update deps 2023-12-23 15:05:16 +01:00
Andrei Laiff 6e96cba6fe Correct split client-server code 2023-12-23 14:39:11 +02:00
TechnicianLP db8aee2c25 Implement Interface Locking for Dual Interfaces (#182)
* Implement Interface Locking for Dual Interfaces

* Update AE2
2023-12-20 13:03:50 +01:00
Andrei Antropov 90e4eb0366 Respect setting preserveSearchBar in InterfaceTerminal (#180)
Closes: GTNewHorizons/GT-New-Horizons-Modpack#15122
2023-12-20 01:40:44 +01:00
Martin Robertz b0a2e6e274 update deps 2023-12-19 11:52:24 +01:00
Andrei Antropov e621da2082 Support to show p2p outputs in interface terminal (#179)
Closes: GTNewHorizons/GT-New-Horizons-Modpack#15124
2023-12-19 09:17:17 +01:00
Martin Robertz f7ea2e9243 update deps 2023-12-18 16:40:05 +01:00
Andrei Antropov a55e699210 Correct stackSize z order (#178)
Closes: GTNewHorizons/GT-New-Horizons-Modpack#15120
2023-12-18 16:33:59 +01:00
TechnicianLP 1372804bc9 Optimize CPacketFluidUpdate (#177) 2023-12-14 17:06:26 +01:00
Martin Robertz 4e3c073fef update deps 2023-12-04 13:55:39 +01:00
Martin Robertz 9d76815744 Update dependencies.gradle 2023-12-04 09:12:08 +01:00
miozuneandMartin Robertz d790afc047 Compat with GT change (#175)
* Compat with GT change

* update gradle+bs+deps

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-12-04 00:09:20 +01:00
MCTBL 3b1b1af852 Add thousandth mark for cell tooltips. (#174)
* Add millennials to cell tooltips, make it more readable

* Update build.gradle
2023-12-03 14:29:03 +00:00
MCTBLandMartin Robertz 3077326c16 Implement the new interface in AE2 for network bytes informations. (#173)
* implement the interface

* sa

* Implements the new interface

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-11-20 19:25:54 +01:00
Martin Robertz 2536488e53 update deps 2023-11-13 13:37:34 +01:00
Dariusz Komosinski 6770a9fe6f Increase maintainer digit limit to 16. 2023-11-13 10:56:14 +01:00
miozune f24694680e Fix loading order again 2023-11-10 19:47:13 +01:00
Martin Robertz 8db0ea3f34 update deps 2023-11-10 17:02:57 +01:00
miozune 8775fbb9c4 Fix items and blocks being registered too late on dedicated server 2023-11-10 17:00:11 +01:00
Martin Robertz 7732cebf68 update deps 2023-10-29 11:28:37 +01:00
Батьків Нестор-Євген Васильович 79dc0eb5bc Add dual interface p2p copy paste (#169)
* update deps

* add dualt interface p2p copy pasting
2023-10-29 11:25:08 +01:00
Martin Robertz ef5efd2e8b update deps 2023-10-27 14:11:01 +02:00
f5912ef2e3 Add LevelMaintainerTerminal rework logic inside TileLevelMaintainer (#162)
* Use new interface terminal API

* Update dependencies.gradle

* feat: Update core hooks and integrations

* api: Add `LevelTerminalRegistry` functionality

* feat: Use `customName` to display in `GuiFluidLevelEmitter`

* feat: Rework scheduling and data storage in `TileLevelMaintainer` functionality

* feat: Add new item `LevelTerminal`

* feat: Support back navigation functionality

* feat: add back navigation in `LevelMaintainer` from terminal

* use `IGuiTooltipHandler` directly from ae2

include #160

* fix correct `InterfaceTerminalSupportedClassProvider` deprecation

* Implement new version of `InterfaceWireless` based on `InterfaceTerminal`

* Fix `LevelTerminal` data recursion and few in fixes gui

* Use `aeRenderItem` directly and fix `zIndex` in custom slots

* Fix rendering numbers bigger than 2.1G through `aeRenderItem`

* Fix fails on `getCraftingItem`

no root cause was found

* Fix add packet logging and try to not fail after receive corrupted packet

* Fix add logging around empty configuration

* Fix packet corruption and log invalid data

* Fix packet corruption with level emitters

* Correct handle overwrite packet

* Fix intercept dnd click from GT5 hook for `AppEngGuiHandler`

keyword `net.bdew.neiaddons.appeng.AppEngGuiHandler`

* update be+deps

* Update dependencies.gradle

* Update dependencies.gradle

* Fix `zIndexes` for compatability with `DuraDisplay`

* Update AE2 and fix compatability

* Change `ForgeDirection` side serialization to `byte`

* Fix tooltip zIndexes

* Rename all rest parts related to `Level terminal`

* Code cleanup after review

* Remove duplicated dependency declaration

---------

Co-authored-by: Firenoo <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2023-10-27 14:10:07 +02:00
Martin Robertz 1515ebe33f update deps
add gradlew bat
2023-10-25 19:15:40 +02:00
miozune 567b1dbce5 Move DefaultExtractorLoader to FMLLoadCompleteEvent (#168) 2023-10-25 23:02:07 +09:00
miozune 1efa92adad Fix stacksize overflow when overlaying recipe (#167) 2023-10-25 23:01:56 +09:00
80 changed files with 2334 additions and 2620 deletions

No files matched your search

+35 -6
View File
@@ -1,9 +1,38 @@
*.bat
.gradle/
.idea/
out/
.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/
*.iml
*.ipr
*.iws
run/
build/
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
+2 -1621
View File
File diff suppressed because it is too large. Load diff
+49 -15
View File
@@ -1,25 +1,59 @@
// Add your dependencies here
/*
* 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
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.4.5-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-268-GTNH-pre:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.6.1-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-404-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.6.0:dev')
api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.1:dev")
api('com.github.GTNewHorizons:waila:1.8.0:dev')
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.2:dev")
compileOnly("com.github.GTNewHorizons:GTNHLib:0.2.11: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.6.14:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.5.3:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.50-pre:dev') {
compileOnly('com.github.GTNewHorizons:ForestryMC:4.9.3:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.8.6:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.48.20:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.17-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.13-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.18:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.14: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.15:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.2.3:dev")
}
+150 -29
View File
@@ -1,71 +1,192 @@
# 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
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
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
# 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/
# 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
# Will update your build.gradle automatically whenever an update is available
# Updates your build.gradle and settings.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
# 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
# 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.
developmentEnvironmentUserName = Developer
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8.
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# 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
# 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
# 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.
replaceGradleTokenInFile = FluidCraft.java
# 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. I must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
# 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
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
# 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.
# 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.
usesShadowedDependencies = false
# 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 =
# 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
# 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
# Optional parameter to prevent the source code from being published
# noPublishedSources =
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+13 -9
View File
@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Vendored
+92
View File
@@ -0,0 +1,92 @@
@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
+5 -10
View File
@@ -4,10 +4,10 @@ pluginManagement {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons.retrofuturagradle")
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
@@ -17,12 +17,7 @@ pluginManagement {
}
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
@@ -57,7 +57,6 @@ public class FluidCraft {
@Mod.EventHandler
public static void init(FMLInitializationEvent event) {
ModAndClassUtil.init();
if (ModAndClassUtil.OC) {
OCDriverInit.run();
}
@@ -77,6 +76,9 @@ public class FluidCraft {
if (!Config.removeRecipe) {
RecipeLoader.INSTANCE.run();
}
if (!ModAndClassUtil.NEW_HORIZONS_CORE_MOD) {
RecipeLoader.addTerminalCards();
}
RecipeLoader.runTerminalRecipe();
if (ModAndClassUtil.isV2) {
@@ -89,6 +91,11 @@ 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();
@@ -106,9 +113,6 @@ public class FluidCraft {
}
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {}
public static ResourceLocation resource(String path) {
return new ResourceLocation(MODID, path);
}
@@ -4,6 +4,7 @@ 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.client.gui.container.ContainerDualInterface;
@@ -17,18 +18,23 @@ 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.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 {
@@ -39,7 +45,10 @@ 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) {
@@ -68,41 +77,78 @@ public class GuiDualInterface extends GuiUpgradeable {
itemRender);
this.buttonList.add(this.switcher);
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO);
int offset = 8;
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + offset, Settings.BLOCK, YesNo.NO);
this.buttonList.add(this.BlockMode);
offset += 18;
this.interfaceMode = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + 26,
this.guiTop + offset,
84,
85,
GuiText.InterfaceTerminal.getLocal(),
GuiText.InterfaceTerminalHint.getLocal());
this.buttonList.add(this.interfaceMode);
offset += 18;
this.insertionMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 44,
this.guiTop + offset,
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 + 62,
this.guiTop + offset,
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 + 80,
this.guiTop + offset,
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
@@ -117,12 +163,25 @@ 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,
@@ -156,11 +215,24 @@ public class GuiDualInterface extends GuiUpgradeable {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.BlockMode.getSetting(), backwards));
} else 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) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
} else if (btn == this.advancedBlockingMode) {
NetworkHandler.instance
.sendToServer(new PacketConfigButton(this.advancedBlockingMode.getSetting(), backwards));
} else if (btn == this.lockCraftingMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.lockCraftingMode.getSetting(), backwards));
}
}
@@ -178,5 +250,8 @@ public class GuiDualInterface extends GuiUpgradeable {
if (this.advancedBlockingMode != null) {
this.advancedBlockingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0);
}
if (this.lockCraftingMode != null) {
this.lockCraftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0);
}
}
}
@@ -1,7 +1,5 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import net.minecraft.client.gui.GuiButton;
@@ -80,13 +78,8 @@ public class GuiEssentiaTerminal extends GuiFluidMonitor {
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotME && AspectUtil.isEssentiaContainer(player.inventory.getItemStack())) {
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
ItemStack itemStack = this.player.inventory.getItemStack().copy();
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
if (!isShiftKeyDown()) {
itemStack.stackSize = 1;
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
@@ -11,6 +11,7 @@ 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;
@@ -34,6 +35,11 @@ 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);
@@ -4,6 +4,7 @@ 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;
@@ -55,8 +56,9 @@ public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
if (Util.getFluidFromItem(stack) != null) {
setSearchString(Util.getFluidFromItem(stack).getLocalizedName(), true);
final FluidStack fluid = Util.getFluidFromItem(stack);
if (fluid != null) {
setSearchString(fluid.getLocalizedName(), true);
}
}
}
@@ -0,0 +1,49 @@
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);
}
}
@@ -1,8 +1,5 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -121,13 +118,8 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotME && Util.FluidUtil.isFluidContainer(player.inventory.getItemStack())) {
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
ItemStack itemStack = this.player.inventory.getItemStack().copy();
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
if (!isShiftKeyDown()) {
itemStack.stackSize = 1;
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
@@ -41,6 +41,7 @@ import appeng.api.AEApi;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.client.gui.IInterfaceTerminalPostUpdate;
@@ -58,7 +59,7 @@ import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketIfaceTermUpdate;
import appeng.core.sync.packets.PacketInterfaceTerminalUpdate;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
import appeng.helpers.PatternHelper;
@@ -80,7 +81,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
AppEng.MOD_ID,
"textures/guis/newinterfaceterminal.png");
private final IfaceList masterList = new IfaceList();
private final InterfaceWirelessList masterList = new InterfaceWirelessList();
private final MEGuiTextField searchFieldOutputs;
private final MEGuiTextField searchFieldInputs;
private final MEGuiTextField searchFieldNames;
@@ -88,6 +89,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
private final GuiImgButton guiButtonAssemblersOnly;
private final GuiImgButton guiButtonBrokenRecipes;
private final GuiImgButton terminalStyleBox;
private final GuiImgButton searchStringSave;
private boolean onlyMolecularAssemblers = false;
private boolean onlyBrokenRecipes = false;
private boolean online;
@@ -96,15 +98,20 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
private final List<String> extraOptionsText;
private ItemStack tooltipStack;
private final boolean neiPresent;
protected static String searchFieldInputsText = "";
protected static String searchFieldOutputsText = "";
protected static String searchFieldNamesText = "";
/*
* Z-level Map (FLOATS) 0.0 - BACKGROUND 1.0 - ItemStacks 2.0 - Slot color overlays 20.0 - ItemStack overlays 21.0 -
* Slot mouse hover overlay 200.0 - Tooltips
*/
private static final float ITEMSTACK_Z = 1.0f;
private static final float ITEM_STACK_Z = 100.0f;
private static final float SLOT_Z = 0.5f;
private static final float ITEMSTACK_OVERLAY_Z = 20.0f;
private static final float SLOT_HOVER_Z = 31.0f;
private static final float TOOLTIP_Z = 200.0f;
private static final float ITEM_STACK_OVERLAY_Z = 200.0f;
private static final float SLOT_HOVER_Z = 310.0f;
private static final float TOOLTIP_Z = 410.0f;
private static final float STEP_Z = 10.0f;
private static final float MAGIC_RENDER_ITEM_Z = 50.0f;
protected int offsetY;
@@ -141,6 +148,11 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
};
searchFieldNames.setFocused(true);
searchStringSave = new GuiImgButton(
0,
0,
Settings.SAVE_SEARCH,
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO);
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
@@ -194,8 +206,11 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
terminalStyleBox.xPosition = guiLeft - 18;
terminalStyleBox.yPosition = guiTop + 8;
searchStringSave.xPosition = guiLeft - 18;
searchStringSave.yPosition = terminalStyleBox.yPosition + 18;
guiButtonBrokenRecipes.xPosition = guiLeft - 18;
guiButtonBrokenRecipes.yPosition = terminalStyleBox.yPosition + 18;
guiButtonBrokenRecipes.yPosition = searchStringSave.yPosition + 18;
guiButtonHideFull.xPosition = guiLeft - 18;
guiButtonHideFull.yPosition = guiButtonBrokenRecipes.yPosition + 18;
@@ -205,12 +220,17 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
offsetY = guiButtonAssemblersOnly.yPosition + 18;
if (AEConfig.instance.preserveSearchBar || isSubGui()) {
setSearchString();
}
this.setScrollBar();
this.repositionSlots();
buttonList.add(guiButtonAssemblersOnly);
buttonList.add(guiButtonHideFull);
buttonList.add(guiButtonBrokenRecipes);
buttonList.add(searchStringSave);
buttonList.add(terminalStyleBox);
initGuiDone();
addSwitchGuiBtns();
@@ -304,6 +324,8 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
initGui();
} else if (btn == searchStringSave) {
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
}
iBtn.set(next);
@@ -313,6 +335,20 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
searchFieldInputsText = searchFieldInputs.getText();
searchFieldOutputsText = searchFieldOutputs.getText();
searchFieldNamesText = searchFieldNames.getText();
}
public void setSearchString() {
searchFieldInputs.setText(searchFieldInputsText);
searchFieldOutputs.setText(searchFieldOutputsText);
searchFieldNames.setText(searchFieldNamesText);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(BACKGROUND);
@@ -327,7 +363,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
offsetY + HEADER_HEIGHT + viewHeight + 1,
0.0f,
0.0f,
(HEADER_HEIGHT + IfaceSection.TITLE_HEIGHT + 1.0f) / 256.0f,
(HEADER_HEIGHT + InterfaceWirelessSection.TITLE_HEIGHT + 1.0f) / 256.0f,
this.xSize / 256.0f,
(HEADER_HEIGHT + 106.0f) / 256.0f);
Tessellator.instance.draw();
@@ -359,7 +395,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
final int scroll = this.getScrollBar().getCurrentScroll();
int viewY = -scroll; // current y in viewport coordinates
int entryIdx = 0;
List<IfaceSection> visibleSections = this.masterList.getVisibleSections();
List<InterfaceWirelessSection> visibleSections = this.masterList.getVisibleSections();
final float guiScaleX = (float) mc.displayWidth / width;
final float guiScaleY = (float) mc.displayHeight / height;
@@ -374,7 +410,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
* Render each section
*/
while (viewY < this.viewHeight && entryIdx < visibleSections.size()) {
IfaceSection section = visibleSections.get(entryIdx);
InterfaceWirelessSection section = visibleSections.get(entryIdx);
int sectionHeight = section.getHeight();
/* Is it viewable/in the viewport at all? */
@@ -401,7 +437,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
* @param relMouseY transformed mouse coords relative to viewport
* @return the height of the section rendered in viewport coordinates, max of viewHeight.
*/
private int drawSection(IfaceSection section, int viewY, int relMouseX, int relMouseY) {
private int drawSection(InterfaceWirelessSection section, int viewY, int relMouseX, int relMouseY) {
int title;
int renderY = 0;
final int sectionBottom = viewY + section.getHeight() - 1;
@@ -409,49 +445,71 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/*
* Render title
*/
GL11.glTranslatef(0.0f, 0.0f, 50f);
bindTexture(BACKGROUND);
if (sectionBottom > 0 && sectionBottom < IfaceSection.TITLE_HEIGHT) {
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < InterfaceWirelessSection.TITLE_HEIGHT) {
/* Transition draw */
title = sectionBottom;
} else if (viewY < 0) {
/* Hidden title draw */
title = 0;
} else {
/* Normal title draw */
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Iterator<InterfaceWirelessEntry> visible = section.getVisible();
while (visible.hasNext()) {
InterfaceWirelessEntry entry = visible.next();
if (viewY + renderY + entry.rows * 18 + 1 > 0 && viewY + renderY < viewHeight) {
renderY += drawEntry(
entry,
viewY + InterfaceWirelessSection.TITLE_HEIGHT + renderY,
title,
relMouseX,
relMouseY);
} else {
entry.dispY = -9999;
entry.optionsButton.yPosition = -1;
renderY += entry.rows * 18 + 1;
}
}
bindTexture(BACKGROUND);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < InterfaceWirelessSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + IfaceSection.TITLE_HEIGHT - sectionBottom,
HEADER_HEIGHT + InterfaceWirelessSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj.drawString(section.name, 2, sectionBottom - IfaceSection.TITLE_HEIGHT + 2, fontColor);
title = sectionBottom;
fontRendererObj
.drawString(section.name, 2, sectionBottom - InterfaceWirelessSection.TITLE_HEIGHT + 2, fontColor);
} else if (viewY < 0) {
/* Hidden title draw */
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0.0f, 0.0f, 100f);
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, InterfaceWirelessSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
title = 0;
GL11.glEnable(GL11.GL_DEPTH_TEST);
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
drawTexturedModalRect(
0,
viewY,
VIEW_LEFT,
HEADER_HEIGHT,
VIEW_WIDTH,
InterfaceWirelessSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -50f);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
Iterator<IfaceEntry> visible = section.getVisible();
while (visible.hasNext()) {
if (viewY < viewHeight) {
renderY += drawEntry(
visible.next(),
viewY + IfaceSection.TITLE_HEIGHT + renderY,
title,
relMouseX,
relMouseY);
} else {
IfaceEntry entry = visible.next();
entry.dispY = -9999;
entry.optionsButton.yPosition = -1;
}
}
return IfaceSection.TITLE_HEIGHT + renderY;
return InterfaceWirelessSection.TITLE_HEIGHT + renderY;
}
/**
@@ -459,7 +517,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
*
* @param viewY the gui coordinate z
*/
private int drawEntry(IfaceEntry entry, int viewY, int titleBottom, int relMouseX, int relMouseY) {
private int drawEntry(InterfaceWirelessEntry entry, int viewY, int titleBottom, int relMouseX, int relMouseY) {
bindTexture(BACKGROUND);
Tessellator.instance.startDrawingQuads();
int relY = 0;
@@ -502,7 +560,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
toRender.drawButton(mc, relMouseX, relMouseY);
if (toRender.getMouseIn()
&& relMouseY >= Math.max(IfaceSection.TITLE_HEIGHT, entry.optionsButton.yPosition)) {
&& relMouseY >= Math.max(InterfaceWirelessSection.TITLE_HEIGHT, entry.optionsButton.yPosition)) {
// draw a tooltip
GL11.glTranslatef(0f, 0f, TOOLTIP_Z);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
@@ -531,30 +589,30 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
ItemStack stack = inv.getStackInSlot(slotIdx);
boolean tooltip = relMouseX > colLeft - 1 && relMouseX < colRight - 1
&& relMouseY >= Math.max(viewY + rowYTop, IfaceSection.TITLE_HEIGHT)
&& relMouseY >= Math.max(viewY + rowYTop, InterfaceWirelessSection.TITLE_HEIGHT)
&& relMouseY < Math.min(viewY + rowYBot, viewHeight);
if (stack != null) {
final ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
final ItemStack toRender = iep.getOutput(stack);
GL11.glPushMatrix();
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEMSTACK_Z);
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
translatedRenderItem.zLevel = 3.0f - 50.0f;
translatedRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
translatedRenderItem
.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
GL11.glTranslatef(0.0f, 0.0f, ITEMSTACK_OVERLAY_Z - ITEMSTACK_Z);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z);
aeRenderItem.setAeStack(AEItemStack.create(toRender));
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
aeRenderItem.zLevel = 0.0f;
RenderHelper.disableStandardItemLighting();
if (!tooltip) {
if (entry.brokenRecipes[slotIdx]) {
GL11.glTranslatef(0.0f, 0.0f, SLOT_Z - ITEMSTACK_OVERLAY_Z);
if (entry.slotIsBroken(slotIdx)) {
GL11.glTranslatef(0.0f, 0.0f, SLOT_Z - ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayInvalid.getColor());
} else if (entry.filteredRecipes[slotIdx]) {
GL11.glTranslatef(0.0f, 0.0f, ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
}
} else {
@@ -563,7 +621,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
GL11.glPopMatrix();
} else if (entry.filteredRecipes[slotIdx]) {
GL11.glPushMatrix();
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
GL11.glPopMatrix();
}
@@ -757,32 +815,38 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return false;
}
public void postUpdate(List<PacketIfaceTermUpdate.PacketEntry> updates, int statusFlags) {
if ((statusFlags & PacketIfaceTermUpdate.CLEAR_ALL_BIT) == PacketIfaceTermUpdate.CLEAR_ALL_BIT) {
public void postUpdate(List<PacketInterfaceTerminalUpdate.PacketEntry> updates, int statusFlags) {
if ((statusFlags & PacketInterfaceTerminalUpdate.CLEAR_ALL_BIT)
== PacketInterfaceTerminalUpdate.CLEAR_ALL_BIT) {
/* Should clear all client entries. */
this.masterList.list.clear();
}
/* Should indicate disconnected, so the terminal turns dark. */
this.online = (statusFlags & PacketIfaceTermUpdate.DISCONNECT_BIT) != PacketIfaceTermUpdate.DISCONNECT_BIT;
this.online = (statusFlags & PacketInterfaceTerminalUpdate.DISCONNECT_BIT)
!= PacketInterfaceTerminalUpdate.DISCONNECT_BIT;
for (PacketIfaceTermUpdate.PacketEntry cmd : updates) {
for (PacketInterfaceTerminalUpdate.PacketEntry cmd : updates) {
parsePacketCmd(cmd);
}
this.masterList.markDirty();
}
private void parsePacketCmd(PacketIfaceTermUpdate.PacketEntry cmd) {
private void parsePacketCmd(PacketInterfaceTerminalUpdate.PacketEntry cmd) {
long id = cmd.entryId;
if (cmd instanceof PacketIfaceTermUpdate.PacketAdd addCmd) {
IfaceEntry entry = new IfaceEntry(id, addCmd.name, addCmd.rows, addCmd.rowSize, addCmd.online)
.setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
.setIcons(addCmd.selfRep, addCmd.dispRep).setItems(addCmd.items);
if (cmd instanceof PacketInterfaceTerminalUpdate.PacketAdd addCmd) {
InterfaceWirelessEntry entry = new InterfaceWirelessEntry(
id,
addCmd.name,
addCmd.rows,
addCmd.rowSize,
addCmd.online).setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
.setIcons(addCmd.selfRep, addCmd.dispRep).setItems(addCmd.items);
masterList.addEntry(entry);
} else if (cmd instanceof PacketIfaceTermUpdate.PacketRemove) {
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketRemove) {
masterList.removeEntry(id);
} else if (cmd instanceof PacketIfaceTermUpdate.PacketOverwrite owCmd) {
IfaceEntry entry = masterList.list.get(id);
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketOverwrite owCmd) {
InterfaceWirelessEntry entry = masterList.list.get(id);
if (entry == null) {
return;
@@ -800,8 +864,8 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
}
masterList.isDirty = true;
} else if (cmd instanceof PacketIfaceTermUpdate.PacketRename renameCmd) {
IfaceEntry entry = masterList.list.get(id);
} else if (cmd instanceof PacketInterfaceTerminalUpdate.PacketRename renameCmd) {
InterfaceWirelessEntry entry = masterList.list.get(id);
if (entry != null) {
if (StatCollector.canTranslate(renameCmd.newName)) {
@@ -894,16 +958,16 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/**
* Tracks the list of entries.
*/
private class IfaceList {
private class InterfaceWirelessList {
private final Map<Long, IfaceEntry> list = new HashMap<>();
private final Map<String, IfaceSection> sections = new TreeMap<>();
private final List<IfaceSection> visibleSections = new ArrayList<>();
private final Map<Long, InterfaceWirelessEntry> list = new HashMap<>();
private final Map<String, InterfaceWirelessSection> sections = new TreeMap<>();
private final List<InterfaceWirelessSection> visibleSections = new ArrayList<>();
private boolean isDirty;
private int height;
private IfaceEntry hoveredEntry;
private InterfaceWirelessEntry hoveredEntry;
IfaceList() {
InterfaceWirelessList() {
this.isDirty = true;
}
@@ -914,7 +978,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
height = 0;
visibleSections.clear();
for (IfaceSection section : sections.values()) {
for (InterfaceWirelessSection section : sections.values()) {
String query = GuiInterfaceWireless.this.searchFieldNames.getText();
if (!query.isEmpty() && !section.name.toLowerCase().contains(query.toLowerCase())) {
continue;
@@ -966,7 +1030,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
} else {
int y = 0;
for (IfaceSection section : sections) {
for (InterfaceWirelessSection section : sections) {
if (y > viewY) {
result = true;
scrollbar.setCurrentScroll(y);
@@ -978,11 +1042,11 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return result;
}
public void addEntry(IfaceEntry entry) {
IfaceSection section = sections.get(entry.dispName);
public void addEntry(InterfaceWirelessEntry entry) {
InterfaceWirelessSection section = sections.get(entry.dispName);
if (section == null) {
section = new IfaceSection(entry.dispName);
section = new InterfaceWirelessSection(entry.dispName);
sections.put(entry.dispName, section);
}
section.addEntry(entry);
@@ -991,14 +1055,14 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
public void removeEntry(long id) {
IfaceEntry entry = list.remove(id);
InterfaceWirelessEntry entry = list.remove(id);
if (entry != null) {
entry.section.removeEntry(entry);
}
}
public List<IfaceSection> getVisibleSections() {
public List<InterfaceWirelessSection> getVisibleSections() {
if (isDirty) {
update();
}
@@ -1016,7 +1080,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
if (relMouseX < 0 || relMouseX >= VIEW_WIDTH || relMouseY < 0 || relMouseY >= viewHeight) {
return false;
}
for (IfaceSection section : getVisibleSections()) {
for (InterfaceWirelessSection section : getVisibleSections()) {
if (section.mouseClicked(relMouseX, relMouseY, btn)) {
return true;
}
@@ -1028,13 +1092,13 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/**
* A section holds all the interface entries with the same name.
*/
private class IfaceSection {
private class InterfaceWirelessSection {
public static final int TITLE_HEIGHT = 12;
String name;
List<IfaceEntry> entries = new ArrayList<>();
Set<IfaceEntry> visibleEntries = new TreeSet<>(Comparator.comparing(e -> {
List<InterfaceWirelessEntry> entries = new ArrayList<>();
Set<InterfaceWirelessEntry> visibleEntries = new TreeSet<>(Comparator.comparing(e -> {
if (e.dispRep != null) {
return e.dispRep.getDisplayName() + e.id;
} else {
@@ -1045,7 +1109,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
private boolean isDirty = true;
boolean visible = false;
IfaceSection(String name) {
InterfaceWirelessSection(String name) {
this.name = name;
}
@@ -1065,7 +1129,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
height = 0;
} else {
height = TITLE_HEIGHT;
for (IfaceEntry entry : visibleEntries) {
for (InterfaceWirelessEntry entry : visibleEntries) {
height += entry.guiHeight;
}
}
@@ -1077,7 +1141,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
String input = GuiInterfaceWireless.this.searchFieldInputs.getText().toLowerCase();
String output = GuiInterfaceWireless.this.searchFieldOutputs.getText().toLowerCase();
for (IfaceEntry entry : entries) {
for (InterfaceWirelessEntry entry : entries) {
var moleAss = AEApi.instance().definitions().blocks().molecularAssembler().maybeStack(1);
entry.dispY = -9999;
if (onlyMolecularAssemblers
@@ -1088,7 +1152,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
&& entry.numItems == entry.rows * entry.rowSize) {
continue;
}
if (onlyBrokenRecipes && entry.numBrokenRecipes == 0) {
if (onlyBrokenRecipes && !entry.hasBrokenSlot()) {
continue;
}
// Find search terms
@@ -1116,19 +1180,19 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
}
public void addEntry(IfaceEntry entry) {
public void addEntry(InterfaceWirelessEntry entry) {
this.entries.add(entry);
entry.section = this;
this.isDirty = true;
}
public void removeEntry(IfaceEntry entry) {
public void removeEntry(InterfaceWirelessEntry entry) {
this.entries.remove(entry);
entry.section = null;
this.isDirty = true;
}
public Iterator<IfaceEntry> getVisible() {
public Iterator<InterfaceWirelessEntry> getVisible() {
if (isDirty) {
update();
}
@@ -1136,7 +1200,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
public boolean mouseClicked(int relMouseX, int relMouseY, int btn) {
Iterator<IfaceEntry> it = getVisible();
Iterator<InterfaceWirelessEntry> it = getVisible();
boolean ret = false;
while (it.hasNext() && !ret) {
@@ -1150,7 +1214,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/**
* This class keeps track of an entry and its widgets.
*/
private class IfaceEntry {
private class InterfaceWirelessEntry {
String dispName;
AppEngInternalInventory inv;
@@ -1161,21 +1225,20 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
ItemStack selfRep;
/** Nullable - icon that represents the interface's "target" */
ItemStack dispRep;
IfaceSection section;
InterfaceWirelessSection section;
long id;
int x, y, z, dim, side;
int rows, rowSize;
int guiHeight;
int dispY = -9999;
boolean online;
int numBrokenRecipes;
boolean[] brokenRecipes;
private Boolean[] brokenRecipes;
int numItems = 0;
/** Should recipe be filtered out/grayed out? */
boolean[] filteredRecipes;
private int hoveredSlotIdx = -1;
IfaceEntry(long id, String name, int rows, int rowSize, boolean online) {
InterfaceWirelessEntry(long id, String name, int rows, int rowSize, boolean online) {
this.id = id;
if (StatCollector.canTranslate(name)) {
this.dispName = StatCollector.translateToLocal(name);
@@ -1196,11 +1259,11 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
this.renameButton = new GuiFCImgButton(2, 0, "EDIT", "YES");
this.renameButton.setHalfSize(true);
this.guiHeight = 18 * rows + 1;
this.brokenRecipes = new boolean[rows * rowSize];
this.brokenRecipes = new Boolean[rows * rowSize];
this.filteredRecipes = new boolean[rows * rowSize];
}
IfaceEntry setLocation(int x, int y, int z, int dim, int side) {
InterfaceWirelessEntry setLocation(int x, int y, int z, int dim, int side) {
this.x = x;
this.y = y;
this.z = z;
@@ -1210,7 +1273,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return this;
}
IfaceEntry setIcons(ItemStack selfRep, ItemStack dispRep) {
InterfaceWirelessEntry setIcons(ItemStack selfRep, ItemStack dispRep) {
// Kotlin would make this pretty easy :(
this.selfRep = selfRep;
this.dispRep = dispRep;
@@ -1221,7 +1284,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
public void fullItemUpdate(NBTTagList items, int newSize) {
inv = new AppEngInternalInventory(null, newSize);
rows = newSize / rowSize;
brokenRecipes = new boolean[newSize];
brokenRecipes = new Boolean[newSize];
numItems = 0;
for (int i = 0; i < inv.getSizeInventory(); ++i) {
@@ -1230,7 +1293,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
this.guiHeight = 18 * rows + 4;
}
IfaceEntry setItems(NBTTagList items) {
InterfaceWirelessEntry setItems(NBTTagList items) {
assert items.tagCount() == inv.getSizeInventory();
for (int i = 0; i < items.tagCount(); ++i) {
@@ -1246,21 +1309,46 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
}
private void setItemInSlot(ItemStack stack, int idx) {
final int oldBroke = brokenRecipes[idx] ? 1 : 0;
final int newBroke = recipeIsBroken(stack) ? 1 : 0;
final int oldHasItem = inv.getStackInSlot(idx) != null ? 1 : 0;
final int newHasItem = stack != null ? 1 : 0;
// Update broken recipe count
numBrokenRecipes += newBroke - oldBroke;
brokenRecipes[idx] = newBroke == 1;
inv.setInventorySlotContents(idx, stack);
assert numBrokenRecipes >= 0;
// Update item count
numItems += newHasItem - oldHasItem;
assert numItems >= 0;
}
public boolean hasBrokenSlot() {
boolean existsUnknown = false;
for (int idx = 0; idx < brokenRecipes.length; idx++) {
if (brokenRecipes[idx] == null) {
existsUnknown = true;
} else if (brokenRecipes[idx] == true) {
return true;
}
}
if (existsUnknown) {
for (int idx = 0; idx < brokenRecipes.length; idx++) {
if (slotIsBroken(idx)) {
return true;
}
}
}
return false;
}
public boolean slotIsBroken(int idx) {
if (brokenRecipes[idx] == null) {
brokenRecipes[idx] = recipeIsBroken(inv.getStackInSlot(idx));
}
return brokenRecipes[idx];
}
public AppEngInternalInventory getInventory() {
return inv;
}
@@ -1270,7 +1358,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
return false;
}
if (mouseX >= optionsButton.xPosition && mouseX < 2 + optionsButton.width
&& mouseY > Math.max(optionsButton.yPosition, IfaceSection.TITLE_HEIGHT)
&& mouseY > Math.max(optionsButton.yPosition, InterfaceWirelessSection.TITLE_HEIGHT)
&& mouseY <= Math.min(optionsButton.yPosition + optionsButton.height, viewHeight)) {
optionsButton.func_146113_a(mc.getSoundHandler());
DimensionalCoord blockPos = new DimensionalCoord(x, y, z, dim);
@@ -1311,7 +1399,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
int offsetY = mouseY - dispY;
int offsetX = mouseX - (VIEW_WIDTH - rowSize * 18) - 1;
if (offsetX >= 0 && offsetX < (rowSize * 18)
&& mouseY > Math.max(dispY, IfaceSection.TITLE_HEIGHT)
&& mouseY > Math.max(dispY, InterfaceWirelessSection.TITLE_HEIGHT)
&& offsetY < Math.min(viewHeight - dispY, guiHeight)) {
final int col = offsetX / 18;
final int row = offsetY / 18;
@@ -6,6 +6,7 @@ import java.awt.Rectangle;
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;
@@ -40,6 +41,7 @@ import com.glodblock.github.network.CPacketLevelTerminalCommands;
import com.glodblock.github.util.FCGuiColors;
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;
@@ -56,6 +58,7 @@ 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")
@@ -75,6 +78,10 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
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));
this.cont = (ContainerLevelMaintainer) inventorySlots;
@@ -278,7 +285,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.input.textboxKeyTyped(character, key);
}
super.keyTyped(character, key);
if (!this.input.getText().matches("^[0-9]+")) {
if (!numberPattern.matcher(this.input.getText()).matches()) {
this.input.setTextColor(0xFF0000);
} else {
this.input.setTextColor(0xFFFFFF);
@@ -318,19 +325,18 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
}
public GuiType getOriginalGui() {
return originalGui;
}
public void switchGui() {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelTerminalCommands(
CPacketLevelTerminalCommands.Action.BACK,
originalBlockPos.x,
originalBlockPos.y,
originalBlockPos.z,
originalBlockPos.getDimension(),
originalBlockPos.getSide()));
CPacketLevelTerminalCommands message = new CPacketLevelTerminalCommands(
CPacketLevelTerminalCommands.Action.BACK,
originalBlockPos.x,
originalBlockPos.y,
originalBlockPos.z,
originalBlockPos.getDimension(),
originalBlockPos.getSide());
if (originalGui != null) {
message.setOriginalGui(originalGui.ordinal());
}
FluidCraft.proxy.netHandler.sendToServer(message);
}
@Override
@@ -354,9 +360,12 @@ 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)) {
if (getSlotArea(slot).contains(mouseX, mouseY) && draggedStack != null) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
@@ -365,9 +374,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
return true;
}
}
if (draggedStack != null) {
draggedStack.stackSize = 0;
}
return false;
}
@@ -412,7 +418,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private boolean send(Widget widget) {
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("^[0-9]+")) {
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()) {
String str = widget.textField.getText().replaceAll("^(0+)", "");
widget.textField.setText(str.isEmpty() ? "0" : str);
FluidCraft.proxy.netHandler.sendToServer(
@@ -538,7 +549,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.textField = textField;
this.textField.setEnableBackgroundDrawing(false);
this.textField.setText("0");
this.textField.setMaxStringLength(10); // this length is enough to useful
this.textField.setMaxStringLength(16); // this length is enough to be useful
this.idx = idx;
this.action = action;
this.tooltip = tooltip;
@@ -9,12 +9,14 @@ import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketOver
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketRemove;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketRename;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -25,6 +27,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -57,11 +60,13 @@ import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import appeng.api.config.Settings;
import appeng.api.config.TerminalFontSize;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.WorldCoord;
import appeng.client.gui.IGuiTooltipHandler;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
@@ -80,10 +85,11 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.common.Loader;
public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextField {
public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextField, IGuiTooltipHandler {
public static final int HEADER_HEIGHT = 52;
public static final int INV_HEIGHT = 98;
@@ -113,11 +119,13 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
// private GuiFCImgButton modeSwitchEdit;
private final LevelTerminalList masterList = new LevelTerminalList();
private final List<String> extraOptionsText = new ArrayList<>(2);
private static final float ITEM_STACK_Z = 1.0f;
private static final float ITEM_STACK_Z = 100.0f;
private static final float SLOT_Z = 0.5f;
private static final float ITEM_STACK_OVERLAY_Z = 20.0f;
private static final float SLOT_HOVER_Z = 31.0f;
private static final float TOOLTIP_Z = 200.0f;
private static final float ITEM_STACK_OVERLAY_Z = 200.0f;
private static final float SLOT_HOVER_Z = 310.0f;
private static final float TOOLTIP_Z = 410.0f;
private static final float STEP_Z = 10.0f;
private static final float MAGIC_RENDER_ITEM_Z = 50.0f;
public GuiLevelTerminal(InventoryPlayer inventoryPlayer, Container container) {
super(inventoryPlayer, container);
@@ -439,32 +447,14 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
/*
* Render title
*/
GL11.glTranslatef(0.0f, 0.0f, 50f);
mc.getTextureManager().bindTexture(TEX_BG);
if (sectionBottom > 0 && sectionBottom < LevelTerminalSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj
.drawString(section.name, 2, sectionBottom - LevelTerminalSection.TITLE_HEIGHT + 2, fontColor);
title = sectionBottom;
} else if (viewY < 0) {
/* Hidden title draw */
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
title = 0;
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -50f);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Iterator<LevelTerminalEntry> visible = section.getVisible();
@@ -484,6 +474,36 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
entry.configButton.yPosition = -1;
}
}
/*
* Render title
*/
mc.getTextureManager().bindTexture(TEX_BG);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < LevelTerminalSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj
.drawString(section.name, 2, sectionBottom - LevelTerminalSection.TITLE_HEIGHT + 2, fontColor);
} else if (viewY < 0) {
/* Hidden title draw */
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0.0f, 0.0f, 100f);
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
GL11.glEnable(GL11.GL_DEPTH_TEST);
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
}
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
return LevelTerminalSection.TITLE_HEIGHT + renderY;
}
@@ -568,7 +588,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
&& relMouseY < Math.min(viewY + rowYBot, viewHeight);
if (stack != null) {
AEItemStack aeItemStack = AEItemStack.create(stack);
NBTTagCompound data = stack.getTagCompound();
ItemStack itemStack = data.hasKey(TLMTags.Stack.tagName)
? ItemStack.loadItemStackFromNBT(data.getCompoundTag(TLMTags.Stack.tagName))
@@ -582,21 +601,12 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
aeItemStack.setStackSize(1);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.zLevel = 3.0f - 50.0f;
itemStack.stackSize = 0;
aeRenderItem.setAeStack(null);
aeRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aeRenderItem.zLevel = 0.0f;
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
aeItemStack.setStackSize(quantity);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
if (batch > 0) {
aeItemStack.setStackSize(batch);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem
.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, -11);
}
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
int color = switch (state) {
case Idle -> FCGuiColors.StateIdle.getColor();
case Craft -> FCGuiColors.StateCraft.getColor();
@@ -607,6 +617,11 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
int offset = 0;
int size = 4;
drawRect(offset, offset, offset + size, offset + size, color);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
this.drawReadableAmount(fontRendererObj, quantity, true, 16777215);
if (batch > 0) {
this.drawReadableAmount(fontRendererObj, batch, false, 16777215);
}
RenderHelper.disableStandardItemLighting();
/*
@@ -644,6 +659,53 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
return relY + 1;
}
public void drawReadableAmount(final FontRenderer fontRenderer, long amount, boolean alignBottom, int color) {
final TerminalFontSize fontSize = AEConfig.instance.getTerminalFontSize();
final String stackSize = this.getToBeRenderedStackSize(amount, fontSize);
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
float scaleFactor = 0.85f;
float shiftX = 0f;
float shiftY = 0f;
if (fontSize == TerminalFontSize.SMALL) {
scaleFactor = 0.5f;
shiftX = -2.0f;
shiftY = -1.0f;
}
final float inverseScaleFactor = 1.0f / scaleFactor;
fontRenderer.setUnicodeFlag(false);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
final int X = (int) ((shiftX + 16.0f + 1.0f - fontRenderer.getStringWidth(stackSize) * scaleFactor)
* inverseScaleFactor);
final int Y = (int) (alignBottom ? (shiftY + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor : 1);
fontRenderer.drawString(stackSize, X + 1, Y, 0);
fontRenderer.drawString(stackSize, X - 1, Y, 0);
fontRenderer.drawString(stackSize, X, Y + 1, 0);
fontRenderer.drawString(stackSize, X, Y - 1, 0);
fontRenderer.drawString(stackSize, X, Y, color);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
fontRenderer.setUnicodeFlag(unicodeFlag);
}
private String getToBeRenderedStackSize(final long originalSize, TerminalFontSize fontSize) {
if (fontSize == TerminalFontSize.SMALL) {
return ReadableNumberConverter.INSTANCE.toWideReadableForm(originalSize);
} else {
return ReadableNumberConverter.INSTANCE.toSlimReadableForm(originalSize);
}
}
@SuppressWarnings("unchecked")
@Override
public void drawHoveringText(List textLines, int x, int y, FontRenderer font) {
@@ -888,6 +950,26 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
@Override
public List<String> handleItemTooltip(ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip) {
if (stack != null && isShiftKeyDown() && stack.hasTagCompound()) {
NBTTagCompound data = stack.getTagCompound();
if (data.hasKey(TLMTags.Quantity.tagName)) {
long quantity = data.getLong(TLMTags.Quantity.tagName);
long batch = data.getLong(TLMTags.Batch.tagName);
currentToolTip.add(
I18n.format(NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE, "\n", false) + ": "
+ NumberFormat.getNumberInstance(Locale.US).format(quantity));
if (batch > 0) {
currentToolTip.add(
I18n.format(NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE, "\n", false) + ": "
+ NumberFormat.getNumberInstance(Locale.US).format(batch));
}
}
}
return currentToolTip;
}
@@ -1334,7 +1416,8 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
if (action != null) {
ItemStack itemStack = getInventory().getStackInSlot(slotIdx);
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
if (itemStack != null && itemStack.hasTagCompound()
&& itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
long batch = itemStack.getTagCompound().getLong(TLMTags.Batch.tagName);
NBTTagCompound stackData = itemStack.getTagCompound().getCompoundTag(TLMTags.Stack.tagName);
ItemStack is = ItemStack.loadItemStackFromNBT(stackData);
@@ -35,6 +35,8 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
protected ItemStack icon = null;
protected GuiType originalGui;
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(new ContainerRenamer(ip, monitorable));
this.host = monitorable;
@@ -51,12 +53,16 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
if (host instanceof PartLevelTerminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
} else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host)) {
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (host instanceof WirelessLevelTerminalInventory) {
icon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
} else if (host instanceof WirelessInterfaceTerminalInventory) {
icon = ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack();
originalGui = GuiType.WIRELESS_INTERFACE_TERMINAL;
}
if (this.icon != null) {
this.buttonList.add(
@@ -114,13 +120,9 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
}
public void switchGui() {
if (host instanceof PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(terminal.getItemStack()));
else if (host instanceof WirelessInterfaceTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
else if (host instanceof WirelessLevelTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_LEVEL_TERMINAL);
if (originalGui != null) {
InventoryHandler.switchGui(originalGui);
}
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
@@ -42,10 +42,11 @@ public abstract class FCGuiAmount extends AEBaseGui {
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
final int a = getIncrementQuantity(0);
final int b = getIncrementQuantity(1);
final int c = getIncrementQuantity(2);
final int d = getIncrementQuantity(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));
@@ -85,6 +86,10 @@ 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());
@@ -101,6 +101,8 @@ 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) {
@@ -167,8 +169,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
protected void reInitalize() {
this.buttonList.clear();
this.initGui();
reInitializationRequested = true;
}
@Override
@@ -182,7 +183,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = 0;
final int NEI = hasNEI ? 1 : 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
@@ -216,6 +217,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
super.initGui();
this.setScrollBar();
// full size : 204
// extra slots : 72
// slot 18
@@ -666,6 +668,11 @@ 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();
}
@@ -1,7 +1,6 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -23,7 +22,6 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
@@ -37,110 +35,118 @@ public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
&& AspectUtil.isEssentiaContainer(clickSlot.getStack())) {
ItemStack tis = clickSlot.getStack();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
tmp.put(0, null);
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(index));
}
}
return super.transferStackInSlot(p, idx);
}
@Override
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player,
int slotIndex) {
for (IAEFluidStack fluid : change) {
IAEFluidStack nfluid = this.monitor.getStorageList().findPrecise(fluid);
ItemStack out = fluidContainer.copy();
out.stackSize = 1;
if (AspectUtil.isEmptyEssentiaContainer(fluidContainer) && AspectUtil.isEssentiaGas(fluid)) {
// add essentia to jars
if (nfluid.getStackSize() / AspectUtil.R <= 0) continue;
final IAEFluidStack toExtract = nfluid.copy();
MutablePair<Integer, ItemStack> fillStack = AspectUtil
.fillEssentiaFromGas(out, toExtract.getFluidStack());
if (fillStack == null || fillStack.right == null || fillStack.left <= 0) continue;
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
IAEFluidStack tmp = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
if (tmp == null) continue;
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
this.dropItem(
AspectUtil.setAspectAmount(
fillStack.right,
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
AspectUtil.getAspectFromGas(toExtract)),
1);
out.stackSize++;
}
}
} else if (!AspectUtil.isEmptyEssentiaContainer(fluidContainer)) {
// add essentia to ae network
AEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(fluidContainer);
if (fluidStack == null) {
continue;
}
final IAEFluidStack aeFluidStack = fluidStack.copy();
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
MutablePair<Integer, ItemStack> drainStack = AspectUtil
.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
if (fluidStack.getStackSize() == notInserted.getStackSize()) continue;
aeFluidStack.decStackSize(notInserted.getStackSize());
public void postChange(IAEFluidStack clientSelectedFluid, EntityPlayer player, int slotIndex, boolean shift) {
ItemStack targetStack;
if (slotIndex == -1) {
targetStack = player.inventory.getItemStack();
} else {
targetStack = player.inventory.getStackInSlot(slotIndex);
}
final int containersRequested = shift ? targetStack.stackSize : 1;
if (drainStack.left > aeFluidStack.getStackSize()
&& AspectUtil.isEssentiaContainer(drainStack.right)) {
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
this.host.getFluidInventory()
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
continue;
}
// drop empty item
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
if (notInserted.getStackSize() % drainStack.left > 0) {
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
this.dropItem(drainStack.right, 1);
}
}
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
} else if (drainStack != null) {
if (slotIndex == -1) {
out.stackSize = fluidContainer.stackSize;
} else {
out.stackSize = (int) (fluidContainer.stackSize
- (aeFluidStack.getStackSize() / drainStack.left));
}
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
}
} else {
continue;
IAEFluidStack storedFluid = this.monitor.getStorageList().findPrecise(clientSelectedFluid);
ItemStack out = targetStack.copy();
out.stackSize = 1;
if (AspectUtil.isEmptyEssentiaContainer(targetStack) && AspectUtil.isEssentiaGas(storedFluid)) {
// add essentia to jars
if (storedFluid.getStackSize() / AspectUtil.R <= 0) {
return;
}
if (slotIndex == -1) {
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
if (player.inventory.getItemStack().stackSize > 0) {
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
(EntityPlayerMP) player);
final IAEFluidStack toExtract = storedFluid.copy();
MutablePair<Integer, ItemStack> fillStack = AspectUtil.fillEssentiaFromGas(out, toExtract.getFluidStack());
if (fillStack == null || fillStack.right == null || fillStack.left <= 0) {
return;
}
toExtract.setStackSize((long) fillStack.left * containersRequested);
IAEFluidStack tmp = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
if (tmp == null) {
return;
}
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
this.dropItem(
AspectUtil.setAspectAmount(
fillStack.right,
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
AspectUtil.getAspectFromGas(toExtract)),
1);
out.stackSize++;
}
}
} else if (!AspectUtil.isEmptyEssentiaContainer(targetStack)) {
// add essentia to ae network
ItemStack containerStack = targetStack.copy();
containerStack.stackSize = containersRequested;
IAEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(containerStack);
if (fluidStack == null) {
return;
}
final IAEFluidStack aeFluidStack = fluidStack.copy();
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
MutablePair<Integer, ItemStack> drainStack = AspectUtil
.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
if (fluidStack.getStackSize() == notInserted.getStackSize()) {
return;
}
aeFluidStack.decStackSize(notInserted.getStackSize());
if (drainStack.left > aeFluidStack.getStackSize() && AspectUtil.isEssentiaContainer(drainStack.right)) {
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
this.host.getFluidInventory()
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
return;
}
// drop empty item
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
if (notInserted.getStackSize() % drainStack.left > 0) {
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
this.dropItem(drainStack.right, 1);
}
}
if (slotIndex == -1) out.stackSize = targetStack.stackSize - out.stackSize;
} else if (drainStack != null) {
if (slotIndex == -1) {
out.stackSize = targetStack.stackSize;
} else {
player.inventory.setItemStack(null);
FluidCraft.proxy.netHandler
.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
out.stackSize = (int) (targetStack.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
}
} else {
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
this.dropItem(drainStack.right, targetStack.stackSize); // drop empty item
}
} else {
return;
}
if (slotIndex == -1) {
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
if (player.inventory.getItemStack().stackSize > 0) {
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
(EntityPlayerMP) player);
} else {
player.inventory.setItemStack(null);
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
} else {
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
}
this.detectAndSendChanges();
}
@@ -9,14 +9,21 @@ 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 {
@@ -35,6 +42,9 @@ 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) {
@@ -57,4 +67,34 @@ 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);
}
}
}
}
@@ -3,7 +3,6 @@ package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -18,7 +17,7 @@ import net.minecraftforge.fluids.IFluidContainerItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
@@ -44,7 +43,6 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
@@ -124,11 +122,8 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
&& Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
ItemStack tis = clickSlot.getStack();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
tmp.put(0, ItemFluidDrop.getAeFluidStack(AEItemStack.create(tis)));
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(index));
}
}
return super.transferStackInSlot(p, idx);
@@ -211,72 +206,26 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
* @param slotIndex The slot. If index == -1, the cursor held itemstack. Else, slotIndex indicates which slot was
* shift clicked on.
*/
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player,
int slotIndex) {
int cursorItems;
public void postChange(IAEFluidStack fluid, EntityPlayer player, int slotIndex, boolean shift) {
ItemStack targetStack;
if (slotIndex == -1) {
cursorItems = player.inventory.getItemStack().stackSize;
targetStack = player.inventory.getItemStack();
} else {
cursorItems = player.inventory.getStackInSlot(slotIndex).stackSize;
targetStack = player.inventory.getStackInSlot(slotIndex);
}
for (IAEFluidStack fluid : change) {
// The primary output itemstack
if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) {
// Situation 1.a: Empty fluid container, and nonnull slot
extractFluid(fluid, fluidContainer, player, cursorItems);
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
// Situation 2.a: We are holding a non-empty container.
insertFluid(fluidContainer, player, slotIndex, cursorItems);
// End of situation 2.a
}
// No op (Any other situation)
// The primary output itemstack
if (Util.FluidUtil.isEmpty(targetStack) && fluid != null) {
// Situation 1.a: Empty fluid container, and nonnull slot
extractFluid(fluid, player, slotIndex, shift);
} else if (!Util.FluidUtil.isEmpty(targetStack)) {
// Situation 2.a: We are holding a non-empty container.
insertFluid(player, slotIndex, shift);
// End of situation 2.a
}
// No op (Any other situation)
this.detectAndSendChanges();
}
/**
* Insert fluid into the ME system
*
* @param canSend the fluidstack to insert
* @param results a tuple of at least size 3 to indicate outputs (1), (2), (3). This will be mutated!
* @param numTanks number of tanks involved in the operation
* @param fluidInTank how much fluid is in the tank initially
* @return the amount of fluid remaining in output (3)
* @see #insertFluid(ItemStack, EntityPlayer, int, int)
*/
private int insertME(IAEFluidStack canSend, int[] results, int numTanks, int fluidInTank) {
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(canSend, Actionable.MODULATE, this.getActionSource());
// Check if we need to handle partial insertion.
if (notInserted != null && notInserted.getStackSize() > 0) {
if (canSend.getStackSize() == notInserted.getStackSize()) {
// No-op for when system is full
results[REM_IDX] = numTanks;
return fluidInTank;
}
// Populate result list with outputs (1), (2), (3).
results[REM_IDX] = (int) (notInserted.getStackSize() / fluidInTank);
results[ACT_IDX] = numTanks - results[REM_IDX];
// If there is remaining fluid, set partial.
final int remainder = (int) (notInserted.getStackSize() % fluidInTank);
if (remainder > 0) {
results[PARTIAL_IDX] = 1;
results[ACT_IDX]--;
return remainder;
} else {
results[PARTIAL_IDX] = 0;
}
} else {
// Full operation successful
results[REM_IDX] = 0;
results[ACT_IDX] = numTanks;
results[PARTIAL_IDX] = 0;
}
return 0;
}
/**
* The insert operation. For input, we have a filled container stack. For outputs, we have the following:
* <ol>
@@ -286,119 +235,160 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
*/
private void insertFluid(ItemStack fluidContainer, EntityPlayer player, int slotIndex, int heldContainers) {
IAEFluidStack canSend;
int fluidPerContainer;
ItemStack partialStack = null;
ItemStack emptyStack = null;
int[] insertionResults = new int[3];
private void insertFluid(EntityPlayer player, int slotIndex, boolean shift) {
final ItemStack targetStack;
if (slotIndex == -1) {
targetStack = player.inventory.getItemStack();
} else {
targetStack = player.inventory.getStackInSlot(slotIndex);
}
final int containersRequestedToInsert = shift ? targetStack.stackSize : 1;
// 2 types of containers: IFluidContainerItem and FluidContainerRegistry
// IFluidContainerItem - items are filled w/ volume (portable tanks)
// FluidContainerRegistry - items are filled, or not (buckets)
// The former is easy, the latter takes a bit more work.
if (fluidContainer.getItem() instanceof IFluidContainerItem fcItem) {
// Step 1: Find out how much fluid we can insert.
canSend = AEFluidStack.create(fcItem.getFluid(fluidContainer));
fluidPerContainer = (int) canSend.getStackSize();
canSend.setStackSize((long) fluidPerContainer * fluidContainer.stackSize);
// Step 2: Find out how much fluid we can extract from the container. If this is null or 0, return.
ItemStack test = fluidContainer.copy();
// Step 1: Determine container characteristics and verify fluid to be extractable
final int fluidPerContainer;
final FluidStack fluidStackPerContainer;
final boolean partialInsertSupported;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
ItemStack test = targetStack.copy();
test.stackSize = 1;
FluidStack fluidStack = fcItem.drain(test, fluidPerContainer, false);
if (fluidStack == null || fluidStack.amount == 0) {
fluidStackPerContainer = fcItem.drain(test, Integer.MAX_VALUE, false);
if (fluidStackPerContainer == null || fluidStackPerContainer.amount == 0) {
return;
}
// Step 3: Find out how much fluid we can insert into the ME system
int partialAmount = insertME(canSend, insertionResults, fluidContainer.stackSize, fluidPerContainer);
// Step 4: Separate the outputs into no drain (1), fully drained (2), and partially drained (3)
// 4.1: Handle the partial stack
if (insertionResults[PARTIAL_IDX] > 0) {
partialStack = fluidContainer.copy();
partialStack.stackSize = 1;
fcItem.drain(partialStack, fluidPerContainer - partialAmount, true);
}
// 4.2: Handle empty output
if (insertionResults[ACT_IDX] > 0) {
emptyStack = fluidContainer.copy();
emptyStack.stackSize = 1;
fcItem.drain(emptyStack, fluidPerContainer, true);
emptyStack.stackSize = insertionResults[ACT_IDX];
}
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
// Step 1: Find out how much fluid we can insert.
canSend = AEFluidStack.create(FluidContainerRegistry.getFluidForFilledItem(fluidContainer));
fluidPerContainer = (int) canSend.getStackSize();
canSend.setStackSize((long) fluidPerContainer * fluidContainer.stackSize);
// Step 2: Find out how much fluid we can extract from the container. If this is null or 0, return.
ItemStack emptyTank = FluidContainerRegistry.drainFluidContainer(fluidContainer);
fluidPerContainer = fluidStackPerContainer.amount;
partialInsertSupported = true;
} else if (FluidContainerRegistry.isContainer(targetStack)) {
ItemStack emptyTank = FluidContainerRegistry.drainFluidContainer(targetStack);
if (emptyTank == null) {
return;
}
// Step 3: Find out how much fluid we can insert into the ME system
int partialAmount = insertME(canSend, insertionResults, fluidContainer.stackSize, fluidPerContainer);
// Step 4: Separate the outputs into no drain (1), fully drained (2), and partially drained (3)
// 4.1: Handle the partial stack
if (partialAmount > 0) {
// We now extract the extra amount from the ME system. Blame simulate not working :P
int extract = FluidContainerRegistry.getContainerCapacity(fluidContainer) - partialAmount;
if (extract > 0) {
IAEFluidStack toExtract = canSend.copy().setStackSize(extract);
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
}
insertionResults[PARTIAL_IDX] = 0;
}
// 4.2: Handle empty output
if (insertionResults[ACT_IDX] > 0) {
emptyStack = FluidContainerRegistry.drainFluidContainer(fluidContainer);
emptyStack.stackSize = insertionResults[ACT_IDX];
}
fluidStackPerContainer = FluidContainerRegistry.getFluidForFilledItem(targetStack);
fluidPerContainer = fluidStackPerContainer.amount;
partialInsertSupported = false;
} else {
return;
}
// Step 2: determine network capacity
final IAEFluidStack totalFluid = AEFluidStack.create(fluidStackPerContainer);
totalFluid.setStackSize((long) fluidPerContainer * containersRequestedToInsert);
final IAEFluidStack notInsertable = this.host.getFluidInventory()
.injectItems(totalFluid, Actionable.SIMULATE, this.getActionSource());
final long insertableFluid;
if (notInsertable == null || notInsertable.getStackSize() == 0) {
insertableFluid = totalFluid.getStackSize();
} else {
long insertable = totalFluid.getStackSize() - notInsertable.getStackSize();
if (partialInsertSupported) {
insertableFluid = insertable;
} else {
// avoid remainder
insertableFluid = insertable - (insertable % fluidPerContainer);
}
}
totalFluid.setStackSize(insertableFluid);
// Step 3: perform insert
final long totalInserted;
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(totalFluid, Actionable.MODULATE, this.getActionSource());
if (notInserted != null && notInserted.getStackSize() > 0) {
// User has a setup that causes discrepancy between simulation and modulation. Likely double storage bus.
long total = totalFluid.getStackSize() - notInserted.getStackSize();
if (partialInsertSupported) {
totalInserted = total;
} else {
// We cant have partially filled containers -> user will receive a fluid packet as last resort
long overflowAmount = fluidPerContainer - (total % fluidPerContainer);
IAEFluidStack overflow = AEFluidStack.create(fluidStackPerContainer);
overflow.setStackSize(overflowAmount);
dropItem(ItemFluidPacket.newStack(overflow));
totalInserted = total + overflowAmount;
}
} else {
totalInserted = totalFluid.getStackSize();
}
// Step 4: calculate outputs
final int emptiedTanks;
final int partialDrain;
if (fluidPerContainer > 0) {
emptiedTanks = (int) (totalInserted / fluidPerContainer);
partialDrain = (int) (totalInserted % fluidPerContainer);
} else {
emptiedTanks = containersRequestedToInsert;
partialDrain = 0;
}
final int partialTanks = partialDrain > 0 && partialInsertSupported ? 1 : 0;
final int usedTanks = emptiedTanks + partialTanks;
final int untouchedTanks = targetStack.stackSize - usedTanks;
final ItemStack emptiedTanksStack;
final ItemStack partialTanksStack;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
if (emptiedTanks > 0) {
emptiedTanksStack = targetStack.copy();
emptiedTanksStack.stackSize = 1;
fcItem.drain(emptiedTanksStack, fluidPerContainer, true);
emptiedTanksStack.stackSize = emptiedTanks;
} else {
emptiedTanksStack = null;
}
if (partialTanks > 0) {
partialTanksStack = targetStack.copy();
partialTanksStack.stackSize = 1;
fcItem.drain(partialTanksStack, partialDrain, true);
} else {
partialTanksStack = null;
}
} else {
if (emptiedTanks > 0) {
emptiedTanksStack = FluidContainerRegistry.drainFluidContainer(targetStack);
emptiedTanksStack.stackSize = emptiedTanks;
} else {
emptiedTanksStack = null;
}
// Not possible > see Step 2 and Step 3
partialTanksStack = null;
}
// Done. Put the output in the inventory or ground, and update stack size.
boolean shouldSendStack = true;
int emptyTanks = insertionResults[ACT_IDX];
int extraTanks = heldContainers - emptyTanks - insertionResults[PARTIAL_IDX];
if (slotIndex == -1) {
// Item is in mouse hand
if (extraTanks > 0) {
ItemStack stack = player.inventory.getItemStack();
stack.stackSize = extraTanks;
adjustStack(stack);
dropItem(emptyStack);
dropItem(partialStack);
} else if (emptyTanks != 0) {
adjustStack(emptyStack);
player.inventory.setItemStack(emptyStack);
dropItem(partialStack);
} else if (partialStack != null) {
player.inventory.setItemStack(partialStack);
if (untouchedTanks > 0) {
targetStack.stackSize = untouchedTanks;
adjustStack(targetStack);
dropItem(emptiedTanksStack);
dropItem(partialTanksStack);
} else if (emptiedTanksStack != null) {
adjustStack(emptiedTanksStack);
player.inventory.setItemStack(emptiedTanksStack);
dropItem(partialTanksStack);
} else if (partialTanksStack != null) {
player.inventory.setItemStack(partialTanksStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
}
} else {
// Shift clicked in
ItemStack stack = player.inventory.getStackInSlot(slotIndex);
if (extraTanks > 0) {
stack.stackSize = extraTanks;
adjustStack(stack);
dropItem(emptyStack);
dropItem(partialStack);
} else if (emptyTanks != 0) {
adjustStack(emptyStack);
player.inventory.setInventorySlotContents(slotIndex, emptyStack);
dropItem(partialStack);
} else if (partialStack != null) {
player.inventory.setInventorySlotContents(slotIndex, partialStack);
if (untouchedTanks > 0) {
targetStack.stackSize = untouchedTanks;
adjustStack(targetStack);
dropItem(emptiedTanksStack);
dropItem(partialTanksStack);
} else if (emptiedTanksStack != null) {
adjustStack(emptiedTanksStack);
player.inventory.setInventorySlotContents(slotIndex, emptiedTanksStack);
dropItem(partialTanksStack);
} else if (partialTanksStack != null) {
player.inventory.setInventorySlotContents(slotIndex, partialTanksStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
@@ -422,97 +412,119 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
*/
private void extractFluid(IAEFluidStack fluid, ItemStack fluidContainer, EntityPlayer player, int heldContainers) {
// Step 1: Check if fluid can actually get filled into the fluidContainer
if (fluidContainer.getItem() instanceof IFluidContainerItem fcItem) {
ItemStack testStack = fluidContainer.copy();
private void extractFluid(IAEFluidStack clientRequestedFluid, EntityPlayer player, int slotIndex, boolean shift) {
if (slotIndex != -1) {
// shift-click from inventory cant fill fluids
return;
}
final ItemStack targetStack = player.inventory.getItemStack();
final int containersRequestedToExtract = shift ? targetStack.stackSize : 1;
final FluidStack clientRequestedFluidStack = clientRequestedFluid.getFluidStack();
clientRequestedFluidStack.amount = Integer.MAX_VALUE;
// Step 1: Determine container characteristics and verify fluid to be insertable
final int fluidPerContainer;
final boolean partialInsertSupported;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
ItemStack testStack = targetStack.copy();
testStack.stackSize = 1;
int test = fcItem.fill(testStack, fluid.getFluidStack(), false);
if (test == 0) {
return;
}
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
ItemStack test = FluidContainerRegistry.fillFluidContainer(fluid.getFluidStack(), fluidContainer);
if (test == null) {
fluidPerContainer = fcItem.fill(testStack, clientRequestedFluidStack, false);
if (fluidPerContainer == 0) {
return;
}
partialInsertSupported = true;
} else if (FluidContainerRegistry.isContainer(targetStack)) {
fluidPerContainer = FluidContainerRegistry.getContainerCapacity(clientRequestedFluidStack, targetStack);
partialInsertSupported = false;
} else {
return;
}
IAEFluidStack storedFluid = this.monitor.getStorageList().findPrecise(fluid);
if (storedFluid == null || storedFluid.getStackSize() <= 0) return;
int capacity = Util.FluidUtil.getCapacity(fluidContainer, storedFluid.getFluid());
if (capacity == 0) return;
// The fluidstack that we will try to extract from the system.
final IAEFluidStack canExtract = storedFluid.copy();
// Maximum amount of fluid we can extract with the given container(s). Guarantees that we won't
// run into issues w/ remainder fluid later.
canExtract.setStackSize((long) capacity * fluidContainer.stackSize);
IAEFluidStack actualExtract = this.host.getFluidInventory()
.extractItems(canExtract, Actionable.MODULATE, this.getActionSource());
if (actualExtract == null) return;
// Calculate the number of full fluid containers we extracted
long toExtract = actualExtract.getStackSize();
int filledTanks = (int) (toExtract / capacity);
int remainder = (int) (toExtract % capacity);
int emptyTanks = heldContainers - filledTanks;
// Fill the filled tanks
ItemStack filledStack = fluidContainer.copy();
filledStack.stackSize = 1;
if (filledTanks > 0) {
if (filledStack.getItem() instanceof IFluidContainerItem) {
int amt = ((IFluidContainerItem) filledStack.getItem())
.fill(filledStack, actualExtract.getFluidStack(), true);
assert amt == capacity;
} else {
// Should not be NPE since we affirmed that we have enough capacity.
filledStack = FluidContainerRegistry.fillFluidContainer(actualExtract.getFluidStack(), filledStack);
assert capacity == FluidContainerRegistry.getContainerCapacity(filledStack);
}
filledStack.stackSize = filledTanks;
} else {
filledStack.stackSize = 0;
// Step 2: determine fluid in network
final IAEFluidStack totalRequestedFluid = clientRequestedFluid.copy();
totalRequestedFluid.setStackSize((long) fluidPerContainer * containersRequestedToExtract);
final IAEFluidStack availableFluid = this.host.getFluidInventory()
.extractItems(totalRequestedFluid, Actionable.SIMULATE, this.getActionSource());
if (availableFluid == null || availableFluid.getStackSize() == 0) {
return;
}
// Calculate the remaining fluid to extract, if any
ItemStack partialStack = fluidContainer.copy();
if (remainder > 0) {
actualExtract.setStackSize(remainder);
partialStack.stackSize = 1;
if (partialStack.getItem() instanceof IFluidContainerItem) {
int amt = ((IFluidContainerItem) partialStack.getItem())
.fill(partialStack, actualExtract.getFluidStack(), true);
assert amt == remainder;
emptyTanks--;
if (availableFluid.getStackSize() != totalRequestedFluid.getStackSize() && !partialInsertSupported) {
availableFluid.decStackSize(availableFluid.getStackSize() % fluidPerContainer);
}
// Step 3: perform extract
final IAEFluidStack extracted = this.host.getFluidInventory()
.extractItems(availableFluid, Actionable.MODULATE, this.getActionSource());
final long totalExtracted = extracted != null ? extracted.getStackSize() : 0;
// Step 4: calculate outputs
final int filledTanks = (int) (totalExtracted / fluidPerContainer);
final int partialFill = (int) (totalExtracted % fluidPerContainer);
final int partialTanks = partialFill > 0 && partialInsertSupported ? 1 : 0;
final int usedTanks = filledTanks + partialTanks;
final int untouchedTanks = targetStack.stackSize - usedTanks;
final ItemStack filledTanksStack;
final ItemStack partialTanksStack;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
if (filledTanks > 0) {
filledTanksStack = targetStack.copy();
filledTanksStack.stackSize = 1;
FluidStack toInsert = extracted.getFluidStack().copy();
toInsert.amount = fluidPerContainer;
fcItem.fill(filledTanksStack, toInsert, true);
filledTanksStack.stackSize = filledTanks;
} else {
ItemStack dummy = FluidContainerRegistry
.fillFluidContainer(actualExtract.getFluidStack(), partialStack);
if (dummy == null) {
// Failed to fill partial...
partialStack.stackSize = 0;
} else {
partialStack = dummy;
emptyTanks--;
}
filledTanksStack = null;
}
if (partialTanks > 0) {
partialTanksStack = targetStack.copy();
partialTanksStack.stackSize = 1;
FluidStack toInsert = extracted.getFluidStack().copy();
toInsert.amount = partialFill;
fcItem.fill(partialTanksStack, toInsert, true);
} else {
partialTanksStack = null;
}
} else {
partialStack.stackSize = 0;
if (filledTanks > 0) {
FluidStack toInsert = extracted.getFluidStack().copy();
toInsert.amount = fluidPerContainer;
filledTanksStack = FluidContainerRegistry.fillFluidContainer(toInsert, targetStack);
filledTanksStack.stackSize = filledTanks;
} else {
filledTanksStack = null;
}
if (partialFill > 0) {
// User has a setup that causes discrepancy between simulation and modulation. Likely double storage
// bus.
// We cant have partially filled containers -> user will receive a fluid packet as last resort
IAEFluidStack overflow = extracted.copy();
overflow.setStackSize(partialFill);
dropItem(ItemFluidPacket.newStack(overflow));
}
partialTanksStack = null;
}
// Done. Put the output in the inventory or ground, and update stack size.
// We can assume slotIndex == -1, since we don't actually allow extraction via shift click.
boolean shouldSendStack = true;
if (emptyTanks > 0) {
if (untouchedTanks > 0) {
ItemStack emptyStack = player.inventory.getItemStack();
emptyStack.stackSize = emptyTanks;
emptyStack.stackSize = untouchedTanks;
adjustStack(emptyStack);
dropItem(filledStack);
dropItem(partialStack);
} else if (filledStack.stackSize != 0) {
adjustStack(filledStack);
player.inventory.setItemStack(filledStack);
dropItem(partialStack);
} else if (partialStack.stackSize != 0) {
player.inventory.setItemStack(partialStack);
dropItem(filledTanksStack);
dropItem(partialTanksStack);
} else if (filledTanksStack != null) {
adjustStack(filledTanksStack);
player.inventory.setItemStack(filledTanksStack);
dropItem(partialTanksStack);
} else if (partialTanksStack != null) {
player.inventory.setItemStack(partialTanksStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
@@ -0,0 +1,69 @@
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);
}
}
}
@@ -135,10 +135,10 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
data.setTag(TLMTags.Stack.tagName, itemStackTag);
}
if (!data.hasKey(TLMTags.Quantity.tagName)) {
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize);
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize > 0 ? itemStack.stackSize : 1);
}
if (!data.hasKey(TLMTags.Batch.tagName)) {
data.setLong(TLMTags.Batch.tagName, 0);
data.setLong(TLMTags.Batch.tagName, 1);
}
if (!data.hasKey(TLMTags.Enable.tagName)) {
data.setBoolean(TLMTags.Enable.tagName, false);
@@ -46,7 +46,7 @@ public class ContainerLevelTerminal extends FCBaseContainer {
*/
private int nextId = 0;
private final Map<ILevelViewable, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
private final Map<IGridHost, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
private IGrid grid;
@@ -246,21 +246,22 @@ public class ContainerLevelTerminal extends FCBaseContainer {
private SPacketLevelTerminalUpdate updateList() {
SPacketLevelTerminalUpdate update = null;
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
Set<ILevelViewable> visited = new HashSet<>();
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(gridNode.getMachine())
: (ILevelViewable) gridNode.getMachine();
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridHost)
: (ILevelViewable) gridHost;
/* First check if we are already tracking this node */
if (tracked.containsKey(machine)) {
if (tracked.containsKey(gridHost)) {
/* Check for updates */
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(machine);
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(gridHost);
/* Name changed? */
String name = machine.getCustomName();
@@ -310,15 +311,15 @@ public class ContainerLevelTerminal extends FCBaseContainer {
.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(machine, entry);
tracked.put(gridHost, entry);
trackedById.put(entry.id, entry);
}
visited.add(machine);
visited.add(gridHost);
}
}
/* Now find any entries that we need to remove */
Iterator<Map.Entry<ILevelViewable, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
Iterator<Map.Entry<IGridHost, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
while (it.hasNext()) {
var entry = it.next();
if (visited.contains(entry.getKey())) {
@@ -17,9 +17,7 @@ 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;
@@ -133,17 +131,19 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
FluidStack fluid = Util.getFluidFromItem(stack);
if (fluid == null || fluid.amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if (validPatternSlot(slot)
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
if (validPatternSlot(slot)) {
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,13 +153,10 @@ 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);
}
@@ -492,8 +489,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
protected NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
Util.writeItemStackToNBT(i, c);
}
return c;
}
@@ -8,8 +8,6 @@ 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;
@@ -38,8 +36,6 @@ 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();
@@ -60,7 +56,6 @@ 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);
}
}
}
@@ -2,6 +2,7 @@ package com.glodblock.github.common.block;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -61,6 +62,14 @@ public class BlockFluidInterface extends FCBaseBlock {
return false;
}
@Override
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor) {
TileFluidInterface tile = this.getTileEntity(worldIn, x, y, z);
if (tile != null) {
tile.getInterfaceDuality().updateRedstoneState();
}
}
@Override
protected boolean hasCustomRotation() {
return true;
@@ -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 IFluidCellInventoryHandler handler) {
if (inventory instanceof final FluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -112,7 +112,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -155,6 +155,9 @@ 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());
}
}
}
}
@@ -187,7 +190,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
return new CellUpgrades(is, 2);
}
@Override
@@ -1,6 +1,8 @@
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;
@@ -33,6 +35,7 @@ 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();
@@ -41,7 +44,8 @@ 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);
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
// terminal
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
if (Platform.isClient()) {
return item;
@@ -98,6 +102,9 @@ 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));
}
@@ -0,0 +1,45 @@
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));
}
}
}
@@ -1,5 +1,6 @@
package com.glodblock.github.common.item;
import java.text.NumberFormat;
import java.util.EnumSet;
import java.util.List;
@@ -82,7 +83,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -93,7 +94,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -0,0 +1,46 @@
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));
}
}
}
@@ -24,27 +24,19 @@ import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.DualityFluidInterface;
import com.glodblock.github.util.Util;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.parts.misc.PartInterface;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -52,7 +44,6 @@ import io.netty.buffer.ByteBuf;
public class PartFluidInterface extends PartInterface implements IDualHost {
private final BaseActionSource ownActionSource = new MachineSource(this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this);
@@ -201,35 +192,9 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
return getInterfaceDuality().getInstalledUpgrades(u);
}
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
} catch (GridAccessException e) {
return null;
}
}
private IEnergyGrid getEnergyGrid() {
try {
return getProxy().getGrid().getCache(IEnergyGrid.class);
} catch (GridAccessException e) {
return null;
}
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
IEnergyGrid energyGrid = getEnergyGrid();
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
int ori = resource.amount;
IAEFluidStack remove;
if (doFill) {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
} else {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
}
return remove == null ? ori : (int) (ori - remove.getStackSize());
return fluidDuality.fill(from, resource, doFill);
}
@Override
@@ -244,12 +209,12 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
return fluidDuality.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
return fluidDuality.canDrain(from, fluid);
}
@Override
@@ -190,6 +190,11 @@ 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) {}
}
@@ -38,14 +38,11 @@ import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.networking.crafting.ICraftingProviderHelper;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkCraftingPatternChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
@@ -60,6 +57,7 @@ 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;
@@ -67,7 +65,6 @@ import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.inv.IInventoryDestination;
import appeng.util.item.AEFluidStack;
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
@@ -107,7 +104,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
};
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
private final BaseActionSource ownActionSource = new MachineSource(this);
public PartFluidP2PInterface(ItemStack is) {
super(is);
@@ -131,6 +127,11 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
dualityFluid.gridChanged();
}
@Override
public void onNeighborChanged() {
this.duality.updateRedstoneState();
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
AppEngInternalInventory patterns = (AppEngInternalInventory) duality.getPatterns();
@@ -349,35 +350,9 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
return true;
}
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
} catch (GridAccessException e) {
return null;
}
}
private IEnergyGrid getEnergyGrid() {
try {
return getProxy().getGrid().getCache(IEnergyGrid.class);
} catch (GridAccessException e) {
return null;
}
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
IEnergyGrid energyGrid = getEnergyGrid();
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
int ori = resource.amount;
IAEFluidStack remove;
if (doFill) {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
} else {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
}
return remove == null ? ori : (int) (ori - remove.getStackSize());
return dualityFluid.fill(from, resource, doFill);
}
@Override
@@ -392,12 +367,12 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
return dualityFluid.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
return dualityFluid.canDrain(from, fluid);
}
@Override
@@ -502,6 +477,19 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
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();
@@ -516,6 +504,54 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
@Override
public boolean shouldDisplay() {
return IInterfaceHost.super.shouldDisplay() && !isOutput();
return IInterfaceHost.super.shouldDisplay();
}
@Override
public IInventory getPatterns() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.getPatterns();
}
return IInterfaceHost.super.getPatterns();
}
return IInterfaceHost.super.getPatterns();
}
@Override
public int rows() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.rows();
}
return IInterfaceHost.super.rows();
}
return IInterfaceHost.super.rows();
}
@Override
public int rowSize() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.rowSize();
}
return IInterfaceHost.super.rowSize();
}
return IInterfaceHost.super.rowSize();
}
@Override
public String getName() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.getName();
}
return IInterfaceHost.super.getName();
}
return IInterfaceHost.super.getName();
}
}
@@ -29,6 +29,7 @@ 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.networking.IGridNode;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
@@ -93,6 +94,7 @@ 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);
}
@@ -371,6 +373,7 @@ 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);
@@ -401,6 +401,11 @@ 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,12 +2,16 @@ 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;
@@ -17,7 +21,8 @@ import appeng.me.storage.MEPassThrough;
import appeng.util.item.AEFluidStack;
import appeng.util.prioitylist.PrecisePriorityList;
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack> implements IFluidCellInventoryHandler {
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
implements IFluidCellInventoryHandler, ICellCacheRegistry {
protected FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
super(c, StorageChannel.FLUIDS);
@@ -30,13 +35,32 @@ 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);
if (Util.getFluidFromItem(is) != null) {
priorityList.add(AEFluidStack.create(Util.getFluidFromItem(is)));
final FluidStack fluid = Util.getFluidFromItem(is);
if (fluid != null) {
priorityList.add(AEFluidStack.create(fluid));
}
}
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);
}
}
}
@@ -74,4 +98,54 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
return val;
}
@Override
public boolean canGetInv() {
IFluidCellInventory cellInv = this.getCellInv();
if (cellInv instanceof CreativeFluidCellInventory) {
return false;
} else {
return true;
}
}
@Override
public long getTotalBytes() {
return this.getCellInv().getTotalBytes();
}
@Override
public long getFreeBytes() {
return this.getCellInv().getFreeBytes();
}
@Override
public long getUsedBytes() {
return this.getCellInv().getUsedBytes();
}
@Override
public long getTotalTypes() {
return this.getCellInv().getTotalFluidTypes();
}
@Override
public long getFreeTypes() {
return this.getCellInv().getRemainingFluidTypes();
}
@Override
public long getUsedTypes() {
return this.getCellInv().getStoredFluidTypes();
}
@Override
public int getCellStatus() {
return this.getStatusForCell();
}
@Override
public TYPE getCellType() {
return TYPE.FLUID;
}
}
@@ -86,4 +86,9 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
long getTotalFluidTypes();
List<IAEFluidStack> getContents();
/**
* @return access installed upgrades.
*/
IInventory getUpgradesInventory();
}
@@ -180,8 +180,7 @@ public class TileFluidAutoFiller extends AENetworkInvTile
protected NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
Util.writeItemStackToNBT(i, c);
}
return c;
}
@@ -187,7 +187,7 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
return fluidDuality.canDrain(from, fluid);
}
@Override
@@ -1,6 +1,7 @@
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;
@@ -16,7 +17,6 @@ import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.AeStackInventoryImpl;
import com.glodblock.github.util.Updater;
import com.google.common.collect.ImmutableSet;
import appeng.api.AEApi;
@@ -26,6 +26,7 @@ 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;
@@ -60,6 +61,7 @@ public class TileLevelMaintainer extends AENetworkTile
public static final int REQ_COUNT = 5;
public final InventoryRequest requests = new InventoryRequest(this);
private int firstRequest = 0;
private final BaseActionSource source;
private final IInventory inv = new AeItemStackHandler(requests.requestStacks);
private boolean isPowered = false;
@@ -139,7 +141,28 @@ public class TileLevelMaintainer extends AENetworkTile
final ICraftingGrid craftingGrid = getProxy().getCrafting();
final IGrid grid = getProxy().getGrid();
final IItemList<IAEItemStack> inv = getProxy().getStorage().getItemInventory().getStorageList();
for (int i = 0; i < REQ_COUNT; i++) {
// 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);
@@ -152,35 +175,26 @@ public class TileLevelMaintainer extends AENetworkTile
boolean shouldCraft = isCraftable && aeItem.getStackSize() < quantity;
if (isDone) requests.updateState(i, State.Idle);
if (!isCraftable) requests.updateState(i, State.Error);
if (craftingGrid.canEmitFor(craftItem) || craftingGrid.isRequesting(craftItem)
|| !isDone
|| !shouldCraft)
if (allBusy || !isDone
|| !shouldCraft
|| craftingGrid.canEmitFor(craftItem)
|| craftingGrid.isRequesting(craftItem))
continue;
// do crafting
Future<ICraftingJob> jobTask = requests.getJob(i);
if (jobTask == null) {
requests.updateJob(
i,
craftingGrid.beginCraftingJob(getWorldObj(), grid, source, craftItem, null));
requests.updateState(i, State.Craft);
// calculate only one job per tick request
return TickRateModulation.SAME;
if (itemToBegin == null) {
itemToBegin = craftItem;
itemToBeginIdx = i;
}
} else if (jobTask.isDone()) {
requests.updateState(i, State.Craft);
try {
ICraftingJob job = jobTask.get();
if (job != null) {
ICraftingLink link = craftingGrid.submitJob(job, this, null, false, source);
requests.updateJob(i, null);
if (link != null) {
requests.updateState(i, State.Craft);
requests.updateLink(i, link);
// submit only one job per tick request
return TickRateModulation.SAME;
} else {
requests.updateState(i, State.Error);
if (jobToSubmit == null) {
jobToSubmit = job;
jobToSubmitIdx = i;
}
} else {
requests.updateState(i, State.Error);
@@ -191,6 +205,31 @@ public class TileLevelMaintainer extends AENetworkTile
}
}
}
if (jobToSubmit != null) {
// Finished calculating a request, try to submit it.
ICraftingLink link = craftingGrid.submitJob(jobToSubmit, this, null, false, source);
requests.updateJob(jobToSubmitIdx, null);
if (link != null) {
requests.updateState(jobToSubmitIdx, State.Craft);
requests.updateLink(jobToSubmitIdx, link);
} else {
requests.updateState(jobToSubmitIdx, State.Error);
}
} else if (itemToBegin != null) {
// No jobs to submit, start calculating some item.
requests.updateJob(
itemToBeginIdx,
craftingGrid.beginCraftingJob(getWorldObj(), grid, source, itemToBegin, null));
requests.updateState(itemToBeginIdx, State.Craft);
// Try the next item next time.
firstRequest = (firstRequest + 1) % REQ_COUNT;
} else {
// No work to be done:
// Every item is at desired quantity, being crafted, or has no patterns.
return TickRateModulation.IDLE;
}
} catch (final GridAccessException ignore) {
}
@@ -348,7 +387,8 @@ public class TileLevelMaintainer extends AENetworkTile
}
private ItemStack removeRecursion(ItemStack itemStack) {
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
if (itemStack != null && itemStack.hasTagCompound()
&& itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
return removeRecursion(loadItemStackFromTag(itemStack));
}
return itemStack;
@@ -503,14 +543,14 @@ public class TileLevelMaintainer extends AENetworkTile
jobs[idx] = job;
}
private void updateField(int idx, Updater<NBTTagCompound, NBTTagCompound> updater) {
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.update(data));
itemStack.setTagCompound(updater.apply(data));
IAEItemStack newRequestStack = AEItemStack.create(itemStack);
newRequestStack.setStackSize(ias.getStackSize());
requestStacks.setStack(idx, newRequestStack);
@@ -12,12 +12,17 @@ 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 {
@@ -30,20 +35,21 @@ public class PartLevelEmitterAdapter implements ILevelViewable, ILevelViewableAd
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).copy();
ItemStack itemStack = inventory.getStackInSlot(SLOT_IN);
if (itemStack == null) return inventory;
NBTTagCompound data = !itemStack.hasTagCompound() ? new NBTTagCompound() : itemStack.getTagCompound();
if (!data.hasKey(TLMTags.Quantity.tagName) || data.getLong(TLMTags.Quantity.tagName) != quantity)
data.setLong(TLMTags.Quantity.tagName, quantity);
if (!data.hasKey(TLMTags.State.tagName) || data.getInteger(TLMTags.State.tagName) != state.ordinal())
data.setInteger(TLMTags.State.tagName, state.ordinal());
data.setLong(TLMTags.Quantity.tagName, quantity);
data.setInteger(TLMTags.State.tagName, state.ordinal());
itemStack.setTagCompound(data);
inventory.setInventorySlotContents(SLOT_IN, itemStack);
return inventory;
AeStackInventoryImpl<IAEItemStack> inv = new AeStackInventoryImpl<>(StorageChannel.ITEMS, 1);
inv.setStack(SLOT_IN, AEItemStack.create(itemStack));
return new AeItemStackHandler(inv);
}
@Override
@@ -10,11 +10,9 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.common.registry.GameRegistry;
import li.cil.oc.api.driver.EnvironmentProvider;
import li.cil.oc.api.driver.NamedBlock;
@@ -124,9 +122,7 @@ public class DriverLevelMaintainer extends DriverSidedTileEntity {
if (dbStack == null) {
throw new IllegalArgumentException("Invalid slot");
}
dbStack.stackSize = 1;
((AeItemStackHandler) tileEntity.getInventory()).getAeInventory()
.setStack(slot, AEItemStack.create(dbStack));
tileEntity.requests.updateStack(slot, dbStack);
} else {
throw new IllegalArgumentException("Not a database");
}
@@ -188,16 +188,6 @@ public class DriverOCPatternEditor extends DriverSidedTileEntity {
return new Object[] { stack };
}
@Callback(
doc = "function([slot:number][, database:address, entry:number[, size:number]]):boolean -- Configure the interface.")
public Object[] setInterfaceConfiguration(Context context, Arguments args) {
IInventory config = tileEntity.getInternalInventory();
int slot = args.isString(0) ? 0 : optSlot(args, config, 0, 0);
config.setInventorySlotContents(slot, getStack(args));
context.pause(0.5);
return new Object[] { true };
}
@Callback(doc = "function([slot:number]):table -- Get the given pattern in the interface.")
public Object[] getInterfacePattern(Context context, Arguments args) {
IInventory inv = tileEntity.getInternalInventory();
@@ -338,8 +338,13 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
private boolean isGTMachine(Object o) {
return ModAndClassUtil.GT5 && o instanceof TileEntity
&& ((TileEntity) o).getBlockType().getUnlocalizedName().equals("gt.blockmachines");
if (!(ModAndClassUtil.GT5 || ModAndClassUtil.GT5NH)) return false;
if (o instanceof TileEntity te) {
return te.getBlockType().getUnlocalizedName().equals("gt.blockmachines");
}
return false;
}
private boolean isItemConduit(TileEntity te) {
@@ -58,21 +58,18 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
int filled = this.handler.fill(this.side, input.getFluidStack(), type == Actionable.MODULATE);
if (filled == 0) {
return input.copy();
} else if ((long) filled == input.getStackSize()) {
return null;
} else {
IAEFluidStack o = input.copy();
o.setStackSize(input.getStackSize() - (long) filled);
if (type == Actionable.MODULATE) {
IAEFluidStack added = o.copy();
this.cache.add(added);
this.postDifference(Collections.singletonList(added));
this.onTick();
}
return o;
if (type == Actionable.MODULATE) {
this.onTick();
}
if ((long) filled == input.getStackSize()) {
return null;
}
IAEFluidStack o = input.copy();
o.setStackSize(input.getStackSize() - (long) filled);
return o;
}
public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) {
@@ -17,6 +17,7 @@ import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
import com.glodblock.github.client.gui.GuiFluidIO;
import com.glodblock.github.client.gui.GuiFluidInterface;
import com.glodblock.github.client.gui.GuiFluidLevelEmitter;
import com.glodblock.github.client.gui.GuiFluidOptimizePatterns;
import com.glodblock.github.client.gui.GuiFluidPacketDecoder;
import com.glodblock.github.client.gui.GuiFluidPatternEncoder;
import com.glodblock.github.client.gui.GuiFluidPatternExWireless;
@@ -44,6 +45,7 @@ import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
import com.glodblock.github.client.gui.container.ContainerFluidOptimizePatterns;
import com.glodblock.github.client.gui.container.ContainerFluidPacketDecoder;
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
import com.glodblock.github.client.gui.container.ContainerFluidPatternExWireless;
@@ -447,6 +449,32 @@ public enum GuiType {
}
}),
FLUID_OPTIMIZE_PATTERNS(new PartGuiFactory<>(FCPart.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCPart inv) {
return new ContainerFluidOptimizePatterns(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, FCPart inv) {
return new GuiFluidOptimizePatterns(player.inventory, inv);
}
}),
FLUID_OPTIMIZE_PATTERNS_ITEM(new ItemGuiFactory<>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerFluidOptimizePatterns(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiFluidOptimizePatterns(player.inventory, inv);
}
}),
FLUID_CRAFTING_AMOUNT(new PartOrItemGuiFactory<>(ITerminalHost.class) {
@Override
@@ -24,6 +24,7 @@ import com.glodblock.github.network.SPacketMEFluidInvUpdate;
import com.glodblock.github.network.SPacketMEItemInvUpdate;
import com.glodblock.github.network.SPacketSetItemAmount;
import com.glodblock.github.network.SPacketStringUpdate;
import com.glodblock.github.network.SPacketSwitchBack;
import com.glodblock.github.network.wrapper.FCNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
@@ -66,6 +67,7 @@ public class ChannelLoader implements Runnable {
netHandler.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
netHandler.registerMessage(new CPacketRenamer.Handler(), CPacketRenamer.class, id++, Side.SERVER);
netHandler.registerMessage(new SPacketStringUpdate.Handler(), SPacketStringUpdate.class, id++, Side.CLIENT);
netHandler.registerMessage(new SPacketSwitchBack.Handler(), SPacketSwitchBack.class, id++, Side.CLIENT);
netHandler.registerMessage(
new SPacketLevelTerminalUpdate.Handler(),
SPacketLevelTerminalUpdate.class,
@@ -18,6 +18,7 @@ import com.glodblock.github.common.block.BlockWalrus;
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
import com.glodblock.github.common.item.ItemBasicFluidStoragePart;
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
import com.glodblock.github.common.item.ItemEnergyCard;
import com.glodblock.github.common.item.ItemFluidConversionMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
@@ -37,6 +38,7 @@ import com.glodblock.github.common.item.ItemPartFluidStorageBus;
import com.glodblock.github.common.item.ItemPartFluidTerminal;
import com.glodblock.github.common.item.ItemPartLevelTerminal;
import com.glodblock.github.common.item.ItemPortableFluidCell;
import com.glodblock.github.common.item.ItemQuantumBridgeCard;
import com.glodblock.github.common.item.ItemWirelessFluidTerminal;
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
import com.glodblock.github.common.item.ItemWirelessLevelTerminal;
@@ -47,6 +49,8 @@ import com.glodblock.github.util.NameConst;
public class ItemAndBlockHolder {
public static void init() {}
public static BlockCertusQuartzTank CERTUS_QUARTZ_TANK = new BlockCertusQuartzTank().register();
public static BlockFluidAutoFiller FLUID_AUTO_FILLER = new BlockFluidAutoFiller().register();
public static BlockFluidDiscretizer DISCRETIZER = new BlockFluidDiscretizer().register();
@@ -133,6 +137,9 @@ public class ItemAndBlockHolder {
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
public static ItemFluidStorageHousing CELL_HOUSING = new ItemFluidStorageHousing().register();
public static ItemEnergyCard ENERGY_CARD = new ItemEnergyCard().register();
public static ItemQuantumBridgeCard QUANTUM_BRIDGE_CARD = new ItemQuantumBridgeCard().register();
public static void loadSetting() {
if (!Config.fluidCells) return;
CellType.Cell1kPart.setItemInstance(CELL_PART);
@@ -23,6 +23,7 @@ import static com.glodblock.github.loader.ItemAndBlockHolder.CERTUS_QUARTZ_TANK;
import static com.glodblock.github.loader.ItemAndBlockHolder.DECODER;
import static com.glodblock.github.loader.ItemAndBlockHolder.DISCRETIZER;
import static com.glodblock.github.loader.ItemAndBlockHolder.ENCODER;
import static com.glodblock.github.loader.ItemAndBlockHolder.ENERGY_CARD;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_AUTO_FILLER;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_BUFFER;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_CONVERSION_MONITOR;
@@ -43,6 +44,7 @@ import static com.glodblock.github.loader.ItemAndBlockHolder.LEVEL_TERMINAL;
import static com.glodblock.github.loader.ItemAndBlockHolder.OC_EDITOR;
import static com.glodblock.github.loader.ItemAndBlockHolder.PATTERN;
import static com.glodblock.github.loader.ItemAndBlockHolder.PORTABLE_FLUID_CELL;
import static com.glodblock.github.loader.ItemAndBlockHolder.QUANTUM_BRIDGE_CARD;
import static com.glodblock.github.loader.ItemAndBlockHolder.QUANTUM_CELL;
import static com.glodblock.github.loader.ItemAndBlockHolder.SINGULARITY_CELL;
import static com.glodblock.github.loader.ItemAndBlockHolder.WALRUS;
@@ -67,6 +69,8 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe;
import com.glodblock.github.loader.recipe.WirelessTerminalQuantumBridgeRecipe;
import com.glodblock.github.loader.recipe.WirelessTerminalRecipe;
import com.glodblock.github.util.ModAndClassUtil;
@@ -169,6 +173,21 @@ public class RecipeLoader implements Runnable {
.findItemStack("ae2wct", "wirelessCraftingTerminal", 1);
public static final ItemStack BUCKET = new ItemStack(Items.bucket, 1);
public static final ItemStack IRON_BAR = new ItemStack(Blocks.iron_bars, 1);
public static final ItemStack AE2_ADVANCED_CARD = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
28);
public static final ItemStack AE2_WIRELESS_RECEIVER = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
41);
public static final ItemStack AE2_BLOCK_CHARGER = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockCharger", 1);
public static final ItemStack AE2_SINGULARITY = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
47);
public static final ItemStack NETHER_STAR = new ItemStack(Items.nether_star, 1);
@Override
public void run() {
@@ -639,13 +658,49 @@ public class RecipeLoader implements Runnable {
}
}
public static void addTerminalCards() {
GameRegistry.addRecipe(
new ShapedOreRecipe(
ENERGY_CARD.stack(),
"DSD",
"HAH",
"DSD",
'H',
AE2_BLOCK_CHARGER,
'D',
AE2_DENSE_ENERGY_CELL,
'A',
AE2_ADVANCED_CARD,
'S',
AE2_SINGULARITY));
GameRegistry.addRecipe(
new ShapedOreRecipe(
QUANTUM_BRIDGE_CARD.stack(),
"QSQ",
"WAW",
"QSQ",
'Q',
AE2_QUANTUM_RING,
'A',
AE2_ADVANCED_CARD,
'S',
NETHER_STAR,
'W',
AE2_WIRELESS_RECEIVER));
}
public static void runTerminalRecipe() {
if (ModAndClassUtil.WCT) {
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_PATTERN_TERM.stack()));
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_FLUID_TERM.stack()));
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_ULTRA_TERM.stack()));
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_INTERFACE_TERM.stack()));
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_LEVEL_TERM.stack()));
ItemStack[] fc2Terms = { WIRELESS_FLUID_TERM.stack(), WIRELESS_PATTERN_TERM.stack(),
WIRELESS_INTERFACE_TERM.stack(), WIRELESS_LEVEL_TERM.stack() };
for (ItemStack fc2term : fc2Terms) {
if (fc2term != null) {
if (ModAndClassUtil.WCT) { // deprecated, adding Infinity Booster Card from WCT mod
GameRegistry.addRecipe(new WirelessTerminalRecipe(fc2term));
}
GameRegistry.addRecipe(new WirelessTerminalQuantumBridgeRecipe(fc2term));
GameRegistry.addRecipe(new WirelessTerminalEnergyRecipe(fc2term));
}
}
ItemStack[] term = { AE2_WIRELESS_TERMINAL, WIRELESS_FLUID_TERM.stack(), WIRELESS_PATTERN_TERM.stack(),
@@ -0,0 +1,69 @@
package com.glodblock.github.loader.recipe;
import static com.glodblock.github.loader.ItemAndBlockHolder.ENERGY_CARD;
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
import java.util.Arrays;
import java.util.Objects;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import appeng.util.Platform;
public class WirelessTerminalEnergyRecipe extends ShapelessRecipes {
private final ItemStack installedTerm;
public static ItemStack energyCard = ENERGY_CARD.stack();
public WirelessTerminalEnergyRecipe(ItemStack term) {
super(term, Arrays.asList(term, getEnergyCard()));
this.installedTerm = installEnergyCard(term);
}
private boolean isEnergyCard(ItemStack is) {
if (is == null || is.getItem() == null) return false;
return (Objects.equals(energyCard.getItem(), is.getItem()));
}
public static ItemStack getEnergyCard() {
return energyCard;
}
@Override
public boolean matches(InventoryCrafting inv, World w) {
ItemStack term = inv.getStackInSlot(0);
ItemStack card = inv.getStackInSlot(1);
return term != null && term.getItem() instanceof ItemBaseWirelessTerminal
&& !hasEnergyCard(term)
&& isEnergyCard(card);
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
return installEnergyCard(inv.getStackInSlot(0));
}
@Override
public int getRecipeSize() {
return 2;
}
private ItemStack installEnergyCard(ItemStack is) {
is = is.copy();
NBTTagCompound data = Platform.openNbtData(is);
data.setBoolean(ItemBaseWirelessTerminal.infinityEnergyCard, true);
is.setTagCompound(data);
return is;
}
@Override
public ItemStack getRecipeOutput() {
return installedTerm;
}
}
@@ -0,0 +1,70 @@
package com.glodblock.github.loader.recipe;
import static com.glodblock.github.loader.ItemAndBlockHolder.QUANTUM_BRIDGE_CARD;
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
import java.util.Arrays;
import java.util.Objects;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import appeng.util.Platform;
public class WirelessTerminalQuantumBridgeRecipe extends ShapelessRecipes {
private final ItemStack installedTerm;
public static ItemStack quantumBridgeCard = QUANTUM_BRIDGE_CARD.stack();
public boolean isQuantumBridgeCard(ItemStack is) {
if (is == null || is.getItem() == null) return false;
return Objects.equals(quantumBridgeCard.getItem(), is.getItem());
}
public WirelessTerminalQuantumBridgeRecipe(ItemStack term) {
super(term, Arrays.asList(term, getQuantumBridgeCard()));
this.installedTerm = installQuantumBridgeCard(term);
}
@Override
public boolean matches(InventoryCrafting inv, World w) {
ItemStack term = inv.getStackInSlot(0);
ItemStack infinityBoosterCard = inv.getStackInSlot(1);
return term != null && term.getItem() instanceof ItemBaseWirelessTerminal
&& !hasInfinityBoosterCard(term)
&& isQuantumBridgeCard(infinityBoosterCard);
}
public static ItemStack getQuantumBridgeCard() {
return quantumBridgeCard;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
return installQuantumBridgeCard(inv.getStackInSlot(0));
}
@Override
public int getRecipeSize() {
return 2;
}
private ItemStack installQuantumBridgeCard(ItemStack is) {
is = is.copy();
NBTTagCompound data = Platform.openNbtData(is);
data.setBoolean(ItemBaseWirelessTerminal.infinityBoosterCard, true);
is.setTagCompound(data);
return is;
}
@Override
public ItemStack getRecipeOutput() {
return installedTerm;
}
}
@@ -1,13 +1,15 @@
package com.glodblock.github.nei;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.GuiFluidMonitor;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.GuiLevelMaintainer;
import codechicken.nei.api.INEIGuiAdapter;
public class NEIGuiHandler extends INEIGuiAdapter {
public class AE2FC_NEIGuiHandler extends INEIGuiAdapter {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
@@ -18,4 +20,12 @@ public class NEIGuiHandler extends INEIGuiAdapter {
}
return false;
}
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (gui instanceof GuiLevelMaintainer guiLevelMaintainer) {
return guiLevelMaintainer.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button);
}
return super.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button);
}
}
@@ -17,7 +17,7 @@ public class NEI_FC_Config implements IConfigureNEI {
@Override
public void loadConfig() {
API.registerNEIGuiHandler(new NEIGuiHandler());
API.registerNEIGuiHandler(new AE2FC_NEIGuiHandler());
API.addSearchProvider(new NEIItemFilter());
API.registerStackStringifyHandler(new FCStackStringifyHandler());
@@ -94,14 +94,12 @@ public class OrderStack<T> {
if (RealStack instanceof ItemStack) {
NBTTagCompound tmp = new NBTTagCompound();
tmp.setByte("t", (byte) ITEM);
((ItemStack) RealStack).writeToNBT(tmp);
Util.writeItemStackToNBT(((ItemStack) RealStack), tmp);
// replacement items
if (items != null) {
NBTTagList list = new NBTTagList();
for (ItemStack is : this.items) {
NBTTagCompound t = new NBTTagCompound();
is.writeToNBT(t);
list.appendTag(t);
Util.writeItemStackToNBT(is, new NBTTagCompound());
}
tmp.setTag(index + ":", list);
}
@@ -130,10 +128,10 @@ public class OrderStack<T> {
NBTTagList items = info.getTagList(index + ":", 10);
for (int x = 0; x < items.tagCount(); x++) {
final NBTTagCompound item = items.getCompoundTagAt(x);
list.add(ItemStack.loadItemStackFromNBT(item));
list.add(Util.loadItemStackFromNBT(item));
}
}
return new OrderStack<>(ItemStack.loadItemStackFromNBT(info), index, list.toArray(new ItemStack[0]));
return new OrderStack<>(Util.loadItemStackFromNBT(info), index, list.toArray(new ItemStack[0]));
}
case FLUID -> {
return new OrderStack<>(FluidStack.loadFluidStackFromNBT(info), index);
@@ -1,5 +1,7 @@
package com.glodblock.github.nei.recipes;
import java.util.Collection;
import com.glodblock.github.nei.recipes.extractor.AvaritiaRecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.EnderIORecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.ForestryRecipeExtractor;
@@ -19,8 +21,6 @@ import forestry.factory.recipes.nei.NEIHandlerMoistener;
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
import forestry.factory.recipes.nei.NEIHandlerStill;
import gregapi.recipes.Recipe;
import gregtech.api.util.GTPP_Recipe;
import gregtech.api.util.GT_Recipe;
public class DefaultExtractorLoader implements Runnable {
@@ -32,12 +32,19 @@ public class DefaultExtractorLoader implements Runnable {
FluidRecipe.addRecipeMap("crafting2x2", new VanillaRecipeExtractor(true));
if (ModAndClassUtil.GT5) {
for (GT_Recipe.GT_Recipe_Map tMap : GT_Recipe.GT_Recipe_Map.sMappings) {
FluidRecipe.addRecipeMap(
tMap.mNEIName,
new GregTech5RecipeExtractor(
tMap.mNEIName.equals("gt.recipe.scanner")
|| tMap.mNEIName.equals("gt.recipe.fakeAssemblylineProcess")));
try {
Class<?> recipeMapClazz = Class.forName("gregtech.api.util.GT_Recipe$GT_Recipe_Map");
Collection<?> sMappings = (Collection<?>) recipeMapClazz.getDeclaredField("sMappings").get(null);
for (Object tMap : sMappings) {
String mNEIName = (String) recipeMapClazz.getDeclaredField("mNEIName").get(tMap);
FluidRecipe.addRecipeMap(
mNEIName,
new GregTech5RecipeExtractor(
mNEIName.equals("gt.recipe.scanner")
|| mNEIName.equals("gt.recipe.fakeAssemblylineProcess")));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -47,11 +54,21 @@ public class DefaultExtractorLoader implements Runnable {
}
}
if (ModAndClassUtil.GTPP) {
for (GTPP_Recipe.GTPP_Recipe_Map_Internal gtppMap : GTPP_Recipe.GTPP_Recipe_Map_Internal.sMappingsEx) {
if (gtppMap.mNEIAllowed) {
FluidRecipe.addRecipeMap(gtppMap.mNEIName, new GTPPRecipeExtractor());
if (ModAndClassUtil.GTPP && !ModAndClassUtil.GT5NH) {
try {
Class<?> gtRecipeMapClazz = Class.forName("gregtech.api.util.GT_Recipe$GT_Recipe_Map");
Class<?> gtppRecipeMapClazz = Class.forName("gregtech.api.util.GTPP_Recipe$GTPP_Recipe_Map_Internal");
Collection<?> sMappingsEx = (Collection<?>) gtppRecipeMapClazz.getDeclaredField("sMappingsEx")
.get(null);
for (Object gtppMap : sMappingsEx) {
boolean mNEIAllowed = gtRecipeMapClazz.getDeclaredField("mNEIAllowed").getBoolean(gtppMap);
if (mNEIAllowed) {
String mNEIName = (String) gtRecipeMapClazz.getDeclaredField("mNEIName").get(gtppMap);
FluidRecipe.addRecipeMap(mNEIName, new GTPPRecipeExtractor());
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@@ -1,19 +1,14 @@
package com.glodblock.github.network;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
import com.glodblock.github.util.Util;
import appeng.api.storage.data.IAEFluidStack;
import appeng.util.item.AEItemStack;
import appeng.util.item.AEFluidStack;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -21,37 +16,42 @@ import io.netty.buffer.ByteBuf;
public class CPacketFluidUpdate implements IMessage {
private Map<Integer, IAEFluidStack> list;
private ItemStack itemStack;
private IAEFluidStack fluid;
private boolean shift;
private int slotIndex;
public CPacketFluidUpdate() {}
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack) {
this.list = data;
this.itemStack = itemStack;
this.slotIndex = -1;
/**
* Used by transferStackInSlot. No clicked fluid, always shift.
*/
public CPacketFluidUpdate(int slotIndex) {
this(null, slotIndex, true);
}
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data) {
this.list = data;
/**
* Used by handleMouseClick. Always uses mouse stack.
*/
public CPacketFluidUpdate(IAEFluidStack fluid, boolean shift) {
this(fluid, -1, shift);
}
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack, int slotIndex) {
this.list = data;
this.itemStack = itemStack;
private CPacketFluidUpdate(IAEFluidStack fluid, int slotIndex, boolean shift) {
this.fluid = fluid;
this.slotIndex = slotIndex;
this.shift = shift;
}
@Override
public void fromBytes(ByteBuf buf) {
this.list = new HashMap<>();
try {
Util.readFluidMapFromBuf(this.list, buf);
if (buf.readBoolean()) {
this.itemStack = AEItemStack.loadItemStackFromPacket(buf).getItemStack();
this.slotIndex = buf.readInt();
this.fluid = AEFluidStack.loadFluidStackFromPacket(buf);
} else {
this.fluid = null;
}
this.slotIndex = buf.readInt();
this.shift = buf.readBoolean();
} catch (IOException e) {
e.printStackTrace();
}
@@ -60,14 +60,14 @@ public class CPacketFluidUpdate implements IMessage {
@Override
public void toBytes(ByteBuf buf) {
try {
Util.writeFluidMapToBuf(this.list, buf);
if (this.itemStack != null) {
buf.writeBoolean(true);
AEItemStack.create(itemStack).writeToPacket(buf);
buf.writeInt(this.slotIndex);
} else {
if (fluid == null) {
buf.writeBoolean(false);
} else {
buf.writeBoolean(true);
fluid.writeToPacket(buf);
}
buf.writeInt(this.slotIndex);
buf.writeBoolean(this.shift);
} catch (IOException e) {
e.printStackTrace();
}
@@ -80,12 +80,7 @@ public class CPacketFluidUpdate implements IMessage {
Container container = ctx.getServerHandler().playerEntity.openContainer;
EntityPlayer player = ctx.getServerHandler().playerEntity;
if (container instanceof ContainerFluidMonitor) {
ItemStack item = player.inventory.getItemStack();
((ContainerFluidMonitor) container).postChange(
new ArrayList<>(message.list.values()),
message.itemStack == null ? item : message.itemStack,
player,
message.slotIndex);
((ContainerFluidMonitor) container).postChange(message.fluid, player, message.slotIndex, message.shift);
}
return null;
}
@@ -1,13 +1,10 @@
package com.glodblock.github.network;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.client.gui.GuiLevelMaintainer;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IClickableInTerminal;
@@ -28,6 +25,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
private int z;
private int dim;
private ForgeDirection side;
private int originalGui = -1;
public enum Action {
EDIT,
@@ -49,17 +47,30 @@ public class CPacketLevelTerminalCommands implements IMessage {
this.side = side;
}
public CPacketLevelTerminalCommands setOriginalGui(int originalGui) {
this.originalGui = originalGui;
return this;
}
@Override
public void fromBytes(ByteBuf buf) {
action = Action.values()[buf.readInt()];
switch (action) {
case EDIT, BACK -> {
case EDIT -> {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
dim = buf.readInt();
side = ForgeDirection.getOrientation(buf.readInt());
}
case BACK -> {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
dim = buf.readInt();
side = ForgeDirection.getOrientation(buf.readInt());
originalGui = buf.readInt();
}
case ENABLE -> {}
case DISABLE -> {}
case ENABLE_ALL -> {}
@@ -71,13 +82,21 @@ public class CPacketLevelTerminalCommands implements IMessage {
public void toBytes(ByteBuf buf) {
buf.writeInt(action.ordinal());
switch (action) {
case EDIT, BACK -> {
case EDIT -> {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeInt(dim);
buf.writeInt(side.ordinal());
}
case BACK -> {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeInt(dim);
buf.writeInt(side.ordinal());
buf.writeInt(originalGui);
}
case ENABLE -> {}
case DISABLE -> {}
case ENABLE_ALL -> {}
@@ -103,11 +122,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
GuiType.LEVEL_MAINTAINER);
}
case BACK -> {
GuiType originalGui = null;
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiLevelMaintainer guiLevelMaintainer) {
originalGui = guiLevelMaintainer.getOriginalGui();
}
GuiType originalGui = GuiType.getByOrdinal(message.originalGui);
if (originalGui == null) {
return null;
}
@@ -1,14 +1,11 @@
package com.glodblock.github.network;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiRenamer;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IClickableInTerminal;
@@ -179,10 +176,7 @@ public class CPacketRenamer implements IMessage {
.getTileEntity(intMsg.x, intMsg.y, intMsg.z);
this.setName(tile, intMsg.getSide(), message.text);
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiRenamer guiRenamer) {
guiRenamer.switchGui();
}
FluidCraft.proxy.netHandler.sendTo(new SPacketSwitchBack(), player);
}
}
}
@@ -15,6 +15,7 @@ import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.client.gui.GuiLevelTerminal;
@@ -70,16 +71,36 @@ public class SPacketLevelTerminalUpdate implements IMessage {
+ " : "
+ this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
AELog.info("Parsed content: -> " + this.commands);
if (AEConfig.instance.isFeatureEnabled(AEFeature.DebugLogging)) {
AELog.info(" <- Parsed content: " + this.commands);
}
}
AELog.debug(e);
return;
}
}
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
" <- Received commands " + this.commands.size()
+ " : "
+ this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
}
}
public void toBytes(ByteBuf buf) {
try {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
" <- Sent commands " + this.commands.size()
+ " : "
+ this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
if (AEConfig.instance.isFeatureEnabled(AEFeature.DebugLogging)) {
AELog.info(" -> Sent commands: " + this.commands);
}
}
buf.writeByte(statusFlags);
buf.writeInt(commands.size());
for (PacketEntry entry : commands) {
@@ -151,14 +172,6 @@ public class SPacketLevelTerminalUpdate implements IMessage {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiLevelTerminal levelTerminal) {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
"Received commands -> " + message.commands.size()
+ " : "
+ message.commands.stream()
.map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
}
levelTerminal.postUpdate(message.commands, message.statusFlags);
}
@@ -256,7 +269,7 @@ public class SPacketLevelTerminalUpdate implements IMessage {
buf.writeInt(y);
buf.writeInt(z);
buf.writeInt(dim);
buf.writeInt(side);
buf.writeByte(side);
buf.writeInt(rows);
buf.writeInt(rowSize);
@@ -289,12 +302,34 @@ public class SPacketLevelTerminalUpdate implements IMessage {
this.y = buf.readInt();
this.z = buf.readInt();
this.dim = buf.readInt();
this.side = buf.readInt();
this.side = buf.readByte();
this.rows = buf.readInt();
this.rowSize = buf.readInt();
int payloadSize = buf.readInt();
try (ByteBufInputStream stream = new ByteBufInputStream(buf, payloadSize)) {
NBTTagCompound payload = CompressedStreamTools.readCompressed(stream);
int available = stream.available();
if (available > 0) {
byte[] left = new byte[available];
int read = stream.read(left);
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
"Unread bytes detected (" + read
+ "): "
+ Arrays.toString(left)
+ " at "
+ dim
+ "#("
+ x
+ ":"
+ y
+ ":"
+ z
+ ")@"
+ ForgeDirection.getOrientation(side));
}
}
if (payload.hasKey("self", NBT.TAG_COMPOUND)) {
this.selfItemStack = ItemStack.loadItemStackFromNBT(payload.getCompoundTag("self"));
}
@@ -437,12 +472,19 @@ public class SPacketLevelTerminalUpdate implements IMessage {
buf.writeInt(validIndex);
}
}
try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) {
ByteBuf tempBuf = Unpooled.directBuffer(256);
try {
try (ByteBufOutputStream stream = new ByteBufOutputStream(tempBuf)) {
NBTTagCompound wrapper = new NBTTagCompound();
NBTTagCompound wrapper = new NBTTagCompound();
wrapper.setTag("data", items);
CompressedStreamTools.writeCompressed(wrapper, stream);
wrapper.setTag("data", items);
CompressedStreamTools.writeCompressed(wrapper, stream);
}
buf.writeInt(tempBuf.readableBytes());
buf.writeBytes(tempBuf);
} finally {
tempBuf.release();
}
} else {
buf.writeByte(flags);
@@ -472,9 +514,17 @@ public class SPacketLevelTerminalUpdate implements IMessage {
this.validIndices[i] = buf.readInt();
}
}
try (ByteBufInputStream stream = new ByteBufInputStream(buf)) {
int payloadSize = buf.readInt();
try (ByteBufInputStream stream = new ByteBufInputStream(buf, payloadSize)) {
this.items = CompressedStreamTools.readCompressed(stream).getTagList("data", NBT.TAG_COMPOUND);
int available = stream.available();
if (available > 0) {
byte[] left = new byte[available];
int read = stream.read(left);
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info("Unread bytes detected (" + read + "): " + Arrays.toString(left));
}
}
}
}
}
@@ -0,0 +1,34 @@
package com.glodblock.github.network;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import com.glodblock.github.client.gui.GuiRenamer;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class SPacketSwitchBack implements IMessage {
public SPacketSwitchBack() {}
@Override
public void fromBytes(ByteBuf buf) {}
@Override
public void toBytes(ByteBuf buf) {}
public static class Handler implements IMessageHandler<SPacketSwitchBack, IMessage> {
@Override
public IMessage onMessage(SPacketSwitchBack message, MessageContext ctx) {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiRenamer) {
((GuiRenamer) gs).switchGui();
}
return null;
}
}
}
@@ -9,7 +9,6 @@ import net.minecraft.tileentity.TileEntity;
import com.google.common.base.Throwables;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
@@ -22,68 +21,8 @@ import cpw.mods.fml.relauncher.Side;
import io.netty.channel.ChannelFutureListener;
/**
* This class is a simplified netty wrapper for those not wishing to deal with the full power of netty. It provides a
* simple message driven system, based on a discriminator byte over the custom packet channel. It assumes that you have
* a series of unique message types with each having a unique handler. Generally, context should be derived at message
* handling time.
* <p>
* Usage is simple:
* <ul>
* <li>construct, and store, an instance of this class. It will automatically register and configure your underlying
* netty channel.
*
* <li>Then, call {@link #registerMessage(Class, Class, byte, Side)} for each message type you want to exchange
* providing an {@link IMessageHandler} implementation class as well as an {@link IMessage} implementation class. The
* side parameter to that method indicates which side (server or client) the <em>message processing</em> will occur on.
* The discriminator byte should be unique for this channelName - it is used to discriminate between different types of
* message that might occur on this channel (a simple form of message channel multiplexing, if you will).
* <li>To get a packet suitable for presenting to the rest of minecraft, you can call {@link #getPacketFrom(IMessage)}.
* The return result is suitable for returning from things like {@link TileEntity#getDescriptionPacket()} for example.
* <li>Finally, use the sendXXX to send unsolicited messages to various classes of recipients.
* </ul>
* <p>
* Example <code>
* <pre>
* // Request message
* public Message1 implements IMessage {
* // message structure
* public fromBytes(ByteBuf buf) {
* // build message from byte array
* }
* public toBytes(ByteBuf buf) {
* // put message content into byte array
* }
* }
* // Reply message
* public Message2 implements IMessage {
* // stuff as before
* }
* // Message1Handler expects input of type Message1 and returns type Message2
* public Message1Handler implements IMessageHandler<Message1,Message2> {
* public Message2 onMessage(Message1 message, MessageContext ctx) {
* // do something and generate reply message
* return aMessage2Object;
* }
* }
* // Message2Handler expects input of type Message2 and returns no message (IMessage)
* public Message2Handler implements IMessageHandler<Message2,IMessage> {
* public IMessage onMessage(Message2 message, MessageContext ctx) {
* // handle the message 2 response message at the other end
* // no reply for this message - return null
* return null;
* }
* }
*
* // Code in a {@link FMLPreInitializationEvent} or {@link FMLInitializationEvent} handler
* SimpleNetworkWrapper wrapper = NetworkRegistry.newSimpleChannel("MYCHANNEL");
* // Message1 is handled by the Message1Handler class, it has discriminator id 1 and it's on the client
* wrapper.registerMessage(Message1Handler.class, Message1.class, 1, Side.CLIENT);
* // Message2 is handled by the Message2Handler class, it has discriminator id 2 and it's on the server
* wrapper.registerMessage(Message2Handler.class, Message2.class, 2, Side.SERVER);
* </pre>
* </code>
*
* @author cpw
* Copied from {@link cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper} to be able to override IndexedCodec
* to add packet logging
*/
public class FCNetworkWrapper {
@@ -7,6 +7,7 @@ import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
import com.glodblock.github.util.ModAndClassUtil;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@@ -28,8 +29,13 @@ public class ClientProxy extends CommonProxy {
@Override
public void postInit(FMLPostInitializationEvent event) {
super.postInit(event);
}
@Override
public void onLoadComplete(FMLLoadCompleteEvent event) {
super.onLoadComplete(event);
if (ModAndClassUtil.NEI) {
(new DefaultExtractorLoader()).run();
new DefaultExtractorLoader().run();
}
}
}
@@ -21,6 +21,7 @@ import appeng.api.IAppEngApi;
import appeng.api.config.Upgrades;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
@@ -28,7 +29,10 @@ public class CommonProxy {
public final FCNetworkWrapper netHandler = new FCNetworkWrapper(FluidCraft.MODID);
public void preInit(FMLPreInitializationEvent event) {}
public void preInit(FMLPreInitializationEvent event) {
ModAndClassUtil.init();
ItemAndBlockHolder.init();
}
public void init(FMLInitializationEvent event) {
this.registerMovables();
@@ -49,10 +53,34 @@ public class CommonProxy {
}
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P), 1);
Upgrades.ADVANCED_BLOCKING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.ADVANCED_BLOCKING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
Upgrades.LOCK_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P), 1);
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 5);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL1K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL64K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL256K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL64KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL256KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1);
if (Config.fluidIOBus) {
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2);
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2);
@@ -65,11 +93,13 @@ public class CommonProxy {
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
}
AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AEFluidInterfaceHandler());
AEApi.instance().registries().ifaceTerm().register(PartFluidP2PInterface.class);
AEApi.instance().registries().ifaceTerm().register(PartFluidInterface.class);
AEApi.instance().registries().ifaceTerm().register(TileFluidInterface.class);
AEApi.instance().registries().interfaceTerminal().register(PartFluidP2PInterface.class);
AEApi.instance().registries().interfaceTerminal().register(PartFluidInterface.class);
AEApi.instance().registries().interfaceTerminal().register(TileFluidInterface.class);
}
public void onLoadComplete(FMLLoadCompleteEvent event) {}
public void registerRenderers() {}
public void registerMovables() {
@@ -9,10 +9,12 @@ import net.minecraftforge.fluids.IFluidHandler;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerCraftConfirm;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.CraftingCPURecord;
import appeng.crafting.MECraftingInventory;
@@ -38,11 +40,13 @@ public class Ae2Reflect {
private static final Field fCPU_machineSrc;
private static final Field fContainerUpgradeable_upgradeable;
private static final Field fDualInterface_gridProxy;
private static final Field fCraftConfirm_result;
private static final Method mItemSlot_setExtractable;
private static final Method mCPU_getGrid;
private static final Method mCPU_postChange;
private static final Method mCPU_markDirty;
private static final Method mP2PLiquids_getTarget;
private static final Method mCraftConfirm_getGrid;
static {
try {
@@ -66,6 +70,8 @@ public class Ae2Reflect {
BaseActionSource.class);
mCPU_markDirty = reflectMethod(CraftingCPUCluster.class, "markDirty");
mP2PLiquids_getTarget = reflectMethod(PartP2PLiquids.class, "getTarget");
fCraftConfirm_result = reflectField(ContainerCraftConfirm.class, "result");
mCraftConfirm_getGrid = reflectMethod(ContainerCraftConfirm.class, "getGrid");
} catch (Exception e) {
throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e);
}
@@ -154,6 +160,18 @@ public class Ae2Reflect {
}
}
public static IGrid getGrid(ContainerCraftConfirm ccc) {
try {
return (IGrid) mCraftConfirm_getGrid.invoke(ccc);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mCPU_getGrid, e);
}
}
public static ICraftingJob getResult(ContainerCraftConfirm ccc) {
return Ae2Reflect.readField(ccc, fCraftConfirm_result);
}
public static MECraftingInventory getCPUInventory(CraftingCPUCluster cpu) {
return Ae2Reflect.readField(cpu, fCPU_inventory);
}
@@ -11,6 +11,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
@@ -408,6 +409,13 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
IAEFluidStack remove;
if (doFill) {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, this.mySource);
if (remove == null) {
onStackReturnedToNetwork(resource);
} else {
FluidStack copy = resource.copy();
copy.amount -= (int) remove.getStackSize();
onStackReturnedToNetwork(copy);
}
} else {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, this.mySource);
}
@@ -439,6 +447,10 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
return this.tanks.getTankInfo(from);
}
private void onStackReturnedToNetwork(FluidStack fluidStack) {
this.iHost.getInterfaceDuality().onStackReturnedToNetwork(ItemFluidDrop.newAeStack(fluidStack));
}
private static class InterfaceInventory extends MEMonitorIFluidHandler {
InterfaceInventory(DualityFluidInterface tileInterface) {
@@ -1,13 +1,3 @@
/*
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package com.glodblock.github.util;
import net.minecraft.util.StatCollector;
@@ -9,9 +9,17 @@ import appeng.core.AEConfig;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import cpw.mods.fml.common.Loader;
import gregtech.api.enums.Mods;
public final class ModAndClassUtil {
/**
* GTNH fork of GregTech5 Unofficial
*/
public static boolean GT5NH = false;
/**
* GregTech5 / GregTech5 Unofficial (Blood-Asp's "official" GT5u)
*/
public static boolean GT5 = false;
public static boolean GT6 = false;
public static boolean EC2 = false;
@@ -27,6 +35,7 @@ public final class ModAndClassUtil {
public static boolean WAILA = false;
public static boolean AVARITIA = false;
public static boolean HODGEPODGE = false;
public static boolean NEW_HORIZONS_CORE_MOD = false;
public static boolean isV2;
public static boolean isTypeFilter;
@@ -119,7 +128,14 @@ public final class ModAndClassUtil {
isTypeFilter = false;
}
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) GT5 = true;
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) {
try {
Class.forName("gregtech.api.recipe.RecipeMap");
GT5NH = true;
} catch (ClassNotFoundException e) {
GT5 = true;
}
}
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) GT6 = true;
if (Loader.isModLoaded("extracells")) EC2 = true;
if (Loader.isModLoaded("EnderIO")) EIO = true;
@@ -134,5 +150,6 @@ public final class ModAndClassUtil {
if (Loader.isModLoaded("Waila")) WAILA = true;
if (Loader.isModLoaded("Avaritia")) AVARITIA = true;
if (Loader.isModLoaded("hodgepodge")) HODGEPODGE = true;
if (Loader.isModLoaded(Mods.Names.NEW_HORIZONS_CORE_MOD)) NEW_HORIZONS_CORE_MOD = true;
}
}
@@ -49,6 +49,8 @@ public class NameConst {
public static final String ITEM_WIRELESS_FLUID_PATTERN_TERMINAL = "wireless_fluid_pattern_terminal";
public static final String ITEM_FLUID_PART = "fluid_part";
public static final String ITEM_FLUID_STORAGE_HOUSING = "fluid_storage_housing";
public static final String ITEM_QUANTUM_BRIDGE_CARD = "quantum_bridge_card";
public static final String ITEM_ENERGY_CARD = "energy_card";
public static final String TT_KEY = FluidCraft.MODID + ".tooltip.";
public static final String TT_FLUID_TERMINAL = TT_KEY + "fluid_terminal";
@@ -93,6 +95,10 @@ public class NameConst {
public static final String TT_ULTRA_TERMINAL = TT_KEY + "ultra_terminal";
public static final String TT_ULTRA_TERMINAL_TIPS = TT_ULTRA_TERMINAL + ".tips";
public static final String TT_ULTRA_TERMINAL_TIPS_DESC = TT_ULTRA_TERMINAL_TIPS + ".desc";
public static final String TT_ENERGY_CARD = TT_KEY + "energy_card";
public static final String TT_ENERGY_CARD_DESC = TT_ENERGY_CARD + ".desc";
public static final String TT_QUANTUM_BRIDGE_CARD = TT_KEY + "quantum_bridge_card";
public static final String TT_QUANTUM_BRIDGE_CARD_DESC = TT_QUANTUM_BRIDGE_CARD + ".desc";
public static final String WAILA_KEY = FluidCraft.MODID + ".waila.";
public static final String WAILA_ENABLE = WAILA_KEY + "enable";
@@ -1,7 +0,0 @@
package com.glodblock.github.util;
@FunctionalInterface
public interface Updater<Input, Output> {
Output update(Input data);
}
@@ -1,6 +1,8 @@
package com.glodblock.github.util;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityBoosterCard;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityEnergyCard;
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
import java.io.IOException;
import java.util.ArrayList;
@@ -55,6 +57,7 @@ import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import baubles.api.BaublesApi;
import codechicken.nei.recipe.StackInfo;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameData;
import io.netty.buffer.ByteBuf;
@@ -90,15 +93,19 @@ public final class Util {
c.setValidContainer(false);
}
ticks++;
if (ticks > 10 && wt != null) {
wt.extractAEPower(pm * ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
if (!hasEnergyCard(wt.getItemStack())) {
wt.extractAEPower(pm * ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
}
ticks = 0;
}
return ticks;
}
public static boolean hasInfinityBoosterCard(ItemStack is) {
if (ModAndClassUtil.WCT && is.getItem() instanceof ItemBaseWirelessTerminal) {
if (is.getItem() instanceof ItemBaseWirelessTerminal) {
NBTTagCompound data = Platform.openNbtData(is);
return data.hasKey(infinityBoosterCard) && data.getBoolean(infinityBoosterCard);
}
@@ -229,46 +236,38 @@ public final class Util {
}
public static AEFluidStack getAEFluidFromItem(ItemStack stack) {
if (stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
if (stack.getItem() instanceof IFluidContainerItem) {
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
if (fluid != null) {
AEFluidStack fluid0 = AEFluidStack.create(fluid.copy());
fluid0.setStackSize(fluid0.getStackSize() * stack.stackSize);
return fluid0;
}
}
if (FluidContainerRegistry.isContainer(stack)) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
if (fluid != null) {
AEFluidStack fluid0 = AEFluidStack.create(fluid.copy());
fluid0.setStackSize(fluid0.getStackSize() * stack.stackSize);
return fluid0;
}
if (stack != null) {
FluidStack fluid = getFluidFromItem(stack);
if (fluid != null) {
return AEFluidStack.create(fluid.copy());
}
}
return null;
}
public static FluidStack getFluidFromItem(ItemStack stack) {
if (stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
if (stack != null) {
FluidStack fluid = null;
if (stack.getItem() instanceof IFluidContainerItem) {
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
if (fluid != null) {
FluidStack fluid0 = fluid.copy();
fluid0.amount *= stack.stackSize;
return fluid0;
}
fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
} else if (FluidContainerRegistry.isContainer(stack)) {
fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
} else if (stack.getItem() instanceof ItemFluidPacket) {
fluid = ItemFluidPacket.getFluidStack(stack);
} else if (stack.getItem() instanceof ItemFluidDrop) {
fluid = ItemFluidDrop.getFluidStack(Util.copyStackWithSize(stack, 1));
}
if (FluidContainerRegistry.isContainer(stack)) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
if (fluid != null) {
FluidStack fluid0 = fluid.copy();
fluid0.amount *= stack.stackSize;
return fluid0;
}
if (fluid == null) {
fluid = StackInfo.getFluid(Util.copyStackWithSize(stack, 1));
}
if (fluid != null) {
FluidStack fluid0 = fluid.copy();
fluid0.amount *= stack.stackSize;
return fluid0;
}
}
return null;
@@ -304,6 +303,18 @@ public final class Util {
}
}
public static void writeItemStackToNBT(ItemStack itemStack, NBTTagCompound tag) {
itemStack.writeToNBT(tag);
tag.setInteger("Count", itemStack.stackSize);
}
public static ItemStack loadItemStackFromNBT(NBTTagCompound tag) {
ItemStack itemStack = ItemStack.loadItemStackFromNBT(tag);
if (itemStack == null) return null;
itemStack.stackSize = tag.getInteger("Count");
return itemStack;
}
public static IAEFluidStack loadFluidStackFromNBT(final NBTTagCompound i) {
final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1);
if (t == null) return null;
@@ -627,5 +638,13 @@ public final class Util {
data.getString("name"));
}
public static boolean hasEnergyCard(ItemStack is) {
if (is.getItem() instanceof ItemBaseWirelessTerminal) {
NBTTagCompound data = Platform.openNbtData(is);
return (data.hasKey(infinityEnergyCard) && data.getBoolean(infinityEnergyCard));
}
return false;
}
}
}
@@ -14,17 +14,19 @@ item.part_fluid_conversion_monitor.name=ME Fluid Conversion Monitor
item.part_level_terminal.name=ME Level Terminal
item.portable_fluid_cell.name=Portable Fluid Cell
item.wireless_fluid_terminal.name=Wireless Fluid Terminal
item.wireless_level_terminal.name=Wireless Level Maintainer Terminal
item.wireless_level_terminal.name=Wireless Level Terminal
item.wireless_fluid_pattern_terminal.name=Wireless Fluid Pattern Terminal
item.wireless_interface_terminal.name=Wireless Interface Terminal
item.wireless_ultra_terminal.WIRELESS_CRAFTING_TERMINAL.name=Universal Wireless Terminal - Crafting
item.wireless_ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL.name=Universal Wireless Terminal - Pattern
item.wireless_ultra_terminal.WIRELESS_FLUID_TERMINAL.name=Universal Wireless Terminal - Fluid
item.wireless_ultra_terminal.WIRELESS_LEVEL_TERMINAL.name=Universal Wireless Terminal - Level Maintainer
item.wireless_ultra_terminal.WIRELESS_LEVEL_TERMINAL.name=Universal Wireless Terminal - Level
item.wireless_ultra_terminal.WIRELESS_ESSENTIA_TERMINAL.name=Universal Wireless Terminal - Essentia
item.wireless_ultra_terminal.WIRELESS_INTERFACE_TERMINAL.name=Universal Wireless Terminal - Interface
item.wireless_ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL_EX.name=Universal Wireless Terminal - Processing Pattern
item.fluid_packet.name=Fluid Packet
item.quantum_bridge_card.name=Quantum Bridge Card
item.energy_card.name=Energy Card
item.creative_fluid_storage.name=Creative ME Fluid Storage Cell
item.fluid_storage.1.name=%s1k%s ME Fluid Storage Cell
item.fluid_storage.4.name=%s4k%s ME Fluid Storage Cell
@@ -94,7 +96,7 @@ ae2fc.tooltip.level_maintainer.link_desc=The system is currently crafting the re
ae2fc.tooltip.level_maintainer.export=§5Exporting§r
ae2fc.tooltip.level_maintainer.export_desc=The Requester is trying to export the crafting results to the system. If the Requester has this status for a long time, there is no available space for the export.
ae2fc.tooltip.level_maintainer.error=§4Errored§r
ae2fc.tooltip.level_maintainer.error_desc=The Requester is trying to schedule crafting job but it fails. Possible reasons no receipt found or insufficient resources to craft.
ae2fc.tooltip.level_maintainer.error_desc=The Requester is trying to schedule a crafting job but is failing. Possible reasons include a missing recipe or insufficient resources.
ae2fc.tooltip.level_maintainer.batch_size=§6Crafting Batch Size§r
ae2fc.tooltip.level_maintainer.batch_size.hint=When craft requests are emitted, the Requester will use the batch size for the request. Using larger batches will increase the speed of stocking up items but will require more crafting storage.
ae2fc.tooltip.level_maintainer.request_size=§6Amount to Maintain§r
@@ -102,7 +104,7 @@ ae2fc.tooltip.level_maintainer.request_size.hint=The count defines how many item
ae2fc.tooltip.ultra_terminal.WIRELESS_CRAFTING_TERMINAL=Mode: Crafting Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL=Mode: Pattern Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_TERMINAL=Mode: Fluid Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_LEVEL_TERMINAL=Mode: Level Maintainer Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_LEVEL_TERMINAL=Mode: Level Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_ESSENTIA_TERMINAL=Mode: Essentia Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_INTERFACE_TERMINAL=Mode: Interface Terminal
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL_EX=Mode: Processing Pattern Terminal
@@ -110,6 +112,9 @@ ae2fc.tooltip.ultra_terminal=Right click + sneaking to switch mode.
ae2fc.tooltip.ultra_terminal.tips=ToolTips:
ae2fc.tooltip.ultra_terminal.tips.desc=1.You can put it to baubles slot and use hotkey to open.\n2.Interface mode hold §3Shift§7 toggle interface renamer button.\n3.When you are in the crafting plan screen.\nHold §3Shift§7 click cancel button will automatically add missing items to NEI bookmark.
ae2fc.tooltip.quantum_bridge_card.desc=Allows wireless terminals to connect to a quantum bridge, allowing for unlimited range
ae2fc.tooltip.energy_card.desc=Infinity Energy for the Wireless Terminal
ae2fc.tooltip.cell_contents=Contains Fluid:
ae2fc.tooltip.cell_empty=Cell is empty
ae2fc.tooltip.cell_portable=Right click to open its GUI. It works like a backpack, but you need to charge it before using.
@@ -22,6 +22,8 @@ item.wireless_ultra_terminal.WIRELESS_ESSENTIA_TERMINAL.name=Беспровод
item.wireless_ultra_terminal.WIRELESS_INTERFACE_TERMINAL.name=Беспроводной универсальный терминал - Интерфейс
item.wireless_ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL_EX.name=Беспроводной универсальный терминал - Шаблон обработки
item.fluid_packet.name=Жидкостный пакет
item.quantum_bridge_card.name=Карта квантового моста
item.energy_card.name=Карта бесконечной энергии
item.creative_fluid_storage.name=Творческая МЭ жидкостная ячейка хранения
item.fluid_storage.1.name=%s1К%s МЭ жидкостная ячейка хранения
item.fluid_storage.4.name=%s4К%s МЭ жидкостная ячейка хранения
@@ -82,7 +84,7 @@ ae2fc.tooltip.fluid_auto_filler=Автоматически создаёт шаб
ae2fc.tooltip.level_maintainer.Who_Am_I=Кто я?
ae2fc.tooltip.level_maintainer.title=§6Статус запроса§r
ae2fc.tooltip.level_maintainer.desc=Автоматически поддерживает заданное количество предметов и жидкостей в хранилище, запрашивая новые при необходимости. Должен быть подключен к МЭ сети.
ae2fc.tooltip.level_maintainer.current=Текущее состояние:
ae2fc.tooltip.level_maintainer.current=Текущее состояние:
ae2fc.tooltip.level_maintainer.none=Запрос не настроен.
ae2fc.tooltip.level_maintainer.idle=§aБездействие§r
ae2fc.tooltip.level_maintainer.idle_desc=Запрашиватель бездействует, когда запрошенное количество уже достигнуто, нет шаблона создания этого предмета или жидкости или если недостаточно ингредиентов, чтобы запросить больше.
@@ -104,6 +106,9 @@ ae2fc.tooltip.ultra_terminal=ПКМ+Shift, чтобы изменить режи
ae2fc.tooltip.ultra_terminal.tips=Подсказки:
ae2fc.tooltip.ultra_terminal.tips.desc=1. Вы можете поместить его в слот Baubles и открыть с помощью привязанной клавиши.\n2. Режим интерфейсов. Удерживайте §3Shift§7 для переключения между кнопками подсветки и переименовывания интерфейсов.\n3. Экран "План создания".\nУдерживая §3Shift§7 нажмите кнопку "Отмена", чтобы автоматически добавить все недостающие ингредиенты в панель закладок NEI.
ae2fc.tooltip.quantum_bridge_card.desc=Позволяет беспроводным терминалам подключаться к квантовому мосту, обеспечивая неограниченный радиус действия
ae2fc.tooltip.energy_card.desc=Бесконечная энергия для беспроводного терминала
ae2fc.tooltip.cell_contents=Содержит жидкость:
ae2fc.tooltip.cell_empty=Ячейка пуста
ae2fc.tooltip.cell_portable=Нажмите ПКМ для открытия её интерфейса. Работает как рюкзак, но её необходимо зарядить перед использованием.
Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B