Compare commits

...
196 Commits
Author SHA1 Message Date
a955757cd7 Refactor: Replace Ae2Reflect usages with direct method calls (#326)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Kogepan229 <[email protected]>
Co-authored-by: Kogepan229 <[email protected]>
2025-10-01 19:02:48 +02:00
Martin Robertz 855fe03f75 fix 2025-10-01 18:43:50 +02:00
Martin Robertz 9a7630bdfa update 2025-10-01 18:29:07 +02:00
Kogepan229andboubou19 8c2bd3ceef Adapted to AE2 GuiAmount changes (#338)
Co-authored-by: boubou19 <[email protected]>
2025-09-27 17:59:42 +02:00
lc-1337 0d58fe01b2 make nbt match item after forming press rename (#337) 2025-09-27 17:37:41 +02:00
Martin Robertz 550e3b2bab update 2025-09-15 21:00:18 +02:00
Martin Robertz d6ae1cf144 update 2025-09-09 07:59:47 +02:00
SKProCH de2f625577 Disable hotbar keys handling in terminals (#331) 2025-09-08 17:05:59 +02:00
Martin Robertz 029b479297 merge conflic fix 2025-09-07 13:24:35 +02:00
lc-1337andUltraProdigy 446920485a fix item duplication when cant inject (#334)
Co-authored-by: UltraProdigy <[email protected]>
2025-09-07 12:35:10 +02:00
Dream Master a48914c55c update 2025-09-05 16:18:39 +02:00
lc-1337 f5bdb35783 Fix Auto Filler crash (#335) 2025-09-03 18:29:53 +02:00
Martin Robertz 99822efb6d update 2025-08-31 11:07:13 +02:00
JakubandMartin Robertz 4c19501f38 Fix duping and voiding bug on network changes in p2p interface (#333)
Co-authored-by: Martin Robertz <[email protected]>
2025-08-31 09:03:14 +00:00
Martin Robertz ec26b6a372 update 2025-08-25 18:36:39 +02:00
SKProCHandKogepan229 697217c5cd Middle click craft ordering inserts a proper count (#329)
Co-authored-by: Kogepan229 <[email protected]>
2025-08-25 16:35:20 +00:00
SKProCH 80bcb3bdf3 Force save search text in the wireless terminal on any button press (#330) 2025-08-18 07:45:31 +07:00
Dream Master 8fe16e87bc update 2025-08-08 23:11:48 +07:00
NeOzay e471c1b38c shows Items|Fluids storage disks with NEI search inventories mode of Search Field (#324) 2025-08-08 16:10:04 +00:00
Niclas Klugmann 81c975ce12 German translation (#325) 2025-08-08 12:15:08 +00:00
Kogepan229 17d9ae47c0 Fix dreamcraft mod ID specification (#328) 2025-08-06 14:49:14 +07:00
Dream Master bbcea46300 update 2025-08-04 10:23:06 +07:00
01b08897d2 fix autofiller wont work after boot (#323)
Co-authored-by: NeOzay <[email protected]>
Co-authored-by: NeOzay <[email protected]>
2025-08-01 22:03:34 +07:00
lc-1337andNeOzay 64ecb14e96 reduce p2p interface lags on bind and on pattern change (#322)
Co-authored-by: NeOzay <[email protected]>
2025-07-27 11:57:21 +02:00
Eldrinn-Elantey 12bdd5ebfc Update ru_RU.lang (#318) 2025-07-27 08:59:08 +07:00
Alexdoru 10ee6f40ca fix event handler SPacketMEUpdateBuffer not being registered (#320) 2025-07-20 08:30:21 +00:00
Alexdoru 1e66772abc Cache Tessellator#instance in local var (#321) 2025-07-18 11:51:16 -07:00
NeOzay ae7af4e712 Use new localization message system from AE2 (#319) 2025-07-14 20:28:34 +00:00
Maya f9566ce891 update 2025-07-05 09:54:43 -06:00
8267150fa6 extend level maintainer feedback (#316)
Co-authored-by: Nikolay S. <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-07-05 15:53:35 +00:00
Kogepan229 22b73f9fbf Use CraftingID to check CraftingLink equivalence in Level Maintainer (#317) 2025-07-05 09:49:50 -06:00
Martin Robertz 4669a1e4ed update 2025-07-02 18:21:47 +02:00
c86370caf9 implement pins (#315)
Co-authored-by: Maya <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2025-07-01 20:40:42 +02:00
Martin Robertz 10fefc7996 update 2025-07-01 13:19:41 +02:00
8a086d714a Make P2P Tunnel - ME Dual Interface share storage slot contents between input and outputs (#302)
Co-authored-by: Ruling-0 <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: lordIcocain <[email protected]>
2025-06-29 17:51:17 +02:00
zyf051520 25abc806df Fix FluidExportBus NPE (#314) 2025-06-24 07:31:59 +00:00
Martin Robertz 04558b6913 update 2025-06-22 18:22:29 +02:00
0499adcc6f Add Super Stock Replenisher (#278)
Co-authored-by: Maya <[email protected]>
Co-authored-by: boubou19 <[email protected]>
Co-authored-by: lordIcocain <[email protected]>
2025-06-22 17:49:44 +02:00
Martin Robertz 35136c31ee update 2025-06-20 21:56:28 +02:00
lc-1337andboubou19 dffd8e07e0 always use fluid packet for partition (#310)
Co-authored-by: boubou19 <[email protected]>
2025-06-19 08:45:08 +00:00
Ethryanandgithub-actions[bot] 88c5b6be72 Hide EC stuff if EC is not loaded. (#312)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-06-17 16:24:33 +02:00
lc-1337 0095f69da2 fix player null crash magnet (#309) 2025-06-15 00:24:25 -05:00
Alexdoru bfba45e796 Account for client /server desync when teleporting items with magnet (#305) 2025-06-11 06:26:00 +02:00
Michael Doyle dee1277753 Fix Universal Terminal restock hotkey chat message saying the opposite of the current state (#308) 2025-06-10 20:36:14 -05:00
Kogepan229andboubou19 6ac5ea30f0 Rewrite Level Maintainer/Terminal Logic (#294)
Co-authored-by: boubou19 <[email protected]>
2025-06-09 20:12:08 +00:00
Martin Robertz 1ffcea9dd9 update 2025-06-09 15:35:46 +02:00
RecursivePineapple 3428c86f64 Fix div by zero (#306) 2025-06-09 12:25:06 +02:00
Alexdoru c504dbb28a Magnet improvements (#303) 2025-06-08 19:42:19 +02:00
Martin Robertz fe3168ed6e update 2025-05-31 14:55:00 +02:00
c5cea9eb19 Add magnet and restock to Universal terminal (#275)
Co-authored-by: Maya <[email protected]>
Co-authored-by: Caedis <[email protected]>
Co-authored-by: Ruling-0 <[email protected]>
2025-05-30 21:35:35 -06:00
Martin Robertz 5cc8534ba2 update 2025-05-25 21:10:05 +02:00
Kogepan229andMaya 410e33faa0 Fix fluid import/export bus GUI when WAILA is disabled (#298)
Co-authored-by: Maya <[email protected]>
2025-05-25 18:36:05 +00:00
Martin Robertz f235a68266 update 2025-05-25 15:10:33 +02:00
Kogepan229 47e41751df Fix NEI search always showing void cell (#300) 2025-05-24 21:02:42 -05:00
Martin Robertz df1384a7ee update 2025-05-24 22:27:58 +02:00
Kogepan229andboubou19 a70854c832 Restore NEI highlighting when searching for fluid in cells (#299)
Co-authored-by: boubou19 <[email protected]>
2025-05-24 18:09:11 +00:00
Martin Robertz a57cb5db52 update 2025-05-23 22:59:21 +02:00
Kogepan229 c0d438f774 Use long stack size in NEI CellView (#297) 2025-05-23 21:46:16 +02:00
lordIcocain 830ac91521 make baubles optional (#296) 2025-05-23 05:14:36 -04:00
Martin Robertz 1a959b5b8d update 2025-05-16 21:33:36 +02:00
Caedis f629b3a7da Update dependencies.gradle (#292) 2025-05-13 22:00:56 +08:00
lordIcocainandMaya c9cf92ca4a Fix cell math for distribution card (#291)
Co-authored-by: Maya <[email protected]>
2025-05-12 14:21:33 +00:00
Martin Robertz 6e613b33af update 2025-05-12 09:31:48 +02:00
Maya 3af7873882 update 2025-05-11 12:16:20 -05:00
lordIcocain 412c6d9cf2 fix player inventory position in interface terminal (#290) 2025-05-11 12:15:24 -05:00
lordIcocainandMaya ddd046fa15 item renamer (#288)
Co-authored-by: Maya <[email protected]>
2025-05-06 22:47:25 +00:00
lordIcocainandMaya f72dde88e6 order from crafting status (#287)
Co-authored-by: Maya <[email protected]>
2025-05-06 17:43:48 -05:00
lordIcocainandMaya aecddfb94a Use interface terminal gui from ae2, instead of copy code from ae2 (#286)
Co-authored-by: Maya <[email protected]>
2025-05-06 17:39:49 -05:00
Martin Robertz 3bc871e541 update 2025-05-04 13:35:55 +02:00
glowredman 452f9d9620 Artificial universe cell recipe (#289) 2025-05-04 10:03:39 +02:00
Martin Robertz bd67f35f36 update 2025-04-21 10:21:36 +02:00
lordIcocainandMaya a03db709ba copy of fix interface terminal crash (#285)
Co-authored-by: Maya <[email protected]>
2025-04-21 05:55:27 +00:00
lordIcocainandMaya 56703bf498 Fix math when cell restricted and new fluid added (#284)
Co-authored-by: Maya <[email protected]>
2025-04-21 05:51:46 +00:00
Maya d222b00de2 update 2025-04-19 10:43:04 -05:00
Kogepan229 a4a5dcd9d8 Small improvements to the Level Maintainer GUI (#283) 2025-04-19 10:41:29 -05:00
Maya c724875af6 update 2025-04-08 23:49:04 -05:00
Guillaume MercierandMaya 3952557fa2 Make the fluid handler more resilient. (#272)
Co-authored-by: Maya <[email protected]>
2025-04-09 04:48:22 +00:00
lordIcocainandMaya be8457d829 Fix isConduit check (#281)
Co-authored-by: Maya <[email protected]>
2025-04-09 04:44:48 +00:00
Kogepan229andMaya 3bcbed7c44 Backport NEI Cell View (#282)
Co-authored-by: Maya <[email protected]>
2025-04-09 04:40:48 +00:00
Maya 64a17f61f4 update 2025-04-02 17:53:11 -05:00
Kogepan229andMaya 613ca10f74 Allow math expression in Fluid Level Emitter GUI (#279)
Co-authored-by: Maya <[email protected]>
2025-04-02 22:52:55 +00:00
cdfe803f16 Partition gregtech fluids (#273)
Co-authored-by: Jurre Groenendijk <[email protected]>
Co-authored-by: Maya <[email protected]>
2025-04-02 22:47:31 +00:00
Guido de HartandMaya 3b66cab727 made ItemBaseWirelessTerminal.canHandle null-safe (#274)
Co-authored-by: Maya <[email protected]>
2025-04-02 22:41:17 +00:00
lordIcocainandMaya e90c29413d Fix pattern multi (#277)
Co-authored-by: Maya <[email protected]>
2025-04-02 22:36:05 +00:00
StaffiX 77cfc0ba64 Change Creative Cell Capacity (#276) 2025-04-02 10:53:16 -05: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
206 changed files with 8806 additions and 4507 deletions

No files matched your search

+20 -16
View File
@@ -34,26 +34,30 @@
* 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.5.25-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-349-GTNH:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.8.0-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-700-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.7.3:dev')
api('com.github.GTNewHorizons:waila:1.9.0:dev')
api("com.github.GTNewHorizons:GTNHLib:0.7.0:dev")
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.2:dev")
compileOnly("com.github.GTNewHorizons:GTNHLib:0.2.11:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.8.9:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.7.3:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.153:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.12.7:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.1.15-GTNH:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.17:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.26:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.02: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.10.10-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.6.4-GTNH:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.4.42:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.19-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.14-GTNH:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.108:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.2.3:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.4:dev")
}
+22 -11
View File
@@ -3,7 +3,7 @@
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = Fluid Craft For AE2
modName = AE2 Fluid Crafting
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
@@ -14,7 +14,7 @@ modId = ae2fc
modGroup = com.glodblock.github
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
@@ -45,24 +45,24 @@ enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
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 =
generateGradleTokenClass = com.glodblock.github.FCTags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId = GRADLETOKEN_MODID
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenModName =
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
@@ -70,7 +70,7 @@ 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 = FluidCraft.java
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.
@@ -85,6 +85,11 @@ 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
@@ -117,9 +122,15 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
# 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.
@@ -140,7 +151,7 @@ modrinthProjectId =
# 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
# Note: UniMixins 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.
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+5 -3
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/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -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
@@ -203,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * 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.
Vendored
+2
View File
@@ -13,6 +13,8 @@
@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 ##########################################################################
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.21'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
}
@@ -33,12 +33,12 @@ import cpw.mods.fml.common.network.NetworkRegistry;
modid = FluidCraft.MODID,
version = FluidCraft.VERSION,
name = FluidCraft.MODNAME,
dependencies = "required-after:appliedenergistics2@[rv3-beta-238,);required-after:CoFHCore;required-after:Baubles;after:waila;after:thaumicenergistics;after:ae2wct")
dependencies = "required-after:appliedenergistics2@[rv3-beta-238,);required-after:CoFHCore;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;
@@ -76,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();
@@ -16,11 +16,13 @@ public interface ILevelViewable extends IGridHost, ISide, ISegmentedInventory, I
TileEntity getTile();
@Deprecated
default long getSortValue() {
TileEntity te = getTile();
return ((long) te.zCoord << 24) ^ ((long) te.xCoord << 8) ^ te.yCoord;
}
@Deprecated
default boolean shouldDisplay() {
return true;
}
@@ -39,6 +41,7 @@ public interface ILevelViewable extends IGridHost, ISide, ISegmentedInventory, I
return 1;
};
@Deprecated
default ItemStack getSelfItemStack() {
return null;
}
@@ -46,8 +49,11 @@ public interface ILevelViewable extends IGridHost, ISide, ISegmentedInventory, I
/**
* "Target" Display representation
*/
@Deprecated
default ItemStack getDisplayItemStack() {
return null;
}
LevelItemInfo[] getLevelItemInfoList();
}
@@ -0,0 +1,20 @@
package com.glodblock.github.api.registries;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class LevelItemInfo {
public ItemStack stack;
public long quantity;
public long batchSize;
public LevelState state;
public LevelItemInfo(@NotNull ItemStack stack, long quantity, long batchSize, LevelState state) {
this.stack = stack;
this.quantity = quantity;
this.batchSize = batchSize;
this.state = state;
}
}
@@ -0,0 +1,11 @@
package com.glodblock.github.api.registries;
public enum LevelState {
None,
Idle,
Craft,
Export,
Error,
NotFound,
CantCraft
}
@@ -0,0 +1,87 @@
package com.glodblock.github.client.gui;
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;
// copy from WirelessCraftingTerminal WCTGuiButton
public class FCGuiBaseButton extends GuiButton {
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());
}
}
}
@@ -3,6 +3,7 @@ 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;
@@ -16,14 +17,16 @@ 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.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.helpers.InventoryAction;
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {
private GuiTabButton originalGuiBtn;
private final ITerminalHost host;
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
@@ -33,26 +36,21 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf
@Override
public void initGui() {
if (host instanceof PartFluidPatternTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL.stack());
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL_EX.stack());
else if (host instanceof PartFluidTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERM.stack());
else if (host instanceof PartLevelTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.LEVEL_TERMINAL.stack());
if (host instanceof PartFluidPatternTerminal) this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
else if (host instanceof PartFluidPatternTerminalEx) this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
else if (host instanceof PartFluidTerminal) this.myIcon = ItemAndBlockHolder.FLUID_TERM.stack();
else if (host instanceof PartLevelTerminal) this.myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack());
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
else if (host instanceof WirelessFluidTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_FLUID_TERM.stack());
this.myIcon = ItemAndBlockHolder.WIRELESS_FLUID_TERM.stack();
else if (host instanceof WirelessPatternTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack());
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
else if (host instanceof WirelessInterfaceTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack());
this.myIcon = ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack();
else if (host instanceof WirelessLevelTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack());
this.myIcon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@Override
@@ -77,4 +75,20 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf
super.actionPerformed(btn);
}
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
IAEItemStack hoveredAEStack = getHoveredAEStack();
if (hoveredAEStack != null && btn == 2) {
((AEBaseContainer) inventorySlots).setTargetStack(hoveredAEStack);
FluidCraft.proxy.netHandler.sendToServer(
new CPacketInventoryAction(
InventoryAction.AUTO_CRAFT,
Ae2ReflectClient.getInventorySlots(this).size(),
hoveredAEStack.getStackSize(),
hoveredAEStack));
return;
}
super.mouseClicked(xCoord, yCoord, btn);
}
}
@@ -17,6 +17,7 @@ import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import appeng.api.config.AdvancedBlockingMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.InsertionMode;
import appeng.api.config.LockCraftingMode;
import appeng.api.config.Settings;
@@ -42,6 +43,8 @@ public class GuiDualInterface extends GuiUpgradeable {
private GuiTabButton priority;
private GuiTabButton switcher;
private GuiImgButton BlockMode;
private GuiImgButton SmartBlockMode;
private GuiImgButton fuzzyMode;
private GuiToggleButton interfaceMode;
private GuiImgButton insertionMode;
private GuiImgButton sidelessMode;
@@ -58,7 +61,6 @@ public class GuiDualInterface extends GuiUpgradeable {
}
@Override
@SuppressWarnings("unchecked")
protected void addButtons() {
this.priority = new GuiTabButton(
this.guiLeft + 154,
@@ -82,6 +84,9 @@ public class GuiDualInterface extends GuiUpgradeable {
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(
@@ -149,6 +154,16 @@ public class GuiDualInterface extends GuiUpgradeable {
LockCraftingMode.NONE);
this.lockCraftingMode.visible = this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0;
this.buttonList.add(lockCraftingMode);
offset += 18;
this.fuzzyMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + offset,
Settings.FUZZY_MODE,
FuzzyMode.IGNORE_ALL);
this.fuzzyMode.visible = this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0;
this.buttonList.add(fuzzyMode);
}
@Override
@@ -156,7 +171,9 @@ 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);
}
@@ -182,6 +199,9 @@ public class GuiDualInterface extends GuiUpgradeable {
if (this.lockCraftingMode != null) {
this.lockCraftingMode.set(((ContainerInterface) this.cvb).getLockCraftingMode());
}
if (this.fuzzyMode != null) {
this.fuzzyMode.set(((ContainerInterface) this.cvb).getFuzzyMode());
}
this.fontRendererObj.drawString(
getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)),
8,
@@ -193,7 +213,7 @@ public class GuiDualInterface extends GuiUpgradeable {
protected String getBackground() {
if (!ModAndClassUtil.isBigInterface) return "guis/interface.png";
return switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) {
case -1 -> "guis/interfacenone.png";
case -1 -> "guis/interfacenonenoconfig.png";
case 1 -> "guis/interface2.png";
case 2 -> "guis/interface3.png";
case 3 -> "guis/interface4.png";
@@ -213,6 +233,8 @@ public class GuiDualInterface extends GuiUpgradeable {
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) {
@@ -233,13 +255,11 @@ public class GuiDualInterface extends GuiUpgradeable {
.sendToServer(new PacketConfigButton(this.advancedBlockingMode.getSetting(), backwards));
} else if (btn == this.lockCraftingMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.lockCraftingMode.getSetting(), backwards));
} else if (btn == this.fuzzyMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.fuzzyMode.getSetting(), backwards));
}
}
private boolean isPart() {
return this.host instanceof PartFluidInterface;
}
private boolean isTile() {
return this.host instanceof TileFluidInterface;
}
@@ -253,5 +273,8 @@ public class GuiDualInterface extends GuiUpgradeable {
if (this.lockCraftingMode != null) {
this.lockCraftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0);
}
if (this.fuzzyMode != null) {
this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0);
}
}
}
@@ -22,6 +22,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
private static Map<EnumPair, ButtonAppearance> appearances;
private final String buttonSetting;
private boolean halfSize = false;
private boolean threeFourths = false;
private String fillVar;
private String currentValue;
private final boolean background;
@@ -66,6 +67,14 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
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, "ENABLE_12x", "ENABLE", "enable");
this.registerApp(33, "DISABLE_12x", "DISABLE", "disable");
this.registerApp(34, "RESTOCK", "ENABLE", "restock.on");
this.registerApp(35, "RESTOCK", "DISABLE", "restock.off");
}
}
@@ -135,6 +144,14 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.halfSize = halfSize;
}
public boolean isThreeFourths() {
return threeFourths;
}
public void setThreeFourths(boolean threeFourths) {
this.threeFourths = threeFourths;
}
public String getFillVar() {
return this.fillVar;
}
@@ -155,12 +172,12 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
@Override
public int getWidth() {
return this.halfSize ? 8 : 16;
return this.halfSize ? 8 : threeFourths ? 12 : 16;
}
@Override
public int getHeight() {
return this.halfSize ? 8 : 16;
return this.halfSize ? 8 : threeFourths ? 12 : 16;
}
@Override
@@ -217,79 +234,44 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
if (this.visible) {
final int iconIndex = this.getIconIndex();
final int iconPage = this.getIconPage();
this.width = getWidth();
this.height = getHeight();
float scaleFactor = halfSize ? 3 : threeFourths ? 4.5f : 6;
if (this.halfSize) {
this.width = 8;
this.height = 8;
GL11.glPushMatrix();
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
GL11.glScalef(0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3);
if (this.enabled) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
this.drawTexturedModalRect(
0,
0,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
GL11.glPushMatrix();
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
GL11.glScalef(0.5f / 16 * scaleFactor, 0.5f / 16 * scaleFactor, 0.5f / 16 * scaleFactor);
if (this.enabled) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GL11.glPushMatrix();
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
GL11.glScalef(0.5f / 16 * 6, 0.5f / 16 * 6, 0.5f / 16 * 6);
if (this.enabled) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
this.drawTexturedModalRect(
0,
0,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
}
@@ -55,6 +55,7 @@ public class GuiFCPriority extends FCGuiAmount {
protected void addQty(final int i) {
try {
this.amountBox.setText(Long.toString(getAmount() + i));
this.amountBox.setCursorPositionEnd();
} catch (final NumberFormatException ignore) {}
try {
NetworkHandler.instance
@@ -3,6 +3,8 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
@@ -17,12 +19,18 @@ 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));
}
@@ -30,8 +38,14 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
@Override
public void initGui() {
super.initGui();
this.amountBox.setText("1");
this.amountBox.setSelectionPos(0);
this.buttonList.add(
this.craftingMode = new GuiImgButton(
this.guiLeft + 10,
this.guiTop + 53,
Settings.CRAFTING_MODE,
CraftingMode.STANDARD));
((ContainerCraftAmount) this.inventorySlots).setAmountField(this.amountBox);
}
@Override
@@ -55,8 +69,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");
@@ -55,7 +55,6 @@ public class GuiFluidCraftingWireless extends GuiItemMonitor {
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.buttonList.add(
@@ -66,7 +66,6 @@ public class GuiFluidInterface extends AEBaseGui {
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.switcher = new GuiTabButton(
@@ -3,6 +3,9 @@ package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
@@ -14,15 +17,17 @@ import appeng.api.config.Settings;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
public class GuiFluidLevelEmitter extends GuiUpgradeable {
private GuiNumberBox level;
private MEGuiTextField amountTextField;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
@@ -31,6 +36,9 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiButton setButton;
private boolean isMul = false;
public GuiFluidLevelEmitter(final InventoryPlayer inventoryPlayer, final PartFluidLevelEmitter te) {
@@ -41,13 +49,12 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
public void initGui() {
super.initGui();
this.level = new GuiNumberBox(this.fontRendererObj, 24, 43, 79, this.fontRendererObj.FONT_HEIGHT, Long.class);
this.level.setEnableBackgroundDrawing(false);
this.level.setMaxStringLength(16);
this.level.setTextColor(GuiColors.LevelEmitterValue.getColor());
this.level.setVisible(true);
this.level.setFocused(true);
((ContainerFluidLevelEmitter) this.inventorySlots).setTextField(this.level);
this.amountTextField = new MEGuiTextField(90, 12);
this.amountTextField.x = this.guiLeft + 39;
this.amountTextField.y = this.guiTop + 44;
this.amountTextField.setFocused(true);
((ContainerFluidLevelEmitter) this.inventorySlots).setTextField(this.amountTextField);
this.validateText();
}
@Override
@@ -68,10 +75,19 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 63, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 63, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 63, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 63, 38, 20, "-" + d));
this.buttonList.add(
this.setButton = new GuiButton(
0,
this.guiLeft + 134,
this.guiTop + 40,
28,
20,
GuiText.Set.getLocal()));
this.buttonList.add(this.redstoneMode);
}
@@ -89,19 +105,18 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
this.ySize - 96 + 3,
GuiColors.UpgradableInventory.getColor());
this.redstoneMode.set(this.cvb.getRedStoneMode());
this.level.drawTextBox();
if (isShiftKeyDown() && !isMul) {
for (Object btn : this.buttonList) {
for (GuiButton btn : this.buttonList) {
if (btn instanceof GuiButton) {
((GuiButton) btn).displayString += "000";
btn.displayString += "000";
}
}
isMul = true;
} else if (!isShiftKeyDown() && isMul) {
for (Object btn : this.buttonList) {
for (GuiButton btn : this.buttonList) {
if (btn instanceof GuiButton) {
((GuiButton) btn).displayString = ((GuiButton) btn).displayString
.substring(0, ((GuiButton) btn).displayString.lastIndexOf("000"));
btn.displayString = btn.displayString.substring(0, btn.displayString.lastIndexOf("000"));
}
}
isMul = false;
@@ -111,6 +126,11 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.amountTextField.drawTextBox();
// Without these two lines, the liquid slot will not draw properly.
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.bindTexture(this.getBackground());
}
@Override
@@ -124,75 +144,76 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable {
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10
|| btn == this.minus100
|| btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
if (btn == this.setButton && this.setButton.enabled) {
final long amount = this.getAmountLong();
this.amountTextField.setText(Long.toString(amount));
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(amount, 0));
} else {
final boolean isPlus = btn == this.plus1 || btn == this.plus10
|| btn == this.plus100
|| btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10
|| btn == this.minus100
|| btn == this.minus1000;
if (isPlus || isMinus) {
long result = addOrderAmount(this.getQty(btn));
this.amountTextField.setText(Long.toString(result));
}
}
}
private void addQty(final long i) {
try {
String Out = this.level.getText();
private long addOrderAmount(final int i) {
long resultL = getAmountLong();
boolean Fixed = false;
while (Out.startsWith("0") && Out.length() > 1) {
Out = Out.substring(1);
Fixed = true;
}
if (Fixed) {
this.level.setText(Out);
}
if (Out.isEmpty()) {
Out = "0";
}
long result = Long.parseLong(Out);
result += i;
if (result < 0) {
result = 0;
}
this.level.setText(Out = Long.toString(result));
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(result, 0));
} catch (final NumberFormatException e) {
this.level.setText("0");
if (resultL == 1 && i > 1) {
resultL = 0;
}
resultL += i;
if (resultL < 1) {
resultL = 1;
}
return resultL;
}
private long getAmountLong() {
String out = this.amountTextField.getText();
double resultD = Calculator.conversion(out);
if (resultD <= 0 || Double.isNaN(resultD)) {
return 0;
} else {
return (long) ArithHelper.round(resultD, 0);
}
}
private void validateText() {
String text = this.amountTextField.getText();
double resultD = Calculator.conversion(text);
this.setButton.enabled = !Double.isNaN(resultD);
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
this.amountTextField.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if ((key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit(character))
&& this.level.textboxKeyTyped(character, key)) {
try {
String Out = this.level.getText();
boolean Fixed = false;
while (Out.startsWith("0") && Out.length() > 1) {
Out = Out.substring(1);
Fixed = true;
}
if (Fixed) {
this.level.setText(Out);
}
if (Out.isEmpty()) {
Out = "0";
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketValueConfig(Long.parseLong(Out), 0));
} catch (final NumberFormatException e) {
AELog.debug(e);
}
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.actionPerformed(this.setButton);
} else {
super.keyTyped(character, key);
boolean typedTextbox = this.amountTextField.textboxKeyTyped(character, key);
if (typedTextbox) {
this.validateText();
} else {
super.keyTyped(character, key);
}
}
}
}
@@ -44,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
@@ -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;
}
}
@@ -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);
File diff suppressed because it is too large. Load diff
@@ -7,12 +7,10 @@ import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.base.FCGuiMonitor;
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.ItemRepo;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
public class GuiItemMonitor extends FCGuiMonitor<IAEItemStack> {
@@ -37,13 +35,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);
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@Override
@@ -1,12 +1,9 @@
package com.glodblock.github.client.gui;
import static com.glodblock.github.client.gui.container.ContainerLevelMaintainer.createLevelValues;
import java.awt.Rectangle;
import java.text.NumberFormat;
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;
@@ -14,20 +11,20 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.registries.LevelState;
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;
@@ -41,7 +38,6 @@ 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;
@@ -49,16 +45,14 @@ import appeng.client.gui.AEBaseGui;
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 appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cofh.core.render.CoFHFontRenderer;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler")
@@ -68,9 +62,7 @@ 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 FCGuiTextField input;
private int lastWorkingTick;
private int refreshTick;
private Widget focusedWidget;
private final CoFHFontRenderer render;
protected ItemStack icon = null;
@@ -78,10 +70,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
protected Util.DimensionalCoordSide originalBlockPos;
protected GuiTabButton originalGuiBtn;
protected static final boolean isGTNHLibLoaded = Loader.isModLoaded("gtnhlib");
protected static final Pattern numberPattern = isGTNHLibLoaded ? MathExpressionParser.EXPRESSION_PATTERN
: Pattern.compile("^[0-9]+");
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(new ContainerLevelMaintainer(ipl, tile));
this.cont = (ContainerLevelMaintainer) inventorySlots;
@@ -92,7 +80,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
TEX_BG,
Minecraft.getMinecraft().getTextureManager(),
true);
this.refreshTick = 0;
if (ipl.player.openContainer instanceof AEBaseContainer container) {
var target = container.getTarget();
if (target instanceof PartLevelTerminal terminal) {
@@ -129,39 +117,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
}
}
public void postUpdate(List<IAEItemStack> list) {
for (Slot slot : this.cont.getRequestSlots()) {
if (!slot.getHasStack()) {
component[slot.getSlotIndex()].setState(State.None);
}
}
for (IAEItemStack is : list) {
NBTTagCompound data = is.getItemStack().getTagCompound();
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);
}
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
this.lastWorkingTick = this.refreshTick;
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
component[i] = new Component(
new Widget(
@@ -178,7 +138,8 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
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);
this.buttonList,
this.cont);
}
if (this.icon != null) {
this.originalGuiBtn = new GuiTabButton(
@@ -190,11 +151,10 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.originalGuiBtn.setHideEdge(13);
this.buttonList.add(originalGuiBtn);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
this.refreshTick++;
super.drawScreen(mouseX, mouseY, btn);
for (Component com : this.component) {
com.getQty().textField.handleTooltip(mouseX, mouseY, this);
@@ -207,12 +167,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
int tick = this.refreshTick;
int interval = 20;
if (tick > lastWorkingTick + interval && this.input == null) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
lastWorkingTick = this.refreshTick;
}
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
this.component[i].draw();
}
@@ -235,11 +190,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return true;
IAEItemStack fake = stack.copy();
if (this.component[slot.getSlotIndex()].getQty().textField.getText().matches("[0-9]+")) {
fake.setStackSize(Long.parseLong(this.component[slot.getSlotIndex()].getQty().textField.getText()));
} else {
fake.setStackSize(0);
}
Widget qty = this.component[slot.getSlotIndex()].getQty();
qty.validate();
fake.setStackSize(qty.getAmount() != null ? qty.getAmount() : 0);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.setAeStack(fake);
aeRenderItem.renderItemOverlayIntoGUI(
@@ -257,60 +212,45 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
if (btn == 0) {
if (input != null) {
input.setFocused(false);
if (focusedWidget != null) {
focusedWidget.textField.setFocused(false);
}
for (Component com : this.component) {
FCGuiTextField textField = com.isMouseIn(xCoord, yCoord);
Widget textField = com.isMouseIn(xCoord, yCoord);
if (textField != null) {
textField.setFocused(true);
this.input = textField;
textField.textField.setFocused(true);
this.focusedWidget = textField;
super.mouseClicked(xCoord, yCoord, btn);
return;
}
}
this.input = null;
this.focusedWidget = null;
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped(final char character, final int key) {
if (this.input == null) {
if (this.focusedWidget == null) {
super.keyTyped(character, key);
return;
}
if (!this.checkHotbarKeys(key)) {
if (!((character == ' ') && this.input.getText().isEmpty())) {
this.input.textboxKeyTyped(character, key);
if (!((character == ' ') && this.focusedWidget.textField.getText().isEmpty())) {
this.focusedWidget.textField.textboxKeyTyped(character, key);
}
super.keyTyped(character, key);
if (!numberPattern.matcher(this.input.getText()).matches()) {
this.input.setTextColor(0xFF0000);
} else {
this.input.setTextColor(0xFFFFFF);
}
this.focusedWidget.validate();
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.input.setFocused(false);
this.input = null;
this.component[this.focusedWidget.componentIndex].submit();
this.focusedWidget.textField.setFocused(false);
this.focusedWidget = null;
}
}
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotFluidConvertingFake && this.cont.getPlayerInv().getItemStack() != null) {
this.component[slot.getSlotIndex()].getQty().textField
.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize));
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
public void updateAmount(int idx, int stackSize) {
this.component[idx].getQty().textField.setText(String.valueOf(stackSize));
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == originalGuiBtn) {
@@ -354,23 +294,33 @@ 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
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int mouseButton) {
if (slot instanceof SlotFluidConvertingFake && this.cont.getPlayerInv().getItemStack() == null) {
slot.putStack(null);
this.component[slot.getSlotIndex()].reset();
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (draggedStack != null) {
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 (getSlotArea(slot).contains(mouseX, mouseY) && draggedStack != null) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
if (slotAtPosition.equals(slot)) {
slot.putStack(draggedStack);
component[i].reset();
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex()));
return true;
}
}
@@ -382,80 +332,103 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
return false;
}
public void updateComponent(int index, long quantity, long batchSize, boolean isEnabled, LevelState state) {
if (index < 0 || index >= TileLevelMaintainer.REQ_COUNT) return;
component[index].setEnable(isEnabled);
component[index].setState(state);
component[index].getQty().textField.setText(String.valueOf(quantity));
component[index].getBatch().textField.setText(String.valueOf(batchSize));
component[index].getQty().validate();
component[index].getBatch().validate();
}
public void updateComponent(int index, LevelState state) {
if (index < 0 || index >= TileLevelMaintainer.REQ_COUNT) return;
component[index].setState(state);
}
private class Component {
public boolean isEnable = true;
public boolean isEnable = false;
private final Widget qty;
private final Widget batch;
private final GuiFCImgButton disable;
private final GuiFCImgButton enable;
private final GuiFCImgButton submit;
private final FCGuiLineField line;
private State state;
private LevelState state;
private final ContainerLevelMaintainer container;
@SuppressWarnings("unchecked")
public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton submitBtn, GuiFCImgButton enableBtn,
GuiFCImgButton disableBtn, FCGuiLineField line, List buttonList) {
GuiFCImgButton disableBtn, FCGuiLineField line, List<GuiButton> buttonList,
ContainerLevelMaintainer container) {
this.qty = qtyInput;
this.batch = batchInput;
this.enable = enableBtn;
this.disable = disableBtn;
this.submit = submitBtn;
this.line = line;
this.state = State.None;
this.state = LevelState.None;
this.container = container;
buttonList.add(this.submit);
buttonList.add(this.enable);
buttonList.add(this.disable);
}
public int getIndex() {
return this.qty.idx;
return this.qty.componentIndex;
}
public void setEnable(boolean enable) {
this.isEnable = enable;
}
private boolean send(Widget widget) {
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (isGTNHLibLoaded) {
long value = (long) MathExpressionParser.parse(widget.textField.getText());
widget.textField.setText(String.valueOf(value));
}
if (!widget.textField.getText().isEmpty()
&& numberPattern.matcher(widget.textField.getText()).matches()) {
String str = widget.textField.getText().replaceAll("^(0+)", "");
widget.textField.setText(str.isEmpty() ? "0" : str);
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText()));
widget.textField.setTextColor(0xFFFFFF);
return true;
} else {
widget.textField.setTextColor(0xFF0000);
return false;
}
private void send(Widget widget) {
if (cont.inventorySlots.get(widget.componentIndex).getHasStack() && widget.getAmount() != null) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer(widget.action, widget.componentIndex, widget.getAmount()));
}
return false;
}
public void submit() {
this.sendToServer(this.submit);
}
protected boolean sendToServer(GuiButton btn) {
boolean didSomething = false;
if (this.submit == btn) {
if (this.send(this.getQty())) this.send(this.getBatch());
final Widget qty = this.getQty();
final Widget batch = this.getBatch();
qty.validate();
batch.validate();
if (qty.getAmount() != null) {
this.send(qty);
qty.textField.setText(String.valueOf(qty.getAmount()));
}
if (batch.getAmount() != null) {
this.send(batch);
batch.textField.setText(String.valueOf(batch.getAmount()));
}
didSomething = true;
} else if (this.enable == btn) {
this.setEnable(false);
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Enable, this.getIndex()));
didSomething = true;
} else if (this.disable == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Disable, this.getIndex()));
didSomething = true;
if (this.container.getInventory().get(this.getIndex()) != null) {
this.setEnable(true);
FluidCraft.proxy.netHandler
.sendToServer(new CPacketLevelMaintainer(Action.Disable, this.getIndex()));
didSomething = true;
}
}
return didSomething;
}
public FCGuiTextField isMouseIn(final int xCoord, final int yCoord) {
if (this.qty.textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField;
if (this.batch.textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField;
public Widget isMouseIn(final int xCoord, final int yCoord) {
if (this.qty.textField.isMouseIn(xCoord, yCoord)) return this.getQty();
if (this.batch.textField.isMouseIn(xCoord, yCoord)) return this.getBatch();
return null;
}
@@ -501,6 +474,18 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
}
case NotFound -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NOT_FOUND));
}
case CantCraft -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CANT_CRAFT));
}
default -> {
this.line.setColor(FCGuiColors.StateNone.getColor());
message.add(
@@ -517,7 +502,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR_DESC));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NOT_FOUND));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NOT_FOUND_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CANT_CRAFT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CANT_CRAFT_DESC));
} else {
message.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
@@ -533,35 +522,57 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
}
public void setState(State state) {
public void setState(LevelState state) {
this.state = state;
}
public void reset() {
this.qty.textField.setText("0");
this.batch.textField.setText("0");
this.qty.validate();
this.batch.validate();
this.setEnable(false);
this.setState(LevelState.None);
}
}
private class Widget {
public final int idx;
public final int componentIndex;
public final Action action;
private final FCGuiTextField textField;
public final FCGuiTextField textField;
private final String tooltip;
private Long amount;
public Widget(FCGuiTextField textField, String tooltip, int idx, Action action) {
public Widget(FCGuiTextField textField, String tooltip, int componentIndex, Action action) {
this.textField = textField;
this.textField.setEnableBackgroundDrawing(false);
this.textField.setText("0");
this.textField.setMaxStringLength(16); // this length is enough to be useful
this.idx = idx;
this.componentIndex = componentIndex;
this.action = action;
this.tooltip = tooltip;
}
public void draw() {
String current = amount != null
? StatCollector.translateToLocal(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NumberFormat.getNumberInstance().format(amount)
+ "\n"
: "";
if (isShiftKeyDown()) {
this.setTooltip(render.wrapFormattedStringToWidth(NameConst.i18n(this.tooltip), xSize / 2));
this.setTooltip(
render.wrapFormattedStringToWidth(
StatCollector.translateToLocal(this.tooltip) + "\n"
+ current
+ "\n"
+ StatCollector.translateToLocal(this.tooltip + ".hint"),
xSize / 2));
} else {
this.setTooltip(
render.wrapFormattedStringToWidth(
NameConst.i18n(this.tooltip, "\n", false) + "\n"
+ current
+ NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE),
(int) Math.floor(xSize * 0.8)));
}
@@ -571,5 +582,21 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
public void setTooltip(String message) {
this.textField.setMessage(message);
}
public void validate() {
final double result = Calculator.conversion(this.textField.getText());
if (Double.isNaN(result) || result < 0) {
this.amount = null;
this.textField.setTextColor(0xFF0000);
} else {
this.amount = (long) ArithHelper.round(result, 0);
this.textField.setTextColor(0xFFFFFF);
}
}
@Nullable
public Long getAmount() {
return this.amount;
}
}
}
@@ -1,22 +1,15 @@
package com.glodblock.github.client.gui;
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.hasInfinityBoosterCard;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.CLEAR_ALL_BIT;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.DISCONNECT_BIT;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketAdd;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketEntry;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketOverwrite;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketRemove;
import static com.glodblock.github.network.SPacketLevelTerminalUpdate.PacketRename;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -27,14 +20,12 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
@@ -44,16 +35,17 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.registries.LevelItemInfo;
import com.glodblock.github.api.registries.LevelState;
import com.glodblock.github.client.gui.base.FCBaseMEGui;
import com.glodblock.github.client.gui.container.ContainerLevelTerminal;
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.network.CPacketLevelTerminalCommands;
import com.glodblock.github.network.CPacketLevelTerminalCommands.Action;
import com.glodblock.github.network.CPacketRenamer;
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
import com.glodblock.github.util.FCGuiColors;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -64,8 +56,6 @@ import appeng.api.config.TerminalFontSize;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.WorldCoord;
import appeng.client.gui.IGuiTooltipHandler;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
@@ -83,7 +73,6 @@ import appeng.core.localization.PlayerMessages;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack;
@@ -96,6 +85,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
public static final int VIEW_WIDTH = 174;
public static final int VIEW_LEFT = 8;
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_terminal.png");
private static final RenderItem renderItem = new RenderItem();
protected int offsetY;
private static final int offsetX = 21;
protected static String searchFieldOutputsText = "";
@@ -120,7 +110,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
private final LevelTerminalList masterList = new LevelTerminalList();
private final List<String> extraOptionsText = new ArrayList<>(2);
private static final float ITEM_STACK_Z = 100.0f;
private static final float SLOT_Z = 0.5f;
private static final float ITEM_STACK_OVERLAY_Z = 200.0f;
private static final float SLOT_HOVER_Z = 310.0f;
private static final float TOOLTIP_Z = 410.0f;
@@ -151,6 +140,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
};
searchFieldNames.setFocused(true);
extraOptionsText.add(ButtonToolTips.HighlightInterface.getLocal());
online = true;
}
public GuiLevelTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
@@ -176,7 +166,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
}
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
@@ -185,8 +174,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
final int unusedSpace = height - ySize;
guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
// modeSwitchView = new GuiFCImgButton(guiLeft + xSize - 40, guiTop + 1, "SWITCH", "OFF", false);
// modeSwitchEdit = new GuiFCImgButton(guiLeft + xSize - 40, guiTop + 1, "SWITCH", "ON", false);
offsetY = guiTop + 8;
terminalStyleBox = new GuiImgButton(
guiLeft - 18,
@@ -283,7 +270,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
}
}
@SuppressWarnings("unchecked")
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
@@ -292,7 +278,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
// buttonList.add(Objects.equals(currentMode, "OFF") ? modeSwitchView : modeSwitchEdit);
addSwitchGuiBtns();
super.drawScreen(mouseX, mouseY, btn);
@@ -324,11 +309,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
@Override
protected void actionPerformed(final GuiButton btn) {
// if (btn == modeSwitchView) {
// currentMode = "ON";
// } else if (btn == modeSwitchEdit) {
// currentMode = "OFF";
// } else
if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
final boolean backwards = Mouse.isButtonDown(1);
@@ -349,8 +329,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
if (btn == terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
reinitialize();
super.scheduleGuiResize();
}
iBtn.set(next);
@@ -359,18 +338,14 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
super.actionPerformed(btn);
}
private void reinitialize() {
buttonList.clear();
initGui();
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
/* Draws the top part. */
drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, HEADER_HEIGHT);
/* Draws the middle part. */
Tessellator.instance.startDrawingQuads();
final Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
addTexturedRectToTesselator(
offsetX,
offsetY + HEADER_HEIGHT,
@@ -381,7 +356,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
(HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT + 1.0f) / 256.0f,
xSize / 256.0f,
(HEADER_HEIGHT + 106.0f) / 256.0f);
Tessellator.instance.draw();
tess.draw();
/* Draw the bottom part */
drawTexturedModalRect(offsetX, offsetY + HEADER_HEIGHT + viewHeight, 0, 158, xSize, INV_HEIGHT);
if (online) {
@@ -392,7 +367,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
GL11.glPushMatrix();
GL11.glTranslatef(offsetX + VIEW_LEFT, offsetY + HEADER_HEIGHT, 0);
tooltipStack = null;
masterList.hoveredEntry = null;
drawViewport(mouseX - offsetX - VIEW_LEFT, mouseY - offsetY - HEADER_HEIGHT - 1);
GL11.glPopMatrix();
GL11.glPopAttrib();
@@ -510,10 +484,11 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int relMouseX, int relMouseY) {
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
mc.getTextureManager().bindTexture(TEX_BG);
Tessellator.instance.startDrawingQuads();
final Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
int relY = 0;
final int slotLeftMargin = (VIEW_WIDTH - entry.rowSize * 18);
float lastZLevel = aeRenderItem.zLevel;
float lastZLevel = renderItem.zLevel;
entry.dispY = viewY;
/* PASS 1: BG */
@@ -539,7 +514,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
(173 + 18) / 256f);
}
}
Tessellator.instance.draw();
tess.draw();
/* Draw button */
if (viewY + entry.highlightButton.height > 0 && viewY < viewHeight) {
entry.highlightButton.yPosition = viewY + 1;
@@ -575,43 +550,36 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
if (viewY + rowYBot <= titleBottom) {
continue;
}
AppEngInternalInventory inv = entry.getInventory();
for (int col = 0; col < entry.rowSize; ++col) {
final int colLeft = col * 18 + slotLeftMargin + 1;
final int colRight = colLeft + 18 + 1;
final int slotIdx = row * entry.rowSize + col;
ItemStack stack = inv.getStackInSlot(slotIdx);
LevelItemInfo info = entry.infoList[slotIdx];
boolean tooltip = relMouseX > colLeft - 1 && relMouseX < colRight - 1
&& relMouseY >= Math.max(viewY + rowYTop, LevelTerminalSection.TITLE_HEIGHT)
&& relMouseY < Math.min(viewY + rowYBot, viewHeight);
if (stack != null) {
NBTTagCompound data = stack.getTagCompound();
ItemStack itemStack = data.hasKey(TLMTags.Stack.tagName)
? ItemStack.loadItemStackFromNBT(data.getCompoundTag(TLMTags.Stack.tagName))
: stack.copy();
long quantity = data.getLong(TLMTags.Quantity.tagName);
long batch = data.getLong(TLMTags.Batch.tagName);
State state = State.values()[data.getInteger(TLMTags.State.tagName)];
NBTTagCompound linkTag = data.getCompoundTag(TLMTags.Link.tagName);
if (info != null) {
ItemStack itemStack = info.stack;
long quantity = info.quantity;
long batch = info.batchSize;
LevelState state = info.state;
GL11.glPushMatrix();
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
itemStack.stackSize = 0;
aeRenderItem.setAeStack(null);
aeRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
renderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
renderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
renderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
int color = switch (state) {
case Idle -> FCGuiColors.StateIdle.getColor();
case Craft -> FCGuiColors.StateCraft.getColor();
case Export -> FCGuiColors.StateExport.getColor();
case Error -> FCGuiColors.StateError.getColor();
case Error, NotFound, CantCraft -> FCGuiColors.StateError.getColor();
case None -> FCGuiColors.StateNone.getColor();
};
int offset = 0;
@@ -619,7 +587,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
drawRect(offset, offset, offset + size, offset + size, color);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
this.drawReadableAmount(fontRendererObj, quantity, true, 16777215);
if (batch > 0) {
if (batch >= 0) {
this.drawReadableAmount(fontRendererObj, batch, false, 16777215);
}
RenderHelper.disableStandardItemLighting();
@@ -633,7 +601,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
}
} else {
tooltipStack = stack;
tooltipStack = itemStack;
}
GL11.glPopMatrix();
} else if (entry.filteredRecipes[slotIdx]) {
@@ -648,14 +616,12 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
GL11.glTranslatef(0.0f, 0.0f, SLOT_HOVER_Z);
drawRect(colLeft, viewY + 1 + rowYTop, -2 + colRight, viewY - 1 + rowYBot, 0x77FFFFFF);
GL11.glTranslatef(0.0f, 0.0f, -SLOT_HOVER_Z);
masterList.hoveredEntry = entry;
entry.hoveredSlotIdx = slotIdx;
}
GL11.glDisable(GL11.GL_LIGHTING);
}
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
aeRenderItem.zLevel = lastZLevel;
renderItem.zLevel = lastZLevel;
return relY + 1;
}
@@ -706,9 +672,8 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
}
}
@SuppressWarnings("unchecked")
@Override
public void drawHoveringText(List textLines, int x, int y, FontRenderer font) {
public void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font) {
if (!textLines.isEmpty()) {
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
@@ -860,62 +825,50 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
&& mouseY < guiTop + HEADER_HEIGHT + viewHeight;
}
public void postUpdate(List<PacketEntry> updates, int statusFlags) {
if ((statusFlags & CLEAR_ALL_BIT) == CLEAR_ALL_BIT) {
/* Should clear all client entries. */
masterList.list.clear();
}
/* Should indicate disconnected, so the terminal turns dark. */
online = (statusFlags & DISCONNECT_BIT) != DISCONNECT_BIT;
for (PacketEntry cmd : updates) {
parsePacketCmd(cmd);
public void receivePackets(List<SPacketLevelTerminalUpdate.PacketEntry> packets) {
for (SPacketLevelTerminalUpdate.PacketEntry packet : packets) {
parsePacket(packet);
}
masterList.markDirty();
}
private void parsePacketCmd(PacketEntry cmd) {
long id = cmd.entryId;
if (cmd instanceof PacketAdd addCmd) {
private void parsePacket(SPacketLevelTerminalUpdate.PacketEntry packet) {
if (packet instanceof SPacketLevelTerminalUpdate.PacketAdd packetAdd) {
LevelTerminalEntry entry = new LevelTerminalEntry(
id,
addCmd.name,
addCmd.rows,
addCmd.rowSize,
addCmd.online).setLocation(addCmd.x, addCmd.y, addCmd.z, addCmd.dim, addCmd.side)
.setIcons(addCmd.selfItemStack, addCmd.displayItemStack).setItems(addCmd.items);
masterList.addEntry(entry);
} else if (cmd instanceof PacketRemove) {
masterList.removeEntry(id);
} else if (cmd instanceof PacketOverwrite owCmd) {
LevelTerminalEntry entry = masterList.list.get(id);
packetAdd.entryId,
packetAdd.name,
packetAdd.rows,
packetAdd.rowSize,
true).setLocation(packetAdd.x, packetAdd.y, packetAdd.z, packetAdd.dim, packetAdd.side)
.setInfoList(packetAdd.infolist);
this.masterList.addEntry(entry);
} else if (packet instanceof SPacketLevelTerminalUpdate.PacketRemove packetRemove) {
this.masterList.removeEntry(packetRemove.entryId);
} else if (packet instanceof SPacketLevelTerminalUpdate.PacketRename packetRename) {
LevelTerminalEntry entry = masterList.list.get(packetRename.entryId);
if (entry == null) return;
if (entry == null) {
return;
}
if (owCmd.onlineValid) {
entry.online = owCmd.online;
}
if (owCmd.itemsValid) {
if (owCmd.allItemUpdate) {
entry.fullItemUpdate(owCmd.items, owCmd.validIndices.length);
} else {
entry.partialItemUpdate(owCmd.items, owCmd.validIndices);
}
if (StatCollector.canTranslate(packetRename.newName)) {
entry.customName = StatCollector.translateToLocal(packetRename.newName);
} else {
entry.customName = StatCollector.translateToFallback(packetRename.newName);
}
masterList.isDirty = true;
} else if (cmd instanceof PacketRename renameCmd) {
LevelTerminalEntry entry = masterList.list.get(id);
} else if (packet instanceof SPacketLevelTerminalUpdate.PacketDisconnect) {
online = false;
}
if (entry != null) {
if (StatCollector.canTranslate(renameCmd.newName)) {
entry.customName = StatCollector.translateToLocal(renameCmd.newName);
} else {
entry.customName = StatCollector.translateToFallback(renameCmd.newName);
}
}
else if (packet instanceof SPacketLevelTerminalUpdate.PacketOverwriteSlot packetOverwirteSlot) {
LevelTerminalEntry entry = masterList.list.get(packetOverwirteSlot.entryId);
if (entry == null) return;
entry.infoList[packetOverwirteSlot.index] = packetOverwirteSlot.info;
masterList.isDirty = true;
} else if (packet instanceof SPacketLevelTerminalUpdate.PacketOverwirteAllSlot packetOverwirteAllSlot) {
LevelTerminalEntry entry = masterList.list.get(packetOverwirteAllSlot.entryId);
if (entry == null) return;
entry.infoList = packetOverwirteAllSlot.infoList;
masterList.isDirty = true;
}
}
@@ -950,22 +903,23 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
@Override
public List<String> handleItemTooltip(ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip) {
if (stack == null || !isShiftKeyDown()) return currentToolTip;
if (stack != null && isShiftKeyDown() && stack.hasTagCompound()) {
NBTTagCompound data = stack.getTagCompound();
for (LevelTerminalSection section : this.masterList.getVisibleSections()) {
for (LevelTerminalEntry entry : section.visibleEntries) {
for (LevelItemInfo info : entry.infoList) {
if (info != null && info.stack.equals(stack)) {
currentToolTip.add(
I18n.format(NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE, "\n", false) + ": "
+ NumberFormat.getInstance().format(info.quantity));
if (data.hasKey(TLMTags.Quantity.tagName)) {
long quantity = data.getLong(TLMTags.Quantity.tagName);
long batch = data.getLong(TLMTags.Batch.tagName);
currentToolTip.add(
I18n.format(NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE, "\n", false) + ": "
+ NumberFormat.getNumberInstance(Locale.US).format(quantity));
if (batch > 0) {
currentToolTip.add(
I18n.format(NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE, "\n", false) + ": "
+ NumberFormat.getNumberInstance(Locale.US).format(batch));
if (info.batchSize >= 0) {
currentToolTip.add(
I18n.format(NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE, "\n", false) + ": "
+ NumberFormat.getInstance().format(info.batchSize));
}
break;
}
}
}
}
@@ -988,7 +942,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
private final List<LevelTerminalSection> visibleSections = new ArrayList<>();
private boolean isDirty;
private int height;
private LevelTerminalEntry hoveredEntry;
LevelTerminalList() {
isDirty = true;
@@ -1121,13 +1074,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
String name;
List<LevelTerminalEntry> entries = new ArrayList<>();
Set<LevelTerminalEntry> visibleEntries = new TreeSet<>(Comparator.comparing(e -> {
if (e.displayItemStack != null) {
return e.displayItemStack.getDisplayName() + e.id;
} else {
return String.valueOf(e.id);
}
}));
Set<LevelTerminalEntry> visibleEntries = new TreeSet<>(Comparator.comparing(e -> e.customName + e.id));
int height;
private boolean isDirty = true;
boolean visible = false;
@@ -1167,18 +1114,22 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
entry.dispY = -9999;
// Find search terms
if (!output.isEmpty()) {
AppEngInternalInventory inv = entry.inv;
boolean shouldAdd = false;
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
if (itemStackMatchesSearchTerm(stack, output)) {
for (int i = 0; i < entry.infoList.length; ++i) {
if (entry.infoList[i] == null) {
entry.filteredRecipes[i] = true;
continue;
}
if (itemStackMatchesSearchTerm(entry.infoList[i].stack, output)) {
shouldAdd = true;
entry.filteredRecipes[i] = false;
} else {
entry.filteredRecipes[i] = true;
}
}
if (!shouldAdd) {
continue;
}
@@ -1226,30 +1177,23 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
private class LevelTerminalEntry {
String customName;
AppEngInternalInventory inv;
GuiFCImgButton highlightButton;
GuiFCImgButton renameButton;
GuiFCImgButton configButton;
/** Nullable - icon that represents the interface */
ItemStack selfItemStack;
/** Nullable - icon that represents the interface's "target" */
ItemStack displayItemStack;
LevelTerminalSection section;
long id;
int x, y, z, dim, side;
int rows, rowSize;
int guiHeight;
int dispY = -9999;
boolean online;
boolean[] filteredRecipes;
int numItems = 0;
private int hoveredSlotIdx = -1;
LevelItemInfo[] infoList;
LevelTerminalEntry(long id, String name, int rows, int rowSize, boolean online) {
this.id = id;
this.rows = rows;
this.rowSize = rowSize;
this.online = online;
if (StatCollector.canTranslate(name)) {
customName = StatCollector.translateToLocal(name);
} else {
@@ -1260,7 +1204,6 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
customName = StatCollector.translateToFallback(name);
}
}
inv = new AppEngInternalInventory(null, rows * rowSize, 1);
highlightButton = new GuiFCImgButton(1, 0, "HIGHLIGHT", "YES");
renameButton = new GuiFCImgButton(1, 0, "EDIT", "YES");
configButton = new GuiFCImgButton(1, 0, "CONFIG", "YES");
@@ -1278,57 +1221,12 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
return this;
}
LevelTerminalEntry setIcons(ItemStack selfItemStack, ItemStack displayItemStack) {
this.selfItemStack = selfItemStack;
this.displayItemStack = displayItemStack;
LevelTerminalEntry setInfoList(LevelItemInfo[] infoList) {
this.infoList = infoList;
return this;
}
public void fullItemUpdate(NBTTagList items, int newSize) {
inv = new AppEngInternalInventory(null, newSize);
rows = newSize / rowSize;
numItems = 0;
for (int i = 0; i < inv.getSizeInventory(); ++i) {
setItemInSlot(ItemStack.loadItemStackFromNBT(items.getCompoundTagAt(i)), i);
}
guiHeight = 18 * rows + 4;
}
LevelTerminalEntry setItems(NBTTagList items) {
assert items.tagCount() == inv.getSizeInventory();
for (int i = 0; i < items.tagCount(); ++i) {
setItemInSlot(ItemStack.loadItemStackFromNBT(items.getCompoundTagAt(i)), i);
}
return this;
}
public void partialItemUpdate(NBTTagList items, int[] validIndices) {
for (int i = 0; i < validIndices.length; ++i) {
setItemInSlot(ItemStack.loadItemStackFromNBT(items.getCompoundTagAt(i)), validIndices[i]);
}
}
private void setItemInSlot(ItemStack stack, int idx) {
final int oldHasItem = inv.getStackInSlot(idx) != null ? 1 : 0;
final int newHasItem = stack != null ? 1 : 0;
inv.setInventorySlotContents(idx, stack);
// Update item count
numItems += newHasItem - oldHasItem;
assert numItems >= 0;
}
public AppEngInternalInventory getInventory() {
return inv;
}
public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (!section.visible || mouseButton < 0 || mouseButton > 2) {
return false;
}
@@ -1343,7 +1241,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
dim,
ForgeDirection.getOrientation(side),
"");
if (isCtrlKeyDown() && isShiftKeyDown() && hasInfinityBoosterCard(player)) {
if (isCtrlKeyDown() && isShiftKeyDown() && hasInfinityBoosterCard(mc.thePlayer)) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelTerminalCommands(
Action.EDIT,
@@ -1361,23 +1259,12 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
blockPos.getDimension(),
blockPos.getSide()));
} else {
/* View in world */
WorldCoord blockPos2 = new WorldCoord((int) player.posX, (int) player.posY, (int) player.posZ);
if (mc.theWorld.provider.dimensionId != dim) {
player.addChatMessage(
new ChatComponentTranslation(PlayerMessages.InterfaceInOtherDim.getName(), dim));
} else {
BlockPosHighlighter.highlightBlock(
blockPos,
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
player.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceHighlighted.getName(),
blockPos.x,
blockPos.y,
blockPos.z));
}
player.closeScreen();
BlockPosHighlighter.highlightBlocks(
mc.thePlayer,
Collections.singletonList(blockPos),
PlayerMessages.LevelEmitterHighlighted.getUnlocalized(),
PlayerMessages.LevelEmitterInAnotherDim.getUnlocalized());
mc.thePlayer.closeScreen();
}
return true;
}
@@ -1393,41 +1280,23 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
// send packet to server, request an update
InventoryAction action = switch (mouseButton) {
case 0 -> {
// pickup / set-down.
yield null;
}
case 1 -> {
yield null;
}
case 0 -> null; // pickup / set-down.
case 1 -> null;
case 2 -> {
// creative dupe:
if (player.capabilities.isCreativeMode) {
if (mc.thePlayer.capabilities.isCreativeMode) {
yield InventoryAction.CREATIVE_DUPLICATE;
} else {
yield InventoryAction.AUTO_CRAFT;
}
}
default -> {
// drop item:
yield null;
}
default -> null;// drop item:
};
if (action != null) {
ItemStack itemStack = getInventory().getStackInSlot(slotIdx);
if (itemStack != null && itemStack.hasTagCompound()
&& itemStack.getTagCompound().hasKey(TLMTags.Stack.tagName)) {
long batch = itemStack.getTagCompound().getLong(TLMTags.Batch.tagName);
NBTTagCompound stackData = itemStack.getTagCompound().getCompoundTag(TLMTags.Stack.tagName);
ItemStack is = ItemStack.loadItemStackFromNBT(stackData);
IAEItemStack stack = AEItemStack.create(is);
if (stack == null) return true;
stack.setStackSize(batch);
((AEBaseContainer) inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, slotIdx, 0, stack));
}
if (action != null && this.infoList[slotIdx] != null) {
AEItemStack aeStack = AEItemStack.create(this.infoList[slotIdx].stack);
((AEBaseContainer) inventorySlots).setTargetStack(aeStack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, slotIdx, 0, aeStack));
}
return true;
@@ -0,0 +1,212 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerMagnetFilter;
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;
import appeng.client.gui.widgets.MEGuiTextField;
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[4];
protected MEGuiTextField oreDict;
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;
oreDict = new MEGuiTextField(149, 12, NameConst.i18n(NameConst.TT_MAGNET_CARD_OREDICT));
}
private class Component {
private final GuiFCImgButton enable;
private final GuiFCImgButton disable;
private final 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;
enable.setThreeFourths(true);
disable.setThreeFourths(true);
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 + 157,
this.guiTop + 18,
this.cont.nbt,
"WirelessTerminal.magnet.NBT");
this.components[1] = new Component(
this.guiLeft + 157,
this.guiTop + 31,
this.cont.meta,
"WirelessTerminal.magnet.Meta");
this.components[2] = new Component(
this.guiLeft + 157,
this.guiTop + 44,
this.cont.ore,
"WirelessTerminal.magnet.Ore");
this.components[3] = new Component(
this.guiLeft + 157,
this.guiTop + 112,
this.cont.oreDict,
"WirelessTerminal.magnet.OreDictState");
oreDict.x = this.guiLeft + 7;
oreDict.y = this.guiTop + 112;
oreDict.setText(this.cont.oreDictFilter);
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 + 7, this.guiTop + 48, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
}
@Override
public void drawScreen(int mouseX, int mouseY, float btn) {
handleTooltip(mouseX, mouseY, oreDict);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRendererObj.drawString(NameConst.i18n(NameConst.GUI_MAGNET_CARD), 8, 6, 0x404040);
this.fontRendererObj.drawString(NameConst.i18n(NameConst.GUI_MAGNET_CARD_NBT), 61, 22, 0x404040);
this.fontRendererObj.drawString(NameConst.i18n(NameConst.GUI_MAGNET_CARD_META), 61, 34, 0x404040);
this.fontRendererObj.drawString(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);
this.components[3].setVar(this.cont.oreDict);
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) {
bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
oreDict.drawTextBox();
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (oreDict.isFocused() && (Keyboard.KEY_NUMPADENTER == keyCode || Keyboard.KEY_RETURN == keyCode)) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("WirelessTerminal.magnet.OreDictFilter", oreDict.getText()));
}
if (!oreDict.textboxKeyTyped(typedChar, keyCode)) super.keyTyped(typedChar, keyCode);
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
oreDict.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@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,55 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Keyboard;
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.network.SPacketPatternItemRenamer;
import appeng.api.storage.ITerminalHost;
public class GuiPatternItemRenamer extends appeng.client.gui.implementations.GuiPatternItemRenamer {
private GuiType originalGui;
public GuiPatternItemRenamer(InventoryPlayer ip, ITerminalHost p) {
super(ip, p);
}
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (target instanceof PartFluidPatternTerminalEx) {
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (target instanceof PartFluidTerminal) {
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof WirelessLevelTerminalInventory) {
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}
@Override
protected void keyTyped(final char character, final int key) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
FluidCraft.proxy.netHandler
.sendToServer(new SPacketPatternItemRenamer(originalGui, getText(), getValueIndex()));
} else super.keyTyped(character, key);
}
}
@@ -0,0 +1,155 @@
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 void addAmount(int i) {
this.amountTextField.setText(Long.toString(i + getAmount()));
this.amountTextField.setCursorPositionEnd();
}
@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;
}
}
}
@@ -9,18 +9,18 @@ import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
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.tile.TileSuperStockReplenisher;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketPatternValueSet;
import appeng.api.storage.ITerminalHost;
import appeng.core.localization.GuiText;
public class GuiPatternValueAmount extends FCGuiAmount {
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final Object te) {
super(new ContainerPatternValueAmount(inventoryPlayer, te));
}
@@ -77,6 +77,9 @@ public class GuiPatternValueAmount extends FCGuiAmount {
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
} else if (target instanceof TileSuperStockReplenisher) {
this.myIcon = ItemAndBlockHolder.SUPER_STOCK_RERPLENISHER.stack();
this.originalGui = GuiType.GUI_SUPER_STOCK_REPLENISHER;
}
}
@@ -46,7 +46,6 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
this.textField.setMaxStringLength(32);
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
super.initGui();
@@ -0,0 +1,116 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerSuperStockReplenisher;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
import com.glodblock.github.network.CPacketInventoryAction;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.client.gui.AEBaseGui;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.core.localization.GuiText;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
public class GuiSuperStockReplenisher extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/superStockReplenisher.png");
private Map<Integer, IAEStack<?>> list = new HashMap<>();
public GuiSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(new ContainerSuperStockReplenisher(ipl, tile));
this.ySize = 251;
this.xSize = 216;
}
@Override
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int mouseButton) {
if (mouseButton == 3) {
if (slot instanceof SlotFake) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.SET_PATTERN_VALUE;
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
if (slot.equals(this.inventorySlots.inventorySlots.get(i))) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, i, 0, stack));
}
}
return;
}
}
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
public void func_146977_a(Slot s) {
if (s instanceof SlotFake) {
this.drawFillStatus(s);
}
super.func_146977_a(s);
}
private void drawFillStatus(Slot slotIn) {
int offsetX = slotIn.xDisplayPosition - 8;
int offsetY = slotIn.yDisplayPosition - 11;
ItemStack itemstack = slotIn.getStack();
int slotInt = slotIn.slotNumber;
if (itemstack != null) {
String s = "0%";
if (slotInt > 0 && slotInt < 10) {
IAEStack<?> aeStack = list.get(slotInt - 1);
if (aeStack != null)
s = (int) (((float) aeStack.getStackSize() / ItemFluidPacket.getFluidAmount(itemstack)) * 100)
+ "%";
} else if (slotInt > 9 && slotInt < 73) {
IAEStack<?> aeStack = list.get(slotInt + 90);
if (aeStack != null && itemstack.stackSize > 0) {
long i = aeStack.getStackSize();
s = (int) (((float) i / itemstack.stackSize) * 100) + "%";
}
}
float scale = 0.5f;
float shiftX = 2;
float shiftY = 1;
final float inverseScaleFactor = 1.0f / scale;
final int X = (int) (((float) offsetX - shiftX + 10.0f) * inverseScaleFactor);
final int Y = (int) (((float) offsetY - shiftY + 16.0f - 7.0f * scale) * inverseScaleFactor);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
GL11.glScaled(scale, scale, scale);
this.fontRendererObj.drawStringWithShadow(s, X, Y, 16777215);
GL11.glScaled(inverseScaleFactor, inverseScaleFactor, inverseScaleFactor);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture(TEX_BG);
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
}
public void update(Map<Integer, IAEStack<?>> map) {
this.list = map;
}
}
@@ -7,20 +7,23 @@ 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.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 {
@@ -32,8 +35,15 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
protected GuiFCImgButton InterfaceTerminal;
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);
@@ -42,10 +52,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();
@@ -61,12 +80,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(
@@ -103,16 +161,14 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.FluidTerminal);
}
if (!(this instanceof GuiInterfaceWireless)) {
this.buttonList.add(
this.InterfaceTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"INTERFACE_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.InterfaceTerminal);
}
this.buttonList.add(
this.InterfaceTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"INTERFACE_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.InterfaceTerminal);
if (!(this instanceof GuiLevelWireless)) {
this.buttonList.add(
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
@@ -131,12 +187,48 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
}
}
@SuppressWarnings("unchecked")
protected void addSwitchGuiBtns() {
if (!drawSwitchGuiBtn) return;
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) {
@@ -154,8 +246,20 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
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;
}
}
@@ -1,7 +1,6 @@
package com.glodblock.github.client.gui.base;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
@@ -12,6 +11,7 @@ import com.glodblock.github.inventory.gui.GuiType;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.container.AEBaseContainer;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
@@ -20,7 +20,7 @@ import appeng.util.calculators.Calculator;
public abstract class FCGuiAmount extends AEBaseGui {
protected GuiTextField amountBox;
protected MEGuiTextField amountBox;
protected GuiTabButton originalGuiBtn;
protected GuiButton submit;
protected GuiButton plus1;
@@ -39,7 +39,6 @@ public abstract class FCGuiAmount extends AEBaseGui {
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
@@ -73,16 +72,10 @@ public abstract class FCGuiAmount extends AEBaseGui {
this.originalGuiBtn.setHideEdge(13);
}
this.amountBox = new GuiTextField(
this.fontRendererObj,
this.guiLeft + 62,
this.guiTop + 57,
59,
this.fontRendererObj.FONT_HEIGHT);
this.amountBox.setEnableBackgroundDrawing(false);
this.amountBox = new MEGuiTextField(61, 12);
this.amountBox.x = this.guiLeft + 60;
this.amountBox.y = this.guiTop + 55;
this.amountBox.setMaxStringLength(16);
this.amountBox.setTextColor(0xFFFFFF);
this.amountBox.setVisible(true);
this.amountBox.setFocused(true);
}
@@ -135,6 +128,7 @@ public abstract class FCGuiAmount extends AEBaseGui {
}
String out = Long.toString(resultI);
this.amountBox.setText(out);
this.amountBox.setCursorPositionEnd();
} catch (final NumberFormatException ignore) {}
}
@@ -5,6 +5,7 @@ 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;
@@ -116,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"));
@@ -16,7 +16,7 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.FCGuiTextField;
import com.glodblock.github.client.gui.GuiFluidMonitor;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.inventory.InventoryHandler;
@@ -26,12 +26,15 @@ import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.config.CraftingStatus;
import appeng.api.config.PinsState;
import appeng.api.config.SearchBoxFocusPriority;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.config.YesNo;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.ITerminalPins;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IDisplayRepo;
@@ -42,7 +45,10 @@ import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.IDropToFillTextField;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
import appeng.client.me.PinSlotME;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.container.AEBaseContainer;
@@ -60,7 +66,9 @@ import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketPinsUpdate;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPinsHandler;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
@@ -70,8 +78,9 @@ 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 {
implements ISortSource, IConfigManagerHost, IDropToFillTextField, IPinsHandler {
public static int craftingGridOffsetX;
public static int craftingGridOffsetY;
@@ -85,7 +94,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
public GuiTabButton craftingStatusBtn;
protected IDisplayRepo repo;
protected GuiImgButton craftingStatusImgBtn;
protected FCGuiTextField searchField;
protected MEGuiTextField searchField;
protected int perRow = 9;
protected int reservedSpace = 0;
protected boolean customSortOrder = true;
@@ -101,8 +110,14 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
protected GuiImgButton terminalStyleBox;
protected GuiImgButton searchStringSave;
protected GuiImgButton typeFilter;
protected GuiImgButton pinsStateButton;
protected boolean hasShiftKeyDown = false;
private boolean reInitializationRequested = false;
private PinsState pinsState;
public final boolean hasPinHost;
private boolean canBeAutoFocused;
private boolean isAutoFocused;
protected int currentMouseY;
protected int currentMouseX;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
@@ -115,6 +130,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (FCContainerMonitor<T>) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
pinsState = (PinsState) configSrc.getSetting(Settings.PINS_STATE);
hasPinHost = te instanceof ITerminalPins && !(this instanceof GuiFluidMonitor);
}
public int getOffsetY() {
@@ -131,12 +148,13 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(
0,
(this.repo.size() + this.perRow - 1) / this.perRow - this.rows,
(this.repo.size() + pinsState.ordinal() * 9 + this.perRow - 1) / this.perRow - this.rows,
Math.max(1, this.rows / 6));
}
@Override
protected void actionPerformed(final GuiButton btn) {
memoryText = this.searchField.getText();
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
}
@@ -151,6 +169,15 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (ModAndClassUtil.isSaveText && btn == this.searchStringSave) {
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
} else if (btn == this.pinsStateButton) {
try {
if (next.ordinal() >= rows) return; // ignore to avoid hiding terminal inventory
final PacketPinsUpdate p = new PacketPinsUpdate((PinsState) next);
NetworkHandler.instance.sendToServer(p);
} catch (final IOException e) {
AELog.debug(e);
}
} else {
try {
NetworkHandler.instance
@@ -161,19 +188,27 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
iBtn.set(next);
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
this.reInitalize();
super.scheduleGuiResize();
}
}
}
super.actionPerformed(btn);
}
protected void reInitalize() {
reInitializationRequested = true;
private void adjustPinsSize() {
final int pinMaxSize = rows - 1;
if (pinsState.ordinal() <= pinMaxSize) return;
try {
PinsState newState = PinsState.fromOrdinal(pinMaxSize);
final PacketPinsUpdate p = new PacketPinsUpdate(newState);
NetworkHandler.instance.sendToServer(p);
} catch (final IOException e) {
AELog.debug(e);
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
Keyboard.enableRepeatEvents(true);
@@ -203,10 +238,26 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
this.getMeSlots().clear();
for (int y = 0; y < this.rows; y++) {
// make sure we have space at least for one row of normal slots, because pins not adjusted by scroll bar
adjustPinsSize();
int pinsRows = pinsState.ordinal();
for (int y = 0; y < pinsRows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots()
.add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
.add(new PinSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, y * 18 + 18));
}
}
for (int y = 0; y < this.rows - pinsRows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots().add(
new InternalSlotME(
this.repo,
x + y * this.perRow,
this.offsetX + x * 18,
18 + y * 18 + pinsRows * 18));
}
}
@@ -217,6 +268,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
super.initGui();
this.setScrollBar();
// full size : 204
// extra slots : 72
// slot 18
@@ -227,6 +279,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
this.offsetY = this.guiTop + 8;
buttonList.clear();
if (this.customSortOrder) {
this.buttonList.add(
this.SortByBox = new GuiImgButton(
@@ -289,18 +342,19 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
this.offsetY += 20;
// Right now 80 > offsetX, but that can be changed later.
// noinspection DataFlowIssue
this.searchField = new FCGuiTextField(
this.fontRendererObj,
this.guiLeft + Math.max(80, this.offsetX),
this.guiTop + 4,
90,
12);
this.searchField.setEnableBackgroundDrawing(false);
this.searchField = new MEGuiTextField(90, 12) {
@Override
public void onTextChange(final String oldText) {
final String text = getText();
repo.setSearchString(text);
repo.updateView();
setScrollBar();
}
};
this.searchField.x = this.guiLeft + Math.max(80, this.offsetX);
this.searchField.y = this.guiTop + 4;
this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF);
this.searchField.setVisible(true);
if (ModAndClassUtil.isSearchStringTooltip)
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
@@ -326,8 +380,19 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
}
if (hasPinHost) {
this.buttonList.add(
this.pinsStateButton = new GuiImgButton(
this.guiLeft + 177,
this.guiTop + 18 + (rows * 18) + 26,
Settings.PINS_STATE,
configSrc.getSetting(Settings.PINS_STATE)));
}
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
this.canBeAutoFocused = SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting;
this.searchField.setFocused(this.canBeAutoFocused);
this.isAutoFocused = this.canBeAutoFocused;
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString(memoryText, false);
@@ -363,6 +428,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
public void setSearchString(String memoryText, boolean updateView) {
this.searchField.setText(memoryText);
this.searchField.setCursorPositionEnd();
this.repo.setSearchString(memoryText);
if (updateView) {
this.repo.updateView();
@@ -372,13 +438,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) {
this.searchField.mouseClicked(xCoord, yCoord, btn);
}
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
setSearchString("", true);
}
this.searchField.mouseClicked(xCoord, yCoord, btn);
isAutoFocused = false;
super.mouseClicked(xCoord, yCoord, btn);
}
@@ -419,6 +480,9 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.SET_PATTERN_VALUE;
if (isCtrlKeyDown()) {
action = InventoryAction.RENAME_PATTERN_ITEM;
}
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
@@ -441,7 +505,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
action = InventoryAction.PICKUP_SINGLE;
}
}
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
if (this.drag_click.size() > 1) {
return;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
@@ -492,7 +556,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
if (slot instanceof SlotDisconnected) {
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
if (this.drag_click.size() > 1) {
return;
}
InventoryAction action = null;
@@ -527,13 +591,22 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
return;
}
if (slot instanceof SlotME) {
if (slot instanceof SlotME sme) {
InventoryAction action = null;
IAEItemStack stack = null;
switch (mouseButton) {
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ((SlotME) slot).getAEStack();
if (sme.isPin() && player.inventory.getItemStack() != null) {
final PacketInventoryAction p = new PacketInventoryAction(
InventoryAction.SET_PIN,
sme.getPinIndex(),
0);
NetworkHandler.instance.sendToServer(p);
return;
}
stack = sme.getAEStack();
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN
&& stack.getStackSize() == 0
&& player.inventory.getItemStack() == null) {
@@ -541,6 +614,15 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
break;
case 1:
if (sme.isPin() && ctrlDown == 1) { // clear pin
final PacketInventoryAction p = new PacketInventoryAction(
InventoryAction.SET_PIN,
sme.getPinIndex(),
-1);
NetworkHandler.instance.sendToServer(p);
return;
}
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ((SlotME) slot).getAEStack();
break;
@@ -590,6 +672,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);
@@ -628,6 +722,9 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
if (this.searchField != null) {
this.searchField.drawTextBox();
}
this.currentMouseX = mouseX;
this.currentMouseY = mouseY;
}
protected String getBackground() {
@@ -650,28 +747,34 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
} else {
super.keyTyped(character, key);
}
boolean skipHotbarCheck = searchField.isFocused()
&& (AEConfig.instance.searchBoxFocusPriority == SearchBoxFocusPriority.ALWAYS
|| (AEConfig.instance.searchBoxFocusPriority == SearchBoxFocusPriority.NO_AUTOSEARCH
&& !isAutoFocused));
if (!skipHotbarCheck && checkHotbarKeys(key)) {
return;
}
final boolean mouseInGui = this
.isPointInRegion(0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY);
if (this.canBeAutoFocused && !searchField.isFocused() && mouseInGui) {
searchField.setFocused(true);
isAutoFocused = true;
}
if (!searchField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
}
@Override
public void updateScreen() {
if (reInitializationRequested) {
reInitializationRequested = false;
this.buttonList.clear();
this.initGui();
}
this.repo.setPowered(this.monitorableContainer.isPowered());
super.updateScreen();
}
@@ -692,12 +795,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));
}
@@ -713,6 +817,13 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
this.typeFilter.set(this.configSrc.getSetting(Settings.TYPE_FILTER));
}
if (this.pinsStateButton != null) {
pinsState = (PinsState) this.configSrc.getSetting(Settings.PINS_STATE);
this.pinsStateButton.set(pinsState);
initGui();
}
this.repo.updateView();
}
@@ -740,13 +851,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
this.standardSize = standardSize;
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
public boolean isOverSearchField(int x, int y) {
return searchField.isMouseIn(x, y);
}
@@ -780,12 +884,31 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
}
@Override
public void handleKeyboardInput() {
super.handleKeyboardInput();
hasShiftKeyDown |= isShiftKeyDown();
if (hasShiftKeyDown && !Keyboard.getEventKeyState()) { // keyup
this.repo.updateView();
hasShiftKeyDown = false;
public void setAEPins(IAEItemStack[] pins) {
if (repo instanceof ItemRepo) repo.setAEPins(pins);
}
@Override
public void setPinsState(PinsState state) {
configSrc.putSetting(Settings.PINS_STATE, state);
}
@SuppressWarnings("SameParameterValue")
protected boolean isPointInRegion(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY) {
pointX -= this.guiLeft;
pointY -= this.guiTop;
return pointX >= rectX - 1 && pointX < rectX + rectWidth + 1
&& pointY >= rectY - 1
&& pointY < rectY + rectHeight + 1;
}
// Moving items via hotbar keys in terminals isn't working anyway.
// Let's disable hotbar keys processing for terminal slots to allow proper input of numbers in the search field
@Override
protected boolean checkHotbarKeys(int keyCode) {
if (theSlot instanceof SlotME) {
return false;
}
return super.checkHotbarKeys(keyCode);
}
}
@@ -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);
@@ -13,11 +13,9 @@ 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;
@@ -71,8 +69,8 @@ public class ContainerFluidCraftConfirm extends ContainerCraftConfirm {
@Override
public void optimizePatterns() {
// only V2 supported
IGrid grid = Ae2Reflect.getGrid(this);
ICraftingJob result = Ae2Reflect.getResult(this);
IGrid grid = this.getGrid();
if (result instanceof CraftingJobV2 && !this.isSimulation()
&& grid != null
&& !grid.getMachines(TilePatternOptimizationMatrix.class).isEmpty()) {
@@ -5,7 +5,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.util.Ae2Reflect;
import appeng.api.config.SchedulingMode;
import appeng.api.config.Settings;
@@ -34,7 +33,7 @@ public class ContainerFluidIO extends FCContainerFluidConfigurable {
@Override
protected void loadSettingsFromHost(IConfigManager cm) {
super.loadSettingsFromHost(cm);
if (Ae2Reflect.getUpgradeableHost(this) instanceof PartFluidExportBus) {
if (this.getUpgradeable() instanceof PartFluidExportBus) {
this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY));
this.setSchedulingMode((SchedulingMode) cm.getSetting(Settings.SCHEDULING_MODE));
}
@@ -1,6 +1,5 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
@@ -8,12 +7,11 @@ import net.minecraft.inventory.IInventory;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.implementations.IUpgradeableHost;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.container.guisync.GuiSync;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
@@ -25,7 +23,7 @@ public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
private final PartFluidLevelEmitter lvlEmitter;
@SideOnly(Side.CLIENT)
private GuiTextField textField;
private MEGuiTextField textField;
@GuiSync(2)
public long EmitterValue = -1;
@@ -39,10 +37,6 @@ public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
return this.lvlEmitter;
}
protected IUpgradeableHost getUpgradeable() {
return Ae2Reflect.getUpgradeableHost(this);
}
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.lvlEmitter.getInventoryByName("config");
}
@@ -50,15 +44,12 @@ public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
@Override
protected void setupConfig() {
final IInventory inv = this.getUpgradeable().getInventoryByName("config");
final int y = 40;
final int x = 80 + 44;
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, x, y, 0, 0, 0));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, 17, 42, 0, 0, 0));
}
@SideOnly(Side.CLIENT)
public void setTextField(final GuiTextField level) {
public void setTextField(final MEGuiTextField level) {
this.textField = level;
this.textField.setText(String.valueOf(this.EmitterValue));
}
public void setLevel(final long l, final EntityPlayer player) {
@@ -87,8 +78,7 @@ public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
if (Platform.isServer()) {
this.EmitterValue = this.lvlEmitter.getReportingValue();
this.setRedStoneMode(
(RedstoneMode) Ae2Reflect.getUpgradeableHost(this).getConfigManager()
.getSetting(Settings.REDSTONE_EMITTER));
(RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_EMITTER));
}
this.standardDetectAndSendChanges();
@@ -99,6 +89,10 @@ public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
if (field.equals("EmitterValue")) {
if (this.textField != null) {
this.textField.setText(String.valueOf(this.EmitterValue));
if (String.valueOf(oldValue).equals("-1")) {
this.textField.setCursorPositionEnd();
}
}
}
}
@@ -314,8 +314,15 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
// Step 4: calculate outputs
final int emptiedTanks = (int) (totalInserted / fluidPerContainer);
final int partialDrain = (int) (totalInserted % fluidPerContainer);
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;
@@ -325,10 +332,15 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
if (targetStack.getItem() instanceof IFluidContainerItem fcItem) {
if (emptiedTanks > 0) {
emptiedTanksStack = targetStack.copy();
emptiedTanksStack.stackSize = 1;
fcItem.drain(emptiedTanksStack, fluidPerContainer, true);
emptiedTanksStack.stackSize = emptiedTanks;
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;
}
@@ -383,8 +395,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
} else if (partialTanksStack != null) {
player.inventory.setInventorySlotContents(slotIndex, partialTanksStack);
} else {
player.inventory.setItemStack(null);
shouldSendStack = false;
player.inventory.setInventorySlotContents(slotIndex, null);
}
}
if (shouldSendStack) {
@@ -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);
}
}
}
@@ -9,7 +9,6 @@ import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurab
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
@@ -23,6 +22,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;
@@ -50,8 +50,8 @@ public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
protected void setupConfig() {
final int xo = 8;
final int yo = 23 + 6;
final IInventory upgrades = Ae2Reflect.getUpgradeList(this).getInventoryByName("upgrades");
final IInventory config = Ae2Reflect.getUpgradeList(this).getInventoryByName("config");
final IInventory upgrades = getUpgradeable().getInventoryByName("upgrades");
final IInventory config = getUpgradeable().getInventoryByName("config");
for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) {
this.addSlotToContainer(
@@ -103,7 +103,7 @@ public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
@Override
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
final int upgrades = getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
final int y = slot / 9;
return y < upgrades + 2;
}
@@ -125,11 +125,9 @@ public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
this.verifyPermissions(SecurityPermissions.BUILD, false);
if (Platform.isServer()) {
this.setReadWriteMode(
(AccessRestriction) Ae2Reflect.getUpgradeList(this).getConfigManager().getSetting(Settings.ACCESS));
this.setReadWriteMode((AccessRestriction) getUpgradeable().getConfigManager().getSetting(Settings.ACCESS));
this.setStorageFilter(
(StorageFilter) Ae2Reflect.getUpgradeList(this).getConfigManager()
.getSetting(Settings.STORAGE_FILTER));
(StorageFilter) getUpgradeable().getConfigManager().getSetting(Settings.STORAGE_FILTER));
}
this.standardDetectAndSendChanges();
@@ -137,8 +135,8 @@ public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
@Override
public boolean isSlotEnabled(final int idx) {
if (Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.ORE_FILTER) > 0) return false;
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
if (getUpgradeable().getInstalledUpgrades(Upgrades.ORE_FILTER) > 0) return false;
final int upgrades = getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
return upgrades > (idx - 2);
}
@@ -156,7 +154,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();
}
@@ -19,7 +19,7 @@ public class ContainerInterfaceWireless extends FCBaseContainer {
delegateContainer = new ContainerInterfaceTerminal(ip, monitorable);
this.bindPlayerInventory(ip, 14, 0);
this.bindPlayerInventory(ip, 14, 3);
}
@Override
@@ -1,20 +1,15 @@
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.FluidCraft;
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 com.glodblock.github.network.SPacketLevelMaintainerGuiUpdate;
import appeng.api.config.SecurityPermissions;
import appeng.container.AEBaseContainer;
@@ -26,6 +21,10 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
private final TileLevelMaintainer tile;
private final SlotFluidConvertingFake[] requestSlots = new SlotFluidConvertingFake[TileLevelMaintainer.REQ_COUNT];
private static final int UPDATE_INTERVAL = 20;
private boolean isFirstUpdate = true;
private int updateCount = UPDATE_INTERVAL;
public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(ipl, tile);
this.tile = tile;
@@ -48,51 +47,17 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
Slot slot = getSlot(slotId);
if (slot instanceof SlotFluidConvertingFake) {
if (getSlot(slotId) instanceof SlotFluidConvertingFake slot) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN -> {
case PICKUP_OR_SET_DOWN, PLACE_SINGLE, SPLIT_OR_PLACE_SINGLE -> {
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))));
slot.putConvertedStack(stack);
}
}
default -> {}
}
} else {
super.doAction(player, action, slotId, id);
@@ -108,10 +73,8 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
for (int i = 0; i < this.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.getRequestSlots()[i];
if (!slot.getHasStack()) {
ItemStack itemStack = ((Slot) this.inventorySlots.get(idx)).getStack();
ItemStack configuration = createLevelValues(itemStack.copy());
configuration.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putConvertedStack(configuration);
ItemStack itemStack = this.inventorySlots.get(idx).getStack();
tile.updateStack(i, itemStack.copy());
break;
}
}
@@ -122,35 +85,23 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isClient()) {
return;
}
this.verifyPermissions(SecurityPermissions.BUILD, false);
super.detectAndSendChanges();
if (this.updateCount++ >= UPDATE_INTERVAL) {
this.updateGui();
}
}
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;
public void updateGui() {
FluidCraft.proxy.netHandler.sendTo(
new SPacketLevelMaintainerGuiUpdate(this.tile.requests, !this.isFirstUpdate),
(EntityPlayerMP) this.getInventoryPlayer().player);
this.isFirstUpdate = false;
this.updateCount = 0;
}
}
@@ -1,30 +1,27 @@
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 org.jetbrains.annotations.Nullable;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.api.registries.LevelItemInfo;
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;
@@ -32,12 +29,7 @@ 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 {
@@ -50,8 +42,8 @@ public class ContainerLevelTerminal extends FCBaseContainer {
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
private IGrid grid;
private SPacketLevelTerminalUpdate dirty;
private boolean isDirty;
private SPacketLevelTerminalUpdate updatePacket;
private boolean isPacketDirty;
private boolean wasOff;
private int ticks = 0;
@@ -63,11 +55,13 @@ public class ContainerLevelTerminal extends FCBaseContainer {
} else if (monitorable instanceof IWirelessTerminal wirelessTerminal) {
grid = wirelessTerminal.getActionableNode().getGrid();
}
dirty = this.updateList();
if (dirty != null) {
this.isDirty = true;
updatePacket = this.updateList();
if (updatePacket != null) {
this.isPacketDirty = true;
} else {
dirty = new SPacketLevelTerminalUpdate();
updatePacket = new SPacketLevelTerminalUpdate();
this.isPacketDirty = false;
}
}
@@ -92,7 +86,7 @@ public class ContainerLevelTerminal extends FCBaseContainer {
if (!wasOff) {
SPacketLevelTerminalUpdate update = new SPacketLevelTerminalUpdate();
update.setDisconnect();
update.addDisconnectEntry();
wasOff = true;
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
@@ -100,149 +94,20 @@ public class ContainerLevelTerminal extends FCBaseContainer {
}
wasOff = false;
if (isDirty) {
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) this.getPlayerInv().player);
dirty = new SPacketLevelTerminalUpdate();
isDirty = false;
if (isPacketDirty) {
FluidCraft.proxy.netHandler.sendTo(updatePacket, (EntityPlayerMP) this.getPlayerInv().player);
updatePacket = new SPacketLevelTerminalUpdate();
isPacketDirty = false;
} else if (++ticks % 20 == 0) {
ticks = 0;
SPacketLevelTerminalUpdate update = this.updateList();
if (update != null) {
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
SPacketLevelTerminalUpdate updateNew = this.updateList();
if (updateNew != null) {
FluidCraft.proxy.netHandler.sendTo(updateNew, (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;
}
@Nullable
private SPacketLevelTerminalUpdate updateList() {
SPacketLevelTerminalUpdate update = null;
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
@@ -257,64 +122,67 @@ public class ContainerLevelTerminal extends FCBaseContainer {
final ILevelViewable machine = isAdopted
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridHost)
: (ILevelViewable) gridHost;
visited.add(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;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addRenameEntry(knownTracker.id, name);
}
/* Status changed? */
boolean isActive = gridNode.isActive() || machine.shouldDisplay();
LevelItemInfo[] prev = knownTracker.infoList;
LevelItemInfo[] curr = machine.getLevelItemInfoList();
if (prev.length == curr.length) {
for (int i = 0; i < prev.length; i++) {
if (prev[i] == null && curr[i] == null) continue;
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);
if (prev[i] == null) {
knownTracker.infoList[i] = curr[i];
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteSlotEntry(knownTracker.id, i, curr[i]);
} else if (curr[i] == null) {
knownTracker.infoList[i] = null;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteSlotEntry(knownTracker.id, i, null);
} else if (!ItemStack.areItemStacksEqual(prev[i].stack, curr[i].stack)
|| prev[i].quantity == curr[i].quantity
|| prev[i].batchSize == curr[i].batchSize
|| prev[i].state == curr[i].state) {
knownTracker.infoList[i] = curr[i];
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteSlotEntry(knownTracker.id, i, curr[i]);
}
}
} else {
knownTracker.infoList = curr;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteAllSlotEntry(knownTracker.id, curr);
}
} 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());
ContainerLevelTerminal.InvTracker entry = new ContainerLevelTerminal.InvTracker(nextId++, machine);
update.addNewEntry(
entry.id,
entry.x,
entry.y,
entry.z,
entry.dim,
entry.side.ordinal(),
entry.rows,
entry.rowSize,
entry.name,
entry.infoList);
tracked.put(gridHost, entry);
trackedById.put(entry.id, entry);
}
visited.add(gridHost);
}
}
@@ -327,10 +195,9 @@ public class ContainerLevelTerminal extends FCBaseContainer {
}
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addRemoveEntry(entry.getValue().id);
trackedById.remove(entry.getValue().id);
it.remove();
update.addRemovalEntry(entry.getValue().id);
}
return update;
}
@@ -340,23 +207,10 @@ public class ContainerLevelTerminal extends FCBaseContainer {
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;
@@ -364,16 +218,15 @@ public class ContainerLevelTerminal extends FCBaseContainer {
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) {
private LevelItemInfo[] infoList;
public InvTracker(long id, ILevelViewable machine) {
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;
@@ -381,26 +234,8 @@ public class ContainerLevelTerminal extends FCBaseContainer {
this.z = location.z;
this.dim = location.getDimension();
this.side = machine.getSide();
this.online = online;
this.inventoryNbt = new NBTTagList();
updateNBT();
this.infoList = machine.getLevelItemInfoList();
}
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,106 @@
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.OptionalSlotFake;
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;
@GuiSync(105)
public boolean oreDict;
@GuiSync(106)
public String oreDictFilter;
protected OptionalSlotFake[] filterSlots;
protected final IInventory filter;
public ContainerMagnetFilter(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.filter = ((IItemTerminal) monitorable).getInventoryByName("config");
this.filterSlots = new OptionalSlotFake[27];
oreDictFilter = ((IWirelessMagnetFilter) getHost()).getOreDictFilter();
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));
this.filterSlots[x + y * 9].setRenderDisabled(false);
}
}
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();
this.oreDict = host.getOreDictMode();
this.oreDictFilter = host.getOreDictFilter();
}
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());
}
}
@@ -4,7 +4,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import appeng.api.config.SecurityPermissions;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotInaccessible;
@@ -17,7 +16,7 @@ public class ContainerPatternValueAmount extends AEBaseContainer {
@GuiSync(11)
public int valueIndex;
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te) {
public ContainerPatternValueAmount(final InventoryPlayer ip, final Object te) {
super(ip, te);
this.patternValue = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53);
this.addSlotToContainer(patternValue);
@@ -0,0 +1,154 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFake;
import com.glodblock.github.network.SPacketSuperStockReplenisherUpdate;
import appeng.api.storage.data.IAEStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.SlotRestrictedInput;
import appeng.items.storage.ItemBasicStorageCell;
import appeng.util.item.AEItemStack;
public class ContainerSuperStockReplenisher extends AEBaseContainer implements IOptionalSlotHost {
private final TileSuperStockReplenisher tile;
private final IInventory configFluids;
private final IInventory configItems;
private int lastUpdated = 0;
public ContainerSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(ipl, tile);
this.tile = tile;
configFluids = tile.getConfigFluid();
configItems = tile.getConfigItems();
final IInventory cell = tile.getCell();
final int x = 8;
final int fy = 8;
this.addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL,
cell,
0,
173,
fy,
this.getInventoryPlayer()));
for (int i = 0; i < 9; i++) {
addSlotToContainer(new OptionalFluidSlotFake(configFluids, this, i, x, fy, i, 0, 0));
}
final int io = 29;
for (int y = 0; y < 7; y++) {
for (int ix = 0; ix < 9; ix++) {
this.addSlotToContainer(new SlotPatternOutputs(configItems, this, y * 9 + ix, x, io, ix, y, y));
}
}
bindPlayerInventory(ipl, 0, 251 - 82);
}
@Override
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
if (slotId == 0 && player.inventory.getItemStack() == null && isConfigurated()) {
return null;
}
return super.slotClick(slotId, clickedButton, mode, player);
}
@Override
public boolean isSlotEnabled(int idx) {
return true;
}
@Override
public void addCraftingToCrafters(ICrafting p_75132_1_) {
super.addCraftingToCrafters(p_75132_1_);
lastUpdated = 24;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (lastUpdated > 20) {
lastUpdated = 0;
Map<Integer, IAEStack<?>> tmp = new HashMap<>();
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < tile.getInternalInventory().getSizeInventory(); i++) {
tmp.put(i + 100, AEItemStack.create(tile.getInternalInventory().getStackInSlot(i)));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketSuperStockReplenisherUpdate(tmp), (EntityPlayerMP) g);
}
}
}
lastUpdated++;
}
private boolean isConfigurated() {
for (int i = 0; i < configItems.getSizeInventory(); i++) {
if (configItems.getStackInSlot(i) != null) {
return true;
}
}
for (int i = 0; i < configFluids.getSizeInventory(); i++) {
if (configFluids.getStackInSlot(i) != null) {
return true;
}
}
return false;
}
@Override
public boolean isValidForSlot(Slot s, ItemStack is) {
if (s.slotNumber == 0 && s.getHasStack() && isConfigurated()) {
long currentBytes = 0;
long newBytes = -1;
if (s.getStack().getItem() instanceof ItemBasicStorageCell ibsc) {
currentBytes = ibsc.getBytesLong(is);
} else if (s.getStack().getItem() instanceof FCBaseItemCell fcbic) {
currentBytes = fcbic.getBytes(is);
}
if (is.getItem() instanceof ItemBasicStorageCell ibsc) {
newBytes = ibsc.getBytesLong(is);
} else if (is.getItem() instanceof FCBaseItemCell fcbic) {
newBytes = fcbic.getBytes(is);
}
if (currentBytes > newBytes) {
return false;
}
}
return super.isValidForSlot(s, is);
}
public TileSuperStockReplenisher getTile() {
return tile;
}
}
@@ -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;
}
}
@@ -53,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;
@@ -155,6 +157,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
slot.putStack(ItemFluidPacket.newStack(fluid));
return;
}
default -> {}
}
}
@@ -268,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()));
}
@@ -537,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();
}
@@ -14,7 +14,6 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Util;
import appeng.api.config.Upgrades;
@@ -64,7 +63,7 @@ public abstract class FCContainerFluidConfigurable extends ContainerUpgradeable
protected void setupConfig() {
this.setupUpgrades();
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName("config");
final IInventory inv = getUpgradeable().getInventoryByName("config");
final int y = 40;
final int x = 80;
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, x, y, 0, 0, 0));
@@ -84,7 +83,7 @@ public abstract class FCContainerFluidConfigurable extends ContainerUpgradeable
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
// assumes 4 slots per upgrade
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
final int upgrades = getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
if (slot > 0 && upgrades < 1) {
return false;
@@ -1,6 +1,8 @@
package com.glodblock.github.client.gui.container.base;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
@@ -10,10 +12,15 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import com.glodblock.github.inventory.item.BaseWirelessInventory;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import appeng.api.config.Actionable;
import appeng.api.config.CraftingAllow;
import appeng.api.config.PinsState;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
@@ -22,10 +29,16 @@ import appeng.api.config.SortOrder;
import appeng.api.config.TypeFilter;
import appeng.api.config.ViewItems;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.ITerminalPins;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
@@ -34,18 +47,22 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPinsHandler;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.items.contents.PinsHandler;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<T> {
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<T>, IPinsHandler {
protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
protected final IConfigManager clientCM;
protected final ITerminalHost host;
protected PinsHandler pinsHandler = null;
@GuiSync(99)
public boolean canAccessViewCells = false;
@@ -70,6 +87,14 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
this.clientCM.registerSetting(Settings.TYPE_FILTER, TypeFilter.ALL);
this.clientCM.registerSetting(Settings.PINS_STATE, PinsState.DISABLED); // use for GUI
if (Platform.isServer()) {
if (monitorable instanceof ITerminalPins t && !(monitorable instanceof BaseWirelessInventory bwi
&& bwi.getChannel() == StorageChannel.FLUIDS)) {
pinsHandler = t.getPinsHandler(ip.player);
}
}
}
public IMEMonitor<T> getMonitor() {
@@ -105,6 +130,16 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
}
}
}
if (pinsHandler != null) {
if (clientCM.getSetting(Settings.PINS_STATE) != pinsHandler.getPinsState()) {
this.clientCM.putSetting(Settings.PINS_STATE, pinsHandler.getPinsState());
updatePins(true);
} else {
updatePins(false);
}
}
processItemList();
this.updatePowerStatus();
final boolean oldAccessible = this.canAccessViewCells;
@@ -122,6 +157,84 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo
}
}
private int lastUpdate = 0;
public void updatePins(boolean forceUpdate) {
if (pinsHandler == null || !(host instanceof ITerminalPins itp)) return;
boolean isActive = pinsHandler.getPinsState() != PinsState.DISABLED;
++lastUpdate;
if (!forceUpdate && lastUpdate <= 20) return;
lastUpdate = 0;
if (isActive) {
final ICraftingGrid cc = itp.getGrid().getCache(ICraftingGrid.class);
final ImmutableList<ICraftingCPU> cpuList = cc.getCpus().asList();
List<IAEItemStack> craftedItems = new ArrayList<>();
// fetch the first available crafting output
for (int i = 0; i < cpuList.size(); i++) {
ICraftingCPU cpu = cpuList.get(i);
if (cpu.getCraftingAllowMode() != CraftingAllow.ONLY_NONPLAYER && cpu.getFinalOutput() != null
&& cpu.getCurrentJobSource() instanceof PlayerSource src
&& src.player == pinsHandler.getPlayer()) {
if (craftedItems.contains(cpu.getFinalOutput())) {
continue; // skip if already added
}
if (cpu.isBusy()) craftedItems.add(0, cpu.getFinalOutput().copy());
else craftedItems.add(cpu.getFinalOutput().copy());
}
}
pinsHandler.addItemsToPins(craftedItems);
}
pinsHandler.update(forceUpdate);
onListUpdate(); // notify the repo that the pins have changed
}
@Override
public void setPin(ItemStack is, int idx) {
if (pinsHandler == null || !(host instanceof ITerminalPins itp)) return;
if (is == null) {
final ICraftingGrid cc = itp.getGrid().getCache(ICraftingGrid.class);
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
for (ICraftingCPU cpu : cpuSet) {
if (cpu.getCraftingAllowMode() != CraftingAllow.ONLY_NONPLAYER && cpu.getFinalOutput() != null
&& cpu.getFinalOutput().isSameType(getPin(idx))) {
if (!cpu.isBusy()) {
cpu.resetFinalOutput();
} else {
return;
}
}
}
}
pinsHandler.setPin(idx, is);
updatePins(true);
}
@Override
public ItemStack getPin(int idx) {
if (pinsHandler == null) return null;
return pinsHandler.getPin(idx);
}
public void setPinsState(PinsState pinsState) {
if (pinsHandler == null) return;
clientCM.putSetting(Settings.PINS_STATE, pinsState);
pinsHandler.setPinsState(pinsState);
updatePins(true);
}
public PinsState getPinsState() {
return pinsHandler != null ? pinsHandler.getPinsState() : PinsState.DISABLED;
}
public PinsHandler getPinsHandler() {
return pinsHandler;
}
protected abstract void processItemList();
protected boolean isInvalid() {
@@ -224,13 +337,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() {
if (needUpdateView()) 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 : needUpdateView() ? this.list : this.cache) {
for (IAEItemStack is : entries) {
if (!AspectUtil.isEssentiaGas(ItemFluidDrop.getAeFluidStack(is))) {
continue;
}
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
continue;
@@ -87,44 +140,6 @@ public class EssentiaRepo extends FluidRepo {
this.view.add(is);
}
}
if (needUpdateView()) {
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);
}
} else {
this.cache.clear();
}
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
this.lastSearchString = this.searchString;
Iterator<IAEItemStack> it1 = this.view.iterator();
while (it1.hasNext()) {
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(it1.next());
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();
}
}
}
}
@@ -10,11 +10,11 @@
package com.glodblock.github.client.me;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
@@ -47,15 +47,14 @@ public class FluidRepo implements IDisplayRepo {
protected final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
protected final ArrayList<IAEItemStack> view = new ArrayList<>();
protected final ArrayList<ItemStack> dsp = new ArrayList<>();
protected final ArrayList<IAEItemStack> cache = new ArrayList<>();
protected final IScrollSource src;
protected final ISortSource sortSrc;
protected int rowSize = 9;
protected String searchString = "";
protected String lastSearchString = "";
protected IPartitionList<IAEItemStack> myPartitionList;
protected boolean paused = false;
private String NEIWord = null;
private boolean hasPower;
@@ -90,33 +89,74 @@ public class FluidRepo implements IDisplayRepo {
if (st != null) {
st.reset();
st.add(is);
if (isShiftKeyDown() && this.view.contains(st)) {
this.view.get(this.view.indexOf(st)).setStackSize(st.getStackSize());
}
} else {
if (isShiftKeyDown()) this.cache.add(is);
this.list.add(is);
}
}
protected boolean needUpdateView() {
return !isShiftKeyDown() || !this.lastSearchString.equals(this.searchString);
}
@Override
public void setViewCell(final ItemStack[] list) {
this.myPartitionList = ItemViewCell.createFilter(list);
this.updateView();
}
@SuppressWarnings("deprecation")
@Override
public void updateView() {
if (needUpdateView()) 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) {
@@ -142,7 +182,7 @@ public class FluidRepo implements IDisplayRepo {
}
}
for (IAEItemStack is : needUpdateView() ? this.list : this.cache) {
for (IAEItemStack is : entries) {
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
continue;
@@ -179,30 +219,6 @@ public class FluidRepo implements IDisplayRepo {
}
}
}
if (needUpdateView()) {
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);
}
} else {
this.cache.clear();
}
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
this.lastSearchString = this.searchString;
}
protected void updateNEI(final String filter) {
@@ -260,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();
}
}
}
}
@@ -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();
}
@@ -22,6 +22,8 @@ public class Config {
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();
@@ -74,6 +76,9 @@ public class Config {
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);
@@ -0,0 +1,66 @@
package com.glodblock.github.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import appeng.block.AEBaseItemBlock;
import cpw.mods.fml.common.registry.GameRegistry;
public class BlockSuperStockReplenisher extends FCBaseBlock {
public BlockSuperStockReplenisher() {
super(Material.web, NameConst.BLOCK_SUPER_STOCK_REPLENISHER);
setTileEntity(TileSuperStockReplenisher.class);
setOpaque(true);
setFullBlock(true);
this.lightOpacity = 4;
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX,
float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileSuperStockReplenisher tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(
player,
world,
new BlockPos(x, y, z),
ForgeDirection.getOrientation(facing),
GuiType.GUI_SUPER_STOCK_REPLENISHER);
}
return true;
}
return false;
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b) {
final TileSuperStockReplenisher tss = this.getTileEntity(w, x, y, z);
if (tss != null) {
tss.fullRefund();
}
super.breakBlock(w, x, y, z, a, b);
}
@Override
public BlockSuperStockReplenisher register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_SUPER_STOCK_REPLENISHER);
GameRegistry.registerTileEntity(TileSuperStockReplenisher.class, NameConst.BLOCK_SUPER_STOCK_REPLENISHER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -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,9 +17,10 @@ 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.FluidCellInventory;
import com.glodblock.github.common.storage.FluidCellInventoryHandler;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.inventory.FluidCellConfig;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
@@ -33,14 +35,15 @@ 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,12 +94,12 @@ 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 FluidCellInventoryHandler handler) {
final IFluidCellInventory cellInventory = handler.getCellInv();
final FluidCellInventory cellInventory = (FluidCellInventory) handler.getCellInv();
if (cellInventory != null) {
lines.add(
@@ -118,7 +120,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ cellInventory.getTotalFluidTypes()
+ cellInventory.getMaxFluidTypes()
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.Types.getLocal());
@@ -143,8 +145,8 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
}
if (handler.isPreformatted()) {
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
: GuiText.Excluded).getLocal();
final String list = (handler.getWhitelist() == IncludeExclude.WHITELIST ? GuiText.Included
: GuiText.Excluded).getLocal();
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
if (GuiScreen.isShiftKeyDown()) {
@@ -159,6 +161,17 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
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));
}
}
}
}
}
@@ -190,12 +203,12 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 2);
return new CellUpgrades(is, 5);
}
@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
return new FluidCellConfig(is);
}
@Override
@@ -213,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()) {
@@ -224,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,8 @@ 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";
public ItemBaseWirelessTerminal(GuiType t) {
super();
@@ -41,26 +46,27 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
if (player.isSneaking()) return removeInfinityBoosterCard(player, item);
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
// terminal
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
if (Platform.isClient()) {
return item;
}
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
if (!term.isWirelessTerminal(item)) {
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.toChat());
return item;
}
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) {
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
player.addChatMessage(PlayerMessages.DeviceNotLinked.toChat());
return item;
}
final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) {
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.toChat());
return item;
}
if (handler.hasPower(player, 0.5, item)) {
@@ -71,7 +77,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
ForgeDirection.UNKNOWN,
this.guiGuiType(item));
} else {
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
player.addChatMessage(PlayerMessages.DeviceNotPowered.toChat());
}
}
@@ -98,6 +104,9 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
if (hasInfinityBoosterCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getInfinityBoosterCard().getDisplayName());
}
if (hasEnergyCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getEnergyCard().getDisplayName());
}
} else {
lines.add(NameConst.i18n(NameConst.TT_CTRL_FOR_MORE));
}
@@ -105,6 +114,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 +133,8 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
return this.type;
}
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.inventory.FluidCellConfig;
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,55 +28,9 @@ 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);
return new FluidCellConfig(is);
}
@Override
@@ -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.inventory.FluidCellConfig;
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.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 FluidCellConfig(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 {
@@ -43,9 +43,8 @@ public class ItemPartLevelTerminal 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_LEVEL_TERMINAL));
} else {
@@ -20,6 +20,7 @@ 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.inventory.FluidCellConfig;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IItemInventory;
@@ -37,7 +38,6 @@ import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.util.Platform;
@@ -163,7 +163,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
@Override
public IInventory getConfigInventory(final ItemStack is) {
return new CellConfig(is);
return new FluidCellConfig(is);
}
@Override
@@ -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));
}
}
}
@@ -44,7 +44,7 @@ public class ItemWirelessFluidTerminal extends ItemBaseWirelessTerminal
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
}
return null;
}
@@ -44,7 +44,7 @@ public class ItemWirelessInterfaceTerminal extends ItemBaseWirelessTerminal
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
}
return null;
}
@@ -44,7 +44,7 @@ public class ItemWirelessLevelTerminal extends ItemBaseWirelessTerminal
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
}
return null;
}
@@ -44,7 +44,7 @@ public class ItemWirelessPatternTerminal extends ItemBaseWirelessTerminal
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
}
return null;
}
@@ -7,8 +7,10 @@ import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
@@ -25,6 +27,8 @@ 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.WirelessMagnet;
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;
@@ -40,6 +44,7 @@ import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import baubles.api.IBauble;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -102,7 +107,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);
@@ -121,12 +128,14 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
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);
}
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
}
return null;
}
@@ -226,7 +235,21 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
@Override
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
if (Platform.isServer() && entityLivingBase instanceof EntityPlayer player) {
IInventory handler = BaublesApi.getBaubles(player);
if (handler != null) {
for (int i = 0; i < handler.getSizeInventory(); ++i) {
if (handler.getStackInSlot(i) == itemStack) {
onUpdate(
itemStack,
null,
player,
Util.GuiHelper.encodeType(i, Util.GuiHelper.InvType.PLAYER_BAUBLES),
false);
}
}
}
}
}
@Override
@@ -248,4 +271,13 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int slot, boolean p_77663_5_) {
if (entityIn instanceof EntityPlayer player) {
if (WirelessMagnet.getMode(stack) != WirelessMagnet.Mode.Off) {
WirelessMagnet.doMagnet(stack, player);
}
}
}
}
@@ -112,10 +112,9 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
this.didSomething = false;
this.fluidToSend = this.calculateAmountToSend();
final TileEntity te = this.getConnectedTE();
if (te instanceof IFluidHandler) {
InventoryAdaptor destination;
if (te instanceof IFluidHandler && (destination = this.getHandler(te)) != null) {
try {
final InventoryAdaptor destination = this.getHandler(te);
final ICraftingGrid cg = this.getProxy().getCrafting();
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
@@ -18,6 +18,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.api.registries.ILevelViewable;
import com.glodblock.github.api.registries.LevelItemInfo;
import com.glodblock.github.api.registries.LevelState;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -226,8 +228,10 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
}
@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();
@@ -312,9 +316,10 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
@SideOnly(Side.CLIENT)
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
rh.setTexture(this.getItemStack().getIconIndex());
Tessellator.instance.startDrawingQuads();
final Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
this.renderTorchAtAngle(0, -0.5, 0);
Tessellator.instance.draw();
tess.draw();
}
private void renderTorchAtAngle(double baseX, double baseY, double baseZ) {
@@ -529,7 +534,8 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
}
@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();
}
@@ -583,4 +589,15 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
return super.getInventoryByName(name);
}
@Override
public LevelItemInfo[] getLevelItemInfoList() {
ItemStack stack = this.config.getStackInSlot(0);
if (stack == null) return new LevelItemInfo[] { null };
return new LevelItemInfo[] { new LevelItemInfo(
stack,
this.getReportingValue(),
-1,
this.isProvidingStrongPower() > 0 ? LevelState.Craft : LevelState.Idle) };
}
}
@@ -1,5 +1,7 @@
package com.glodblock.github.common.parts;
import static appeng.helpers.DualityInterface.NUMBER_OF_STORAGE_SLOTS;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@@ -56,6 +58,7 @@ import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.me.cache.CraftingGridCache;
import appeng.parts.automation.UpgradeInventory;
import appeng.parts.p2p.PartP2PTunnel;
import appeng.parts.p2p.PartP2PTunnelStatic;
@@ -64,28 +67,45 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.inv.AdaptorIInventory;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.WrapperInvSlot;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInterface>
implements IGridTickable, IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory,
IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost, IInterfaceHost {
boolean needUpdateOnNetworkBooted = false;
boolean lastPowerStart = false;
public PartFluidP2PInterface(ItemStack is) {
super(is);
}
private final DualityInterface duality = new DualityInterface(this.getProxy(), this) {
@Override
public void updateCraftingList() {
if (!isOutput()) {
CraftingGridCache.pauseRebuilds();
super.updateCraftingList();
try {
for (PartFluidP2PInterface p2p : getOutputs()) p2p.duality.updateCraftingList();
for (PartFluidP2PInterface p2p : getOutputs()) {
p2p.duality.updateCraftingList();
}
} catch (GridAccessException e) {
// ?
}
CraftingGridCache.unpauseRebuilds();
} else {
PartFluidP2PInterface p2p = getInput();
if (p2p != null) {
this.craftingList = p2p.duality.craftingList;
try {
this.gridProxy.getGrid()
.postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
@@ -96,29 +116,165 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
}
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
final boolean powerState = proxy.isActive();
if (needUpdateOnNetworkBooted || lastPowerStart != powerState) {
needUpdateOnNetworkBooted = false;
lastPowerStart = powerState;
updateSharingInventory();
}
return super.tickingRequest(node, ticksSinceLastCall);
}
@Override
protected boolean hasWorkToDo() {
if (isOutput()) {
return hasItemsToSend() || hasConfig() || !getStorage().isEmpty();
} else return super.hasWorkToDo();
}
@Override
public void readConfig() {
if (isOutput()) {
PartFluidP2PInterface p2p = getInput();
boolean alertDevice = false;
if (p2p != null) {
this.setHasConfig(p2p.duality.hasConfig());
alertDevice = hasWorkToDo();
} else {
this.setHasConfig(false);
}
if (alertDevice) {
try {
this.gridProxy.getTick().alertDevice(this.gridProxy.getNode());
} catch (final GridAccessException ignored) {}
} else {
try {
this.gridProxy.getTick().sleepDevice(this.gridProxy.getNode());
} catch (final GridAccessException ignored) {}
}
this.notifyNeighbors();
} else {
super.readConfig();
}
}
@Override
public void addDrops(final List<ItemStack> drops) {
if (!isOutput()) {
super.addDrops(drops);
try {
for (PartFluidP2PInterface p2p : getOutputs()) p2p.duality.addDrops(drops);
} catch (GridAccessException ignored) {}
} else {
if (this.getWaitingToSend() != null) {
for (final ItemStack is : this.getWaitingToSend()) {
if (is != null) {
drops.add(is);
}
}
}
for (final ItemStack is : this.getUpgrades()) {
if (is != null) {
drops.add(is);
}
}
for (final ItemStack is : this.getPatterns()) {
if (is != null) {
drops.add(is);
}
}
}
}
@Override
public int getInstalledUpgrades(Upgrades u) {
if (isOutput() && u == Upgrades.PATTERN_CAPACITY) return -1;
return super.getInstalledUpgrades(u);
}
@Override
public int getConfigSize() {
if (isOutput()) return -1;
return super.getConfigSize();
}
};
private final DualityFluidInterface dualityFluid = new DualityFluidInterface(this.getProxy(), this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
public PartFluidP2PInterface(ItemStack is) {
super(is);
private void updateSharingInventory() {
duality.readConfig();
if (isOutput()) {
PartFluidP2PInterface p2p = getInput();
if (proxy.isActive() && p2p != null) {
if (!duality.sharedInventory && !duality.getStorage().isEmpty()) {
ArrayList<ItemStack> drops = new ArrayList<>();
AppEngInternalInventory storageAppEng = this.duality.getStorage();
AdaptorIInventory p2pInv = new AdaptorIInventory(p2p.duality.getStorage());
for (ItemStack itemStack : storageAppEng) {
if (itemStack == null) continue;
ItemStack drop = p2pInv.addItems(itemStack);
if (drop != null && drop.stackSize > 0) {
drops.add(drop);
}
}
TileEntity te = getTileEntity();
Platform.spawnDrops(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, drops);
}
duality.setStorage(p2p.duality.getStorage());
duality.sharedInventory = true;
} else {
if (duality.sharedInventory) {
duality.setStorage(new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS));
duality.setSlotInv(new WrapperInvSlot(duality.getStorage()));
duality.sharedInventory = false;
}
}
} else {
if (duality.sharedInventory) {
duality.setStorage(new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS));
duality.setSlotInv(new WrapperInvSlot(duality.getStorage()));
duality.sharedInventory = false;
}
try {
for (PartFluidP2PInterface p2p : getOutputs()) {
p2p.duality.readConfig();
}
} catch (GridAccessException ignored) {}
}
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkChannelsChanged c) {
dualityFluid.onChannelStateChange(c);
duality.notifyNeighbors();
this.duality.notifyNeighbors();
updateSharingInventory();
needUpdateOnNetworkBooted = true;
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkPowerStatusChange c) {
dualityFluid.onPowerStateChange(c);
duality.notifyNeighbors();
this.duality.notifyNeighbors();
updateSharingInventory();
needUpdateOnNetworkBooted = true;
}
@Override
public int getInstalledUpgrades(final Upgrades u) {
return this.duality.getInstalledUpgrades(u);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getTypeTexture() {
return ItemAndBlockHolder.INTERFACE.getBlockTextureFromSide(0);
}
@Override
@@ -127,20 +283,73 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
dualityFluid.gridChanged();
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.duality.readFromNBT(data);
}
@Override
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
this.duality.writeToNBT(data);
}
@Override
public NBTTagCompound getMemoryCardData() {
final NBTTagCompound output = super.getMemoryCardData();
this.duality.getConfigManager().writeToNBT(output);
return output;
}
@Override
public void pasteMemoryCardData(PartP2PTunnel<?> newTunnel, NBTTagCompound data) throws GridAccessException {
this.duality.getConfigManager().readFromNBT(data);
super.pasteMemoryCardData(newTunnel, data);
}
@Override
public void addToWorld() {
super.addToWorld();
this.duality.initialize();
}
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
this.duality.addDrops(drops);
}
@Override
public int cableConnectionRenderTo() {
return 4;
}
@Override
public IConfigManager getConfigManager() {
return this.duality.getConfigManager();
}
@Override
public IInventory getInventoryByName(final String name) {
return this.duality.getInventoryByName(name);
}
@Override
public void onNeighborChanged() {
this.duality.updateRedstoneState();
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
AppEngInternalInventory patterns = (AppEngInternalInventory) duality.getPatterns();
if (super.onPartActivate(player, pos)) {
public boolean onPartActivate(final EntityPlayer p, final Vec3 pos) {
AppEngInternalInventory patterns = this.duality.getPatterns();
if (super.onPartActivate(p, pos)) {
ArrayList<ItemStack> drops = new ArrayList<>();
for (int i = 0; i < patterns.getSizeInventory(); i++) {
if (patterns.getStackInSlot(i) == null) continue;
drops.add(patterns.getStackInSlot(i));
}
final IPart tile = this.getHost().getPart(this.getSide());
if (tile instanceof PartFluidP2PInterface dualTile) {
DualityInterface newDuality = dualTile.duality;
@@ -151,11 +360,15 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
for (int i = 0; i < upgrades.getSizeInventory(); ++i) {
newUpgrade.setInventorySlotContents(i, upgrades.getStackInSlot(i));
}
IInventory storage = duality.getStorage();
IInventory newStorage = newDuality.getStorage();
for (int i = 0; i < storage.getSizeInventory(); ++i) {
newStorage.setInventorySlotContents(i, storage.getStackInSlot(i));
if (!duality.sharedInventory) {
IInventory storage = duality.getStorage();
IInventory newStorage = newDuality.getStorage();
for (int i = 0; i < storage.getSizeInventory(); ++i) {
newStorage.setInventorySlotContents(i, storage.getStackInSlot(i));
}
}
IConfigManager config = duality.getConfigManager();
config.getSettings().forEach(
setting -> newDuality.getConfigManager().putSetting(setting, config.getSetting(setting)));
@@ -166,13 +379,13 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
return true;
}
if (player.isSneaking()) {
if (p.isSneaking()) {
return false;
}
if (Platform.isServer()) {
InventoryHandler.openGui(
player,
p,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(this.getSide()),
@@ -183,13 +396,23 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
}
@Override
public IIcon getTypeTexture() {
return ItemAndBlockHolder.INTERFACE.getBlockTextureFromSide(0);
public IIcon getBreakingTexture() {
return this.getItemStack().getIconIndex();
}
@Override
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src) {
return duality.getMonitorable(side, src, this);
public boolean canInsert(final ItemStack stack) {
return this.duality.canInsert(stack);
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return this.duality.getItemInventory();
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return this.duality.getFluidInventory();
}
@Override
@@ -214,142 +437,216 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
}
}
@Override
public int getInstalledUpgrades(Upgrades u) {
return duality.getInstalledUpgrades(u);
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return duality.getItemInventory();
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return duality.getFluidInventory();
}
@Override
public int getPriority() {
return duality.getPriority();
}
@Override
public void setPriority(int newValue) {
duality.setPriority(newValue);
}
@Override
public void onTunnelNetworkChange() {
duality.updateCraftingList();
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation op, ItemStack removedStack,
ItemStack newStack) {
duality.onChangeInventory(inv, slot, op, removedStack, newStack);
}
@Override
public boolean canInsert(ItemStack stack) {
return duality.canInsert(stack);
}
@Override
public int getSizeInventory() {
return duality.getStorage().getSizeInventory();
return this.duality.getStorage().getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slotIn) {
return duality.getStorage().getStackInSlot(slotIn);
public ItemStack getStackInSlot(final int i) {
return this.duality.getStorage().getStackInSlot(i);
}
@Override
public ItemStack decrStackSize(int index, int count) {
return duality.getStorage().decrStackSize(index, count);
public ItemStack decrStackSize(final int i, final int j) {
return this.duality.getStorage().decrStackSize(i, j);
}
@Override
public ItemStack getStackInSlotOnClosing(int index) {
return duality.getStorage().getStackInSlotOnClosing(index);
public ItemStack getStackInSlotOnClosing(final int i) {
return this.duality.getStorage().getStackInSlotOnClosing(i);
}
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
duality.getStorage().setInventorySlotContents(index, stack);
}
@Override
public IInventory getInventoryByName(String name) {
return duality.getInventoryByName(name);
}
@Override
public IConfigManager getConfigManager() {
return duality.getConfigManager();
}
@Override
public IIcon getBreakingTexture() {
return getItemStack().getIconIndex();
public void setInventorySlotContents(final int i, final ItemStack itemstack) {
this.duality.getStorage().setInventorySlotContents(i, itemstack);
}
@Override
public String getInventoryName() {
return duality.getStorage().getInventoryName();
return this.duality.getStorage().getInventoryName();
}
@Override
public boolean hasCustomInventoryName() {
return duality.getStorage().hasCustomInventoryName();
return this.duality.getStorage().hasCustomInventoryName();
}
@Override
public int getInventoryStackLimit() {
return duality.getStorage().getInventoryStackLimit();
return this.duality.getStorage().getInventoryStackLimit();
}
@Override
public void markDirty() {
duality.markDirty();
this.duality.getStorage().markDirty();
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return duality.getStorage().isUseableByPlayer(player);
public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
return this.duality.getStorage().isUseableByPlayer(entityplayer);
}
@Override
public void openInventory() {
duality.getStorage().openInventory();
this.duality.getStorage().openInventory();
}
@Override
public void closeInventory() {
duality.getStorage().closeInventory();
this.duality.getStorage().closeInventory();
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
return duality.getStorage().isItemValidForSlot(index, stack);
public boolean isItemValidForSlot(final int i, final ItemStack itemstack) {
return this.duality.getStorage().isItemValidForSlot(i, itemstack);
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return duality.getAccessibleSlotsFromSide(side);
public int[] getAccessibleSlotsFromSide(final int s) {
return this.duality.getAccessibleSlotsFromSide(s);
}
@Override
public boolean canInsertItem(int p_102007_1_, ItemStack itemStack, int p_102007_3_) {
public boolean canInsertItem(final int i, final ItemStack itemstack, final int j) {
return true;
}
@Override
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
public boolean canExtractItem(final int i, final ItemStack itemstack, final int j) {
return true;
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
final ItemStack removedStack, final ItemStack newStack) {
this.duality.onChangeInventory(inv, slot, mc, removedStack, newStack);
}
@Override
public DualityInterface getInterfaceDuality() {
return this.duality;
}
@Override
public EnumSet<ForgeDirection> getTargets() {
return EnumSet.of(this.getSide());
}
@Override
public TileEntity getTileEntity() {
return super.getHost().getTile();
}
@Override
public IStorageMonitorable getMonitorable(final ForgeDirection side, final BaseActionSource src) {
return this.duality.getMonitorable(side, src, this);
}
@Override
public boolean pushPattern(final ICraftingPatternDetails patternDetails, final InventoryCrafting table) {
return this.duality.pushPattern(patternDetails, table);
}
@Override
public boolean isBusy() {
return this.duality.isBusy();
}
@Override
public void provideCrafting(final ICraftingProviderHelper craftingTracker) {
this.duality.provideCrafting(craftingTracker);
}
@Override
public ImmutableSet<ICraftingLink> getRequestedJobs() {
return this.duality.getRequestedJobs();
}
@Override
public IAEItemStack injectCraftedItems(final ICraftingLink link, final IAEItemStack items, final Actionable mode) {
return this.duality.injectCraftedItems(link, items, mode);
}
@Override
public void jobStateChange(final ICraftingLink link) {
this.duality.jobStateChange(link);
}
@Override
public int getPriority() {
return this.duality.getPriority();
}
@Override
public void setPriority(final int newValue) {
this.duality.setPriority(newValue);
}
@Override
public void onTunnelNetworkChange() {
this.duality.updateCraftingList();
updateSharingInventory();
}
@Override
public void onTunnelConfigChange() {
updateSharingInventory();
}
@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();
}
@Override
public ItemStack getSelfRep() {
return this.getItemStack();
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return dualityFluid.fill(from, resource, doFill);
@@ -420,138 +717,9 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
}
}
@Override
public DualityInterface getInterfaceDuality() {
return duality;
}
@Override
public EnumSet<ForgeDirection> getTargets() {
return EnumSet.of(this.getSide());
}
@Override
public TileEntity getTileEntity() {
return super.getHost().getTile();
}
@Override
public void provideCrafting(ICraftingProviderHelper craftingTracker) {
duality.provideCrafting(craftingTracker);
}
@Override
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) {
return duality.pushPattern(patternDetails, table);
}
@Override
public boolean isBusy() {
return duality.isBusy();
}
@Override
public ImmutableSet<ICraftingLink> getRequestedJobs() {
return duality.getRequestedJobs();
}
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
return duality.injectCraftedItems(link, items, mode);
}
@Override
public void jobStateChange(ICraftingLink link) {
duality.jobStateChange(link);
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
duality.readFromNBT(data);
}
@Override
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
duality.writeToNBT(data);
}
@Override
public NBTTagCompound getMemoryCardData() {
final NBTTagCompound output = super.getMemoryCardData();
this.duality.getConfigManager().writeToNBT(output);
return output;
}
@Override
public void pasteMemoryCardData(PartP2PTunnel newTunnel, NBTTagCompound data) throws GridAccessException {
this.duality.getConfigManager().readFromNBT(data);
super.pasteMemoryCardData(newTunnel, data);
}
@Override
public void addToWorld() {
super.addToWorld();
this.duality.initialize();
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched) {
super.getDrops(drops, wrenched);
duality.addDrops(drops);
}
@Override
public boolean shouldDisplay() {
return IInterfaceHost.super.shouldDisplay();
}
@Override
public IInventory getPatterns() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.getPatterns();
}
return IInterfaceHost.super.getPatterns();
}
return IInterfaceHost.super.getPatterns();
}
@Override
public int rows() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.rows();
}
return IInterfaceHost.super.rows();
}
return IInterfaceHost.super.rows();
}
@Override
public int rowSize() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.rowSize();
}
return IInterfaceHost.super.rowSize();
}
return IInterfaceHost.super.rowSize();
}
@Override
public String getName() {
if (isOutput()) {
PartFluidP2PInterface input = getInput();
if (input != null) {
return input.getName();
}
return IInterfaceHost.super.getName();
}
return IInterfaceHost.super.getName();
}
}
@@ -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;
@@ -43,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;
@@ -63,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 {
@@ -86,8 +87,10 @@ 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);
@@ -96,6 +99,27 @@ public class PartFluidStorageBus extends PartUpgradeable
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
@@ -129,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();
}
@@ -148,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
@@ -201,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;
@@ -221,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);
}
@@ -239,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
@@ -272,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
@@ -356,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);
@@ -365,16 +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);
}
@@ -385,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);
}
}
}
@@ -435,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
}
@@ -3,6 +3,7 @@ package com.glodblock.github.common.parts.base;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -10,14 +11,19 @@ import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.item.IItemPatternTerminal;
import appeng.api.networking.IGrid;
import appeng.api.storage.ITerminalPins;
import appeng.api.storage.data.IAEItemStack;
import appeng.items.contents.PinsHandler;
import appeng.items.contents.PinsHolder;
import appeng.tile.inventory.AppEngInternalInventory;
public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatternTerminal {
public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatternTerminal, ITerminalPins {
protected AppEngInternalInventory crafting;
protected AppEngInternalInventory output;
protected final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
private final PinsHolder pinsInv = new PinsHolder(this);
protected boolean craftingMode = true;
protected boolean substitute = false;
@@ -56,6 +62,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
pinsInv.readFromNBT(data, "pins");
}
@Override
@@ -72,6 +79,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
pinsInv.writeToNBT(data, "pins");
}
@Override
@@ -217,4 +225,14 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public PinsHandler getPinsHandler(EntityPlayer player) {
return pinsInv.getHandler(player);
}
@Override
public IGrid getGrid() {
return getGridNode().getGrid();
}
}
@@ -284,7 +284,8 @@ public abstract class FCPart extends AEBasePart
}
@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) {}
@Override
public IInventory getViewCellStorage() {
@@ -365,21 +366,22 @@ public abstract class FCPart extends AEBasePart
rh.setBounds(2, 2, 14, 14, 14, 16);
rh.renderBlock(x, y, z, renderer);
final Tessellator tess = Tessellator.instance;
if (this.getLightLevel() > 0) {
final int l = 13;
Tessellator.instance.setBrightness(l << 20 | l << 4);
tess.setBrightness(l << 20 | l << 4);
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this
.getSpin();
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant);
tess.setColorOpaque_I(this.getColor().whiteVariant);
rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().mediumVariant);
tess.setColorOpaque_I(this.getColor().mediumVariant);
rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant);
tess.setColorOpaque_I(this.getColor().blackVariant);
rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer);
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
@@ -403,15 +405,15 @@ public abstract class FCPart extends AEBasePart
if (hasChan) {
final int l = 14;
Tessellator.instance.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant);
tess.setBrightness(l << 20 | l << 4);
tess.setColorOpaque_I(this.getColor().blackVariant);
} else if (hasPower) {
final int l = 9;
Tessellator.instance.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant);
tess.setBrightness(l << 20 | l << 4);
tess.setColorOpaque_I(this.getColor().whiteVariant);
} else {
Tessellator.instance.setBrightness(0);
Tessellator.instance.setColorOpaque_I(0x000000);
tess.setBrightness(0);
tess.setColorOpaque_I(0x000000);
}
final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon();
@@ -148,7 +148,7 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
if (Platform.isWrench(player, eq, te.xCoord, te.yCoord, te.zCoord)) {
this.isLocked = !this.isLocked;
player.addChatMessage((this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).get());
player.addChatMessage((this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).toChat());
this.getHost().markForUpdate();
} else if (!this.isLocked) {
this.configuredFluid = AEFluidStack.create(Util.FluidUtil.getFluidFromContainer(eq));
@@ -323,8 +323,10 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
}
@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 (this.configuredFluid != null) {
if (fullStack == null) {
this.configuredFluid.setStackSize(0);
@@ -397,21 +399,22 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
rh.setBounds(2, 2, 14, 14, 14, 16);
rh.renderBlock(x, y, z, renderer);
final Tessellator tess = Tessellator.instance;
if (this.getLightLevel() > 0) {
final int l = 13;
Tessellator.instance.setBrightness(l << 20 | l << 4);
tess.setBrightness(l << 20 | l << 4);
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this
.getSpin();
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant);
tess.setColorOpaque_I(this.getColor().whiteVariant);
rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().mediumVariant);
tess.setColorOpaque_I(this.getColor().mediumVariant);
rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant);
tess.setColorOpaque_I(this.getColor().blackVariant);
rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer);
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
@@ -435,15 +438,15 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
if (hasChan) {
final int l = 14;
Tessellator.instance.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant);
tess.setBrightness(l << 20 | l << 4);
tess.setColorOpaque_I(this.getColor().blackVariant);
} else if (hasPower) {
final int l = 9;
Tessellator.instance.setBrightness(l << 20 | l << 4);
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant);
tess.setBrightness(l << 20 | l << 4);
tess.setColorOpaque_I(this.getColor().whiteVariant);
} else {
Tessellator.instance.setBrightness(0);
Tessellator.instance.setColorOpaque_I(0x000000);
tess.setBrightness(0);
tess.setColorOpaque_I(0x000000);
}
final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon();
@@ -56,14 +56,12 @@ public class CreativeFluidCellInventory extends FluidCellInventory {
IInventory inv = this.cellType.getConfigInventory(this.cellItem);
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack is = inv.getStackInSlot(i);
if (Util.FluidUtil.isFluidContainer(is)) {
FluidStack fs = Util.getFluidFromItem(is);
if (fs == null) continue;
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
iaeFluidStack.setStackSize(Integer.MAX_VALUE);
this.cellFluids.add(iaeFluidStack);
}
FluidStack fs = Util.getFluidFromItem(is);
if (fs == null) continue;
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
iaeFluidStack.setStackSize((long) (Math.pow(2, 52) - 1));
this.cellFluids.add(iaeFluidStack);
}
}
}
@@ -51,7 +51,8 @@ public class FluidCellHandler implements ICellHandler {
@Override
public void openChestGui(final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler,
final IMEInventoryHandler inv, final ItemStack is, final StorageChannel chan) {
@SuppressWarnings("rawtypes") final IMEInventoryHandler inv, final ItemStack is,
final StorageChannel chan) {
if (chan == StorageChannel.FLUIDS) {
if (chest instanceof TileEntity te) {
InventoryHandler
@@ -61,7 +62,7 @@ public class FluidCellHandler implements ICellHandler {
}
@Override
public int getStatusForCell(final ItemStack is, final IMEInventory handler) {
public int getStatusForCell(final ItemStack is, @SuppressWarnings("rawtypes") final IMEInventory handler) {
if (handler instanceof final FluidCellInventoryHandler ci) {
return ci.getStatusForCell();
}
@@ -69,7 +70,7 @@ public class FluidCellHandler implements ICellHandler {
}
@Override
public double cellIdleDrain(final ItemStack is, final IMEInventory handler) {
public double cellIdleDrain(final ItemStack is, @SuppressWarnings("rawtypes") final IMEInventory handler) {
final IFluidCellInventory inv = ((IFluidCellInventoryHandler) handler).getCellInv();
return inv.getIdleDrain(is);
}
@@ -1,6 +1,7 @@
package com.glodblock.github.common.storage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
@@ -12,13 +13,18 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
import org.jetbrains.annotations.NotNull;
import com.glodblock.github.common.item.ItemBaseInfinityStorageCell;
import com.glodblock.github.common.item.ItemFluidVoidStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.exceptions.AppEngException;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider;
@@ -45,6 +51,10 @@ public class FluidCellInventory implements IFluidCellInventory {
protected IItemList<IAEFluidStack> cellFluids;
protected final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;
private boolean cardVoidOverflow = false;
private boolean cardDistribution = false;
private byte restrictionTypes = 0;
private long restrictionLong = 0;
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
if (o == null) {
@@ -73,19 +83,37 @@ public class FluidCellInventory implements IFluidCellInventory {
}
}
final IInventory upgrades = this.getUpgradesInventory();
Upgrades u;
for (int x = 0; x < upgrades.getSizeInventory(); x++) {
final ItemStack is = upgrades.getStackInSlot(x);
if (is == null) continue;
if (is.getItem() instanceof IUpgradeModule upgradeItem && (u = upgradeItem.getType(is)) != null) {
switch (u) {
case VOID_OVERFLOW -> cardVoidOverflow = true;
case DISTRIBUTION -> cardDistribution = true;
default -> {}
}
}
}
this.container = container;
this.tagCompound = Platform.openNbtData(o);
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG);
this.restrictionTypes = this.tagCompound.getByte("cellRestrictionTypes");
this.restrictionLong = this.tagCompound.getLong("cellRestrictionAmount");
this.cellFluids = null;
}
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
try {
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
if (o.getItem() instanceof ItemBaseInfinityStorageCell) {
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
} else if (o.getItem() instanceof ProxyFluidStorageCell) {
return new FluidCellInventoryHandler(new ProxyFluidCellInventory(o, container2));
} else if (o.getItem() instanceof ItemFluidVoidStorageCell) {
return new FluidCellInventoryHandler(new FluidVoidStorageCellInventory(o, container2));
} else {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
}
@@ -151,6 +179,11 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public long getTotalFluidTypes() {
if (restrictionTypes > 0) return restrictionTypes;
return this.cellType.getTotalTypes(this.cellItem);
}
public long getMaxFluidTypes() {
return this.cellType.getTotalTypes(this.cellItem);
}
@@ -166,17 +199,50 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public long getRemainingFluidTypes() {
final long basedOnStorage = this.getFreeBytes() / this.getBytesPerType();
final long basedOnStorage = this.getFreeBytes() / Math.max(1, this.getBytesPerType());
final long baseOnTotal = this.getTotalFluidTypes() - this.getStoredFluidTypes();
return Math.min(basedOnStorage, baseOnTotal);
}
@Override
public long getRemainingFluidCount() {
if (restrictionLong > 0) {
return Math.min(
restrictionLong - this.getStoredFluidCount(),
this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount());
}
final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount();
return remaining > 0 ? remaining : 0;
}
@Override
public long getRemainingFluidCountDist(IAEFluidStack l) {
long remaining;
long types = 0;
for (int i = 0; i < this.getTotalFluidTypes(); i++) {
if (this.getConfigInventory().getStackInSlot(i) != null) {
types++;
}
}
if (types == 0) types = this.getTotalFluidTypes();
if (l != null) {
if (restrictionLong > 0) {
remaining = Math.min((restrictionLong / types) - l.getStackSize(), getRemainingFluidCount());
} else {
remaining = (((getTotalBytes() / types) - getBytesPerType()) * singleByteAmount) - l.getStackSize();
}
} else {
if (restrictionLong > 0) {
remaining = Math.min(
restrictionLong / types,
((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount);
} else {
remaining = ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount;
}
}
return remaining > 0 ? remaining : 0;
}
@Override
public int getUnusedFluidCount() {
final int div = (int) (this.getStoredFluidCount() % singleByteAmount);
@@ -188,13 +254,16 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public int getStatusForCell() {
if (this.canHoldNewFluid()) {
if (this.getUsedBytes() == 0) {
return 1;
}
if (this.getRemainingFluidCount() > 0) {
if (this.canHoldNewFluid()) {
return 2;
}
return 3;
if (this.getRemainingFluidCount() > 0) {
return 3;
}
return 4;
}
protected void loadCellFluids() {
@@ -287,9 +356,17 @@ public class FluidCellInventory implements IFluidCellInventory {
final IAEFluidStack l = this.getCellFluids().findPrecise(input);
if (l != null) {
final long remainingFluidSlots = this.getRemainingFluidCount();
long remainingFluidSlots;
if (cardDistribution) {
remainingFluidSlots = this.getRemainingFluidCountDist(l);
} else {
remainingFluidSlots = this.getRemainingFluidCount();
}
if (remainingFluidSlots < 0) {
if (remainingFluidSlots <= 0) {
if (cardVoidOverflow) {
return null;
}
return input;
}
@@ -314,8 +391,15 @@ public class FluidCellInventory implements IFluidCellInventory {
if (this.canHoldNewFluid()) // room for new type, and for at least one item!
{
final long remainingFluidCount = this.getRemainingFluidCount()
- ((long) this.getBytesPerType() * singleByteAmount);
long remainingFluidCount;
if (cardDistribution) {
remainingFluidCount = this.getRemainingFluidCountDist(null);
} else {
remainingFluidCount = Math.min(
getRemainingFluidCount(),
getFreeBytes() * singleByteAmount + getUnusedFluidCount()
- (long) getBytesPerType() * singleByteAmount);
}
if (remainingFluidCount > 0) {
if (input.getStackSize() > remainingFluidCount) {
@@ -380,7 +464,7 @@ public class FluidCellInventory implements IFluidCellInventory {
}
@Override
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out) {
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out, int iteration) {
for (final IAEFluidStack i : this.getCellFluids()) {
out.add(i);
}
@@ -388,12 +472,12 @@ public class FluidCellInventory implements IFluidCellInventory {
}
@Override
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request) {
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request, int iteration) {
return this.getCellFluids().findPrecise(request);
}
@Override
public List<IAEFluidStack> getContents() {
public @NotNull List<IAEFluidStack> getContents() {
List<IAEFluidStack> ret = new ArrayList<>();
for (IAEFluidStack fluid : this.getCellFluids()) {
ret.add(fluid);
@@ -410,4 +494,8 @@ public class FluidCellInventory implements IFluidCellInventory {
public StorageChannel getChannel() {
return StorageChannel.FLUIDS;
}
public List<Object> getRestriction() {
return Arrays.asList(restrictionLong, restrictionTypes);
}
}
@@ -1,10 +1,12 @@
package com.glodblock.github.common.storage;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.util.Util;
import appeng.api.AEApi;
@@ -37,7 +39,15 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
final ItemStack is = config.getStackInSlot(x);
final FluidStack fluid = Util.getFluidFromItem(is);
if (fluid != null) {
priorityList.add(AEFluidStack.create(fluid));
AEFluidStack stack = AEFluidStack.create(fluid);
stack.setStackSize(1);
priorityList.add(stack);
// convert partition on cells in network
if (!(is.getItem() instanceof ItemFluidPacket)) {
config.setInventorySlotContents(x, ItemFluidPacket.newDisplayStack(fluid));
config.markDirty();
}
}
}
if (!priorityList.isEmpty()) {
@@ -67,8 +77,8 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
@Override
public IFluidCellInventory getCellInv() {
Object o = this.getInternal();
if (o instanceof MEPassThrough) {
o = Ae2Reflect.getInternal((MEPassThrough<?>) o);
if (o instanceof MEPassThrough<?>pt) {
o = pt.getInternal();
}
return (IFluidCellInventory) (o instanceof IFluidCellInventory ? o : null);
}
@@ -76,24 +86,30 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
@Override
@SuppressWarnings("unchecked")
public Iterable<IAEFluidStack> getPartitionInv() {
return (Iterable<IAEFluidStack>) Ae2Reflect.getPartitionList(this).getItems();
return getPartitionList().getItems();
}
@Override
public boolean isPreformatted() {
return !Ae2Reflect.getPartitionList(this).isEmpty();
return !getPartitionList().isEmpty();
}
@Override
@Deprecated
public IncludeExclude getIncludeExcludeMode() {
return getWhitelist();
}
@Override
public IncludeExclude getWhitelist() {
return IncludeExclude.WHITELIST;
}
public int getStatusForCell() {
int val = this.getCellInv().getStatusForCell();
if (val == 1 && this.isPreformatted()) {
val = 2;
if ((val == 1 || val == 2) && this.isPreformatted()) {
val = 3;
}
return val;
@@ -102,11 +118,7 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
@Override
public boolean canGetInv() {
IFluidCellInventory cellInv = this.getCellInv();
if (cellInv instanceof CreativeFluidCellInventory) {
return false;
} else {
return true;
}
return !(cellInv instanceof CreativeFluidCellInventory);
}
@Override
@@ -148,4 +160,12 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
public TYPE getCellType() {
return TYPE.FLUID;
}
public List<Object> getRestricted() {
IFluidCellInventory cellInventory = this.getCellInv();
if (cellInventory instanceof FluidCellInventory ci) {
return ci.getRestriction();
}
return null;
}
}
@@ -0,0 +1,118 @@
package com.glodblock.github.common.storage;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import appeng.api.config.Actionable;
import appeng.api.exceptions.AppEngException;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
public class FluidVoidStorageCellInventory extends FluidCellInventory {
public FluidVoidStorageCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
super(o, container);
}
@Override
public boolean canHoldNewFluid() {
return true;
}
@Override
public long getTotalBytes() {
return 0;
}
@Override
public long getFreeBytes() {
return 0;
}
@Override
public long getUsedBytes() {
return 0;
}
@Override
public long getTotalFluidTypes() {
return 63;
}
@Override
public long getStoredFluidCount() {
return 0;
}
@Override
public long getStoredFluidTypes() {
return 0;
}
@Override
public long getRemainingFluidTypes() {
return 63;
}
@Override
public long getRemainingFluidCount() {
return Long.MAX_VALUE;
}
@Override
public int getUnusedFluidCount() {
return Integer.MAX_VALUE;
}
@Override
public int getStatusForCell() {
return 1;
}
@Override
protected void loadCellFluids() {}
@Override
protected IItemList<IAEFluidStack> getCellFluids() {
return null;
}
@Override
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src) {
if (input == null || input.getStackSize() == 0) {
return null;
}
if (this.cellType.isBlackListed(this.cellItem, input)) {
return input;
}
return null;
}
@Override
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
return null;
}
@Override
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out, int iteration) {
return out;
}
@Override
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request, int iteration) {
return null;
}
@Override
public @NotNull List<IAEFluidStack> getContents() {
return Collections.emptyList();
}
}
Loaded 100 of 206 files, more files were not shown because too many files have changed in this diff. Show more