Compare commits

...
Author SHA1 Message Date
Martin Robertz 3407d8b2ac sa 2023-10-13 15:56:56 +02:00
Martin Robertz 48a65d0ee6 Merge remote-tracking branch 'Laiff/feature/level-maintainer-terminal' into dev 2023-10-13 15:55:58 +02:00
Andrei Laiff 750a175767 fix correct InterfaceTerminalSupportedClassProvider deprecation 2023-10-13 16:52:37 +03:00
Andrei Laiff f7fb0cf0ba Merge remote-tracking branch 'gtnh/master' into feature/level-maintainer-terminal
# Conflicts:
#	dependencies.gradle
2023-10-13 15:48:23 +03:00
Andrei Laiff 88492c4926 use IGuiTooltipHandler directly from ae2
include #160
2023-10-13 15:44:18 +03:00
Martin Robertz a459f63fbc SA 2023-10-13 13:31:08 +02:00
Martin Robertz 2c09dbd08e Merge remote-tracking branch 'Laiff/dev-for-fix' into dev 2023-10-13 13:29:21 +02:00
Andrei Laiff 4064c7b01c use IGuiTooltipHandler directly from ae2 2023-10-13 14:28:39 +03:00
Andrei Laiff 34db5a7836 feat: add back navigation in LevelMaintainer from terminal 2023-10-13 14:14:52 +03:00
Martin Robertz 897380c07b update bs+deps 2023-10-13 12:30:12 +02:00
Martin Robertz c6d11305bb update bs+deps 2023-10-13 12:28:38 +02:00
Martin Robertz 0fe787580c Merge remote-tracking branch 'Laiff/feature/level-maintainer-terminal' into dev 2023-10-13 12:13:50 +02:00
Martin Robertz 1058e60bac Merge remote-tracking branch 'origin/master' into dev 2023-10-13 12:13:09 +02:00
Alexdoru a4892aee06 fix NPE in FluidPatternDetails (#163) 2023-10-13 02:16:18 +02:00
Martin Robertz 11fd470613 Merge branch 'master' into fix_interface_term 2023-10-12 11:54:08 +02:00
Martin Robertz 42d7eb3aa4 Update dependencies.gradle 2023-10-12 11:53:42 +02:00
Andrei Laiff 1a81100185 feat: Support back navigation functionality 2023-10-12 12:41:15 +03:00
Andrei Laiff 8098f04b45 feat: Add new item LevelTerminal 2023-10-12 12:41:09 +03:00
Andrei Laiff c83f073319 feat: Rework scheduling and data storage in TileLevelMaintainer functionality 2023-10-12 12:40:57 +03:00
Andrei Laiff f5729b123a feat: Use customName to display in GuiFluidLevelEmitter 2023-10-12 12:40:47 +03:00
Andrei Laiff 28518eb816 api: Add LevelTerminalRegistry functionality 2023-10-12 12:40:27 +03:00
Andrei Laiff 77507a3f5c feat: Update core hooks and integrations 2023-10-12 12:40:10 +03:00
Dream-MasterXXL 8186653910 update bs+deps 2023-10-09 22:49:23 +02:00
Glease 25ab0916a7 add fluid pattern blame (#161) 2023-10-07 10:59:40 +08:00
Firenoo ef2281f717 Use new interface terminal API 2023-09-27 09:56:30 -07:00
Martin Robertz cc6959eb03 update deps 2023-09-27 16:07:11 +02:00
miozune 861791f4fb Fix GUIs not accepting numpad enter key (#159)
* updateBuildScript

* updateDependencies

* Fix GUIs not accepting numpad enter key

* Fix wildcard import
2023-09-27 16:03:59 +02:00
miozune 5b6540f637 Fix Wireless Pattern Terminal not saving stack size change to blank pattern slot (#158) 2023-08-28 21:49:03 +02:00
miozune 1f55def09f Revert fluid animation fix for Quartz Tank to mitigate FPS issue (#157) 2023-08-27 17:58:49 +02:00
firenoo 4de0ee4b1a Fix gt++ fluid cells not extracting properly (#156)
* Fix gt++ fluid cells not extracting properly

If GT++ fluid tank item sees a stacksize > 1, it refuses to fill/drain the
tank item, so we need to set the tank size to 1 before performing tests.

* Fix GT cells not working with fluid terminal

GT cells use IFluidContainerItem, despite the fact that they act like
FluidContainerRegistry items. Unfortunately this threw off the test code;
need to extract the entire container at a time for the test.
2023-08-19 12:34:36 +02:00
Fox_white bcdd765870 Fix Crafting Input Bus Compatibility & fix general bugs (#154)
* fix: uses IInterfaceTerminalSupport for interface terminal

fix custom target not registered in ae2fc wireless interface terminal

* fix: empty string caused channel crash && check if custom name exist before getting

* fix: Fluid interface not registered

* Revert "fix: Fluid interface not registered"

This reverts commit bc21ee2673.

* fix: remove ASM in favor of the new API

* fix: remove zero size character bypass as checking hasCustomName is enough
2023-08-11 21:18:57 +02:00
firenoo 98ff754306 Fix doubling fluids for real now (#153)
If condition was inverted
2023-08-07 23:50:39 +02:00
firenoo 1ed32d46dc A collection of fixes (#152)
* Fix the adv blocking mode setting shown w/o upgrade

* Use else ifs instead of ifs when looking for button

* Register dual p2p interface to interface term

* Fix moving inventory region when space is held

* Fix scrollbars not initialized when terminal is empty

* Fix fluid handling for the 3rd time

Rearranges the steps to insertion and validates whether the tank can be
drained.

* Fix fluid extraction for the 3rd time
2023-08-07 09:28:11 +02:00
firenoo 3d01f50100 Fix fluid stack not doubling (#151) 2023-08-05 17:15:07 +02:00
Raven Szewczyk 64977b87a9 Lazy monitor updates (#150)
* Update buildscript and dependencies

* Implement getAvailableItem for faster network updates

* Use findPrecise
2023-08-05 09:39:12 +02:00
firenoo dd842a182c Save search string when search unfocuses (#149) 2023-08-02 18:02:12 +02:00
DancingSnow 3fa1b1e0e2 Update zh_CN.lang (#147) 2023-07-30 19:25:53 +02:00
firenoo 3fce70a406 Add pattern doubling to ae2fc terminals (#148)
* Brings pattern doubling to ae2fc pattern terms

Literally copied and pasted the code over

* Update dep
2023-07-30 12:59:03 +02:00
StrangeMan1580 3df15eae97 Update ru_RU.lang (#146) 2023-07-29 15:47:41 +02:00
firenoo 0374c1c521 Add null check for retrieving tank info (#145)
ThaumicTinkerer returns null for sides. Normally this is handled when
it is directly adjacent to the dual interface via a null check, but for
p2ps it is not checked, leading to a NPE. Adds a check for it
2023-07-28 13:35:52 +02:00
firenoo b0d67ac917 Render drops as fluids in GuiCraftConfirm (#144)
* Render drops as fluids in GuiCraftConfirm

The crafting tree feature changed where the itemstacks were being drawn
from `drawFG` to `drawListFG`. This changes the ASM to include that in
its visit.

* Render drops as fluid in GuiCraftingTree

Now look for fluid drops in crafting tree.
Temporarily permanent ASM.
2023-07-24 08:26:39 -07:00
firenoo f51f09845a Register dual p2p interface for pattern capacity upgrade (#143) 2023-07-24 09:14:18 +02:00
firenooandGitHub GTNH Actions c94876b02e Add the dual P2P interface (#139)
* Add the dual P2P interface

- Can be disabled in the config
- Updated dependencies
- We now require a hard inheritance dependency on beta-238+.
- CANNOT BE ATTUNED.

* Dependency cleanup (don't use pre)

* Fix dual interface background

* Fix null icon for p2p dual interface

BetterP2P needs this to properly display the icon.

* spotlessApply

---------

Co-authored-by: GitHub GTNH Actions <unknown>
2023-07-22 17:00:43 +02:00
miozune e8f069375f Fix another typo (#142) 2023-07-22 17:18:39 +09:00
Eraldoe b50fd74e9c Fix typo "encoded" pattern 2023-07-22 17:18:28 +09:00
firenooGitHub GTNH Actionsgithub-actions[bot]
51229e972b Untangle Baubles hard dependency and skip on unmapped items/blocks (#137)
* Untangle Baubles hard dependency and skip on unmapped items/blocks

Have forge issue the standard "Missing items" screen when updating, so
players are warned before joining the world. Previously we consumed all
missing mapping by mistake.

Remove the hard dependency on baubles by adding Optional.Interface

* spotlessApply (#138)

Co-authored-by: GitHub GTNH Actions <>

* Update dependencies and fix wrong gui channel

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-14 21:08:20 +02:00
miozune 95a72f0e08 Fix fluid texture animation (#136) 2023-07-13 19:37:54 +09:00
firenoo 6afa01da74 Fix modulate/sim bug (#135)
Actionable.SIMULATE gives faulty results. Using Actionable.MODULATE will
force the AE system to extract the correct amount, which fixes a dupe bug
with the previous implementation.
2023-07-12 13:39:40 +02:00
Maxim 7895fce275 Changed craft amount config ref from priority to crafting amount (#134) 2023-06-28 19:29:45 +02:00
chill d5b8ef6ea9 Code cleanup (#133)
* gradle updateBuildScript

* fix comments and commented-out code

Code deletion, converting comments into javadocs, and refactoring code to not
need comments.

* remove redundant suppressions

* replace C-style array declaration with Java-style

* make private field final

* remove unnecessary semicolon

* extract a common part from an if

* simplify boolean expression

* simplify ternary if

* remove unused imports

* convert escaped characters for clarity

* replace while with for

* replace explicit types with diamond operators

* replace anonymous type with lambda

* enable modern Java syntax

* migrate to enhanced switch

* migrate to pattern variables for instanceof

* remove empty javadoc

* add Nonnull annotation to overrides of Nonnull methods

* replace wailaStack with null

When wailaStack is not null, the flow breaks out of the loop,
so there's no need to confuse the reader with putting wailaStack
both as the result and the parameter of the call - there's no
recursion.

* int cannot be bigger than its max value

* suppress dataflow warning

* remove redundant initializer

The default value of int is 0.

* null check is covered by instanceof

* simplify some calls of addVertexWithUV

* fix typos and add TODOs

* make flipState more understandable
2023-06-18 23:29:57 +02:00
firenooandGitHub GTNH Actions f87b76347e Update APIs (#130)
* Add an API to allow other mods to blacklist fluids from this mod.

* Removed Thaumic Energistics config setting. This will be handled by
Thaumic Energistic's side (which also happens to have a config setting).

* Added an API that allows for blacklisting fluids from either the storage
or the display individually.

* Prevent blacklisted fluids from being discretized

* Update API usage

- use AE2's new API

- use ThE's config setting for aspect -> gas

* spotlessApply

---------

Co-authored-by: GitHub GTNH Actions <unknown>
2023-05-20 19:46:37 +02:00
miozune 14853a2481 Fix NPE with FCStackStringifyHandler (#129) 2023-05-13 19:03:22 +02:00
miozune 2cd049d40e ForgeDirection fix & update dependencies (#128) 2023-05-09 07:39:00 +02:00
miozune f01cde7659 Show detailed fluid amount tooltip for Fluid Drop and Packet item (#127)
* Show detailed fluid amount tooltip for Fluid Drop and Packet item

* Guard against division by zero
2023-05-08 17:57:35 +02:00
miozune 56cda9f9e2 Fix fluid animation with Hodgepodge loaded (#126)
* Fix fluid animation with Hodgepodge loaded

* updateBuildScript
2023-05-07 17:55:46 +02:00
firenooGitHub GTNH Actionsgithub-actions[bot]
3da14b3bbe More ec2 mappings (#124)
* Replace ore dictionary bus

Extra Cells ore dict bus -> export bus w/ ore dict card
(retains ore filter setting, not verified they are 1:1)

* Add OpenComputer migration

Moves migration to postInit, and migrates OC upgrades.

* Remap wireless w/ correct encryption key + power

Basically now works without needing to relink in security term

* Update buildscript

* spotless apply

* spotlessApply (#125)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-06 19:04:59 +02:00
firenoo 97c7533ffb Add support for the Advanced Blocking Card to Dual Interfaces (#123)
* Update ae2 to latest (beta-203)

* Add support for the Advanced Blocking Card to Dual Interfaces

Behavior: The Dual Interface acts in the same way as the regular ME
interface when the advanced blocking card is used, but has an additional
check for fluids on top of items contained in the ME system.
2023-05-05 20:19:55 +02:00
firenoo d2df9beb31 Fix fluid export bus voiding fluids on crafting only mode (#120)
The Fluid Export Bus was voiding fluids on craft only mode because it
tried to craft it, and decided to continue with the normal export logic:
Extract fluid from ME system and fill the tank.

Unfortunately, there was a condition that prevented the extracted fluid
from going anywhere depending on craft only mode, so it got voided.

Commit fixes this by skipping the normal extract logic if set to craft
only.

The amount must be simulated before extracting from the ME system. This
helps prevent a scenario where we cannot insert the fluid back (such as
when we have a fluid storage bus on Extract Only).

Signed-off-by: Firenoo <[email protected]>
2023-05-01 19:43:07 +02:00
firenoo dab5a0dbf3 Add mappings for most important Extra Cells items (#115)
* EC2 deprecation: Part 1 - Items

Laying the groundwork for absorbing EC2 mappings.

* EC2 deprecation: Part 2 - Blocks

* EC2 Deprecation: Part 3 - Parts

Parts are deprecated.

* set config "replaceEC2" to default true

* API changes to make room for Extra Cells fluid placeholder

* Finish basic item replacement code

- parts work
- items are remapped properly, and converted when they enter the player inventory

* Fixed some storage cell conversion issues

The placeholders did not transfer NBT data properly

* Add handlers for deprecated item cells

Now the placeholder should work automatically in a drive.

The void cell is still a WIP.

* Add more tooltip help and cell handler for void cell

* apply spotless

too lazy to rebase
2023-05-01 19:42:52 +02:00
firenoo 6090f198e6 Allow all 63 partition items to be used for fluid cells (#121)
Previously, only one partition item was allowed. This fix will have
the cell consider all 63 slots. If you configure more than 1 or 5
cell slots, it works as expected - up to 1 or 5 of the whitelisted
fluids can be stored at a time.

This will degrade performance slightly.

Signed-off-by: Firenoo <[email protected]>
2023-05-01 19:38:07 +02:00
firenoo c29f8cf846 Fix FluidContainerRegistry interactions w/ Certus Quart Tank (#122)
The Certus Quartz Tank previously did not consider the
FluidContainerRegistry API for fluid containers, so fluid containers
that implemented that (like ic2 cells) were voided when filling the
tank.

Signed-off-by: Firenoo <[email protected]>
2023-05-01 19:37:53 +02:00
firenoo 77ec41812d Add null check for tanks (#118)
* Add null check for tanks

Some IFluidHandlers return null for getTankInfo(), so a null check is needed.

* spotless apply
2023-04-28 19:19:53 +02:00
Martin Robertz 258465a654 fix (#117) 2023-04-26 22:38:09 +02:00
Martin Robertz adbc077736 Update dependencies.gradle 2023-04-26 22:13:49 +02:00
Martin Robertz adf317d6a1 update dep file 2023-04-26 21:36:16 +02:00
firenoo 508f6e5d64 Add null check when determining potential tanks to import (#116)
It seems that implementers of IFluidHandler sometimes return null
in `getTankInfo()`, so this adds a check for that before doing the
bus work.
2023-04-26 21:14:40 +02:00
firenoo c174db3f15 Fix fluid terminal interactions (#111)
Now the math is properly calculated.
2023-04-01 14:54:48 +02:00
firenooandMartin Robertz e1b3f20078 Network throttle: Force ME update packets to be sent once every N ms. (#110)
* Network throttle: Force ME update packets to be sent once every 50ms.

1. Item and fluid packets are separated to their own classes, as they are
not even allowed to be mixed together in the first place. This will enforce a strict
separation of the two.

2. New network worker thread for handling ME inventory updates. Instead of
creating packets directly, classes should schedule packet(s) to be sent at the
next 50ms boundary. The packet has a limit of 256 items to prevent killing the
client, but this can be changed in the config. In fact, the packet send rate is
also configurable.

3. Upon opening a terminal GUI, ME update packets are split. Only the last received
packet will trigger a terminal sorting, so if the ME system is large, it may take
several seconds (!) to load all the items.

* Update SPacketMEFluidInvUpdate.java

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-04-01 14:04:39 +02:00
chochem 54781c290e quantum fluid fix (#114) 2023-03-30 22:21:00 +02:00
firenoo 9c2ef02383 Split packets when sending items over network (#107)
Packets are now split into smaller chunks when sent. The packet
size is adjustable in the config.
2023-03-23 17:14:14 +01:00
Raven Szewczyk 6a244c12c4 Add unlocalized names to fluid drops&packets (#105)
Previously they were null.

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/12874>
2023-03-14 21:04:56 +01:00
asdflj 399c5f53dd craft confirm screen add cpu select support (#99)
* craft confirm screen add cpu select support

* fix bug
2023-03-13 12:58:20 +08:00
asdfljandRaven Szewczyk b9724d9369 fc terminal add type filter (#98)
* fc terminal add type filter

* Update dependencies.gradle

---------

Co-authored-by: Raven Szewczyk <[email protected]>
2023-03-12 20:25:42 +01:00
Yang Xizhi c92f8bdd7c Merge pull request #103 from asdflj/recipe
fix fc pattern terminal shift click will use not support item to fill slot
2023-03-07 12:41:05 +08:00
asdflj ab7769a45d add default method 2023-03-06 18:35:54 +08:00
asdflj d2c03bc903 fix fc pattern terminal shift click will use not support item to fill slot 2023-03-06 15:54:33 +08:00
Yang Xizhi e8664328ed Merge pull request #102 from asdflj/terminal
fix cant Take/Put items in Universal Terminal
2023-03-04 13:10:41 +08:00
asdflj 84e395e470 fix cant Take/Put items in Universal Terminal 2023-03-04 08:36:21 +08:00
GlodBlock 0a01bb008b fix gl crash 2023-03-03 20:27:02 +08:00
Yang Xizhi f73f79da7b Merge pull request #100 from asdflj/terminal
terminal does not update view
2023-03-03 13:03:22 +08:00
asdflj 16f207ce80 terminal does not update view 2023-03-03 13:00:01 +08:00
GlodBlock 18f31ac3ef fix export bus exporting too much fluid 2023-03-02 16:46:35 +08:00
Yang Xizhi b205d3f53f Merge pull request #97 from asdflj/master
fluid packet decode add support to use conduit to export fluid
2023-02-28 12:24:33 +08:00
asdflj 6505967826 add fluid packet check 2023-02-28 09:06:06 +08:00
asdflj 78e9291fc6 Certus Quartz Tank add waila support
fluid packet decode add support to use conduit to export fluid
2023-02-27 16:50:29 +08:00
Yang Xizhi 6c4e12e968 Merge pull request #96 from asdflj/master
fluid export bus add schedule mode
2023-02-26 16:45:31 +08:00
asdflj ebf5a23ab9 fluid export bus add schedule mode 2023-02-26 10:46:55 +08:00
GlodBlock 161e38cbda fix fluid dupe from simulate drain 2023-02-25 22:06:29 +08:00
Yang Xizhi 948dcdcbce Merge pull request #95 from asdflj/master
fix can't be display in network details
2023-02-25 20:42:39 +08:00
asdflj 0b99ba974f fixed renamer bug 2023-02-25 19:21:52 +08:00
asdflj 2407653e96 fix universal terminal infinity connect bug 2023-02-25 11:43:21 +08:00
asdflj acfb5b1d48 add universal terminal more tips 2023-02-24 16:30:39 +08:00
asdflj 232b64e819 fix Universal terminal patten mode recipe transfer to slot item stack size error 2023-02-24 11:16:54 +08:00
asdflj 7438c7075c fix can't be display in network details 2023-02-24 09:40:21 +08:00
Yang Xizhi 9615e1cbf0 Merge pull request #86 from GTNewHorizons/blockingfix
Blockingfix
2023-02-23 20:40:23 +08:00
Martin Robertz 98c633e13d Merge pull request #94 from GTNewHorizons/master
merge from master
2023-02-22 12:12:18 +01:00
Yang Xizhi 704dbf6eec Merge pull request #92 from asdflj/master
fix bug
2023-02-22 18:35:31 +08:00
GlodBlock bf7190ce21 sa 2023-02-22 15:46:22 +08:00
GlodBlock 883ae61395 fix eio item conduit doesn't work 2023-02-22 15:44:28 +08:00
asdflj a203f2ff6b fix bug 2023-02-22 15:21:05 +08:00
GlodBlock fee5c6ee76 check gt pipe connection and fix eio fluid conduit 2023-02-21 18:22:53 +08:00
GlodBlock fb003da0a3 fix inventory check of gt machine 2023-02-21 15:36:10 +08:00
Martin Robertz 0e774f4e66 Merge pull request #91 from GTNewHorizons/master
merge master
2023-02-20 23:04:14 +01:00
Martin Robertz 25763691ca Merge pull request #90 from asdflj/master
fix fluid storage bus npe
2023-02-20 12:18:22 +01:00
asdflj bc053b2690 fix fluid storage bus crash 2023-02-20 18:19:47 +08:00
Martin Robertz 9761008907 Merge pull request #89 from GTNewHorizons/master
merge master
2023-02-18 23:25:05 +01:00
Martin Robertz 1a7acf4d28 Merge pull request #88 from asdflj/master
pattern terminal add auto fill blank pattern
2023-02-18 19:09:26 +01:00
asdflj c21752b80d fix bug 2023-02-18 14:18:22 +08:00
asdflj 80c364455d add Avaritia crafting table support 2023-02-18 14:16:40 +08:00
asdflj aef677868b add hotkey and baubles support 2023-02-17 22:34:06 +08:00
asdflj 09c1c49529 pattern terminal add auto fill blank pattern 2023-02-17 12:04:11 +08:00
Martin Robertz 18fb84de69 Merge branch 'master' into blockingfix 2023-02-16 20:41:21 +01:00
Yang Xizhi 271917c765 Merge pull request #85 from asdflj/nee
add nee support
2023-02-16 20:14:06 +08:00
GlodBlock e9c6c75ac9 ignore eio conduit in blocking check 2023-02-16 12:28:43 +08:00
asdflj 7d09bf606f add nee support 2023-02-16 11:29:34 +08:00
Martin Robertz 098561a01d Merge pull request #87 from GTNewHorizons/master
merge master
2023-02-15 17:36:17 +01:00
Yang Xizhi e292a4d35c Merge pull request #84 from asdflj/master
remove keep mouse pos
2023-02-15 18:02:13 +08:00
GlodBlock 52a985765c remove dep 2023-02-15 17:58:18 +08:00
GlodBlock 4f8811d376 make eio conduit consistant with ae2 2023-02-15 17:56:51 +08:00
asdflj bfcf33975c remove keep mouse pos 2023-02-15 09:30:13 +08:00
Yang Xizhi f3052c3353 Merge pull request #83 from asdflj/master
fix bug
2023-02-14 22:28:34 +08:00
GlodBlock b4a5c070e2 check every side in blocking mode 2023-02-14 22:20:47 +08:00
asdflj c8457bb7d3 fix bug 2023-02-14 22:12:40 +08:00
GlodBlock 0734dc4d0b add fluid name in certus tank name 2023-02-14 12:34:32 +08:00
GlodBlock 9f53884572 split client side hook code 2023-02-13 19:11:32 +08:00
Martin Robertz c9033aa93e Merge pull request #82 from asdflj/master
update zh language
2023-02-13 09:22:26 +01:00
GlodBlock 09df769db8 e 2023-02-13 15:02:04 +08:00
GlodBlock a5f7d8bed2 fix wireless terminal not usable at server 2023-02-13 14:59:31 +08:00
asdflj f66330d878 update zh language 2023-02-13 09:30:25 +08:00
Yang Xizhi 273ac040de Merge pull request #81 from GTNewHorizons/cell-housing
cell housing and multi fluid cell
2023-02-12 20:18:36 +08:00
GlodBlock 4f54c9bb28 add 5 type fluid cell 2023-02-12 20:12:23 +08:00
GlodBlock 96c7032523 add fluid cell housing 2023-02-12 19:04:04 +08:00
Yang Xizhi 7910578318 Merge pull request #80 from asdflj/cell
add cells
2023-02-12 17:10:38 +08:00
asdflj f7001d205e fix bug 2023-02-12 15:54:35 +08:00
asdflj a28bbe6e34 wireless interface terminal add switch crafting status button 2023-02-12 11:55:43 +08:00
asdflj 56a9dc1524 update dependencies.gradle 2023-02-11 22:42:34 +08:00
asdflj eb293ceb63 add ME Fluid Quantum Storage Cell
add ME Fluid Digital Singularity Storage Cell
2023-02-11 21:57:05 +08:00
Yang Xizhi 45e0dcbc05 Merge pull request #79 from asdflj/master
Universal wireless terminal support processing pattern terminal mode
2023-02-10 19:16:14 +08:00
asdflj e92cffd2b2 Merge remote-tracking branch 'origin/master' 2023-02-10 16:19:59 +08:00
asdflj 56b8683686 update wireless interface recipe 2023-02-10 16:19:34 +08:00
asdflj 879993cf22 add Creative ME Fluid Storage Cell 2023-02-10 16:03:51 +08:00
asdflj 8d14239c53 refactor 2023-02-10 11:05:19 +08:00
asdflj 5ada5ddec3 add Wireless Pattern Terminal Ex 2023-02-09 15:40:14 +08:00
Yang Xizhi 2812153280 Merge pull request #78 from asdflj/master
add wireless interface terminal
2023-02-09 12:38:03 +08:00
asdflj 95f34a7c29 fix bug 2023-02-08 21:10:32 +08:00
asdflj 7693487343 update language 2023-02-08 20:58:21 +08:00
asdflj a7d8d5db39 Merge remote-tracking branch 'origin/master' 2023-02-08 20:51:28 +08:00
asdflj c935e85a2f fix interface terminal bug 2023-02-08 20:51:08 +08:00
asdflj 417574fb3c wireless interface terminal add edit button 2023-02-08 18:16:27 +08:00
asdflj d2c420d193 add wireless interface terminal 2023-02-08 12:07:15 +08:00
asdflj c2ccede395 Switching terminal does not blink 2023-02-06 16:56:10 +08:00
asdflj 5f6a826ed9 keep mouse pos 2023-02-06 11:33:18 +08:00
Yang Xizhi 8e230af664 Merge pull request #76 from GTNewHorizons/wireless-terminals
Wireless terminals
2023-02-05 20:37:07 +08:00
Yang Xizhi b34192182e Merge pull request #77 from GTNewHorizons/wireless-terminals-spotless-fixes
Spotless apply for branch wireless-terminals for #76
2023-02-05 20:31:48 +08:00
GitHub GTNH Actions ee1c260d3d spotlessApply 2023-02-05 12:31:16 +00:00
GlodBlock 62b23e8102 remove 2023-02-05 20:26:47 +08:00
GlodBlock 2632a9b1cd fix crafting terminal 2023-02-05 20:25:23 +08:00
Yang Xizhi e8e27d421a Merge pull request #75 from asdflj/wireless
fix bug
2023-02-05 18:18:05 +08:00
asdflj 92213031f8 fix bug 2023-02-05 18:12:58 +08:00
asdflj d04aac3b29 fix bug 2023-02-05 16:52:16 +08:00
Yang Xizhi 66ac56434a Merge pull request #74 from asdflj/wireless
Wireless
2023-02-05 15:34:36 +08:00
asdflj ba45bd5606 Merge remote-tracking branch 'origin/wireless' into wireless 2023-02-05 15:18:17 +08:00
asdflj d1316f1309 spotless apply 2023-02-05 15:18:02 +08:00
asdflj fe6a4ba9de Merge branch 'wireless-terminals' into wireless 2023-02-05 15:11:09 +08:00
asdflj f81fab984a update 2023-02-05 15:06:06 +08:00
asdflj 1bbc575f6e spotless apply 2023-02-05 01:59:57 +08:00
GlodBlock f1c11fcd06 E 2023-02-05 01:31:27 +08:00
GlodBlock 6edad9fae0 more fixes 2023-02-05 01:23:00 +08:00
GlodBlock c1b2400549 fix bugs 2023-02-05 01:03:59 +08:00
GlodBlock f22bebbf21 wireless crafting terminal 2023-02-04 18:27:16 +08:00
GlodBlock 513af871aa wireless universal terminal 2023-02-03 22:38:33 +08:00
GlodBlock e1aa537670 make wct recipe not removed 2023-02-03 13:03:55 +08:00
Yang Xizhi 86551892e3 Merge pull request #73 from asdflj/bookmark
add NEI Highlighting for Text on AE2FC Fluid Storage Cells
2023-02-02 22:35:47 +08:00
asdflj b2eafe5c88 add NEI Highlighting for Text on AE2FC Fluid Storage Cells 2023-02-02 22:15:04 +08:00
Yang Xizhi f14e168555 Merge pull request #72 from asdflj/bookmark
fix bug
2023-02-02 15:41:13 +08:00
asdflj a8155c8b17 fix when open the auto filler, always to try update pattern
add using exists item to fill pattern slot
2023-02-02 11:13:59 +08:00
Yang Xizhi f40e088bc0 Merge pull request #71 from asdflj/bookmark
add fluid auto filler & wireless fluid pattern terminal
2023-02-01 21:19:23 +08:00
Yang Xizhi 7ecd7d246f Merge branch 'master' into bookmark 2023-02-01 21:19:09 +08:00
GlodBlock dadf2784a8 fixes 2023-02-01 21:15:44 +08:00
asdflj 8081eb2c2c all done? 2023-02-01 16:25:42 +08:00
Raven Szewczyk 72c1d37225 [ci skip] upgraded build system 2023-01-31 09:50:38 +00:00
asdflj 5ea7f44058 Merge remote-tracking branch 'origin/bookmark' into bookmark 2023-01-31 15:51:29 +08:00
asdflj 7f53e01184 add wireless fluid pattern terminal 2023-01-31 15:50:45 +08:00
GlodBlock 2eb1854eda network update flag 2023-01-31 10:49:19 +08:00
asdflj a22814940b add wireless fluid terminal 2023-01-30 22:52:25 +08:00
GlodBlock 482298021e tank 2023-01-30 18:07:57 +08:00
asdflj 99f8e98017 spotless apply 2023-01-29 16:30:27 +08:00
Yang Xizhi 1f6dc04a71 Merge branch 'master' into bookmark 2023-01-29 14:25:51 +08:00
asdflj bad29bfdc3 add certus quartz tank 2023-01-29 14:21:56 +08:00
Jason Mitchell 4eb5b5f2f0 [ci skip] Add git-blame-ignore-revs for spotlessApply 2023-01-28 17:43:10 -08:00
Jason Mitchell 69a5c0e6ee [ci skip] spotlessApply with the new settings 2023-01-28 17:43:10 -08:00
Jason Mitchell ab0b8f11d4 [ci skip] Update buildscript to RetroFuturaGradle 2023-01-28 17:43:08 -08:00
GlodBlock d238a82451 portable cell recipe 2023-01-28 23:45:39 +08:00
GlodBlock 80340dbd75 add portable fluid cell 2023-01-28 23:15:33 +08:00
asdflj 44ff338023 add fluid auto filler 2023-01-28 20:47:10 +08:00
GlodBlock fc9893ac32 fix npe from two storage bus facing each other 2023-01-28 15:48:14 +08:00
Martin Robertz 4d236cb898 Merge pull request #69 from asdflj/bookmark
add fluid storage monitor
2023-01-25 10:36:13 +01:00
GlodBlock e424230f96 add missing super event handler 2023-01-25 14:56:36 +08:00
asdflj 3f35dadb41 add walrus 2023-01-25 14:08:36 +08:00
asdflj 2a249bf5a4 Merge branch 'bookmark' 2023-01-24 21:58:50 +08:00
asdflj 14d41f3548 fix terminal btn 2023-01-24 21:50:03 +08:00
asdflj 3531f9f23e add fluid storage monitor 2023-01-24 21:38:10 +08:00
GlodBlock ea4014fc1e fix fluid storage bus trigger 2023-01-24 15:48:10 +08:00
Yang Xizhi 96ba5e2997 Merge pull request #70 from GTNewHorizons/removeasm
remove io port asm and add 16384k fluid cell
2023-01-24 00:10:13 +08:00
asdflj 949eefb873 remove me io asm 2023-01-23 21:21:17 +08:00
asdflj 8a99073d40 uh 2023-01-23 21:15:29 +08:00
GlodBlock 0a5a38341f remove io port asm 2023-01-23 20:55:31 +08:00
GlodBlock 4440ea5a1c colorful tooltips and 16384k cell 2023-01-23 20:52:19 +08:00
Yang Xizhi e69a0fc977 Merge pull request #68 from GTNewHorizons/refactor
refactor code
2023-01-23 17:06:44 +08:00
GlodBlock 8d072f0c89 refactor 6 2023-01-23 16:45:14 +08:00
GlodBlock 5b62c4fdc8 refactor 5 2023-01-22 19:37:44 +08:00
GlodBlock d9449622b9 refactor 4 2023-01-21 23:19:25 +08:00
GlodBlock b9b8ac3b43 Merge branch 'master' of https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git into refactor 2023-01-21 17:25:12 +08:00
GlodBlock 65134a3786 refactor 3 2023-01-21 17:19:40 +08:00
GlodBlock 018d488bee refactor 2 2023-01-21 14:45:07 +08:00
GlodBlock a70ace4742 refactor 1 2023-01-20 22:45:58 +08:00
Yang Xizhi c67ee59120 Merge pull request #62 from GTNewHorizons/fix/fluidterminal
add fluid storage bus
2023-01-20 15:33:24 +08:00
Martin Robertz 4d04a057eb Merge pull request #67 from GTNewHorizons/fix/fluidterminal-spotless-fixes
Spotless apply for branch fix/fluidterminal for #62
2023-01-20 08:31:04 +01:00
GitHub GTNH Actions 204535479c spotlessApply 2023-01-20 07:30:52 +00:00
Yang Xizhi 7640a1fe88 Merge c5e9b34a5e into 15b8b291fd 2023-01-20 08:29:27 +01:00
Yang Xizhi c5e9b34a5e Merge branch 'master' into fix/fluidterminal 2023-01-20 15:29:25 +08:00
Yang Xizhi 15b8b291fd Merge pull request #64 from asdflj/levelEmitter
add fluid level emitter
2023-01-20 15:27:21 +08:00
Martin Robertz e29f044e2e Merge pull request #66 from asdflj/master
missing items always in the top
2023-01-20 08:09:27 +01:00
asdflj 37a49cb720 missing items always in the top 2023-01-20 14:50:24 +08:00
Martin Robertz 1aedac721a Merge pull request #65 from asdflj/master
remove asm
2023-01-19 07:36:50 +01:00
asdflj 3715e470aa remove asm 2023-01-19 10:09:45 +08:00
asdflj 5ca8909dbf add fluid level emitter 2023-01-19 00:07:16 +08:00
Yang Xizhi 510cd6d4bd Merge pull request #63 from GTNewHorizons/fix/fluidterminal-spotless-fixes
Spotless apply for branch fix/fluidterminal for #62
2023-01-17 22:44:39 +08:00
GitHub GTNH Actions f0aef4e73c spotlessApply 2023-01-17 14:44:20 +00:00
Yang Xizhi 11bf706a32 Merge fe1ec6276d into b1dff2ec2c 2023-01-17 14:43:10 +00:00
GlodBlock fe1ec6276d add fluid storage bus 2023-01-17 22:41:49 +08:00
Martin Robertz b1dff2ec2c Merge pull request #60 from asdflj/levelmaintainer
fix level maintainer bug
2023-01-16 16:22:43 +01:00
Martin Robertz 101f4de7ed Merge pull request #61 from GTNewHorizons/crafting-calc-v2-compat
Crafting calculator v2 compatibility
2023-01-15 21:54:47 +01:00
Martin Robertz 2679df71c4 Update dependencies.gradle 2023-01-15 15:56:05 +00:00
Raven Szewczyk 18630c9618 Add crafting calculator v2 compat for newer AE2-GTNH versions 2023-01-14 18:04:23 +00:00
Raven Szewczyk f203c24551 Update dependencies 2023-01-14 12:48:06 +00:00
Raven Szewczyk 7a1b507b08 Update buildscript 2023-01-14 11:28:25 +00:00
asdflj f07d996eb7 fix level maintainer if item can't be craft, it always requests item to crafting 2023-01-14 19:23:23 +08:00
Martin Robertz 36a9507c22 Merge pull request #59 from asdflj/levelmaintainer
fix fluid dupe
2023-01-13 09:35:28 +01:00
asdflj 5b5b11b330 fix fluid terminal bug
update zh-cn lang
2023-01-13 15:47:58 +08:00
Martin Robertz 91720df96d Merge pull request #56 from asdflj/levelmaintainer
update level maintainer
2023-01-12 06:24:12 +01:00
asdflj de63822afb update level_maintainer 2023-01-12 09:43:06 +08:00
Martin Robertz 669c83917f Merge pull request #55 from asdflj/master
fix fluid terminal bug
2023-01-11 16:25:38 +01:00
asdflj 606bac83f4 fix fluid terminal bug 2023-01-11 18:09:55 +08:00
Martin Robertz 80f07a4dc6 Merge pull request #53 from asdflj/super_speed_card
add super speed card support
2023-01-03 12:57:58 +01:00
Martin Robertz 8654ce8ad3 Merge pull request #52 from asdflj/fluid_terminal
fix fluid terminal crash
2023-01-03 12:57:46 +01:00
asdflj 42c47a3a3e add super speed card support 2023-01-03 16:25:33 +08:00
Martin Robertz 644e3e2a6f Merge pull request #50 from asdflj/io_bus
fix io bus shift click upgrade card crash
2023-01-03 08:48:03 +01:00
Martin Robertz 95dc2e0717 Merge pull request #51 from asdflj/levelmaintainer
fix bug
2023-01-03 08:47:33 +01:00
asdflj dd9d4df44b fix fluid terminal crash 2023-01-03 15:27:47 +08:00
asdflj 0ca9a9f46c fix bug 2023-01-03 10:16:24 +08:00
asdflj 0a11fb0431 fix io bus shift click crash 2022-12-24 16:58:27 +08:00
Martin Robertz 043c6a6cc2 Merge pull request #49 from xstmass/fix_recipe_npe
Fix NPE of FluidBuffer
2022-12-19 19:06:00 +01:00
Christmas fb7454ab71 Fix NPE
NPE if "Enable Fluid Storage Cell" entry "false"
2022-12-19 18:04:14 +03:00
Martin Robertz 33e7fbb633 Merge pull request #47 from asdflj/fluidBuffer
add Fluid Buffer
2022-12-18 09:07:50 +01:00
GlodBlock 23379df0b0 sa 2022-12-18 15:57:32 +08:00
asdflj c9ba859d34 fix fluid buffer bug 2022-12-18 15:04:59 +08:00
asdflj 77ccfb5606 add Fluid Buffer 2022-12-14 15:05:00 +08:00
Martin Robertz b9ecf92fa3 Merge pull request #44 from GTNewHorizons/fixs
add contents display on cells and fix pattern terminal encode overflow
2022-12-05 18:20:25 +01:00
Yang Xizhi 3cd9aef9a1 Merge pull request #46 from GTNewHorizons/fixs-spotless-fixes
Spotless apply for branch fixs for #44
2022-12-06 00:41:13 +08:00
GitHub GTNH Actions c2e91139b2 spotlessApply 2022-12-05 16:40:38 +00:00
Yang Xizhi 66e51a1ba8 Merge 31d5e89144 into e67ac46197 2022-12-05 16:39:27 +00:00
Yang Xizhi 31d5e89144 Merge branch 'master' into fixs 2022-12-06 00:39:24 +08:00
Yang Xizhi 52e3e0baaa use ctrl 2022-12-06 00:37:43 +08:00
Martin Robertz e67ac46197 Merge pull request #45 from asdflj/master
fix tooltip format
2022-12-05 15:42:24 +01:00
asdflj 5e31096c7e spotless apply 2022-12-05 14:41:36 +08:00
asdflj 6acf2bace1 uh 2022-12-05 10:57:27 +08:00
Martin Robertz b81a18ff65 Merge pull request #24 from dipo33/fluid-interface-sideless
Add option to make Fluid Interface sideless
2022-12-04 18:18:51 +01:00
Matej Dipčár e54d274b88 Fix button visible in part interface 2022-12-04 13:16:26 +01:00
Matej Dipčár e8a0523d56 Update ae2 version 2022-12-04 13:00:47 +01:00
Matej Dipčár d712c01657 Make DualInterface behaviour correspond to sideless setting 2022-12-03 23:28:20 +01:00
Matej Dipčár 05485ddaa6 Add SidelessMode button to FluidInterface 2022-12-03 21:08:31 +01:00
GlodBlock c087930016 add contents display on cells and fix pattern terminal encode overflow 2022-12-03 13:58:00 +08:00
Martin Robertz a805df0e9e Merge pull request #43 from asdflj/master
add waila support
2022-11-30 07:43:59 +01:00
asdflj 5b6cc1471b fix terminal fluid stack tooltip display error 2022-11-30 12:08:01 +08:00
asdflj b3fa0c09d1 add waila support 2022-11-30 10:29:37 +08:00
Matej Dipčár 18b67f804b Update buildscript 2022-11-28 01:53:10 +01:00
Matej Dipčár d28ffa6adc Fix Fluid Import Bus to be able to import multiple fluids just like EIO conduits 2022-11-28 01:44:36 +01:00
Matej Dipčár bcb688c079 Remove sides from fluid interface 2022-11-28 01:44:36 +01:00
Martin Robertz 9b992731c2 Merge pull request #42 from GTNewHorizons/oc-api
fix no environement return
2022-11-24 13:34:52 +01:00
GlodBlock b02ac628e9 fix no return 2022-11-23 20:49:51 +08:00
Martin Robertz 7f6933483f Merge pull request #41 from asdflj/permission
add level maintainer permission control
2022-11-21 17:19:48 +01:00
asdflj 73fcfce454 add level maintainer permission control 2022-11-21 14:53:27 +08:00
Martin Robertz a8d2b12ef9 Merge pull request #38 from GTNewHorizons/fixes
fix blocking mode and item amount change
2022-11-19 17:24:21 +01:00
Martin Robertz 76032e1e28 Merge pull request #40 from GTNewHorizons/oc-api
oc api for me dual interface
2022-11-18 19:02:26 +01:00
Martin Robertz eff505cdb9 Merge pull request #39 from asdflj/filter
fluid packet decoder add slot restricted input
2022-11-18 18:48:57 +01:00
GlodBlock 3d5ffbba4c oc api for me dual interface 2022-11-18 19:10:22 +08:00
asdflj 7a18bed394 fluid packet decoder add slot restricted input 2022-11-17 10:55:21 +08:00
GlodBlock e4749970ef no way 2022-11-15 15:30:47 +08:00
GlodBlock b6b3467251 fix block mode doesn't work in pure fluid pattern 2022-11-15 15:18:00 +08:00
Martin Robertz 1c791480d5 Merge pull request #36 from asdflj/IOPort&LevelMaintainer 2022-11-15 06:47:15 +01:00
asdflj dc7c33bfa0 uh substitutions mode is not complete yet 2022-11-15 09:15:30 +08:00
asdflj 244e7fb4f8 Level Maintainer add control button
Level Maintainer add oc support
fix Level Maintainer render error
2022-11-15 09:06:23 +08:00
Martin Robertz 3a0eeeac07 revert 2022-11-12 22:40:00 +01:00
Martin Robertz 88875ab99b Update build.gradle 2022-11-12 11:32:41 +01:00
Martin Robertz e311705327 Merge pull request #37 from OneEyeMaker/master
Greggified recipes of fluid storage cells
2022-11-12 11:32:22 +01:00
OneEyeMaker 086e46dc46 Greggified recipes of fluid storage cells 2022-11-12 13:14:20 +03:00
asdflj 04c8aab837 Merge branch 'master' into IOPort&LevelMaintainer 2022-11-09 11:06:05 +08:00
asdflj 5d31d6d6fb Add LevelMaintainer 2022-11-09 11:03:46 +08:00
Guinea Wheek 89068c4dff fix silly NPE crash 2022-11-07 19:17:20 +08:00
GlodBlock d29f035139 fluid terminal clean up 2022-11-07 19:17:20 +08:00
asdflj ce1ac164dc update 2022-11-05 15:34:36 +08:00
Martin Robertz 6da8cdf831 Merge pull request #35 from guineawheek/fix_npe
fix NPE crash with recent code change
2022-11-02 18:03:07 +01:00
Guinea Wheek 7def78aa90 fix silly NPE crash 2022-10-31 19:34:47 -07:00
asdflj fd6eb37369 fluid terminal add "use substitutions" button 2022-10-31 09:16:19 +08:00
Martin Robertz ccd3a5da98 Merge pull request #30 from GTNewHorizons/cleanup
fluid terminal code clean up
2022-10-28 19:47:39 +02:00
Martin Robertz ceee7ad85f Merge pull request #33 from asdflj/dev
pattern terminal update
2022-10-28 15:05:01 +02:00
asdflj b576e4b178 pattern terminal shift click player inventory encode pattern to transfer output pattern slot 2022-10-28 15:25:46 +08:00
Martin Robertz 546e02a9fe Merge pull request #32 from asdflj/dev
update lang and fix dual interface infinity export fluid bug
2022-10-26 10:57:24 +02:00
asdflj 16003b93ba update lang and fix dual interface infinity export fluid bug 2022-10-26 14:16:41 +08:00
Martin Robertz 6cf7918cb8 Merge pull request #31 from guineawheek/fluid_p2p_blocking
make blocking mode work with fluid p2ps
2022-10-24 12:21:09 +02:00
Guinea Wheek e9351c5302 move reflection to Ae2Reflect 2022-10-24 02:59:03 -07:00
Guinea Wheek 521a256378 make blocking mode work with fluid p2ps 2022-10-24 01:31:08 -07:00
GlodBlock c1c1aef1f5 fluid terminal clean up 2022-10-23 18:10:37 +08:00
Martin Robertz da804448a8 Merge pull request #29 from asdflj/dev
fluid terminal support long fluid amount
2022-10-23 10:09:07 +02:00
asdflj e47c65fbdf support long fluid amount 2022-10-23 10:50:10 +08:00
Martin Robertz 02f3ed037c Merge pull request #28 from asdflj/dev
add fluid terminal
2022-10-20 18:29:43 +02:00
asdflj 238fd317e4 add fluid terminal 2022-10-20 12:28:01 +08:00
Connor-Colenso 87d7f699e8 Merge pull request #27 from GTNewHorizons/formatted-cell-tooltip
Add filter tooltip to partitioned storage cells
2022-10-10 06:08:18 +01:00
Matej Dipčár 7eb22f8720 Add filter tooltip to partitioned storage cells 2022-10-10 06:17:04 +02:00
Martin Robertz 1a2ba79745 Merge pull request #26 from GTNewHorizons/fix
fix AIOOBE in amount set packet
2022-10-08 19:11:56 +02:00
GlodBlock e6b4917b64 fix AIOOBE 2022-10-09 00:11:03 +08:00
Martin Robertz c29f50214e Merge pull request #25 from GTNewHorizons/fix
fix wrong invert trigger
2022-10-08 17:01:23 +02:00
GlodBlock b2f07d2a02 fix wrong invert trigger 2022-10-08 20:20:11 +08:00
Martin Robertz d8140da431 Merge pull request #23 from GTNewHorizons/fix
fix wrong bytes display when ingrentent isn't enough and a possible d…
2022-10-07 21:38:14 +02:00
Yang Xizhi 47dce05cfa Merge branch 'master' into fix 2022-10-06 23:10:15 +08:00
GlodBlock ab4acbe5eb fix wrong bytes display when ingrentent isn't enough and a possible dupe from fluid packet decoder 2022-10-06 23:07:26 +08:00
Martin Robertz 587fd70876 Merge pull request #22 from GTNewHorizons/craftin-card
crafting card support for fluid export bus
2022-10-04 12:14:07 +02:00
GlodBlock d820b68a7d uh 2022-10-03 20:04:19 +08:00
GlodBlock bce6e35675 crafting card support for fluid export bus 2022-10-03 19:46:57 +08:00
Martin Robertz b6b9f71677 Merge pull request #21 from GTNewHorizons/eio-compact-fix
eio conduct compact and fix transfer item and fluid in different dirs
2022-10-01 12:56:28 +02:00
Martin Robertz 63daee5e56 Merge pull request #20 from asdflj/master
Update and fix some bug
2022-10-01 10:49:50 +02:00
GlodBlock c6f7c17854 eio conduct compact and fix transfer item and fluid in differentdirections 2022-10-01 14:44:34 +08:00
asdflj 61ac42d270 fix MouseRegionManager can't display tooltip.
when ingredient buffer outputting fluid, the current slot is used continuously,not from first slot to start output.
2022-09-30 16:55:11 +08:00
GlodBlock 989cd173fb more sanity asm 2022-09-29 21:42:27 +08:00
asdflj 8cafbceed7 add crafting preview screen support nei bookmark 2022-09-29 19:50:22 +08:00
Martin Robertz 292a70ab6e Merge pull request #18 from asdflj/master
me dual interface add insert mode
2022-09-22 17:25:49 +02:00
asdflj 2b8c983e8a me dual interface add insert mode 2022-09-21 12:32:45 +08:00
430 changed files with 43315 additions and 11210 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Ignore spotlessApply reformat
69a5c0e6ee71fe714eabe24002f9e39aae3b97be
+44
View File
@@ -0,0 +1,44 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
+1
View File
@@ -6,3 +6,4 @@ out/
*.ipr
*.iws
run/
build/
+1284 -407
View File
File diff suppressed because it is too large. Load diff
+19 -20
View File
@@ -1,26 +1,25 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-92-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:ExtraCells2:2.5.20:dev') {transitive = false}
compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.8.5:dev")
api('com.github.GTNewHorizons:NotEnoughItems:2.4.3-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-263-GTNH-pre:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.6.0:dev')
api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.0:dev")
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.7:dev")
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
compileOnly('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16: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.2:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.36:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.29:dev") {transitive = false}
compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false}
runtime("com.github.GTNewHorizons:Baubles:1.0.1.14: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.17:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.9:dev") { transitive = false }
}
+5 -1
View File
@@ -21,6 +21,10 @@ forgeVersion = 10.13.4.1614
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting 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
@@ -35,7 +39,7 @@ gradleTokenGroupName = GRADLETOKEN_GROUPNAME
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage =
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
Binary file not shown.
+2 -1
View File
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Regular → Executable
+198 -117
View File
@@ -1,79 +1,126 @@
#!/usr/bin/env bash
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn ( ) {
warn () {
echo "$*"
}
} >&2
die ( ) {
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -82,7 +129,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
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.
Please set the JAVA_HOME variable in your environment to match the
@@ -90,75 +137,109 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
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
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
-27
View File
@@ -1,31 +1,4 @@
// Add any additional repositories for your dependencies here
repositories {
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
allowInsecureProtocol
}
maven {
name 'ic2'
url 'https://maven.ic2.player.to/'
metadataSources {
mavenPom()
artifact()
}
}
maven {
name 'gt'
url 'https://gregtech.overminddl1.com/'
}
maven {
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
url 'https://jitpack.io'
}
}
+28
View File
@@ -0,0 +1,28 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
mavenContent {
includeGroup("com.gtnewhorizons.retrofuturagradle")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
@@ -1,27 +1,39 @@
package com.glodblock.github;
import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.FluidCellHandler;
import com.glodblock.github.crossmod.extracells.EC2Replacer;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.crossmod.waila.WailaInit;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.loader.CalculatorV2PluginLoader;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.loader.RecipeLoader;
import com.glodblock.github.loader.filter.FluidFilter;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
import com.glodblock.github.proxy.CommonProxy;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.AEApi;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@Mod(modid = FluidCraft.MODID, version = FluidCraft.VERSION, name = FluidCraft.MODNAME, dependencies = "required-after:appliedenergistics2")
@Mod(
modid = FluidCraft.MODID,
version = FluidCraft.VERSION,
name = FluidCraft.MODNAME,
dependencies = "required-after:appliedenergistics2@[rv3-beta-238,);required-after:CoFHCore;required-after:Baubles;after:waila;after:thaumicenergistics;after:ae2wct")
public class FluidCraft {
public static final String MODID = "GRADLETOKEN_MODID";
@@ -31,13 +43,15 @@ public class FluidCraft {
@Mod.Instance(MODID)
public static FluidCraft INSTANCE;
@SidedProxy(clientSide = "com.glodblock.github.proxy.ClientProxy", serverSide = "com.glodblock.github.proxy.CommonProxy")
@SidedProxy(
clientSide = "com.glodblock.github.proxy.ClientProxy",
serverSide = "com.glodblock.github.proxy.CommonProxy")
public static CommonProxy proxy;
@Mod.EventHandler
public static void preInit(FMLPreInitializationEvent event) {
Config.run();
(new ChannelLoader()).run();
ChannelLoader.INSTANCE.run();
proxy.preInit(event);
}
@@ -47,6 +61,9 @@ public class FluidCraft {
if (ModAndClassUtil.OC) {
OCDriverInit.run();
}
if (ModAndClassUtil.WAILA) {
WailaInit.run();
}
proxy.init(event);
}
@@ -58,34 +75,41 @@ public class FluidCraft {
ItemAndBlockHolder.loadSetting();
if (!Config.removeRecipe) {
(new RecipeLoader()).run();
RecipeLoader.INSTANCE.run();
}
RecipeLoader.runTerminalRecipe();
if (ModAndClassUtil.isBigInterface) {
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 3 );
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 3 );
if (ModAndClassUtil.isV2) {
CalculatorV2PluginLoader.installCalculatorV2Plugins();
}
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1 );
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1 );
if (Config.fluidIOBus) {
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2 );
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2 );
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1 );
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 1 );
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4 );
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4 );
if (ModAndClassUtil.isTypeFilter) {
AEApi.instance().registries().itemDisplay().addItemFilter(FluidFilter::filter);
}
proxy.postInit(event);
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {
public void onServerStart(FMLServerStartingEvent event) {
SPacketMEUpdateBuffer.init();
}
@Mod.EventHandler
public void onServerStop(FMLServerStoppedEvent event) {
SPacketMEUpdateBuffer.disable();
}
@Mod.EventHandler
public void missingMappings(FMLMissingMappingsEvent event) {
if (!ModAndClassUtil.EC2 && Config.replaceEC2) {
EC2Replacer.replaceExtraCells(event);
}
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {}
public static ResourceLocation resource(String path) {
return new ResourceLocation(MODID, path);
}
}
@@ -0,0 +1,53 @@
package com.glodblock.github.api;
import java.util.HashSet;
import java.util.Set;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
public final class FluidCraftAPI implements IFluidCraftAPI {
private static final FluidCraftAPI API = new FluidCraftAPI();
/**
* These fluids will not be allowed to be stored in fluid storage cells.
*/
private final Set<Class<? extends Fluid>> blacklistedFluids = new HashSet<>();
/**
* These fluids will not be displayed in a fluid terminal.
*/
private final Set<Class<? extends Fluid>> blacklistedDispFluids = new HashSet<>();
public static FluidCraftAPI instance() {
return API;
}
@Override
public void blacklistFluidInStorage(Class<? extends Fluid> fluid) {
blacklistedFluids.add(fluid);
}
@Override
public void blacklistFluidInDisplay(Class<? extends Fluid> fluid) {
blacklistedDispFluids.add(fluid);
}
@Override
public boolean isBlacklistedInStorage(Class<? extends Fluid> fluid) {
return blacklistedFluids.contains(fluid);
}
@Override
public boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid) {
return blacklistedDispFluids.contains(fluid);
}
@Override
public ILevelTerminalRegistry levelTerminalRegistry() {
return LevelTerminalRegistry.instance();
}
}
@@ -0,0 +1,34 @@
package com.glodblock.github.api;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
@SuppressWarnings("unused")
public interface IFluidCraftAPI {
/**
* Blacklisted fluids will not be allowed to be added to a storage cell.
*/
void blacklistFluidInStorage(Class<? extends Fluid> fluid);
/**
* Blacklisted fluids will not be displayed in fluid terminals.
*/
void blacklistFluidInDisplay(Class<? extends Fluid> fluid);
/**
* Mostly for internal use; queries whether the fluid is blacklisted from storage cells.
*/
boolean isBlacklistedInStorage(Class<? extends Fluid> fluid);
/**
* Mostly for internal use; queries whether the fluid is blacklisted from being displayed.
*/
boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid);
/**
* Get instance of `ILevelTerminalRegistry` to add new supported machines into terminal
*/
ILevelTerminalRegistry levelTerminalRegistry();
}
@@ -0,0 +1,8 @@
package com.glodblock.github.api;
import net.minecraftforge.common.util.ForgeDirection;
public interface ISide {
ForgeDirection getSide();
}
@@ -0,0 +1,20 @@
package com.glodblock.github.api.registries;
import java.util.Set;
import appeng.api.networking.IGridHost;
public interface ILevelTerminalRegistry {
void register(Class<? extends ILevelViewable> clazz);
void register(Class<? extends IGridHost> aeClass, ILevelViewableAdapter adapter);
Set<Class<? extends ILevelViewable>> getSupportedClasses();
boolean isAdopted(Class<? extends ILevelViewable> clazz);
Class<? extends IGridHost> getAdopted(Class<? extends ILevelViewable> clazz);
ILevelViewableAdapter getAdapter(Class<? extends ILevelViewable> clazz);
}
@@ -0,0 +1,53 @@
package com.glodblock.github.api.registries;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import com.glodblock.github.api.ISide;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.networking.IGridHost;
import appeng.api.util.DimensionalCoord;
import appeng.helpers.ICustomNameObject;
public interface ILevelViewable extends IGridHost, ISide, ISegmentedInventory, ICustomNameObject {
DimensionalCoord getLocation();
TileEntity getTile();
default long getSortValue() {
TileEntity te = getTile();
return ((long) te.zCoord << 24) ^ ((long) te.xCoord << 8) ^ te.yCoord;
}
default boolean shouldDisplay() {
return true;
}
/**
* Number of rows to expect. This is used with {@link #rowSize()} to determine how to render the slots.
*/
default int rows() {
return 1;
};
/**
* Number of slots per row.
*/
default int rowSize() {
return 1;
};
default ItemStack getSelfItemStack() {
return null;
}
/**
* "Target" Display representation
*/
default ItemStack getDisplayItemStack() {
return null;
}
}
@@ -0,0 +1,8 @@
package com.glodblock.github.api.registries;
import appeng.api.networking.IGridHost;
public interface ILevelViewableAdapter extends ILevelViewable {
ILevelViewable adapt(IGridHost gridHost);
}
@@ -1,21 +1,20 @@
package com.glodblock.github.client;
import com.glodblock.github.client.textures.FCPartsTexture;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import com.glodblock.github.client.textures.FCPartsTexture;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ClientHelper {
@SubscribeEvent
public void updateTextureSheet( final TextureStitchEvent.Pre ev )
{
if( ev.map.getTextureType() == 0 )
{
for( final FCPartsTexture cb : FCPartsTexture.values() )
{
cb.registerIcon( ev.map );
public void updateTextureSheet(final TextureStitchEvent.Pre ev) {
if (ev.map.getTextureType() == 0) {
for (final FCPartsTexture cb : FCPartsTexture.values()) {
cb.registerIcon(ev.map);
}
}
}
@@ -25,5 +24,4 @@ public class ClientHelper {
MinecraftForge.EVENT_BUS.register(handler);
FMLCommonHandler.instance().bus().register(handler);
}
}
@@ -0,0 +1,30 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.FontRenderer;
public class FCGuiLineField extends FCGuiTextField {
private final int _xPos;
private final int _yPos;
private final int _width;
private final FontRenderer _fontRender;
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width) {
this(fontRenderer, xPos, yPos, width, 5);
}
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width, int height) {
super(fontRenderer, xPos, yPos, width, height);
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._fontRender = fontRenderer;
}
@Override
public void drawTextBox() {
if (this.getVisible()) {
drawRect(this._xPos, this._yPos, this.xPosition + this.width, this.yPosition + this.height, getColor());
}
}
}
@@ -1,21 +1,26 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.widgets.ITooltip;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.ITooltip;
public class FCGuiTextField extends GuiTextField {
private static final int PADDING = 2;
private final FontRenderer _fontRender;
private String tooltip;
private final int _xPos;
private final int _yPos;
private final int _width;
private final int _height;
private int _border;
private int _color;
/**
* Uses the values to instantiate a padded version of a text field.
* Pays attention to the '_' caret.
* Uses the values to instantiate a padded version of a text field. Pays attention to the '_' caret.
*
* @param fontRenderer renderer for the strings
* @param xPos absolute left position
@@ -23,13 +28,81 @@ public class FCGuiTextField extends GuiTextField {
* @param width absolute width
* @param height absolute height
*/
public FCGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) {
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth('_'), height - 2 * PADDING);
public FCGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width,
final int height) {
super(
fontRenderer,
xPos + PADDING,
yPos + PADDING,
width - 2 * PADDING - fontRenderer.getCharWidth('_'),
height - 2 * PADDING);
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._height = height;
this._fontRender = fontRenderer;
}
@Override
public void drawTextBox() {
super.drawTextBox();
if (this.getBorder() > 0 && this.getVisible()) {
drawRect(
this._xPos - getBorder(),
this._yPos - getBorder(),
this.xPosition + this.width + getBorder(),
this.yPosition + this.height + getBorder(),
this.getColor());
}
}
public void handleTooltip(int mouseX, int mouseY, AEBaseGui gui) {
this.handleTooltip(mouseX, mouseY, gui, 0);
}
public void handleTooltip(int mouseX, int mouseY, AEBaseGui gui, int offsetY) {
if (isMouseIn(mouseX, mouseY) && this.tooltip != null && !"".equals(this.tooltip)) {
int length = 0;
for (String s : this.getMessage().split("\n")) {
length = Math.max(this._fontRender.getStringWidth(s), length);
}
if (mouseY < 15) {
mouseY = 15;
}
if (mouseX + length + 20 >= gui.width) {
gui.drawTooltip(mouseX - length - 20, mouseY + 4 + offsetY, 0, this.getMessage());
} else {
gui.drawTooltip(mouseX, mouseY + 4 + offsetY, 0, this.getMessage());
}
}
}
public int getBorder() {
return this._border;
}
public void setBorder(int border) {
this._border = border;
this._color = 0;
}
public void setBorder(int border, int color) {
this._border = border;
this._color = color;
}
public void setBorder() {
this._border = 0;
this._color = 0;
}
public int getColor() {
return this._color;
}
public void setColor(int color) {
this._color = color;
}
@Override
@@ -55,13 +128,16 @@ public class FCGuiTextField extends GuiTextField {
return withinXRange && withinYRange;
}
public void setMessage(String t)
{
public void setMessage(String t) {
tooltip = t;
}
public class TooltipProvider implements ITooltip
{
public String getMessage() {
return tooltip;
}
public class TooltipProvider implements ITooltip {
@Override
public String getMessage() {
return tooltip;
@@ -83,7 +159,9 @@ public class FCGuiTextField extends GuiTextField {
}
@Override
public int getWidth() { return _width; }
public int getWidth() {
return _width;
}
@Override
public boolean isVisible() {
@@ -1,201 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.slot.AppEngSlot;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainer;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
private static final String SUBSITUTION_DISABLE = "0";
private static final String SUBSITUTION_ENABLE = "1";
private static final String CRAFTMODE_CRFTING = "1";
private static final String CRAFTMODE_PROCESSING = "0";
public FCBasePartContainer container;
private GuiTabButton tabCraftButton;
private GuiTabButton tabProcessButton;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiImgButton encodeBtn;
private GuiImgButton clearBtn;
private GuiImgButton doubleBtn;
private GuiFCImgButton combineEnableBtn;
private GuiFCImgButton combineDisableBtn;
public GuiBaseFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new FCBasePartContainer( inventoryPlayer, te ) );
this.container = (FCBasePartContainer) this.inventorySlots;
setReservedSpace(81);
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
if( this.tabCraftButton == btn || this.tabProcessButton == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING ) );
}
else if( this.encodeBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0) ));
}
else if( this.clearBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Clear", "1" ) );
}
else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Combine", this.combineDisableBtn == btn ? "1" : "0" ) );
}
else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn)
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") );
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
super.initGui();
this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ), GuiText.CraftingPattern.getLocal(), itemRender );
this.buttonList.add( this.tabCraftButton );
this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ), GuiText.ProcessingPattern.getLocal(), itemRender );
this.buttonList.add( this.tabProcessButton );
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED );
this.substitutionsEnabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsEnabledBtn );
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED );
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
this.buttonList.add( this.encodeBtn );
int combineLeft = 74;
if (ModAndClassUtil.isDoubleButton) {
this.doubleBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE );
this.doubleBtn.setHalfSize( true );
this.buttonList.add( this.doubleBtn );
combineLeft = 84;
}
this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "FORCE_COMBINE", "DO_COMBINE" );
this.combineEnableBtn.setHalfSize( true );
this.buttonList.add( this.combineEnableBtn );
this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "NOT_COMBINE", "DONT_COMBINE" );
this.combineDisableBtn.setHalfSize( true );
this.buttonList.add( this.combineDisableBtn );
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if( !this.container.isCraftingMode() )
{
this.tabCraftButton.visible = false;
this.tabProcessButton.visible = true;
if (ModAndClassUtil.isDoubleButton)
this.doubleBtn.visible = true;
}
else
{
this.tabCraftButton.visible = true;
this.tabProcessButton.visible = false;
if (ModAndClassUtil.isDoubleButton)
this.doubleBtn.visible = false;
}
if( this.container.substitute )
{
this.substitutionsEnabledBtn.visible = true;
this.substitutionsDisabledBtn.visible = false;
}
else
{
this.substitutionsEnabledBtn.visible = false;
this.substitutionsDisabledBtn.visible = true;
}
if (!this.container.isCraftingMode())
{
if ( this.container.combine )
{
this.combineEnableBtn.visible = true;
this.combineDisableBtn.visible = false;
}
else
{
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = true;
}
}
else
{
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = false;
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 );
}
@Override
protected String getBackground()
{
if( this.container.isCraftingMode() )
{
return "gui/pattern.png";
}
return "gui/pattern2.png";
}
@Override
protected void repositionSlot( final AppEngSlot s )
{
if( s.isPlayerSide() )
{
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
else
{
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -1,290 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.PatternSlotConfig;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
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;
public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
private static final String SUBSITUTION_DISABLE = "0";
private static final String SUBSITUTION_ENABLE = "1";
private static final String PRIORITY_DISABLE = "0";
private static final String PRIORITY_ENABLE = "1";
public FCBasePartContainerEx container;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiFCImgButton fluidPrioritizedEnabledBtn;
private GuiFCImgButton fluidPrioritizedDisabledBtn;
private GuiImgButton encodeBtn;
private GuiImgButton invertBtn;
private GuiImgButton clearBtn;
private GuiImgButton doubleBtn;
private GuiFCImgButton combineEnableBtn;
private GuiFCImgButton combineDisableBtn;
private final GuiScrollbar processingScrollBar = new GuiScrollbar();
public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new FCBasePartContainerEx( inventoryPlayer, te ) );
this.container = (FCBasePartContainerEx) this.inventorySlots;
setReservedSpace(81);
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
if( this.encodeBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Encode",(isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)) );
}
else if( this.clearBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Clear", "1" ) );
}
else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
else if( this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE ) );
}
else if( this.invertBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Invert", container.inverted ? "0" : "1" ) );
}
else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Combine", this.combineDisableBtn == btn ? "1" : "0" ) );
}
else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn)
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") );
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
super.initGui();
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED );
this.substitutionsEnabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsEnabledBtn );
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED );
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
this.fluidPrioritizedEnabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "FORCE_PRIO", "DO_PRIO" );
this.fluidPrioritizedEnabledBtn.setHalfSize( true );
this.buttonList.add( this.fluidPrioritizedEnabledBtn );
this.fluidPrioritizedDisabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "NOT_PRIO", "DONT_PRIO" );
this.fluidPrioritizedDisabledBtn.setHalfSize( true );
this.buttonList.add( this.fluidPrioritizedDisabledBtn );
invertBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 153, Settings.ACTIONS, container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4);
invertBtn.setHalfSize( true );
this.buttonList.add( this.invertBtn );
this.clearBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
this.buttonList.add( this.encodeBtn );
if (ModAndClassUtil.isDoubleButton) {
this.doubleBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE );
this.doubleBtn.setHalfSize( true );
this.buttonList.add( this.doubleBtn );
}
this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "FORCE_COMBINE", "DO_COMBINE" );
this.combineEnableBtn.setHalfSize( true );
this.buttonList.add( this.combineEnableBtn );
this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "NOT_COMBINE", "DONT_COMBINE" );
this.combineDisableBtn.setHalfSize( true );
this.buttonList.add( this.combineDisableBtn );
processingScrollBar.setTop(this.ySize - 164);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if (ModAndClassUtil.isDoubleButton)
this.doubleBtn.visible = true;
if( this.container.substitute )
{
this.substitutionsEnabledBtn.visible = true;
this.substitutionsDisabledBtn.visible = false;
}
else
{
this.substitutionsEnabledBtn.visible = false;
this.substitutionsDisabledBtn.visible = true;
}
if( this.container.prioritize )
{
this.fluidPrioritizedEnabledBtn.visible = false;
this.fluidPrioritizedDisabledBtn.visible = true;
}
else
{
this.fluidPrioritizedEnabledBtn.visible = true;
this.fluidPrioritizedDisabledBtn.visible = false;
}
if ( this.container.combine )
{
this.combineEnableBtn.visible = true;
this.combineDisableBtn.visible = false;
}
else
{
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = true;
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 );
this.processingScrollBar.draw(this);
}
@Override
protected String getBackground()
{
return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png";
}
@Override
protected void repositionSlot( final AppEngSlot s )
{
if( s.isPlayerSide() )
{
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
else
{
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
if (container.substitute) {
substitutionsEnabledBtn.visible = true;
substitutionsDisabledBtn.visible = false;
} else {
substitutionsEnabledBtn.visible = false;
substitutionsDisabledBtn.visible = true;
}
if (container.prioritize) {
fluidPrioritizedEnabledBtn.visible = true;
fluidPrioritizedDisabledBtn.visible = false;
} else {
fluidPrioritizedEnabledBtn.visible = false;
fluidPrioritizedDisabledBtn.visible = true;
}
final int offset = container.inverted? 18 * -3: 0;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedEnabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedDisabledBtn.xPosition = this.guiLeft + 97 + offset;
doubleBtn.xPosition = this.guiLeft + 97 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
invertBtn.xPosition = this.guiLeft + 87 + offset;
combineEnableBtn.xPosition = this.guiLeft + 87 + offset;
combineDisableBtn.xPosition = this.guiLeft + 87 + offset;
processingScrollBar.setCurrentScroll(container.activePage);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn )
{
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
super.mouseClicked(xCoord, yCoord, btn);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
protected void mouseClickMove( final int x, final int y, final int c, final long d )
{
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop );
super.mouseClickMove(x, y, c, d);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
public void handleMouseInput()
{
super.handleMouseInput();
final int wheel = Mouse.getEventDWheel();
if (wheel != 0) {
final int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight;
if (this.processingScrollBar.contains(x - this.guiLeft, y - this.guiTop)) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.wheel(wheel);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
}
}
private void changeActivePage()
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll())));
}
}
@@ -0,0 +1,80 @@
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.PartFluidTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2ReflectClient;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiTabButton;
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {
private GuiTabButton originalGuiBtn;
private final ITerminalHost host;
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
host = te;
}
@Override
public void initGui() {
if (host instanceof PartFluidPatternTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL.stack());
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL_EX.stack());
else if (host instanceof PartFluidTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERM.stack());
else if (host instanceof PartLevelTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.LEVEL_TERMINAL.stack());
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack());
else if (host instanceof WirelessFluidTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_FLUID_TERM.stack());
else if (host instanceof WirelessPatternTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack());
else if (host instanceof WirelessInterfaceTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack());
else if (host instanceof WirelessLevelTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack());
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == originalGuiBtn) {
if (host instanceof PartFluidPatternTerminal) InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
else if (host instanceof 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 WirelessFluidTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
else if (host instanceof WirelessPatternTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
else if (host instanceof WirelessInterfaceTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
else if (host instanceof WirelessLevelTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_LEVEL_TERMINAL);
} else {
super.actionPerformed(btn);
}
}
}
@@ -1,6 +1,25 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
import com.glodblock.github.client.gui.container.ContainerDualInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import appeng.api.config.AdvancedBlockingMode;
import appeng.api.config.InsertionMode;
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;
@@ -11,18 +30,6 @@ import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.helpers.IInterfaceHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
public class GuiDualInterface extends GuiUpgradeable {
@@ -30,99 +37,146 @@ public class GuiDualInterface extends GuiUpgradeable {
private GuiTabButton switcher;
private GuiImgButton BlockMode;
private GuiToggleButton interfaceMode;
private GuiImgButton insertionMode;
private GuiImgButton sidelessMode;
private GuiImgButton advancedBlockingMode;
private final IInterfaceHost host;
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
super(new ContainerInterface(inventoryPlayer, te));
super(new ContainerDualInterface(inventoryPlayer, te));
this.host = te;
this.ySize = 211;
}
@Override
@SuppressWarnings("unchecked")
protected void addButtons()
{
this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
this.buttonList.add( this.priority );
protected void addButtons() {
this.priority = new GuiTabButton(
this.guiLeft + 154,
this.guiTop,
2 + 4 * 16,
GuiText.Priority.getLocal(),
itemRender);
this.buttonList.add(this.priority);
this.switcher = new GuiTabButton( this.guiLeft + 132, this.guiTop, host instanceof PartFluidInterface ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
this.switcher = new GuiTabButton(
this.guiLeft + 132,
this.guiTop,
host instanceof PartFluidInterface ? ItemAndBlockHolder.FLUID_INTERFACE.stack()
: ItemAndBlockHolder.INTERFACE.stack(),
StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"),
itemRender);
this.buttonList.add(this.switcher);
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
this.buttonList.add( this.BlockMode );
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO);
this.buttonList.add(this.BlockMode);
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal() );
this.buttonList.add( this.interfaceMode );
this.interfaceMode = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + 26,
84,
85,
GuiText.InterfaceTerminal.getLocal(),
GuiText.InterfaceTerminalHint.getLocal());
this.buttonList.add(this.interfaceMode);
this.insertionMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 44,
Settings.INSERTION_MODE,
InsertionMode.DEFAULT);
this.buttonList.add(this.insertionMode);
this.advancedBlockingMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 62,
Settings.ADVANCED_BLOCKING_MODE,
AdvancedBlockingMode.DEFAULT);
this.buttonList.add(this.advancedBlockingMode);
this.advancedBlockingMode.visible = this.bc.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0;
if (isTile()) {
this.sidelessMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 80,
Settings.SIDELESS_MODE,
SidelessMode.SIDELESS);
this.buttonList.add(this.sidelessMode);
}
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if( this.BlockMode != null )
{
this.BlockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (this.BlockMode != null) {
this.BlockMode.set(((ContainerInterface) this.cvb).getBlockingMode());
}
if( this.interfaceMode != null )
{
this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).getInterfaceTerminalMode() == YesNo.YES );
if (this.interfaceMode != null) {
this.interfaceMode.setState(((ContainerInterface) this.cvb).getInterfaceTerminalMode() == YesNo.YES);
}
this.fontRendererObj.drawString( getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752 );
if (this.insertionMode != null) {
this.insertionMode.set(((ContainerInterface) this.cvb).getInsertionMode());
}
if (this.sidelessMode != null) {
this.sidelessMode.set(((ContainerDualInterface) this.cvb).getSidelessMode());
}
if (this.advancedBlockingMode != null) {
this.advancedBlockingMode.set(((ContainerDualInterface) this.cvb).getAdvancedBlockingMode());
}
this.fontRendererObj.drawString(
getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)),
8,
6,
4210752);
}
@Override
protected String getBackground()
{
if (!ModAndClassUtil.isBigInterface)
return "guis/interface.png";
switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled())
{
case 1:
return "guis/interface2.png";
case 2:
return "guis/interface3.png";
case 3:
return "guis/interface4.png";
}
return "guis/interface.png";
protected String getBackground() {
if (!ModAndClassUtil.isBigInterface) return "guis/interface.png";
return switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) {
case -1 -> "guis/interfacenone.png";
case 1 -> "guis/interface2.png";
case 2 -> "guis/interface3.png";
case 3 -> "guis/interface4.png";
default -> "guis/interface.png";
};
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
final boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.priority )
{
if (host instanceof TileFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
}
else if(host instanceof PartFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART));
}
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == this.priority) {
InventoryHandler.switchGui(GuiType.PRIORITY);
} else if (btn == this.switcher) {
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE_FLUID);
} else if (btn == this.interfaceMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
} else if (btn == this.BlockMode) {
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.sidelessMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
} else if (btn == this.advancedBlockingMode) {
NetworkHandler.instance
.sendToServer(new PacketConfigButton(this.advancedBlockingMode.getSetting(), backwards));
}
}
if( btn == this.switcher )
{
if (host instanceof TileFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
}
else if (host instanceof PartFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
}
}
private boolean isPart() {
return this.host instanceof PartFluidInterface;
}
if( btn == this.interfaceMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
}
private boolean isTile() {
return this.host instanceof TileFluidInterface;
}
if( btn == this.BlockMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
@Override
protected void handleButtonVisibility() {
super.handleButtonVisibility();
if (this.advancedBlockingMode != null) {
this.advancedBlockingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0);
}
}
}
@@ -0,0 +1,109 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerEssentiaMonitor;
import com.glodblock.github.client.me.EssentiaRepo;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.crossmod.thaumcraft.AspectRender;
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
public class GuiEssentiaTerminal extends GuiFluidMonitor {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
protected EntityPlayer player;
public GuiEssentiaTerminal(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerEssentiaMonitor(inventoryPlayer, te));
this.repo = new EssentiaRepo(getScrollBar(), this);
this.player = inventoryPlayer.player;
}
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
if (AspectUtil.getAspectFromJar(stack) != null) {
setSearchString(Objects.requireNonNull(AspectUtil.getAspectFromJar(stack)).getName(), true);
}
}
@Override
public void func_146977_a(final Slot s) {
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotME) {
IAEItemStack stack = ((SlotME) slot).getAEStack();
if (stack == null) return true;
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
AspectRender.drawAspect(
this.player,
slot.xDisplayPosition,
slot.yDisplayPosition,
this.zLevel,
AspectUtil.getAspectFromGas(fluidStack),
fluidStack.amount);
IAEItemStack gas = stack.copy().setStackSize(stack.getStackSize() / AspectUtil.R);
stackSizeRenderer.setAeStack(gas);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
gas.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
}
@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));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
public void update(ItemStack itemStack) {
this.player.inventory.setItemStack(itemStack);
}
}
@@ -1,793 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.config.*;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.container.AEBaseContainer;
import appeng.container.slot.*;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBaseMonitorContain;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.util.List;
public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost
{
public static int craftingGridOffsetX;
public static int craftingGridOffsetY;
private static String memoryText = "";
private final ItemRepo repo;
private final int offsetX = 9;
private final int lowerTextureOffset = 0;
public IConfigManager configSrc;
private final boolean viewCell;
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
public FCBaseMonitorContain monitorableContainer;
public GuiTabButton craftingStatusBtn;
private GuiImgButton craftingStatusImgBtn;
private FCGuiTextField searchField;
private int perRow = 9;
private int reservedSpace = 0;
private boolean customSortOrder = true;
private int rows = 0;
private int maxRows = Integer.MAX_VALUE;
private int standardSize;
private GuiImgButton ViewBox;
private GuiImgButton SortByBox;
private GuiImgButton SortDirBox;
private GuiImgButton searchBoxSettings;
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
public GuiFCBaseMonitor( final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c )
{
super( c );
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.repo = new ItemRepo( scrollbar, this );
this.xSize = 195;
this.ySize = 204;
this.standardSize = this.xSize;
this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager();
( this.monitorableContainer = (FCBaseMonitorContain) this.inventorySlots ).setGui( this );
this.viewCell = te instanceof IViewCellStorage;
}
public void postUpdate( final List<IAEItemStack> list )
{
for( final IAEItemStack is : list )
{
this.repo.postUpdate( is );
}
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar()
{
this.getScrollBar().setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 );
this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
}
@Override
protected void actionPerformed( final GuiButton btn )
{
if( btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
}
if( btn instanceof GuiImgButton )
{
final boolean backwards = Mouse.isButtonDown( 1 );
final GuiImgButton iBtn = (GuiImgButton) btn;
if( iBtn.getSetting() != Settings.ACTIONS )
{
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
if( btn == this.terminalStyleBox )
{
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
}
else if( btn == this.searchBoxSettings )
{
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
}
else if( ModAndClassUtil.isSaveText && btn == this.searchStringSave )
{
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
}
else
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
iBtn.set( next );
if( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class )
{
this.reinitalize();
}
}
}
}
private void reinitalize()
{
this.buttonList.clear();
this.initGui();
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
Keyboard.enableRepeatEvents( true );
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 );
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.NEI );
final int NEI = hasNEI ? 0 : 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
this.rows = (int) Math.floor( extraSpace / 18.0 );
if( this.rows > this.maxRows )
{
top += ( this.rows - this.maxRows ) * 18 / 2;
this.rows = this.maxRows;
}
if( hasNEI )
{
this.rows--;
}
if( this.rows < 3 )
{
this.rows = 3;
}
this.getMeSlots().clear();
for( int y = 0; y < this.rows; y++ )
{
for( int x = 0; x < this.perRow; x++ )
{
this.getMeSlots().add( new InternalSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) );
}
}
if( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
{
this.xSize = this.standardSize + ( ( this.perRow - 9 ) * 18 );
}
else
{
this.xSize = this.standardSize;
}
super.initGui();
// full size : 204
// extra slots : 72
// slot 18
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor( unusedSpace / ( unusedSpace < 0 ? 3.8f : 2.0f ) );
int offset = this.guiTop + 8;
if( this.customSortOrder )
{
this.buttonList.add( this.SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ) ) );
offset += 20;
}
this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
offset += 20;
this.buttonList.add( this.SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
offset += 20;
this.buttonList.add( this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ) ) );
offset += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add( this.searchStringSave = new GuiImgButton( this.guiLeft - 18, offset, Settings.SAVE_SEARCH, AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO ) );
offset += 20;
}
this.buttonList.add( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting( Settings.TERMINAL_STYLE ) ) );
offset += 20;
this.searchField = new FCGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
this.searchField.setEnableBackgroundDrawing( false );
this.searchField.setMaxStringLength( 25 );
this.searchField.setTextColor( 0xFFFFFF );
this.searchField.setVisible( true );
if (ModAndClassUtil.isSearchStringTooltip)
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
if( this.viewCell)
{
if (ModAndClassUtil.isCraftStatus && AEConfig.instance.getConfigManager().getSetting(Settings.CRAFTING_STATUS).equals(CraftingStatus.BUTTON)) {
this.buttonList.add(this.craftingStatusImgBtn = new GuiImgButton(this.guiLeft - 18, offset, Settings.CRAFTING_STATUS, AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
} else {
this.buttonList.add(this.craftingStatusBtn = new GuiTabButton(this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender));
this.craftingStatusBtn.setHideEdge( 13 ); // GuiTabButton implementation //
}
}
// Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
final Enum<?> setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui()))
{
setSearchString(memoryText, false);
}
if( this.isSubGui() )
{
this.repo.updateView();
this.setScrollBar();
}
craftingGridOffsetX = Integer.MAX_VALUE;
craftingGridOffsetY = Integer.MAX_VALUE;
for( final Object s : this.inventorySlots.inventorySlots )
{
if( s instanceof AppEngSlot)
{
if( ( (Slot) s ).xDisplayPosition < 195 )
{
this.repositionSlot( (AppEngSlot) s );
}
}
if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix)
{
final Slot g = (Slot) s;
if( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 )
{
craftingGridOffsetX = Math.min( craftingGridOffsetX, g.xDisplayPosition );
craftingGridOffsetY = Math.min( craftingGridOffsetY, g.yDisplayPosition );
}
}
}
craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6;
}
public void setSearchString(String memoryText, boolean updateView)
{
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
if (updateView)
{
this.repo.updateView();
this.setScrollBar();
}
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Terminal.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn )
{
final Enum<?> searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
if( searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH )
{
this.searchField.mouseClicked( xCoord, yCoord, btn );
}
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
{
setSearchString("", true);
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override
protected void handleMouseClick( final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton )
{
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (mouseButton == 3 ){
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE");
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
return;
}
}
}
if( slot instanceof SlotFake)
{
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
}
else {
action = InventoryAction.PICKUP_SINGLE;
}
}
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
return;
}
final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
NetworkHandler.instance.sendToServer( p );
return;
}
if( slot instanceof SlotPatternTerm)
{
if( mouseButton == 6 )
{
return; // prevent weird double clicks..
}
try
{
NetworkHandler.instance.sendToServer( ( (SlotPatternTerm) slot ).getRequest( isShiftKeyDown() ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else if( slot instanceof SlotCraftingTerm )
{
if( mouseButton == 6 )
{
return; // prevent weird double clicks..
}
InventoryAction action;
if( isShiftKeyDown() )
{
action = InventoryAction.CRAFT_SHIFT;
}
else
{
// Craft stack on right-click, craft single on left-click
action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
NetworkHandler.instance.sendToServer( p );
return;
}
if( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) )
{
if( this.enableSpaceClicking() && !( slot instanceof SlotPatternTerm ) )
{
IAEItemStack stack = null;
if( slot instanceof SlotME )
{
stack = ( (SlotME) slot ).getAEStack();
}
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
if( !( slot instanceof SlotME ) && slot != null )
{
slotNum = slot.slotNumber;
}
( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack );
final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 );
NetworkHandler.instance.sendToServer( p );
return;
}
}
if( slot instanceof SlotDisconnected)
{
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
return;
}
InventoryAction action = null;
switch( mouseButton )
{
case 0: // pickup / set-down.
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if( player.capabilities.isCreativeMode )
{
action = InventoryAction.CREATIVE_DUPLICATE;
}
break;
default:
case 4: // drop item:
case 6:
}
if( action != null )
{
final PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() );
NetworkHandler.instance.sendToServer( p );
}
return;
}
if( slot instanceof SlotME )
{
InventoryAction action = null;
IAEItemStack stack = null;
switch( mouseButton )
{
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ( (SlotME) slot ).getAEStack();
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null )
{
action = InventoryAction.AUTO_CRAFT;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ( (SlotME) slot ).getAEStack();
break;
case 3: // creative dupe:
stack = ( (SlotME) slot ).getAEStack();
if( stack != null && stack.isCraftable() )
{
action = InventoryAction.AUTO_CRAFT;
}
else if( player.capabilities.isCreativeMode )
{
final IAEItemStack slotItem = ( (SlotME) slot ).getAEStack();
if( slotItem != null )
{
action = InventoryAction.CREATIVE_DUPLICATE;
}
}
break;
default:
case 4: // drop item:
case 6:
}
if (action == InventoryAction.AUTO_CRAFT) {
((AEBaseContainer) this.inventorySlots).setTargetStack( stack );
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
}
else if( action != null )
{
( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack );
final PacketInventoryAction p = new PacketInventoryAction( action, Ae2ReflectClient.getInventorySlots(this).size(), 0 );
NetworkHandler.instance.sendToServer( p );
}
return;
}
super.handleMouseClick( slot, slotIdx, ctrlDown, mouseButton );
}
@Override
public void onGuiClosed()
{
super.onGuiClosed();
Keyboard.enableRepeatEvents( false );
memoryText = this.searchField.getText();
}
public void bindTextureBack( final String file )
{
final ResourceLocation loc = new ResourceLocation( FluidCraft.MODID, "textures/" + file );
this.mc.getTextureManager().bindTexture( loc );
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTextureBack( this.getBackground() );
final int x_width = 195;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
if( this.viewCell )
{
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
}
for( int x = 0; x < this.rows; x++ )
{
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
}
this.drawTexturedModalRect( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset );
if( this.viewCell )
{
boolean update = false;
for( int i = 0; i < 5; i++ )
{
if( this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot( i ).getStack() )
{
update = true;
this.myCurrentViewCells[i] = this.monitorableContainer.getCellViewSlot( i ).getStack();
}
}
if( update )
{
this.repo.setViewCell( this.myCurrentViewCells );
}
}
if( this.searchField != null )
{
this.searchField.drawTextBox();
}
}
protected String getBackground()
{
return "gui/terminal.png";
}
@Override
protected boolean isPowered()
{
return this.repo.hasPower();
}
int getMaxRows()
{
return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
}
protected void repositionSlot( final AppEngSlot s )
{
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( character == ' ' && this.searchField.getText().isEmpty() )
{
return;
}
if( this.searchField.textboxKeyTyped( character, key ) )
{
this.repo.setSearchString( this.searchField.getText() );
this.repo.updateView();
this.setScrollBar();
}
else
{
super.keyTyped( character, key );
}
}
}
@Override
public void updateScreen()
{
this.repo.setPower( this.monitorableContainer.isPowered() );
super.updateScreen();
}
@Override
public Enum<?> getSortBy()
{
return this.configSrc.getSetting( Settings.SORT_BY );
}
@Override
public Enum<?> getSortDir()
{
return this.configSrc.getSetting( Settings.SORT_DIRECTION );
}
@Override
public Enum<?> getSortDisplay()
{
return this.configSrc.getSetting( Settings.VIEW_MODE );
}
@Override
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
{
if( this.SortByBox != null )
{
this.SortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) );
}
if( this.SortDirBox != null )
{
this.SortDirBox.set( this.configSrc.getSetting( Settings.SORT_DIRECTION ) );
}
if( this.ViewBox != null )
{
this.ViewBox.set( this.configSrc.getSetting( Settings.VIEW_MODE ) );
}
this.repo.updateView();
}
public int getReservedSpace()
{
return this.reservedSpace;
}
public void setReservedSpace( final int reservedSpace )
{
this.reservedSpace = reservedSpace;
}
public boolean isCustomSortOrder()
{
return this.customSortOrder;
}
public void setCustomSortOrder( final boolean customSortOrder )
{
this.customSortOrder = customSortOrder;
}
public int getStandardSize()
{
return this.standardSize;
}
public void setStandardSize( final int standardSize )
{
this.standardSize = standardSize;
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn ) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
public boolean isOverSearchField(int x, int y)
{
return searchField.isMouseIn(x,y);
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th)
{
if (this.viewCell) {
int rw = 33;
int rh = 14 + myCurrentViewCells.length * 18;
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
return false;
}
int rx = this.guiLeft + this.xSize;
int ry = this.guiTop + 0;
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
}
return false;
}
}
@@ -1,31 +1,39 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.widgets.ITooltip;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.NameConst;
import appeng.client.gui.widgets.ITooltip;
public class GuiFCImgButton extends GuiButton implements ITooltip {
private static final Pattern COMPILE = Pattern.compile( "%s" );
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
private static final Pattern COMPILE = Pattern.compile("%s");
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
private static Map<EnumPair, ButtonAppearance> appearances;
private final String buttonSetting;
private boolean halfSize = false;
private String fillVar;
private String currentValue;
private final boolean background;
private static final String prefix = NameConst.TT_KEY;
public GuiFCImgButton( final int x, final int y, final String idx, final String val ) {
super(0, 0, 16, "");
public GuiFCImgButton(final int x, final int y, final String idx, final String val) {
this(x, y, idx, val, true);
}
public GuiFCImgButton(final int x, final int y, final String idx, final String val, boolean background) {
super(0, 0, 16, "");
this.background = background;
this.buttonSetting = idx;
this.currentValue = val;
this.xPosition = x;
@@ -33,37 +41,56 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.width = 16;
this.height = 16;
if( appearances == null ) {
if (appearances == null) {
appearances = new HashMap<>();
this.registerApp( 0, "NOT_COMBINE", "DONT_COMBINE", "not_combine" );
this.registerApp( 1, "FORCE_COMBINE", "DO_COMBINE", "combine" );
this.registerApp( 2, "FORCE_PRIO", "DO_PRIO", "prio" );
this.registerApp( 3, "NOT_PRIO", "DONT_PRIO", "not_prio" );
this.registerApp(0, "NOT_COMBINE", "DONT_COMBINE", "not_combine");
this.registerApp(1, "FORCE_COMBINE", "DO_COMBINE", "combine");
this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio");
this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio");
this.registerApp(4, "SUBMIT", "SUBMIT", "submit");
this.registerApp(5, "EDIT", "YES", "edit");
this.registerApp(6, "DISABLE", "DISABLE", "disable");
this.registerApp(7, "ENABLE", "ENABLE", "enable");
this.registerApp(10, "FLUID_TEM", "YES", "fluid_terminal_w");
this.registerApp(11, "CRAFT_TEM", "YES", "craft_terminal_w");
this.registerApp(12, "PATTERN_TEM", "YES", "pattern_terminal_w");
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
this.registerApp(20, "LEVEL_TEM", "YES", "level_terminal_w");
this.registerApp(21, "SWITCH", "ON", "edit");
this.registerApp(22, "SWITCH", "OFF", "view");
this.registerApp(21, "SWITCH", "ENABLE", "enable");
this.registerApp(22, "SWITCH", "DISABLE", "disable");
this.registerApp(23, "CONFIG", "YES", "open_configuration");
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
}
}
private void registerApp(final int iconIndex, final String setting, final String val, final String title )
{
private void registerApp(final int iconIndex, final String setting, final String val, final String title) {
final ButtonAppearance a = new ButtonAppearance();
a.displayName = StatCollector.translateToLocal(prefix + title);
a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint");
a.index = iconIndex;
appearances.put( new EnumPair( setting, val ), a );
if (StatCollector.translateToLocal(prefix + title + ".hint").equals(prefix + title + ".hint")) {
a.displayValue = null;
} else {
a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint");
}
a.index = iconIndex % 10;
a.page = iconIndex / 10;
appearances.put(new EnumPair(setting, val), a);
}
public void setVisibility( final boolean vis )
{
public void setVisibility(final boolean vis) {
this.visible = vis;
this.enabled = vis;
}
private int getIconIndex()
{
if( this.buttonSetting != null && this.currentValue != null )
{
final ButtonAppearance app = appearances.get(new EnumPair( this.buttonSetting, this.currentValue ));
if( app == null )
{
private int getIconIndex() {
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
if (app == null) {
return 8;
}
return app.index;
@@ -71,217 +98,225 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
return 8;
}
public String getSetting()
{
private int getIconPage() {
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
if (app == null) {
return 0;
}
return app.page;
}
return 0;
}
public String getSetting() {
return this.buttonSetting;
}
public String getCurrentValue()
{
public String getCurrentValue() {
return this.currentValue;
}
public void set( final String e )
{
if(!this.currentValue.equals(e))
{
public boolean getMouseIn() {
return this.field_146123_n;
}
public void set(final String e) {
if (!this.currentValue.equals(e)) {
this.currentValue = e;
}
}
public boolean isHalfSize()
{
public boolean isHalfSize() {
return this.halfSize;
}
public void setHalfSize( final boolean halfSize )
{
public void setHalfSize(final boolean halfSize) {
this.halfSize = halfSize;
}
public String getFillVar()
{
public String getFillVar() {
return this.fillVar;
}
public void setFillVar( final String fillVar )
{
public void setFillVar(final String fillVar) {
this.fillVar = fillVar;
}
@Override
public int xPos()
{
public int xPos() {
return this.xPosition;
}
@Override
public int yPos()
{
public int yPos() {
return this.yPosition;
}
@Override
public int getWidth()
{
public int getWidth() {
return this.halfSize ? 8 : 16;
}
@Override
public int getHeight()
{
public int getHeight() {
return this.halfSize ? 8 : 16;
}
@Override
public boolean isVisible()
{
public boolean isVisible() {
return this.visible;
}
@Override
public String getMessage()
{
public String getMessage() {
String displayName = null;
String displayValue = null;
if( this.buttonSetting != null && this.currentValue != null )
{
final ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
if( buttonAppearance == null )
{
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance buttonAppearance = appearances
.get(new EnumPair(this.buttonSetting, this.currentValue));
if (buttonAppearance == null) {
return "No Such Message";
}
displayName = buttonAppearance.displayName;
displayValue = buttonAppearance.displayValue;
}
if( displayName != null )
{
String name = StatCollector.translateToLocal( displayName );
String value = StatCollector.translateToLocal( displayValue );
if( name == null || name.isEmpty() )
{
if (displayName != null) {
String name = StatCollector.translateToLocal(displayName);
if (name == null || name.isEmpty()) {
name = displayName;
}
if( value == null || value.isEmpty() )
{
value = displayValue;
}
if (displayValue != null) {
String value = StatCollector.translateToLocal(displayValue);
if( this.fillVar != null )
{
value = COMPILE.matcher( value ).replaceFirst( this.fillVar );
}
if (this.fillVar != null) {
value = COMPILE.matcher(value).replaceFirst(this.fillVar);
}
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
final StringBuilder sb = new StringBuilder( value );
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
final StringBuilder sb = new StringBuilder(value);
int i = sb.lastIndexOf( "\n" );
if( i <= 0 )
{
i = 0;
int i = sb.lastIndexOf("\n");
if (i <= 0) {
i = 0;
}
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
sb.replace(i, i + 1, "\n");
}
return name + '\n' + sb;
}
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
{
sb.replace( i, i + 1, "\n" );
}
return name + '\n' + sb;
return name;
}
return null;
}
@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3 )
{
if( this.visible )
{
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
final int iconPage = this.getIconPage();
if( this.halfSize )
{
if (this.halfSize) {
this.width = 8;
this.height = 8;
GL11.glPushMatrix();
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
GL11.glScalef( 0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3 );
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
GL11.glScalef(0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3);
if( this.enabled )
{
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
else
{
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
if (this.enabled) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture( FluidCraft.resource("textures/gui/states.png") );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
final int uv_y = (int) Math.floor( iconIndex / 3.0 );
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
this.drawTexturedModalRect( 0, 0, Math.round(32F * 16F / 3F), Math.round(32F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F) );
this.drawTexturedModalRect( 0, 0, Math.round(uv_x * 16F * 16F / 3F), Math.round(uv_y * 16F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F) );
this.mouseDragged( par1Minecraft, par2, par3 );
GL11.glPopMatrix();
}
else
{
if( this.enabled )
{
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
else
{
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
this.drawTexturedModalRect(
0,
0,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
} else {
GL11.glPushMatrix();
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
GL11.glScalef(0.5f / 16 * 6, 0.5f / 16 * 6, 0.5f / 16 * 6);
if (this.enabled) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture( FluidCraft.resource("textures/gui/states.png") );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
final int uv_y = (int) Math.floor( iconIndex / 3.0 );
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
this.drawTexturedModalRect( this.xPosition, this.yPosition, 32, 32, 16, 16 );
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
this.drawTexturedModalRect(
0,
0,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
}
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
private static final class EnumPair
{
private static final class EnumPair {
final String setting;
final String value;
EnumPair( final String a, final String b )
{
EnumPair(final String a, final String b) {
this.setting = a;
this.value = b;
}
@Override
public int hashCode()
{
public int hashCode() {
return this.setting.hashCode() ^ this.value.hashCode();
}
@Override
public boolean equals( final Object obj )
{
if( obj == null )
{
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if( this.getClass() != obj.getClass() )
{
if (this.getClass() != obj.getClass()) {
return false;
}
final EnumPair other = (EnumPair) obj;
@@ -289,12 +324,11 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
}
}
private static class ButtonAppearance {
private static class ButtonAppearance
{
public int index;
public int page;
public String displayName;
public String displayValue;
}
}
@@ -1,219 +1,101 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import java.io.IOException;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.IDualHost;
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;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import java.io.IOException;
public class GuiFCPriority extends FCGuiAmount {
public class GuiFCPriority extends AEBaseGui
{
private GuiNumberBox priority;
private GuiTabButton originalGuiBtn;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiType OriginalGui;
public GuiFCPriority( final InventoryPlayer inventoryPlayer, final IPriorityHost te )
{
super( new ContainerPriority( inventoryPlayer, te ) );
public GuiFCPriority(final InventoryPlayer inventoryPlayer, final IPriorityHost te) {
super(new ContainerPriority(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
public void initGui() {
super.initGui();
final int a = AEConfig.instance.priorityByStacksAmounts( 0 );
final int b = AEConfig.instance.priorityByStacksAmounts( 1 );
final int c = AEConfig.instance.priorityByStacksAmounts( 2 );
final int d = AEConfig.instance.priorityByStacksAmounts( 3 );
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
ItemStack myIcon = null;
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
if( target instanceof TileFluidInterface)
{
myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE;
}
else if (target instanceof PartFluidInterface)
{
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
}
if( this.OriginalGui != null && myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
}
this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class );
this.priority.setEnableBackgroundDrawing( false );
this.priority.setMaxStringLength( 16 );
this.priority.setTextColor( 0xFFFFFF );
this.priority.setVisible( true );
this.priority.setFocused( true );
( (ContainerPriority) this.inventorySlots ).setTextField( this.priority );
this.submit.enabled = false;
this.submit.visible = false;
this.buttonList.remove(this.submit);
((ContainerPriority) this.inventorySlots).setTextField(this.amountBox);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 0x404040);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.priority.drawTextBox();
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.amountBox.drawTextBox();
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
if( btn == this.originalGuiBtn )
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
}
}
private void addQty( final int i )
{
try
{
String out = this.priority.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if( fixed )
{
this.priority.setText( out );
}
if( out.isEmpty() )
{
out = "0";
}
long result = Long.parseLong( out );
result += i;
this.priority.setText( out = Long.toString( result ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch( final NumberFormatException e )
{
// nope..
this.priority.setText( "0" );
}
catch( final IOException e )
{
AELog.debug( e );
protected void addQty(final int i) {
try {
this.amountBox.setText(Long.toString(getAmount() + i));
} catch (final NumberFormatException ignore) {}
try {
NetworkHandler.instance
.sendToServer(new PacketValueConfig("PriorityHost.Priority", String.valueOf(getAmount())));
} catch (IOException e) {
AELog.debug(e);
}
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority.textboxKeyTyped( character, key ) )
{
try
{
String out = this.priority.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if( fixed )
{
this.priority.setText( out );
}
if( out.isEmpty() )
{
out = "0";
}
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else
{
super.keyTyped( character, key );
}
protected void setOriginGUI(Object target) {
if (target instanceof IDualHost) {
this.myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.originalGui = GuiType.DUAL_INTERFACE;
} else if (target instanceof PartFluidStorageBus) {
this.myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
this.originalGui = GuiType.FLUID_STORAGE_BUS;
}
}
protected String getBackground()
{
@Override
protected void keyTyped(final char character, final int key) {
super.keyTyped(character, key);
try {
NetworkHandler.instance
.sendToServer(new PacketValueConfig("PriorityHost.Priority", String.valueOf(getAmount())));
} catch (IOException e) {
AELog.debug(e);
}
}
@Override
protected int getAmount() {
try {
String out = this.amountBox.getText();
double result = Calculator.conversion(out);
if (Double.isNaN(result)) {
return 0;
} else {
return (int) ArithHelper.round(result, 0);
}
} catch (final NumberFormatException e) {
return 0;
}
}
protected String getBackground() {
return "guis/priority.png";
}
}
@@ -0,0 +1,37 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidAutoFiller;
import com.glodblock.github.common.tile.TileFluidAutoFiller;
import com.glodblock.github.util.NameConst;
import appeng.client.gui.AEBaseMEGui;
import appeng.core.localization.GuiText;
public class GuiFluidAutoFiller extends AEBaseMEGui {
protected EntityPlayer player;
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_auto_filler.png");
public GuiFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
super(new ContainerFluidAutoFiller(ipl, tile));
this.player = ipl.player;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_AUTO_FILLER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
}
@@ -1,258 +1,96 @@
package com.glodblock.github.client.gui;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
import com.glodblock.github.network.CPacketSwitchGuis;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GuiFluidCraftAmount extends AEBaseGui
{
private GuiNumberBox amountToCraft;
private GuiTabButton originalGuiBtn;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
private GuiButton next;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.localization.GuiText;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
public class GuiFluidCraftAmount extends FCGuiAmount {
private GuiType originalGui;
@Reflected
public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( new ContainerCraftAmount( inventoryPlayer, te ) );
public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerCraftAmount(inventoryPlayer, te));
}
@Override
public void initGui()
{
public void initGui() {
super.initGui();
this.amountBox.setText("1");
this.amountBox.setSelectionPos(0);
}
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 );
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 0x404040);
}
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.submit.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
try {
this.submit.enabled = getAmount() > 0;
} catch (final NumberFormatException e) {
this.submit.enabled = false;
}
this.amountBox.drawTextBox();
}
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try {
if (btn == this.submit && this.submit.enabled) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketCraftRequest(getAmount(), isShiftKeyDown()));
}
} catch (final NumberFormatException e) {
this.amountBox.setText("1");
}
}
this.buttonList.add( this.next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
ItemStack myIcon = null;
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if( target instanceof PartFluidPatternTerminal)
{
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if( this.originalGui != null && myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
}
this.amountToCraft = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class );
this.amountToCraft.setEnableBackgroundDrawing( false );
this.amountToCraft.setMaxStringLength( 16 );
this.amountToCraft.setTextColor( 0xFFFFFF );
this.amountToCraft.setVisible( true );
this.amountToCraft.setFocused( true );
this.amountToCraft.setText( "1" );
this.amountToCraft.setSelectionPos(0);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
this.bindTexture( "guis/craftAmt.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
try
{
Long.parseLong( this.amountToCraft.getText() );
this.next.enabled = this.amountToCraft.getText().length() > 0;
}
catch( final NumberFormatException e )
{
this.next.enabled = false;
}
this.amountToCraft.drawTextBox();
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( key == 28 )
{
this.actionPerformed( this.next );
}
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.amountToCraft.textboxKeyTyped( character, key ) )
{
try
{
String out = this.amountToCraft.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if( fixed )
{
this.amountToCraft.setText( out );
}
if( out.isEmpty() )
{
out = "0";
}
final long result = Long.parseLong( out );
if( result < 0 )
{
this.amountToCraft.setText( "1" );
}
}
catch( final NumberFormatException e )
{
// :P
}
}
else
{
super.keyTyped( character, key );
}
} else if (target instanceof PartFluidTerminal) {
this.myIcon = ItemAndBlockHolder.FLUID_TERM.stack();
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof PartLevelTerminal) {
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof WirelessLevelTerminalInventory) {
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
try
{
if( btn == this.originalGuiBtn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketSwitchGuis( this.originalGui ) );
}
if( btn == this.next )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
}
}
catch( final NumberFormatException e )
{
// nope..
this.amountToCraft.setText( "1" );
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
}
protected String getBackground() {
return "guis/craftAmt.png";
}
private void addQty( final int i )
{
try
{
String out = this.amountToCraft.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if( fixed )
{
this.amountToCraft.setText( out );
}
if( out.isEmpty() )
{
out = "0";
}
long result = Integer.parseInt( out );
if( result == 1 && i > 1 )
{
result = 0;
}
result += i;
if( result < 1 )
{
result = 1;
}
out = Long.toString( result );
Integer.parseInt( out );
this.amountToCraft.setText( out );
}
catch( final NumberFormatException e )
{
// :P
}
}
}
@@ -1,554 +1,43 @@
package com.glodblock.github.client.gui;
import appeng.api.AEApi;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
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.coremod.hooker.CoreModHooks;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
import com.google.common.base.Joiner;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftConfirm;
public class GuiFluidCraftConfirm extends AEBaseGui {
public class GuiFluidCraftConfirm extends GuiCraftConfirm {
private final ContainerFluidCraftConfirm ccc;
private GuiType originalGui;
private final int rows = 5;
private final IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
private final IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
private final IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
private final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
private GuiType OriginalGui;
private GuiButton cancel;
private GuiButton start;
private GuiButton selectCPU;
private int tooltip = -1;
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( new ContainerFluidCraftConfirm( inventoryPlayer, te ) );
this.xSize = 238;
this.ySize = 206;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.ccc = (ContainerFluidCraftConfirm) this.inventorySlots;
if( te instanceof PartFluidPatternTerminal)
{
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if( te instanceof PartFluidPatternTerminalEx)
{
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
}
boolean isAutoStart()
{
return ( (ContainerFluidCraftConfirm) this.inventorySlots ).isAutoStart();
}
@Override
public void initGui()
{
super.initGui();
this.start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal() );
this.start.enabled = false;
this.buttonList.add( this.start );
this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic );
this.selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
if( this.OriginalGui != null )
{
this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
}
this.buttonList.add( this.cancel );
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
this.updateCPUButtonText();
this.start.enabled = !( this.ccc.hasNoCPU() || this.isSimulation() );
this.selectCPU.enabled = !this.isSimulation();
final int gx = ( this.width - this.xSize ) / 2;
final int gy = ( this.height - this.ySize ) / 2;
this.tooltip = -1;
final int offY = 23;
int y = 0;
int x = 0;
for( int z = 0; z <= 4 * 5; z++ )
{
final int minX = gx + 9 + x * 67;
final int minY = gy + 22 + y * offY;
if( minX < mouseX && minX + 67 > mouseX )
{
if( minY < mouseY && minY + offY - 2 > mouseY )
{
this.tooltip = z;
break;
}
}
x++;
if( x > 2 )
{
y++;
x = 0;
}
}
super.drawScreen( mouseX, mouseY, btn );
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
if( this.ccc.getSelectedCpu() >= 0 )// && status.selectedCpu < status.cpus.size() )
{
if( this.ccc.getName().length() > 0 )
{
final String name = this.ccc.getName().substring( 0, Math.min( 20, this.ccc.getName().length() ) );
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
}
else
{
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.getSelectedCpu();
}
}
if( this.ccc.hasNoCPU() )
{
btnTextText = GuiText.NoCraftingCPUs.getLocal();
}
this.selectCPU.displayString = btnTextText;
}
private boolean isSimulation()
{
return ( (ContainerFluidCraftConfirm) this.inventorySlots ).isSimulation();
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
final long BytesUsed = this.ccc.getUsedBytes();
final String byteUsed = NumberFormat.getInstance().format( BytesUsed );
final String Add = BytesUsed > 0 ? ( byteUsed + ' ' + GuiText.BytesUsed.getLocal() ) : GuiText.CalculatingWait.getLocal();
this.fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
String dsp = null;
if( this.isSimulation() )
{
dsp = GuiText.Simulation.getLocal();
}
else
{
dsp = this.ccc.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
}
final int offset = ( 219 - this.fontRendererObj.getStringWidth( dsp ) ) / 2;
this.fontRendererObj.drawString( dsp, offset, 165, 4210752 );
final int sectionLength = 67;
int x = 0;
int y = 0;
final int xo = 9;
final int yo = 22;
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
final int viewEnd = viewStart + 3 * this.rows;
String dspToolTip = "";
final List<String> lineList = new LinkedList<String>();
int toolPosX = 0;
int toolPosY = 0;
final int offY = 23;
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
{
final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
if( refStack != null )
{
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
final IAEItemStack stored = this.storage.findPrecise( refStack );
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
final IAEItemStack missingStack = this.missing.findPrecise( refStack );
int lines = 0;
if( stored != null && stored.getStackSize() > 0 )
{
lines++;
}
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
lines++;
}
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
lines++;
}
final int negY = ( ( lines - 1 ) * 5 ) / 2;
int downY = 0;
if( stored != null && stored.getStackSize() > 0 )
{
String str = Long.toString( stored.getStackSize() );
if( stored.getStackSize() >= 10000 )
{
str = Long.toString( stored.getStackSize() / 1000 ) + 'k';
}
if( stored.getStackSize() >= 10000000 )
{
str = Long.toString( stored.getStackSize() / 1000000 ) + 'm';
}
str = GuiText.FromStorage.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
}
downY += 5;
}
boolean red = false;
if( missingStack != null && missingStack.getStackSize() > 0 )
{
String str = Long.toString( missingStack.getStackSize() );
if( missingStack.getStackSize() >= 10000 )
{
str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k';
}
if( missingStack.getStackSize() >= 10000000 )
{
str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm';
}
str = GuiText.Missing.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
}
red = true;
downY += 5;
}
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
String str = Long.toString( pendingStack.getStackSize() );
if( pendingStack.getStackSize() >= 10000 )
{
str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k';
}
if( pendingStack.getStackSize() >= 10000000 )
{
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm';
}
str = GuiText.ToCraft.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
}
}
GL11.glPopMatrix();
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
final int posY = y * offY + yo;
final ItemStack is = CoreModHooks.displayFluid(refStack.copy());
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if( lineList.size() > 0 )
{
addItemTooltip(is, lineList);
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
}
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
}
this.drawItem( posX, posY, is );
if( red )
{
final int startX = x * ( 1 + sectionLength ) + xo;
final int startY = posY - 4;
drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
}
x++;
if( x > 2 )
{
y++;
x = 0;
}
}
}
if( this.tooltip >= 0 && dspToolTip.length() > 0 )
{
this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final 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
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.setScrollBar();
this.bindTexture( "guis/craftingreport.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
public void switchToOriginalGUI() {
InventoryHandler.switchGui(originalGui);
}
private void setScrollBar()
{
final int size = this.visual.size();
this.getScrollBar().setTop( 19 ).setLeft( 218 ).setHeight( 114 );
this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - this.rows, 1 );
}
public void postUpdate( final List<IAEItemStack> list, final byte ref )
{
switch( ref )
{
case 0:
for( final IAEItemStack l : list )
{
this.handleInput( this.storage, l );
}
break;
case 1:
for( final IAEItemStack l : list )
{
this.handleInput( this.pending, l );
}
break;
case 2:
for( final IAEItemStack l : list )
{
this.handleInput( this.missing, l );
}
break;
}
for( final IAEItemStack l : list )
{
final long amt = this.getTotal( l );
if( amt <= 0 )
{
this.deleteVisualStack( l );
}
else
{
final IAEItemStack is = this.findVisualStack( l );
is.setStackSize( amt );
}
}
this.setScrollBar();
}
private void handleInput( final IItemList<IAEItemStack> s, final IAEItemStack l )
{
IAEItemStack a = s.findPrecise( l );
if( l.getStackSize() <= 0 )
{
if( a != null )
{
a.reset();
}
}
else
{
if( a == null )
{
s.add( l.copy() );
a = s.findPrecise( l );
}
if( a != null )
{
a.setStackSize( l.getStackSize() );
}
}
}
private long getTotal( final IAEItemStack is )
{
final IAEItemStack a = this.storage.findPrecise( is );
final IAEItemStack c = this.pending.findPrecise( is );
final IAEItemStack m = this.missing.findPrecise( is );
long total = 0;
if( a != null )
{
total += a.getStackSize();
}
if( c != null )
{
total += c.getStackSize();
}
if( m != null )
{
total += m.getStackSize();
}
return total;
}
private void deleteVisualStack( final IAEItemStack l )
{
final Iterator<IAEItemStack> i = this.visual.iterator();
while( i.hasNext() )
{
final IAEItemStack o = i.next();
if( o.equals( l ) )
{
i.remove();
return;
}
}
}
private IAEItemStack findVisualStack( final IAEItemStack l )
{
for( final IAEItemStack o : this.visual )
{
if( o.equals( l ) )
{
return o;
}
}
final IAEItemStack stack = l.copy();
this.visual.add( stack );
return stack;
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( key == 28 )
{
this.actionPerformed( this.start );
}
super.keyTyped( character, key );
}
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
final boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.selectCPU )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
}
if( btn == this.cancel )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketSwitchGuis( this.OriginalGui ) );
}
if( btn == this.start )
{
try
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "Terminal.Start", "Start" ) );
}
catch( final Throwable e )
{
AELog.debug( e );
}
}
}
@SuppressWarnings({"rawtypes", "unchecked"})
protected void addItemTooltip(ItemStack is, List<String> lineList)
{
if (isShiftKeyDown())
{
List l = is.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
if (!l.isEmpty())
l.remove(0);
lineList.addAll(l);
}
else if (ModAndClassUtil.isShiftTooltip)
{
lineList.add(GuiText.HoldShiftForTooltip.getLocal());
}
}
}
@@ -0,0 +1,85 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import com.glodblock.github.client.gui.container.ContainerCraftingWireless;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
public class GuiFluidCraftingWireless extends GuiItemMonitor {
private GuiImgButton clearBtn;
public GuiFluidCraftingWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerCraftingWireless(inventoryPlayer, te));
this.setReservedSpace(73);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
if (this.clearBtn == btn) {
Slot s = null;
final Container c = this.inventorySlots;
for (final Object j : c.inventorySlots) {
if (j instanceof SlotCraftingMatrix) {
s = (Slot) j;
}
}
if (s != null) {
final PacketInventoryAction p = new PacketInventoryAction(
InventoryAction.MOVE_REGION,
s.slotNumber,
0);
NetworkHandler.instance.sendToServer(p);
}
}
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.buttonList.add(
this.clearBtn = new GuiImgButton(
this.guiLeft + 92,
this.guiTop + this.ySize - 156,
Settings.ACTIONS,
ActionItems.STASH));
this.clearBtn.setHalfSize(true);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRendererObj.drawString(
GuiText.CraftingTerminal.getLocal(),
8,
this.ySize - 96 + 1 - this.getReservedSpace(),
GuiColors.CraftingTerminalTitle.getColor());
}
@Override
protected String getBackground() {
return "gui/crafting.png";
}
}
@@ -1,59 +1,72 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidIO extends GuiUpgradeable
{
private final PartSharedFluidBus bus;
import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.util.NameConst;
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te )
{
super( new ContainerFluidIO( inventoryPlayer, te ) );
import appeng.api.config.Upgrades;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
public class GuiFluidIO extends GuiUpgradeable {
private final FCSharedFluidBus bus;
public GuiFluidIO(InventoryPlayer inventoryPlayer, FCSharedFluidBus te) {
super(new ContainerFluidIO(inventoryPlayer, te));
this.bus = te;
}
@Override
protected GuiText getName()
{
protected GuiText getName() {
return this.bus instanceof PartFluidImportBus ? GuiText.ImportBus : GuiText.ExportBus;
}
public void update(int id, IAEFluidStack stack) {
((ContainerFluidIO)this.cvb).getBus().setFluidInSlot(id, stack);
((ContainerFluidIO) this.cvb).getBus().setFluidInSlot(id, stack);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName(I18n.format(this.bus instanceof PartFluidImportBus ? NameConst.GUI_FLUID_IMPORT : NameConst.GUI_FLUID_EXPORT)), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
this.getGuiDisplayName(
I18n.format(
this.bus instanceof PartFluidImportBus ? NameConst.GUI_FLUID_IMPORT
: NameConst.GUI_FLUID_EXPORT)),
8,
6,
4210752);
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
if( this.redstoneMode != null )
{
this.redstoneMode.set( this.cvb.getRedStoneMode() );
if (this.redstoneMode != null) {
this.redstoneMode.set(this.cvb.getRedStoneMode());
}
if( this.fuzzyMode != null )
{
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
if (this.fuzzyMode != null) {
this.fuzzyMode.set(this.cvb.getFuzzyMode());
}
if( this.craftMode != null )
{
this.craftMode.set( this.cvb.getCraftingMode() );
if (this.craftMode != null) {
this.craftMode.set(this.cvb.getCraftingMode());
}
if( this.schedulingMode != null )
{
this.schedulingMode.set( this.cvb.getSchedulingMode() );
if (this.schedulingMode != null) {
this.schedulingMode.set(this.cvb.getSchedulingMode());
}
}
@Override
protected void handleButtonVisibility() {
super.handleButtonVisibility();
if (this.schedulingMode != null) {
this.schedulingMode.setVisibility(
this.bc.getInstalledUpgrades(Upgrades.CAPACITY) > 0 && this.bc instanceof PartFluidExportBus);
}
}
}
@@ -1,60 +1,81 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
public class GuiFluidInterface extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/interface_fluid.png");
private static final int TANK_X = 35, TANK_X_OFF = 18, TANK_Y = 53;
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 68;
private final ContainerFluidInterface cont;
private GuiTabButton switcher;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiFluidInterface(InventoryPlayer ipl, TileFluidInterface tile) {
public GuiFluidInterface(InventoryPlayer ipl, IDualHost tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
this.addMouseRegin();
}
public GuiFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
private void addMouseRegin() {
for (int i = 0; i < 6; i++) {
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
}
}
@Override
public void func_146977_a(final Slot s) {
try {
GuiContainer.class.getDeclaredMethod("func_146977_a_original", Slot.class).invoke(this, s);
} catch (final Exception ignore) {}
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
public void initGui() {
super.initGui();
this.switcher = new GuiTabButton( this.guiLeft + 154, this.guiTop, isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
this.switcher = new GuiTabButton(
this.guiLeft + 154,
this.guiTop,
isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(),
StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"),
itemRender);
this.buttonList.add(this.switcher);
}
@Override
@@ -63,22 +84,23 @@ public class GuiFluidInterface extends AEBaseGui {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv;
if (isPart()) {
fluidInv = ((PartFluidInterface) cont.getTile()).getInternalFluid();
} else {
fluidInv = ((TileFluidInterface) cont.getTile()).getInternalFluid();
}
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 6; i++) {
if (!isPart()) {
fontRendererObj.drawString(dirName(i), TANK_X + i * TANK_X_OFF + 5, 22, 0x404040);
}
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public String dirName(int face) {
@@ -91,55 +113,23 @@ public class GuiFluidInterface extends AEBaseGui {
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
public void renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
@Override
protected void actionPerformed( final GuiButton btn )
{
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE));
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE);
}
}
public void update(int id, IAEFluidStack stack) {
if (id >= 100) {
id -= 100;
if (isPart()) {
((PartFluidInterface) cont.getTile()).setConfig(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setConfig(id, stack);
}
}
else {
if(isPart()) {
((PartFluidInterface) cont.getTile()).setFluidInv(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setFluidInv(id, stack);
}
cont.getTile().setConfig(id - 100, stack);
} else {
cont.getTile().setFluidInv(id, stack);
}
}
private boolean isPart() {
return this.cont.getTile() instanceof PartFluidInterface;
}
}
@@ -0,0 +1,211 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.network.CPacketValueConfig;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.render.AppEngRenderItem;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
public class GuiFluidLevelEmitter extends GuiUpgradeable {
private GuiNumberBox level;
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private boolean isMul = false;
public GuiFluidLevelEmitter(final InventoryPlayer inventoryPlayer, final PartFluidLevelEmitter te) {
super(new ContainerFluidLevelEmitter(inventoryPlayer, te));
}
@Override
public void initGui() {
super.initGui();
this.level = new GuiNumberBox(this.fontRendererObj, 24, 43, 79, this.fontRendererObj.FONT_HEIGHT, Long.class);
this.level.setEnableBackgroundDrawing(false);
this.level.setMaxStringLength(16);
this.level.setTextColor(GuiColors.LevelEmitterValue.getColor());
this.level.setVisible(true);
this.level.setFocused(true);
((ContainerFluidLevelEmitter) this.inventorySlots).setTextField(this.level);
}
@Override
protected void addButtons() {
this.redstoneMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 8,
Settings.REDSTONE_EMITTER,
RedstoneMode.LOW_SIGNAL);
final int a = AEConfig.instance.levelByStackAmounts(0);
final int b = AEConfig.instance.levelByStackAmounts(1);
final int c = AEConfig.instance.levelByStackAmounts(2);
final int d = AEConfig.instance.levelByStackAmounts(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d));
this.buttonList.add(this.redstoneMode);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
getGuiDisplayName(NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER)),
8,
6,
GuiColors.UpgradableTitle.getColor());
this.fontRendererObj.drawString(
GuiText.inventory.getLocal(),
8,
this.ySize - 96 + 3,
GuiColors.UpgradableInventory.getColor());
this.redstoneMode.set(this.cvb.getRedStoneMode());
this.level.drawTextBox();
if (isShiftKeyDown() && !isMul) {
for (Object btn : this.buttonList) {
if (btn instanceof GuiButton) {
((GuiButton) btn).displayString += "000";
}
}
isMul = true;
} else if (!isShiftKeyDown() && isMul) {
for (Object btn : this.buttonList) {
if (btn instanceof GuiButton) {
((GuiButton) btn).displayString = ((GuiButton) btn).displayString
.substring(0, ((GuiButton) btn).displayString.lastIndexOf("000"));
}
}
isMul = false;
}
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
}
@Override
protected void handleButtonVisibility() {}
@Override
protected String getBackground() {
return "guis/lvlemitter.png";
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10
|| btn == this.minus100
|| btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
private void addQty(final long i) {
try {
String Out = this.level.getText();
boolean Fixed = false;
while (Out.startsWith("0") && Out.length() > 1) {
Out = Out.substring(1);
Fixed = true;
}
if (Fixed) {
this.level.setText(Out);
}
if (Out.isEmpty()) {
Out = "0";
}
long result = Long.parseLong(Out);
result += i;
if (result < 0) {
result = 0;
}
this.level.setText(Out = Long.toString(result));
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(result, 0));
} catch (final NumberFormatException e) {
this.level.setText("0");
}
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if ((key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit(character))
&& this.level.textboxKeyTyped(character, key)) {
try {
String Out = this.level.getText();
boolean Fixed = false;
while (Out.startsWith("0") && Out.length() > 1) {
Out = Out.substring(1);
Fixed = true;
}
if (Fixed) {
this.level.setText(Out);
}
if (Out.isEmpty()) {
Out = "0";
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(Long.parseLong(Out), 0));
} catch (final NumberFormatException e) {
AELog.debug(e);
}
} else {
super.keyTyped(character, key);
}
}
}
@Override
protected boolean drawUpgrades() {
return false;
}
public void update(Integer key, IAEFluidStack value) {
((ContainerFluidLevelEmitter) this.cvb).getBus().setFluidInSlot(key, value);
}
}
@@ -0,0 +1,62 @@
package com.glodblock.github.client.gui;
import java.util.List;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.base.FCGuiMonitor;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
import com.glodblock.github.client.me.FluidRepo;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.util.Util;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.localization.GuiText;
import appeng.util.item.AEItemStack;
public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
public GuiFluidMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te,
final ContainerFluidMonitor c) {
super(inventoryPlayer, te, c);
this.repo = new FluidRepo(getScrollBar(), this);
this.setScrollBar();
}
@Override
public void postUpdate(final List<IAEFluidStack> list, boolean resort) {
for (final IAEFluidStack is : list) {
IAEItemStack stack = AEItemStack.create(ItemFluidDrop.newDisplayStack(is.getFluidStack()));
stack.setStackSize(is.getStackSize());
this.repo.postUpdate(stack);
}
if (resort) {
this.repo.updateView();
}
this.setScrollBar();
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.Terminal.getLocal()), 8, 6, 4210752);
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
protected IAEItemStack transformItem(IAEItemStack stack) {
if (stack.getItem() instanceof ItemFluidDrop) {
return ItemFluidDrop.newAeStack(ItemFluidDrop.getAeFluidStack(stack));
}
return stack;
}
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
if (Util.getFluidFromItem(stack) != null) {
setSearchString(Util.getFluidFromItem(stack).getLocalizedName(), true);
}
}
}
@@ -1,14 +1,16 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidPacketDecoder;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiFluidPacketDecoder extends AEBaseGui {
@@ -29,5 +31,4 @@ public class GuiFluidPacketDecoder extends AEBaseGui {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_PACKET_DECODER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
}
@@ -1,19 +1,9 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.render.AppEngRenderItem;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.SlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
@@ -23,9 +13,21 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.ISlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.render.AppEngRenderItem;
import appeng.core.localization.GuiText;
public class GuiFluidPatternEncoder extends AEBaseGui {
@@ -37,8 +39,9 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
super(new ContainerFluidPatternEncoder(ipl, tile));
this.cont = (ContainerFluidPatternEncoder)inventorySlots;
this.cont = (ContainerFluidPatternEncoder) inventorySlots;
mouseRegions.addRegion(141, 38, 10, 10, new MouseRegionManager.Handler() {
@Override
public List<String> getTooltip() {
return Collections.singletonList(I18n.format(NameConst.TT_ENCODE_PATTERN));
@@ -78,14 +81,13 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
}
@Override
public void func_146977_a( final Slot s )
{
this.drawSlot0( s );
public void func_146977_a(final Slot s) {
this.drawSlot0(s);
}
public void drawSlot0(Slot slot) {
if (slot instanceof SlotFluid) {
IAEItemStack stack = ((SlotFluid)slot).getAeStack();
if (slot instanceof ISlotFluid) {
IAEItemStack stack = ((ISlotFluid) slot).getAeStack();
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return;
IAEItemStack fake = stack.copy();
@@ -94,42 +96,42 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
}
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
} else {
super.func_146977_a(slot);
}
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
protected void renderToolTip(ItemStack stack, int x, int y) {
@SuppressWarnings({ "unchecked", "rawtypes" })
public void renderToolTip(ItemStack stack, int x, int y) {
List list;
if (stack.getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
if (fluid != null) {
list = Arrays.asList(fluid.getLocalizedName(), String.format(EnumChatFormatting.GRAY + "%,d mB", fluid.amount));
}
else {
list = Arrays.asList(
fluid.getLocalizedName(),
String.format(EnumChatFormatting.GRAY + "%,d mB", fluid.amount));
} else {
list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
}
}
else {
} else {
list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
}
for (int k = 0; k < list.size(); ++k)
{
if (k == 0)
{
list.set(k, stack.getRarity().rarityColor + (String)list.get(k));
}
else
{
list.set(k, EnumChatFormatting.GRAY + (String)list.get(k));
for (int k = 0; k < list.size(); ++k) {
if (k == 0) {
list.set(k, stack.getRarity().rarityColor + (String) list.get(k));
} else {
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
}
}
FontRenderer font = stack.getItem().getFontRenderer(stack);
drawHoveringText(list, x, y, (font == null ? fontRendererObj : font));
}
}
@@ -0,0 +1,24 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
public GuiFluidPatternExWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -1,75 +1,166 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.SlotFake;
import appeng.util.item.AEItemStack;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal {
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
private GuiTabButton craftingStatusBtn;
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.PatternBeSubstitution;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternTerm;
import appeng.core.localization.GuiText;
public GuiFluidPatternTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
ContainerFluidPatternTerminal container = new ContainerFluidPatternTerminal(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
this.container = container;
this.monitorableContainer = container;
this.configSrc = container.getConfigManager();
public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
}
public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternWireless(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
craftingStatusBtn = super.craftingStatusBtn;
this.tabCraftButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.crafting_table),
GuiText.CraftingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabCraftButton);
this.tabProcessButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.furnace),
GuiText.ProcessingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabProcessButton);
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 84,
this.guiTop + this.ySize - 163,
Settings.ACTIONS,
ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 84,
this.guiTop + this.ySize - 163,
Settings.ACTIONS,
ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.clearBtn = new GuiImgButton(
this.guiLeft + 74,
this.guiTop + this.ySize - 163,
Settings.ACTIONS,
ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
this.encodeBtn = new GuiImgButton(
this.guiLeft + 147,
this.guiTop + this.ySize - 142,
Settings.ACTIONS,
ActionItems.ENCODE);
this.buttonList.add(this.encodeBtn);
int combineLeft = 74;
int combineTop = 153;
if (ModAndClassUtil.isDoubleButton) {
this.doubleBtn = new GuiImgButton(
this.guiLeft + 74,
this.guiTop + this.ySize - 153,
Settings.ACTIONS,
ActionItems.DOUBLE);
this.doubleBtn.setHalfSize(true);
this.buttonList.add(this.doubleBtn);
combineLeft = 84;
}
if (ModAndClassUtil.isBeSubstitutionsButton) {
combineLeft = 74;
combineTop -= 11;
this.beSubstitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 84,
this.guiTop + this.ySize - 153,
Settings.ACTIONS,
PatternBeSubstitution.ENABLED);
this.beSubstitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.beSubstitutionsEnabledBtn);
this.beSubstitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 84,
this.guiTop + this.ySize - 153,
Settings.ACTIONS,
PatternBeSubstitution.DISABLED);
this.beSubstitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.beSubstitutionsDisabledBtn);
}
this.combineEnableBtn = new GuiFCImgButton(
this.guiLeft + combineLeft,
this.guiTop + this.ySize - combineTop,
"FORCE_COMBINE",
"DO_COMBINE");
this.combineEnableBtn.setHalfSize(true);
this.buttonList.add(this.combineEnableBtn);
this.combineDisableBtn = new GuiFCImgButton(
this.guiLeft + combineLeft,
this.guiTop + this.ySize - combineTop,
"NOT_COMBINE",
"DONT_COMBINE");
this.combineDisableBtn.setHalfSize(true);
this.buttonList.add(this.combineDisableBtn);
}
@Override
public void func_146977_a( final Slot s )
{
if (drawSlot0(s))
super.func_146977_a( s );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRendererObj.drawString(
StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL),
8,
this.ySize - 96 + 2 - getReservedSpace(),
4210752);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotFake && !this.container.isCraftingMode()) {
AEItemStack stack = AEItemStack.create(slot.getStack());
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return true;
IAEItemStack fake = stack.copy();
if (fake.getItemStack().getItem() instanceof ItemFluidPacket) {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (mouseButton == 3) {
if (this.container.isCraftingMode()
&& (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix
|| slot instanceof SlotPatternTerm)) {
return;
}
else
return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
return false;
}
return true;
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
protected String getBackground() {
if (this.container.isCraftingMode()) {
return "gui/pattern.png";
}
return "gui/pattern2.png";
}
}
@@ -1,48 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
private GuiTabButton originalGuiBtn;
private final ITerminalHost host;
public GuiFluidPatternTerminalCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
host = te;
}
@Override
public void initGui() {
if (host instanceof PartFluidPatternTerminal)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == originalGuiBtn) {
if (host instanceof PartFluidPatternTerminal)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
} else {
super.actionPerformed(btn);
}
}
}
@@ -1,75 +1,226 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.SlotFake;
import appeng.util.item.AEItemStack;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.util.StatCollector;
public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
import org.lwjgl.input.Mouse;
private GuiTabButton craftingStatusBtn;
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternExWireless;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
public GuiFluidPatternTerminalEx(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
ContainerFluidPatternTerminalEx container = new ContainerFluidPatternTerminalEx(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
this.container = container;
this.monitorableContainer = container;
this.configSrc = container.getConfigManager();
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.PatternBeSubstitution;
import appeng.api.config.PatternSlotConfig;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerFluidPatternTerminalEx(inventoryPlayer, te));
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternExWireless(inventoryPlayer, te));
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
craftingStatusBtn = super.craftingStatusBtn;
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 97,
this.guiTop + this.ySize - 163,
Settings.ACTIONS,
ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 97,
this.guiTop + this.ySize - 163,
Settings.ACTIONS,
ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.fluidPrioritizedEnabledBtn = new GuiFCImgButton(
this.guiLeft + 97,
this.guiTop + this.ySize - 114,
"FORCE_PRIO",
"DO_PRIO");
this.fluidPrioritizedEnabledBtn.setHalfSize(true);
this.buttonList.add(this.fluidPrioritizedEnabledBtn);
this.fluidPrioritizedDisabledBtn = new GuiFCImgButton(
this.guiLeft + 97,
this.guiTop + this.ySize - 114,
"NOT_PRIO",
"DONT_PRIO");
this.fluidPrioritizedDisabledBtn.setHalfSize(true);
this.buttonList.add(this.fluidPrioritizedDisabledBtn);
invertBtn = new GuiImgButton(
this.guiLeft + 87,
this.guiTop + this.ySize - 153,
Settings.ACTIONS,
container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4);
invertBtn.setHalfSize(true);
this.buttonList.add(this.invertBtn);
this.clearBtn = new GuiImgButton(
this.guiLeft + 87,
this.guiTop + this.ySize - 163,
Settings.ACTIONS,
ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
this.encodeBtn = new GuiImgButton(
this.guiLeft + 147,
this.guiTop + this.ySize - 142,
Settings.ACTIONS,
ActionItems.ENCODE);
this.buttonList.add(this.encodeBtn);
if (ModAndClassUtil.isDoubleButton) {
this.doubleBtn = new GuiImgButton(
this.guiLeft + 97,
this.guiTop + this.ySize - 153,
Settings.ACTIONS,
ActionItems.DOUBLE);
this.doubleBtn.setHalfSize(true);
this.buttonList.add(this.doubleBtn);
}
this.combineEnableBtn = new GuiFCImgButton(
this.guiLeft + 87,
this.guiTop + this.ySize - 114,
"FORCE_COMBINE",
"DO_COMBINE");
this.combineEnableBtn.setHalfSize(true);
this.buttonList.add(this.combineEnableBtn);
this.combineDisableBtn = new GuiFCImgButton(
this.guiLeft + 87,
this.guiTop + this.ySize - 114,
"NOT_COMBINE",
"DONT_COMBINE");
this.combineDisableBtn.setHalfSize(true);
this.buttonList.add(this.combineDisableBtn);
if (ModAndClassUtil.isBeSubstitutionsButton) {
this.beSubstitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 87,
this.guiTop + this.ySize - 103,
Settings.ACTIONS,
PatternBeSubstitution.ENABLED);
this.beSubstitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.beSubstitutionsEnabledBtn);
this.beSubstitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 87,
this.guiTop + this.ySize - 103,
Settings.ACTIONS,
PatternBeSubstitution.DISABLED);
this.beSubstitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.beSubstitutionsDisabledBtn);
}
processingScrollBar.setTop(this.ySize - 164);
}
@Override
public void func_146977_a( final Slot s )
{
if (drawSlot0(s))
super.func_146977_a( s );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRendererObj.drawString(
StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX),
8,
this.ySize - 96 + 2 - getReservedSpace(),
4210752);
this.processingScrollBar.draw(this);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotFake) {
AEItemStack stack = AEItemStack.create(slot.getStack());
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return true;
IAEItemStack fake = stack.copy();
if (fake.getItemStack().getItem() instanceof ItemFluidPacket) {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
@Override
protected String getBackground() {
return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png";
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
final int offset = container.inverted ? 18 * -3 : 0;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
beSubstitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
beSubstitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedEnabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedDisabledBtn.xPosition = this.guiLeft + 97 + offset;
doubleBtn.xPosition = this.guiLeft + 97 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
invertBtn.xPosition = this.guiLeft + 87 + offset;
combineEnableBtn.xPosition = this.guiLeft + 87 + offset;
combineDisableBtn.xPosition = this.guiLeft + 87 + offset;
processingScrollBar.setCurrentScroll(container.activePage);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
super.mouseClicked(xCoord, yCoord, btn);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
protected void mouseClickMove(final int x, final int y, final int c, final long d) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop);
super.mouseClickMove(x, y, c, d);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
public void handleMouseInput() {
super.handleMouseInput();
final int wheel = Mouse.getEventDWheel();
if (wheel != 0) {
final int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight;
if (this.processingScrollBar.contains(x - this.guiLeft, y - this.guiTop)) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.wheel(wheel);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
else
return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
return false;
}
return true;
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
private void changeActivePage() {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.ActivePage",
String.valueOf(this.processingScrollBar.getCurrentScroll())));
}
}
@@ -0,0 +1,24 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
public GuiFluidPatternWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -0,0 +1,30 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.client.gui.container.ContainerFluidPortableCell;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.container.slot.AppEngSlot;
public class GuiFluidPortableCell extends GuiFluidTerminal {
public GuiFluidPortableCell(final InventoryPlayer inventoryPlayer, final IFluidPortableCell te) {
super(inventoryPlayer, te, new ContainerFluidPortableCell(inventoryPlayer, te));
}
@Override
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected int getMaxRows() {
if (this.container.getHost() instanceof IWirelessTerminal) {
return super.getMaxRows();
} else {
return 3;
}
}
}
@@ -0,0 +1,105 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.NameConst;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
public class GuiFluidStorageBus extends GuiUpgradeable {
private GuiImgButton rwMode;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
public GuiFluidStorageBus(InventoryPlayer inventoryPlayer, PartFluidStorageBus te) {
super(new ContainerFluidStorageBus(inventoryPlayer, te));
this.ySize = 251;
}
@Override
@SuppressWarnings("unchecked")
protected void addButtons() {
this.clear = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE);
this.partition = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH);
this.rwMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 48,
Settings.ACCESS,
AccessRestriction.READ_WRITE);
this.priority = new GuiTabButton(
this.guiLeft + 154,
this.guiTop,
2 + 4 * 16,
GuiText.Priority.getLocal(),
itemRender);
this.buttonList.add(this.priority);
this.buttonList.add(this.rwMode);
this.buttonList.add(this.partition);
this.buttonList.add(this.clear);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
this.getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_STORAGE_BUS)),
8,
6,
GuiColors.StorageBusTitle.getColor());
this.fontRendererObj.drawString(
GuiText.inventory.getLocal(),
8,
this.ySize - 96 + 3,
GuiColors.StorageBusInventory.getColor());
if (this.rwMode != null) {
this.rwMode.set(((ContainerFluidStorageBus) this.cvb).getReadWriteMode());
}
}
@Override
protected String getBackground() {
return "guis/storagebus.png";
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == this.partition) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Partition"));
} else if (btn == this.clear) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
InventoryHandler.switchGui(GuiType.PRIORITY);
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
}
public void update(int id, IAEFluidStack stack) {
((ContainerFluidStorageBus) this.cvb).bus.setFluidInSlot(id, stack);
}
}
@@ -0,0 +1,142 @@
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;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.AppEngSlot;
public class GuiFluidTerminal extends GuiFluidMonitor {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
protected EntityPlayer player;
public ContainerFluidMonitor container;
public GuiFluidTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te, new ContainerFluidMonitor(inventoryPlayer, te));
this.container = new ContainerFluidMonitor(inventoryPlayer, te);
this.player = inventoryPlayer.player;
this.showViewBtn = false;
}
public GuiFluidTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te,
final ContainerFluidMonitor c) {
super(inventoryPlayer, te, c);
this.container = c;
this.player = inventoryPlayer.player;
this.showViewBtn = false;
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
@Override
public void func_146977_a(final Slot s) {
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotME) {
IAEItemStack stack = ((SlotME) slot).getAEStack();
if (stack == null) return true;
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid());
stackSizeRenderer.setAeStack(stack);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
}
private void drawWidget(int posX, int posY, Fluid fluid) {
if (fluid == null) return;
IIcon icon = fluid.getIcon();
if (icon == null) return;
if (ModAndClassUtil.HODGEPODGE && icon instanceof IPatchedTextureAtlasSprite) {
((IPatchedTextureAtlasSprite) icon).markNeedsAnimationUpdate();
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor3f(
(fluid.getColor() >> 16 & 0xFF) / 255.0F,
(fluid.getColor() >> 8 & 0xFF) / 255.0F,
(fluid.getColor() & 0xFF) / 255.0F);
drawTexturedModelRectFromIcon(posX, posY, fluid.getIcon(), 16, 16);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor3f(1, 1, 1);
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotME && Util.FluidUtil.isFluidContainer(player.inventory.getItemStack())) {
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
ItemStack itemStack = this.player.inventory.getItemStack().copy();
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
if (!isShiftKeyDown()) {
itemStack.stackSize = 1;
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
public void update(ItemStack itemStack) {
this.player.inventory.setItemStack(itemStack);
}
}
@@ -1,8 +1,13 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerIngredientBuffer;
import com.glodblock.github.common.tile.TileIngredientBuffer;
@@ -11,16 +16,11 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.util.RenderUtil;
import javax.annotation.Nullable;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiIngredientBuffer extends AEBaseGui {
@@ -36,10 +36,18 @@ public class GuiIngredientBuffer extends AEBaseGui {
this.cont = (ContainerIngredientBuffer) inventorySlots;
this.ySize = 222;
for (int i = 0; i < 4; i++) {
mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7,
ButtonMouseHandler.dumpTank(cont, i));
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i,
TANK_Y + TANK_HEIGHT + 2,
7,
7,
ButtonMouseHandler.dumpTank(cont, i));
}
}
@@ -62,38 +70,23 @@ public class GuiIngredientBuffer extends AEBaseGui {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 4; i++) {
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -0,0 +1,769 @@
package com.glodblock.github.client.gui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCBaseMEGui;
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketRenamer;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import com.google.common.collect.HashMultimap;
import appeng.api.AEApi;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.util.WorldCoord;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.client.render.BlockPosHighlighter;
import appeng.container.slot.AppEngSlot;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.PatternHelper;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.Platform;
public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillTextField {
protected int offsetY;
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
private static final int offsetX = 21;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, Util.DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
protected static String searchFieldOutputsText = "";
protected static String searchFieldInputsText = "";
protected static String searchFieldNamesText = "";
private final MEGuiTextField searchFieldOutputs;
private final MEGuiTextField searchFieldInputs;
private final MEGuiTextField searchFieldNames;
private final GuiImgButton guiButtonHideFull;
private final GuiImgButton guiButtonAssemblersOnly;
private final GuiImgButton guiButtonBrokenRecipes;
private GuiImgButton searchStringSave;
private GuiImgButton terminalStyleBox;
private boolean refreshList = false;
protected static boolean onlyMolecularAssemblers = false;
protected static boolean onlyBrokenRecipes = false;
protected GuiTabButton craftingStatusBtn;
private int rows = 3;
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
public GuiInterfaceWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));
this.setScrollBar(new GuiScrollbar());
this.xSize = 208;
this.ySize = 255;
searchFieldInputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldOutputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames = new MEGuiTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames.setFocused(true);
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
}
@Override
public int getOffsetY() {
return this.offsetY;
}
@Override
public void setOffsetY(int y) {
this.offsetY = y;
}
private void setScrollBar() {
this.getScrollBar().setTop(52).setLeft(189).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, this.lines.size() - this.rows, 2);
}
@Override
public void initGui() {
super.initGui();
this.rows = calculateRowsCount();
this.ySize = MAGIC_HEIGHT_NUMBER + this.rows * 18;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
this.offsetY = this.guiTop + 8;
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
this.offsetY += 20;
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SAVE_SEARCH,
AEConfig.instance.settings.getSetting(Settings.SAVE_SEARCH)));
this.offsetY += 20;
searchFieldInputs.x = guiLeft + Math.max(32, offsetX);
searchFieldInputs.y = guiTop + 25;
searchFieldOutputs.x = guiLeft + Math.max(32, offsetX);
searchFieldOutputs.y = guiTop + 38;
searchFieldNames.x = guiLeft + Math.max(32, offsetX) + 99;
searchFieldNames.y = guiTop + 38;
guiButtonAssemblersOnly.xPosition = guiLeft + Math.max(32, offsetX) + 99;
guiButtonAssemblersOnly.yPosition = guiTop + 20;
guiButtonHideFull.xPosition = guiButtonAssemblersOnly.xPosition + 18;
guiButtonHideFull.yPosition = guiTop + 20;
guiButtonBrokenRecipes.xPosition = guiButtonHideFull.xPosition + 18;
guiButtonBrokenRecipes.yPosition = guiTop + 20;
terminalStyleBox.xPosition = guiLeft - 18;
terminalStyleBox.yPosition = guiTop + 8;
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + this.xSize - 24,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString();
}
this.setScrollBar();
this.repositionSlots();
this.initGuiDone();
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
searchFieldOutputsText = this.searchFieldOutputs.getText();
searchFieldInputsText = this.searchFieldInputs.getText();
searchFieldNamesText = this.searchFieldNames.getText();
}
public void setSearchString() {
this.searchFieldOutputs.setText(searchFieldOutputsText);
this.searchFieldInputs.setText(searchFieldInputsText);
this.searchFieldNames.setText(searchFieldNamesText);
}
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof final AppEngSlot slot) {
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
}
}
}
protected int calculateRowsCount() {
final int maxRows = this.getMaxRows();
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int input = 22;
final int topPanel = 18;
final int NEIPadding = hasNEI ? input + topPanel : 0;
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - NEIPadding;
return Math.max(3, Math.min(maxRows, extraSpace / 18));
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
fontRendererObj.drawString(
getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()),
8,
6,
GuiColors.InterfaceTerminalTitle.getColor());
fontRendererObj.drawString(
GuiText.inventory.getLocal(),
GuiInterfaceWireless.offsetX + 2,
this.ySize - 96,
GuiColors.InterfaceTerminalInventory.getColor());
int offset = 51;
final int ex = getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z))) drawRect(
z * 18 + 22,
1 + offset,
z * 18 + 22 + 16,
1 + offset + 16,
GuiColors.InterfaceTerminalMatch.getColor());
}
} else if (lineObj instanceof String name) {
final int rows = this.byName.get(name).size();
String postfix = "";
if (rows > 1) {
postfix = " (" + rows + ')';
}
while (name.length() > 2 && this.fontRendererObj.getStringWidth(name + postfix) > 158) {
name = name.substring(0, name.length() - 1);
}
this.fontRendererObj.drawString(
name + postfix,
GuiInterfaceWireless.offsetX + 3,
6 + offset,
GuiColors.InterfaceTerminalName.getColor());
}
offset += 18;
}
}
@SuppressWarnings("unchecked")
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
buttonList.clear();
inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
guiButtonAssemblersOnly.set(
onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLEERS_ON : ActionItems.MOLECULAR_ASSEMBLEERS_OFF);
guiButtonHideFull.set(
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF
: ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
guiButtonBrokenRecipes.set(
onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_OFF
: ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_ON);
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
buttonList.add(guiButtonAssemblersOnly);
buttonList.add(guiButtonHideFull);
buttonList.add(guiButtonBrokenRecipes);
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
this.guiButtonHashMap.clear();
addSwitchGuiBtns();
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 22, 1 + offset));
}
GuiButton guiButton = new GuiImgButton(
guiLeft + 4,
guiTop + offset + 1,
Settings.ACTIONS,
ActionItems.HIGHLIGHT_INTERFACE);
GuiFCImgButton editButton = new GuiFCImgButton(guiLeft + 4, guiTop + offset + 1, "EDIT", "YES");
guiButtonHashMap.put(guiButton, inv);
guiButtonHashMap.put(editButton, inv);
if (isShiftKeyDown()) {
buttonList.add(editButton);
} else {
buttonList.add(guiButton);
}
}
offset += 18;
}
super.drawScreen(mouseX, mouseY, btn);
handleTooltip(mouseX, mouseY, searchFieldInputs);
handleTooltip(mouseX, mouseY, searchFieldOutputs);
handleTooltip(mouseX, mouseY, searchFieldNames);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
boolean focusIn = searchFieldInputs.isFocused();
boolean focusOut = searchFieldOutputs.isFocused();
boolean focusName = searchFieldNames.isFocused();
searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
searchFieldOutputs.mouseClicked(xCoord, yCoord, btn);
searchFieldNames.mouseClicked(xCoord, yCoord, btn);
if (focusIn && !searchFieldInputs.isFocused()) {
searchFieldInputsText = searchFieldInputs.getText();
} else if (focusOut && !searchFieldOutputs.isFocused()) {
searchFieldOutputsText = searchFieldOutputs.getText();
} else if (focusName && !searchFieldNames.isFocused()) {
searchFieldNamesText = searchFieldNames.getText();
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (guiButtonHashMap.containsKey(btn)) {
Util.DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
if (btn instanceof GuiFCImgButton) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketRenamer(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
blockPos.getSide()));
} else {
WorldCoord blockPos2 = new WorldCoord(
(int) mc.thePlayer.posX,
(int) mc.thePlayer.posY,
(int) mc.thePlayer.posZ);
if (mc.theWorld.provider.dimensionId != blockPos.getDimension()) {
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceInOtherDim.getName(),
blockPos.getDimension()));
} else {
BlockPosHighlighter.highlightBlock(
blockPos,
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceHighlighted.getName(),
blockPos.x,
blockPos.y,
blockPos.z));
}
mc.thePlayer.closeScreen();
}
} else if (btn == guiButtonHideFull) {
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal = !AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal;
this.refreshList();
} else if (btn == guiButtonAssemblersOnly) {
onlyMolecularAssemblers = !onlyMolecularAssemblers;
this.refreshList();
} else if (btn == guiButtonBrokenRecipes) {
onlyBrokenRecipes = !onlyBrokenRecipes;
this.refreshList();
} else if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
AEConfig.instance.settings.putSetting(Settings.SAVE_SEARCH, next);
this.searchStringSave.set(next);
} else if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else if (btn instanceof final GuiImgButton iBtn) {
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final boolean backwards = Mouse.isButtonDown(1);
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
this.reinitialize();
}
iBtn.set(next);
}
}
super.actionPerformed(btn);
}
private void reinitialize() {
this.buttonList.clear();
this.initGui();
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/newinterfaceterminal.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 53);
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 53 + x * 18, 0, 52, this.xSize, 18);
}
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
GL11.glColor4f(1, 1, 1, 1);
final int width = inv.getInventory().getSizeInventory() * 18;
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18);
}
offset += 18;
}
this.drawTexturedModalRect(offsetX, offsetY + 50 + this.rows * 18, 0, 158, this.xSize, 99);
searchFieldInputs.drawTextBox();
searchFieldOutputs.drawTextBox();
searchFieldNames.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) {
if (!checkHotbarKeys(key)) {
if (character == ' ') {
if ((searchFieldInputs.getText().isEmpty() && searchFieldInputs.isFocused())
|| (searchFieldOutputs.getText().isEmpty() && searchFieldOutputs.isFocused())
|| (searchFieldNames.getText().isEmpty() && searchFieldNames.isFocused()))
return;
} else if (character == '\t') {
if (handleTab()) return;
}
if (searchFieldInputs.textboxKeyTyped(character, key) || searchFieldOutputs.textboxKeyTyped(character, key)
|| searchFieldNames.textboxKeyTyped(character, key)) {
refreshList();
} else {
super.keyTyped(character, key);
}
}
}
private boolean handleTab() {
if (searchFieldInputs.isFocused()) {
searchFieldInputs.setFocused(false);
if (isShiftKeyDown()) searchFieldNames.setFocused(true);
else searchFieldOutputs.setFocused(true);
return true;
} else if (searchFieldOutputs.isFocused()) {
searchFieldOutputs.setFocused(false);
if (isShiftKeyDown()) searchFieldInputs.setFocused(true);
else searchFieldNames.setFocused(true);
return true;
} else if (searchFieldNames.isFocused()) {
searchFieldNames.setFocused(false);
if (isShiftKeyDown()) searchFieldOutputs.setFocused(true);
else searchFieldInputs.setFocused(true);
return true;
}
return false;
}
public void postUpdate(final NBTTagCompound in) {
if (in.getBoolean("clear")) {
this.byId.clear();
this.refreshList = true;
}
for (final Object oKey : in.func_150296_c()) {
final String key = (String) oKey;
if (key.startsWith("=")) {
try {
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
final NBTTagCompound invData = in.getCompoundTag(key);
int size = invData.getInteger("size");
final ClientDCInternalInv current = this
.getById(id, invData.getLong("sortBy"), invData.getString("un"), size);
int X = invData.getInteger("x");
int Y = invData.getInteger("y");
int Z = invData.getInteger("z");
int dim = invData.getInteger("dim");
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
blockPosHashMap.put(
current,
new Util.DimensionalCoordSide(X, Y, Z, dim, side, current.getUnlocalizedName()));
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
final String which = Integer.toString(x);
if (invData.hasKey(which)) {
current.getInventory().setInventorySlotContents(
x,
ItemStack.loadItemStackFromNBT(invData.getCompoundTag(which)));
}
}
} catch (final NumberFormatException ignored) {}
}
}
if (this.refreshList) {
this.refreshList = false;
// invalidate caches on refresh
this.cachedSearches.clear();
this.refreshList();
}
}
/**
* Rebuilds the list of interfaces.
* <p>
* Respects a search term if present (ignores case) and adding only matching patterns.
*/
private void refreshList() {
this.byName.clear();
this.buttonList.clear();
this.matchedStacks.clear();
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
final String searchFieldNames = this.searchFieldNames.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm(
"IN:" + searchFieldInputs
+ "OUT:"
+ searchFieldOutputs
+ "NAME:"
+ searchFieldNames
+ AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
+ onlyMolecularAssemblers
+ onlyBrokenRecipes);
final boolean rebuild = cachedSearch.isEmpty();
for (final ClientDCInternalInv entry : this.byId.values()) {
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
if (!rebuild && !cachedSearch.contains(entry)) {
continue;
}
// Shortcut to skip any filter if search term is ""/empty
boolean found = searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty();
boolean interfaceHasFreeSlots = false;
boolean interfaceHasBrokenRecipes = false;
// Search if the current inventory holds a pattern containing the search term.
if (!found || AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || onlyBrokenRecipes) {
for (final ItemStack itemStack : entry.getInventory()) {
// If only Interfaces with empty slots should be shown, check that here
if (itemStack == null) {
interfaceHasFreeSlots = true;
continue;
}
if (onlyBrokenRecipes && recipeIsBroken(itemStack)) {
interfaceHasBrokenRecipes = true;
}
if ((!searchFieldInputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0))
|| (!searchFieldOutputs.isEmpty()
&& itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1))) {
found = true;
matchedStacks.add(itemStack);
}
}
}
if ((found && entry.getName().toLowerCase().contains(searchFieldNames))
&& (!onlyMolecularAssemblers || entry.getUnlocalizedName().contains(MOLECULAR_ASSEMBLER))
&& (!AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || interfaceHasFreeSlots)
&& (!onlyBrokenRecipes || interfaceHasBrokenRecipes)) {
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
} else {
cachedSearch.remove(entry);
}
}
this.names.clear();
this.names.addAll(this.byName.keySet());
Collections.sort(this.names);
this.lines.clear();
this.lines.ensureCapacity(this.names.size() + this.byId.size());
for (final String n : this.names) {
this.lines.add(n);
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
Collections.sort(clientInventories);
this.lines.addAll(clientInventories);
}
this.setScrollBar();
}
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm, int pass) {
if (itemStack == null) {
return false;
}
final NBTTagCompound encodedValue = itemStack.getTagCompound();
if (encodedValue == null) {
return false;
}
final NBTTagList tags = encodedValue.getTagList(pass == 0 ? "in" : "out", 10);
final boolean containsInvalidDisplayName = GuiText.UnknownItem.getLocal().toLowerCase().contains(searchTerm);
for (int i = 0; i < tags.tagCount(); i++) {
final NBTTagCompound tag = tags.getCompoundTagAt(i);
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT(tag);
if (parsedItemStack != null) {
final String displayName = Platform
.getItemDisplayName(AEApi.instance().storage().createItemStack(parsedItemStack)).toLowerCase();
if (displayName.contains(searchTerm)) {
return true;
}
} else if (containsInvalidDisplayName && !tag.hasNoTags()) {
return true;
}
}
return false;
}
private boolean recipeIsBroken(final ItemStack itemStack) {
if (itemStack == null) {
return false;
}
final NBTTagCompound encodedValue = itemStack.getTagCompound();
if (encodedValue == null) {
return true;
}
final World w = CommonHelper.proxy.getWorld();
if (w == null) {
return false;
}
try {
new PatternHelper(itemStack, w);
return false;
} catch (final Throwable t) {
return true;
}
}
/**
* Tries to retrieve a cache for a with search term as keyword.
* <p>
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
* the empty string.
*
* @param searchTerm the corresponding search
* @return a Set matching a superset of the search term
*/
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
if (!this.cachedSearches.containsKey(searchTerm)) {
this.cachedSearches.put(searchTerm, new HashSet<>());
}
final Set<Object> cache = this.cachedSearches.get(searchTerm);
if (cache.isEmpty() && searchTerm.length() > 1) {
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
return cache;
}
return cache;
}
private int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
? AEConfig.instance.InterfaceTerminalSmallSize
: Integer.MAX_VALUE;
}
private ClientDCInternalInv getById(final long id, final long sortBy, final String unlocalizedName,
final int sizeInit) {
ClientDCInternalInv o = this.byId.get(id);
if (o == null) {
this.byId.put(id, o = new ClientDCInternalInv(sizeInit, id, sortBy, unlocalizedName));
this.refreshList = true;
}
return o;
}
public boolean isOverTextField(final int mousex, final int mousey) {
return searchFieldInputs.isMouseIn(mousex, mousey) || searchFieldOutputs.isMouseIn(mousex, mousey)
|| searchFieldNames.isMouseIn(mousex, mousey);
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
if (searchFieldInputs.isMouseIn(mousex, mousey)) {
searchFieldInputs.setText(displayName);
} else if (searchFieldOutputs.isMouseIn(mousex, mousey)) {
searchFieldOutputs.setText(displayName);
} else if (searchFieldNames.isMouseIn(mousex, mousey)) {
searchFieldNames.setText(displayName);
}
}
}
@@ -0,0 +1,53 @@
package com.glodblock.github.client.gui;
import java.util.List;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.base.FCGuiMonitor;
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.ItemRepo;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
public class GuiItemMonitor extends FCGuiMonitor<IAEItemStack> {
public GuiItemMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerItemMonitor c) {
super(inventoryPlayer, te, c);
this.repo = new ItemRepo(getScrollBar(), this);
}
@Override
public void postUpdate(final List<IAEItemStack> list, boolean resort) {
for (final IAEItemStack is : list) {
this.repo.postUpdate(is);
}
if (resort) {
this.repo.updateView();
}
this.setScrollBar();
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.Terminal.getLocal()), 8, 6, 4210752);
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
setSearchString(displayName, true);
}
}
@@ -1,8 +1,13 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLargeIngredientBuffer;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
@@ -11,16 +16,11 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.util.RenderUtil;
import javax.annotation.Nullable;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiLargeIngredientBuffer extends AEBaseGui {
@@ -36,10 +36,18 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
this.cont = (ContainerLargeIngredientBuffer) inventorySlots;
this.ySize = 222;
for (int i = 0; i < 7; i++) {
mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7,
ButtonMouseHandler.dumpTank(cont, i));
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i,
TANK_Y + TANK_HEIGHT + 2,
7,
7,
ButtonMouseHandler.dumpTank(cont, i));
}
}
@@ -58,42 +66,28 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LARGE_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRendererObj
.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LARGE_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 7; i++) {
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -0,0 +1,554 @@
package com.glodblock.github.client.gui;
import static com.glodblock.github.client.gui.container.ContainerLevelMaintainer.createLevelValues;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketLevelMaintainer;
import com.glodblock.github.network.CPacketLevelMaintainer.Action;
import com.glodblock.github.network.CPacketLevelTerminalCommands;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.FCGuiColors;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.DimensionalCoord;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketNEIDragClick;
import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cofh.core.render.CoFHFontRenderer;
import cpw.mods.fml.common.Optional;
@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler")
public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_maintainer.png");
private final ContainerLevelMaintainer cont;
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private FCGuiTextField input;
private int lastWorkingTick;
private int refreshTick;
private final CoFHFontRenderer render;
protected ItemStack icon = null;
protected GuiType originalGui;
protected Util.DimensionalCoordSide originalBlockPos;
protected GuiTabButton originalGuiBtn;
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(new ContainerLevelMaintainer(ipl, tile));
this.cont = (ContainerLevelMaintainer) inventorySlots;
this.xSize = 195;
this.ySize = 214;
this.render = new CoFHFontRenderer(
Minecraft.getMinecraft().gameSettings,
TEX_BG,
Minecraft.getMinecraft().getTextureManager(),
true);
this.refreshTick = 0;
if (ipl.player.openContainer instanceof AEBaseContainer container) {
var target = container.getTarget();
if (target instanceof PartLevelTerminal terminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
DimensionalCoord blockPos = new DimensionalCoord(terminal.getTile());
originalBlockPos = new Util.DimensionalCoordSide(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
terminal.getSide(),
"");
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
ipl.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
ipl.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
}
}
}
public void postUpdate(List<IAEItemStack> list) {
for (Slot slot : this.cont.getRequestSlots()) {
if (!slot.getHasStack()) {
component[slot.getSlotIndex()].setState(State.None);
}
}
for (IAEItemStack is : list) {
NBTTagCompound data = is.getItemStack().getTagCompound();
long batch = data.getLong(TLMTags.Batch.tagName);
long quantity = data.getLong(TLMTags.Quantity.tagName);
int idx = data.getInteger(TLMTags.Index.tagName);
boolean isEnable = data.getBoolean(TLMTags.Enable.tagName);
State state = State.values()[data.getInteger(TLMTags.State.tagName)];
component[idx].getQty().textField.setText(String.valueOf(quantity));
component[idx].getBatch().textField.setText(String.valueOf(batch));
component[idx].setEnable(isEnable);
component[idx].setState(state);
}
}
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.lastWorkingTick = this.refreshTick;
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
component[i] = new Component(
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 46, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE,
i,
Action.Quantity),
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE,
i,
Action.Batch),
new GuiFCImgButton(guiLeft + 105 + 47, guiTop + 17 + 19 * i, "SUBMIT", "SUBMIT", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "ENABLE", "ENABLE", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "DISABLE", "DISABLE", false),
new FCGuiLineField(fontRendererObj, guiLeft + 47, guiTop + 33 + 19 * i, 125),
this.buttonList);
}
if (this.icon != null) {
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 151,
this.guiTop - 4,
this.icon,
this.icon.getDisplayName(),
itemRender);
this.originalGuiBtn.setHideEdge(13);
this.buttonList.add(originalGuiBtn);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
}
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
this.refreshTick++;
super.drawScreen(mouseX, mouseY, btn);
for (Component com : this.component) {
com.getQty().textField.handleTooltip(mouseX, mouseY, this);
com.getBatch().textField.handleTooltip(mouseX, mouseY, this);
com.getLine().handleTooltip(mouseX, mouseY, this);
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
int tick = this.refreshTick;
int interval = 20;
if (tick > lastWorkingTick + interval && this.input == null) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
lastWorkingTick = this.refreshTick;
}
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
this.component[i].draw();
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_LEVEL_MAINTAINER)), 8, 6, 0x404040);
mouseRegions.render(mouseX, mouseY);
}
@Override
public void func_146977_a(final Slot s) {
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotFake) {
IAEItemStack stack = ((SlotFluidConvertingFake) slot).getAeStack();
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return true;
IAEItemStack fake = stack.copy();
if (this.component[slot.getSlotIndex()].getQty().textField.getText().matches("[0-9]+")) {
fake.setStackSize(Long.parseLong(this.component[slot.getSlotIndex()].getQty().textField.getText()));
} else {
fake.setStackSize(0);
}
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
fake.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
if (btn == 0) {
if (input != null) {
input.setFocused(false);
}
for (Component com : this.component) {
FCGuiTextField textField = com.isMouseIn(xCoord, yCoord);
if (textField != null) {
textField.setFocused(true);
this.input = textField;
super.mouseClicked(xCoord, yCoord, btn);
return;
}
}
this.input = null;
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped(final char character, final int key) {
if (this.input == null) {
super.keyTyped(character, key);
return;
}
if (!this.checkHotbarKeys(key)) {
if (!((character == ' ') && this.input.getText().isEmpty())) {
this.input.textboxKeyTyped(character, key);
}
super.keyTyped(character, key);
if (!this.input.getText().matches("^[0-9]+")) {
this.input.setTextColor(0xFF0000);
} else {
this.input.setTextColor(0xFFFFFF);
}
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.input.setFocused(false);
this.input = null;
}
}
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotFluidConvertingFake && this.cont.getPlayerInv().getItemStack() != null) {
this.component[slot.getSlotIndex()].getQty().textField
.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize));
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
public void updateAmount(int idx, int stackSize) {
this.component[idx].getQty().textField.setText(String.valueOf(stackSize));
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == originalGuiBtn) {
switchGui();
} else {
super.actionPerformed(btn);
for (Component com : this.component) {
if (com.sendToServer(btn)) {
break;
}
}
}
}
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()));
// InventoryHandler.switchGui(originalGui);
}
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
return currentVisibility;
}
@Override
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
return Collections.emptyList();
}
@Override
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
return null;
}
private Rectangle getSlotArea(SlotFake slot) {
return new Rectangle(guiLeft + slot.getX(), guiTop + slot.getY(), 16, 16);
}
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) {
if (getSlotArea(slot).contains(mouseX, mouseY)) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
return true;
}
}
if (draggedStack != null) {
draggedStack.stackSize = 0;
}
return false;
}
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
return false;
}
private class Component {
public boolean isEnable = true;
private final Widget qty;
private final Widget batch;
private final GuiFCImgButton disable;
private final GuiFCImgButton enable;
private final GuiFCImgButton submit;
private final FCGuiLineField line;
private State state;
@SuppressWarnings("unchecked")
public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton submitBtn, GuiFCImgButton enableBtn,
GuiFCImgButton disableBtn, FCGuiLineField line, List buttonList) {
this.qty = qtyInput;
this.batch = batchInput;
this.enable = enableBtn;
this.disable = disableBtn;
this.submit = submitBtn;
this.line = line;
this.state = State.None;
buttonList.add(this.submit);
buttonList.add(this.enable);
buttonList.add(this.disable);
}
public int getIndex() {
return this.qty.idx;
}
public void setEnable(boolean enable) {
this.isEnable = enable;
}
private boolean send(Widget widget) {
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("^[0-9]+")) {
String str = widget.textField.getText().replaceAll("^(0+)", "");
widget.textField.setText(str.isEmpty() ? "0" : str);
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText()));
widget.textField.setTextColor(0xFFFFFF);
return true;
} else {
widget.textField.setTextColor(0xFF0000);
return false;
}
}
return false;
}
protected boolean sendToServer(GuiButton btn) {
boolean didSomething = false;
if (this.submit == btn) {
if (this.send(this.getQty())) this.send(this.getBatch());
didSomething = true;
} else if (this.enable == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Enable, this.getIndex()));
didSomething = true;
} else if (this.disable == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Disable, this.getIndex()));
didSomething = true;
}
return didSomething;
}
public FCGuiTextField isMouseIn(final int xCoord, final int yCoord) {
if (this.qty.textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
if (this.batch.textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
return null;
}
public Widget getQty() {
return this.qty;
}
public Widget getBatch() {
return this.batch;
}
public FCGuiLineField getLine() {
return this.line;
}
public void draw() {
this.qty.draw();
this.batch.draw();
ArrayList<String> message = new ArrayList<>();
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_TITLE) + "\n");
switch (this.state) {
case Idle -> {
this.line.setColor(FCGuiColors.StateIdle.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
}
case Craft -> {
this.line.setColor(FCGuiColors.StateCraft.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
}
case Export -> {
this.line.setColor(FCGuiColors.StateExport.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
}
case Error -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
}
default -> {
this.line.setColor(FCGuiColors.StateNone.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NONE));
}
}
message.add("");
if (isShiftKeyDown()) {
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR_DESC));
} else {
message.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
this.line.setMessage(
render.wrapFormattedStringToWidth(String.join("\n", message), (int) Math.floor(xSize * 0.8)));
this.line.drawTextBox();
if (this.isEnable) {
this.enable.visible = true;
this.disable.visible = false;
} else {
this.enable.visible = false;
this.disable.visible = true;
}
}
public void setState(State state) {
this.state = state;
}
}
private class Widget {
public final int idx;
public final Action action;
private final FCGuiTextField textField;
private final String tooltip;
public Widget(FCGuiTextField textField, String tooltip, int idx, Action action) {
this.textField = textField;
this.textField.setEnableBackgroundDrawing(false);
this.textField.setText("0");
this.textField.setMaxStringLength(10); // this length is enough to useful
this.idx = idx;
this.action = action;
this.tooltip = tooltip;
}
public void draw() {
if (isShiftKeyDown()) {
this.setTooltip(render.wrapFormattedStringToWidth(NameConst.i18n(this.tooltip), xSize / 2));
} else {
this.setTooltip(
render.wrapFormattedStringToWidth(
NameConst.i18n(this.tooltip, "\n", false) + "\n"
+ NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE),
(int) Math.floor(xSize * 0.8)));
}
this.textField.drawTextBox();
}
public void setTooltip(String message) {
this.textField.setMessage(message);
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,24 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.client.gui.container.ContainerLevelWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.container.slot.AppEngSlot;
public class GuiLevelWireless extends GuiLevelTerminal {
public GuiLevelWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerLevelWireless(inventoryPlayer, te));
}
@Override
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof final AppEngSlot slot) {
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 4;
}
}
}
}
@@ -1,14 +1,16 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerOCPatternEditor;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiOCPatternEditor extends AEBaseGui {
@@ -1,124 +1,35 @@
package com.glodblock.github.client.gui;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.common.item.ItemFluidPacket;
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.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketPatternValueSet;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class GuiPatternValueAmount extends AEBaseGui {
import appeng.api.storage.ITerminalHost;
import appeng.core.localization.GuiText;
private GuiTextField amountToSet;
private GuiTabButton originalGuiBtn;
public class GuiPatternValueAmount extends FCGuiAmount {
private GuiButton set;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiType originalGui;
private final int valueIndex;
private final int originalAmount;
@Reflected
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerPatternValueAmount(inventoryPlayer, te));
GuiContainer gui = (GuiContainer) Minecraft.getMinecraft().currentScreen;
if (gui != null && gui.theSlot != null && gui.theSlot.getHasStack()) {
Slot slot = gui.theSlot;
originalAmount = this.getOriginalAmount(slot.getStack());
valueIndex = slot.slotNumber;
} else {
valueIndex = -1;
originalAmount = 0;
}
}
@Override
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);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add(this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
ItemStack myIcon = null;
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if (target instanceof PartFluidPatternTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (this.originalGui != null && myIcon != null) {
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToSet = new GuiTextField(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
this.amountToSet.setEnableBackgroundDrawing(false);
this.amountToSet.setMaxStringLength(16);
this.amountToSet.setTextColor(0xFFFFFF);
this.amountToSet.setVisible(true);
this.amountToSet.setFocused(true);
this.amountToSet.setText(String.valueOf(originalAmount));
this.amountToSet.setSelectionPos(0);
this.submit.displayString = GuiText.Set.getLocal();
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 0x404040);
@@ -126,115 +37,56 @@ public class GuiPatternValueAmount extends AEBaseGui {
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.set.displayString = I18n.format("ae2fc.gui.button.set");
this.set.enabled = valueIndex >= 0;
this.bindTexture("guis/craftAmt.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
try {
String out = this.amountToSet.getText();
double resultD = Calculator.conversion(out);
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 0;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
this.set.enabled = resultI > 0;
int result = getAmount();
this.submit.enabled = result > 0;
} catch (final NumberFormatException e) {
this.set.enabled = false;
}
this.amountToSet.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.set);
}
this.amountToSet.textboxKeyTyped(character, key);
super.keyTyped(character, key);
this.submit.enabled = false;
}
this.amountBox.drawTextBox();
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try {
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
if (btn == this.set && btn.enabled) {
double resultD = Calculator.conversion(this.amountToSet.getText());
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 1;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex));
if (btn == this.submit && btn.enabled) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketPatternValueSet(
originalGui.ordinal(),
getAmount(),
((ContainerPatternValueAmount) this.inventorySlots).getValueIndex()));
}
} catch (final NumberFormatException e) {
// nope..
this.amountToSet.setText("1");
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
this.amountBox.setText("1");
}
}
private void addQty(final int i) {
try {
String out = this.amountToSet.getText();
double resultD = Calculator.conversion(out);
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 0;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
if (resultI == 1 && i > 1) {
resultI = 0;
}
resultI += i;
if (resultI < 1) {
resultI = 1;
}
out = Integer.toString(resultI);
this.amountToSet.setText(out);
} catch (final NumberFormatException e) {
// :P
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
}
}
private int getOriginalAmount(ItemStack stack) {
if (Util.isFluidPacket(stack)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
return fluidStack.amount;
} else {
return stack.stackSize;
}
@Override
protected String getBackground() {
return "guis/craftAmt.png";
}
public void setAmount(int amount) {
this.amountBox.setText(String.valueOf(amount));
this.amountBox.setSelectionPos(0);
}
}
@@ -0,0 +1,133 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerRenamer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketRenamer;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
protected final MEGuiTextField textField;
protected final ITerminalHost host;
protected GuiTabButton originalGuiBtn;
protected ItemStack icon = null;
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(new ContainerRenamer(ip, monitorable));
this.host = monitorable;
this.xSize = 256;
this.textField = new MEGuiTextField(230, 12);
this.textField.setMaxStringLength(32);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
if (host instanceof PartLevelTerminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
} else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host)) {
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
} else if (host instanceof WirelessLevelTerminalInventory) {
icon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
} else if (host instanceof WirelessInterfaceTerminalInventory) {
icon = ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack();
}
if (this.icon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 231,
this.guiTop - 4,
this.icon,
this.icon.getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13);
}
this.textField.x = this.guiLeft + 12;
this.textField.y = this.guiTop + 35;
this.textField.setFocused(true);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRendererObj.drawString(GuiText.Renamer.getLocal(), 12, 8, GuiColors.RenamerTitle.getColor());
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/renamer.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.textField.drawTextBox();
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
this.textField.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped(final char character, final int key) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(this.textField.getText()));
} else if (!this.textField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
}
public boolean isOverTextField(final int mousex, final int mousey) {
return textField.isMouseIn(mousex, mousey);
}
@Override
protected void actionPerformed(GuiButton button) {
if (button == originalGuiBtn) {
switchGui();
} else {
super.actionPerformed(button);
}
}
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);
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
textField.setText(displayName);
}
public void postUpdate(String text) {
this.textField.setText(text);
}
}
@@ -1,9 +1,8 @@
package com.glodblock.github.client.gui;
public interface TankDumpable {
public interface ITankDump {
boolean canDumpTank(int index);
void dumpTank(int index);
}
@@ -0,0 +1,161 @@
package com.glodblock.github.client.gui.base;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import com.glodblock.github.client.gui.GuiEssentiaTerminal;
import com.glodblock.github.client.gui.GuiFCImgButton;
import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
import com.glodblock.github.client.gui.GuiFluidPatternExWireless;
import com.glodblock.github.client.gui.GuiFluidPatternWireless;
import com.glodblock.github.client.gui.GuiFluidPortableCell;
import com.glodblock.github.client.gui.GuiInterfaceWireless;
import com.glodblock.github.client.gui.GuiLevelWireless;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.client.gui.AEBaseMEGui;
public abstract class FCBaseMEGui extends AEBaseMEGui {
protected GuiFCImgButton FluidTerminal;
protected GuiFCImgButton CraftingTerminal;
protected GuiFCImgButton PatternTerminal;
protected GuiFCImgButton EssentiaTerminal;
protected GuiFCImgButton InterfaceTerminal;
protected GuiFCImgButton LevelTerminal;
protected GuiFCImgButton PatternTerminalEx;
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
protected boolean drawSwitchGuiBtn;
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
if (container instanceof FCBaseContainer) {
Object target = ((FCBaseContainer) container).getTarget();
if (target instanceof IWirelessTerminal
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
}
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
}
protected void initGuiDone() {
if (drawSwitchGuiBtn) {
drawSwitchGuiBtns();
}
}
public abstract int getOffsetY();
public abstract void setOffsetY(int y);
@SuppressWarnings("unchecked")
protected void drawSwitchGuiBtns() {
if (!drawSwitchGuiBtn) return;
if (!termBtns.isEmpty()) {
this.termBtns.clear();
}
if (!(this instanceof GuiFluidCraftingWireless)) {
this.buttonList.add(
this.CraftingTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"CRAFT_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.CraftingTerminal);
}
if (!(this instanceof GuiFluidPatternWireless)) {
this.buttonList.add(
this.PatternTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"PATTERN_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminal);
}
if (!(this instanceof GuiFluidPatternExWireless)) {
this.buttonList.add(
this.PatternTerminalEx = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"PATTERN_EX_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminalEx);
}
if (!(this instanceof GuiFluidPortableCell)) {
this.buttonList.add(
this.FluidTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "FLUID_TEM", "YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.FluidTerminal);
}
if (!(this instanceof GuiInterfaceWireless)) {
this.buttonList.add(
this.InterfaceTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"INTERFACE_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.InterfaceTerminal);
}
if (!(this instanceof GuiLevelWireless)) {
this.buttonList.add(
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.LevelTerminal);
}
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
this.buttonList.add(
this.EssentiaTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"ESSENTIA_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.EssentiaTerminal);
}
}
@SuppressWarnings("unchecked")
protected void addSwitchGuiBtns() {
if (!drawSwitchGuiBtn) return;
this.buttonList.addAll(termBtns);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn instanceof GuiFCImgButton) {
if (btn == this.FluidTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_TERMINAL);
} else if (btn == this.CraftingTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_CRAFTING_TERMINAL);
} else if (btn == this.EssentiaTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_ESSENTIA_TERMINAL);
} else if (btn == this.PatternTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
} else if (btn == this.InterfaceTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
} else if (btn == this.LevelTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_LEVEL_TERMINAL);
} else if (btn == this.PatternTerminalEx) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
}
}
super.actionPerformed(btn);
}
}
@@ -0,0 +1,153 @@
package com.glodblock.github.client.gui.base;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
public abstract class FCGuiAmount extends AEBaseGui {
protected GuiTextField amountBox;
protected GuiTabButton originalGuiBtn;
protected GuiButton submit;
protected GuiButton plus1;
protected GuiButton plus10;
protected GuiButton plus100;
protected GuiButton plus1000;
protected GuiButton minus1;
protected GuiButton minus10;
protected GuiButton minus100;
protected GuiButton minus1000;
protected GuiType originalGui;
protected ItemStack myIcon;
public FCGuiAmount(Container container) {
super(container);
}
@Override
@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);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add(
this.submit = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
setOriginGUI(((AEBaseContainer) this.inventorySlots).getTarget());
if (this.originalGui != null && this.myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 151,
this.guiTop - 4,
this.myIcon,
this.myIcon.getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13);
}
this.amountBox = new GuiTextField(
this.fontRendererObj,
this.guiLeft + 62,
this.guiTop + 57,
59,
this.fontRendererObj.FONT_HEIGHT);
this.amountBox.setEnableBackgroundDrawing(false);
this.amountBox.setMaxStringLength(16);
this.amountBox.setTextColor(0xFFFFFF);
this.amountBox.setVisible(true);
this.amountBox.setFocused(true);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(getBackground());
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.actionPerformed(this.submit);
}
this.amountBox.textboxKeyTyped(character, key);
super.keyTyped(character, key);
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.originalGuiBtn) {
InventoryHandler.switchGui(originalGui);
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10
|| btn == this.minus100
|| btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
protected void addQty(final int i) {
try {
long resultI = getAmount();
if (resultI == 1 && i > 1) {
resultI = 0;
}
resultI += i;
if (resultI < 1) {
resultI = 1;
}
String out = Long.toString(resultI);
this.amountBox.setText(out);
} catch (final NumberFormatException ignore) {}
}
protected abstract void setOriginGUI(Object target);
protected abstract String getBackground();
protected int getAmount() {
try {
String out = this.amountBox.getText();
double result = Calculator.conversion(out);
if (result <= 0 || Double.isNaN(result)) {
return 0;
} else {
return (int) ArithHelper.round(result, 0);
}
} catch (final NumberFormatException e) {
return 0;
}
}
}
@@ -0,0 +1,198 @@
package com.glodblock.github.client.gui.base;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFCImgButton;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotFake;
import appeng.util.item.AEItemStack;
public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
private static final String SUBSTITUTION_DISABLE = "0";
private static final String SUBSTITUTION_ENABLE = "1";
private static final String PRIORITY_DISABLE = "0";
private static final String PRIORITY_ENABLE = "1";
private static final String MODE_CRAFTING = "1";
private static final String MODE_PROCESSING = "0";
public FCContainerEncodeTerminal container;
protected GuiTabButton tabCraftButton;
protected GuiTabButton tabProcessButton;
protected GuiImgButton substitutionsEnabledBtn;
protected GuiImgButton substitutionsDisabledBtn;
protected GuiFCImgButton fluidPrioritizedEnabledBtn;
protected GuiFCImgButton fluidPrioritizedDisabledBtn;
protected GuiImgButton encodeBtn;
protected GuiImgButton invertBtn;
protected GuiImgButton clearBtn;
protected GuiImgButton doubleBtn;
protected GuiImgButton beSubstitutionsEnabledBtn;
protected GuiImgButton beSubstitutionsDisabledBtn;
protected GuiFCImgButton combineEnableBtn;
protected GuiFCImgButton combineDisableBtn;
protected GuiFCImgButton autoFillPatternEnableBtn;
protected GuiFCImgButton autoFillPatternDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public FCGuiEncodeTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te,
final FCContainerEncodeTerminal c) {
super(inventoryPlayer, te, c);
this.container = (FCContainerEncodeTerminal) this.inventorySlots;
c.setGui(this);
setReservedSpace(81);
}
@Override
public void initGui() {
super.initGui();
this.buttonList.add(
this.autoFillPatternEnableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"FILL_PATTERN",
"DO_FILL"));
this.buttonList.add(
this.autoFillPatternDisableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"NOT_FILL_PATTERN",
"DONT_FILL"));
this.offsetY += 20;
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else if (this.tabCraftButton == btn || this.tabProcessButton == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.CraftMode",
this.tabProcessButton == btn ? MODE_CRAFTING : MODE_PROCESSING));
} else if (this.encodeBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.Encode",
(isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)));
} else if (this.clearBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Clear", "1"));
} else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.Substitute",
this.substitutionsEnabledBtn == btn ? SUBSTITUTION_DISABLE : SUBSTITUTION_ENABLE));
} else if (this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.Prioritize",
isShiftKeyDown() ? "2" : (container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE)));
} else if (this.invertBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminal.Invert", container.inverted ? "0" : "1"));
} else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.Combine",
this.combineDisableBtn == btn ? "1" : "0"));
} else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.Double",
Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0"));
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "1"));
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0"));
} else if (this.autoFillPatternDisableBtn == btn || this.autoFillPatternEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.AutoFillerPattern",
this.autoFillPatternDisableBtn == btn ? "1" : "0"));
}
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
updateButton(this.tabCraftButton, this.container.isCraftingMode());
updateButton(this.tabProcessButton, !this.container.isCraftingMode());
updateButton(this.doubleBtn, !this.container.isCraftingMode());
updateButton(this.substitutionsEnabledBtn, this.container.substitute);
updateButton(this.substitutionsDisabledBtn, !this.container.substitute);
updateButton(this.combineEnableBtn, !this.container.isCraftingMode() && this.container.combine);
updateButton(this.combineDisableBtn, !this.container.isCraftingMode() && !this.container.combine);
updateButton(this.beSubstitutionsEnabledBtn, this.container.beSubstitute);
updateButton(this.beSubstitutionsDisabledBtn, !this.container.beSubstitute);
updateButton(this.fluidPrioritizedEnabledBtn, this.container.prioritize);
updateButton(this.fluidPrioritizedDisabledBtn, !this.container.prioritize);
updateButton(this.autoFillPatternEnableBtn, this.container.autoFillPattern);
updateButton(this.autoFillPatternDisableBtn, !this.container.autoFillPattern);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
protected void updateButton(GuiButton button, boolean vis) {
if (button != null) {
button.visible = vis;
}
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
public void func_146977_a(final Slot s) {
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotFake && !this.container.isCraftingMode()) {
AEItemStack stack = AEItemStack.create(slot.getStack());
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return true;
IAEItemStack fake = stack.copy();
if (fake.getItemStack().getItem() instanceof ItemFluidPacket) {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
} else return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
}
}
@@ -0,0 +1,775 @@
package com.glodblock.github.client.gui.base;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.FCGuiTextField;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.config.CraftingStatus;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IDisplayRepo;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.container.AEBaseContainer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm;
import appeng.container.slot.SlotDisabled;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternTerm;
import appeng.core.AEConfig;
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.PacketInventoryAction;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import codechicken.nei.LayoutManager;
import codechicken.nei.util.TextHistory;
public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public static int craftingGridOffsetX;
public static int craftingGridOffsetY;
protected static String memoryText = "";
protected final int offsetX = 9;
protected final int lowerTextureOffset = 0;
public IConfigManager configSrc;
protected final boolean viewCell;
protected final ItemStack[] myCurrentViewCells = new ItemStack[5];
public FCContainerMonitor<T> monitorableContainer;
public GuiTabButton craftingStatusBtn;
protected IDisplayRepo repo;
protected GuiImgButton craftingStatusImgBtn;
protected FCGuiTextField searchField;
protected int perRow = 9;
protected int reservedSpace = 0;
protected boolean customSortOrder = true;
protected boolean showViewBtn = true;
protected int rows = 0;
protected int maxRows = Integer.MAX_VALUE;
protected int standardSize;
protected int offsetY;
protected GuiImgButton ViewBox;
protected GuiImgButton SortByBox;
protected GuiImgButton SortDirBox;
protected GuiImgButton searchBoxSettings;
protected GuiImgButton terminalStyleBox;
protected GuiImgButton searchStringSave;
protected GuiImgButton typeFilter;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
super(inventoryPlayer, c);
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.xSize = 195;
this.ySize = 204;
this.standardSize = this.xSize;
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (FCContainerMonitor<T>) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
}
public int getOffsetY() {
return offsetY;
}
public void setOffsetY(int y) {
offsetY = y;
}
public abstract void postUpdate(final List<T> list, boolean resort);
protected void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(
0,
(this.repo.size() + this.perRow - 1) / this.perRow - this.rows,
Math.max(1, this.rows / 6));
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
}
if (btn instanceof final GuiImgButton iBtn) {
final boolean backwards = Mouse.isButtonDown(1);
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (btn == this.searchBoxSettings) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (ModAndClassUtil.isSaveText && btn == this.searchStringSave) {
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
} else {
try {
NetworkHandler.instance
.sendToServer(new PacketValueConfig(iBtn.getSetting().name(), next.name()));
} catch (final IOException e) {
AELog.debug(e);
}
}
iBtn.set(next);
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
this.reInitalize();
}
}
}
super.actionPerformed(btn);
}
protected void reInitalize() {
this.buttonList.clear();
this.initGui();
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL ? 9
: 9 + ((this.width - this.standardSize) / 18);
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
this.rows = (int) Math.floor(extraSpace / 18.0);
if (this.rows > this.maxRows) {
this.rows = this.maxRows;
}
if (hasNEI) {
this.rows--;
}
if (this.rows < 3) {
this.rows = 3;
}
this.getMeSlots().clear();
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots()
.add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
}
}
if (AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL) {
this.xSize = this.standardSize + ((this.perRow - 9) * 18);
} else {
this.xSize = this.standardSize;
}
super.initGui();
// full size : 204
// extra slots : 72
// slot 18
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
this.offsetY = this.guiTop + 8;
if (this.customSortOrder) {
this.buttonList.add(
this.SortByBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SORT_BY,
this.configSrc.getSetting(Settings.SORT_BY)));
this.offsetY += 20;
}
if (this.showViewBtn) {
this.buttonList.add(
this.ViewBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.VIEW_MODE,
this.configSrc.getSetting(Settings.VIEW_MODE)));
this.offsetY += 20;
}
if (ModAndClassUtil.isTypeFilter && this instanceof GuiItemMonitor) {
this.buttonList.add(
this.typeFilter = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.TYPE_FILTER,
this.configSrc.getSetting(Settings.TYPE_FILTER)));
this.offsetY += 20;
}
this.buttonList.add(
this.SortDirBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SORT_DIRECTION,
this.configSrc.getSetting(Settings.SORT_DIRECTION)));
this.offsetY += 20;
this.buttonList.add(
this.searchBoxSettings = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SEARCH_MODE,
AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
this.offsetY += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SAVE_SEARCH,
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
this.offsetY += 20;
}
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
this.offsetY += 20;
// Right now 80 > offsetX, but that can be changed later.
// noinspection DataFlowIssue
this.searchField = new FCGuiTextField(
this.fontRendererObj,
this.guiLeft + Math.max(80, this.offsetX),
this.guiTop + 4,
90,
12);
this.searchField.setEnableBackgroundDrawing(false);
this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF);
this.searchField.setVisible(true);
if (ModAndClassUtil.isSearchStringTooltip)
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
if (this.viewCell) {
if (ModAndClassUtil.isCraftStatus && AEConfig.instance.getConfigManager()
.getSetting(Settings.CRAFTING_STATUS).equals(CraftingStatus.BUTTON)) {
this.buttonList.add(
this.craftingStatusImgBtn = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.CRAFTING_STATUS,
AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
this.offsetY += 20;
} else {
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + 170,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
}
}
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString(memoryText, false);
}
if (this.isSubGui()) {
this.repo.updateView();
this.setScrollBar();
}
craftingGridOffsetX = Integer.MAX_VALUE;
craftingGridOffsetY = Integer.MAX_VALUE;
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195 || s instanceof SlotDisabled) {
this.repositionSlot((AppEngSlot) s);
}
}
if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) {
final Slot g = (Slot) s;
if (g.xDisplayPosition > 0 && g.yDisplayPosition > 0) {
craftingGridOffsetX = Math.min(craftingGridOffsetX, g.xDisplayPosition);
craftingGridOffsetY = Math.min(craftingGridOffsetY, g.yDisplayPosition);
}
}
}
craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6;
initGuiDone();
}
public void setSearchString(String memoryText, boolean updateView) {
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
if (updateView) {
this.repo.updateView();
this.setScrollBar();
}
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) {
this.searchField.mouseClicked(xCoord, yCoord, btn);
}
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
setSearchString("", true);
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
public void handleMouseInput() {
final int wheel = Mouse.getEventDWheel();
final int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight;
if (wheel != 0 && this.searchField.isMouseIn(x, y) && isCtrlKeyDown()) {
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode == SearchBoxMode.NEI_MANUAL_SEARCH || searchMode == SearchBoxMode.NEI_AUTOSEARCH) {
try {
Field cls = LayoutManager.searchField.getClass().getDeclaredField("history");
cls.setAccessible(true);
TextHistory history = ((TextHistory) cls.get("get"));
TextHistory.Direction direction;
if (wheel > 0) {
direction = TextHistory.Direction.PREVIOUS;
} else {
direction = TextHistory.Direction.NEXT;
}
history.get(direction, this.searchField.getText()).map(newText -> {
setSearchString(newText, true);
return true;
}).orElse(false);
return;
} catch (NoSuchFieldException | IllegalAccessException ignore) {}
}
}
super.handleMouseInput();
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (mouseButton == 3) {
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.SET_PATTERN_VALUE;
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
if (slot.equals(this.inventorySlots.inventorySlots.get(i))) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, i, 0, stack));
}
}
return;
}
}
}
if (slot instanceof SlotFake) {
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE
: InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
} else {
action = InventoryAction.PICKUP_SINGLE;
}
}
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if (slot instanceof SlotPatternTerm) {
if (mouseButton == 6) {
return; // prevents weird double clicks
}
try {
NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown()));
} catch (final IOException e) {
AELog.debug(e);
}
} else if (slot instanceof SlotCraftingTerm) {
if (mouseButton == 6) {
return; // prevents weird double clicks
}
InventoryAction action;
if (isShiftKeyDown()) {
action = InventoryAction.CRAFT_SHIFT;
} else {
// Craft a stack on right-click, craft a single one on left-click
action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
if (this.enableSpaceClicking() && !(slot instanceof SlotPatternTerm)) {
IAEItemStack stack = null;
if (slot instanceof SlotME) {
stack = ((SlotME) slot).getAEStack();
}
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
if (!(slot instanceof SlotME) && slot != null) {
slotNum = slot.slotNumber;
}
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
}
if (slot instanceof SlotDisconnected) {
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
InventoryAction action = null;
switch (mouseButton) {
case 0: // pickup / set-down.
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null) action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if (player.capabilities.isCreativeMode) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
break;
default:
case 4: // drop item:
case 6:
}
if (action != null) {
final PacketInventoryAction p = new PacketInventoryAction(
action,
slot.getSlotIndex(),
((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance.sendToServer(p);
}
return;
}
if (slot instanceof SlotME) {
InventoryAction action = null;
IAEItemStack stack = null;
switch (mouseButton) {
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ((SlotME) slot).getAEStack();
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN
&& stack.getStackSize() == 0
&& player.inventory.getItemStack() == null) {
action = InventoryAction.AUTO_CRAFT;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ((SlotME) slot).getAEStack();
break;
case 3: // creative dupe:
stack = ((SlotME) slot).getAEStack();
stack = transformItem(stack); // for fluid terminal
if (stack != null && stack.isCraftable()) {
action = InventoryAction.AUTO_CRAFT;
} else if (player.capabilities.isCreativeMode) {
final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
if (slotItem != null) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
}
break;
default:
case 4: // drop item:
case 6:
}
if (action == InventoryAction.AUTO_CRAFT) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(
new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
} else if (action != null) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(
action,
Ae2ReflectClient.getInventorySlots(this).size(),
0);
NetworkHandler.instance.sendToServer(p);
}
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
protected IAEItemStack transformItem(IAEItemStack stack) {
return stack;
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
memoryText = this.searchField.getText();
}
public void bindTextureBack(final String file) {
final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file);
this.mc.getTextureManager().bindTexture(loc);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTextureBack(this.getBackground());
final int x_width = 195;
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
if (this.viewCell) {
this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 46, 128);
}
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect(
offsetX,
offsetY + 16 + this.rows * 18 + this.lowerTextureOffset,
0,
106 - 18 - 18,
x_width,
99 + this.reservedSpace - this.lowerTextureOffset);
if (this.viewCell) {
boolean update = false;
for (int i = 0; i < 5; i++) {
if (this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot(i).getStack()) {
update = true;
this.myCurrentViewCells[i] = this.monitorableContainer.getCellViewSlot(i).getStack();
}
}
if (update) {
this.repo.setViewCell(this.myCurrentViewCells);
}
}
if (this.searchField != null) {
this.searchField.drawTextBox();
}
}
protected String getBackground() {
return "gui/terminal.png";
}
@Override
protected boolean isPowered() {
return this.repo.hasPower();
}
protected int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6
: Integer.MAX_VALUE;
}
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
} else {
super.keyTyped(character, key);
}
}
}
@Override
public void updateScreen() {
this.repo.setPowered(this.monitorableContainer.isPowered());
super.updateScreen();
}
@Override
public Enum<?> getSortBy() {
return this.configSrc.getSetting(Settings.SORT_BY);
}
@Override
public Enum<?> getSortDir() {
return this.configSrc.getSetting(Settings.SORT_DIRECTION);
}
@Override
public Enum<?> getSortDisplay() {
return this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public Enum getTypeFilter() {
return this.configSrc.getSetting(Settings.TYPE_FILTER);
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.SortByBox != null) {
this.SortByBox.set(this.configSrc.getSetting(Settings.SORT_BY));
}
if (this.SortDirBox != null) {
this.SortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION));
}
if (this.ViewBox != null) {
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
}
if (this.typeFilter != null) {
this.typeFilter.set(this.configSrc.getSetting(Settings.TYPE_FILTER));
}
this.repo.updateView();
}
public int getReservedSpace() {
return this.reservedSpace;
}
public void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
public boolean isCustomSortOrder() {
return this.customSortOrder;
}
public void setCustomSortOrder(final boolean customSortOrder) {
this.customSortOrder = customSortOrder;
}
public int getStandardSize() {
return this.standardSize;
}
public void setStandardSize(final int standardSize) {
this.standardSize = standardSize;
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
public boolean isOverSearchField(int x, int y) {
return searchField.isMouseIn(x, y);
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) {
if (this.viewCell) {
int rw = 33;
int rh = 14 + myCurrentViewCells.length * 18;
if (tw <= 0 || th <= 0) {
return false;
}
int rx = this.guiLeft + this.xSize;
int ry = this.guiTop;
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
}
return false;
}
@Override
public boolean isOverTextField(int mousex, int mousey) {
return searchField.isMouseIn(mousex, mousey);
}
}
@@ -0,0 +1,99 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import com.glodblock.github.inventory.item.IWirelessCraftTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.container.ContainerNull;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm;
import appeng.helpers.IContainerCraftingPacket;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
public class ContainerCraftingWireless extends ContainerItemMonitor
implements IAEAppEngInventory, IContainerCraftingPacket {
private final IWirelessCraftTerminal it;
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
private final SlotCraftingTerm outputSlot;
public ContainerCraftingWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable, false);
this.it = (IWirelessCraftTerminal) monitorable;
final IInventory crafting = this.it.getInventoryByName("crafting");
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * 3] = new SlotCraftingMatrix(
this,
crafting,
x + y * 3,
37 + x * 18,
-72 + y * 18));
}
}
AppEngInternalInventory output = new AppEngInternalInventory(this, 1);
this.addSlotToContainer(
this.outputSlot = new SlotCraftingTerm(
this.getPlayerInv().player,
this.getActionSource(),
this.getPowerSource(),
monitorable,
crafting,
crafting,
output,
131,
-72 + 18,
this));
this.bindPlayerInventory(ip, 0, 0);
this.onCraftMatrixChanged(crafting);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
@Override
public void onCraftMatrixChanged(final IInventory par1IInventory) {
final ContainerNull cn = new ContainerNull();
final InventoryCrafting ic = new InventoryCrafting(cn, 3, 3);
for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(x, this.craftingSlots[x].getStack());
}
this.outputSlot
.putStack(CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj));
}
@Override
public void saveChanges() {
// NO-OP
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
final ItemStack removedStack, final ItemStack newStack) {
// NO-OP
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("player")) {
return this.getInventoryPlayer();
}
return this.it.getInventoryByName(name);
}
@Override
public boolean useRealItems() {
return true;
}
}
@@ -0,0 +1,36 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.common.tile.TileFluidInterface;
import appeng.api.config.Settings;
import appeng.api.config.SidelessMode;
import appeng.api.util.IConfigManager;
import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerInterface;
import appeng.helpers.IInterfaceHost;
public class ContainerDualInterface extends ContainerInterface {
@GuiSync(11)
public SidelessMode sidelessMode;
private final boolean isTile;
public ContainerDualInterface(InventoryPlayer ip, IInterfaceHost te) {
super(ip, te);
this.sidelessMode = SidelessMode.SIDELESS;
this.isTile = te instanceof TileFluidInterface;
}
public SidelessMode getSidelessMode() {
return this.sidelessMode;
}
@Override
protected void loadSettingsFromHost(IConfigManager cm) {
super.loadSettingsFromHost(cm);
this.sidelessMode = this.isTile ? (SidelessMode) cm.getSetting(Settings.SIDELESS_MODE) : SidelessMode.SIDELESS;
}
}
@@ -0,0 +1,153 @@
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;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.util.Util;
import appeng.api.config.Actionable;
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 {
public ContainerEssentiaMonitor(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
&& 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));
}
}
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());
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;
}
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();
}
@Override
protected boolean isEssentiaMode() {
return true;
}
}
@@ -0,0 +1,64 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
import com.glodblock.github.common.tile.TileFluidAutoFiller;
import com.glodblock.github.util.Util;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
public class ContainerFluidAutoFiller extends AEBaseContainer {
public static class FakeSlot extends SlotFake {
public FakeSlot(IInventory inv, int idx, int x, int y) {
super(inv, idx, x, y);
}
@Override
public void putStack(ItemStack is) {
MutablePair<Boolean, ItemStack> result = ContainerFluidAutoFiller.isItemValid(is);
if (result.left) {
if (super.getHasStack()) super.clearStack();
hasChange = true;
super.putStack(result.right);
}
}
}
private final TileFluidAutoFiller tile;
private static boolean hasChange;
public ContainerFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
super(ipl, tile);
this.tile = tile;
addSlotToContainer(new FakeSlot(tile.getInventory(), 0, 80, 35));
bindPlayerInventory(ipl, 0, 84);
}
public static MutablePair<Boolean, ItemStack> isItemValid(ItemStack itemStack) {
boolean result = Util.FluidUtil.isFluidContainer(itemStack);
if (!result) return new MutablePair<>(false, null);
ItemStack tank = itemStack.copy();
tank.stackSize = 1;
if (Util.FluidUtil.isFilled(tank)) {
return new MutablePair<>(true, Util.FluidUtil.clearFluid(tank));
} else {
return new MutablePair<>(true, tank);
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (hasChange) {
tile.updatePattern();
hasChange = false;
}
}
}
@@ -1,146 +0,0 @@
package com.glodblock.github.client.gui.container;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.slot.AppEngSlot;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import java.util.HashMap;
import java.util.Map;
public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te)
{
super( ip, te );
}
public abstract AppEngInternalAEInventory getFakeFluidInv();
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx )
{
AppEngSlot clickSlot = (AppEngSlot)this.inventorySlots.get(idx);
if (clickSlot == null || !clickSlot.getHasStack()) return null;
ItemStack tis = clickSlot.getStack();
FluidStack fs = Util.getFluidFromItem(tis);
if( fs != null )
{
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final IAEFluidStack stack = AEFluidStack.create( fs );
for( int i = 0; i < inv.getSizeInventory(); ++i )
{
if( inv.getStackInSlot(i) == null && this.isValidForConfig( i, stack ) )
{
ItemStack tmp = ItemFluidPacket.newStack(fs);
if (tmp != null) {
tmp.setStackDisplayName(fs.getLocalizedName());
}
inv.setInventorySlotContents( i, tmp );
break;
}
}
this.standardDetectAndSendChanges();
return null;
} else {
if(idx < this.availableUpgrades()){
if(!mergeItemStack(tis, this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades(), this.inventorySlots.size(), false)) return null;
}else if(idx>=this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades()){
if(!mergeItemStack(tis, 0, this.availableUpgrades(), false)) return null;
}
if (tis.stackSize == 0) {
clickSlot.putStack(null);
} else {
clickSlot.onSlotChanged();
}
this.standardDetectAndSendChanges();
return tis;
}
}
protected void setupConfig()
{
this.setupUpgrades();
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName( "config" );
final int y = 40;
final int x = 80;
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 0, x, y, 0, 0, 0 ) );
if( this.supportCapacity() )
{
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 1, x, y, -1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 2, x, y, 1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 3, x, y, 0, -1, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 4, x, y, 0, 1, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 5, x, y, -1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 6, x, y, 1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 7, x, y, -1, 1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 8, x, y, 1, 1, 2 ) );
}
}
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
{
if( this.supportCapacity() )
{
// assumes 4 slots per upgrade
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades( Upgrades.CAPACITY );
if( slot > 0 && upgrades < 1 )
{
return false;
}
return slot <= 4 || upgrades >= 2;
}
return true;
}
@Override
protected void standardDetectAndSendChanges()
{
if( Platform.isServer() )
{
// clear out config items that are no longer valid (eg capacity upgrade removed)
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for( int i = 0; i < inv.getSizeInventory(); ++i )
{
if( inv.getStackInSlot( i ) != null && !this.isValidForConfig( i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i )))) )
{
inv.setInventorySlotContents( i, null );
}
tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i ))));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
super.standardDetectAndSendChanges();
}
}
@@ -1,444 +1,60 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.implementations.CraftingCPURecord;
import appeng.core.AELog;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import java.util.Objects;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
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.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.Future;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerCraftConfirm;
public class ContainerFluidCraftConfirm extends AEBaseContainer {
public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
private final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
private Future<ICraftingJob> job;
private ICraftingJob result;
@GuiSync( 0 )
public long bytesUsed;
@GuiSync( 1 )
public long cpuBytesAvail;
@GuiSync( 2 )
public int cpuCoProcessors;
@GuiSync( 3 )
public boolean autoStart = false;
@GuiSync( 4 )
public boolean simulation = true;
@GuiSync( 5 )
public int selectedCpu = -1;
@GuiSync( 6 )
public boolean noCPU = true;
@GuiSync( 7 )
public String myName = "";
public ContainerFluidCraftConfirm(final InventoryPlayer ip, final ITerminalHost te )
{
super( ip, te );
}
public void cycleCpu( final boolean next )
{
if( next )
{
this.setSelectedCpu( this.getSelectedCpu() + 1 );
}
else
{
this.setSelectedCpu( this.getSelectedCpu() - 1 );
}
if( this.getSelectedCpu() < -1 )
{
this.setSelectedCpu( this.cpus.size() - 1 );
}
else if( this.getSelectedCpu() >= this.cpus.size() )
{
this.setSelectedCpu( -1 );
}
if( this.getSelectedCpu() == -1 )
{
this.setCpuAvailableBytes( 0 );
this.setCpuCoProcessors( 0 );
this.setName( "" );
}
else
{
this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu())));
this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu())));
this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu())));
}
public ContainerFluidCraftConfirm(final InventoryPlayer ip, final ITerminalHost te) {
super(ip, te);
}
@Override
public void detectAndSendChanges()
{
if( Platform.isClient() )
{
return;
}
if (getGrid() == null)
return;
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
int matches = 0;
boolean changed = false;
for( final ICraftingCPU c : cpuSet )
{
boolean found = false;
for( final CraftingCPURecord ccr : this.cpus )
{
if( Ae2Reflect.getCPU(ccr) == c )
{
found = true;
}
}
final boolean matched = this.cpuMatches( c );
if( matched )
{
matches++;
}
if( found == !matched )
{
changed = true;
}
}
if( changed || this.cpus.size() != matches )
{
this.cpus.clear();
for( final ICraftingCPU c : cpuSet )
{
if( this.cpuMatches( c ) )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
}
}
this.sendCPUs();
}
this.setNoCPU( this.cpus.isEmpty() );
super.detectAndSendChanges();
if( this.getJob() != null && this.getJob().isDone() )
{
try
{
this.result = this.getJob().get();
if( !this.result.isSimulation() )
{
this.setSimulation( false );
if( this.isAutoStart() )
{
this.startJob();
return;
}
}
else
{
this.setSimulation( true );
}
final SPacketMEInventoryUpdate a = new SPacketMEInventoryUpdate( (byte) 0 );
final SPacketMEInventoryUpdate b = new SPacketMEInventoryUpdate( (byte) 1 );
final SPacketMEInventoryUpdate c = this.result.isSimulation() ? new SPacketMEInventoryUpdate( (byte) 2 ) : null;
final IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
this.result.populatePlan( plan );
this.setUsedBytes( this.result.getByteTotal() );
for( final IAEItemStack out : plan )
{
IAEItemStack o = out.copy();
o.reset();
o.setStackSize( out.getStackSize() );
final IAEItemStack p = out.copy();
p.reset();
p.setStackSize( out.getCountRequestable() );
final IStorageGrid sg = this.getGrid().getCache( IStorageGrid.class );
final IMEInventory<IAEItemStack> items = sg.getItemInventory();
IAEItemStack m = null;
if( c != null && this.result.isSimulation() )
{
m = o.copy();
o = items.extractItems( o, Actionable.SIMULATE, this.getActionSource() );
if( o == null )
{
o = m.copy();
o.setStackSize( 0 );
}
m.setStackSize( m.getStackSize() - o.getStackSize() );
}
if( o.getStackSize() > 0 )
{
a.appendItem( o );
}
if( p.getStackSize() > 0 )
{
b.appendItem( p );
}
if( c != null && m != null && m.getStackSize() > 0 )
{
c.appendItem( m );
}
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo( a, (EntityPlayerMP) g );
FluidCraft.proxy.netHandler.sendTo( b, (EntityPlayerMP) g );
if( c != null )
{
FluidCraft.proxy.netHandler.sendTo( c, (EntityPlayerMP) g );
}
}
}
}
catch( final Throwable e )
{
this.getPlayerInv().player.addChatMessage( new ChatComponentText( "Error: " + e.toString() ) );
AELog.debug( e );
this.setValidContainer( false );
this.result = null;
}
this.setJob( null );
}
this.verifyPermissions( SecurityPermissions.CRAFT, false );
}
private IGrid getGrid()
{
final IActionHost h = ( (IActionHost) this.getTarget() );
if (h == null || h.getActionableNode() == null)
return null;
return h.getActionableNode().getGrid();
}
private boolean cpuMatches( final ICraftingCPU c )
{
return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy();
}
private void sendCPUs()
{
Collections.sort( this.cpus );
if( this.getSelectedCpu() >= this.cpus.size() )
{
this.setSelectedCpu( -1 );
this.setCpuAvailableBytes( 0 );
this.setCpuCoProcessors( 0 );
this.setName( "" );
}
else if( this.getSelectedCpu() != -1 )
{
this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu())));
this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu())));
this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu())));
}
}
public void startJob()
{
public void switchToOriginalGUI() {
GuiType originalGui = null;
final IActionHost ah = this.getActionHost();
if( ah instanceof PartFluidPatternTerminal)
{
if (ah instanceof PartFluidPatternTerminal) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if( ah instanceof PartFluidPatternTerminalEx)
{
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if( this.result != null && !this.isSimulation() && getGrid() != null)
{
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
final ICraftingLink g = cc.submitJob( this.result, null, this.getSelectedCpu() == -1 ? null : Ae2Reflect.getCPU(this.cpus.get(this.getSelectedCpu())), true, this.getActionSrc() );
this.setAutoStart( false );
if( g != null && originalGui != null && this.getOpenContext() != null )
{
InventoryHandler.openGui(this.getInventoryPlayer().player, getWorld(), new BlockPos(this.getOpenContext().getTile()), Objects.requireNonNull(Util.from(this.getOpenContext().getSide())), originalGui);
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
originalGui = ((ItemBaseWirelessTerminal) terminal.getItem()).guiGuiType(terminal);
}
}
}
private BaseActionSource getActionSrc()
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}
@Override
public void removeCraftingFromCrafters( final ICrafting c )
{
super.removeCraftingFromCrafters( c );
if( this.getJob() != null )
{
this.getJob().cancel( true );
this.setJob( null );
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);
}
}
@Override
public void onContainerClosed( final EntityPlayer par1EntityPlayer )
{
super.onContainerClosed( par1EntityPlayer );
if( this.getJob() != null )
{
this.getJob().cancel( true );
this.setJob( null );
}
}
public World getWorld()
{
return this.getPlayerInv().player.worldObj;
}
public boolean isAutoStart()
{
return this.autoStart;
}
public void setAutoStart( final boolean autoStart )
{
this.autoStart = autoStart;
}
public long getUsedBytes()
{
return this.bytesUsed;
}
private void setUsedBytes( final long bytesUsed )
{
this.bytesUsed = bytesUsed;
}
public long getCpuAvailableBytes()
{
return this.cpuBytesAvail;
}
private void setCpuAvailableBytes( final long cpuBytesAvail )
{
this.cpuBytesAvail = cpuBytesAvail;
}
public int getCpuCoProcessors()
{
return this.cpuCoProcessors;
}
private void setCpuCoProcessors( final int cpuCoProcessors )
{
this.cpuCoProcessors = cpuCoProcessors;
}
public int getSelectedCpu()
{
return this.selectedCpu;
}
private void setSelectedCpu( final int selectedCpu )
{
this.selectedCpu = selectedCpu;
}
public String getName()
{
return this.myName;
}
private void setName( @Nonnull final String myName )
{
this.myName = myName;
}
public boolean hasNoCPU()
{
return this.noCPU;
}
private void setNoCPU( final boolean noCPU )
{
this.noCPU = noCPU;
}
public boolean isSimulation()
{
return this.simulation;
}
private void setSimulation( final boolean simulation )
{
this.simulation = simulation;
}
private Future<ICraftingJob> getJob()
{
return this.job;
}
public void setJob( final Future<ICraftingJob> job )
{
this.job = job;
}
}
@@ -1,20 +1,28 @@
package com.glodblock.github.client.gui.container;
import appeng.tile.inventory.AppEngInternalAEInventory;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidIO extends ContainerFluidConfigurable
{
private final PartSharedFluidBus bus;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.util.Ae2Reflect;
public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te )
{
super( ip, te );
import appeng.api.config.SchedulingMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.util.IConfigManager;
import appeng.tile.inventory.AppEngInternalAEInventory;
public class ContainerFluidIO extends FCContainerFluidConfigurable {
private final FCSharedFluidBus bus;
public ContainerFluidIO(InventoryPlayer ip, FCSharedFluidBus te) {
super(ip, te);
this.bus = te;
}
public PartSharedFluidBus getBus() {
public FCSharedFluidBus getBus() {
return this.bus;
}
@@ -22,4 +30,17 @@ public class ContainerFluidIO extends ContainerFluidConfigurable
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.bus.getInventoryByName("config");
}
@Override
protected void loadSettingsFromHost(IConfigManager cm) {
super.loadSettingsFromHost(cm);
if (Ae2Reflect.getUpgradeableHost(this) instanceof PartFluidExportBus) {
this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY));
this.setSchedulingMode((SchedulingMode) cm.getSetting(Settings.SCHEDULING_MODE));
}
}
public void setSchedulingMode(final SchedulingMode schedulingMode) {
this.schedulingMode = schedulingMode;
}
}
@@ -1,52 +1,42 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.IOptionalSlotHost;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.IOptionalSlotHost;
import appeng.util.item.AEFluidStack;
public class ContainerFluidInterface extends AEBaseContainer implements IOptionalSlotHost {
private final Object tile;
private final IDualHost tile;
public ContainerFluidInterface(InventoryPlayer ipl, TileFluidInterface tile) {
public ContainerFluidInterface(InventoryPlayer ipl, IDualHost tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getConfig();
final int y = 35;
final int x = 35;
for (int i = 0; i < 6; i++) {
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
addSlotToContainer(
new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
}
bindPlayerInventory(ipl, 0, 149);
}
public ContainerFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getConfig();
final int y = 35;
final int x = 35;
for (int i = 0; i < 6; i++) {
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
}
bindPlayerInventory(ipl, 0, 149);
}
public Object getTile() {
public IDualHost getTile() {
return tile;
}
@@ -59,30 +49,16 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
if (tile instanceof TileFluidInterface) {
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((TileFluidInterface) tile).getConfig().getStackInSlot( i ))));
}
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
else {
for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
tmp.put(i, ((PartFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((PartFluidInterface) tile).getConfig().getStackInSlot( i ))));
}
for (int i = 0; i < tile.getConfig().getSizeInventory(); i++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(tile.getConfig().getStackInSlot(i))));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -0,0 +1,105 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.implementations.IUpgradeableHost;
import appeng.container.guisync.GuiSync;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
private final PartFluidLevelEmitter lvlEmitter;
@SideOnly(Side.CLIENT)
private GuiTextField textField;
@GuiSync(2)
public long EmitterValue = -1;
public ContainerFluidLevelEmitter(final InventoryPlayer ip, final PartFluidLevelEmitter te) {
super(ip, te);
this.lvlEmitter = te;
}
public PartFluidLevelEmitter getBus() {
return this.lvlEmitter;
}
protected IUpgradeableHost getUpgradeable() {
return Ae2Reflect.getUpgradeableHost(this);
}
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.lvlEmitter.getInventoryByName("config");
}
@Override
protected void setupConfig() {
final IInventory inv = this.getUpgradeable().getInventoryByName("config");
final int y = 40;
final int x = 80 + 44;
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, x, y, 0, 0, 0));
}
@SideOnly(Side.CLIENT)
public void setTextField(final GuiTextField level) {
this.textField = level;
this.textField.setText(String.valueOf(this.EmitterValue));
}
public void setLevel(final long l, final EntityPlayer player) {
this.lvlEmitter.setReportingValue(l);
this.EmitterValue = l;
}
@Override
protected boolean supportCapacity() {
return false;
}
@Override
public int availableUpgrades() {
return 0;
}
public void setRedStoneMode(final RedstoneMode rsMode) {
this.rsMode = rsMode;
}
@Override
public void detectAndSendChanges() {
this.verifyPermissions(SecurityPermissions.BUILD, false);
if (Platform.isServer()) {
this.EmitterValue = this.lvlEmitter.getReportingValue();
this.setRedStoneMode(
(RedstoneMode) Ae2Reflect.getUpgradeableHost(this).getConfigManager()
.getSetting(Settings.REDSTONE_EMITTER));
}
this.standardDetectAndSendChanges();
}
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
if (field.equals("EmitterValue")) {
if (this.textField != null) {
this.textField.setText(String.valueOf(this.EmitterValue));
}
}
}
}
@@ -0,0 +1,544 @@
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;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
protected final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
/**
* Index of tuple which indicates remaining tanks that are remaining (not emptied/filled)
*/
protected static final int REM_IDX = 0;
/**
* Index of tuple which indicates remaining tanks that are acted upon (emptied/filled)
*/
protected static final int ACT_IDX = 1;
/**
* Index of tuple which indicates tanks that are partially emptied/filled
*/
protected static final int PARTIAL_IDX = 2;
public ContainerFluidMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected ContainerFluidMonitor(final InventoryPlayer ip, final ITerminalHost monitorable,
final boolean bindInventory) {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getFluidInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = monitorable.getFluidInventory();
this.monitor.addListener(this, null);
this.setPowerSource((IEnergySource) monitorable);
}
} else {
this.monitor = null;
}
this.canAccessViewCells = false;
if (monitorable instanceof IViewCellStorage) {
for (int y = 0; y < 5; y++) {
this.cellView[y] = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.VIEW_CELL,
((IViewCellStorage) monitorable).getViewCellStorage(),
y,
206,
y * 18 + 8,
this.getInventoryPlayer());
this.cellView[y].setAllowEdit(this.canAccessViewCells);
this.addSlotToContainer(this.cellView[y]);
}
}
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0);
}
}
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient() && !isEssentiaMode()) {
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));
}
}
return super.transferStackInSlot(p, idx);
}
@Override
protected void processItemList() {
if (!this.fluids.isEmpty()) {
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
List<IAEFluidStack> toSend = new ArrayList<>();
for (final IAEFluidStack is : this.fluids) {
final IAEFluidStack send = monitorCache.findPrecise(is);
if (send != null) {
toSend.add(send);
} else {
is.setStackSize(0);
toSend.add(is);
}
}
for (final Object c : this.crafters) {
if (c instanceof EntityPlayerMP) {
SPacketMEUpdateBuffer.scheduleFluidUpdate((EntityPlayerMP) c, toSend);
}
}
this.fluids.resetStatus();
}
}
@Override
protected void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayerMP && this.monitor != null) {
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
List<IAEFluidStack> toSend = new ArrayList<>();
for (final IAEFluidStack is : monitorCache) {
toSend.add(is);
}
SPacketMEUpdateBuffer.scheduleFluidUpdate((EntityPlayerMP) c, toSend);
}
}
@Override
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change,
BaseActionSource actionSource) {
for (final IAEFluidStack is : change) {
this.fluids.add(is);
}
}
protected void dropItem(ItemStack is) {
if (is == null || is.stackSize <= 0) return;
ItemStack itemStack = is.copy();
int i = itemStack.getMaxStackSize();
while (itemStack.stackSize > 0) {
if (i > itemStack.stackSize) {
if (!getPlayerInv().addItemStackToInventory(itemStack.copy())) {
getPlayerInv().player.entityDropItem(itemStack.copy(), 0);
}
break;
} else {
itemStack.stackSize -= i;
ItemStack item = itemStack.copy();
item.stackSize = i;
if (!getPlayerInv().addItemStackToInventory(item)) {
getPlayerInv().player.entityDropItem(item, 0);
}
}
}
}
protected void dropItem(ItemStack itemStack, int stackSize) {
if (itemStack == null || itemStack.stackSize <= 0) return;
ItemStack is = itemStack.copy();
is.stackSize = stackSize;
this.dropItem(is);
}
/**
* Two operations, insert and extract.
*
* @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;
if (slotIndex == -1) {
cursorItems = player.inventory.getItemStack().stackSize;
} else {
cursorItems = player.inventory.getStackInSlot(slotIndex).stackSize;
}
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)
}
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>
* <li>Leftover filled container stack</li>
* <li>Empty containers</li>
* <li>Partially filled container x1</li>
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
*/
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];
// 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();
test.stackSize = 1;
FluidStack fluidStack = fcItem.drain(test, fluidPerContainer, false);
if (fluidStack == null || fluidStack.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);
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];
}
} else {
return;
}
// 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);
} 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);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
}
}
if (shouldSendStack) {
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
(EntityPlayerMP) player);
} else {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
}
/**
* The extract operation. For input, we have an empty container stack. For outputs, we have the following:
* <ol>
* <li>Leftover empty container stack</li>
* <li>Filled containers (full)</li>
* <li>Partially filled container x1</li>
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
*/
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();
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) {
return;
}
} 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;
}
// Calculate the remaining fluid to extract, if any
ItemStack partialStack = fluidContainer.copy();
if (remainder > 0) {
actualExtract.setStackSize(remainder);
partialStack.stackSize = 1;
if (partialStack.getItem() instanceof IFluidContainerItem) {
int amt = ((IFluidContainerItem) partialStack.getItem())
.fill(partialStack, actualExtract.getFluidStack(), true);
assert amt == remainder;
emptyTanks--;
} else {
ItemStack dummy = FluidContainerRegistry
.fillFluidContainer(actualExtract.getFluidStack(), partialStack);
if (dummy == null) {
// Failed to fill partial...
partialStack.stackSize = 0;
} else {
partialStack = dummy;
emptyTanks--;
}
}
} else {
partialStack.stackSize = 0;
}
// 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) {
ItemStack emptyStack = player.inventory.getItemStack();
emptyStack.stackSize = emptyTanks;
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);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
}
if (shouldSendStack) {
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
(EntityPlayerMP) player);
} else {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
}
void adjustStack(ItemStack stack) {
if (stack != null && stack.stackSize > stack.getMaxStackSize()) {
dropItem(stack, stack.stackSize - stack.getMaxStackSize());
stack.stackSize = stack.getMaxStackSize();
}
}
protected boolean isEssentiaMode() {
return false;
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
}
@@ -1,16 +1,19 @@
package com.glodblock.github.client.gui.container;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import static com.glodblock.github.loader.ItemAndBlockHolder.PACKET;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.inventory.slot.FCSlotRestrictedInput;
import appeng.container.AEBaseContainer;
public class ContainerFluidPacketDecoder extends AEBaseContainer {
public ContainerFluidPacketDecoder(InventoryPlayer ipl, TileFluidPacketDecoder tile) {
super(ipl, tile);
addSlotToContainer(new SlotNormal(tile.getInventory(), 0, 80, 35));
addSlotToContainer(new FCSlotRestrictedInput(PACKET.stack(), tile.getInventory(), 0, 80, 35, ipl));
bindPlayerInventory(ipl, 0, 84);
}
}
@@ -1,37 +1,33 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.PatternConsumer;
import com.glodblock.github.inventory.slot.SlotFluid;
import com.glodblock.github.inventory.IPatternConsumer;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import appeng.api.AEApi;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.InventoryAction;
public class ContainerFluidPatternEncoder extends AEBaseContainer implements PatternConsumer {
public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPatternConsumer {
private final TileFluidPatternEncoder tile;
@@ -46,10 +42,22 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
}
addSlotToContainer(new SlotFluidConvertingFake(output, y, 113, 17 + y * 18));
}
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, tile.getInventory(), 0, 138, 20, ipl));
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, tile.getInventory(), 1, 138, 50, ipl));
addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
tile.getInventory(),
0,
138,
20,
ipl));
addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
tile.getInventory(),
1,
138,
50,
ipl));
bindPlayerInventory(ipl, 0, 84);
}
@@ -57,12 +65,17 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
return tile;
}
private static boolean isNotPattern(ItemStack stack) {
return stack == null || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack)
|| (stack.getItem() instanceof ItemFluidEncodedPattern));
}
public boolean canEncodePattern() {
if (isNotPattern(tile.getInventory().getStackInSlot(0)) && isNotPattern(tile.getInventory().getStackInSlot(1))) {
if (isNotPattern(tile.getInventory().getStackInSlot(0))
&& isNotPattern(tile.getInventory().getStackInSlot(1))) {
return false;
}
find_input:
{
find_input: {
for (IAEItemStack stack : tile.getCraftingSlots()) {
if (stack != null && stack.getStackSize() > 0) {
break find_input;
@@ -78,11 +91,6 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
return false;
}
private static boolean isNotPattern(ItemStack stack) {
return stack == null || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack)
|| (stack.getItem() instanceof ItemFluidEncodedPattern));
}
public void encodePattern() {
if (canEncodePattern()) {
// if there is an encoded pattern, overwrite it; otherwise, consume a blank
@@ -98,7 +106,10 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
}
private static IAEItemStack[] collectAeInventory(AeStackInventory<IAEItemStack> inv) {
// see note at top of DensePatternDetails
/*
* AE2 API documentation says the input/output arrays can contain nulls, but their use of the API directly
* contradicts that, so we just go by behaviour and filter out nulls.
*/
List<IAEItemStack> acc = new ArrayList<>();
for (IAEItemStack stack : inv) {
if (stack != null) {
@@ -122,33 +133,38 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
if (slot instanceof SlotFluidConvertingFake) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN:
case PICKUP_OR_SET_DOWN -> {
if (stack == null) {
slot.putStack(null);
} else {
((SlotFluidConvertingFake)slot).putConvertedStack(stack.copy());
((SlotFluidConvertingFake) slot).putConvertedStack(stack.copy());
}
break;
case PLACE_SINGLE:
}
case PLACE_SINGLE -> {
if (stack != null) {
((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
break;
case SPLIT_OR_PLACE_SINGLE:
}
case SPLIT_OR_PLACE_SINGLE -> {
ItemStack inSlot = slot.getStack();
if (inSlot != null) {
if (stack == null) {
slot.putStack(Util.copyStackWithSize(inSlot, Math.max(1, inSlot.stackSize - 1)));
} else if (stack.isItemEqual(inSlot)) {
slot.putStack(Util.copyStackWithSize(inSlot,
Math.min(inSlot.getMaxStackSize(), inSlot.stackSize + 1)));
slot.putStack(
Util.copyStackWithSize(
inSlot,
Math.min(inSlot.getMaxStackSize(), inSlot.stackSize + 1)));
} else {
((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
} else if (stack != null) {
((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
break;
}
}
} else {
super.doAction(player, action, slotId, id);
@@ -167,60 +183,4 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
dest.setStack(i, src[i]);
}
}
private static class SlotFluidConvertingFake extends SlotFake implements SlotFluid {
private final AeStackInventory<IAEItemStack> inv;
public SlotFluidConvertingFake(AeItemStackHandler inv, int idx, int x, int y) {
super(inv, idx, x, y);
this.inv = inv.getAeInventory();
}
@Override
public void putStack(ItemStack stack) {
inv.setStack(getSlotIndex(), AEItemStack.create(stack));
}
@Override
public void setAeStack(@Nullable IAEItemStack stack, boolean sync) {
inv.setStack(getSlotIndex(), stack);
}
public void putConvertedStack(ItemStack stack) {
if (stack == null) {
setAeStack(null, false);
return;
} else if (stack.getItem() instanceof IFluidContainerItem) {
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
if (fluid != null) {
fluid.amount *= stack.stackSize;
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
if (aeStack != null) {
setAeStack(aeStack, false);
return;
}
}
} else if (FluidContainerRegistry.isContainer(stack)) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
if (fluid != null) {
fluid.amount *= stack.stackSize;
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
if (aeStack != null) {
setAeStack(aeStack, false);
return;
}
}
}
putStack(stack);
}
@Nullable
@Override
public IAEItemStack getAeStack() {
return inv.getStack(getSlotIndex());
}
}
}
@@ -0,0 +1,17 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class ContainerFluidPatternExWireless extends ContainerFluidPatternTerminalEx {
public ContainerFluidPatternExWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
@@ -1,200 +1,161 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.PatternConsumer;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraft.item.crafting.CraftingManager;
public class ContainerFluidPatternTerminal extends FCBasePartContainer implements PatternConsumer {
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
public ContainerFluidPatternTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
import appeng.api.storage.ITerminalHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.SlotPatternTerm;
import appeng.util.Platform;
public class ContainerFluidPatternTerminal extends FCContainerEncodeTerminal {
public ContainerFluidPatternTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
final IInventory output = this.patternTerminal.getInventoryByName("output");
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
this.craftingSlots = new SlotFakeCraftingMatrix[9];
this.outputSlots = new OptionalSlotFake[3];
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix(
this.crafting,
x + y * 3,
18 + x * 18,
-76 + y * 18));
}
}
this.addSlotToContainer(
this.craftSlot = new SlotPatternTerm(
ip.player,
this.getActionSource(),
this.getPowerSource(),
monitorable,
this.crafting,
patternInv,
this.cOut,
110,
-76 + 18,
this,
2,
this));
this.craftSlot.setIIcon(-1);
for (int y = 0; y < 3; y++) {
this.addSlotToContainer(
this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
this.outputSlots[y].setRenderDisabled(false);
}
this.updateOrderOfOutputSlots();
}
public void encodeAllItemAndMoveToInventory(){
encode();
ItemStack output = this.patternSlotOUT.getStack();
if(output != null){
if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
private void updateOrderOfOutputSlots() {
if (!this.isCraftingMode()) {
this.craftSlot.xDisplayPosition = -9000;
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
}
} else {
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = -9000;
}
this.patternSlotOUT.putStack( null );
this.patternSlotIN.putStack(null);
}
}
protected boolean validPatternSlot(Slot slot) {
return slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs;
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
super.encode();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack == null) {
stack = this.patternSlotIN.getStack();
if (!isPattern(stack)) {
return;
}
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize --;
}
encodeFluidPattern();
} else if (isPattern(stack)) {
encodeFluidPattern();
}
}
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output);
}
private boolean checkHasFluidPattern() {
if (this.craftingMode) {
return false;
}
boolean hasFluid = false, search = false;
for (Slot craftingSlot : this.craftingSlots) {
final ItemStack crafting = craftingSlot.getStack();
if (crafting == null) {
continue;
}
search = true;
if (crafting.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
if (!search) { // search=false -> inputs were empty
return false;
}
// `search` should be true at this point
for (Slot outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out == null) {
continue;
}
search = false;
if (hasFluid) {
break;
} else if (out.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
return hasFluid && !search; // search=true -> outputs were empty
}
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
patternSlotOUT.putStack(pattern.writeToStack());
}
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
stacks[i] = aeStack;
}
return stacks;
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
super.putStackInSlot(par1, par2ItemStack);
this.getAndUpdateOutput();
}
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (getPatternTerminal() != null) {
getPatternTerminal().onChangeCrafting(inputs, outputs);
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
super.putStacksInSlots(par1ArrayOfItemStack);
this.getAndUpdateOutput();
}
private ItemStack getAndUpdateOutput() {
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
for (int x = 0; x < ic.getSizeInventory(); x++) {
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
}
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
this.cOut.setInventorySlotContents(0, is);
return is;
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
protected ItemStack[] getOutputs() {
if (this.isCraftingMode()) {
super.doAction(player, action, slotId, id);
return;
}
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
final ItemStack out = this.getAndUpdateOutput();
if (out != null && out.stackSize > 0) {
return new ItemStack[] { out };
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
super.doAction(player, action, slotId, id);
return super.getOutputs();
}
@Override
public boolean isSlotEnabled(final int idx) {
if (idx == 1) {
return Platform.isServer() ? !this.patternTerminal.isCraftingRecipe() : !this.isCraftingMode();
} else if (idx == 2) {
return Platform.isServer() ? this.patternTerminal.isCraftingRecipe() : this.isCraftingMode();
} else {
return false;
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isServer()) {
if (this.isCraftingMode() != this.patternTerminal.isCraftingRecipe()) {
this.setCraftingMode(this.patternTerminal.isCraftingRecipe());
this.updateOrderOfOutputSlots();
}
}
}
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (field.equals("craftingMode")) {
this.getAndUpdateOutput();
this.updateOrderOfOutputSlots();
}
}
public void clear() {
super.clear();
this.getAndUpdateOutput();
}
private void setCraftingMode(final boolean craftingMode) {
this.craftingMode = craftingMode;
}
@Override
public void doubleStacks(boolean isShift) {
if (!isCraftingMode()) {
super.doubleStacks(isShift);
}
}
}
@@ -1,199 +1,153 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.slot.OptionalSlotFake;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.PatternConsumer;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx implements PatternConsumer {
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
public ContainerFluidPatternTerminalEx(InventoryPlayer ip, ITerminalHost monitorable) {
import appeng.api.storage.ITerminalHost;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.helpers.InventoryAction;
import appeng.util.Platform;
public class ContainerFluidPatternTerminalEx extends FCContainerEncodeTerminal {
private static final int CRAFTING_GRID_PAGES = 2;
private static final int CRAFTING_GRID_WIDTH = 4;
private static final int CRAFTING_GRID_HEIGHT = 4;
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
public ContainerFluidPatternTerminalEx(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
}
public void encodeAllItemAndMoveToInventory(){
encode();
ItemStack output = this.patternSlotOUT.getStack();
if(output != null){
if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
this.patternSlotIN.putStack(null);
}
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
super.encode();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack == null) {
stack = this.patternSlotIN.getStack();
if (!isPattern(stack)) {
return;
}
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize --;
}
encodeFluidPattern();
} else if (isPattern(stack)) {
encodeFluidPattern();
}
}
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output);
}
private boolean checkHasFluidPattern() {
boolean hasFluid = false, search = false;
for (Slot craftingSlot : this.craftingSlots) {
final ItemStack crafting = craftingSlot.getStack();
if (crafting == null) {
continue;
}
search = true;
if (crafting.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
if (!search) { // search=false -> inputs were empty
return false;
}
// `search` should be true at this point
for (Slot outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out == null) {
continue;
}
search = false;
if (hasFluid) {
break;
} else if (out.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
return hasFluid && !search; // search=true -> outputs were empty
}
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setCombine(this.combine ? 1:0);
pattern.setPriority(this.prioritize? 1:0);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
patternSlotOUT.putStack(pattern.writeToStack());
}
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
this.craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
this.outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
final IInventory output = this.getPatternTerminal().getInventoryByName("output");
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH
+ page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(
crafting,
this,
x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS,
15,
-83,
x,
y,
x + 4));
}
}
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
this.addSlotToContainer(
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y
+ page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(
output,
this,
x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS,
112,
-83,
-x,
y,
x));
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
stacks[i] = aeStack;
}
return stacks;
this.craftingMode = false;
}
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (getPatternTerminal() != null) {
getPatternTerminal().onChangeCrafting(inputs, outputs);
public boolean isSlotEnabled(final int idx) {
if (idx < 4) // outputs
{
return inverted || idx == 0;
} else {
return !inverted || idx == 4;
}
}
protected boolean validPatternSlot(Slot slot) {
return slot instanceof ProcessingSlotFake;
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
inverted = patternTerminal.isInverted();
activePage = patternTerminal.getActivePage();
offsetSlots();
}
}
super.detectAndSendChanges();
}
private void offsetSlots() {
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
((ProcessingSlotFake) this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS])
.setHidden(page != activePage || x > 0 && inverted);
((ProcessingSlotFake) this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS])
.setHidden(page != activePage || x > 0 && !inverted);
}
}
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (field.equals("inverted") || field.equals("activePage")) {
offsetSlots();
}
}
@Override
public void onSlotChange(final Slot s) {
if (s == this.patternSlotOUT && Platform.isServer()) {
inverted = patternTerminal.isInverted();
}
super.onSlotChange(s);
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof OptionalSlotFake) && stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
if (stack == null && slot.getStack() != null && slot.getStack().getItem() instanceof ItemFluidPacket) {
return;
}
}
this.craftingMode = false;
super.doAction(player, action, slotId, id);
}
@Override
public void encode() {
this.craftingMode = false;
super.encode();
}
@Override
public boolean isCraftingMode() {
return false;
}
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX,
int offY, int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
}
@@ -0,0 +1,17 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class ContainerFluidPatternWireless extends ContainerFluidPatternTerminal {
public ContainerFluidPatternWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
@@ -0,0 +1,19 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IFluidPortableCell;
public class ContainerFluidPortableCell extends ContainerFluidMonitor {
public ContainerFluidPortableCell(final InventoryPlayer ip, final IFluidPortableCell monitorable) {
super(ip, monitorable, false);
this.bindPlayerInventory(ip, 0, 0);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
@@ -0,0 +1,193 @@
package com.glodblock.github.client.gui.container;
import java.util.Iterator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.Upgrades;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
public final PartFluidStorageBus bus;
@GuiSync(3)
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
@GuiSync(4)
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
public ContainerFluidStorageBus(InventoryPlayer ip, PartFluidStorageBus te) {
super(ip, te);
this.bus = te;
}
@Override
protected int getHeight() {
return 251;
}
@Override
protected void setupConfig() {
final int xo = 8;
final int yo = 23 + 6;
final IInventory upgrades = Ae2Reflect.getUpgradeList(this).getInventoryByName("upgrades");
final IInventory config = Ae2Reflect.getUpgradeList(this).getInventoryByName("config");
for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) {
this.addSlotToContainer(
new OptionalFluidSlotFakeTypeOnly(config, null, this, y * 9 + x, xo, yo, x, y, y));
}
}
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
0,
187,
8,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
1,
187,
8 + 18,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
2,
187,
8 + 18 * 2,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
3,
187,
8 + 18 * 3,
this.getInventoryPlayer())).setNotDraggable());
this.addSlotToContainer(
(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
4,
187,
8 + 18 * 4,
this.getInventoryPlayer())).setNotDraggable());
}
@Override
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
final int y = slot / 9;
return y < upgrades + 2;
}
return true;
}
@Override
protected boolean supportCapacity() {
return true;
}
@Override
public int availableUpgrades() {
return 5;
}
@Override
public void detectAndSendChanges() {
this.verifyPermissions(SecurityPermissions.BUILD, false);
if (Platform.isServer()) {
this.setReadWriteMode(
(AccessRestriction) Ae2Reflect.getUpgradeList(this).getConfigManager().getSetting(Settings.ACCESS));
this.setStorageFilter(
(StorageFilter) Ae2Reflect.getUpgradeList(this).getConfigManager()
.getSetting(Settings.STORAGE_FILTER));
}
this.standardDetectAndSendChanges();
}
@Override
public boolean isSlotEnabled(final int idx) {
if (Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.ORE_FILTER) > 0) return false;
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
return upgrades > (idx - 2);
}
public void clear() {
AppEngInternalAEInventory h = this.bus.getConfig();
for (int i = 0; i < h.getSizeInventory(); ++i) {
h.setInventorySlotContents(i, null);
}
this.detectAndSendChanges();
}
public void partition() {
AppEngInternalAEInventory h = this.bus.getConfig();
final IMEInventory<IAEFluidStack> cellInv = this.bus.getInternalHandler();
Iterator<IAEFluidStack> i = new NullIterator<>();
if (cellInv != null) {
final IItemList<IAEFluidStack> list = cellInv
.getAvailableItems(AEApi.instance().storage().createFluidList());
i = list.iterator();
}
for (int x = 0; x < h.getSizeInventory(); x++) {
if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) {
h.setInventorySlotContents(x, ItemFluidPacket.newStack(i.next()));
} else {
h.setInventorySlotContents(x, null);
}
}
this.detectAndSendChanges();
}
public AccessRestriction getReadWriteMode() {
return this.rwMode;
}
public StorageFilter getStorageFilter() {
return this.storageFilter;
}
@Override
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.bus.getInventoryByName("config");
}
private void setReadWriteMode(final AccessRestriction rwMode) {
this.rwMode = rwMode;
}
private void setStorageFilter(final StorageFilter storageFilter) {
this.storageFilter = storageFilter;
}
}
@@ -1,21 +1,23 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.ITankDump;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
public class ContainerIngredientBuffer extends AEBaseContainer implements TankDumpable {
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
public class ContainerIngredientBuffer extends AEBaseContainer implements ITankDump {
private final TileIngredientBuffer tile;
@@ -23,10 +25,14 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements TankDu
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getInternalInventory();
addSlots(inv);
bindPlayerInventory(ipl, 0, 140);
}
protected void addSlots(IInventory inv) {
for (int i = 0; i < 9; i++) {
addSlotToContainer(new SlotNormal(inv, i, 8 + 18 * i, 108));
}
bindPlayerInventory(ipl, 0, 140);
}
public TileIngredientBuffer getTile() {
@@ -35,28 +41,25 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements TankDu
@Override
public boolean canDumpTank(int index) {
return tile.getFluidInventory().getFluidInSlot(index) != null;
return tile.getInternalFluid().getFluidInSlot(index) != null;
}
@Override
public void dumpTank(int index) {
if (index >= 0 && index < tile.getFluidInventory().getSlots()) {
tile.getFluidInventory().setFluidInSlot(index, null);
if (index >= 0 && index < tile.getInternalFluid().getSlots()) {
tile.getInternalFluid().setFluidInSlot(index, null);
}
}
@Override
public void detectAndSendChanges()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) {
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
@@ -0,0 +1,404 @@
package com.glodblock.github.client.gui.container;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.api.util.DimensionalCoord;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketCompressedNBT;
import appeng.helpers.IInterfaceTerminalSupport;
import appeng.helpers.InterfaceTerminalSupportedClassProvider;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.parts.AEBasePart;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorIInventory;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.ItemSlot;
import appeng.util.inv.WrapperInvSlot;
public class ContainerInterfaceWireless extends FCBaseContainer {
/**
* this stuff is all server side
*/
private static long autoBase = Long.MIN_VALUE;
private final Multimap<IInterfaceTerminalSupport, InvTracker> supportedInterfaces = HashMultimap.create();
private final Map<Long, InvTracker> byId = new HashMap<>();
private IGrid grid;
private NBTTagCompound data = new NBTTagCompound();
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable);
if (Platform.isServer()) {
this.grid = monitorable.getActionableNode().getGrid();
}
this.bindPlayerInventory(ip, 14, 0);
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
super.detectAndSendChanges();
if (this.grid == null) {
return;
}
int total = 0;
boolean missing = false;
final IActionHost host = this.getActionHost();
if (host != null) {
final IGridNode agn = host.getActionableNode();
if (agn != null && agn.isActive()) {
Set<Class<? extends IInterfaceTerminalSupport>> supportedClasses = InterfaceTerminalSupportedClassProvider
.getSupportedClasses();
if (supportedClasses == null) {
return;
}
for (var clz : supportedClasses) {
for (final IGridNode gn : this.grid.getMachines(clz)) {
final IInterfaceTerminalSupport interfaceTerminalSupport = (IInterfaceTerminalSupport) gn
.getMachine();
if (!gn.isActive() || !interfaceTerminalSupport.shouldDisplay()) continue;
final Collection<InvTracker> t = supportedInterfaces.get(interfaceTerminalSupport);
final String name = interfaceTerminalSupport.getName();
missing = t.isEmpty() || t.stream().anyMatch(it -> !it.unlocalizedName.equals(name));
total += interfaceTerminalSupport.getPatternsConfigurations().length;
if (missing) break;
}
// we can stop if any is missing. The value of `total` is not important if `missing == true`
if (missing) break;
}
}
}
if (total != this.supportedInterfaces.size() || missing) {
this.regenList(this.data);
} else {
for (final ContainerInterfaceWireless.InvTracker inv : supportedInterfaces.values()) {
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
this.addItems(this.data, inv, x, 1);
}
}
}
}
if (!this.data.hasNoTags()) {
try {
NetworkHandler.instance
.sendTo(new PacketCompressedNBT(this.data), (EntityPlayerMP) this.getPlayerInv().player);
} catch (final IOException ignored) {}
this.data = new NBTTagCompound();
}
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slot, final long id) {
final ContainerInterfaceWireless.InvTracker inv = this.byId.get(id);
if (inv != null) {
final ItemStack is = inv.server.getStackInSlot(slot + inv.offset);
final boolean hasItemInHand = player.inventory.getItemStack() != null;
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
final WrapperInvSlot slotInv = new ContainerInterfaceWireless.PatternInvSlot(inv.server);
final IInventory theSlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor interfaceSlot = new AdaptorIInventory(theSlot);
IInventory interfaceHandler = inv.server;
boolean canInsert = true;
switch (action) {
case PICKUP_OR_SET_DOWN -> {
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
interfaceHandler.getStackInSlot(s),
player.inventory.getItemStack())) {
canInsert = false;
break;
}
}
if (canInsert) {
ItemStack inSlot = theSlot.getStackInSlot(0);
if (inSlot == null) {
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
} else {
inSlot = inSlot.copy();
final ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents(0, null);
player.inventory.setItemStack(null);
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
if (player.inventory.getItemStack() == null) {
player.inventory.setItemStack(inSlot);
} else {
player.inventory.setItemStack(inHand);
theSlot.setInventorySlotContents(0, inSlot);
}
}
}
} else {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
mySlot.setInventorySlotContents(0, playerHand.addItems(mySlot.getStackInSlot(0)));
}
}
case SPLIT_OR_PLACE_SINGLE -> {
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
interfaceHandler.getStackInSlot(s),
player.inventory.getItemStack())) {
canInsert = false;
break;
}
}
if (canInsert) {
ItemStack extra = playerHand.removeItems(1, null, null);
if (extra != null && !interfaceSlot.containsItems()) {
extra = interfaceSlot.addItems(extra);
}
if (extra != null) {
playerHand.addItems(extra);
}
}
} else if (is != null) {
ItemStack extra = interfaceSlot.removeItems((is.stackSize + 1) / 2, null, null);
if (extra != null) {
extra = playerHand.addItems(extra);
}
if (extra != null) {
interfaceSlot.addItems(extra);
}
}
}
case SHIFT_CLICK -> {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
mySlot.setInventorySlotContents(0, mergeToPlayerInventory(playerInv, mySlot.getStackInSlot(0)));
}
case MOVE_REGION -> {
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
inv.server.setInventorySlotContents(
x + inv.offset,
mergeToPlayerInventory(playerInvAd, inv.server.getStackInSlot(x + inv.offset)));
}
}
case CREATIVE_DUPLICATE -> {
if (player.capabilities.isCreativeMode && !hasItemInHand) {
player.inventory.setItemStack(is == null ? null : is.copy());
}
}
default -> {
return;
}
}
this.updateHeld(player);
}
}
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
if (stack == null) return null;
for (ItemSlot slot : playerInv) {
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
++slot.getItemStack().stackSize;
return null;
}
}
}
return playerInv.addItems(stack);
}
private void regenList(final NBTTagCompound data) {
this.byId.clear();
this.supportedInterfaces.clear();
final IActionHost host = this.getActionHost();
if (host != null) {
final IGridNode agn = host.getActionableNode();
if (agn != null && agn.isActive()) {
Set<Class<? extends IInterfaceTerminalSupport>> supportedClasses = InterfaceTerminalSupportedClassProvider
.getSupportedClasses();
if (supportedClasses == null) {
return;
}
for (var clz : supportedClasses) {
for (final IGridNode gn : this.grid.getMachines(clz)) {
final IInterfaceTerminalSupport terminalSupport = (IInterfaceTerminalSupport) gn.getMachine();
if (!gn.isActive() || !terminalSupport.shouldDisplay()) continue;
final var configurations = terminalSupport.getPatternsConfigurations();
for (int i = 0; i < configurations.length; ++i) {
this.supportedInterfaces.put(
terminalSupport,
new ContainerInterfaceWireless.InvTracker(terminalSupport, configurations[i], i));
}
}
}
}
}
data.setBoolean("clear", true);
for (final ContainerInterfaceWireless.InvTracker inv : this.supportedInterfaces.values()) {
this.byId.put(inv.which, inv);
this.addItems(data, inv, 0, inv.client.getSizeInventory());
}
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
private boolean isDifferent(final ItemStack a, final ItemStack b) {
if (a == null && b == null) {
return false;
}
if (a == null || b == null) {
return true;
}
return !ItemStack.areItemStacksEqual(a, b);
}
private void addItems(final NBTTagCompound data, final ContainerInterfaceWireless.InvTracker inv, final int offset,
final int length) {
final String name = '=' + Long.toString(inv.which, Character.MAX_RADIX);
final NBTTagCompound tag = data.getCompoundTag(name);
if (tag.hasNoTags()) {
tag.setLong("sortBy", inv.sortBy);
tag.setString("un", inv.unlocalizedName);
tag.setInteger("x", inv.X);
tag.setInteger("y", inv.Y);
tag.setInteger("z", inv.Z);
tag.setInteger("dim", inv.dim);
tag.setInteger("side", inv.side.ordinal());
tag.setInteger("size", inv.client.getSizeInventory());
}
for (int x = 0; x < length; x++) {
final NBTTagCompound itemNBT = new NBTTagCompound();
final ItemStack is = inv.server.getStackInSlot(x + offset + inv.offset);
// "update" client side.
inv.client.setInventorySlotContents(offset + x, is == null ? null : is.copy());
if (is != null) {
is.writeToNBT(itemNBT);
}
tag.setTag(Integer.toString(x + offset), itemNBT);
}
data.setTag(name, tag);
}
private static class InvTracker {
private final long sortBy;
private final long which = autoBase++;
private final String unlocalizedName;
private final IInventory client;
private final IInventory server;
private final int offset;
private final int X;
private final int Y;
private final int Z;
private final int dim;
private final ForgeDirection side;
public InvTracker(final DimensionalCoord coord, long sortValue, final IInventory patterns,
final String unlocalizedName, int offset, int size, ForgeDirection side) {
this(
coord.x,
coord.y,
coord.z,
coord.getDimension(),
sortValue,
patterns,
unlocalizedName,
offset,
size,
side);
}
public InvTracker(int x, int y, int z, int dim, long sortValue, final IInventory patterns,
final String unlocalizedName, int offset, int size, ForgeDirection side) {
this.server = patterns;
this.client = new AppEngInternalInventory(null, size);
this.unlocalizedName = unlocalizedName;
this.sortBy = sortValue + offset << 16;
this.offset = offset;
this.X = x;
this.Y = y;
this.Z = z;
this.dim = dim;
this.side = side;
}
public InvTracker(IInterfaceTerminalSupport terminalSupport,
IInterfaceTerminalSupport.PatternsConfiguration configuration, int index) {
this(
terminalSupport.getLocation(),
terminalSupport.getSortValue(),
terminalSupport.getPatterns(index),
terminalSupport.getName(),
configuration.offset,
configuration.size,
terminalSupport instanceof AEBasePart ? ((AEBasePart) terminalSupport).getSide()
: ForgeDirection.UNKNOWN);
}
}
private static class PatternInvSlot extends WrapperInvSlot {
public PatternInvSlot(final IInventory inv) {
super(inv);
}
@Override
public boolean isItemValid(final ItemStack itemstack) {
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
}
}
}
@@ -0,0 +1,152 @@
package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
import appeng.api.AEApi;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.slot.SlotRestrictedInput;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.Platform;
public class ContainerItemMonitor extends FCContainerMonitor<IAEItemStack> {
private final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
public ContainerItemMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected ContainerItemMonitor(final InventoryPlayer ip, final ITerminalHost monitorable,
final boolean bindInventory) {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
IStorageGrid storageGrid = g.getCache(IStorageGrid.class);
this.monitor = storageGrid.getItemInventory();
if (this.monitor == null) {
this.setValidContainer(false);
} else {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = monitorable.getItemInventory();
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
this.setPowerSource((IEnergySource) monitorable);
}
} else {
this.monitor = null;
}
this.canAccessViewCells = false;
if (monitorable instanceof IViewCellStorage) {
for (int y = 0; y < 5; y++) {
this.cellView[y] = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.VIEW_CELL,
((IViewCellStorage) monitorable).getViewCellStorage(),
y,
206,
y * 18 + 8,
this.getInventoryPlayer());
this.cellView[y].setAllowEdit(this.canAccessViewCells);
this.addSlotToContainer(this.cellView[y]);
}
}
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0);
}
}
@Override
protected void processItemList() {
if (!this.items.isEmpty()) {
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
List<IAEItemStack> toSend = new ArrayList<>();
for (final IAEItemStack is : this.items) {
final IAEItemStack send = monitorCache.findPrecise(is);
if (send != null) {
toSend.add(send);
} else {
is.setStackSize(0);
toSend.add(is);
}
}
for (final Object c : this.crafters) {
if (c instanceof EntityPlayer) {
SPacketMEUpdateBuffer.scheduleItemUpdate((EntityPlayerMP) c, toSend);
}
}
this.items.resetStatus();
}
}
@Override
protected void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
List<IAEItemStack> toSend = new ArrayList<>();
for (final IAEItemStack is : monitorCache) {
toSend.add(is);
}
SPacketMEUpdateBuffer.scheduleItemUpdate((EntityPlayerMP) c, toSend);
}
}
@Override
public void removeCraftingFromCrafters(final ICrafting c) {
super.removeCraftingFromCrafters(c);
if (this.crafters.isEmpty() && this.monitor != null) {
this.monitor.removeListener(this);
if (c instanceof EntityPlayerMP) {
SPacketMEUpdateBuffer.clear((EntityPlayerMP) c);
}
}
}
@Override
public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change,
final BaseActionSource source) {
for (final IAEItemStack is : change) {
this.items.add(is);
}
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
}
@@ -1,67 +1,23 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
public class ContainerLargeIngredientBuffer extends AEBaseContainer implements TankDumpable {
import appeng.container.slot.SlotNormal;
private final TileLargeIngredientBuffer tile;
public class ContainerLargeIngredientBuffer extends ContainerIngredientBuffer {
public ContainerLargeIngredientBuffer(InventoryPlayer ipl, TileLargeIngredientBuffer tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getInternalInventory();
}
protected void addSlots(IInventory inv) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new SlotNormal(inv, i * 9 + j, 8 + 18 * j, 72 + 18 * i));
}
}
bindPlayerInventory(ipl, 0, 140);
}
public TileLargeIngredientBuffer getTile() {
return tile;
}
@Override
public boolean canDumpTank(int index) {
return tile.getFluidInventory().getFluidInSlot(index) != null;
}
@Override
public void dumpTank(int index) {
if (index >= 0 && index < tile.getFluidInventory().getSlots()) {
tile.getFluidInventory().setFluidInSlot(index, null);
}
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) {
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -0,0 +1,141 @@
package com.glodblock.github.client.gui.container;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.util.Util;
import appeng.api.config.SecurityPermissions;
import appeng.container.AEBaseContainer;
import appeng.helpers.InventoryAction;
import appeng.util.Platform;
public class ContainerLevelMaintainer extends AEBaseContainer {
private final TileLevelMaintainer tile;
private final SlotFluidConvertingFake[] requestSlots = new SlotFluidConvertingFake[TileLevelMaintainer.REQ_COUNT];
public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(ipl, tile);
this.tile = tile;
AeItemStackHandler request = new AeItemStackHandler(tile.getRequestSlots());
for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) {
SlotFluidConvertingFake slot = new SlotFluidConvertingFake(request, y, 27, 20 + y * 19);
addSlotToContainer(slot);
requestSlots[y] = slot;
}
bindPlayerInventory(ipl, 0, 130);
}
public TileLevelMaintainer getTile() {
return tile;
}
public SlotFluidConvertingFake[] getRequestSlots() {
return this.requestSlots;
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
Slot slot = getSlot(slotId);
if (slot instanceof SlotFluidConvertingFake) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN -> {
if (stack == null) {
slot.putStack(null);
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(createLevelValues(stack.copy()));
}
}
case PLACE_SINGLE -> {
if (stack != null) {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
}
case SPLIT_OR_PLACE_SINGLE -> {
ItemStack inSlot = slot.getStack();
if (inSlot != null) {
if (stack == null) {
slot.putStack(
createLevelValues(
Objects.requireNonNull(
Util.copyStackWithSize(
inSlot,
Math.max(1, inSlot.stackSize - 1)))));
} else if (stack.isItemEqual(inSlot)) {
slot.putStack(
createLevelValues(
Objects.requireNonNull(
Util.copyStackWithSize(
inSlot,
Math.min(
inSlot.getMaxStackSize(),
inSlot.stackSize + 1)))));
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
} else if (stack != null) {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
}
}
} else {
super.doAction(player, action, slotId, id);
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
if (Platform.isClient()) {
return null;
}
for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
if (!slot.getHasStack()) {
ItemStack itemStack = ((Slot) this.inventorySlots.get(idx)).getStack();
slot.putConvertedStack(createLevelValues(itemStack.copy()));
break;
}
}
this.detectAndSendChanges();
return null;
}
@Override
public void detectAndSendChanges() {
this.verifyPermissions(SecurityPermissions.BUILD, false);
super.detectAndSendChanges();
}
public static ItemStack createLevelValues(ItemStack itemStack) {
var data = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
var itemStackTag = new NBTTagCompound();
itemStack.writeToNBT(itemStackTag);
data.setTag(TLMTags.Stack.tagName, itemStackTag);
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize);
data.setLong(TLMTags.Batch.tagName, 0);
data.setBoolean(TLMTags.Enable.tagName, false);
data.setInteger(TLMTags.State.tagName, State.None.ordinal());
itemStack.setTagCompound(data);
return itemStack;
}
}
@@ -0,0 +1,405 @@
package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
import com.google.common.primitives.Ints;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.api.util.DimensionalCoord;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.ItemSlot;
public class ContainerLevelTerminal extends FCBaseContainer {
/**
* this stuff is all server side
*/
private int nextId = 0;
private final Map<ILevelViewable, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
private IGrid grid;
private SPacketLevelTerminalUpdate dirty;
private boolean isDirty;
private boolean wasOff;
private int ticks = 0;
public ContainerLevelTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
if (Platform.isServer()) {
if (monitorable instanceof PartLevelTerminal terminal) {
grid = terminal.getActionableNode().getGrid();
} else if (monitorable instanceof IWirelessTerminal wirelessTerminal) {
grid = wirelessTerminal.getActionableNode().getGrid();
}
dirty = this.updateList();
if (dirty != null) {
this.isDirty = true;
} else {
dirty = new SPacketLevelTerminalUpdate();
}
}
this.bindPlayerInventory(ip, 14, 0);
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
super.detectAndSendChanges();
if (this.grid == null) {
return;
}
final IActionHost host = this.getActionHost();
if (!host.getActionableNode().isActive()) {
if (!wasOff) {
SPacketLevelTerminalUpdate update = new SPacketLevelTerminalUpdate();
update.setDisconnect();
wasOff = true;
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
return;
}
wasOff = false;
if (isDirty) {
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) this.getPlayerInv().player);
dirty = new SPacketLevelTerminalUpdate();
isDirty = false;
} else if (++ticks % 20 == 0) {
ticks = 0;
SPacketLevelTerminalUpdate update = this.updateList();
if (update != null) {
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
}
}
/**
* Merge from slot -> player inv. Returns the items not added.
*/
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
if (stack == null) return null;
for (ItemSlot slot : playerInv) {
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
++slot.getItemStack().stackSize;
return null;
}
}
}
return playerInv.addItems(stack);
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slotIdx, final long id) {
final ContainerLevelTerminal.InvTracker invTracker = this.trackedById.get(id);
if (invTracker != null) {
final ItemStack handStack = player.inventory.getItemStack();
if (handStack != null && !(handStack.getItem() instanceof ItemEncodedPattern)) {
// Why even bother if we're not dealing with an encoded pattern in hand
return;
}
final ItemStack slotStack = invTracker.requests.getStackInSlot(slotIdx);
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
switch (action) {
/* Set down/pickup. This is the same as SPLIT_OR_PLACE_SINGLE as our max stack sizes are 1 in slots. */
case PICKUP_OR_SET_DOWN -> {
if (handStack != null) {
for (int s = 0; s < invTracker.requests.getSizeInventory(); s++) {
/* Is there a duplicate pattern here? */
if (Platform.isSameItemPrecise(invTracker.requests.getStackInSlot(s), handStack)) {
/* We're done here - dupe found. */
return;
}
}
}
if (slotStack == null) {
/* Insert to container, if valid */
if (handStack == null) {
/* Nothing happens */
return;
}
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
} else {
/* Exchange? */
if (handStack != null && handStack.stackSize > 1) {
/* Exchange is impossible, abort */
return;
}
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
playerHand.addItems(slotStack.copy());
}
syncLevelTerminalSlot(invTracker, id, slotIdx, invTracker.requests.getStackInSlot(slotIdx));
}
/* Shift click from slotIdx -> player. Player -> slotIdx is not supported. */
case SHIFT_CLICK -> {
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player.inventory, ForgeDirection.UNKNOWN);
ItemStack leftOver = mergeToPlayerInventory(playerInv, slotStack);
if (leftOver == null) {
invTracker.requests.setInventorySlotContents(slotIdx, null);
syncLevelTerminalSlot(invTracker, id, slotIdx, null);
}
}
/* Move all blank patterns -> player */
case MOVE_REGION -> {
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
List<Integer> valid = new ArrayList<>();
for (int i = 0; i < invTracker.requests.getSizeInventory(); i++) {
ItemStack toExtract = invTracker.requests.getStackInSlot(i);
if (toExtract == null) {
continue;
}
ItemStack leftOver = mergeToPlayerInventory(playerInv, toExtract);
if (leftOver != null) {
break;
} else {
invTracker.requests.setInventorySlotContents(i, null);
}
valid.add(i);
}
if (valid.size() > 0) {
int[] validIndices = Ints.toArray(valid);
NBTTagList tag = new NBTTagList();
for (int i = 0; i < valid.size(); ++i) {
tag.appendTag(new NBTTagCompound());
}
dirty.addOverwriteEntry(id).setItems(validIndices, tag);
isDirty = true;
}
}
case CREATIVE_DUPLICATE -> {
if (player.capabilities.isCreativeMode) {
playerHand.addItems(handStack);
}
}
default -> {
return;
}
}
this.updateHeld(player);
}
}
private void syncLevelTerminalSlot(ContainerLevelTerminal.InvTracker inv, long id, int slot, ItemStack stack) {
int[] validIndices = { slot };
NBTTagList list = new NBTTagList();
NBTTagCompound item = new NBTTagCompound();
if (stack != null) {
stack.writeToNBT(item);
}
list.appendTag(item);
inv.updateNBT();
this.dirty.addOverwriteEntry(id).setItems(validIndices, list);
this.isDirty = true;
}
private SPacketLevelTerminalUpdate updateList() {
SPacketLevelTerminalUpdate update = null;
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
Set<ILevelViewable> 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 ILevelViewable machine = isAdopted
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridNode.getMachine())
: (ILevelViewable) gridNode.getMachine();
/* First check if we are already tracking this node */
if (tracked.containsKey(machine)) {
/* Check for updates */
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(machine);
/* Name changed? */
String name = machine.getCustomName();
if (!Objects.equals(knownTracker.name, name)) {
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addRenamedEntry(knownTracker.id, name);
knownTracker.name = name;
}
/* Status changed? */
boolean isActive = gridNode.isActive() || machine.shouldDisplay();
if (!knownTracker.online && isActive) {
/* Node offline -> online */
knownTracker.online = true;
if (update == null) update = new SPacketLevelTerminalUpdate();
knownTracker.updateNBT();
update.addOverwriteEntry(knownTracker.id).setOnline(true)
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
} else if (knownTracker.online && !isActive) {
/* Node online -> offline */
knownTracker.online = false;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteEntry(knownTracker.id).setOnline(false);
}
for (int i = 0; i < knownTracker.requests.getSizeInventory(); i++) {
ItemStack knowmItemStack = ItemStack
.loadItemStackFromNBT(knownTracker.inventoryNbt.getCompoundTagAt(i));
ItemStack machineItemStack = machine.getInventoryByName("config").getStackInSlot(i);
if (isDifferent(knowmItemStack, machineItemStack)) {
if (update == null) update = new SPacketLevelTerminalUpdate();
knownTracker.updateNBT();
update.addOverwriteEntry(knownTracker.id)
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
}
}
} else {
/* Add a new entry */
if (update == null) update = new SPacketLevelTerminalUpdate();
ContainerLevelTerminal.InvTracker entry = new ContainerLevelTerminal.InvTracker(
nextId++,
machine,
gridNode.isActive());
update.addNewEntry(entry.id, entry.name, entry.online)
.setLocation(entry.x, entry.y, entry.z, entry.dim, entry.side.ordinal())
.setItems(entry.rows, entry.rowSize, entry.inventoryNbt)
.setViewItemStack(machine.getSelfItemStack(), machine.getDisplayItemStack());
tracked.put(machine, entry);
trackedById.put(entry.id, entry);
}
visited.add(machine);
}
}
/* Now find any entries that we need to remove */
Iterator<Map.Entry<ILevelViewable, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
while (it.hasNext()) {
var entry = it.next();
if (visited.contains(entry.getKey())) {
continue;
}
if (update == null) update = new SPacketLevelTerminalUpdate();
trackedById.remove(entry.getValue().id);
it.remove();
update.addRemovalEntry(entry.getValue().id);
}
return update;
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
private boolean isDifferent(final ItemStack a, final ItemStack b) {
if (a == null && b == null) {
return false;
}
if (a == null || b == null) {
return true;
}
return !ItemStack.areItemStacksEqual(a, b);
}
private static class InvTracker {
private final long id;
private String name;
private final IInventory requests;
private final int rowSize;
private final int rows;
private final int x;
private final int y;
private final int z;
private final int dim;
private final ForgeDirection side;
private boolean online;
private NBTTagList inventoryNbt;
public InvTracker(long id, ILevelViewable machine, boolean online) {
DimensionalCoord location = machine.getLocation();
this.id = id;
this.name = machine.getCustomName();
this.requests = machine.getInventoryByName("config");
this.rowSize = machine.rowSize();
this.rows = machine.rows();
this.x = location.x;
this.y = location.y;
this.z = location.z;
this.dim = location.getDimension();
this.side = machine.getSide();
this.online = online;
this.inventoryNbt = new NBTTagList();
updateNBT();
}
private void updateNBT() {
this.inventoryNbt = new NBTTagList();
for (int i = 0; i < this.rows; ++i) {
for (int j = 0; j < this.rowSize; ++j) {
final int offset = this.rowSize * i;
ItemStack stack = this.requests.getStackInSlot(offset + j);
if (stack != null) {
this.inventoryNbt.appendTag(stack.writeToNBT(new NBTTagCompound()));
} else {
this.inventoryNbt.appendTag(new NBTTagCompound());
}
}
}
}
}
}
@@ -0,0 +1,17 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class ContainerLevelWireless extends ContainerLevelTerminal {
public ContainerLevelWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
@@ -1,23 +1,28 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerOCPatternEditor extends AEBaseContainer {
public ContainerOCPatternEditor(InventoryPlayer ipl, TileOCPatternEditor tile) {
super(ipl, tile);
for (int i = 0; i < 4; i ++) {
for (int j = 0; j < 4; j ++) {
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.PATTERN, tile.getInternalInventory(),
j * 4 + i, 55 + i * 18, 17 + j * 18, ipl
));
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.PATTERN,
tile.getInternalInventory(),
j * 4 + i,
55 + i * 18,
17 + j * 18,
ipl));
}
}
bindPlayerInventory(ipl, 0, 104);
}
}
@@ -1,45 +1,43 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import appeng.api.config.SecurityPermissions;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotInaccessible;
import appeng.tile.inventory.AppEngInternalInventory;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
public class ContainerPatternValueAmount extends AEBaseContainer {
private final Slot patternValue;
private int valueIndex;
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te )
{
super( ip, te );
this.patternValue = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
this.addSlotToContainer( patternValue );
@GuiSync(11)
public int valueIndex;
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te) {
super(ip, te);
this.patternValue = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53);
this.addSlotToContainer(patternValue);
}
@Override
public void detectAndSendChanges()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
this.verifyPermissions( SecurityPermissions.CRAFT, false );
this.verifyPermissions(SecurityPermissions.CRAFT, false);
}
public Slot getPatternValue()
{
public Slot getPatternValue() {
return patternValue;
}
public int getValueIndex()
{
public int getValueIndex() {
return valueIndex;
}
public void setValueIndex( int valueIndex )
{
public void setValueIndex(int valueIndex) {
this.valueIndex = valueIndex;
}
}
@@ -0,0 +1,13 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
public class ContainerRenamer extends AEBaseContainer {
public ContainerRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
}
}
@@ -1,408 +0,0 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.BufferOverflowException;
public class FCBaseMonitorContain extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>
{
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEItemStack> monitor;
private final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
private final IConfigManager clientCM;
private final ITerminalHost host;
@GuiSync( 99 )
public boolean canAccessViewCells = false;
@GuiSync( 98 )
public boolean hasPower = false;
private IConfigManagerHost gui;
private IConfigManager serverCM;
private IGridNode networkNode;
public FCBaseMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable )
{
this( ip, monitorable, true );
}
protected FCBaseMonitorContain( final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory )
{
super( ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null );
this.host = monitorable;
this.clientCM = new ConfigManager( this );
this.clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
if( Platform.isServer() )
{
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getItemInventory();
if( this.monitor != null )
{
this.monitor.addListener( this, null );
this.setCellInventory( this.monitor );
if( monitorable instanceof IPortableCell)
{
this.setPowerSource( (IEnergySource) monitorable );
}
else if( monitorable instanceof IMEChest)
{
this.setPowerSource( (IEnergySource) monitorable );
}
else if( monitorable instanceof IGridHost)
{
final IGridNode node = ( (IGridHost) monitorable ).getGridNode( ForgeDirection.UNKNOWN );
if( node != null )
{
this.networkNode = node;
final IGrid g = node.getGrid();
if( g != null )
{
this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) );
}
}
}
}
else
{
this.setValidContainer( false );
}
}
else
{
this.monitor = null;
}
this.canAccessViewCells = false;
if( monitorable instanceof IViewCellStorage)
{
for( int y = 0; y < 5; y++ )
{
this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ( (IViewCellStorage) monitorable ).getViewCellStorage(), y, 206, y * 18 + 8, this.getInventoryPlayer() );
this.cellView[y].setAllowEdit( this.canAccessViewCells );
this.addSlotToContainer( this.cellView[y] );
}
}
if( bindInventory )
{
this.bindPlayerInventory( ip, 0, 0 );
}
}
public IGridNode getNetworkNode()
{
return this.networkNode;
}
@Override
public void detectAndSendChanges()
{
if( Platform.isServer() )
{
if( this.monitor != this.host.getItemInventory() )
{
this.setValidContainer( false );
}
for( final Settings set : this.serverCM.getSettings() )
{
final Enum<?> sideLocal = this.serverCM.getSetting( set );
final Enum<?> sideRemote = this.clientCM.getSetting( set );
if( sideLocal != sideRemote )
{
this.clientCM.putSetting( set, sideLocal );
for( final Object crafter : this.crafters )
{
try
{
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) crafter );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
}
}
if( !this.items.isEmpty() )
{
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
for( final IAEItemStack is : this.items )
{
final IAEItemStack send = monitorCache.findPrecise( is );
if( send == null )
{
is.setStackSize( 0 );
piu.appendItem( is );
}
else
{
piu.appendItem( send );
}
}
if( !piu.isEmpty() )
{
this.items.resetStatus();
for( final Object c : this.crafters )
{
if( c instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
}
}
this.updatePowerStatus();
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells =
this.host instanceof WirelessTerminalGuiObject
|| this.hasAccess( SecurityPermissions.BUILD, false );
if( this.canAccessViewCells != oldAccessible )
{
for( int y = 0; y < 5; y++ )
{
if( this.cellView[y] != null )
{
this.cellView[y].setAllowEdit( this.canAccessViewCells );
}
}
}
super.detectAndSendChanges();
}
}
protected void updatePowerStatus()
{
try
{
if( this.networkNode != null )
{
this.setPowered( this.networkNode.isActive() );
}
else if( this.getPowerSource() instanceof IEnergyGrid )
{
this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() );
}
else
{
this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 );
}
}
catch( final Throwable t )
{
// :P
}
}
@Override
public void onUpdate( final String field, final Object oldValue, final Object newValue )
{
if( field.equals( "canAccessViewCells" ) )
{
for( int y = 0; y < 5; y++ )
{
if( this.cellView[y] != null )
{
this.cellView[y].setAllowEdit( this.canAccessViewCells );
}
}
}
super.onUpdate( field, oldValue, newValue );
}
@Override
public void addCraftingToCrafters( final ICrafting c )
{
super.addCraftingToCrafters( c );
this.queueInventory( c );
}
private void queueInventory( final ICrafting c )
{
if( Platform.isServer() && c instanceof EntityPlayer && this.monitor != null )
{
SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
for( final IAEItemStack send : monitorCache )
{
try
{
piu.appendItem( send );
}
catch( final BufferOverflowException boe )
{
FluidCraft.proxy.netHandler.sendTo( piu, (EntityPlayerMP) c );
piu = new SPacketMEInventoryUpdate();
piu.appendItem( send );
}
}
FluidCraft.proxy.netHandler.sendTo( piu, (EntityPlayerMP) c );
}
}
@Override
public void removeCraftingFromCrafters( final ICrafting c )
{
super.removeCraftingFromCrafters( c );
if( this.crafters.isEmpty() && this.monitor != null )
{
this.monitor.removeListener( this );
}
}
@Override
public void onContainerClosed( final EntityPlayer player )
{
super.onContainerClosed( player );
if( this.monitor != null )
{
this.monitor.removeListener( this );
}
}
@Override
public boolean isValid( final Object verificationToken )
{
return true;
}
@Override
public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource source )
{
for( final IAEItemStack is : change )
{
this.items.add( is );
}
}
@Override
public void onListUpdate()
{
for( final Object c : this.crafters )
{
if( c instanceof ICrafting )
{
final ICrafting cr = (ICrafting) c;
this.queueInventory( cr );
}
}
}
@Override
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
{
if( this.getGui() != null )
{
this.getGui().updateSetting( manager, settingName, newValue );
}
}
@Override
public IConfigManager getConfigManager()
{
if( Platform.isServer() )
{
return this.serverCM;
}
return this.clientCM;
}
public ItemStack[] getViewCells()
{
final ItemStack[] list = new ItemStack[this.cellView.length];
for( int x = 0; x < this.cellView.length; x++ )
{
list[x] = this.cellView[x].getStack();
}
return list;
}
public SlotRestrictedInput getCellViewSlot( final int index )
{
return this.cellView[index];
}
public boolean isPowered()
{
return this.hasPower;
}
private void setPowered( final boolean isPowered )
{
this.hasPower = isPowered;
}
private IConfigManagerHost getGui()
{
return this.gui;
}
public void setGui( @Nonnull final IConfigManagerHost gui )
{
this.gui = gui;
}
}
@@ -1,637 +0,0 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.networking.security.MachineSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.*;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private final PartFluidPatternTerminal patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
private final IInventory crafting;
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
protected final SlotPatternTerm craftSlot;
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync( 97 )
public boolean craftingMode = true;
@GuiSync( 96 )
public boolean substitute = false;
@GuiSync( 95 )
public boolean combine = false;
public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable )
{
super( ip, monitorable, false );
this.patternTerminal = (PartFluidPatternTerminal) monitorable;
final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
final IInventory output = this.getPatternTerminal().getInventoryByName( "output" );
this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" );
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 3; x++ )
{
this.addSlotToContainer( this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) );
}
}
this.addSlotToContainer( this.craftSlot = new SlotPatternTerm( ip.player, this.getActionSource(), this.getPowerSource(), monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this ) );
this.craftSlot.setIIcon( -1 );
for( int y = 0; y < 3; y++ )
{
this.addSlotToContainer( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) );
this.outputSlots[y].setRenderDisabled( false );
}
this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) );
this.addSlotToContainer( this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this.getInventoryPlayer() ) );
this.patternSlotOUT.setStackLimit( 1 );
this.bindPlayerInventory( ip, 0, 0 );
this.updateOrderOfOutputSlots();
}
private void updateOrderOfOutputSlots()
{
if( !this.isCraftingMode() )
{
this.craftSlot.xDisplayPosition = -9000;
for( int y = 0; y < 3; y++ )
{
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
}
}
else
{
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
for( int y = 0; y < 3; y++ )
{
this.outputSlots[y].xDisplayPosition = -9000;
}
}
}
@Override
public void putStackInSlot( final int par1, final ItemStack par2ItemStack )
{
super.putStackInSlot( par1, par2ItemStack );
this.getAndUpdateOutput();
}
@Override
public void putStacksInSlots( final ItemStack[] par1ArrayOfItemStack )
{
super.putStacksInSlots( par1ArrayOfItemStack );
this.getAndUpdateOutput();
}
private ItemStack getAndUpdateOutput()
{
final InventoryCrafting ic = new InventoryCrafting( this, 3, 3 );
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
ic.setInventorySlotContents( x, this.crafting.getStackInSlot( x ) );
}
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj );
this.cOut.setInventorySlotContents( 0, is );
return is;
}
@Override
public void saveChanges()
{
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
}
public void encodeAndMoveToInventory()
{
encode();
ItemStack output = this.patternSlotOUT.getStack();
if ( output != null )
{
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
}
}
public void encode()
{
ItemStack output = this.patternSlotOUT.getStack();
final ItemStack[] in = this.getInputs();
final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if( in == null || out == null )
{
return;
}
// first check the output slots, should either be null, or a pattern
if( output != null && !this.isPattern( output ) )
{
return;
}// if nothing is there we should snag a new pattern.
else if( output == null )
{
output = this.patternSlotIN.getStack();
if (!this.isPattern( output ))
{
return; // no blanks.
}
// remove one, and clear the input slot.
output.stackSize--;
if( output.stackSize == 0 )
{
this.patternSlotIN.putStack( null );
}
// add a new encoded pattern.
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
} else if ( output.getItem() instanceof ItemFluidEncodedPattern ) {
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
}
// encode the slot.
final NBTTagCompound encodedValue = new NBTTagCompound();
final NBTTagList tagIn = new NBTTagList();
final NBTTagList tagOut = new NBTTagList();
for( final ItemStack i : in )
{
tagIn.appendTag( this.createItemTag( i ) );
}
for( final ItemStack i : out )
{
tagOut.appendTag( this.createItemTag( i ) );
}
encodedValue.setTag( "in", tagIn );
encodedValue.setTag( "out", tagOut );
encodedValue.setBoolean( "crafting", this.isCraftingMode() );
encodedValue.setBoolean( "substitute", this.isSubstitute() );
output.setTagCompound( encodedValue );
}
private ItemStack[] getInputs()
{
final ItemStack[] input = new ItemStack[9];
boolean hasValue = false;
for( int x = 0; x < this.craftingSlots.length; x++ )
{
input[x] = this.craftingSlots[x].getStack();
if( input[x] != null )
{
hasValue = true;
}
}
if( hasValue )
{
return input;
}
return null;
}
private ItemStack[] getOutputs()
{
if( this.isCraftingMode() )
{
final ItemStack out = this.getAndUpdateOutput();
if( out != null && out.stackSize > 0 )
{
return new ItemStack[] { out };
}
}
else
{
final List<ItemStack> list = new ArrayList<>( 3 );
boolean hasValue = false;
for( final OptionalSlotFake outputSlot : this.outputSlots )
{
final ItemStack out = outputSlot.getStack();
if( out != null && out.stackSize > 0 )
{
list.add( out );
hasValue = true;
}
}
if( hasValue )
{
return list.toArray( new ItemStack[list.size()] );
}
}
return null;
}
private boolean isPattern( final ItemStack output )
{
if( output == null )
{
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs( output );
isPattern |= definitions.materials().blankPattern().isSameAs( output );
return isPattern;
}
private NBTBase createItemTag(final ItemStack i )
{
final NBTTagCompound c = new NBTTagCompound();
if( i != null )
{
i.writeToNBT( c );
}
return c;
}
@Override
public boolean isSlotEnabled( final int idx )
{
if( idx == 1 )
{
return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode();
}
else if( idx == 2 )
{
return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode();
}
else
{
return false;
}
}
public void craftOrGetItem( final PacketPatternSlot packetPatternSlot )
{
if( packetPatternSlot.slotItem != null && this.getCellInventory() != null )
{
final IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorPlayerHand( this.getPlayerInv().player );
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player, ForgeDirection.UNKNOWN );
if( packetPatternSlot.shift )
{
inv = playerInv;
}
if( inv.simulateAdd( out.getItemStack() ) != null )
{
return;
}
final IAEItemStack extracted = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), out, this.getActionSource() );
final EntityPlayer p = this.getPlayerInv().player;
if( extracted != null )
{
inv.addItems( extracted.getItemStack() );
if( p instanceof EntityPlayerMP)
{
this.updateHeld( (EntityPlayerMP) p );
}
this.detectAndSendChanges();
return;
}
final InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
final InventoryCrafting real = new InventoryCrafting( new ContainerNull(), 3, 3 );
for( int x = 0; x < 9; x++ )
{
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack() );
}
final IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
if( r == null )
{
return;
}
final IMEMonitor<IAEItemStack> storage = this.getPatternTerminal().getItemInventory();
final IItemList<IAEItemStack> all = storage.getStorageList();
final ItemStack is = r.getCraftingResult( ic );
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
if( ic.getStackInSlot( x ) != null )
{
final ItemStack pulled = Platform.extractItemsByRecipe( this.getPowerSource(), this.getActionSource(), storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) );
real.setInventorySlotContents( x, pulled );
}
}
final IRecipe rr = Platform.findMatchingRecipe( real, p.worldObj );
if( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) )
{
final SlotCrafting sc = new SlotCrafting( p, real, this.cOut, 0, 0, 0 );
sc.onPickupFromSlot( p, is );
for( int x = 0; x < real.getSizeInventory(); x++ )
{
final ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) );
if( failed != null )
{
p.dropPlayerItemWithRandomChoice( failed, false );
}
}
inv.addItems( is );
if( p instanceof EntityPlayerMP )
{
this.updateHeld( (EntityPlayerMP) p );
}
this.detectAndSendChanges();
}
else
{
for( int x = 0; x < real.getSizeInventory(); x++ )
{
final ItemStack failed = real.getStackInSlot( x );
if( failed != null )
{
this.getCellInventory().injectItems( AEItemStack.create( failed ), Actionable.MODULATE, new MachineSource( this.getPatternTerminal() ) );
}
}
}
}
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
if( Platform.isServer() )
{
if( this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe() )
{
this.setCraftingMode( this.getPatternTerminal().isCraftingRecipe() );
this.updateOrderOfOutputSlots();
}
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine();
}
}
@Override
public void onUpdate( final String field, final Object oldValue, final Object newValue )
{
super.onUpdate( field, oldValue, newValue );
if( field.equals( "craftingMode" ) )
{
this.getAndUpdateOutput();
this.updateOrderOfOutputSlots();
}
}
@Override
public void onSlotChange( final Slot s )
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
for( final Object crafter : this.crafters )
{
final ICrafting icrafting = (ICrafting) crafter;
for( final Object g : this.inventorySlots )
{
if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
{
final Slot sri = (Slot) g;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false;
}
this.detectAndSendChanges();
}
}
public void clear()
{
for( final Slot s : this.craftingSlots )
{
s.putStack( null );
}
for( final Slot s : this.outputSlots )
{
s.putStack( null );
}
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
@Override
public IInventory getInventoryByName( final String name )
{
if( name.equals( "player" ) )
{
return this.getInventoryPlayer();
}
return this.getPatternTerminal().getInventoryByName( name );
}
@Override
public boolean useRealItems()
{
return false;
}
public void toggleSubstitute()
{
this.substitute = !this.substitute;
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
public boolean isCraftingMode()
{
return this.craftingMode;
}
private void setCraftingMode( final boolean craftingMode )
{
this.craftingMode = craftingMode;
}
public PartFluidPatternTerminal getPatternTerminal()
{
return this.patternTerminal;
}
private boolean isSubstitute()
{
return this.substitute;
}
public void setSubstitute( final boolean substitute )
{
this.substitute = substitute;
}
static boolean canDoubleStacks(SlotFake[] slots)
{
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count();
return fullSlots <= emptyStots && emptyStots < enabledSlots.size();
}
static void doubleStacksInternal(SlotFake[] slots)
{
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots)
{
ItemStack st = s.getStack();
if (st == null)
continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2)
fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
}
else if (st.stackSize * 2 > 127)
{
overFlowStacks.add(st.copy());
}
else
{
st.stackSize *= 2;
s.putStack(st);
}
}
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext())
break;
if (s.getStack() != null)
continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
}
public void doubleStacks(boolean isShift)
{
if (!isCraftingMode() && canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots))
{
doubleStacksInternal(this.craftingSlots);
doubleStacksInternal(this.outputSlots);
if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots))
{
while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots))
{
doubleStacksInternal(this.craftingSlots);
doubleStacksInternal(this.outputSlots);
}
}
this.detectAndSendChanges();
}
}
static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count();
return fluid > 0;
}
}
@@ -1,480 +0,0 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.IContainerCraftingPacket;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private static final int CRAFTING_GRID_PAGES = 2;
private static final int CRAFTING_GRID_WIDTH = 4;
private static final int CRAFTING_GRID_HEIGHT = 4;
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
private final PartFluidPatternTerminalEx patternTerminal;
protected final ProcessingSlotFake[] craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final ProcessingSlotFake[] outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync( 96 + (17-9) + 11 )
public boolean combine = false;
@GuiSync( 96 + (17-9) + 12 )
public boolean substitute = false;
@GuiSync( 96 + (17-9) + 16 )
public boolean inverted;
@GuiSync( 96 + (17-9) + 17 )
public int activePage = 0;
@GuiSync( 96 + (17-9) + 13 )
public boolean prioritize = false;
public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable )
{
super( ip, monitorable, false );
this.patternTerminal = (PartFluidPatternTerminalEx) monitorable;
this.inverted = patternTerminal.isInverted();
final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
final IInventory output = this.getPatternTerminal().getInventoryByName( "output" );
IInventory crafting = this.getPatternTerminal().getInventoryByName("crafting");
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.addSlotToContainer(this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(crafting, this, x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS, 15, -83, x, y, x + 4));
}
}
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
this.addSlotToContainer(this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(output, this, x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS, 112, -83, -x, y, x));
}
}
}
this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) );
this.addSlotToContainer( this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this.getInventoryPlayer() ) );
this.patternSlotOUT.setStackLimit( 1 );
this.bindPlayerInventory( ip, 0, 0 );
}
@Override
public void saveChanges()
{
}
public void clear()
{
for( final Slot s : this.craftingSlots )
{
s.putStack( null );
}
for( final Slot s : this.outputSlots )
{
s.putStack( null );
}
this.detectAndSendChanges();
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
}
public void encodeAndMoveToInventory()
{
encode();
ItemStack output = this.patternSlotOUT.getStack();
if ( output != null )
{
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
}
}
public void encode()
{
ItemStack output = this.patternSlotOUT.getStack();
final ItemStack[] in = this.getInputs();
final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if( in == null || out == null )
{
return;
}
// first check the output slots, should either be null, or a pattern
if( output != null && !this.isPattern( output ) )
{
return;
}// if nothing is there we should snag a new pattern.
else if( output == null )
{
output = this.patternSlotIN.getStack();
if (!this.isPattern( output ))
{
return; // no blanks.
}
// remove one, and clear the input slot.
output.stackSize--;
if( output.stackSize == 0 )
{
this.patternSlotIN.putStack( null );
}
// add a new encoded pattern.
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
} else if ( output.getItem() instanceof ItemFluidEncodedPattern ) {
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
}
// encode the slot.
final NBTTagCompound encodedValue = new NBTTagCompound();
final NBTTagList tagIn = new NBTTagList();
final NBTTagList tagOut = new NBTTagList();
for( final ItemStack i : in )
{
tagIn.appendTag( this.createItemTag( i ) );
}
for( final ItemStack i : out )
{
tagOut.appendTag( this.createItemTag( i ) );
}
encodedValue.setTag( "in", tagIn );
encodedValue.setTag( "out", tagOut );
encodedValue.setBoolean( "substitute", this.isSubstitute() );
encodedValue.setTag( "in", tagIn );
encodedValue.setTag( "out", tagOut );
encodedValue.setBoolean( "prioritize", this.isPrioritize() );
output.setTagCompound( encodedValue );
}
private ItemStack[] getInputs()
{
final ItemStack[] input = new ItemStack[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
boolean hasValue = false;
for( int x = 0; x < this.craftingSlots.length; x++ )
{
input[x] = this.craftingSlots[x].getStack();
if( input[x] != null )
{
hasValue = true;
}
}
if( hasValue )
{
return input;
}
return null;
}
private ItemStack[] getOutputs()
{
final List<ItemStack> list = new ArrayList<>( CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES );
boolean hasValue = false;
for( final OptionalSlotFake outputSlot : this.outputSlots )
{
final ItemStack out = outputSlot.getStack();
if( out != null && out.stackSize > 0 )
{
list.add( out );
hasValue = true;
}
}
if( hasValue )
{
return list.toArray(new ItemStack[0]);
}
return null;
}
private boolean isPattern( final ItemStack output )
{
if( output == null )
{
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs( output );
isPattern |= definitions.materials().blankPattern().isSameAs( output );
return isPattern;
}
private NBTBase createItemTag(final ItemStack i )
{
final NBTTagCompound c = new NBTTagCompound();
if( i != null )
{
i.writeToNBT( c );
}
return c;
}
@Override
public boolean isSlotEnabled( final int idx )
{
if (idx < 4) // outputs
{
return inverted || idx == 0;
}
else
{
return !inverted || idx == 4;
}
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
if( Platform.isServer() )
{
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine(); //Check out
this.prioritize = this.patternTerminal.isPrioritize();
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
inverted = patternTerminal.isInverted();
activePage = patternTerminal.getActivePage();
offsetSlots();
}
}
}
private void offsetSlots()
{
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && inverted);
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && !inverted);
}
}
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue) {
super.onUpdate( field, oldValue, newValue );
if (field.equals( "inverted" ) || field.equals( "activePage" )) {
offsetSlots();
}
}
@Override
public void onSlotChange( final Slot s )
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
inverted = patternTerminal.isInverted();
for( final Object crafter : this.crafters )
{
final ICrafting icrafting = (ICrafting) crafter;
for( final Object g : this.inventorySlots )
{
if( g instanceof OptionalSlotFake )
{
final Slot sri = (Slot) g;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false;
}
this.detectAndSendChanges();
}
}
@Override
public IInventory getInventoryByName( final String name )
{
if( name.equals( "player" ) )
{
return this.getInventoryPlayer();
}
return this.getPatternTerminal().getInventoryByName( name );
}
@Override
public boolean useRealItems()
{
return false;
}
public PartFluidPatternTerminalEx getPatternTerminal()
{
return this.patternTerminal;
}
private boolean isSubstitute()
{
return this.substitute;
}
private boolean isPrioritize() { return this.prioritize; }
static boolean canDoubleStacks(SlotFake[] slots)
{
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count();
return fullSlots <= emptyStots;
}
static void doubleStacksInternal(SlotFake[] slots)
{
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots)
{
ItemStack st = s.getStack();
if (st == null)
continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2)
fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
}
else if (st.stackSize * 2 > 127)
{
overFlowStacks.add(st.copy());
}
else
{
st.stackSize *= 2;
s.putStack(st);
}
}
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext())
break;
if (s.getStack() != null)
continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
}
public void doubleStacks(boolean isShift)
{
if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots))
{
doubleStacksInternal(this.craftingSlots);
doubleStacksInternal(this.outputSlots);
if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots))
{
while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots))
{
doubleStacksInternal(this.craftingSlots);
doubleStacksInternal(this.outputSlots);
}
}
this.detectAndSendChanges();
}
}
static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count();
return fluid > 0;
}
public void setActivePage(final int activePage) {
this.activePage = activePage;
}
public int getActivePage() {
return this.activePage;
}
}
@@ -1,12 +0,0 @@
package com.glodblock.github.client.gui.container;
import akka.actor.Status;
import java.lang.reflect.Type;
public enum FluidPrioritization {
ENABLED,
DISABLED;
}
@@ -0,0 +1,62 @@
package com.glodblock.github.client.gui.container.base;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.util.Util;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
public abstract class FCBaseContainer extends AEBaseContainer {
private int ticks;
private final double powerMultiplier = 0.5;
private IFluidPortableCell host;
private int slot = -1;
private final InventoryPlayer ip;
public FCBaseContainer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.ip = ip;
if (isWirelessTerminal()) {
host = (IFluidPortableCell) monitorable;
this.slot = lockSlot();
}
}
private int lockSlot() {
if (isWirelessTerminal()) {
if (this.host != null) {
final int slotIndex = this.host.getInventorySlot();
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
return slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
}
}
return -1;
}
protected abstract boolean isWirelessTerminal();
public void detectAndSendChanges() {
if (isWirelessTerminal()) {
this.ticks = Util.drainItemPower(
this,
this.getPlayerInv(),
this.slot,
this.ticks,
this.getPowerMultiplier(),
this.host);
}
super.detectAndSendChanges();
}
public double getPowerMultiplier() {
return this.powerMultiplier;
}
}
@@ -0,0 +1,605 @@
package com.glodblock.github.client.gui.container.base;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
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;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.IPatternConsumer;
import com.glodblock.github.inventory.item.IItemPatternTerminal;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket, IPatternConsumer {
protected final IItemPatternTerminal patternTerminal;
protected final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
protected final IInventory crafting;
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
protected SlotFake[] craftingSlots;
protected OptionalSlotFake[] outputSlots;
protected SlotPatternTerm craftSlot;
@GuiSync(97)
public boolean craftingMode = true;
@GuiSync(96)
public boolean substitute = false;
@GuiSync(95)
public boolean combine = false;
@GuiSync(94)
public boolean beSubstitute = false;
@GuiSync(93)
public boolean inverted;
@GuiSync(92)
public int activePage = 0;
@GuiSync(91)
public boolean prioritize = false;
@GuiSync(90)
public boolean autoFillPattern = false;
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
this.patternTerminal = (IItemPatternTerminal) monitorable;
this.inverted = patternTerminal.isInverted();
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
this.crafting = this.patternTerminal.getInventoryByName("crafting");
this.addSlotToContainer(
this.patternSlotIN = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
patternInv,
0,
147,
-72 - 9,
this.getInventoryPlayer()));
this.addSlotToContainer(
this.patternSlotOUT = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
patternInv,
1,
147,
-72 + 34,
this.getInventoryPlayer()));
this.patternSlotOUT.setStackLimit(1);
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (this.isCraftingMode()) {
super.doAction(player, action, slotId, id);
return;
}
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.MOVE_REGION, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if (validPatternSlot(slot)
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN -> {
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
}
case SPLIT_OR_PLACE_SINGLE -> {
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
}
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
super.doAction(player, action, slotId, id);
}
protected abstract boolean validPatternSlot(Slot slot);
@Override
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
ItemStack is = clickSlot.getStack();
if (is != null && !patternSlotOUT.getHasStack()
&& is.stackSize == 1
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
ItemStack output = is.copy();
patternSlotOUT.putStack(output);
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
this.detectAndSendChanges();
return null;
} else {
return super.transferStackInSlot(p, idx);
}
}
public IItemPatternTerminal getPatternTerminal() {
return this.patternTerminal;
}
protected static boolean canDoubleStacks(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptySlots = enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream().filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127)
.count();
return fullSlots <= emptySlots;
}
protected static void doubleStacksInternal(SlotFake[] slots) {
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots) {
ItemStack st = s.getStack();
if (st == null) continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2) fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
} else if (st.stackSize * 2 > 127) {
overFlowStacks.add(st.copy());
} else {
st.stackSize *= 2;
s.putStack(st);
}
}
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext()) break;
if (s.getStack() != null) continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
}
protected static boolean containsItem(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long item = enabledSlots.stream().filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack()))
.count();
return item > 0;
}
protected static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count();
return fluid > 0;
}
protected static boolean nonNullSlot(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long object = enabledSlots.stream().filter(s -> s.getStack() != null).count();
return object > 0;
}
protected boolean checkHasFluidPattern() {
if (this.craftingMode) {
return false;
}
boolean hasFluid = containsFluid(this.craftingSlots);
boolean search = nonNullSlot(this.craftingSlots);
if (!search) { // search=false -> inputs were empty
return false;
}
hasFluid |= containsFluid(this.outputSlots);
search = nonNullSlot(this.outputSlots);
return hasFluid && search; // search=false -> outputs were empty
}
protected ItemStack stampAuthor(ItemStack patternStack) {
if (patternStack.stackTagCompound == null) {
patternStack.stackTagCompound = new NBTTagCompound();
}
patternStack.stackTagCompound.setString("author", getPlayerInv().player.getCommandSenderName());
return patternStack;
}
protected void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(this.craftingSlots));
pattern.setOutputs(collectInventory(this.outputSlots));
pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(stampAuthor(pattern.writeToStack()));
}
protected static IAEItemStack[] collectInventory(Slot[] slots) {
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
stacks[i] = aeStack;
}
return stacks;
}
@Override
public void saveChanges() {
// NO-OP
}
public void clear() {
for (final Slot s : this.craftingSlots) {
s.putStack(null);
}
for (final Slot s : this.outputSlots) {
s.putStack(null);
}
this.detectAndSendChanges();
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
final ItemStack removedStack, final ItemStack newStack) {
// NO-OP
}
public void encodeAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if (output != null) {
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack(null);
}
fillPattern();
}
public void encodeAllItemAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if (output != null) {
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
fillPattern();
}
private void fillPattern() {
if (this.autoFillPattern && this.getHost().getItemInventory() != null) {
// try to use me network item to fill pattern input slot
final IDefinitions definitions = AEApi.instance().definitions();
int fillStackSize = this.patternSlotIN.getHasStack() ? 64 - this.patternSlotIN.getStack().stackSize : 64;
if (fillStackSize == 0) return;
for (ItemStack blankPattern : definitions.materials().blankPattern().maybeStack(fillStackSize).asSet()) {
IAEItemStack iBlankPattern = AEApi.instance().storage().createItemStack(blankPattern);
if (this.patternSlotIN.getHasStack() && !iBlankPattern.isSameType(this.patternSlotIN.getStack()))
continue;
IAEItemStack out = this.getHost().getItemInventory()
.extractItems(iBlankPattern, Actionable.MODULATE, this.getActionSource());
if (out != null) {
ItemStack outPattern;
if (this.patternSlotIN.getHasStack()) {
outPattern = this.patternSlotIN.getStack().copy();
outPattern.stackSize += out.getItemStack().stackSize;
} else {
outPattern = out.getItemStack();
}
this.patternSlotIN.putStack(outPattern);
return;
}
}
}
}
public void encode() {
fillPattern();
if (!checkHasFluidPattern()) {
encodeItemPattern();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack == null) {
stack = this.patternSlotIN.getStack();
if (notPattern(stack)) {
return;
}
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize--;
}
encodeFluidPattern();
} else if (!notPattern(stack)) {
encodeFluidPattern();
}
}
public void encodeItemPattern() {
ItemStack output = this.patternSlotOUT.getStack();
final ItemStack[] in = this.getInputs();
final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if (in == null || out == null) {
return;
}
// first check the output slots, should either be null, or a pattern
if (output != null && this.notPattern(output)) {
return;
} // if nothing is there we should snag a new pattern.
else if (output == null) {
output = this.patternSlotIN.getStack();
if (this.notPattern(output)) {
return; // no blanks.
}
// remove one, and clear the input slot.
output.stackSize--;
if (output.stackSize == 0) {
this.patternSlotIN.putStack(null);
}
// add a new encoded pattern.
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern()
.maybeStack(1).asSet()) {
output = encodedPatternStack;
}
} else if (output.getItem() instanceof ItemFluidEncodedPattern) {
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern()
.maybeStack(1).asSet()) {
output = encodedPatternStack;
}
}
// encode the slot.
final NBTTagCompound encodedValue = new NBTTagCompound();
final NBTTagList tagIn = new NBTTagList();
final NBTTagList tagOut = new NBTTagList();
for (final ItemStack i : in) {
tagIn.appendTag(this.createItemTag(i));
}
for (final ItemStack i : out) {
tagOut.appendTag(this.createItemTag(i));
}
encodedValue.setTag("in", tagIn);
encodedValue.setTag("out", tagOut);
encodedValue.setBoolean("crafting", this.craftingMode);
encodedValue.setBoolean("substitute", this.substitute);
encodedValue.setBoolean("beSubstitute", this.beSubstitute);
encodedValue.setBoolean("prioritize", this.prioritize);
output.setTagCompound(encodedValue);
stampAuthor(output);
this.patternSlotOUT.putStack(output);
}
protected ItemStack[] getInputs() {
final ArrayList<ItemStack> input = new ArrayList<>();
for (SlotFake craftingSlot : this.craftingSlots) {
input.add(craftingSlot.getStack());
}
if (input.stream().anyMatch(Objects::nonNull)) {
return input.toArray(new ItemStack[0]);
}
return null;
}
protected ItemStack[] getOutputs() {
final ArrayList<ItemStack> output = new ArrayList<>();
for (final SlotFake outputSlot : this.outputSlots) {
output.add(outputSlot.getStack());
}
if (output.stream().anyMatch(Objects::nonNull)) {
return output.toArray(new ItemStack[0]);
}
return null;
}
protected boolean notPattern(final ItemStack output) {
if (output == null) {
return true;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return false;
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
isPattern |= definitions.materials().blankPattern().isSameAs(output);
return !isPattern;
}
protected NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
}
return c;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isServer()) {
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
this.autoFillPattern = this.patternTerminal.isAutoFillPattern();
}
}
@Override
public void onSlotChange(final Slot s) {
if (s == this.patternSlotOUT && Platform.isServer()) {
for (final Object crafter : this.crafters) {
final ICrafting icrafting = (ICrafting) crafter;
for (final Object g : this.inventorySlots) {
if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) {
final Slot sri = (Slot) g;
icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack());
}
}
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
}
this.detectAndSendChanges();
}
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("player")) {
return this.getInventoryPlayer();
}
return this.patternTerminal.getInventoryByName(name);
}
@Override
public boolean useRealItems() {
return false;
}
static boolean canDouble(SlotFake[] slots, int mult) {
for (Slot s : slots) {
ItemStack st = s.getStack();
if (st != null) {
if (st.getItem() instanceof ItemFluidPacket) {
long result = (long) ItemFluidPacket.getFluidAmount(st) * mult;
if (result > Integer.MAX_VALUE) {
return false;
}
} else {
long result = (long) s.getStack().stackSize * mult;
if (result > Integer.MAX_VALUE) {
return false;
}
}
}
}
return true;
}
static void doubleStacksInternal(SlotFake[] slots, int mult) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots) {
ItemStack st = s.getStack();
if (st != null) {
if (st.getItem() instanceof ItemFluidPacket) {
ItemFluidPacket.setFluidAmount(st, ItemFluidPacket.getFluidAmount(st) * mult);
} else {
st.stackSize *= mult;
}
}
}
}
public void doubleStacks(boolean isShift) {
if (!isCraftingMode()) {
if (isShift) {
if (canDouble(this.craftingSlots, 8) && canDouble(this.outputSlots, 8)) {
doubleStacksInternal(this.craftingSlots, 8);
doubleStacksInternal(this.outputSlots, 8);
}
} else {
if (canDouble(this.craftingSlots, 2) && canDouble(this.outputSlots, 2)) {
doubleStacksInternal(this.craftingSlots, 2);
doubleStacksInternal(this.outputSlots, 2);
}
}
this.detectAndSendChanges();
}
}
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (this.patternTerminal != null) {
this.patternTerminal.onChangeCrafting(inputs, outputs);
}
}
public boolean isCraftingMode() {
return this.craftingMode;
}
}
@@ -0,0 +1,120 @@
package com.glodblock.github.client.gui.container.base;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Util;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.slot.AppEngSlot;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
public abstract class FCContainerFluidConfigurable extends ContainerUpgradeable {
public FCContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) {
super(ip, te);
}
public abstract AppEngInternalAEInventory getFakeFluidInv();
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx);
if (clickSlot == null || !clickSlot.getHasStack()) return null;
ItemStack tis = clickSlot.getStack();
FluidStack fs = Util.getFluidFromItem(tis);
if (fs != null) {
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final IAEFluidStack stack = AEFluidStack.create(fs);
for (int i = 0; i < inv.getSizeInventory(); ++i) {
if (inv.getStackInSlot(i) == null && this.isValidForConfig(i, stack)) {
ItemStack tmp = ItemFluidPacket.newStack(fs);
if (tmp != null) {
tmp.setStackDisplayName(fs.getLocalizedName());
}
inv.setInventorySlotContents(i, tmp);
break;
}
}
this.standardDetectAndSendChanges();
return null;
} else {
return super.transferStackInSlot(p, idx);
}
}
protected void setupConfig() {
this.setupUpgrades();
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName("config");
final int y = 40;
final int x = 80;
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, x, y, 0, 0, 0));
if (this.supportCapacity()) {
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 1, x, y, -1, 0, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 2, x, y, 1, 0, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 3, x, y, 0, -1, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 4, x, y, 0, 1, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 5, x, y, -1, -1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 6, x, y, 1, -1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 7, x, y, -1, 1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 8, x, y, 1, 1, 2));
}
}
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
// assumes 4 slots per upgrade
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
if (slot > 0 && upgrades < 1) {
return false;
}
return slot <= 4 || upgrades >= 2;
}
return true;
}
@Override
protected void standardDetectAndSendChanges() {
if (Platform.isServer()) {
// clear out config items that are no longer valid (for instance, capacity upgrade removed)
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
if (inv.getStackInSlot(i) != null && !this.isValidForConfig(
i,
AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot(i))))) {
inv.setInventorySlotContents(i, null);
}
tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot(i))));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
super.standardDetectAndSendChanges();
}
}
@@ -0,0 +1,236 @@
package com.glodblock.github.client.gui.container.base;
import java.io.IOException;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.TypeFilter;
import appeng.api.config.ViewItems;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<T> {
protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
protected final IConfigManager clientCM;
protected final ITerminalHost host;
@GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync(98)
public boolean hasPower = false;
protected IConfigManagerHost gui;
protected IConfigManager serverCM;
protected IGridNode networkNode;
protected IMEMonitor<T> monitor;
public FCContainerMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected FCContainerMonitor(final InventoryPlayer ip, final ITerminalHost monitorable,
final boolean bindInventory) {
super(ip, monitorable);
this.host = monitorable;
this.clientCM = new ConfigManager(this);
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
this.clientCM.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
}
public IMEMonitor<T> getMonitor() {
return this.monitor;
}
public IGridNode getNetworkNode() {
return this.networkNode;
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
if (isInvalid()) {
this.setValidContainer(false);
}
if (this.serverCM != null) {
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
if (sideLocal != sideRemote) {
this.clientCM.putSetting(set, sideLocal);
for (final Object crafter : this.crafters) {
try {
NetworkHandler.instance.sendTo(
new PacketValueConfig(set.name(), sideLocal.name()),
(EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
}
}
}
}
}
processItemList();
this.updatePowerStatus();
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells = this.host instanceof WirelessTerminalGuiObject
|| this.host instanceof IWirelessTerminal
|| this.hasAccess(SecurityPermissions.BUILD, false);
if (this.canAccessViewCells != oldAccessible) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
super.detectAndSendChanges();
}
}
protected abstract void processItemList();
protected boolean isInvalid() {
return this.monitor == null;
}
protected void updatePowerStatus() {
try {
if (this.networkNode != null) {
this.setPowered(this.networkNode.isActive());
} else if (this.getPowerSource() instanceof IEnergyGrid) {
this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered());
} else {
this.setPowered(
this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
}
} catch (final Throwable ignore) {}
}
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
if (field.equals("canAccessViewCells")) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
super.onUpdate(field, oldValue, newValue);
}
@Override
public void addCraftingToCrafters(final ICrafting c) {
super.addCraftingToCrafters(c);
this.queueInventory(c);
}
protected abstract void queueInventory(final ICrafting c);
@Override
public void onContainerClosed(final EntityPlayer player) {
super.onContainerClosed(player);
if (this.monitor != null) {
this.monitor.removeListener(this);
if (player instanceof EntityPlayerMP && Platform.isServer()) {
SPacketMEUpdateBuffer.clear((EntityPlayerMP) player);
}
}
}
@Override
public IConfigManager getConfigManager() {
if (Platform.isServer()) {
return this.serverCM;
}
return this.clientCM;
}
public ItemStack[] getViewCells() {
final ItemStack[] list = new ItemStack[this.cellView.length];
for (int x = 0; x < this.cellView.length; x++) {
list[x] = this.cellView[x].getStack();
}
return list;
}
public SlotRestrictedInput getCellViewSlot(final int index) {
return this.cellView[index];
}
public boolean isPowered() {
return this.hasPower;
}
protected void setPowered(final boolean isPowered) {
this.hasPower = isPowered;
}
protected IConfigManagerHost getGui() {
return this.gui;
}
public void setGui(@Nonnull final IConfigManagerHost gui) {
this.gui = gui;
}
@Override
public boolean isValid(Object verificationToken) {
return true;
}
@Override
public void onListUpdate() {
for (final Object c : this.crafters) {
if (c instanceof final ICrafting cr) {
this.queueInventory(cr);
}
}
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.getGui() != null) {
this.getGui().updateSetting(manager, settingName, newValue);
}
}
public ITerminalHost getHost() {
return this.host;
}
}
@@ -0,0 +1,126 @@
package com.glodblock.github.client.me;
import java.util.Iterator;
import java.util.regex.Pattern;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
import com.glodblock.github.util.FluidSorters;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.IScrollSource;
import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig;
public class EssentiaRepo extends FluidRepo {
public EssentiaRepo(final IScrollSource src, final ISortSource sortSrc) {
super(src, sortSrc);
}
@Override
public void updateView() {
this.view.clear();
this.dsp.clear();
this.view.ensureCapacity(this.list.size());
this.dsp.ensureCapacity(this.list.size());
final Enum<?> viewMode = this.sortSrc.getSortDisplay();
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
this.updateNEI(this.searchString);
}
String innerSearch = this.searchString;
if (innerSearch.startsWith("@")) {
innerSearch = innerSearch.substring(1);
}
Pattern m;
try {
m = Pattern.compile(innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
} catch (final Throwable ignore) {
try {
m = Pattern.compile(Pattern.quote(innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
} catch (final Throwable __) {
return;
}
}
for (IAEItemStack is : this.list) {
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
continue;
}
}
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
continue;
}
if (viewMode == ViewItems.CRAFTABLE) {
is = is.copy();
is.setStackSize(0);
}
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
continue;
}
Fluid fluid = ItemFluidDrop.getAeFluidStack(is).getFluid();
if (!AspectUtil.isEssentiaGas(fluid)) {
continue;
}
if (m.matcher(fluid.getLocalizedName().toLowerCase()).find()) {
this.view.add(is);
}
}
final Enum<?> SortBy = this.sortSrc.getSortBy();
final Enum<?> SortDir = this.sortSrc.getSortDir();
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
FluidSorters.init();
if (SortBy == SortOrder.MOD) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
} else if (SortBy == SortOrder.AMOUNT) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
} else if (SortBy == SortOrder.INVTWEAKS) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
} else {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
}
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
Iterator<IAEItemStack> it1 = this.view.iterator();
while (it1.hasNext()) {
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(it1.next());
if (!AspectUtil.isEssentiaGas(fluid)) {
it1.remove();
}
}
Iterator<ItemStack> it2 = this.dsp.iterator();
while (it2.hasNext()) {
FluidStack fluid = ItemFluidDrop.getFluidStack(it2.next());
if (!AspectUtil.isEssentiaGas(fluid)) {
it2.remove();
}
}
}
}
@@ -0,0 +1,247 @@
/*
* 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.client.me;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.util.FluidSorters;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IDisplayRepo;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.widgets.IScrollSource;
import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig;
import appeng.items.storage.ItemViewCell;
import appeng.util.prioitylist.IPartitionList;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class FluidRepo implements IDisplayRepo {
protected final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
protected final ArrayList<IAEItemStack> view = new ArrayList<>();
protected final ArrayList<ItemStack> dsp = new ArrayList<>();
protected final IScrollSource src;
protected final ISortSource sortSrc;
protected int rowSize = 9;
protected String searchString = "";
protected IPartitionList<IAEItemStack> myPartitionList;
private String NEIWord = null;
private boolean hasPower;
public FluidRepo(final IScrollSource src, final ISortSource sortSrc) {
this.src = src;
this.sortSrc = sortSrc;
}
@Override
public IAEItemStack getReferenceItem(int idx) {
idx += this.src.getCurrentScroll() * this.rowSize;
if (idx >= this.view.size()) {
return null;
}
return this.view.get(idx);
}
@Override
public ItemStack getItem(int idx) {
idx += this.src.getCurrentScroll() * this.rowSize;
if (idx >= this.dsp.size()) {
return null;
}
return this.dsp.get(idx);
}
@Override
public void postUpdate(final IAEItemStack is) {
final IAEItemStack st = this.list.findPrecise(is);
if (st != null) {
st.reset();
st.add(is);
} else {
this.list.add(is);
}
}
@Override
public void setViewCell(final ItemStack[] list) {
this.myPartitionList = ItemViewCell.createFilter(list);
this.updateView();
}
@Override
public void updateView() {
this.view.clear();
this.dsp.clear();
this.view.ensureCapacity(this.list.size());
this.dsp.ensureCapacity(this.list.size());
final Enum<?> viewMode = this.sortSrc.getSortDisplay();
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
this.updateNEI(this.searchString);
}
String innerSearch = this.searchString;
boolean searchMod = false;
if (innerSearch.startsWith("@")) {
searchMod = true;
innerSearch = innerSearch.substring(1);
}
Pattern m;
try {
m = Pattern.compile(innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
} catch (final Throwable ignore) {
try {
m = Pattern.compile(Pattern.quote(innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
} catch (final Throwable __) {
return;
}
}
for (IAEItemStack is : this.list) {
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
continue;
}
}
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
continue;
}
if (viewMode == ViewItems.CRAFTABLE) {
is = is.copy();
is.setStackSize(0);
}
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
continue;
}
Fluid fluid = ItemFluidDrop.getAeFluidStack(is).getFluid();
if (FluidCraftAPI.instance().isBlacklistedInDisplay(fluid.getClass())) {
continue;
}
if (searchMod) {
if (m.matcher(Util.getFluidModID(fluid).toLowerCase()).find()
|| m.matcher(Util.getFluidModName(fluid).toLowerCase()).find()) {
this.view.add(is);
}
} else {
if (m.matcher(fluid.getLocalizedName().toLowerCase()).find()) {
this.view.add(is);
}
}
}
final Enum<?> SortBy = this.sortSrc.getSortBy();
final Enum<?> SortDir = this.sortSrc.getSortDir();
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
FluidSorters.init();
if (SortBy == SortOrder.MOD) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
} else if (SortBy == SortOrder.AMOUNT) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
} else if (SortBy == SortOrder.INVTWEAKS) {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
} else {
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
}
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
}
protected void updateNEI(final String filter) {
try {
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
final Class<?> c = ReflectionHelper
.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
final Field fldSearchField = c.getField("searchField");
final Object searchField = fldSearchField.get(c);
final Method a = searchField.getClass().getMethod("setText", String.class);
final Method b = searchField.getClass().getMethod("onTextChange", String.class);
this.NEIWord = filter;
a.invoke(searchField, filter);
b.invoke(searchField, "");
}
} catch (final Throwable ignore) {
}
}
@Override
public int size() {
return this.view.size();
}
@Override
public void clear() {
this.list.resetStatus();
}
@Override
public boolean hasPower() {
return this.hasPower;
}
@Override
public void setPowered(final boolean hasPower) {
this.hasPower = hasPower;
}
public int getRowSize() {
return this.rowSize;
}
public void setRowSize(final int rowSize) {
this.rowSize = rowSize;
}
public String getSearchString() {
return this.searchString;
}
public void setSearchString(@Nonnull final String searchString) {
this.searchString = searchString;
}
}
Loaded 100 of 430 files, more files were not shown because too many files have changed in this diff. Show more