Compare commits

...
Author SHA1 Message Date
Martin Robertz 11868c9f3a update 2025-04-02 08:07:47 +02:00
Martin Robertz 76d3c3c880 Merge remote-tracking branch 'lordIcocain/fix-for-gui-amount' into dev 2025-04-02 08:07:20 +02:00
lordIcocain 38c5af6079 1st commit 2025-04-02 08:07:46 +03:00
Martin Robertz a110560099 Merge remote-tracking branch 'origin/creativecellcapacity' into dev 2025-03-31 19:37:18 +02:00
StaffiX 6c3106c001 Change creative water cell capacity to 2^52-1 2025-03-31 19:28:39 +02:00
Martin Robertz 77d694d097 update 2025-03-29 11:06:54 +01:00
Martin Robertz 85c56a0552 Merge remote-tracking branch 'lordIcocain/magnet-and-restock' into dev 2025-03-29 11:06:27 +01:00
Martin Robertz dc542e9a90 Merge remote-tracking branch 'C0bra5/sink-issue-fix' into dev 2025-03-29 11:06:24 +01:00
lordIcocain e37a24a861 1st commit 2025-03-29 04:37:30 +02:00
Guillaume Mercier bde2c04322 cleanup decompiled code
I'm honestly surprised this hasn't caused some sort of concurrency issue yet.
2025-03-25 21:38:02 -04:00
Guillaume Mercier ba822d614d Add chat log to help stop future dupes early
This will make it easier for players to report potential dupes in the future.
2025-03-25 21:35:50 -04:00
Guillaume Mercier 4b66de3ddb Add one time log if removed fluid isn't the same as the requested fluid.
This should help us diagnose similar issues in the future.
2025-03-25 21:33:23 -04:00
Guillaume Mercier 5d2b7cd305 fix unintentional voiding
thx cocain
2025-03-25 18:13:57 -04:00
Martin Robertz 750d0d90e8 update 2025-03-25 18:27:18 +01:00
Martin Robertz d5885cb599 Merge remote-tracking branch 'guid118/master' into dev 2025-03-25 18:26:38 +01:00
Martin Robertz 676d44c112 Merge remote-tracking branch 'jurrejelle/fix-fluid-partition' into dev 2025-03-25 18:26:34 +01:00
guid118 0f7a126417 made ItemBaseWirelessTerminal.canHandle null-safe 2025-03-25 17:01:27 +01:00
Jurre Groenendijk 766b289246 Partition fluids with size 0 2025-03-24 08:06:37 +01:00
Martin Robertz efd579bfae update 2025-03-23 13:06:01 +01:00
Guillaume Mercier b0583a32cb Make the fluid monitor more resilient.
- Add checks via the can drain and can fill methods of fluid tanks to prevent dupe bugs like the one encountered with the blockhead sink

the blockhead sink doesn't check the fluid passed to it during the drain or fill calls so it ended up draining itself instead of the required fluid when ever it was working

Adding some some sort of logging if the fluid extracted and the fluid requested aren't the same would be a good idea, and since there is no caching from the simulate phase, it's going to have to be done in both phases. It shouldn't just void the output though since the changes will have already been applied to the tank by the time we void out the values and we can't assume the fill function would work properly if the drain doesn't.
2025-03-22 23:12:20 -04:00
Maya a7f00c1830 update 2025-03-22 09:42:35 -05:00
Kogepan229andMaya 2f8d51183d Fix terminal key bindings for mouse (#270)
Co-authored-by: Maya <[email protected]>
2025-03-22 14:41:57 +00:00
Martin Robertz 21794f5a9f update 2025-03-20 15:24:04 +01:00
Kogepan229 a4bf54f1b9 Fix an issue that GT and AE2FC fluids could not be used with Creative Fluid Cell (#271) 2025-03-20 10:49:31 +00:00
Maya 546d2f504b update 2025-02-28 13:08:01 -06:00
Maya 23e80c7dd9 Fix fluid containers with null empty items not deleting in fluid terminal (#267) 2025-02-28 13:07:11 -06:00
Maya 8b61980087 update 2025-02-22 22:30:29 -06:00
Zoltán Szepesi d78618d950 Read NBT tags combine and beSubstitute from ItemStack when converting them to FluidPattern (#268) 2025-02-22 22:30:19 -06:00
Martin Robertz e88af75f40 update 2025-02-14 12:23:25 +01:00
Martin Robertz 7b8d87477b convert to long like in ae2 code 2025-02-14 12:22:38 +01:00
Maya 149b9e36ba update 2025-02-14 00:26:30 -06:00
JuliaandJulia Dijkstra b14bded93c Improve ME Fluid Auto Filler Performance (#266)
Co-authored-by: Julia Dijkstra <[email protected]>
2025-02-14 06:24:26 +00:00
lordIcocainandMaya bedb2c25e1 No more drop drops from interface (#265)
Co-authored-by: Maya <[email protected]>
2025-01-26 19:01:35 +00:00
0908e906d2 Option to restrict fluid cell (#263)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-01-25 22:13:40 +00:00
Martin Robertz 3ff53243da update 2025-01-24 21:16:57 +01:00
lordIcocain c853dbc30d Allow exotic cells use upgrade cards (#264) 2025-01-23 17:26:37 -06:00
Martin Robertz 188d1ff4c1 update 2025-01-18 22:23:44 +01:00
lordIcocain 31a5decaeb Add Support Void and Distribution card for cells and increase card limit for cells (#262) 2025-01-17 11:48:52 -06:00
Dream Master d184c30d1f update 2025-01-15 12:17:01 +01:00
9fbea64d8d Fixed essentia level maintaining (#245)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
Co-authored-by: lailani-f <[email protected]>
2025-01-14 11:15:13 +01:00
lordIcocain 353b9a4191 Add fluid pattern support to fake crafting card (#260) 2025-01-13 17:04:45 -06:00
1d5abe027c Fix/same network multiple extract only storage buses (#244)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-01-13 00:47:55 -06:00
49402e3474 [Feature] Shift to pause terminal view movement (#256)
Co-authored-by: Caedis <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-01-13 00:43:56 -06:00
Maya b690089c68 update 2025-01-13 00:39:37 -06:00
Martin Robertz 5079ba1d70 update 2025-01-12 12:28:27 +01:00
Maya 4a5e763170 Add cell + pattern disassemble recipes like AE2 (#257) 2025-01-10 11:19:06 -06:00
Martin Robertz f931911381 update 2025-01-09 21:08:24 +01:00
5b0d356fe5 x2 button funtional for fluid pattern terminals. And varions fixes. (#252)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Alexdoru <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-01-09 11:47:53 +00:00
Martin Robertz 3489be7d54 update 2025-01-05 12:48:12 +01:00
0b67a8a4e7 Scalable Walrus (#248)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-01-04 15:48:13 -07:00
Martin Robertz d8de0e8f27 update 2025-01-04 16:13:07 +01:00
03538d3338 Add class dump args (#239)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-01-04 04:34:09 +00:00
Martin Robertz b84ed01a02 update 2025-01-03 21:41:52 +01:00
lordIcocain 6acffd220e Fix npe on fluid conduit connected check (#255) 2025-01-02 22:45:18 +01:00
Martin Robertz 954f5eec37 update 2024-12-31 14:01:51 +01:00
lordIcocainandMaya 319dcc95df Prevent Universal Wireless crafting terminal void items. (#254)
Co-authored-by: Maya <[email protected]>
2024-12-30 21:16:00 -06:00
Martin Robertz b663d87801 update 2024-12-30 20:56:51 +01:00
glowredman 0df88f2305 Cleanup (#253) 2024-12-29 19:51:31 -06:00
Martin Robertz 4a39cf4ece update 2024-12-27 10:16:39 +01:00
lordIcocainandMartin Robertz e0aed44bcf Skip this side check if fluid conduit not connected. (#249)
Co-authored-by: Martin Robertz <[email protected]>
2024-12-26 16:11:02 -06:00
Maya 55f48a98f4 update 2024-12-26 12:13:41 -06:00
lordIcocainandMartin Robertz d85e09dda3 Add Fluid Void Cell (#234)
Co-authored-by: Martin Robertz <[email protected]>
2024-12-26 12:11:43 -06:00
Martin Robertz 71d820eacb update 2024-12-17 19:26:58 +01:00
EnderProyects 02ee43b04e Add new texture for infinite water cell (#251) 2024-12-17 15:45:17 +00:00
Martin Robertz 170bf2099a update 2024-12-07 20:14:47 +01:00
AlexdoruandMartin Robertz 8b1dff3f21 Fix pattern dividing (#246)
Co-authored-by: Martin Robertz <[email protected]>
2024-12-06 19:30:11 +01:00
boubou19 be6dfac4d0 retain the priority setting of the fluid storage buses when wrenched (#247) 2024-11-24 21:59:46 +01:00
Martin Robertz 9fb8baef7b update 2024-11-23 16:40:15 +01:00
hiroschoandMartin Robertz 3314e31bdc Fix fluid is registered twice in crafting CPU (#237)
Co-authored-by: Martin Robertz <[email protected]>
2024-11-23 00:27:51 +01:00
Martin Robertz e9804a1538 update 2024-11-18 08:26:03 +01:00
Alexdoru adc2a1f2fd fix changing size of the interface terminal switching to a different GUI entirely (#242) 2024-11-17 22:35:04 +00:00
Alexdoruandboubou19 8a37e085c1 Hide P2P outputs from interface terminal (#241)
Co-authored-by: boubou19 <[email protected]>
2024-11-17 22:26:00 +00:00
AlexdoruandMCTBL 8b4ab1ba61 Fix clearing the current search when clicking the change terminal size button (#240)
Co-authored-by: MCTBL <[email protected]>
2024-11-17 12:51:48 +00:00
AlexdoruandMCTBL e48073976d fix the search strings resetting when changing the terminal size in the interface terminal (#243)
Co-authored-by: MCTBL <[email protected]>
2024-11-17 13:48:36 +01:00
Martin Robertz d699539bd0 update 2024-11-16 15:44:30 +01:00
hiroscho 91542f3d68 Fix that the clicked slot in a level maintainer is not determined correctly (#236) 2024-11-16 15:20:06 +01:00
Martin Robertz 12ebe0b55a update
(cherry picked from commit 5934a8b886)
2024-10-27 16:06:52 +01:00
lordIcocain 311210fc4a another fix (#235) 2024-10-27 16:06:27 +01:00
Martin Robertz b09615f982 update 2024-10-25 16:12:52 +02:00
lordIcocain 25133d8c3f fail (#233) 2024-10-22 16:07:58 +02:00
Martin Robertz dbbdf72230 update 2024-10-20 15:58:07 +02:00
lordIcocainandMartin Robertz 25da378a51 Fix: Adv blocking card for omni. False positive when getAdaptor() return null. (#231)
* fix_getadaptor

* spotless

* allow certus tank & buffers

* better check

* spotless

* better blocking behavior

---------

Co-authored-by: Martin Robertz <[email protected]>
2024-10-20 15:00:14 +02:00
lordIcocain f8e7aba55a Add Smart Blocking Mode GUI for DualInterface (#232) 2024-10-19 10:03:07 -05:00
Martin Robertz d68adac1cc update 2024-10-05 12:28:43 +02:00
hiroscho d411d4f18a Fix fluid storage bus does full reset on every neighbor change (#230) 2024-10-05 12:16:24 +02:00
Martin Robertz eda554a200 update 2024-10-02 15:25:58 +02:00
hiroscho c7f2ea5797 Fix isAutoCraftingInventory returns false (#229) 2024-09-29 18:47:27 +02:00
Martin Robertz e27a8de392 update 2024-09-10 17:30:33 +02:00
MCTBL 9448540466 add blue light for drive and ME chest (#228) 2024-09-08 16:15:15 +02:00
NotAPenguin 41963430dd rename (#227) 2024-09-03 11:37:40 +02:00
Martin Robertz 7deb868713 update 2024-09-02 21:47:56 +02:00
Martin Robertz 5e723f4813 Update dependencies.gradle 2024-09-02 21:09:19 +02:00
Demiu b2e74d8ea0 Complete crafting jobs on networks without discretizer (#225) 2024-08-27 11:30:49 +02:00
Martin Robertz a3eee96d75 update 2024-08-27 10:50:59 +02:00
hiroscho 6bba29a007 Fix inverter card for fluid storage bus (#224) 2024-08-27 10:50:07 +02:00
Martin Robertz 437bb60af3 update 2024-08-27 10:22:56 +02:00
MCTBL 9ca192722b add ignore crafting mode button for wireless terminal (#226) 2024-08-27 07:48:32 +02:00
Martin Robertz 1546f5f505 update 2024-08-23 22:49:05 +02:00
Thomasandhiroscho b4bc6fa0ff add fluid storage bus extract filter (#223)
Co-authored-by: hiroscho <[email protected]>
2024-08-23 22:47:48 +02:00
Martin Robertz 767c6e99da update 2024-08-18 14:31:00 +02:00
c6c5d162a1 Fix fluid autocrafting (#221)
* Fix fluid autocrafting

Depends on https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial/pull/545

* update

* update

* rename

* Add FluidCraftingInventoryHandler so that fluid crafting isn't handled in Pass 2

* update deps

---------

Co-authored-by: hiroscho <[email protected]>
Co-authored-by: Dream Master <[email protected]>
2024-08-18 14:29:36 +02:00
Thomasandhiroscho e09525bc88 Fix fluid storage bus that undergoes a full reset returns amount 0 (#222)
Co-authored-by: hiroscho <[email protected]>
2024-08-18 10:11:35 +02:00
Dream Master 131747335f update 2024-08-04 19:06:50 +07:00
Pasha BouzarjomehriandMartin Robertz 6f05a1dd42 setItemToCraft (crash fix) (#219)
Fixes GTNewHorizons/GT-New-Horizons-Modpack#16769 for change GTNewHorizons/Applied-Energistics-2-Unofficial#523

Co-authored-by: Martin Robertz <[email protected]>
2024-08-04 19:04:58 +07:00
DemiuandDream Master e983a5e87c Adjust to AE2 api changes (#220)
* Adjust to AE2 api changes

* update

* update

---------

Co-authored-by: Dream Master <[email protected]>
2024-07-31 00:39:16 +07:00
Dream Master f63435403b update 2024-07-28 19:40:24 +07:00
MCTBL a0db8e38e6 Add Fluid Artificial Universe Cell (#218)
* Add Fluid Artificial Universe Cell

* reduce type from 63 to 5

* change the internal name of cell
2024-07-28 19:32:26 +07:00
Dream Master 386884ccb0 update 2024-07-20 18:08:41 +07:00
Martin Robertz 8e62be4638 fix (#217)
* fix

* fix
2024-07-20 18:05:17 +07:00
Fox_white 27e0610042 fix: add back universal terminal addon recipe (#215) 2024-07-20 17:51:09 +07:00
tth05andDream Master fb7508263f Remove blinkCell override (#216)
* Remove blinkCell override

* update

* Update dependencies.gradle

* fix?

---------

Co-authored-by: Dream Master <[email protected]>
2024-07-20 11:02:02 +07:00
Dream Master 7a72ee28b3 update 2024-07-17 17:26:24 +07:00
RealSilverMoon 4d5b8d9b47 Fix Fluid export bus void liquids (#214) 2024-07-17 17:23:24 +07:00
Dream Master 57edd12466 update 2024-07-17 16:17:39 +07:00
Martin Robertz a9f2edd488 update 2024-07-02 23:18:54 +02:00
Quetz4landZereff06 5d2b8eec85 add infinity water cell (#212)
* add infinity water cell

* code improvement for water cell

* code improvement for water cell 2
* changed Integer.MAX_VALUE to Integer.MAX_VALUE * 1000L for creative cells

* code improvement for water cell 3
* changed value to Integer.MAX_VALUE * 1_000_000L for creative cells

---------

Co-authored-by: Zereff06 <[email protected]>
2024-07-02 00:15:02 +02:00
Martin Robertz 402fdedf07 update 2024-06-28 22:47:15 +02:00
glowredman 08c75f9406 Disable useDependencyInformation 2024-06-25 20:44:35 +02:00
Martin Robertz f86046081e update 2024-06-18 11:39:43 +02:00
Quetz4landZereff06 d80127933a add energy and quantum bridge cards (#210)
Co-authored-by: Zereff06 <[email protected]>
2024-06-18 11:38:37 +02:00
HoleFish 75c8f55bb9 Add null check (#211) 2024-06-17 23:27:29 +02:00
Martin Robertz 04cd7ed0b2 update 2024-06-07 11:59:58 +02:00
Smile Yik c1c6a03146 Remove 'setInterfacePattern' method (#209)
The 'setInterfacePattern' method can use OpenComputer to directly generate items in the game.
2024-06-07 05:46:04 +02:00
Martin Robertz 72ce3a0e2f update 2024-05-31 19:00:07 +02:00
Martin Robertz 0135a11ea1 Update dependencies.gradle 2024-05-31 11:29:07 +02:00
slprimeandslprime 6fc5951dbc Fix ScrollBar Position in Empty Terminal (#208)
Co-authored-by: slprime <[email protected]>
2024-05-31 10:38:35 +02:00
Martin Robertz afe7338b83 update 2024-05-29 17:06:17 +02:00
chochem f7b15d0283 fix divide by zero (#207) 2024-05-29 12:31:17 +02:00
Martin Robertz 84d5546758 update 2024-05-03 22:28:56 +02:00
Martin Robertz 90f586e55a update 2024-05-01 23:13:15 +02:00
Caedis 4ef743bb29 Revert "hold the shift to stop sort items (#188)" + update deps (#206)
* Revert "hold the shift to stop sort items (#188)"

This reverts commit 0bf904f2a4.

* update deps

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

* Defer to AE2 implementation + cache GTNHLib loaded.

* Reuse pattern.

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

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

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

* Replace wildcard imports with regular one

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

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

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

Co-authored-by: GitHub GTNH Actions <>

---------

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

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

* remove unused imports

---------

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

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

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

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

---------

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

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

* update gradle+bs+deps

---------

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

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

* sa

* Implements the new interface

---------

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

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

* Update dependencies.gradle

* feat: Update core hooks and integrations

* api: Add `LevelTerminalRegistry` functionality

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

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

* feat: Add new item `LevelTerminal`

* feat: Support back navigation functionality

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

* use `IGuiTooltipHandler` directly from ae2

include #160

* fix correct `InterfaceTerminalSupportedClassProvider` deprecation

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

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

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

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

* Fix fails on `getCraftingItem`

no root cause was found

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

* Fix add logging around empty configuration

* Fix packet corruption and log invalid data

* Fix packet corruption with level emitters

* Correct handle overwrite packet

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

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

* update be+deps

* Update dependencies.gradle

* Update dependencies.gradle

* Fix `zIndexes` for compatability with `DuraDisplay`

* Update AE2 and fix compatability

* Change `ForgeDirection` side serialization to `byte`

* Fix tooltip zIndexes

* Rename all rest parts related to `Level terminal`

* Code cleanup after review

* Remove duplicated dependency declaration

---------

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

No files matched your search

+35 -6
View File
@@ -1,9 +1,38 @@
*.bat
.gradle/
.idea/
out/
.gradle
.settings
/.idea/
/.vscode/
/run/
/build/
/eclipse/
.classpath
.project
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.iml
*.ipr
*.iws
run/
build/
src/main/resources/mixins.*([!.]).json
*.bat
*.DS_Store
!gradlew.bat
.factorypath
addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
+2 -1621
View File
File diff suppressed because it is too large. Load diff
+56 -17
View File
@@ -1,24 +1,63 @@
// Add your dependencies here
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
* Available at compiletime but not runtime for mods depending on this mod
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
* Not available at all for mods depending on this mod, only visible at runtime for this mod
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
*
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
*
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.4.3-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-262-GTNH:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.7.34-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-575-GTNH-pre:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.6.0:dev')
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
api('com.github.GTNewHorizons:waila:1.8.4:dev')
api("com.github.GTNewHorizons:GTNHLib:0.6.17:dev")
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.0:dev")
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'
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.12.0:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.1.6-GTNH:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.5:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.6:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.200:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.17-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.13-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.17:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.9:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.12-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.6-GTNH:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.31:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.4:dev")
}
+163 -31
View File
@@ -1,71 +1,203 @@
modName = Fluid Craft For AE2
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
# Human-readable mod name, available for mcmod.info population.
modName = AE2 Fluid Crafting
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = ae2fc
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = com.glodblock.github
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
useModGroupForPublishing = false
# Will update your build.gradle automatically whenever an update is available
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8.
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Define a source file of your project with:
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = true
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass = com.glodblock.github.FCTags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = FluidCraft.java
gradleTokenModId = GRADLETOKEN_MODID
gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
apiPackage = api
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile = ae2fc_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass = coremod.FluidCraftCore
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = false
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# projects. New projects should not use this parameter.
#customArchiveBaseName =
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
# Optional parameter to prevent the source code from being published
# noPublishedSources =
Binary file not shown.
+2 -1
View File
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+16 -10
View File
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# 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
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,7 +85,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +133,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +147,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +155,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +204,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Vendored
+94
View File
@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+5 -10
View File
@@ -4,10 +4,10 @@ pluginManagement {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons.retrofuturagradle")
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
@@ -17,12 +17,7 @@ pluginManagement {
}
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.37'
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
@@ -36,9 +36,9 @@ import cpw.mods.fml.common.network.NetworkRegistry;
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";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String MODNAME = "GRADLETOKEN_MODNAME";
public static final String MODID = "ae2fc";
public static final String VERSION = FCTags.VERSION;
public static final String MODNAME = "AE2 Fluid Crafting";
@Mod.Instance(MODID)
public static FluidCraft INSTANCE;
@@ -57,7 +57,6 @@ public class FluidCraft {
@Mod.EventHandler
public static void init(FMLInitializationEvent event) {
ModAndClassUtil.init();
if (ModAndClassUtil.OC) {
OCDriverInit.run();
}
@@ -77,7 +76,12 @@ public class FluidCraft {
if (!Config.removeRecipe) {
RecipeLoader.INSTANCE.run();
}
if (!ModAndClassUtil.NEW_HORIZONS_CORE_MOD) {
RecipeLoader.addTerminalCards();
RecipeLoader.addInfiniteWaterCell();
}
RecipeLoader.runTerminalRecipe();
RecipeLoader.addDisassembleRecipe();
if (ModAndClassUtil.isV2) {
CalculatorV2PluginLoader.installCalculatorV2Plugins();
@@ -89,6 +93,11 @@ public class FluidCraft {
proxy.postInit(event);
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {
proxy.onLoadComplete(event);
}
@Mod.EventHandler
public void onServerStart(FMLServerStartingEvent event) {
SPacketMEUpdateBuffer.init();
@@ -106,9 +115,6 @@ public class FluidCraft {
}
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {}
public static ResourceLocation resource(String path) {
return new ResourceLocation(MODID, path);
}
@@ -5,6 +5,9 @@ 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();
@@ -42,4 +45,9 @@ public final class FluidCraftAPI implements IFluidCraftAPI {
public boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid) {
return blacklistedDispFluids.contains(fluid);
}
@Override
public ILevelTerminalRegistry levelTerminalRegistry() {
return LevelTerminalRegistry.instance();
}
}
@@ -2,6 +2,8 @@ package com.glodblock.github.api;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
@SuppressWarnings("unused")
public interface IFluidCraftAPI {
@@ -24,4 +26,9 @@ public interface IFluidCraftAPI {
* Mostly for internal use; queries whether the fluid is blacklisted from being displayed.
*/
boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid);
/**
* Get instance of `ILevelTerminalRegistry` to add new supported machines into terminal
*/
ILevelTerminalRegistry levelTerminalRegistry();
}
@@ -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);
}
@@ -0,0 +1,86 @@
package com.glodblock.github.client.gui.widget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class FCGuiBaseButton extends GuiButton {
// copy from wct button
protected static final ResourceLocation buttonTextures = new ResourceLocation(
"minecraft",
"textures/gui/widgets.png");
public FCGuiBaseButton(int id, int xPosition, int yPosition, int width, int height, String displayString) {
super(id, xPosition, yPosition, width, height, displayString);
this.enabled = true;
this.visible = true;
this.id = id;
this.xPosition = xPosition;
this.yPosition = yPosition;
this.width = width;
this.height = height;
this.displayString = displayString;
}
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
FontRenderer fontrenderer = mc.fontRenderer;
mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
int k = this.getHoverState(this.field_146123_n);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(
this.xPosition + this.width / 2,
this.yPosition,
200 - this.width / 2,
46 + k * 20,
this.width / 2,
this.height - 2);
this.drawTexturedModalRect(
this.xPosition + 2,
this.yPosition + (this.height - 2),
200 - (this.width - 2),
64 + k * 20,
this.width - 2,
2);
this.drawTexturedModalRect(
this.xPosition,
this.yPosition + (this.height - 1),
200 - this.width,
65 + k * 20,
this.width,
1);
this.mouseDragged(mc, mouseX, mouseY);
int l = 14737632;
if (packedFGColour != 0) {
l = packedFGColour;
} else if (!this.enabled) {
l = 10526880;
} else if (this.field_146123_n) {
l = 16777120;
}
this.drawCenteredString(
fontrenderer,
this.displayString,
this.xPosition + this.width / 2,
this.yPosition + (this.height - 8) / 2,
l);
}
}
}
@@ -6,8 +6,6 @@ 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);
@@ -17,8 +15,6 @@ public class FCGuiLineField extends FCGuiTextField {
super(fontRenderer, xPos, yPos, width, height);
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._fontRender = fontRenderer;
}
@Override
@@ -71,9 +71,9 @@ public class FCGuiTextField extends GuiTextField {
mouseY = 15;
}
if (mouseX + length + 20 >= gui.width) {
gui.drawTooltip(mouseX - length - 20, mouseY + 4 + offsetY, 0, this.getMessage());
gui.drawTooltip(mouseX - length - 20, mouseY + 4 + offsetY, this.getMessage());
} else {
gui.drawTooltip(mouseX, mouseY + 4 + offsetY, 0, this.getMessage());
gui.drawTooltip(mouseX, mouseY + 4 + offsetY, this.getMessage());
}
}
}
@@ -2,31 +2,31 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2ReflectClient;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {
private GuiTabButton originalGuiBtn;
private final ITerminalHost host;
public GuiFluidPatternTerminalCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
host = te;
}
@@ -34,20 +34,23 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
@Override
public void initGui() {
if (host instanceof PartFluidPatternTerminal)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL.stack());
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
else if (host instanceof PartFluidTerminal) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
} else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1));
} else if (host instanceof WirelessFluidTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
} else if (host instanceof WirelessPatternTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
} else if (host instanceof WirelessInterfaceTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
}
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);
}
@@ -59,14 +62,17 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
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 IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
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);
}
@@ -4,32 +4,37 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerDualInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import appeng.api.config.AdvancedBlockingMode;
import appeng.api.config.InsertionMode;
import appeng.api.config.LockCraftingMode;
import appeng.api.config.Settings;
import appeng.api.config.SidelessMode;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSimpleImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerInterface;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IInterfaceHost;
public class GuiDualInterface extends GuiUpgradeable {
@@ -37,10 +42,14 @@ public class GuiDualInterface extends GuiUpgradeable {
private GuiTabButton priority;
private GuiTabButton switcher;
private GuiImgButton BlockMode;
private GuiImgButton SmartBlockMode;
private GuiToggleButton interfaceMode;
private GuiImgButton insertionMode;
private GuiImgButton sidelessMode;
private GuiSimpleImgButton doublePatterns;
private GuiToggleButton patternOptimization;
private GuiImgButton advancedBlockingMode;
private GuiImgButton lockCraftingMode;
private final IInterfaceHost host;
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
@@ -50,7 +59,6 @@ public class GuiDualInterface extends GuiUpgradeable {
}
@Override
@SuppressWarnings("unchecked")
protected void addButtons() {
this.priority = new GuiTabButton(
this.guiLeft + 154,
@@ -69,41 +77,81 @@ public class GuiDualInterface extends GuiUpgradeable {
itemRender);
this.buttonList.add(this.switcher);
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO);
int offset = 8;
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + offset, Settings.BLOCK, YesNo.NO);
this.buttonList.add(this.BlockMode);
this.SmartBlockMode = new GuiImgButton(this.guiLeft - 36, this.guiTop + offset, Settings.SMART_BLOCK, YesNo.NO);
this.buttonList.add(this.SmartBlockMode);
offset += 18;
this.interfaceMode = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + 26,
this.guiTop + offset,
84,
85,
GuiText.InterfaceTerminal.getLocal(),
GuiText.InterfaceTerminalHint.getLocal());
this.buttonList.add(this.interfaceMode);
offset += 18;
this.insertionMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 44,
this.guiTop + offset,
Settings.INSERTION_MODE,
InsertionMode.DEFAULT);
this.buttonList.add(this.insertionMode);
offset += 18;
this.doublePatterns = new GuiSimpleImgButton(this.guiLeft - 18, this.guiTop + offset, 71, "");
this.doublePatterns.enabled = false;
this.buttonList.add(this.doublePatterns);
offset += 18;
this.patternOptimization = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + offset,
178,
194,
GuiText.PatternOptimization.getLocal(),
GuiText.PatternOptimizationHint.getLocal());
this.buttonList.add(this.patternOptimization);
offset += 18;
this.advancedBlockingMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 62,
this.guiTop + offset,
Settings.ADVANCED_BLOCKING_MODE,
AdvancedBlockingMode.DEFAULT);
this.buttonList.add(this.advancedBlockingMode);
this.advancedBlockingMode.visible = this.bc.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0;
offset += 18;
if (isTile()) {
this.sidelessMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 80,
this.guiTop + offset,
Settings.SIDELESS_MODE,
SidelessMode.SIDELESS);
this.buttonList.add(this.sidelessMode);
offset += 18;
}
this.lockCraftingMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + offset,
Settings.LOCK_CRAFTING_MODE,
LockCraftingMode.NONE);
this.lockCraftingMode.visible = this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0;
this.buttonList.add(lockCraftingMode);
}
@Override
@@ -111,19 +159,34 @@ public class GuiDualInterface extends GuiUpgradeable {
if (this.BlockMode != null) {
this.BlockMode.set(((ContainerInterface) this.cvb).getBlockingMode());
}
if (this.SmartBlockMode != null) {
this.SmartBlockMode.set(((ContainerInterface) this.cvb).getSmartBlockingMode());
}
if (this.interfaceMode != null) {
this.interfaceMode.setState(((ContainerInterface) this.cvb).getInterfaceTerminalMode() == YesNo.YES);
}
if (this.insertionMode != null) {
this.insertionMode.set(((ContainerInterface) this.cvb).getInsertionMode());
}
if (this.doublePatterns != null) {
this.doublePatterns.enabled = ((ContainerInterface) this.cvb).isAllowedToMultiplyPatterns;
if (this.doublePatterns.enabled) this.doublePatterns.setTooltip(
ButtonToolTips.DoublePatterns.getLocal() + "\n" + ButtonToolTips.DoublePatternsHint.getLocal());
else this.doublePatterns.setTooltip(
ButtonToolTips.DoublePatterns.getLocal() + "\n" + ButtonToolTips.OptimizePatternsNoReq.getLocal());
}
if (this.patternOptimization != null) {
this.patternOptimization.setState(((ContainerInterface) this.cvb).getPatternOptimization() == YesNo.YES);
}
if (this.sidelessMode != null) {
this.sidelessMode.set(((ContainerDualInterface) this.cvb).getSidelessMode());
}
if (this.advancedBlockingMode != null) {
this.advancedBlockingMode.set(((ContainerDualInterface) this.cvb).getAdvancedBlockingMode());
}
if (this.lockCraftingMode != null) {
this.lockCraftingMode.set(((ContainerInterface) this.cvb).getLockCraftingMode());
}
this.fontRendererObj.drawString(
getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)),
8,
@@ -148,27 +211,38 @@ public class GuiDualInterface extends GuiUpgradeable {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == this.priority) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
InventoryHandler.switchGui(GuiType.PRIORITY);
} else if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
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.SmartBlockMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.SmartBlockMode.getSetting(), backwards));
} else if (btn == this.insertionMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.insertionMode.getSetting(), backwards));
} else if (btn == this.doublePatterns) {
try {
int val = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? 1 : 0;
if (backwards) val |= 0b10;
NetworkHandler.instance
.sendToServer(new PacketValueConfig("Interface.DoublePatterns", String.valueOf(val)));
} catch (final Throwable e) {
AELog.debug(e);
}
} else if (btn == this.patternOptimization) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.PATTERN_OPTIMIZATION, backwards));
} else if (btn == this.sidelessMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
} else if (btn == this.advancedBlockingMode) {
NetworkHandler.instance
.sendToServer(new PacketConfigButton(this.advancedBlockingMode.getSetting(), backwards));
} else if (btn == this.lockCraftingMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.lockCraftingMode.getSetting(), backwards));
}
}
private boolean isPart() {
return this.host instanceof PartFluidInterface;
}
private boolean isTile() {
return this.host instanceof TileFluidInterface;
}
@@ -179,5 +253,8 @@ public class GuiDualInterface extends GuiUpgradeable {
if (this.advancedBlockingMode != null) {
this.advancedBlockingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0);
}
if (this.lockCraftingMode != null) {
this.lockCraftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0);
}
}
}
@@ -1,7 +1,5 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import net.minecraft.client.gui.GuiButton;
@@ -11,6 +9,8 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerEssentiaMonitor;
import com.glodblock.github.client.me.EssentiaRepo;
@@ -21,16 +21,13 @@ 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) {
@@ -64,13 +61,15 @@ public class GuiEssentiaTerminal extends GuiFluidMonitor {
AspectUtil.getAspectFromGas(fluidStack),
fluidStack.amount);
IAEItemStack gas = stack.copy().setStackSize(stack.getStackSize() / AspectUtil.R);
stackSizeRenderer.setAeStack(gas);
stackSizeRenderer.renderItemOverlayIntoGUI(
aeRenderItem.setAeStack(gas);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
gas.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
@@ -79,13 +78,8 @@ public class GuiEssentiaTerminal extends GuiFluidMonitor {
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotME && AspectUtil.isEssentiaContainer(player.inventory.getItemStack())) {
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
ItemStack itemStack = this.player.inventory.getItemStack().copy();
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
if (!isShiftKeyDown()) {
itemStack.stackSize = 1;
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
@@ -59,6 +59,23 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
this.registerApp(20, "LEVEL_TEM", "YES", "level_terminal_w");
this.registerApp(21, "SWITCH", "ON", "edit");
this.registerApp(22, "SWITCH", "OFF", "view");
this.registerApp(21, "SWITCH", "ENABLE", "enable");
this.registerApp(22, "SWITCH", "DISABLE", "disable");
this.registerApp(23, "CONFIG", "YES", "open_configuration");
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
this.registerApp(30, "MAGNET_CARD", "INV", "magnet_card.inv");
this.registerApp(30, "MAGNET_CARD", "ME", "magnet_card.me");
this.registerApp(30, "MAGNET_CARD", "FILTER", "magnet_card.filter");
this.registerApp(31, "MAGNET_CARD", "OFF", "magnet_card.off");
this.registerApp(32, "DATA_SYNC", "ENABLE", "data_sync.enable");
this.registerApp(33, "ENABLE_12x", "ENABLE", "enable");
this.registerApp(34, "DISABLE_12x", "DISABLE", "disable");
this.registerApp(35, "DATA_SYNC", "DISABLE", "data_sync.disable");
this.registerApp(36, "RESTOCK", "ENABLE", "restock.on");
this.registerApp(37, "RESTOCK", "DISABLE", "restock.off");
}
}
@@ -110,6 +127,10 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
return this.currentValue;
}
public boolean getMouseIn() {
return this.field_146123_n;
}
public void set(final String e) {
if (!this.currentValue.equals(e)) {
this.currentValue = e;
@@ -11,6 +11,7 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import appeng.container.implementations.ContainerPriority;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
@@ -34,6 +35,11 @@ public class GuiFCPriority extends FCGuiAmount {
((ContainerPriority) this.inventorySlots).setTextField(this.amountBox);
}
@Override
protected int getIncrementQuantity(int i) {
return AEConfig.instance.priorityByStacksAmounts(i);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 0x404040);
@@ -2,7 +2,8 @@ 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.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
@@ -10,18 +11,26 @@ 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;
import appeng.api.config.CraftingMode;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
public class GuiFluidCraftAmount extends FCGuiAmount {
private GuiImgButton craftingMode;
public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerCraftAmount(inventoryPlayer, te));
}
@@ -29,6 +38,14 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
@Override
public void initGui() {
super.initGui();
this.buttonList.add(
this.craftingMode = new GuiImgButton(
this.guiLeft + 10,
this.guiTop + 53,
Settings.CRAFTING_MODE,
CraftingMode.STANDARD));
this.amountBox.setText("1");
this.amountBox.setSelectionPos(0);
}
@@ -54,8 +71,20 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
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()));
if (btn == this.craftingMode) {
GuiImgButton iBtn = ((GuiImgButton) btn);
final Enum<?> cv = iBtn.getCurrentValue();
final boolean backwards = Mouse.isButtonDown(1);
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
iBtn.set(next);
} else if (btn == this.submit && this.submit.enabled) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketCraftRequest(
getAmount(),
isShiftKeyDown(),
((CraftingMode) this.craftingMode.getCurrentValue())));
}
} catch (final NumberFormatException e) {
this.amountBox.setText("1");
@@ -65,20 +94,26 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (target instanceof PartFluidTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
this.myIcon = ItemAndBlockHolder.FLUID_TERM.stack();
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
} else if (target instanceof 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 = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
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;
}
}
@@ -2,37 +2,42 @@ package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.network.CPacketSwitchGuis;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftConfirm;
public class GuiFluidCraftConfirm extends GuiCraftConfirm {
private GuiType OriginalGui;
private GuiType originalGui;
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te);
if (te instanceof PartFluidPatternTerminal) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (te instanceof PartFluidPatternTerminalEx) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (te instanceof IWirelessTerminal && ((IWirelessTerminal) te).isUniversal(te)) {
this.OriginalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) te).getItemStack());
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;
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (te instanceof WirelessLevelTerminalInventory) {
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}
@Override
public void switchToOriginalGUI() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
InventoryHandler.switchGui(originalGui);
}
}
@@ -55,7 +55,6 @@ public class GuiFluidCraftingWireless extends GuiItemMonitor {
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.buttonList.add(
@@ -17,11 +17,11 @@ import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
@@ -66,7 +66,6 @@ public class GuiFluidInterface extends AEBaseGui {
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.switcher = new GuiTabButton(
@@ -117,7 +116,7 @@ public class GuiFluidInterface extends AEBaseGui {
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE));
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE);
}
}
@@ -7,7 +7,6 @@ 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;
@@ -16,7 +15,6 @@ 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;
@@ -25,7 +23,6 @@ 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;
@@ -82,7 +79,7 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER),
getGuiDisplayName(NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER)),
8,
6,
GuiColors.UpgradableTitle.getColor());
@@ -4,6 +4,7 @@ import java.util.List;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.client.gui.base.FCGuiMonitor;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
@@ -43,6 +44,7 @@ public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
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);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@Override
@@ -55,8 +57,9 @@ public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
if (Util.getFluidFromItem(stack) != null) {
setSearchString(Util.getFluidFromItem(stack).getLocalizedName(), true);
final FluidStack fluid = Util.getFluidFromItem(stack);
if (fluid != null) {
setSearchString(fluid.getLocalizedName(), true);
}
}
}
@@ -0,0 +1,49 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiOptimizePatterns;
import appeng.core.localization.GuiText;
public class GuiFluidOptimizePatterns extends GuiOptimizePatterns {
private GuiType originalGui;
public GuiFluidOptimizePatterns(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
if (te instanceof PartFluidPatternTerminal) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (te instanceof PartFluidPatternTerminalEx) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (te instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
} else if (te instanceof IWirelessTerminal terminal && terminal.isUniversal(te)) {
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (te instanceof WirelessPatternTerminalInventory) {
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (te instanceof WirelessLevelTerminalInventory) {
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}
@Override
protected void actionPerformed(GuiButton btn) {
if (btn.displayString.equals(GuiText.Cancel.getLocal())) {
InventoryHandler.switchGui(originalGui);
return;
}
super.actionPerformed(btn);
}
}
@@ -13,6 +13,8 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
import com.glodblock.github.common.item.ItemFluidPacket;
@@ -21,12 +23,10 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.ISlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.render.AppEngRenderItem;
import appeng.core.localization.GuiText;
public class GuiFluidPatternEncoder extends AEBaseGui {
@@ -35,7 +35,6 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
private final ContainerFluidPatternEncoder cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
super(new ContainerFluidPatternEncoder(ipl, tile));
@@ -95,13 +94,15 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
}
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
aeRenderItem.setAeStack(fake);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
} else {
super.func_146977_a(slot);
}
@@ -6,10 +6,12 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import com.glodblock.github.FluidCraft;
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.network.CPacketInventoryAction;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -24,6 +26,7 @@ import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternTerm;
import appeng.core.localization.GuiText;
import appeng.helpers.InventoryAction;
public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
@@ -36,7 +39,6 @@ public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.tabCraftButton = new GuiTabButton(
@@ -144,6 +146,18 @@ public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
4210752);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
if (btn == 2 && doubleBtn.mousePressed(this.mc, xCoord, yCoord)) { //
InventoryAction action = InventoryAction.SET_PATTERN_MULTI;
final CPacketInventoryAction p = new CPacketInventoryAction(action, 0, 0);
FluidCraft.proxy.netHandler.sendToServer(p);
} else super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (mouseButton == 3) {
@@ -11,6 +11,7 @@ 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.network.CPacketInventoryAction;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -21,6 +22,7 @@ import appeng.api.config.PatternSlotConfig;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.helpers.InventoryAction;
public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
@@ -37,7 +39,6 @@ public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
@@ -179,7 +180,12 @@ public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
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 (btn == 2 && doubleBtn.mousePressed(this.mc, xCoord, yCoord)) { //
InventoryAction action = InventoryAction.SET_PATTERN_MULTI;
final CPacketInventoryAction p = new CPacketInventoryAction(action, 0, 0);
FluidCraft.proxy.netHandler.sendToServer(p);
} else super.mouseClicked(xCoord, yCoord, btn);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
@@ -27,4 +27,9 @@ public class GuiFluidPortableCell extends GuiFluidTerminal {
return 3;
}
}
@Override
protected boolean isPortableCell() {
return true;
}
}
@@ -9,9 +9,9 @@ import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import appeng.api.config.AccessRestriction;
@@ -39,7 +39,6 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
}
@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);
@@ -93,7 +92,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
} else if (btn == this.clear) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
InventoryHandler.switchGui(GuiType.PRIORITY);
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
@@ -1,8 +1,5 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -22,7 +19,6 @@ 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;
@@ -31,12 +27,10 @@ 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;
@@ -84,13 +78,15 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
if (stack == null) return true;
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid());
stackSizeRenderer.setAeStack(stack);
stackSizeRenderer.renderItemOverlayIntoGUI(
aeRenderItem.setAeStack(stack);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
@@ -122,13 +118,8 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotME && Util.FluidUtil.isFluidContainer(player.inventory.getItemStack())) {
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
ItemStack itemStack = this.player.inventory.getItemStack().copy();
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
if (!isShiftKeyDown()) {
itemStack.stackSize = 1;
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(fluid, isShiftKeyDown()));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
@@ -1,769 +0,0 @@
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 GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
protected int offsetY;
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
private static final int offsetX = 21;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, Util.DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
protected static String searchFieldOutputsText = "";
protected static String searchFieldInputsText = "";
protected static String searchFieldNamesText = "";
private final MEGuiTextField searchFieldOutputs;
private final MEGuiTextField searchFieldInputs;
private final MEGuiTextField searchFieldNames;
private final GuiImgButton guiButtonHideFull;
private final GuiImgButton guiButtonAssemblersOnly;
private final GuiImgButton guiButtonBrokenRecipes;
private GuiImgButton searchStringSave;
private GuiImgButton terminalStyleBox;
private boolean refreshList = false;
protected static boolean onlyMolecularAssemblers = false;
protected static boolean onlyBrokenRecipes = false;
protected GuiTabButton craftingStatusBtn;
private int rows = 3;
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
public GuiInterfaceTerminalWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));
this.setScrollBar(new GuiScrollbar());
this.xSize = 208;
this.ySize = 255;
searchFieldInputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldOutputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames = new MEGuiTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames.setFocused(true);
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
}
@Override
public int getOffsetY() {
return this.offsetY;
}
@Override
public void setOffsetY(int y) {
this.offsetY = y;
}
private void setScrollBar() {
this.getScrollBar().setTop(52).setLeft(189).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, this.lines.size() - this.rows, 2);
}
@Override
public void initGui() {
super.initGui();
this.rows = calculateRowsCount();
this.ySize = MAGIC_HEIGHT_NUMBER + this.rows * 18;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
this.offsetY = this.guiTop + 8;
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
this.offsetY += 20;
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SAVE_SEARCH,
AEConfig.instance.settings.getSetting(Settings.SAVE_SEARCH)));
this.offsetY += 20;
searchFieldInputs.x = guiLeft + Math.max(32, offsetX);
searchFieldInputs.y = guiTop + 25;
searchFieldOutputs.x = guiLeft + Math.max(32, offsetX);
searchFieldOutputs.y = guiTop + 38;
searchFieldNames.x = guiLeft + Math.max(32, offsetX) + 99;
searchFieldNames.y = guiTop + 38;
guiButtonAssemblersOnly.xPosition = guiLeft + Math.max(32, offsetX) + 99;
guiButtonAssemblersOnly.yPosition = guiTop + 20;
guiButtonHideFull.xPosition = guiButtonAssemblersOnly.xPosition + 18;
guiButtonHideFull.yPosition = guiTop + 20;
guiButtonBrokenRecipes.xPosition = guiButtonHideFull.xPosition + 18;
guiButtonBrokenRecipes.yPosition = guiTop + 20;
terminalStyleBox.xPosition = guiLeft - 18;
terminalStyleBox.yPosition = guiTop + 8;
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + this.xSize - 24,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString();
}
this.setScrollBar();
this.repositionSlots();
this.initGuiDone();
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
searchFieldOutputsText = this.searchFieldOutputs.getText();
searchFieldInputsText = this.searchFieldInputs.getText();
searchFieldNamesText = this.searchFieldNames.getText();
}
public void setSearchString() {
this.searchFieldOutputs.setText(searchFieldOutputsText);
this.searchFieldInputs.setText(searchFieldInputsText);
this.searchFieldNames.setText(searchFieldNamesText);
}
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof final AppEngSlot slot) {
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
}
}
}
protected int calculateRowsCount() {
final int maxRows = this.getMaxRows();
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int input = 22;
final int topPanel = 18;
final int NEIPadding = hasNEI ? input + topPanel : 0;
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - NEIPadding;
return Math.max(3, Math.min(maxRows, extraSpace / 18));
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
fontRendererObj.drawString(
getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()),
8,
6,
GuiColors.InterfaceTerminalTitle.getColor());
fontRendererObj.drawString(
GuiText.inventory.getLocal(),
GuiInterfaceTerminalWireless.offsetX + 2,
this.ySize - 96,
GuiColors.InterfaceTerminalInventory.getColor());
int offset = 51;
final int ex = getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z))) drawRect(
z * 18 + 22,
1 + offset,
z * 18 + 22 + 16,
1 + offset + 16,
GuiColors.InterfaceTerminalMatch.getColor());
}
} else if (lineObj instanceof String name) {
final int rows = this.byName.get(name).size();
String postfix = "";
if (rows > 1) {
postfix = " (" + rows + ')';
}
while (name.length() > 2 && this.fontRendererObj.getStringWidth(name + postfix) > 158) {
name = name.substring(0, name.length() - 1);
}
this.fontRendererObj.drawString(
name + postfix,
GuiInterfaceTerminalWireless.offsetX + 3,
6 + offset,
GuiColors.InterfaceTerminalName.getColor());
}
offset += 18;
}
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
buttonList.clear();
inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
guiButtonAssemblersOnly.set(
onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLEERS_ON : ActionItems.MOLECULAR_ASSEMBLEERS_OFF);
guiButtonHideFull.set(
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF
: ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
guiButtonBrokenRecipes.set(
onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_OFF
: ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_ON);
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
buttonList.add(guiButtonAssemblersOnly);
buttonList.add(guiButtonHideFull);
buttonList.add(guiButtonBrokenRecipes);
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
this.guiButtonHashMap.clear();
addSwitchGuiBtns();
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof final ClientDCInternalInv inv) {
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 22, 1 + offset));
}
GuiButton guiButton = new GuiImgButton(
guiLeft + 4,
guiTop + offset + 1,
Settings.ACTIONS,
ActionItems.HIGHLIGHT_INTERFACE);
GuiFCImgButton editButton = new GuiFCImgButton(guiLeft + 4, guiTop + offset + 1, "EDIT", "YES");
guiButtonHashMap.put(guiButton, inv);
guiButtonHashMap.put(editButton, inv);
if (isShiftKeyDown()) {
buttonList.add(editButton);
} else {
buttonList.add(guiButton);
}
}
offset += 18;
}
super.drawScreen(mouseX, mouseY, btn);
handleTooltip(mouseX, mouseY, searchFieldInputs);
handleTooltip(mouseX, mouseY, searchFieldOutputs);
handleTooltip(mouseX, mouseY, searchFieldNames);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
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);
}
}
}
File diff suppressed because it is too large. Load diff
@@ -37,6 +37,7 @@ public class GuiItemMonitor extends FCGuiMonitor<IAEItemStack> {
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);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@Override
@@ -1,9 +1,11 @@
package com.glodblock.github.client.gui;
import java.awt.Rectangle;
import static com.glodblock.github.client.gui.container.ContainerLevelMaintainer.createLevelValues;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -13,29 +15,49 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketLevelMaintainer;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.network.CPacketLevelMaintainer.Action;
import com.glodblock.github.network.CPacketLevelTerminalCommands;
import com.glodblock.github.util.FCGuiColors;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import com.gtnewhorizon.gtnhlib.util.parsing.MathExpressionParser;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.DimensionalCoord;
import appeng.client.gui.AEBaseGui;
import appeng.client.render.AppEngRenderItem;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.AEFeature;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketNEIDragClick;
import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cofh.core.render.CoFHFontRenderer;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler")
@@ -45,11 +67,19 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private final ContainerLevelMaintainer cont;
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private FCGuiTextField input;
private int lastWorkingTick;
private int refreshTick;
private final CoFHFontRenderer render;
protected ItemStack icon = null;
protected GuiType originalGui;
protected Util.DimensionalCoordSide originalBlockPos;
protected GuiTabButton originalGuiBtn;
protected static final boolean isGTNHLibLoaded = Loader.isModLoaded("gtnhlib");
protected static final Pattern numberPattern = isGTNHLibLoaded ? MathExpressionParser.EXPRESSION_PATTERN
: Pattern.compile("^[0-9]+");
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(new ContainerLevelMaintainer(ipl, tile));
@@ -62,24 +92,68 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
Minecraft.getMinecraft().getTextureManager(),
true);
this.refreshTick = 0;
if (ipl.player.openContainer instanceof AEBaseContainer container) {
var target = container.getTarget();
if (target instanceof PartLevelTerminal terminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
DimensionalCoord blockPos = new DimensionalCoord(terminal.getTile());
originalBlockPos = new Util.DimensionalCoordSide(
blockPos.x,
blockPos.y,
blockPos.z,
blockPos.getDimension(),
terminal.getSide(),
"");
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
ipl.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
originalBlockPos = new Util.DimensionalCoordSide(
terminal.getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0,
ipl.player.worldObj.provider.dimensionId,
ForgeDirection.UNKNOWN,
"");
}
}
}
public void postUpdate(List<IAEItemStack> list) {
for (Slot slot : this.cont.getRequestSlots()) {
if (!slot.getHasStack()) {
component[slot.getSlotIndex()].setState(TileLevelMaintainer.State.Nothing);
component[slot.getSlotIndex()].setState(State.None);
}
}
for (IAEItemStack is : list) {
NBTTagCompound data = is.getItemStack().getTagCompound();
long size = data.getLong("Batch");
int i = data.getInteger("Index");
boolean isEnable = data.getBoolean("Enable");
TileLevelMaintainer.State state = TileLevelMaintainer.State.values()[data.getInteger("State")];
component[i].getQty().textField.setText(String.valueOf(is.getStackSize()));
component[i].getBatch().textField.setText(String.valueOf(size));
component[i].setEnable(isEnable);
component[i].setState(state);
if (data == null) {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info("Received empty configuration: ", is);
}
continue;
}
long batch = data.getLong(TLMTags.Batch.tagName);
long quantity = data.getLong(TLMTags.Quantity.tagName);
int idx = data.getInteger(TLMTags.Index.tagName);
boolean isEnable = data.getBoolean(TLMTags.Enable.tagName);
State state = State.values()[data.getInteger(TLMTags.State.tagName)];
component[idx].getQty().textField.setText(String.valueOf(quantity));
component[idx].getBatch().textField.setText(String.valueOf(batch));
component[idx].setEnable(isEnable);
component[idx].setState(state);
}
}
@@ -92,19 +166,29 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
new FCGuiTextField(this.fontRendererObj, guiLeft + 46, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE,
i,
"TileLevelMaintainer.Quantity"),
Action.Quantity),
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE,
i,
"TileLevelMaintainer.Batch"),
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);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
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) {
@@ -124,7 +208,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
int tick = this.refreshTick;
int interval = 20;
if (tick > lastWorkingTick + interval && this.input == null) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
lastWorkingTick = this.refreshTick;
}
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
@@ -154,13 +238,15 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
} else {
fake.setStackSize(0);
}
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.setAeStack(fake);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
fake.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
@@ -197,7 +283,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.input.textboxKeyTyped(character, key);
}
super.keyTyped(character, key);
if (!this.input.getText().matches("^[0-9]+")) {
if (!numberPattern.matcher(this.input.getText()).matches()) {
this.input.setTextColor(0xFF0000);
} else {
this.input.setTextColor(0xFFFFFF);
@@ -225,14 +311,32 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
for (Component com : this.component) {
if (com.sendToServer(btn)) {
break;
if (btn == originalGuiBtn) {
switchGui();
} else {
super.actionPerformed(btn);
for (Component com : this.component) {
if (com.sendToServer(btn)) {
break;
}
}
}
}
public void switchGui() {
CPacketLevelTerminalCommands message = new CPacketLevelTerminalCommands(
CPacketLevelTerminalCommands.Action.BACK,
originalBlockPos.x,
originalBlockPos.y,
originalBlockPos.z,
originalBlockPos.getDimension(),
originalBlockPos.getSide());
if (originalGui != null) {
message.setOriginalGui(originalGui.ordinal());
}
FluidCraft.proxy.netHandler.sendToServer(message);
}
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
return currentVisibility;
@@ -248,26 +352,29 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
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)) {
slot.putStack(draggedStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex()));
if (draggedStack != null) {
this.updateAmount(slot.getSlotIndex(), draggedStack.stackSize);
draggedStack.stackSize = 0;
}
if (draggedStack == null) {
return false;
}
draggedStack.stackSize = 0;
Slot slotAtPosition = this.getSlotAtPosition(mouseX, mouseY);
if (slotAtPosition == null) {
return false;
}
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
if (slotAtPosition.equals(slot)) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
return true;
}
}
if (draggedStack != null) {
draggedStack.stackSize = 0;
}
return false;
}
@@ -285,24 +392,24 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private final GuiFCImgButton enable;
private final GuiFCImgButton submit;
private final FCGuiLineField line;
private TileLevelMaintainer.State state;
private State state;
public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton submitBtn, GuiFCImgButton enableBtn,
GuiFCImgButton disableBtn, FCGuiLineField line, List buttonList) {
GuiFCImgButton disableBtn, FCGuiLineField line, List<GuiButton> buttonList) {
this.qty = qtyInput;
this.batch = batchInput;
this.enable = enableBtn;
this.disable = disableBtn;
this.submit = submitBtn;
this.line = line;
this.state = TileLevelMaintainer.State.Nothing;
this.state = State.None;
buttonList.add(this.submit);
buttonList.add(this.enable);
buttonList.add(this.disable);
}
public int getIndex() {
return this.getQty().idx;
return this.qty.idx;
}
public void setEnable(boolean enable) {
@@ -311,7 +418,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private boolean send(Widget widget) {
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("^[0-9]+")) {
if (isGTNHLibLoaded) {
long value = (long) MathExpressionParser.parse(widget.textField.getText());
widget.textField.setText(String.valueOf(value));
}
if (!widget.textField.getText().isEmpty()
&& numberPattern.matcher(widget.textField.getText()).matches()) {
String str = widget.textField.getText().replaceAll("^(0+)", "");
widget.textField.setText(str.isEmpty() ? "0" : str);
FluidCraft.proxy.netHandler.sendToServer(
@@ -332,20 +444,18 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
if (this.send(this.getQty())) this.send(this.getBatch());
didSomething = true;
} else if (this.enable == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex()));
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Enable, this.getIndex()));
didSomething = true;
} else if (this.disable == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex()));
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.getQty().textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
if (this.getBatch().textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
if (this.qty.textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
if (this.batch.textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
return null;
}
@@ -362,33 +472,39 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
public void draw() {
this.getQty().draw();
this.getBatch().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 Idling -> {
this.line.setColor(0xFF55FF55);
case Idle -> {
this.line.setColor(FCGuiColors.StateIdle.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
}
case Crafting -> {
this.line.setColor(0xFFFFFF55);
case Craft -> {
this.line.setColor(FCGuiColors.StateCraft.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
}
case Exporting -> {
this.line.setColor(0xFFAA00AA);
case Export -> {
this.line.setColor(FCGuiColors.StateExport.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
}
default -> {
this.line.setColor(0);
case Error -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
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));
}
}
@@ -399,7 +515,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC));
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));
}
@@ -415,7 +533,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
}
public void setState(TileLevelMaintainer.State state) {
public void setState(State state) {
this.state = state;
}
}
@@ -423,15 +541,15 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private class Widget {
public final int idx;
public final String action;
public final Action action;
private final FCGuiTextField textField;
private final String tooltip;
public Widget(FCGuiTextField textField, String tooltip, int idx, String action) {
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.textField.setMaxStringLength(16); // this length is enough to be useful
this.idx = idx;
this.action = action;
this.tooltip = tooltip;
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;
}
}
}
}
@@ -0,0 +1,177 @@
/* Author: asdflj */
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerMagnetFilter;
import com.glodblock.github.client.gui.widget.FCGuiBaseButton;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.item.WirelessMagnet;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.NameConst;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
public class GuiMagnetFilter extends AEBaseMEGui {
protected FCGuiBaseButton listModeBtn;
protected ContainerMagnetFilter cont;
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/magnet_filter.png");
protected Component components[] = new Component[3];
protected GuiTabButton originalGuiBtn;
protected GuiImgButton clearBtn;
public GuiMagnetFilter(InventoryPlayer ip, ITerminalHost container) {
super(new ContainerMagnetFilter(ip, container));
this.xSize = 195;
this.ySize = 214;
this.cont = (ContainerMagnetFilter) this.inventorySlots;
}
private class Component {
private GuiFCImgButton enable;
private GuiFCImgButton disable;
private String action;
private boolean var;
public Component(int x, int y, boolean var, String action) {
this.enable = new GuiFCImgButton(x, y, "ENABLE_12x", "ENABLE", false);
this.disable = new GuiFCImgButton(x, y, "DISABLE_12x", "DISABLE", false);
this.var = var;
this.action = action;
buttonList.add(this.enable);
buttonList.add(this.disable);
}
public boolean sameBtn(GuiButton btn) {
return btn == this.enable || btn == this.disable;
}
public boolean getVar() {
return this.var;
}
public void setVar(boolean var) {
this.var = var;
}
public void send() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(this.action, !this.getVar()));
}
public void draw() {
if (var) {
this.enable.visible = true;
this.disable.visible = false;
} else {
this.enable.visible = false;
this.disable.visible = true;
}
}
}
@Override
public void initGui() {
super.initGui();
this.buttonList.clear();
this.buttonList.add(
this.listModeBtn = new FCGuiBaseButton(
0,
this.guiLeft + 86,
this.guiTop + 4,
64,
14,
NameConst.i18n(
this.cont.listMode == WirelessMagnet.ListMode.WhiteList
? NameConst.GUI_MAGNET_CARD_WhiteList
: NameConst.GUI_MAGNET_CARD_BlackList)));
this.components[0] = new Component(
this.guiLeft + 156,
this.guiTop + 18,
this.cont.nbt,
"WirelessTerminal.magnet.NBT");
this.components[1] = new Component(
this.guiLeft + 156,
this.guiTop + 31,
this.cont.meta,
"WirelessTerminal.magnet.Meta");
this.components[2] = new Component(
this.guiLeft + 156,
this.guiTop + 44,
this.cont.ore,
"WirelessTerminal.magnet.Ore");
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + this.xSize - 44,
this.guiTop - 4,
this.cont.getPortableCell().getItemStack(),
this.cont.getPortableCell().getItemStack().getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13); // GuiTabButton implementation //
this.clearBtn = new GuiImgButton(this.guiLeft + 8, this.guiTop + 48, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRendererObj.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_MAGNET_CARD)), 8, 6, 0x404040);
this.fontRendererObj
.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_MAGNET_CARD_NBT)), 61, 22, 0x404040);
this.fontRendererObj
.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_MAGNET_CARD_META)), 61, 34, 0x404040);
this.fontRendererObj
.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_MAGNET_CARD_ORE)), 61, 46, 0x404040);
this.components[0].setVar(this.cont.nbt);
this.components[1].setVar(this.cont.meta);
this.components[2].setVar(this.cont.ore);
for (Component c : components) {
c.draw();
}
this.listModeBtn.displayString = NameConst.i18n(
this.cont.listMode == WirelessMagnet.ListMode.WhiteList ? NameConst.GUI_MAGNET_CARD_WhiteList
: NameConst.GUI_MAGNET_CARD_BlackList);
}
@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
protected void actionPerformed(GuiButton btn) {
for (Component c : components) {
if (c.sameBtn(btn)) {
c.send();
break;
}
}
if (btn == this.listModeBtn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"WirelessTerminal.magnet.FilterMode",
this.cont.listMode != WirelessMagnet.ListMode.WhiteList));
} else if (btn == this.originalGuiBtn) {
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(this.cont.getPortableCell().getItemStack()));
} else if (btn == this.clearBtn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.magnet.clear", 1));
}
super.actionPerformed(btn);
}
}
@@ -0,0 +1,154 @@
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.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.CPacketPatternMultiSet;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiAmount;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerPatternMulti;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
public class GuiPatternMulti extends GuiAmount {
private static final int DEFAULT_VALUE = 0;
private GuiImgButton symbolSwitch;
protected GuiType originalGui;
@Reflected
public GuiPatternMulti(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerPatternMulti(inventoryPlayer, te));
}
@Override
public void initGui() {
super.initGui();
this.buttonList.add(
this.symbolSwitch = new GuiImgButton(
this.guiLeft + 22,
this.guiTop + 53,
Settings.ACTIONS,
ActionItems.MULTIPLY));
this.amountTextField.x = this.guiLeft + 48;
this.amountTextField.w = 73;
this.amountTextField.setText(String.valueOf(DEFAULT_VALUE));
this.amountTextField.setCursorPositionEnd();
this.amountTextField.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, GuiColors.CraftAmountSelectAmount.getColor());
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.nextBtn.displayString = GuiText.Set.getLocal();
try {
int resultI = getAmount();
this.symbolSwitch.set(resultI >= 0 ? ActionItems.MULTIPLY : ActionItems.DIVIDE);
this.nextBtn.enabled = resultI < -1 || resultI > 1;
} catch (final NumberFormatException e) {
this.nextBtn.enabled = false;
}
this.amountTextField.drawTextBox();
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try {
if (btn == this.nextBtn && btn.enabled) {
int resultI = getAmount();
if (resultI > 1 || resultI < -1)
FluidCraft.proxy.netHandler.sendToServer(new CPacketPatternMultiSet(this.originalGui, resultI));
}
} catch (final NumberFormatException e) {
// nope..
this.amountTextField.setText(String.valueOf(DEFAULT_VALUE));
}
if (btn == this.symbolSwitch) {
int resultI = -getAmount();
this.amountTextField.setText(Integer.toString(resultI));
}
}
@Override
protected int getAmount() {
String out = this.amountTextField.getText();
double resultD = Calculator.conversion(out);
if (Double.isNaN(resultD)) {
return DEFAULT_VALUE;
} else {
return (int) ArithHelper.round(resultD, 0);
}
}
@Override
protected long addOrderAmount(final int i) {
return i + getAmount();
}
@Override
protected String getBackground() {
return "guis/patternMulti.png";
}
@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 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;
}
}
}
@@ -2,7 +2,6 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
@@ -67,16 +66,16 @@ public class GuiPatternValueAmount extends FCGuiAmount {
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
} else if (target instanceof 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 = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
}
}
@@ -1,5 +1,6 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -7,10 +8,19 @@ 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;
@@ -18,10 +28,18 @@ import appeng.core.localization.GuiText;
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
private final MEGuiTextField textField;
protected final MEGuiTextField textField;
protected final ITerminalHost host;
protected GuiTabButton originalGuiBtn;
protected ItemStack icon = null;
protected GuiType originalGui;
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
super(new ContainerRenamer(ip, monitorable));
this.host = monitorable;
this.xSize = 256;
this.textField = new MEGuiTextField(230, 12);
@@ -32,6 +50,29 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
public void initGui() {
super.initGui();
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
if (host instanceof PartLevelTerminal) {
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
originalGui = GuiType.LEVEL_TERMINAL;
} else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host)) {
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (host instanceof WirelessLevelTerminalInventory) {
icon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
} else if (host instanceof WirelessInterfaceTerminalInventory) {
icon = ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack();
originalGui = GuiType.WIRELESS_INTERFACE_TERMINAL;
}
if (this.icon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 231,
this.guiTop - 4,
this.icon,
this.icon.getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13);
}
this.textField.x = this.guiLeft + 12;
this.textField.y = this.guiTop + 35;
this.textField.setFocused(true);
@@ -68,6 +109,21 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
return textField.isMouseIn(mousex, mousey);
}
@Override
protected void actionPerformed(GuiButton button) {
if (button == originalGuiBtn) {
switchGui();
} else {
super.actionPerformed(button);
}
}
public void switchGui() {
if (originalGui != null) {
InventoryHandler.switchGui(originalGui);
}
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
textField.setText(displayName);
}
@@ -7,19 +7,24 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import com.glodblock.github.FluidCraft;
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.GuiInterfaceTerminalWireless;
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.inventory.item.WirelessMagnet;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.storage.StorageChannel;
import appeng.client.gui.AEBaseMEGui;
public abstract class FCBaseMEGui extends AEBaseMEGui {
@@ -29,9 +34,17 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
protected GuiFCImgButton PatternTerminal;
protected GuiFCImgButton EssentiaTerminal;
protected GuiFCImgButton InterfaceTerminal;
protected GuiFCImgButton PatternTerminaleEx;
protected GuiFCImgButton LevelTerminal;
protected GuiFCImgButton PatternTerminalEx;
protected GuiFCImgButton magnetOff;
protected GuiFCImgButton magnetInv;
protected GuiFCImgButton magnetME;
protected GuiFCImgButton magnetFilter;
protected GuiFCImgButton restockEnableBtn;
protected GuiFCImgButton restockDisableBtn;
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
protected boolean drawSwitchGuiBtn;
private StorageChannel channel = null;
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
@@ -40,10 +53,19 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
if (target instanceof IWirelessTerminal
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
channel = ((IWirelessTerminal) target).getChannel();
}
}
}
protected WirelessMagnet.Mode getMagnetMode() {
return ((FCBaseContainer) this.inventorySlots).mode;
}
protected boolean isRestock() {
return ((FCBaseContainer) this.inventorySlots).restock;
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
@@ -59,12 +81,51 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
public abstract void setOffsetY(int y);
@SuppressWarnings("unchecked")
protected void drawSwitchGuiBtns() {
if (!drawSwitchGuiBtn) return;
if (!termBtns.isEmpty()) {
this.termBtns.clear();
}
if (this.getMagnetMode() != null && this.channel == StorageChannel.ITEMS) {
this.buttonList.add(
this.magnetOff = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiTop + this.ySize - 124,
"MAGNET_CARD",
"OFF"));
this.buttonList.add(
this.magnetInv = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiTop + this.ySize - 124,
"MAGNET_CARD",
"INV"));
this.buttonList.add(
this.magnetME = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiTop + this.ySize - 124,
"MAGNET_CARD",
"ME"));
this.buttonList.add(
this.magnetFilter = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiTop + this.ySize - 104,
"MAGNET_CARD",
"FILTER"));
}
if (this.channel == StorageChannel.ITEMS) {
this.buttonList.add(
this.restockEnableBtn = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiTop + this.ySize - 84,
"RESTOCK",
"ENABLE"));
this.buttonList.add(
this.restockDisableBtn = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiTop + this.ySize - 84,
"RESTOCK",
"DISABLE"));
}
if (!(this instanceof GuiFluidCraftingWireless)) {
this.buttonList.add(
this.CraftingTerminal = new GuiFCImgButton(
@@ -87,13 +148,13 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
}
if (!(this instanceof GuiFluidPatternExWireless)) {
this.buttonList.add(
this.PatternTerminaleEx = new GuiFCImgButton(
this.PatternTerminalEx = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"PATTERN_EX_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminaleEx);
termBtns.add(this.PatternTerminalEx);
}
if (!(this instanceof GuiFluidPortableCell)) {
this.buttonList.add(
@@ -101,7 +162,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.FluidTerminal);
}
if (!(this instanceof GuiInterfaceTerminalWireless)) {
if (!(this instanceof GuiInterfaceWireless)) {
this.buttonList.add(
this.InterfaceTerminal = new GuiFCImgButton(
this.guiLeft - 18,
@@ -111,6 +172,12 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.InterfaceTerminal);
}
if (!(this instanceof GuiLevelWireless)) {
this.buttonList.add(
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.LevelTerminal);
}
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
this.buttonList.add(
this.EssentiaTerminal = new GuiFCImgButton(
@@ -128,6 +195,43 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
this.buttonList.addAll(termBtns);
}
private boolean scheduleGuiResize;
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
super.mouseClicked(xCoord, yCoord, btn);
if (scheduleGuiResize) {
// in the GuiScreen class, the implementation of super.mouseClicked
// ends up looping on the button list and execute the action for any
// button below the mouse.
// Therefore, if we initGui() the terminal in the actionPerformed method below
// it will run the actionPerformed a second time for the new button
// that will end up being below the mouse (if any) after the initGui()
buttonList.clear();
initGui();
scheduleGuiResize = false;
}
}
protected final void scheduleGuiResize() {
scheduleGuiResize = true;
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
if (isPortableCell()) return;
if (getMagnetMode() != null && this.channel == StorageChannel.ITEMS) {
GuiFCImgButton[] magnetButtons = { this.magnetOff, this.magnetInv, this.magnetME };
for (int i = 0; i < magnetButtons.length; i++) {
magnetButtons[i].visible = getMagnetMode().ordinal() == i;
}
}
if (this.drawSwitchGuiBtn && this.channel == StorageChannel.ITEMS) { // Only ultra terminal
this.restockDisableBtn.visible = !this.isRestock();
this.restockEnableBtn.visible = this.isRestock();
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn instanceof GuiFCImgButton) {
@@ -141,10 +245,24 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
} else if (btn == this.InterfaceTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
} else if (btn == this.PatternTerminaleEx) {
} 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);
} else if (btn == this.magnetOff || btn == this.magnetME || btn == this.magnetInv) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("WirelessTerminal.MagnetMode", this.getMagnetMode().ordinal()));
} else if (btn == this.magnetFilter) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.OpenMagnet", 0));
} else if (btn == this.restockDisableBtn || btn == this.restockEnableBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.Stock", 1));
}
}
super.actionPerformed(btn);
}
protected boolean isPortableCell() {
return false;
}
}
@@ -7,9 +7,8 @@ import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
@@ -40,13 +39,13 @@ public abstract class FCGuiAmount extends AEBaseGui {
}
@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);
final int a = getIncrementQuantity(0);
final int b = getIncrementQuantity(1);
final int c = getIncrementQuantity(2);
final int d = getIncrementQuantity(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
@@ -65,11 +64,12 @@ public abstract class FCGuiAmount extends AEBaseGui {
if (this.originalGui != null && this.myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154,
this.guiTop,
this.guiLeft + 151,
this.guiTop - 4,
this.myIcon,
this.myIcon.getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13);
}
this.amountBox = new GuiTextField(
@@ -85,6 +85,10 @@ public abstract class FCGuiAmount extends AEBaseGui {
this.amountBox.setFocused(true);
}
protected int getIncrementQuantity(int i) {
return AEConfig.instance.craftItemsByStackAmounts(i);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(getBackground());
@@ -106,7 +110,7 @@ public abstract class FCGuiAmount extends AEBaseGui {
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
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
@@ -5,6 +5,8 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFCImgButton;
@@ -15,7 +17,6 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.storage.ITerminalHost;
@@ -23,7 +24,6 @@ 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;
@@ -54,7 +54,6 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
protected GuiFCImgButton autoFillPatternEnableBtn;
protected GuiFCImgButton autoFillPatternDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public FCGuiEncodeTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te,
final FCContainerEncodeTerminal c) {
@@ -118,10 +117,10 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
"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"));
int val = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? 1 : 0;
if (Mouse.isButtonDown(1)) val |= 0b10;
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Double", String.valueOf(val)));
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "1"));
@@ -184,13 +183,15 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
} else return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
aeRenderItem.setAeStack(fake);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
@@ -70,6 +70,7 @@ import appeng.util.item.AEItemStack;
import codechicken.nei.LayoutManager;
import codechicken.nei.util.TextHistory;
// TODO why is this copy pasting all the UI code from AE2 instead of reusing it ???
public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
implements ISortSource, IConfigManagerHost, IDropToFillTextField {
@@ -101,6 +102,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
protected GuiImgButton terminalStyleBox;
protected GuiImgButton searchStringSave;
protected GuiImgButton typeFilter;
protected boolean hasShiftKeyDown = false;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
@@ -159,20 +161,15 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
iBtn.set(next);
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
this.reInitalize();
memoryText = this.searchField.getText();
super.scheduleGuiResize();
}
}
}
super.actionPerformed(btn);
}
protected void reInitalize() {
this.buttonList.clear();
this.initGui();
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
Keyboard.enableRepeatEvents(true);
@@ -182,7 +179,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = 0;
final int NEI = hasNEI ? 1 : 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
@@ -216,6 +213,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
super.initGui();
this.setScrollBar();
// full size : 204
// extra slots : 72
// slot 18
@@ -589,6 +587,18 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
memoryText = this.searchField.getText();
}
@Override
public void handleKeyboardInput() {
super.handleKeyboardInput();
// Pause the terminal when holding shift
this.repo.setPaused(hasShiftDown());
}
private boolean hasShiftDown() {
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
}
public void bindTextureBack(final String file) {
final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file);
this.mc.getTextureManager().bindTexture(loc);
@@ -686,12 +696,13 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
@Override
public Enum getTypeFilter() {
public Enum<?> getTypeFilter() {
return this.configSrc.getSetting(Settings.TYPE_FILTER);
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
public void updateSetting(final IConfigManager manager, @SuppressWarnings("rawtypes") final Enum settingName,
@SuppressWarnings("rawtypes") final Enum newValue) {
if (this.SortByBox != null) {
this.SortByBox.set(this.configSrc.getSetting(Settings.SORT_BY));
}
@@ -6,6 +6,7 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.inventory.item.IWirelessCraftTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
@@ -36,7 +37,16 @@ public class ContainerCraftingWireless extends ContainerItemMonitor
crafting,
x + y * 3,
37 + x * 18,
-72 + y * 18));
-72 + y * 18) {
@Override
public void onSlotChanged() {
if (this.inventory instanceof ItemBiggerAppEngInventory i) {
i.markDirty();
}
super.onSlotChanged();
}
});
}
}
AppEngInternalInventory output = new AppEngInternalInventory(this, 1);
@@ -1,7 +1,6 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -23,7 +22,6 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
@@ -37,110 +35,118 @@ public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
&& AspectUtil.isEssentiaContainer(clickSlot.getStack())) {
ItemStack tis = clickSlot.getStack();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
tmp.put(0, null);
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(index));
}
}
return super.transferStackInSlot(p, idx);
}
@Override
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player,
int slotIndex) {
for (IAEFluidStack fluid : change) {
IAEFluidStack nfluid = this.monitor.getStorageList().findPrecise(fluid);
ItemStack out = fluidContainer.copy();
out.stackSize = 1;
if (AspectUtil.isEmptyEssentiaContainer(fluidContainer) && AspectUtil.isEssentiaGas(fluid)) {
// add essentia to jars
if (nfluid.getStackSize() / AspectUtil.R <= 0) continue;
final IAEFluidStack toExtract = nfluid.copy();
MutablePair<Integer, ItemStack> fillStack = AspectUtil
.fillEssentiaFromGas(out, toExtract.getFluidStack());
if (fillStack == null || fillStack.right == null || fillStack.left <= 0) continue;
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
IAEFluidStack tmp = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
if (tmp == null) continue;
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
this.dropItem(
AspectUtil.setAspectAmount(
fillStack.right,
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
AspectUtil.getAspectFromGas(toExtract)),
1);
out.stackSize++;
}
}
} else if (!AspectUtil.isEmptyEssentiaContainer(fluidContainer)) {
// add essentia to ae network
AEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(fluidContainer);
if (fluidStack == null) {
continue;
}
final IAEFluidStack aeFluidStack = fluidStack.copy();
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
MutablePair<Integer, ItemStack> drainStack = AspectUtil
.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
if (fluidStack.getStackSize() == notInserted.getStackSize()) continue;
aeFluidStack.decStackSize(notInserted.getStackSize());
public void postChange(IAEFluidStack clientSelectedFluid, EntityPlayer player, int slotIndex, boolean shift) {
ItemStack targetStack;
if (slotIndex == -1) {
targetStack = player.inventory.getItemStack();
} else {
targetStack = player.inventory.getStackInSlot(slotIndex);
}
final int containersRequested = shift ? targetStack.stackSize : 1;
if (drainStack.left > aeFluidStack.getStackSize()
&& AspectUtil.isEssentiaContainer(drainStack.right)) {
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
this.host.getFluidInventory()
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
continue;
}
// drop empty item
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
if (notInserted.getStackSize() % drainStack.left > 0) {
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
this.dropItem(drainStack.right, 1);
}
}
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
} else if (drainStack != null) {
if (slotIndex == -1) {
out.stackSize = fluidContainer.stackSize;
} else {
out.stackSize = (int) (fluidContainer.stackSize
- (aeFluidStack.getStackSize() / drainStack.left));
}
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
}
} else {
continue;
IAEFluidStack storedFluid = this.monitor.getStorageList().findPrecise(clientSelectedFluid);
ItemStack out = targetStack.copy();
out.stackSize = 1;
if (AspectUtil.isEmptyEssentiaContainer(targetStack) && AspectUtil.isEssentiaGas(storedFluid)) {
// add essentia to jars
if (storedFluid.getStackSize() / AspectUtil.R <= 0) {
return;
}
if (slotIndex == -1) {
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
if (player.inventory.getItemStack().stackSize > 0) {
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
(EntityPlayerMP) player);
final IAEFluidStack toExtract = storedFluid.copy();
MutablePair<Integer, ItemStack> fillStack = AspectUtil.fillEssentiaFromGas(out, toExtract.getFluidStack());
if (fillStack == null || fillStack.right == null || fillStack.left <= 0) {
return;
}
toExtract.setStackSize((long) fillStack.left * containersRequested);
IAEFluidStack tmp = this.host.getFluidInventory()
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
if (tmp == null) {
return;
}
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
this.dropItem(
AspectUtil.setAspectAmount(
fillStack.right,
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
AspectUtil.getAspectFromGas(toExtract)),
1);
out.stackSize++;
}
}
} else if (!AspectUtil.isEmptyEssentiaContainer(targetStack)) {
// add essentia to ae network
ItemStack containerStack = targetStack.copy();
containerStack.stackSize = containersRequested;
IAEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(containerStack);
if (fluidStack == null) {
return;
}
final IAEFluidStack aeFluidStack = fluidStack.copy();
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
MutablePair<Integer, ItemStack> drainStack = AspectUtil
.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
if (fluidStack.getStackSize() == notInserted.getStackSize()) {
return;
}
aeFluidStack.decStackSize(notInserted.getStackSize());
if (drainStack.left > aeFluidStack.getStackSize() && AspectUtil.isEssentiaContainer(drainStack.right)) {
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
this.host.getFluidInventory()
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
return;
}
// drop empty item
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
if (notInserted.getStackSize() % drainStack.left > 0) {
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
this.dropItem(drainStack.right, 1);
}
}
if (slotIndex == -1) out.stackSize = targetStack.stackSize - out.stackSize;
} else if (drainStack != null) {
if (slotIndex == -1) {
out.stackSize = targetStack.stackSize;
} else {
player.inventory.setItemStack(null);
FluidCraft.proxy.netHandler
.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
out.stackSize = (int) (targetStack.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
}
} else {
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
this.dropItem(drainStack.right, targetStack.stackSize); // drop empty item
}
} else {
return;
}
if (slotIndex == -1) {
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
if (player.inventory.getItemStack().stackSize > 0) {
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
(EntityPlayerMP) player);
} else {
player.inventory.setItemStack(null);
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
} else {
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
}
this.detectAndSendChanges();
}
@@ -9,14 +9,21 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerCraftConfirm;
import appeng.container.implementations.ContainerOptimizePatterns;
import appeng.crafting.v2.CraftingJobV2;
import appeng.tile.misc.TilePatternOptimizationMatrix;
public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
@@ -35,6 +42,9 @@ public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (ah instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
}
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
@@ -57,4 +67,34 @@ public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
originalGui);
}
}
@Override
public void optimizePatterns() {
// only V2 supported
IGrid grid = Ae2Reflect.getGrid(this);
ICraftingJob result = Ae2Reflect.getResult(this);
if (result instanceof CraftingJobV2 && !this.isSimulation()
&& grid != null
&& !grid.getMachines(TilePatternOptimizationMatrix.class).isEmpty()) {
final IActionHost ah = this.getActionHost();
if (ah instanceof IWirelessTerminal) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
GuiType.FLUID_OPTIMIZE_PATTERNS_ITEM);
} else if (this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
GuiType.FLUID_OPTIMIZE_PATTERNS);
}
if (this.getPlayerInv().player.openContainer instanceof ContainerOptimizePatterns cop) {
cop.setResult(result);
}
}
}
}
@@ -3,7 +3,6 @@ package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -18,7 +17,7 @@ import net.minecraftforge.fluids.IFluidContainerItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
@@ -44,7 +43,6 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
@@ -124,11 +122,8 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
&& Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
ItemStack tis = clickSlot.getStack();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
tmp.put(0, ItemFluidDrop.getAeFluidStack(AEItemStack.create(tis)));
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(index));
}
}
return super.transferStackInSlot(p, idx);
@@ -211,72 +206,26 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
* @param slotIndex The slot. If index == -1, the cursor held itemstack. Else, slotIndex indicates which slot was
* shift clicked on.
*/
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player,
int slotIndex) {
int cursorItems;
public void postChange(IAEFluidStack fluid, EntityPlayer player, int slotIndex, boolean shift) {
ItemStack targetStack;
if (slotIndex == -1) {
cursorItems = player.inventory.getItemStack().stackSize;
targetStack = player.inventory.getItemStack();
} else {
cursorItems = player.inventory.getStackInSlot(slotIndex).stackSize;
targetStack = player.inventory.getStackInSlot(slotIndex);
}
for (IAEFluidStack fluid : change) {
// The primary output itemstack
if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) {
// Situation 1.a: Empty fluid container, and nonnull slot
extractFluid(fluid, fluidContainer, player, cursorItems);
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
// Situation 2.a: We are holding a non-empty container.
insertFluid(fluidContainer, player, slotIndex, cursorItems);
// End of situation 2.a
}
// No op (Any other situation)
// The primary output itemstack
if (Util.FluidUtil.isEmpty(targetStack) && fluid != null) {
// Situation 1.a: Empty fluid container, and nonnull slot
extractFluid(fluid, player, slotIndex, shift);
} else if (!Util.FluidUtil.isEmpty(targetStack)) {
// Situation 2.a: We are holding a non-empty container.
insertFluid(player, slotIndex, shift);
// End of situation 2.a
}
// No op (Any other situation)
this.detectAndSendChanges();
}
/**
* Insert fluid into the ME system
*
* @param canSend the fluidstack to insert
* @param results a tuple of at least size 3 to indicate outputs (1), (2), (3). This will be mutated!
* @param numTanks number of tanks involved in the operation
* @param fluidInTank how much fluid is in the tank initially
* @return the amount of fluid remaining in output (3)
* @see #insertFluid(ItemStack, EntityPlayer, int, int)
*/
private int insertME(IAEFluidStack canSend, int[] results, int numTanks, int fluidInTank) {
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(canSend, Actionable.MODULATE, this.getActionSource());
// Check if we need to handle partial insertion.
if (notInserted != null && notInserted.getStackSize() > 0) {
if (canSend.getStackSize() == notInserted.getStackSize()) {
// No-op for when system is full
results[REM_IDX] = numTanks;
return fluidInTank;
}
// Populate result list with outputs (1), (2), (3).
results[REM_IDX] = (int) (notInserted.getStackSize() / fluidInTank);
results[ACT_IDX] = numTanks - results[REM_IDX];
// If there is remaining fluid, set partial.
final int remainder = (int) (notInserted.getStackSize() % fluidInTank);
if (remainder > 0) {
results[PARTIAL_IDX] = 1;
results[ACT_IDX]--;
return remainder;
} else {
results[PARTIAL_IDX] = 0;
}
} else {
// Full operation successful
results[REM_IDX] = 0;
results[ACT_IDX] = numTanks;
results[PARTIAL_IDX] = 0;
}
return 0;
}
/**
* The insert operation. For input, we have a filled container stack. For outputs, we have the following:
* <ol>
@@ -286,122 +235,167 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
*/
private void insertFluid(ItemStack fluidContainer, EntityPlayer player, int slotIndex, int heldContainers) {
IAEFluidStack canSend;
int fluidPerContainer;
ItemStack partialStack = null;
ItemStack emptyStack = null;
int[] insertionResults = new int[3];
private void insertFluid(EntityPlayer player, int slotIndex, boolean shift) {
final ItemStack targetStack;
if (slotIndex == -1) {
targetStack = player.inventory.getItemStack();
} else {
targetStack = player.inventory.getStackInSlot(slotIndex);
}
final int containersRequestedToInsert = shift ? targetStack.stackSize : 1;
// 2 types of containers: IFluidContainerItem and FluidContainerRegistry
// IFluidContainerItem - items are filled w/ volume (portable tanks)
// FluidContainerRegistry - items are filled, or not (buckets)
// The former is easy, the latter takes a bit more work.
if (fluidContainer.getItem() instanceof IFluidContainerItem fcItem) {
// Step 1: Find out how much fluid we can insert.
canSend = AEFluidStack.create(fcItem.getFluid(fluidContainer));
fluidPerContainer = (int) canSend.getStackSize();
canSend.setStackSize((long) fluidPerContainer * fluidContainer.stackSize);
// Step 2: Find out how much fluid we can extract from the container. If this is null or 0, return.
ItemStack test = fluidContainer.copy();
// Step 1: Determine container characteristics and verify fluid to be extractable
final int fluidPerContainer;
final FluidStack fluidStackPerContainer;
final boolean partialInsertSupported;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
ItemStack test = targetStack.copy();
test.stackSize = 1;
FluidStack fluidStack = fcItem.drain(test, fluidPerContainer, false);
if (fluidStack == null || fluidStack.amount == 0) {
fluidStackPerContainer = fcItem.drain(test, Integer.MAX_VALUE, false);
if (fluidStackPerContainer == null || fluidStackPerContainer.amount == 0) {
return;
}
// Step 3: Find out how much fluid we can insert into the ME system
int partialAmount = insertME(canSend, insertionResults, fluidContainer.stackSize, fluidPerContainer);
// Step 4: Separate the outputs into no drain (1), fully drained (2), and partially drained (3)
// 4.1: Handle the partial stack
if (insertionResults[PARTIAL_IDX] > 0) {
partialStack = fluidContainer.copy();
partialStack.stackSize = 1;
fcItem.drain(partialStack, fluidPerContainer - partialAmount, true);
}
// 4.2: Handle empty output
if (insertionResults[ACT_IDX] > 0) {
emptyStack = fluidContainer.copy();
emptyStack.stackSize = 1;
fcItem.drain(emptyStack, fluidPerContainer, true);
emptyStack.stackSize = insertionResults[ACT_IDX];
}
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
// Step 1: Find out how much fluid we can insert.
canSend = AEFluidStack.create(FluidContainerRegistry.getFluidForFilledItem(fluidContainer));
fluidPerContainer = (int) canSend.getStackSize();
canSend.setStackSize((long) fluidPerContainer * fluidContainer.stackSize);
// Step 2: Find out how much fluid we can extract from the container. If this is null or 0, return.
ItemStack emptyTank = FluidContainerRegistry.drainFluidContainer(fluidContainer);
fluidPerContainer = fluidStackPerContainer.amount;
partialInsertSupported = true;
} else if (FluidContainerRegistry.isContainer(targetStack)) {
ItemStack emptyTank = FluidContainerRegistry.drainFluidContainer(targetStack);
if (emptyTank == null) {
return;
}
// Step 3: Find out how much fluid we can insert into the ME system
int partialAmount = insertME(canSend, insertionResults, fluidContainer.stackSize, fluidPerContainer);
// Step 4: Separate the outputs into no drain (1), fully drained (2), and partially drained (3)
// 4.1: Handle the partial stack
if (partialAmount > 0) {
// We now extract the extra amount from the ME system. Blame simulate not working :P
int extract = FluidContainerRegistry.getContainerCapacity(fluidContainer) - partialAmount;
if (extract > 0) {
IAEFluidStack toExtract = canSend.copy().setStackSize(extract);
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
}
insertionResults[PARTIAL_IDX] = 0;
}
// 4.2: Handle empty output
if (insertionResults[ACT_IDX] > 0) {
emptyStack = FluidContainerRegistry.drainFluidContainer(fluidContainer);
emptyStack.stackSize = insertionResults[ACT_IDX];
}
fluidStackPerContainer = FluidContainerRegistry.getFluidForFilledItem(targetStack);
fluidPerContainer = fluidStackPerContainer.amount;
partialInsertSupported = false;
} else {
return;
}
// Step 2: determine network capacity
final IAEFluidStack totalFluid = AEFluidStack.create(fluidStackPerContainer);
totalFluid.setStackSize((long) fluidPerContainer * containersRequestedToInsert);
final IAEFluidStack notInsertable = this.host.getFluidInventory()
.injectItems(totalFluid, Actionable.SIMULATE, this.getActionSource());
final long insertableFluid;
if (notInsertable == null || notInsertable.getStackSize() == 0) {
insertableFluid = totalFluid.getStackSize();
} else {
long insertable = totalFluid.getStackSize() - notInsertable.getStackSize();
if (partialInsertSupported) {
insertableFluid = insertable;
} else {
// avoid remainder
insertableFluid = insertable - (insertable % fluidPerContainer);
}
}
totalFluid.setStackSize(insertableFluid);
// Step 3: perform insert
final long totalInserted;
final IAEFluidStack notInserted = this.host.getFluidInventory()
.injectItems(totalFluid, Actionable.MODULATE, this.getActionSource());
if (notInserted != null && notInserted.getStackSize() > 0) {
// User has a setup that causes discrepancy between simulation and modulation. Likely double storage bus.
long total = totalFluid.getStackSize() - notInserted.getStackSize();
if (partialInsertSupported) {
totalInserted = total;
} else {
// We cant have partially filled containers -> user will receive a fluid packet as last resort
long overflowAmount = fluidPerContainer - (total % fluidPerContainer);
IAEFluidStack overflow = AEFluidStack.create(fluidStackPerContainer);
overflow.setStackSize(overflowAmount);
dropItem(ItemFluidPacket.newStack(overflow));
totalInserted = total + overflowAmount;
}
} else {
totalInserted = totalFluid.getStackSize();
}
// Step 4: calculate outputs
final int emptiedTanks;
final int partialDrain;
if (fluidPerContainer > 0) {
emptiedTanks = (int) (totalInserted / fluidPerContainer);
partialDrain = (int) (totalInserted % fluidPerContainer);
} else {
emptiedTanks = containersRequestedToInsert;
partialDrain = 0;
}
final int partialTanks = partialDrain > 0 && partialInsertSupported ? 1 : 0;
final int usedTanks = emptiedTanks + partialTanks;
final int untouchedTanks = targetStack.stackSize - usedTanks;
final ItemStack emptiedTanksStack;
final ItemStack partialTanksStack;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
if (emptiedTanks > 0) {
final ItemStack testDrainStack = targetStack.copy();
testDrainStack.stackSize = 1;
fcItem.drain(testDrainStack, fluidPerContainer, true);
if (testDrainStack.stackSize == 0) {
emptiedTanksStack = null;
} else {
emptiedTanksStack = testDrainStack.copy();
emptiedTanksStack.stackSize = emptiedTanks;
}
} else {
emptiedTanksStack = null;
}
if (partialTanks > 0) {
partialTanksStack = targetStack.copy();
partialTanksStack.stackSize = 1;
fcItem.drain(partialTanksStack, partialDrain, true);
} else {
partialTanksStack = null;
}
} else {
if (emptiedTanks > 0) {
emptiedTanksStack = FluidContainerRegistry.drainFluidContainer(targetStack);
emptiedTanksStack.stackSize = emptiedTanks;
} else {
emptiedTanksStack = null;
}
// Not possible > see Step 2 and Step 3
partialTanksStack = null;
}
// Done. Put the output in the inventory or ground, and update stack size.
boolean shouldSendStack = true;
int emptyTanks = insertionResults[ACT_IDX];
int extraTanks = heldContainers - emptyTanks - insertionResults[PARTIAL_IDX];
if (slotIndex == -1) {
// Item is in mouse hand
if (extraTanks > 0) {
ItemStack stack = player.inventory.getItemStack();
stack.stackSize = extraTanks;
adjustStack(stack);
dropItem(emptyStack);
dropItem(partialStack);
} else if (emptyTanks != 0) {
adjustStack(emptyStack);
player.inventory.setItemStack(emptyStack);
dropItem(partialStack);
} else if (partialStack != null) {
player.inventory.setItemStack(partialStack);
if (untouchedTanks > 0) {
targetStack.stackSize = untouchedTanks;
adjustStack(targetStack);
dropItem(emptiedTanksStack);
dropItem(partialTanksStack);
} else if (emptiedTanksStack != null) {
adjustStack(emptiedTanksStack);
player.inventory.setItemStack(emptiedTanksStack);
dropItem(partialTanksStack);
} else if (partialTanksStack != null) {
player.inventory.setItemStack(partialTanksStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
}
} else {
// Shift clicked in
ItemStack stack = player.inventory.getStackInSlot(slotIndex);
if (extraTanks > 0) {
stack.stackSize = extraTanks;
adjustStack(stack);
dropItem(emptyStack);
dropItem(partialStack);
} else if (emptyTanks != 0) {
adjustStack(emptyStack);
player.inventory.setInventorySlotContents(slotIndex, emptyStack);
dropItem(partialStack);
} else if (partialStack != null) {
player.inventory.setInventorySlotContents(slotIndex, partialStack);
if (untouchedTanks > 0) {
targetStack.stackSize = untouchedTanks;
adjustStack(targetStack);
dropItem(emptiedTanksStack);
dropItem(partialTanksStack);
} else if (emptiedTanksStack != null) {
adjustStack(emptiedTanksStack);
player.inventory.setInventorySlotContents(slotIndex, emptiedTanksStack);
dropItem(partialTanksStack);
} else if (partialTanksStack != null) {
player.inventory.setInventorySlotContents(slotIndex, partialTanksStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
player.inventory.setInventorySlotContents(slotIndex, null);
}
}
if (shouldSendStack) {
@@ -422,97 +416,119 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
* </ol>
* In order above, the itemstack at `slotIndex` is transformed into the output.
*/
private void extractFluid(IAEFluidStack fluid, ItemStack fluidContainer, EntityPlayer player, int heldContainers) {
// Step 1: Check if fluid can actually get filled into the fluidContainer
if (fluidContainer.getItem() instanceof IFluidContainerItem fcItem) {
ItemStack testStack = fluidContainer.copy();
private void extractFluid(IAEFluidStack clientRequestedFluid, EntityPlayer player, int slotIndex, boolean shift) {
if (slotIndex != -1) {
// shift-click from inventory cant fill fluids
return;
}
final ItemStack targetStack = player.inventory.getItemStack();
final int containersRequestedToExtract = shift ? targetStack.stackSize : 1;
final FluidStack clientRequestedFluidStack = clientRequestedFluid.getFluidStack();
clientRequestedFluidStack.amount = Integer.MAX_VALUE;
// Step 1: Determine container characteristics and verify fluid to be insertable
final int fluidPerContainer;
final boolean partialInsertSupported;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
ItemStack testStack = targetStack.copy();
testStack.stackSize = 1;
int test = fcItem.fill(testStack, fluid.getFluidStack(), false);
if (test == 0) {
return;
}
} else if (FluidContainerRegistry.isContainer(fluidContainer)) {
ItemStack test = FluidContainerRegistry.fillFluidContainer(fluid.getFluidStack(), fluidContainer);
if (test == null) {
fluidPerContainer = fcItem.fill(testStack, clientRequestedFluidStack, false);
if (fluidPerContainer == 0) {
return;
}
partialInsertSupported = true;
} else if (FluidContainerRegistry.isContainer(targetStack)) {
fluidPerContainer = FluidContainerRegistry.getContainerCapacity(clientRequestedFluidStack, targetStack);
partialInsertSupported = false;
} else {
return;
}
IAEFluidStack storedFluid = this.monitor.getStorageList().findPrecise(fluid);
if (storedFluid == null || storedFluid.getStackSize() <= 0) return;
int capacity = Util.FluidUtil.getCapacity(fluidContainer, storedFluid.getFluid());
if (capacity == 0) return;
// The fluidstack that we will try to extract from the system.
final IAEFluidStack canExtract = storedFluid.copy();
// Maximum amount of fluid we can extract with the given container(s). Guarantees that we won't
// run into issues w/ remainder fluid later.
canExtract.setStackSize((long) capacity * fluidContainer.stackSize);
IAEFluidStack actualExtract = this.host.getFluidInventory()
.extractItems(canExtract, Actionable.MODULATE, this.getActionSource());
if (actualExtract == null) return;
// Calculate the number of full fluid containers we extracted
long toExtract = actualExtract.getStackSize();
int filledTanks = (int) (toExtract / capacity);
int remainder = (int) (toExtract % capacity);
int emptyTanks = heldContainers - filledTanks;
// Fill the filled tanks
ItemStack filledStack = fluidContainer.copy();
filledStack.stackSize = 1;
if (filledTanks > 0) {
if (filledStack.getItem() instanceof IFluidContainerItem) {
int amt = ((IFluidContainerItem) filledStack.getItem())
.fill(filledStack, actualExtract.getFluidStack(), true);
assert amt == capacity;
} else {
// Should not be NPE since we affirmed that we have enough capacity.
filledStack = FluidContainerRegistry.fillFluidContainer(actualExtract.getFluidStack(), filledStack);
assert capacity == FluidContainerRegistry.getContainerCapacity(filledStack);
}
filledStack.stackSize = filledTanks;
} else {
filledStack.stackSize = 0;
// Step 2: determine fluid in network
final IAEFluidStack totalRequestedFluid = clientRequestedFluid.copy();
totalRequestedFluid.setStackSize((long) fluidPerContainer * containersRequestedToExtract);
final IAEFluidStack availableFluid = this.host.getFluidInventory()
.extractItems(totalRequestedFluid, Actionable.SIMULATE, this.getActionSource());
if (availableFluid == null || availableFluid.getStackSize() == 0) {
return;
}
// Calculate the remaining fluid to extract, if any
ItemStack partialStack = fluidContainer.copy();
if (remainder > 0) {
actualExtract.setStackSize(remainder);
partialStack.stackSize = 1;
if (partialStack.getItem() instanceof IFluidContainerItem) {
int amt = ((IFluidContainerItem) partialStack.getItem())
.fill(partialStack, actualExtract.getFluidStack(), true);
assert amt == remainder;
emptyTanks--;
if (availableFluid.getStackSize() != totalRequestedFluid.getStackSize() && !partialInsertSupported) {
availableFluid.decStackSize(availableFluid.getStackSize() % fluidPerContainer);
}
// Step 3: perform extract
final IAEFluidStack extracted = this.host.getFluidInventory()
.extractItems(availableFluid, Actionable.MODULATE, this.getActionSource());
final long totalExtracted = extracted != null ? extracted.getStackSize() : 0;
// Step 4: calculate outputs
final int filledTanks = (int) (totalExtracted / fluidPerContainer);
final int partialFill = (int) (totalExtracted % fluidPerContainer);
final int partialTanks = partialFill > 0 && partialInsertSupported ? 1 : 0;
final int usedTanks = filledTanks + partialTanks;
final int untouchedTanks = targetStack.stackSize - usedTanks;
final ItemStack filledTanksStack;
final ItemStack partialTanksStack;
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
if (filledTanks > 0) {
filledTanksStack = targetStack.copy();
filledTanksStack.stackSize = 1;
FluidStack toInsert = extracted.getFluidStack().copy();
toInsert.amount = fluidPerContainer;
fcItem.fill(filledTanksStack, toInsert, true);
filledTanksStack.stackSize = filledTanks;
} else {
ItemStack dummy = FluidContainerRegistry
.fillFluidContainer(actualExtract.getFluidStack(), partialStack);
if (dummy == null) {
// Failed to fill partial...
partialStack.stackSize = 0;
} else {
partialStack = dummy;
emptyTanks--;
}
filledTanksStack = null;
}
if (partialTanks > 0) {
partialTanksStack = targetStack.copy();
partialTanksStack.stackSize = 1;
FluidStack toInsert = extracted.getFluidStack().copy();
toInsert.amount = partialFill;
fcItem.fill(partialTanksStack, toInsert, true);
} else {
partialTanksStack = null;
}
} else {
partialStack.stackSize = 0;
if (filledTanks > 0) {
FluidStack toInsert = extracted.getFluidStack().copy();
toInsert.amount = fluidPerContainer;
filledTanksStack = FluidContainerRegistry.fillFluidContainer(toInsert, targetStack);
filledTanksStack.stackSize = filledTanks;
} else {
filledTanksStack = null;
}
if (partialFill > 0) {
// User has a setup that causes discrepancy between simulation and modulation. Likely double storage
// bus.
// We cant have partially filled containers -> user will receive a fluid packet as last resort
IAEFluidStack overflow = extracted.copy();
overflow.setStackSize(partialFill);
dropItem(ItemFluidPacket.newStack(overflow));
}
partialTanksStack = null;
}
// Done. Put the output in the inventory or ground, and update stack size.
// We can assume slotIndex == -1, since we don't actually allow extraction via shift click.
boolean shouldSendStack = true;
if (emptyTanks > 0) {
if (untouchedTanks > 0) {
ItemStack emptyStack = player.inventory.getItemStack();
emptyStack.stackSize = emptyTanks;
emptyStack.stackSize = untouchedTanks;
adjustStack(emptyStack);
dropItem(filledStack);
dropItem(partialStack);
} else if (filledStack.stackSize != 0) {
adjustStack(filledStack);
player.inventory.setItemStack(filledStack);
dropItem(partialStack);
} else if (partialStack.stackSize != 0) {
player.inventory.setItemStack(partialStack);
dropItem(filledTanksStack);
dropItem(partialTanksStack);
} else if (filledTanksStack != null) {
adjustStack(filledTanksStack);
player.inventory.setItemStack(filledTanksStack);
dropItem(partialTanksStack);
} else if (partialTanksStack != null) {
player.inventory.setItemStack(partialTanksStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
@@ -0,0 +1,69 @@
package com.glodblock.github.client.gui.container;
import java.util.Objects;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerOptimizePatterns;
public class ContainerFluidOptimizePatterns extends ContainerOptimizePatterns {
public ContainerFluidOptimizePatterns(InventoryPlayer ip, ITerminalHost te) {
super(ip, te);
}
public World getWorld() {
return this.getPlayerInv().player.worldObj;
}
@Override
public void switchToOriginalGUI() {
GuiType originalGui = null;
final IActionHost ah = this.getActionHost();
if (ah instanceof PartFluidPatternTerminal) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (ah instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
}
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
originalGui = ((ItemBaseWirelessTerminal) terminal.getItem()).guiGuiType(terminal);
}
}
if (ah instanceof IWirelessTerminal) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
originalGui);
} else if (this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
}
}
}
@@ -165,6 +165,7 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
}
default -> {}
}
} else {
super.doAction(player, action, slotId, id);
@@ -153,9 +153,9 @@ public class ContainerFluidPatternTerminal extends FCContainerEncodeTerminal {
}
@Override
public void doubleStacks(boolean isShift) {
public void doubleStacks(int val) {
if (!isCraftingMode()) {
super.doubleStacks(isShift);
super.doubleStacks(val);
}
}
}
@@ -23,6 +23,7 @@ import appeng.api.storage.data.IItemList;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.IterationCounter;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
@@ -156,7 +157,7 @@ public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
Iterator<IAEFluidStack> i = new NullIterator<>();
if (cellInv != null) {
final IItemList<IAEFluidStack> list = cellInv
.getAvailableItems(AEApi.instance().storage().createFluidList());
.getAvailableItems(AEApi.instance().storage().createFluidList(), IterationCounter.fetchNewId());
i = list.iterator();
}
@@ -1,58 +1,23 @@
package com.glodblock.github.client.gui.container;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
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.container.implementations.ContainerInterfaceTerminal;
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();
ContainerInterfaceTerminal delegateContainer;
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable);
if (Platform.isServer()) {
this.grid = monitorable.getActionableNode().getGrid();
}
delegateContainer = new ContainerInterfaceTerminal(ip, monitorable);
this.bindPlayerInventory(ip, 14, 0);
}
@@ -64,330 +29,16 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
}
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()) {
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
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();
}
delegateContainer.detectAndSendChanges();
}
@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()) {
for (var clz : InterfaceTerminalSupportedClassProvider.getSupportedClasses()) {
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());
}
delegateContainer.doAction(player, action, slot, id);
}
@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;
}
}
}
@@ -1,16 +1,25 @@
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.util.item.AEItemStack;
import appeng.helpers.InventoryAction;
import appeng.util.Platform;
public class ContainerLevelMaintainer extends AEBaseContainer {
@@ -37,15 +46,112 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
return this.requestSlots;
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
Slot slot = getSlot(slotId);
if (slot instanceof SlotFluidConvertingFake) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN -> {
if (stack == null) {
slot.putStack(null);
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(createLevelValues(stack.copy()));
}
}
case PLACE_SINGLE -> {
if (stack != null) {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
}
case SPLIT_OR_PLACE_SINGLE -> {
ItemStack inSlot = slot.getStack();
if (inSlot != null) {
if (stack == null) {
slot.putStack(
createLevelValues(
Objects.requireNonNull(
Util.copyStackWithSize(
inSlot,
Math.max(1, inSlot.stackSize - 1)))));
} else if (stack.isItemEqual(inSlot)) {
slot.putStack(
createLevelValues(
Objects.requireNonNull(
Util.copyStackWithSize(
inSlot,
Math.min(
inSlot.getMaxStackSize(),
inSlot.stackSize + 1)))));
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
} else if (stack != null) {
((SlotFluidConvertingFake) slot).putConvertedStack(
createLevelValues(Objects.requireNonNull(Util.copyStackWithSize(stack, 1))));
}
}
default -> {}
}
} else {
super.doAction(player, action, slotId, id);
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
if (Platform.isClient()) {
return null;
}
for (int i = 0; i < this.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.getRequestSlots()[i];
if (!slot.getHasStack()) {
slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true);
ItemStack itemStack = ((Slot) this.inventorySlots.get(idx)).getStack();
ItemStack configuration = createLevelValues(itemStack.copy());
configuration.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putConvertedStack(configuration);
break;
}
}
this.detectAndSendChanges();
return null;
}
@Override
public void detectAndSendChanges() {
this.verifyPermissions(SecurityPermissions.BUILD, false);
super.detectAndSendChanges();
}
public static ItemStack createLevelValues(ItemStack itemStack) {
var data = itemStack.hasTagCompound() ? itemStack.getTagCompound() : new NBTTagCompound();
if (!data.hasKey(TLMTags.Stack.tagName)) {
var itemStackTag = new NBTTagCompound();
itemStack.copy().writeToNBT(itemStackTag);
data.setTag(TLMTags.Stack.tagName, itemStackTag);
}
if (!data.hasKey(TLMTags.Quantity.tagName)) {
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize > 0 ? itemStack.stackSize : 1);
}
if (!data.hasKey(TLMTags.Batch.tagName)) {
data.setLong(TLMTags.Batch.tagName, 1);
}
if (!data.hasKey(TLMTags.Enable.tagName)) {
data.setBoolean(TLMTags.Enable.tagName, false);
}
if (data.hasKey(TLMTags.Index.tagName)) {
data.removeTag(TLMTags.Index.tagName);
}
data.setInteger(TLMTags.State.tagName, State.None.ordinal());
itemStack.setTagCompound(data);
return itemStack;
}
}
@@ -0,0 +1,406 @@
package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
import com.google.common.primitives.Ints;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.api.util.DimensionalCoord;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.ItemSlot;
public class ContainerLevelTerminal extends FCBaseContainer {
/**
* this stuff is all server side
*/
private int nextId = 0;
private final Map<IGridHost, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
private IGrid grid;
private SPacketLevelTerminalUpdate dirty;
private boolean isDirty;
private boolean wasOff;
private int ticks = 0;
public ContainerLevelTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
if (Platform.isServer()) {
if (monitorable instanceof PartLevelTerminal terminal) {
grid = terminal.getActionableNode().getGrid();
} else if (monitorable instanceof IWirelessTerminal wirelessTerminal) {
grid = wirelessTerminal.getActionableNode().getGrid();
}
dirty = this.updateList();
if (dirty != null) {
this.isDirty = true;
} else {
dirty = new SPacketLevelTerminalUpdate();
}
}
this.bindPlayerInventory(ip, 14, 0);
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
super.detectAndSendChanges();
if (this.grid == null) {
return;
}
final IActionHost host = this.getActionHost();
if (!host.getActionableNode().isActive()) {
if (!wasOff) {
SPacketLevelTerminalUpdate update = new SPacketLevelTerminalUpdate();
update.setDisconnect();
wasOff = true;
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
return;
}
wasOff = false;
if (isDirty) {
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) this.getPlayerInv().player);
dirty = new SPacketLevelTerminalUpdate();
isDirty = false;
} else if (++ticks % 20 == 0) {
ticks = 0;
SPacketLevelTerminalUpdate update = this.updateList();
if (update != null) {
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
}
}
/**
* Merge from slot -> player inv. Returns the items not added.
*/
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
if (stack == null) return null;
for (ItemSlot slot : playerInv) {
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
++slot.getItemStack().stackSize;
return null;
}
}
}
return playerInv.addItems(stack);
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slotIdx, final long id) {
final ContainerLevelTerminal.InvTracker invTracker = this.trackedById.get(id);
if (invTracker != null) {
final ItemStack handStack = player.inventory.getItemStack();
if (handStack != null && !(handStack.getItem() instanceof ItemEncodedPattern)) {
// Why even bother if we're not dealing with an encoded pattern in hand
return;
}
final ItemStack slotStack = invTracker.requests.getStackInSlot(slotIdx);
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
switch (action) {
/* Set down/pickup. This is the same as SPLIT_OR_PLACE_SINGLE as our max stack sizes are 1 in slots. */
case PICKUP_OR_SET_DOWN -> {
if (handStack != null) {
for (int s = 0; s < invTracker.requests.getSizeInventory(); s++) {
/* Is there a duplicate pattern here? */
if (Platform.isSameItemPrecise(invTracker.requests.getStackInSlot(s), handStack)) {
/* We're done here - dupe found. */
return;
}
}
}
if (slotStack == null) {
/* Insert to container, if valid */
if (handStack == null) {
/* Nothing happens */
return;
}
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
} else {
/* Exchange? */
if (handStack != null && handStack.stackSize > 1) {
/* Exchange is impossible, abort */
return;
}
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
playerHand.addItems(slotStack.copy());
}
syncLevelTerminalSlot(invTracker, id, slotIdx, invTracker.requests.getStackInSlot(slotIdx));
}
/* Shift click from slotIdx -> player. Player -> slotIdx is not supported. */
case SHIFT_CLICK -> {
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player.inventory, ForgeDirection.UNKNOWN);
ItemStack leftOver = mergeToPlayerInventory(playerInv, slotStack);
if (leftOver == null) {
invTracker.requests.setInventorySlotContents(slotIdx, null);
syncLevelTerminalSlot(invTracker, id, slotIdx, null);
}
}
/* Move all blank patterns -> player */
case MOVE_REGION -> {
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
List<Integer> valid = new ArrayList<>();
for (int i = 0; i < invTracker.requests.getSizeInventory(); i++) {
ItemStack toExtract = invTracker.requests.getStackInSlot(i);
if (toExtract == null) {
continue;
}
ItemStack leftOver = mergeToPlayerInventory(playerInv, toExtract);
if (leftOver != null) {
break;
} else {
invTracker.requests.setInventorySlotContents(i, null);
}
valid.add(i);
}
if (!valid.isEmpty()) {
int[] validIndices = Ints.toArray(valid);
NBTTagList tag = new NBTTagList();
for (int i = 0; i < valid.size(); ++i) {
tag.appendTag(new NBTTagCompound());
}
dirty.addOverwriteEntry(id).setItems(validIndices, tag);
isDirty = true;
}
}
case CREATIVE_DUPLICATE -> {
if (player.capabilities.isCreativeMode) {
playerHand.addItems(handStack);
}
}
default -> {
return;
}
}
this.updateHeld(player);
}
}
private void syncLevelTerminalSlot(ContainerLevelTerminal.InvTracker inv, long id, int slot, ItemStack stack) {
int[] validIndices = { slot };
NBTTagList list = new NBTTagList();
NBTTagCompound item = new NBTTagCompound();
if (stack != null) {
stack.writeToNBT(item);
}
list.appendTag(item);
inv.updateNBT();
this.dirty.addOverwriteEntry(id).setItems(validIndices, list);
this.isDirty = true;
}
private SPacketLevelTerminalUpdate updateList() {
SPacketLevelTerminalUpdate update = null;
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
Set<IGridHost> visited = new HashSet<>();
for (Class<? extends ILevelViewable> clz : supported) {
boolean isAdopted = LevelTerminalRegistry.instance().isAdopted(clz);
Class<? extends IGridHost> machineClass = isAdopted ? LevelTerminalRegistry.instance().getAdopted(clz)
: clz;
for (IGridNode gridNode : grid.getMachines(machineClass)) {
final IGridHost gridHost = gridNode.getMachine();
final ILevelViewable machine = isAdopted
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridHost)
: (ILevelViewable) gridHost;
/* First check if we are already tracking this node */
if (tracked.containsKey(gridHost)) {
/* Check for updates */
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(gridHost);
/* Name changed? */
String name = machine.getCustomName();
if (!Objects.equals(knownTracker.name, name)) {
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addRenamedEntry(knownTracker.id, name);
knownTracker.name = name;
}
/* Status changed? */
boolean isActive = gridNode.isActive() || machine.shouldDisplay();
if (!knownTracker.online && isActive) {
/* Node offline -> online */
knownTracker.online = true;
if (update == null) update = new SPacketLevelTerminalUpdate();
knownTracker.updateNBT();
update.addOverwriteEntry(knownTracker.id).setOnline(true)
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
} else if (knownTracker.online && !isActive) {
/* Node online -> offline */
knownTracker.online = false;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteEntry(knownTracker.id).setOnline(false);
}
for (int i = 0; i < knownTracker.requests.getSizeInventory(); i++) {
ItemStack knowmItemStack = ItemStack
.loadItemStackFromNBT(knownTracker.inventoryNbt.getCompoundTagAt(i));
ItemStack machineItemStack = machine.getInventoryByName("config").getStackInSlot(i);
if (isDifferent(knowmItemStack, machineItemStack)) {
if (update == null) update = new SPacketLevelTerminalUpdate();
knownTracker.updateNBT();
update.addOverwriteEntry(knownTracker.id)
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
}
}
} else {
/* Add a new entry */
if (update == null) update = new SPacketLevelTerminalUpdate();
ContainerLevelTerminal.InvTracker entry = new ContainerLevelTerminal.InvTracker(
nextId++,
machine,
gridNode.isActive());
update.addNewEntry(entry.id, entry.name, entry.online)
.setLocation(entry.x, entry.y, entry.z, entry.dim, entry.side.ordinal())
.setItems(entry.rows, entry.rowSize, entry.inventoryNbt)
.setViewItemStack(machine.getSelfItemStack(), machine.getDisplayItemStack());
tracked.put(gridHost, entry);
trackedById.put(entry.id, entry);
}
visited.add(gridHost);
}
}
/* Now find any entries that we need to remove */
Iterator<Map.Entry<IGridHost, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
while (it.hasNext()) {
var entry = it.next();
if (visited.contains(entry.getKey())) {
continue;
}
if (update == null) update = new SPacketLevelTerminalUpdate();
trackedById.remove(entry.getValue().id);
it.remove();
update.addRemovalEntry(entry.getValue().id);
}
return update;
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
private boolean isDifferent(final ItemStack a, final ItemStack b) {
if (a == null && b == null) {
return false;
}
if (a == null || b == null) {
return true;
}
return !ItemStack.areItemStacksEqual(a, b);
}
private static class InvTracker {
private final long id;
private String name;
private final IInventory requests;
private final int rowSize;
private final int rows;
private final int x;
private final int y;
private final int z;
private final int dim;
private final ForgeDirection side;
private boolean online;
private NBTTagList inventoryNbt;
public InvTracker(long id, ILevelViewable machine, boolean online) {
DimensionalCoord location = machine.getLocation();
this.id = id;
this.name = machine.getCustomName();
this.requests = machine.getInventoryByName("config");
this.rowSize = machine.rowSize();
this.rows = machine.rows();
this.x = location.x;
this.y = location.y;
this.z = location.z;
this.dim = location.getDimension();
this.side = machine.getSide();
this.online = online;
this.inventoryNbt = new NBTTagList();
updateNBT();
}
private void updateNBT() {
this.inventoryNbt = new NBTTagList();
for (int i = 0; i < this.rows; ++i) {
for (int j = 0; j < this.rowSize; ++j) {
final int offset = this.rowSize * i;
ItemStack stack = this.requests.getStackInSlot(offset + j);
if (stack != null) {
this.inventoryNbt.appendTag(stack.writeToNBT(new NBTTagCompound()));
} else {
this.inventoryNbt.appendTag(new NBTTagCompound());
}
}
}
}
}
}
@@ -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;
}
}
@@ -0,0 +1,95 @@
/* Author: asdflj */
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.inventory.item.IItemTerminal;
import com.glodblock.github.inventory.item.IWirelessMagnetFilter;
import com.glodblock.github.inventory.item.WirelessMagnet;
import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotPatternOutputs;
import appeng.util.Platform;
public class ContainerMagnetFilter extends FCBaseContainer implements IOptionalSlotHost {
@GuiSync(101)
public WirelessMagnet.ListMode listMode;
@GuiSync(102)
public boolean nbt;
@GuiSync(103)
public boolean meta;
@GuiSync(104)
public boolean ore;
protected SlotFake[] filterSlots;
protected final IInventory filter;
public ContainerMagnetFilter(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.filter = ((IItemTerminal) monitorable).getInventoryByName("config");
this.filterSlots = new SlotFake[27];
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
this.addSlotToContainer(
this.filterSlots[x + y * 9] = new SlotPatternOutputs(
this.filter,
this,
x + y * 9,
8 + x * 18,
58 + y * 18,
0,
0,
1));
}
}
bindPlayerInventory(ip, 0, 126);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx);
if (clickSlot == null || !clickSlot.getHasStack()) return null;
ItemStack tis = clickSlot.getStack();
for (SlotFake slot : this.filterSlots) {
if (!slot.getHasStack()) {
slot.putStack(tis);
detectAndSendChanges();
break;
}
}
return super.transferStackInSlot(p, idx);
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer() && this.getPortableCell() instanceof IWirelessMagnetFilter) {
IWirelessMagnetFilter host = (IWirelessMagnetFilter) this.getHost();
this.listMode = host.getListMode();
this.meta = host.getMetaMode();
this.nbt = host.getNBTMode();
this.ore = host.getOreMode();
}
super.detectAndSendChanges();
}
@Override
public boolean isSlotEnabled(int idx) {
return true;
}
}
@@ -0,0 +1,38 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.world.World;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
public class ContainerPatternMulti extends AEBaseContainer {
public ContainerPatternMulti(final InventoryPlayer ip, final ITerminalHost te) {
super(ip, te);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
this.verifyPermissions(SecurityPermissions.CRAFT, false);
}
public IGrid getGrid() {
final IActionHost h = ((IActionHost) this.getTarget());
return h.getActionableNode().getGrid();
}
public World getWorld() {
return this.getPlayerInv().player.worldObj;
}
public BaseActionSource getActionSrc() {
return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget());
}
}
@@ -3,32 +3,42 @@ 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.inventory.item.IWirelessExtendCard;
import com.glodblock.github.inventory.item.WirelessMagnet;
import com.glodblock.github.util.Util;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.util.Platform;
public abstract class FCBaseContainer extends AEBaseContainer {
private int ticks;
private final double powerMultiplier = 0.5;
private IFluidPortableCell host;
private ITerminalHost host;
private int slot = -1;
private final InventoryPlayer ip;
@GuiSync(105)
public boolean restock = false;
@GuiSync(106)
public WirelessMagnet.Mode mode = WirelessMagnet.Mode.Off;
public FCBaseContainer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.ip = ip;
this.host = monitorable;
if (isWirelessTerminal()) {
host = (IFluidPortableCell) monitorable;
this.slot = lockSlot();
}
}
private int lockSlot() {
if (isWirelessTerminal()) {
if (this.host != null) {
final int slotIndex = this.host.getInventorySlot();
if (this.host instanceof IFluidPortableCell) {
final int slotIndex = ((IFluidPortableCell) this.host).getInventorySlot();
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
@@ -50,7 +60,14 @@ public abstract class FCBaseContainer extends AEBaseContainer {
this.slot,
this.ticks,
this.getPowerMultiplier(),
this.host);
((IFluidPortableCell) this.host));
}
if (Platform.isServer()) {
if (this.host instanceof IWirelessExtendCard wec) {
this.mode = wec.getMagnetCardMode();
this.restock = wec.isRestock();
}
}
super.detectAndSendChanges();
}
@@ -59,4 +76,14 @@ public abstract class FCBaseContainer extends AEBaseContainer {
return this.powerMultiplier;
}
public ITerminalHost getHost() {
return this.host;
}
public IFluidPortableCell getPortableCell() {
if (this.host instanceof IFluidPortableCell fpc) {
return fpc;
}
return null;
}
}
@@ -17,9 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
@@ -55,6 +53,8 @@ import appeng.util.item.AEItemStack;
public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket, IPatternConsumer {
public static final int MULTIPLE_OF_BUTTON_CLICK = 2;
public static final int MULTIPLE_OF_BUTTON_CLICK_ON_SHIFT = 8;
protected final IItemPatternTerminal patternTerminal;
protected final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
protected final IInventory crafting;
@@ -133,17 +133,19 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
FluidStack fluid = Util.getFluidFromItem(stack);
if (fluid == null || fluid.amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if (validPatternSlot(slot)
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
if (validPatternSlot(slot)) {
switch (action) {
case PICKUP_OR_SET_DOWN -> {
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
return;
}
case SPLIT_OR_PLACE_SINGLE -> {
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
@@ -153,13 +155,11 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
return;
}
default -> {}
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
super.doAction(player, action, slotId, id);
}
@@ -271,6 +271,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
pattern.setInputs(collectInventory(this.craftingSlots));
pattern.setOutputs(collectInventory(this.outputSlots));
pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
pattern.setCombine(this.combine ? 1 : 0);
patternSlotOUT.putStack(stampAuthor(pattern.writeToStack()));
}
@@ -492,8 +493,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
protected NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
Util.writeItemStackToNBT(i, c);
}
return c;
}
@@ -541,52 +541,89 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
return false;
}
static boolean canDouble(SlotFake[] slots, int mult) {
for (Slot s : slots) {
ItemStack st = s.getStack();
if (st != null) {
if (st.getItem() instanceof ItemFluidPacket) {
long result = (long) ItemFluidPacket.getFluidAmount(st) * mult;
if (result > Integer.MAX_VALUE) {
return false;
}
} else {
long result = (long) s.getStack().stackSize * mult;
if (result > Integer.MAX_VALUE) {
return false;
}
}
}
}
return true;
public void doubleStacks(int val) {
multiplyOrDivideStacks(
((val & 1) != 0 ? MULTIPLE_OF_BUTTON_CLICK_ON_SHIFT : MULTIPLE_OF_BUTTON_CLICK)
* ((val & 2) != 0 ? -1 : 1));
}
static void doubleStacksInternal(SlotFake[] slots, int mult) {
static boolean canMultiplyOrDivide(SlotFake[] slots, int mult) {
if (mult > 0) {
for (Slot s : slots) {
ItemStack st = s.getStack();
if (st == null) continue;
final long count;
if (st.getItem() instanceof ItemFluidPacket) {
count = ItemFluidPacket.getFluidAmount(st);
} else {
count = s.getStack().stackSize;
}
long result = count * mult;
if (result > Integer.MAX_VALUE) {
return false;
}
}
return true;
} else if (mult < 0) {
mult = Math.abs(mult);
for (Slot s : slots) {
ItemStack st = s.getStack();
if (st == null) continue;
final int count;
if (st.getItem() instanceof ItemFluidPacket) {
count = ItemFluidPacket.getFluidAmount(st);
} else {
count = s.getStack().stackSize;
}
if (count % mult != 0) {
return false;
}
}
return true;
}
return false;
}
static void multiplyOrDivideStacksInternal(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;
if (mult > 0) {
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;
s.putStack(st);
}
}
}
} else if (mult < 0) {
mult = Math.abs(mult);
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;
s.putStack(st);
}
}
}
}
}
public void doubleStacks(boolean isShift) {
/**
* Multiply or divide a number
*
* @param multi Positive numbers are multiplied and negative numbers are divided
*/
public void multiplyOrDivideStacks(int multi) {
if (!isCraftingMode()) {
if (isShift) {
if (canDouble(this.craftingSlots, 8) && canDouble(this.outputSlots, 8)) {
doubleStacksInternal(this.craftingSlots, 8);
doubleStacksInternal(this.outputSlots, 8);
}
} else {
if (canDouble(this.craftingSlots, 2) && canDouble(this.outputSlots, 2)) {
doubleStacksInternal(this.craftingSlots, 2);
doubleStacksInternal(this.outputSlots, 2);
}
if (canMultiplyOrDivide(this.craftingSlots, multi) && canMultiplyOrDivide(this.outputSlots, multi)) {
multiplyOrDivideStacksInternal(this.craftingSlots, multi);
multiplyOrDivideStacksInternal(this.outputSlots, multi);
}
this.detectAndSendChanges();
}
@@ -224,13 +224,10 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
public void updateSetting(final IConfigManager manager, @SuppressWarnings("rawtypes") final Enum settingName,
@SuppressWarnings("rawtypes") final Enum newValue) {
if (this.getGui() != null) {
this.getGui().updateSetting(manager, settingName, newValue);
}
}
public ITerminalHost getHost() {
return this.host;
}
}
@@ -1,11 +1,11 @@
package com.glodblock.github.client.me;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
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;
@@ -15,7 +15,6 @@ 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;
@@ -27,14 +26,64 @@ public class EssentiaRepo extends FluidRepo {
super(src, sortSrc);
}
@SuppressWarnings("deprecation")
@Override
public void updateView() {
this.view.clear();
if (this.paused) {
// Update existing view with new data
for (int i = 0; i < this.view.size(); i++) {
IAEItemStack entry = this.view.get(i);
IAEItemStack serverEntry = this.list.findPrecise(entry);
if (serverEntry == null) {
entry.setStackSize(0);
} else {
this.view.set(i, serverEntry);
}
}
// Append newly added item stacks to the end of the view
Set<IAEItemStack> viewSet = new HashSet<>(this.view);
ArrayList<IAEItemStack> entriesToAdd = new ArrayList<>();
for (IAEItemStack serverEntry : this.list) {
if (!viewSet.contains(serverEntry)) {
entriesToAdd.add(serverEntry);
}
}
addEntriesToView(entriesToAdd);
} else {
this.view.clear();
this.view.ensureCapacity(this.list.size());
addEntriesToView(this.list);
}
// Do not sort if paused
if (!this.paused) {
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);
}
}
// Update the display
this.dsp.clear();
this.view.ensureCapacity(this.list.size());
this.dsp.ensureCapacity(this.list.size());
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
}
private void addEntriesToView(Iterable<IAEItemStack> entries) {
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) {
@@ -58,7 +107,11 @@ public class EssentiaRepo extends FluidRepo {
}
}
for (IAEItemStack is : this.list) {
for (IAEItemStack is : entries) {
if (!AspectUtil.isEssentiaGas(ItemFluidDrop.getAeFluidStack(is))) {
continue;
}
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
continue;
@@ -87,40 +140,6 @@ public class EssentiaRepo extends FluidRepo {
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();
}
}
}
}
@@ -13,6 +13,8 @@ package com.glodblock.github.client.me;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
@@ -52,6 +54,7 @@ public class FluidRepo implements IDisplayRepo {
protected String searchString = "";
protected IPartitionList<IAEItemStack> myPartitionList;
protected boolean paused = false;
private String NEIWord = null;
private boolean hasPower;
@@ -97,14 +100,63 @@ public class FluidRepo implements IDisplayRepo {
this.updateView();
}
@SuppressWarnings("deprecation")
@Override
public void updateView() {
this.view.clear();
if (this.paused) {
// Update existing view with new data
for (int i = 0; i < this.view.size(); i++) {
IAEItemStack entry = this.view.get(i);
IAEItemStack serverEntry = this.list.findPrecise(entry);
if (serverEntry == null) {
entry.setStackSize(0);
} else {
this.view.set(i, serverEntry);
}
}
// Append newly added item stacks to the end of the view
Set<IAEItemStack> viewSet = new HashSet<>(this.view);
ArrayList<IAEItemStack> entriesToAdd = new ArrayList<>();
for (IAEItemStack serverEntry : this.list) {
if (!viewSet.contains(serverEntry)) {
entriesToAdd.add(serverEntry);
}
}
addEntriesToView(entriesToAdd);
} else {
this.view.clear();
this.view.ensureCapacity(this.list.size());
addEntriesToView(this.list);
}
// Do not sort if paused
if (!paused) {
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);
}
}
this.dsp.clear();
this.view.ensureCapacity(this.list.size());
this.dsp.ensureCapacity(this.list.size());
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
}
private void addEntriesToView(Iterable<IAEItemStack> entries) {
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) {
@@ -130,7 +182,7 @@ public class FluidRepo implements IDisplayRepo {
}
}
for (IAEItemStack is : this.list) {
for (IAEItemStack is : entries) {
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
continue;
@@ -167,26 +219,6 @@ public class FluidRepo implements IDisplayRepo {
}
}
}
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) {
@@ -244,4 +276,21 @@ public class FluidRepo implements IDisplayRepo {
public void setSearchString(@Nonnull final String searchString) {
this.searchString = searchString;
}
@Override
public boolean isPaused() {
return this.paused;
}
@Override
public void setPaused(boolean paused) {
if (this.paused != paused) {
this.paused = paused;
// Update view when un-paused
if (!paused) {
updateView();
}
}
}
}
@@ -8,8 +8,6 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.block.BlockFluidBuffer;
import com.glodblock.github.common.tile.TileFluidBuffer;
@@ -38,8 +36,6 @@ public class RenderBlockFluidBuffer extends BaseBlockRender<BlockFluidBuffer, Ti
if (tileEntity != null && tileEntity.getFluidStack() != null) {
Fluid storedFluid = tileEntity.getFluidStack().getFluid();
if (storedFluid != null) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Block id = Block.getBlockById(FluidRegistry.WATER.getID());
IIcon fluidIcon = storedFluid.getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
@@ -60,7 +56,6 @@ public class RenderBlockFluidBuffer extends BaseBlockRender<BlockFluidBuffer, Ti
renderer.renderFaceXNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(id, x, y, z, fluidIcon);
GL11.glDisable(GL11.GL_BLEND);
}
}
}
@@ -10,6 +10,7 @@ import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tile.TileWalrus;
public class RenderBlockWalrus extends TileEntitySpecialRenderer {
@@ -19,16 +20,28 @@ public class RenderBlockWalrus extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
if (!(tileentity instanceof TileWalrus Tile)) return;
float scale = Tile.getWalrusScale();
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5);
int orientation = tileentity.getBlockMetadata();
if (orientation == 4) {
GL11.glRotatef(90, 0, 1, 0);
} else if (orientation == 5) {
GL11.glRotatef(-90, 0, 1, 0);
} else if (orientation == 3) {
GL11.glRotatef(180, 0, 1, 0);
int orientation = Tile.getBlockMetadata();
switch (orientation) {
case 2:
GL11.glTranslated(x + 0.5, y, z + 1 - scale * .655); // centering walrus model
break;
case 3:
GL11.glTranslated(x + 0.5, y, z + scale * .655);
GL11.glRotatef(180, 0, 1, 0);
break;
case 4:
GL11.glTranslated(x + 1 - scale * .655, y, z + 0.5);
GL11.glRotatef(90, 0, 1, 0);
break;
case 5:
GL11.glTranslated(x + scale * .655, y, z + 0.5);
GL11.glRotatef(-90, 0, 1, 0);
break;
}
GL11.glScalef(scale, scale, scale);
this.modelWalrus.renderAll();
GL11.glPopMatrix();
}
@@ -18,6 +18,9 @@ public enum FCPartsTexture {
PartFluidPatternTerminal_Bright("pattern_terminal_bright"),
PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
PartFluidPatternTerminal_Colored("pattern_terminal_medium"),
PartLevelTerminal_Bright("level_terminal_bright"),
PartLevelTerminal_Dark("level_terminal_dark"),
PartLevelTerminal_Colored("level_terminal_medium"),
PartTerminalBroad("terminal_broad"),
PartFluidImportBus("fluid_import_face"),
PartFluidExportBus("fluid_export_face"),
@@ -20,6 +20,10 @@ public class Config {
public static int packetSize;
public static int packetRate;
public static boolean replaceEC2;
public static int levelMaintainerMinTicks;
public static int levelMaintainerMaxTicks;
public static int reStockTime;
public static int magnetRange;
public static void run() {
loadCategory();
@@ -66,6 +70,15 @@ public class Config {
"Fluid Craft for AE2",
true,
"Set true to handle missing item mappings from EC2. Note to work properly, you must have all relevant parts.");
levelMaintainerMinTicks = Config.get("LevelMaintainer", "minTick", 5, "Number on ticks for minimal request")
.getInt();
levelMaintainerMaxTicks = Config.get("LevelMaintainer", "maxTick", 120, "Number on ticks for maximal request")
.getInt();
reStockTime = Config.get("UltraWireless", "reStockTime", 1000, "Time between restocks").getInt();
magnetRange = Config.get("UltraWireless", "magnetRange", 16, "Magnet pick up radius").getInt();
if (Config.hasChanged()) Config.save();
}
@@ -48,7 +48,7 @@ public class BlockFluidBuffer extends FCBaseBlock {
if (fs == null && ias != null) {
player.addChatMessage(
new ChatComponentText(
Tooltip.fluidFormat(ias.getFluid().getLocalizedName(), ias.getStackSize())));
Tooltip.fluidFormat(ias.getFluidStack().getLocalizedName(), ias.getStackSize())));
return false;
} else {
tile.setFluid(fs);
@@ -2,6 +2,7 @@ package com.glodblock.github.common.block;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -61,6 +62,14 @@ public class BlockFluidInterface extends FCBaseBlock {
return false;
}
@Override
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor) {
TileFluidInterface tile = this.getTileEntity(worldIn, x, y, z);
if (tile != null) {
tile.getInterfaceDuality().updateRedstoneState();
}
}
@Override
protected boolean hasCustomRotation() {
return true;
@@ -52,20 +52,20 @@ public class BlockWalrus extends BaseBlockContainer {
int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if (l == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if (l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (l == 3) {
if (l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
if (l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 3) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
}
@Override
@@ -75,12 +75,28 @@ public class BlockWalrus extends BaseBlockContainer {
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
switch (ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z))) {
case NORTH -> setBlockBounds(0.0F, 0.0F, -1.0F, 1.0F, 1.0F, 1.0F);
case EAST -> setBlockBounds(0.0F, 0.0F, 0.0F, 2.0F, 1.0F, 1.0F);
case SOUTH -> setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2.0F);
case WEST -> setBlockBounds(-1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
default -> setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
TileEntity tileentity = blockAccess.getTileEntity(x, y, z);
if (tileentity instanceof TileWalrus Tile) {
float scale = Tile.getWalrusScale();
switch (ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z))) {
case NORTH -> setBlockBounds(
-(scale / 2 - 0.5F),
0.0F,
-scale * 2F + 1.0F,
(scale / 2 + 0.5f),
scale,
1.0F);
case EAST -> setBlockBounds(0.0F, 0.0F, -(scale / 2 - 0.5F), 2.0F * scale, scale, (scale / 2 + 0.5f));
case SOUTH -> setBlockBounds(-(scale / 2 - 0.5F), 0.F, 0.F, (scale / 2 + 0.5f), scale, 2.0F * scale);
case WEST -> setBlockBounds(
-scale * 2F + 1.0F,
0.0F,
-(scale / 2 - 0.5F),
1.0F,
scale,
(scale / 2 + 0.5f));
default -> setBlockBounds(0.0F, 0.0F, 0.0F, scale, scale, scale);
}
}
}
@@ -102,4 +118,17 @@ public class BlockWalrus extends BaseBlockContainer {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
@Override
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer entityplayer, int blockID,
float offsetX, float offsetY, float offsetZ) {
TileEntity tileentity = worldObj.getTileEntity(x, y, z);
if (!(tileentity instanceof TileWalrus Tile)) return false;
if (entityplayer.isSneaking()) {
Tile.setWalrusScale(Tile.getWalrusScale() / 2);
} else {
Tile.setWalrusScale(Tile.getWalrusScale() * 2);
}
return true;
}
}
@@ -23,8 +23,7 @@ public class BaseItemBlockContainer extends ItemBlock {
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List toolTip,
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List<String> toolTip,
final boolean advancedToolTips) {
blockType.addInformation(itemStack, player, toolTip, advancedToolTips);
}
@@ -1,6 +1,7 @@
package com.glodblock.github.common.item;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
@@ -16,8 +17,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.FluidCellInventory;
import com.glodblock.github.common.storage.FluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
@@ -33,14 +34,16 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.helpers.ICellRestriction;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.InventoryAdaptor;
import appeng.util.IterationCounter;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell {
public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell, ICellRestriction {
protected CellType component;
protected long totalBytes;
@@ -61,7 +64,6 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
this.component = null;
}
@SuppressWarnings("all")
public FCBaseItemCell(final Optional<String> subName) {
super(subName);
}
@@ -92,16 +94,16 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (inventory instanceof final FluidCellInventoryHandler handler) {
final FluidCellInventory cellInventory = (FluidCellInventory) handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -112,13 +114,13 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ cellInventory.getTotalFluidTypes()
+ cellInventory.getMaxFluidTypes()
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.Types.getLocal());
@@ -144,7 +146,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
if (handler.isPreformatted()) {
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
: GuiText.Excluded).getLocal();
: GuiText.Excluded).getLocal();
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
if (GuiScreen.isShiftKeyDown()) {
@@ -155,6 +157,20 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
if (handler.getSticky()) {
lines.add(GuiText.Sticky.getLocal());
}
}
List<Object> restricted = handler.getRestricted();
if (restricted != null && ((long) restricted.get(0) != 0 || (byte) restricted.get(1) != 0)) {
lines.add(GuiText.Restricted.getLocal());
if (GuiScreen.isShiftKeyDown()) {
NumberFormat nf = NumberFormat.getNumberInstance();
if ((long) restricted.get(0) != 0)
lines.add(GuiText.MaxFluid.getLocal() + " " + nf.format((long) restricted.get(0)) + " mB");
if ((byte) restricted.get(1) != 0)
lines.add(GuiText.MaxTypes.getLocal() + " " + restricted.get(1));
}
}
}
}
@@ -187,7 +203,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
return new CellUpgrades(is, 5);
}
@Override
@@ -210,6 +226,29 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@Override
public String getCellData(ItemStack is) {
return totalBytes + ","
+ this.getTotalTypes(null)
+ ","
+ this.getBytesPerType(null)
+ ","
+ 256 * 8
+ ","
+ Platform.openNbtData(is).getByte("cellRestrictionTypes")
+ ","
+ Platform.openNbtData(is).getLong("cellRestrictionAmount")
+ ","
+ "fluid";
}
@Override
public void setCellRestriction(ItemStack is, String newData) {
List<String> data = Arrays.asList(newData.split(",", 2));
Platform.openNbtData(is).setByte("cellRestrictionTypes", Byte.parseByte(data.get(0)));
Platform.openNbtData(is).setLong("cellRestrictionAmount", Long.parseLong(data.get(1)));
}
@SuppressWarnings("unchecked")
protected boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
@@ -221,7 +260,8 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inv != null && playerInventory.getCurrentItem() == stack) {
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
final IItemList<IAEFluidStack> list = inv.getAvailableItems(StorageChannel.FLUIDS.createList());
final IItemList<IAEFluidStack> list = inv
.getAvailableItems(StorageChannel.FLUIDS.createList(), IterationCounter.fetchNewId());
if (list.isEmpty() && ia != null) {
playerInventory.setInventorySlotContents(playerInventory.currentItem, null);
@@ -0,0 +1,93 @@
package com.glodblock.github.common.item;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellUpgrades;
public abstract class ItemBaseInfinityStorageCell extends AEBaseItem implements IStorageFluidCell {
@Override
public long getBytes(ItemStack cellItem) {
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return 0;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain(ItemStack is) {
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 0;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (GuiScreen.isCtrlKeyDown()) {
if (!cellInventory.getContents().isEmpty()) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(String.format(" %s %s", StatCollector.translateToLocal(NameConst.TT_INFINITY_FLUID_STORAGE_TIPS), fluid.getFluidStack().getLocalizedName()));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
}
}
}
@@ -1,6 +1,8 @@
package com.glodblock.github.common.item;
import static com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe.getEnergyCard;
import static com.glodblock.github.loader.recipe.WirelessTerminalRecipe.getInfinityBoosterCard;
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
import java.util.List;
@@ -8,6 +10,7 @@ import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -33,6 +36,9 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
protected GuiType type;
public static String infinityBoosterCard = "infinityBoosterCard";
public static String infinityEnergyCard = "InfinityEnergyCard";
public static String restockItems = "restock";
private static boolean effect = false;
public ItemBaseWirelessTerminal(GuiType t) {
super();
@@ -41,9 +47,11 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
if (player.isSneaking()) return removeInfinityBoosterCard(player, item);
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
// terminal
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
if (Platform.isClient()) {
setEffect(false);
return item;
}
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
@@ -98,6 +106,12 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
if (hasInfinityBoosterCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getInfinityBoosterCard().getDisplayName());
}
if (hasEnergyCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getEnergyCard().getDisplayName());
}
if (hasEnergyCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getEnergyCard().getDisplayName());
}
} else {
lines.add(NameConst.i18n(NameConst.TT_CTRL_FOR_MORE));
}
@@ -105,6 +119,9 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
@Override
public boolean canHandle(final ItemStack is) {
if (is == null) {
return false;
}
return is.getItem() instanceof ItemBaseWirelessTerminal;
}
@@ -121,4 +138,24 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
return this.type;
}
public static void setEffect(boolean e) {
effect = e;
}
public static boolean getEffect() {
return effect;
}
@Override
public boolean hasEffect(ItemStack par1ItemStack, int pass) {
if (Platform.isClient()) {
return getEffect();
}
return super.hasEffect(par1ItemStack, pass);
}
public static void toggleRestockItemsMode(ItemStack is, boolean state) {
NBTTagCompound data = Platform.openNbtData(is);
data.setBoolean(restockItems, state);
}
}
@@ -43,7 +43,7 @@ public class ItemBasicFluidStorageCell extends FCBaseItemCell
this.totalBytes = kilobytes * 1024;
this.component = whichCell;
this.housingValue = housingValue;
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes);
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + "." + kilobytes);
switch (this.component) {
case Cell1kPart -> {
@@ -1,36 +1,23 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemCreativeFluidStorageCell extends AEBaseItem
public class ItemCreativeFluidStorageCell extends ItemBaseInfinityStorageCell
implements IStorageFluidCell, IRegister<ItemCreativeFluidStorageCell> {
public ItemCreativeFluidStorageCell() {
@@ -41,52 +28,6 @@ public class ItemCreativeFluidStorageCell extends AEBaseItem
this.setMaxStackSize(1);
}
@Override
public long getBytes(ItemStack cellItem) {
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return 0;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain(ItemStack is) {
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 0;
}
@Override
public boolean isEditable(ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
@@ -103,29 +44,8 @@ public class ItemCreativeFluidStorageCell extends AEBaseItem
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final IFluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getContents().size() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(String.format(" %s", fluid.getFluidStack().getLocalizedName()));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
}
public boolean isEditable(ItemStack is) {
return true;
}
@Override
@@ -0,0 +1,44 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemEnergyCard extends FCBaseItem {
public ItemEnergyCard() {
super();
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_ENERGY_CARD);
this.setTextureName(FluidCraft.resource(NameConst.ITEM_ENERGY_CARD).toString());
}
@Override
public ItemEnergyCard register() {
GameRegistry.registerItem(this, NameConst.ITEM_ENERGY_CARD, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> toolTip, boolean flag) {
if (isShiftKeyDown()) {
toolTip.addAll(RenderUtil.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_ENERGY_CARD_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -41,9 +41,8 @@ public class ItemFluidDrop extends FCBaseItem {
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
if (CreativeTabs.tabMisc.equals(tab)) {
list.add(newStack(new FluidStack(FluidRegistry.WATER, 1)));
list.add(newStack(new FluidStack(FluidRegistry.LAVA, 1)));
@@ -67,9 +66,8 @@ public class ItemFluidDrop extends FCBaseItem {
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flag) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean flag) {
FluidStack fluid = getFluidStack(stack);
if (ItemFluidPacket.isDisplay(stack)) return;
if (fluid != null) {
@@ -70,8 +70,7 @@ public class ItemFluidPacket extends FCBaseItem {
}
@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean flags) {
FluidStack fluid = getFluidStack(stack);
boolean display = isDisplay(stack);
if (display) return;
@@ -0,0 +1,136 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemFluidVoidStorageCell extends AEBaseItem
implements IStorageFluidCell, IRegister<ItemFluidVoidStorageCell> {
public ItemFluidVoidStorageCell() {
super();
setUnlocalizedName(NameConst.ITEM_FLUID_VOID_CELL);
setTextureName(FluidCraft.resource(NameConst.ITEM_FLUID_VOID_CELL).toString());
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
}
@Override
public ItemFluidVoidStorageCell register() {
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_VOID_CELL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final IFluidCellInventoryHandler handler) {
lines.add(NameConst.i18n(NameConst.TT_ITEM_FLUID_VOID_CELL));
lines.add(GuiText.VoidCellTooltip.getLocal());
lines.add(0 + " " + GuiText.Of.getLocal() + " \u00A7k9999\u00A77 " + GuiText.BytesUsed.getLocal());
final IFluidCellInventory inv = handler.getCellInv();
if (GuiScreen.isShiftKeyDown()) {
lines.add(GuiText.Filter.getLocal() + ": ");
for (int i = 0; i < inv.getConfigInventory().getSizeInventory(); ++i) {
ItemStack s = inv.getConfigInventory().getStackInSlot(i);
if (s != null) lines.add(s.getDisplayName());
}
}
}
}
@Override
public long getBytes(ItemStack cellItem) {
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return 0;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}
@Override
public boolean storableInStorageCell() {
return true;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain(ItemStack is) {
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 0;
}
@Override
public boolean isEditable(ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 5);
}
@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
}
@@ -0,0 +1,68 @@
package com.glodblock.github.common.item;
import static com.glodblock.github.util.Util.FluidUtil.water_bucket;
import java.util.EnumSet;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import appeng.api.config.FuzzyMode;
import appeng.core.features.AEFeature;
import appeng.tile.inventory.AppEngInternalInventory;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemInfinityWaterStorageCell extends ItemBaseInfinityStorageCell
implements IStorageFluidCell, IRegister<ItemInfinityWaterStorageCell> {
@Override
public IInventory getConfigInventory(ItemStack is) {
return new InfinityConfig(water_bucket);
}
public static class InfinityConfig extends AppEngInternalInventory {
public InfinityConfig(final ItemStack is) {
super(null, 1);
this.setInventorySlotContents(0, is);
}
@Override
public void markDirty() {}
}
public ItemInfinityWaterStorageCell() {
super();
setUnlocalizedName(NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE);
setTextureName(FluidCraft.resource(NameConst.ITEM_INFINITY_FLUID_STORAGE).toString());
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
}
@Override
public ItemInfinityWaterStorageCell register() {
GameRegistry.registerItem(this, NameConst.ITEM_INFINITY_WATER_FLUID_STORAGE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public boolean isEditable(ItemStack is) {
return false;
}
@Override
public FuzzyMode getFuzzyMode(ItemStack is) {
return FuzzyMode.IGNORE_ALL;
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {}
}
@@ -44,7 +44,7 @@ public class ItemMultiFluidStorageCell extends FCBaseItemCell
this.component = whichCell;
this.housingValue = housingValue;
this.maxType = 5;
setUnlocalizedName(NameConst.ITEM_MULTI_FLUID_STORAGE + kilobytes);
setUnlocalizedName(NameConst.ITEM_MULTI_FLUID_STORAGE + "." + kilobytes);
switch (this.component) {
case Cell1kPart -> {
@@ -43,9 +43,8 @@ public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List toolTip, boolean flag) {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> toolTip, boolean flag) {
if (isShiftKeyDown()) {
toolTip.add(NameConst.i18n(NameConst.TT_FLUID_TERMINAL));
} else {
@@ -0,0 +1,70 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemPartLevelTerminal extends FCBaseItem implements IPartItem {
public ItemPartLevelTerminal() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_LEVEL_TERMINAL);
AEApi.instance().partHelper().setItemBusRenderer(this);
}
@Nullable
@Override
public PartLevelTerminal createPartFromItemStack(ItemStack is) {
return new PartLevelTerminal(is);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float xOffset, float yOffset, float zOffset) {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> toolTip, boolean flag) {
if (isShiftKeyDown()) {
toolTip.add(NameConst.i18n(NameConst.TT_LEVEL_TERMINAL));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
@Override
public ItemPartLevelTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_LEVEL_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
}
@@ -1,5 +1,6 @@
package com.glodblock.github.common.item;
import java.text.NumberFormat;
import java.util.EnumSet;
import java.util.List;
@@ -82,7 +83,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -93,7 +94,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
EnumChatFormatting.WHITE + NumberFormat.getInstance().format(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
@@ -0,0 +1,45 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemQuantumBridgeCard extends FCBaseItem {
public ItemQuantumBridgeCard() {
super();
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_QUANTUM_BRIDGE_CARD);
this.setTextureName(FluidCraft.resource(NameConst.ITEM_QUANTUM_BRIDGE_CARD).toString());
}
@Override
public ItemQuantumBridgeCard register() {
GameRegistry.registerItem(this, NameConst.ITEM_QUANTUM_BRIDGE_CARD, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> toolTip, boolean flag) {
if (isShiftKeyDown()) {
toolTip.addAll(
RenderUtil.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_QUANTUM_BRIDGE_CARD_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -0,0 +1,51 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemWirelessLevelTerminal extends ItemBaseWirelessTerminal
implements IRegister<ItemWirelessLevelTerminal> {
public ItemWirelessLevelTerminal() {
super(GuiType.WIRELESS_LEVEL_TERMINAL);
AEApi.instance().registries().wireless().registerWirelessHandler(this);
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
setUnlocalizedName(NameConst.ITEM_WIRELESS_LEVEL_TERMINAL);
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_LEVEL_TERMINAL).toString());
}
@Override
public ItemWirelessLevelTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_LEVEL_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
}
@@ -24,6 +24,8 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessMagnetCardFilterInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalExInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.IRegister;
@@ -63,6 +65,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
guis.add(GuiType.WIRELESS_FLUID_TERMINAL);
guis.add(GuiType.WIRELESS_INTERFACE_TERMINAL);
guis.add(GuiType.WIRELESS_LEVEL_TERMINAL);
if (ModAndClassUtil.ThE) {
guis.add(GuiType.WIRELESS_ESSENTIA_TERMINAL);
}
@@ -100,7 +103,9 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
final GuiType gui;
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z == -1) {
gui = GuiType.WIRELESS_MAGNET_FILTER;
} else if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
gui = getGuis().get(Util.GuiHelper.decodeType(y).getRight());
} else {
gui = readMode(stack);
@@ -115,8 +120,12 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_INTERFACE_TERMINAL) {
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_LEVEL_TERMINAL) {
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) {
return new WirelessPatternTerminalExInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_MAGNET_FILTER) {
return new WirelessMagnetCardFilterInventory(stack, x, gridNode, player);
} else {
this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
@@ -197,6 +206,15 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
}
}
public static boolean hasInfinityBoosterCard(EntityPlayer player) {
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
if (term == null) return false;
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
return Util.hasInfinityBoosterCard(term.getRight());
}
return false;
}
public static List<GuiType> getGuis() {
return guis;
}
@@ -24,27 +24,19 @@ import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.DualityFluidInterface;
import com.glodblock.github.util.Util;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.parts.misc.PartInterface;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -52,7 +44,6 @@ import io.netty.buffer.ByteBuf;
public class PartFluidInterface extends PartInterface implements IDualHost {
private final BaseActionSource ownActionSource = new MachineSource(this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this);
@@ -201,35 +192,9 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
return getInterfaceDuality().getInstalledUpgrades(u);
}
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
} catch (GridAccessException e) {
return null;
}
}
private IEnergyGrid getEnergyGrid() {
try {
return getProxy().getGrid().getCache(IEnergyGrid.class);
} catch (GridAccessException e) {
return null;
}
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
IEnergyGrid energyGrid = getEnergyGrid();
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
int ori = resource.amount;
IAEFluidStack remove;
if (doFill) {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
} else {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
}
return remove == null ? ori : (int) (ori - remove.getStackSize());
return fluidDuality.fill(from, resource, doFill);
}
@Override
@@ -244,12 +209,12 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
return fluidDuality.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
return fluidDuality.canDrain(from, fluid);
}
@Override
@@ -17,6 +17,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -62,8 +63,8 @@ import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartFluidLevelEmitter extends PartUpgradeable
implements IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable {
public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatcherHost, ICraftingWatcherHost,
IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable, ILevelViewable {
private static final int FLAG_ON = 8;
@@ -189,6 +190,11 @@ public class PartFluidLevelEmitter extends PartUpgradeable
if (this.myWatcher != null && myStack != null) {
this.myWatcher.add(myStack);
}
if (myStack == null) {
this.getProxy().getStorage().getFluidInventory().addListener(this, this.getProxy().getGrid());
}
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
} catch (final GridAccessException ignored) {}
}
@@ -220,8 +226,10 @@ public class PartFluidLevelEmitter extends PartUpgradeable
}
@Override
public void onStackChange(final IItemList o, final IAEStack fullStack, final IAEStack diffStack,
final BaseActionSource src, final StorageChannel chan) {
public void onStackChange(@SuppressWarnings("rawtypes") final IItemList o,
@SuppressWarnings("rawtypes") final IAEStack fullStack,
@SuppressWarnings("rawtypes") final IAEStack diffStack, final BaseActionSource src,
final StorageChannel chan) {
if (chan == StorageChannel.FLUIDS && fullStack.equals(this.getIAEFluidStack())) {
this.lastReportedValue = fullStack.getStackSize();
this.updateState();
@@ -523,7 +531,8 @@ public class PartFluidLevelEmitter extends PartUpgradeable
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
public void updateSetting(final IConfigManager manager, @SuppressWarnings("rawtypes") final Enum settingName,
@SuppressWarnings("rawtypes") final Enum newValue) {
this.configureWatchers();
}
@@ -38,14 +38,11 @@ import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.networking.crafting.ICraftingProviderHelper;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkCraftingPatternChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
@@ -60,6 +57,7 @@ import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.parts.automation.UpgradeInventory;
import appeng.parts.p2p.PartP2PTunnel;
import appeng.parts.p2p.PartP2PTunnelStatic;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
@@ -67,7 +65,6 @@ import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.inv.IInventoryDestination;
import appeng.util.item.AEFluidStack;
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
@@ -107,7 +104,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
};
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
private final BaseActionSource ownActionSource = new MachineSource(this);
public PartFluidP2PInterface(ItemStack is) {
super(is);
@@ -131,6 +127,11 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
dualityFluid.gridChanged();
}
@Override
public void onNeighborChanged() {
this.duality.updateRedstoneState();
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
AppEngInternalInventory patterns = (AppEngInternalInventory) duality.getPatterns();
@@ -349,35 +350,9 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
return true;
}
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
} catch (GridAccessException e) {
return null;
}
}
private IEnergyGrid getEnergyGrid() {
try {
return getProxy().getGrid().getCache(IEnergyGrid.class);
} catch (GridAccessException e) {
return null;
}
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
IEnergyGrid energyGrid = getEnergyGrid();
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
int ori = resource.amount;
IAEFluidStack remove;
if (doFill) {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
} else {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
}
return remove == null ? ori : (int) (ori - remove.getStackSize());
return dualityFluid.fill(from, resource, doFill);
}
@Override
@@ -392,12 +367,12 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
return dualityFluid.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
return dualityFluid.canDrain(from, fluid);
}
@Override
@@ -502,6 +477,19 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
duality.writeToNBT(data);
}
@Override
public NBTTagCompound getMemoryCardData() {
final NBTTagCompound output = super.getMemoryCardData();
this.duality.getConfigManager().writeToNBT(output);
return output;
}
@Override
public void pasteMemoryCardData(PartP2PTunnel<?> newTunnel, NBTTagCompound data) throws GridAccessException {
this.duality.getConfigManager().readFromNBT(data);
super.pasteMemoryCardData(newTunnel, data);
}
@Override
public void addToWorld() {
super.addToWorld();
@@ -516,6 +504,54 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
@Override
public boolean shouldDisplay() {
return IInterfaceHost.super.shouldDisplay() && !isOutput();
return IInterfaceHost.super.shouldDisplay();
}
@Override
public IInventory getPatterns() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.getPatterns();
}
return IInterfaceHost.super.getPatterns();
}
return IInterfaceHost.super.getPatterns();
}
@Override
public int rows() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.rows();
}
return IInterfaceHost.super.rows();
}
return IInterfaceHost.super.rows();
}
@Override
public int rowSize() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.rowSize();
}
return IInterfaceHost.super.rowSize();
}
return IInterfaceHost.super.rowSize();
}
@Override
public String getName() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.getName();
}
return IInterfaceHost.super.getName();
}
return IInterfaceHost.super.getName();
}
}
@@ -1,8 +1,12 @@
package com.glodblock.github.common.parts;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
@@ -11,16 +15,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraftforge.fluids.IFluidHandler;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.MEMonitorIFluidHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
@@ -29,6 +30,7 @@ import appeng.api.config.IncludeExclude;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
@@ -42,9 +44,9 @@ import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.ITickManager;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.parts.PartItemStack;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
@@ -62,16 +64,16 @@ import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.me.cache.GridStorageCache;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.StorageBusInventoryHandler;
import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.tile.networking.TileCableBus;
import appeng.util.IterationCounter;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.prioitylist.PrecisePriorityList;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import extracells.tileentity.TileEntityFluidInterface;
public class PartFluidStorageBus extends PartUpgradeable
implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEFluidStack>, IPriorityHost {
@@ -85,15 +87,39 @@ public class PartFluidStorageBus extends PartUpgradeable
private int handlerHash = 0;
private boolean wasActive = false;
private byte resetCacheLogic = 0;
private boolean accessChanged;
private boolean readOncePass;
/**
* used to read changes once when the list of extractable items was changed
*/
private boolean readOncePass = false;
public PartFluidStorageBus(ItemStack is) {
super(is);
this.getConfigManager().registerSetting(Settings.ACCESS, AccessRestriction.READ_WRITE);
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.getConfigManager().registerSetting(Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
this.getConfigManager().registerSetting(Settings.STICKY_MODE, YesNo.NO);
this.source = new MachineSource(this);
if (is.getTagCompound() != null) {
NBTTagCompound tag = is.getTagCompound();
if (tag.hasKey("priority")) {
priority = tag.getInteger("priority");
// if we don't do this, the tag will stick forever to the storage bus, as it's never cleaned up,
// even when the item is broken with a pickaxe
this.is.setTagCompound(null);
}
}
}
@Override
public ItemStack getItemStack(final PartItemStack type) {
if (type == PartItemStack.Wrench) {
final NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("priority", priority);
final ItemStack copy = this.is.copy();
copy.setTagCompound(tag);
return copy;
}
return super.getItemStack(type);
}
@Override
@@ -127,10 +153,8 @@ public class PartFluidStorageBus extends PartUpgradeable
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (settingName.name().equals("ACCESS")) {
this.accessChanged = true;
}
public void updateSetting(final IConfigManager manager, @SuppressWarnings("rawtypes") final Enum settingName,
@SuppressWarnings("rawtypes") final Enum newValue) {
this.resetCache(true);
this.getHost().markForSave();
}
@@ -146,7 +170,6 @@ public class PartFluidStorageBus extends PartUpgradeable
super.readFromNBT(data);
this.config.readFromNBT(data, "config");
this.priority = data.getInteger("priority");
this.accessChanged = false;
}
@Override
@@ -199,18 +222,7 @@ public class PartFluidStorageBus extends PartUpgradeable
final MEInventoryHandler<IAEFluidStack> in = this.getInternalHandler();
IItemList<IAEFluidStack> before = AEApi.instance().storage().createFluidList();
if (in != null) {
if (accessChanged) {
AccessRestriction currentAccess = (AccessRestriction) this.getConfigManager()
.getSetting(Settings.ACCESS);
if (!currentAccess.hasPermission(AccessRestriction.READ)) {
readOncePass = true;
}
before = in.getAvailableItems(before);
in.setBaseAccess(currentAccess);
accessChanged = false;
} else {
before = in.getAvailableItems(before);
}
before = in.getAvailableItems(before, IterationCounter.fetchNewId());
}
this.cached = false;
@@ -219,11 +231,15 @@ public class PartFluidStorageBus extends PartUpgradeable
}
final MEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
if (this.monitor != null) {
this.monitor.onTick();
}
IItemList<IAEFluidStack> after = AEApi.instance().storage().createFluidList();
if (in != out) {
if (out != null) {
after = out.getAvailableItems(after);
after = out.getAvailableItems(after, IterationCounter.fetchNewId());
}
Platform.postListChanges(before, after, this, this.source);
}
@@ -237,23 +253,46 @@ public class PartFluidStorageBus extends PartUpgradeable
@Override
public void postChange(final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change,
final BaseActionSource source) {
if (this.getProxy().isActive()) {
AccessRestriction currentAccess = (AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS);
if (readOncePass) {
readOncePass = false;
try {
this.getProxy().getStorage()
.postAlterationOfStoredItems(StorageChannel.FLUIDS, change, this.source);
} catch (final GridAccessException ignore) {}
return;
try {
if (this.getProxy().isActive()) {
if (!this.readOncePass) {
AccessRestriction currentAccess = (AccessRestriction) this.getConfigManager()
.getSetting(Settings.ACCESS);
if (!currentAccess.hasPermission(AccessRestriction.READ)) {
return;
}
}
Iterable<IAEFluidStack> filteredChanges = this.filterChanges(change, this.readOncePass);
this.readOncePass = false;
if (filteredChanges == null) return;
this.getProxy().getStorage()
.postAlterationOfStoredItems(StorageChannel.FLUIDS, filteredChanges, this.source);
}
if (!currentAccess.hasPermission(AccessRestriction.READ)) {
return;
}
try {
this.getProxy().getStorage().postAlterationOfStoredItems(StorageChannel.FLUIDS, change, source);
} catch (final GridAccessException ignore) {}
} catch (final GridAccessException ignore) {}
}
/**
* Filters the changes to only include fluids that pass the handlers extract filter. Will return null if none of the
* changes match the filter.
*/
@Nullable
private Iterable<IAEFluidStack> filterChanges(final Iterable<IAEFluidStack> change, final boolean readOncePass) {
if (readOncePass) {
return change;
}
if (this.handler != null && this.handler.isExtractFilterActive()
&& !this.handler.getExtractPartitionList().isEmpty()) {
List<IAEFluidStack> filteredChanges = new ArrayList<>();
Predicate<IAEFluidStack> extractFilterCondition = this.handler.getExtractFilterCondition();
for (final IAEFluidStack changedFluid : change) {
if (extractFilterCondition.test(changedFluid)) {
filteredChanges.add(changedFluid);
}
}
return filteredChanges.isEmpty() ? null : Collections.unmodifiableList(filteredChanges);
}
return change;
}
@Override
@@ -270,38 +309,7 @@ public class PartFluidStorageBus extends PartUpgradeable
@Override
public void onNeighborChanged() {
TileEntity tile = this.getTile();
if (tile == null || this.getProxy() == null || !this.getProxy().isActive()) return;
BlockPos neighbor = new BlockPos(tile).getOffSet(this.getSide());
final TileEntity te = neighbor.getTileEntity();
// In case the TE was destroyed, we have to do a full reset immediately.
if (te instanceof TileCableBus) {
IPart iPart = ((TileCableBus) te).getPart(this.getSide().getOpposite());
if (iPart == null || iPart instanceof PartFluidInterface) {
this.resetCache(true);
this.resetCache();
}
if (ModAndClassUtil.EC2) {
if (iPart == null || iPart instanceof extracells.part.PartFluidInterface) {
this.resetCache(true);
this.resetCache();
}
}
} else if (te == null || te instanceof TileFluidInterface) {
this.resetCache(true);
this.resetCache();
} else if (ModAndClassUtil.EC2) {
if (te instanceof TileEntityFluidInterface) {
this.resetCache(true);
this.resetCache();
}
} else if (te instanceof IFluidHandler) {
this.resetCache(true);
this.resetCache();
} else {
this.resetCache(false);
}
this.resetCache(false);
}
@Override
@@ -354,6 +362,7 @@ public class PartFluidStorageBus extends PartUpgradeable
this.handlerHash = newHandlerHash;
this.handler = null;
this.monitor = null;
this.readOncePass = true;
if (target != null) {
final IExternalStorageHandler esh = AEApi.instance().registries().externalStorage()
.getHandler(target, this.getSide().getOpposite(), StorageChannel.FLUIDS, this.source);
@@ -363,15 +372,21 @@ public class PartFluidStorageBus extends PartUpgradeable
if (inv instanceof final MEMonitorIFluidHandler h) {
h.setMode((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
h.setActionSource(new MachineSource(this));
this.monitor = (MEMonitorIFluidHandler) inv;
this.monitor = h;
}
if (inv != null) {
this.handler = new MEInventoryHandler(inv, StorageChannel.FLUIDS);
this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
this.handler = new StorageBusInventoryHandler(inv, StorageChannel.FLUIDS);
AccessRestriction currentAccess = (AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS);
this.handler.setBaseAccess(currentAccess);
this.handler.setWhitelist(
this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST
: IncludeExclude.WHITELIST);
this.handler.setSticky(this.getInstalledUpgrades(Upgrades.STICKY) > 0);
this.handler.setPriority(this.priority);
// only READ since READ_WRITE would break compat of existing storage buses
// could use a new setting that is applied via button or a card too
this.handler.setIsExtractFilterActive(currentAccess == AccessRestriction.READ);
if (inv instanceof IMEMonitor) {
((IBaseMonitor) inv).addListener(this, this.handler);
}
@@ -382,7 +397,9 @@ public class PartFluidStorageBus extends PartUpgradeable
final IAEItemStack is = this.config.getAEStackInSlot(x);
if (is != null) priorityList.add(AEFluidStack.create(ItemFluidPacket.getFluidStack(is)));
}
this.handler.setPartitionList(new PrecisePriorityList(priorityList));
PrecisePriorityList partitionList = new PrecisePriorityList(priorityList);
this.handler.setPartitionList(partitionList);
this.handler.setExtractPartitionList(partitionList);
}
}
}
@@ -432,12 +449,7 @@ public class PartFluidStorageBus extends PartUpgradeable
}
@Override
public void blinkCell(int slot) {
// NO-OP
}
@Override
public void saveChanges(final IMEInventory cellInventory) {
public void saveChanges(@SuppressWarnings("rawtypes") final IMEInventory cellInventory) {
// NO-OP
}
@@ -0,0 +1,83 @@
package com.glodblock.github.common.parts;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.parts.base.FCPart;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IClickableInTerminal;
import com.glodblock.github.util.Util;
public class PartLevelTerminal extends FCPart implements IClickableInTerminal {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartLevelTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartLevelTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartLevelTerminal_Dark;
private Util.DimensionalCoordSide tile;
public PartLevelTerminal(ItemStack is) {
super(is, true);
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
if (data.hasKey("clickedInterface")) {
NBTTagCompound tileMsg = (NBTTagCompound) data.getTag("clickedInterface");
this.tile = Util.DimensionalCoordSide.readFromNBT(tileMsg);
}
}
@Override
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
if (this.tile == null) return;
NBTTagCompound tileMsg = new NBTTagCompound();
tile.writeToNBT(tileMsg);
data.setTag("clickedInterface", tileMsg);
}
@Override
public FCPartsTexture getFrontBright() {
return FRONT_BRIGHT_ICON;
}
@Override
public FCPartsTexture getFrontColored() {
return FRONT_COLORED_ICON;
}
@Override
public FCPartsTexture getFrontDark() {
return FRONT_DARK_ICON;
}
@Override
public boolean isLightSource() {
return false;
}
@Override
public boolean isBooting() {
return super.isBooting();
}
@Override
public GuiType getGui() {
return GuiType.LEVEL_TERMINAL;
}
@Override
public void setClickedInterface(Util.DimensionalCoordSide tile) {
this.tile = tile;
this.getHost().markForSave();
}
@Override
public Util.DimensionalCoordSide getClickedInterface() {
return this.tile;
}
}
Loaded 100 of 219 files, more files were not shown because too many files have changed in this diff. Show more