Compare commits

...

322 Commits

Author SHA1 Message Date
PrototypeTrousers 51522019ca fix wireless terminals not opening again 2023-02-06 13:27:52 -03:00
PrototypeTrousers 15dff5d53d fix JEI integration 2023-02-05 23:04:20 -03:00
PrototypeTrousers dcd36b3b2f wip 2023-02-03 23:08:13 -03:00
PrototypeTrousers 7b985c72bd fix slots and texture 2023-02-03 22:33:14 -03:00
PrototypeTrousers 269d3766db implement tall interface terminal (part, not wireless) 2023-02-03 20:56:17 -03:00
PrototypeTrousers d7e7ef0cb4 wip 2023-02-03 15:07:55 -03:00
PrototypeTrousers 472f1e65a2 more autocrafting fixes 2023-02-03 13:49:27 -03:00
PrototypeTrousers 56268aba79 fix autocrafting gui not opening 2023-02-03 12:53:04 -03:00
PrototypeTrousers 9d7dacdc29 Toggle magnet on/off from container/gui 2023-02-02 21:48:01 -03:00
PrototypeTrousers fb2aa21337 cleaning 2023-02-02 20:00:56 -03:00
PrototypeTrousers 8bad14f982 cursed recipes 2023-02-02 19:24:03 -03:00
PrototypeTrousers 0e797b2120 GUI/Container fixes Ugh 2023-02-02 18:22:20 -03:00
PrototypeTrousers 17c38a6418 wip 2023-02-02 16:19:56 -03:00
PrototypeTrousers 58a6dabb20 wip 2023-02-02 14:50:23 -03:00
PrototypeTrousers 329e613c99 recipes 2023-02-02 11:39:16 -03:00
PrototypeTrousers 11a4783881 more textures 2023-02-02 11:23:51 -03:00
PrototypeTrousers e230440cba add some textures 2023-02-01 22:27:01 -03:00
PrototypeTrousers 149e7d251a clean up 2023-02-01 21:43:47 -03:00
PrototypeTrousers 405f14bd13 safer comparisons 2023-02-01 21:19:09 -03:00
PrototypeTrousers acd77ff3f2 lock quantumbridge inventory to 1 card or singularity 2023-02-01 21:10:41 -03:00
PrototypeTrousers a0ec9ceb51 keybinds work 2023-01-31 23:24:27 -03:00
PrototypeTrousers d6f2ed30e5 make them bauble trinkets 2023-01-31 16:52:00 -03:00
PrototypeTrousers 9785e38e3f magnet filtering 2023-01-31 15:29:43 -03:00
PrototypeTrousers 1759bd898e magnetize magnet 2023-01-31 12:40:41 -03:00
PrototypeTrousers ae0d02e7d5 linking kinda works 2023-01-30 23:41:13 -03:00
PrototypeTrousers d76eec2145 wip 2023-01-30 21:56:31 -03:00
PrototypeTrousers d7e1554e41 save upgrades 2023-01-30 20:40:16 -03:00
PrototypeTrousers 9dee7f6c0e cards 2023-01-30 17:45:41 -03:00
PrototypeTrousers 13c3067068 add upgrade slots 2023-01-30 15:41:42 -03:00
PrototypeTrousers 7c4e5679a3 fluid terminal 2023-01-29 21:55:01 -03:00
PrototypeTrousers 03ed421331 more fixes 2023-01-29 21:55:01 -03:00
PrototypeTrousers 36197a5dc6 refresh status if a encoded pattern is put in the output slot 2023-01-29 21:55:01 -03:00
PrototypeTrousers f407a26a8f work on wireless pattern terminal 2023-01-29 21:55:01 -03:00
PrototypeTrousers cb1011295c wip 2023-01-29 21:55:01 -03:00
PrototypeTrousers 55a56ad79d Start implementing wireless terminals. 2023-01-29 21:55:01 -03:00
PrototypeTrousers dd2f1c6dc7 attempt to fix stacking issues 2023-01-28 23:45:14 -03:00
PrototypeTrousers f14407b87a attempted fixes for spatialIO, security and ShaderTech compat 2023-01-28 14:09:23 -03:00
PrototypeTrousers 04f006695e fix terminals not being usable on servers 2023-01-12 12:55:35 -03:00
PrototypeTrousers 4f36ccf64d bump version 2023-01-09 14:25:24 -03:00
PrototypeTrousers d9b4410c94 attempt to fix #197 2023-01-09 02:26:48 -03:00
PrototypeTrousers 9bbd0ad61b ASM Patch ItemStack packet size setter and getter. code from StackUp 2023-01-09 02:15:45 -03:00
MycroftJr 662a7805dd add ItemStack to/from NBT helpers (#202)
to simplify the "stackSize" NBT tag workaround
2023-01-09 01:10:35 -03:00
PrototypeTrousers c46eadec08 Merge branch 'revert-async-repo' into AE2-Omnifactory 2023-01-09 01:08:47 -03:00
PrototypeTrousers 148207f5c3 Merge branch 'gtceu-fix' into PrototypeTrousers/AE2-Omnifactory 2023-01-09 01:08:39 -03:00
PrototypeTrousers 3ae251f098 Revert "Merge remote-tracking branch 'LasmGratel/async-itemrepo' into AE2-Omnifactory"
This reverts commit 86a42e970f.
2023-01-09 01:03:55 -03:00
PrototypeTrousers 82a906886f Revert "delay repo view sorting to once per tick"
This reverts commit d9588441b0.
2023-01-09 01:03:51 -03:00
PrototypeTrousers 5b2c6658c0 Revert "synchronizedList must be in a synchronized block when iterating"
This reverts commit 1f12fc5e91.
2023-01-09 01:03:51 -03:00
PrototypeTrousers 653557bc65 wip. auto-crafting still broken 2023-01-07 18:25:31 -03:00
PrototypeTrousers dde87448a9 initial patch 2023-01-07 12:37:21 -03:00
TheAirBlow 8c29eeecdc Add support for RecipeStages and ItemStages (#198)
* RecipeStages info in README

* Add support for RecipeStages

* Add support for ItemStages
2022-12-26 09:03:49 -03:00
PrototypeTrousers d852d0c216 bump version 2022-12-10 21:26:55 -03:00
Dane Strandboge f9bb00a7e7 fix patterns not respecting item models and colors... (#193)
when shift key is held and the "output" item in the pattern is rendered instead of the base pattern texture

Consequences:
- The "output" item of the pattern will now be rendered always when shift is held, not just when the TransformType is GUI.
    - This means that you will see the "output" item now for in-world patterns, as well as the rendered model in the player's hand or offhand
    - However, I honestly think this is an improvement from before
2022-12-10 21:17:26 -03:00
PrototypeTrousers 9f7e42ca7d fix lang entry 2022-12-07 20:29:46 -03:00
PrototypeTrousers b76c18fedf fix JEI transfer handler breaking in some instances 2022-12-07 20:29:39 -03:00
PrototypeTrousers 98ce8235bb revert change made to fix nee compat but broke it instead 2022-11-22 20:30:20 -03:00
PrototypeTrousers e1ea4ae22f Revert "restore method name to keep compat with NEE"
This reverts commit c5607bda4e.
2022-11-22 20:29:04 -03:00
PrototypeTrousers 20ba83c529 bump version 2022-11-22 19:11:05 -03:00
PrototypeTrousers 225a4d5ab6 fix items voiding under certain circumstances 2022-11-22 19:04:59 -03:00
PrototypeTrousers bd4f03652e bump version 2022-11-20 14:05:29 -03:00
PrototypeTrousers d6650f9617 Merge remote-tracking branch 'TheAirBlow/AE2-Omnifactory' into AE2-Omnifactory 2022-11-20 14:04:46 -03:00
PrototypeTrousers c5607bda4e restore method name to keep compat with NEE 2022-11-20 14:03:36 -03:00
PrototypeTrousers 11af1f2111 actually sort.. with invTweaks AND bogosort... 2022-11-20 14:00:18 -03:00
TheAirBlow 7748f7c92d Fix #189 + replace curseforge with curse.maven 2022-11-20 19:32:36 +05:00
PrototypeTrousers 801fec3eaa another attempt to fix async item view crashes 2022-11-17 18:22:21 -03:00
PrototypeTrousers de324aad91 rename 9 slot fluid interface texture 2022-11-11 20:51:22 -03:00
PrototypeTrousers 16ccb2ee46 Fix blocks connecting to ME cables. Give boost to chisel facades 2022-11-08 23:05:41 -03:00
PrototypeTrousers bd0d2a1f28 0.54.11 2022-11-08 18:01:39 -03:00
PrototypeTrousers 9abd53a8e8 fix encoded patterns not showing the encoded item in AE GUIs 2022-11-08 18:01:00 -03:00
PrototypeTrousers 1f12fc5e91 synchronizedList must be in a synchronized block when iterating 2022-11-08 18:00:30 -03:00
Yang Xizhi 87fcc6c267 update nbt when accepting result (#180) 2022-11-08 17:46:17 -03:00
PrototypeTrousers e301459dfa bump version 2022-10-29 10:32:16 -03:00
Yang Xizhi bf802f1c6f fix ae fluid inventory fluid exceeding (#174)
* ae fluid inventory fix
2022-10-29 10:31:54 -03:00
Xikaro 7ba4ca6923 External improvements (#166)
* lang

* Update controller_column_lights.png.mcmeta

* energy cell

cells display internal energy storage along the bar

* 3D drive

* drive fix model

* 3D chest

* Update ru_ru.lang

* Update ru_ru.lang

* model fix drive and chest
2022-10-27 20:15:16 -03:00
PrototypeTrousers 53ed861e23 isolate the oversized slots and itemhandlers 2022-10-27 20:13:44 -03:00
PrototypeTrousers 833f8aca2a More damaged item search work. GT tools are so special 2022-10-26 13:29:35 -03:00
PrototypeTrousers 9bcf45b7e2 add a healthy 1 sec delay between JEI transfer updates to avoid horrible
GC pressure
2022-10-25 22:32:53 -03:00
PrototypeTrousers b2847677ed forgot to check the items already in the 3x3 grid 2022-10-24 17:29:25 -03:00
PrototypeTrousers 95845d5a6c 54.4 2022-10-24 17:08:44 -03:00
PrototypeTrousers 286a3631be Merge branch 'mytsag-crystal-fix' into AE2-Omnifactory 2022-10-24 17:08:25 -03:00
PrototypeTrousers 6506301049 fix fluid interfaces / configuration terminal not showing all the slots 2022-10-24 17:05:27 -03:00
PrototypeTrousers 422543f205 check player inv for items that can be used to craft 2022-10-24 16:38:25 -03:00
PrototypeTrousers 1eec160b74 look for damageable items of the same type if substitutions are disabled 2022-10-24 16:09:22 -03:00
PrototypeTrousers de23b62493 some JEI work. missing player inventory check 2022-10-22 00:06:18 -03:00
Yang Xizhi 2b6299f2b0 fix expended pattern terminal can't place item manually (#161) 2022-10-20 16:35:20 -03:00
Yang Xizhi b495c972c4 add dev jar artifacts (#160) 2022-10-20 16:35:11 -03:00
PrototypeTrousers 7722dcc720 bump version. remove dead maven repo 2022-10-19 18:16:44 -03:00
PrototypeTrousers c4d5add5f1 allow part interfaces to be copied 2022-10-19 18:05:04 -03:00
PrototypeTrousers 348e6436b8 fix processing patterns encoding as invalid 2022-10-19 18:00:01 -03:00
PrototypeTrousers 92457ac680 bump version 2022-10-18 23:59:25 -03:00
PrototypeTrousers 9e53737635 Merge branch 'jei-transfer-highlight' into AE2-Omnifactory 2022-10-18 23:58:58 -03:00
PrototypeTrousers 0e0729166f Fix WCT invisible stacksizes, OOB when opening pattern terminal
FIx security station card slot being reaaally off
2022-10-18 23:56:40 -03:00
PrototypeTrousers 15a1e8f150 attempt to fix fluid interfaces capacity desync 2022-10-18 20:51:52 -03:00
PrototypeTrousers b443f1ce57 refactor pattern encoding terminals 2022-10-18 20:48:20 -03:00
PrototypeTrousers 486a68d06b update items while JEI GUI is active 2022-10-18 07:49:25 -03:00
PrototypeTrousers 9b263c5501 add tooltip callback. Paint craftables in blue. middle click to craft
from JEI
2022-10-18 05:20:55 -03:00
PrototypeTrousers daf4910548 start work. 2022-10-17 23:56:59 -03:00
PrototypeTrousers 4f5bdfefe8 bump version 2022-10-17 22:34:37 -03:00
PrototypeTrousers c9f1387098 small fixes to tool tips. allow +1 button to go over maxstacksize 2022-10-17 22:33:42 -03:00
PrototypeTrousers 1f1d6d041a Merge remote-tracking branch 'PrototypeTrousers/AE2-Omnifactory' into AE2-Omnifactory 2022-10-17 21:19:44 -03:00
PrototypeTrousers 403a6e8b4a update gradle deps
Use GTCEu instead of GTCE.
move hwyla dep to cursemaven due to security certificate expiration
2022-10-17 21:19:30 -03:00
PrototypeTrousers 0a0c23c190 fix NPE with the network tool 2022-10-17 21:17:21 -03:00
PrototypeTrousers d28cd798e9 rework gui highlighting for terminals 2022-10-13 15:19:25 -03:00
PrototypeTrousers 3dedb7eefb show network tool inventory on fluid interfaces 2022-10-12 21:25:44 -03:00
PrototypeTrousers ae3295d3c9 allow memory card to copy encoded patterns of interfaces 2022-10-12 20:42:42 -03:00
PrototypeTrousers 4bac5f43db allow interface itemstack handler to accept over sized stacks 2022-10-12 19:10:07 -03:00
PrototypeTrousers 2e9a5dc8ea wip interfaces stacksizes 2022-10-12 04:48:02 -03:00
PrototypeTrousers 9ac4ea4e6e custom serialization of oversized itemstacks.
simple limiting by checking overflow
2022-10-12 04:10:23 -03:00
PrototypeTrousers 601faf5087 encoded pattern render fixes 2022-10-12 04:08:39 -03:00
PrototypeTrousers 88e3df897e limit fluid texture scaling 2022-10-12 03:04:30 -03:00
PrototypeTrousers f57a8cefda replaced the stacksize render with the readable formated 2022-10-12 02:38:07 -03:00
PrototypeTrousers d3fdac2b81 Merge branch 'fluidInterfaceUpgrade' into AE2-Omnifactory 2022-10-12 01:22:30 -03:00
PrototypeTrousers f7be92adcf Upgrade fluid interfaces
9 tanks, with up to 64B/fluid with 2 capacity cards
2022-10-12 01:18:38 -03:00
PrototypeTrousers 53f18f8e80 Merge branch 'fluidConfigTerminal' into AE2-Omnifactory 2022-10-11 22:36:31 -03:00
PrototypeTrousers 770db27777 add recipes 2022-10-11 22:30:54 -03:00
PrototypeTrousers de674f72bd fix fluid search by name 2022-10-11 21:38:18 -03:00
PrototypeTrousers 19747ba1f1 lang, models, textures 2022-10-10 22:25:28 -03:00
PrototypeTrousers 024b5c6503 fix fluid slots offsets 2022-10-10 20:02:22 -03:00
PrototypeTrousers 63dd035c85 works 2022-10-10 19:48:24 -03:00
PrototypeTrousers e611b1fb76 make Enter also set the string on the storage bus gui 2022-10-10 04:14:16 -03:00
PrototypeTrousers 4c8ad87875 fix lang typo ( 4k cell having 16k as name ) 2022-10-05 13:12:29 -03:00
PrototypeTrousers 194d1171f9 bump version 2022-09-30 20:08:39 -03:00
PrototypeTrousers 376bbf7e84 additional security checks to P2P parts 2022-09-30 20:08:08 -03:00
PrototypeTrousers ddfac3a339 return early instead of cancelling 2022-09-30 19:55:35 -03:00
PrototypeTrousers 95d8216992 Fix craft-only export busses also exporting stocked items 2022-09-25 14:37:00 -03:00
PrototypeTrousers 4e2afb297e push security station slots further down to match the GUI 2022-09-25 14:35:52 -03:00
PrototypeTrousers d9588441b0 delay repo view sorting to once per tick 2022-09-25 14:35:13 -03:00
PrototypeTrousers 86a42e970f Merge remote-tracking branch 'LasmGratel/async-itemrepo' into AE2-Omnifactory 2022-09-25 13:52:30 -03:00
Xikaro bdb0ac14c5 Add color lang (#150), Fixes WAILA wrong lang keys 2022-09-25 13:46:33 -03:00
Lasm Gratel 8c735305d7 Speed up ME Terminal search performance by using CompletableFuture 2022-09-20 18:21:57 +08:00
YoungOnion 9011273229 reformatted all src files (#141) 2022-09-17 08:08:02 -03:00
PrototypeTrousers 3328bfcda2 flip a condition 2022-09-15 12:43:25 -03:00
PrototypeTrousers 158d7c6a04 fix GTEU p2p injecting power on the side of the P2P input 2022-09-14 18:50:07 -03:00
brachy84 0085262779 sort terminal by bogosorter sort rules (#138) 2022-09-10 08:37:59 -03:00
PrototypeTrousers 1ed654843c Fix patterns needing to be encoded twice 2022-09-10 08:35:40 -03:00
PrototypeTrousers 6277058167 p2p fixes 2022-09-09 12:49:47 -03:00
PrototypeTrousers 6e6f8d33cd 0.52.5 2022-09-05 15:35:24 -03:00
PrototypeTrousers efb9ab512a minor cleanup 2022-09-05 15:30:28 -03:00
James a9c891f69a added renaming feature with quartz cutting knife 2022-09-05 15:06:46 -03:00
yanxiatao 2ea120e614 add InterfaceConfigurationTerminal Chinese traslate (#133) 2022-08-29 19:46:57 -03:00
PrototypeTrousers 29c18bbf33 fix a dupe bug 2022-08-29 19:46:29 -03:00
PrototypeTrousers 027e8477c2 push down some buttons so the JEI doesnt get cutoff vertically.
ME autocrafting now uses the cached storage list instead of a full simulated network extraction
2022-08-26 17:28:00 -03:00
PrototypeTrousers f8bac0475a more tinkering with JEI exclusion areas 2022-08-25 02:57:39 -03:00
Yang Xizhi 55c527e557 fix scroll bar being rendered wrongly (#130)
* fix scroll bar being rendered wrongly

* tooltip overlap

* fix the first cpu select grid render
2022-08-22 18:43:00 -03:00
PrototypeTrousers 7714f5196e bump version 2022-08-19 11:33:28 -03:00
PrototypeTrousers 430ee8430d apply JEI extra areas to missing GUIs 2022-08-19 11:32:41 -03:00
PrototypeTrousers 2e98ec015c Merge branch 'better-crafting-status' into AE2-Omnifactory 2022-08-19 11:32:13 -03:00
PrototypeTrousers b6955d42b6 Fixes "Device missing channel" when channels are disabled and a ME
controller is present on the network
2022-08-19 11:31:56 -03:00
alongstringofnumbers e696b31013 Remove some commented out code 2022-08-17 16:02:59 -07:00
alongstringofnumbers b84c25e64c Implement Crafting CPU selector widget 2022-08-17 15:54:03 -07:00
PrototypeTrousers 327b26559f bump version 2022-08-15 01:15:03 -03:00
YoungOnion f434688f3a Allow max size of controller to be configurable (#126)
* modifiable max length of a controller in all 3 axis

* added a 1-255 range on the sizes

* fixed values to [1, 63]
2022-08-15 01:13:33 -03:00
PrototypeTrousers 7996c44075 Make ME Controller still usable even without channels on. gives energy
discount. 
Hide channel count from Waila and TOP, if channels are disabled
2022-08-15 01:12:23 -03:00
PrototypeTrousers f5e9df07d4 version 0.53.0 2022-08-12 23:03:50 -03:00
PrototypeTrousers 159a9370c9 Attempt to fix #127 2022-08-12 23:03:02 -03:00
PrototypeTrousers ad5dcf5c97 Merge branch 'cit' into AE2-Omnifactory 2022-08-12 23:01:54 -03:00
PrototypeTrousers 104d6fc34d Implement Interface Configuration Terminal 2022-08-12 23:01:35 -03:00
PrototypeTrousers 40caeec92f JEI Ghost items work, missing some click interactions and GUI work 2022-08-11 04:05:45 -03:00
PrototypeTrousers 119cdbc2c0 missing JEI ghost support 2022-08-11 03:19:13 -03:00
PrototypeTrousers a44c74b0d7 wip 2022-08-09 03:41:31 -03:00
PrototypeTrousers a55dbb061c fix autocrafting logic bug with container items and processing patterns
fix message reporting missing items having their values swapped
2022-08-08 19:06:50 -03:00
PrototypeTrousers 9fdf0345b3 Fix #123 2022-07-20 22:25:19 -03:00
PrototypeTrousers 346f5aeaac fix GTEU energy tax evasion
fix StackOverflow crash
2022-07-20 17:09:56 -03:00
PrototypeTrousers d4b5d0dc26 allow automation insertion "gemCertusQuartz" oredictd items into charger
Fixes #120
2022-07-13 20:11:42 -03:00
PrototypeTrousers d77838146d fix patterns "not extracting" due to acidental dragging
bump version
2022-05-30 23:28:17 -03:00
PrototypeTrousers 5b1f98b2d8 fix expanded processing pattern terminal not refreshing when placing
patterns on the encoding output slot
2022-05-30 22:28:50 -03:00
PrototypeTrousers 1c197c0f20 Fix incorrect with behavior with interfaces and storage busses
while using interfaces with crafting cards
2022-05-15 08:18:59 -03:00
PrototypeTrousers 46a1faaca2 Merge pull request #105 from Xikaro/AE2-Omnifactory
Update ru_ru.lang
2022-05-15 08:17:16 -03:00
PrototypeTrousers dd28b610e1 bump version
last minute fix
2022-05-13 15:04:34 -03:00
Xikaro aa2bb45199 Update ru_ru.lang 2022-05-13 08:18:33 +05:00
PrototypeTrousers 48146af137 Blocking mode for sub-networks 2022-05-12 19:55:38 -03:00
PrototypeTrousers 582d7f140c bump version 2022-05-09 14:18:10 -03:00
PrototypeTrousers ffdc052d99 fix last facade on off hand deleting the item on the main hand when used
fixes #101
2022-05-09 14:15:10 -03:00
PrototypeTrousers de7d6321f0 Merge pull request #102 from TechLord22/dust_texture_fix
Fix Misaligned Dust Textures
2022-05-09 14:14:49 -03:00
tech22 235eef23e3 fix misaligned dust textures 2022-05-08 14:51:16 -04:00
PrototypeTrousers c7fcdf7d8b small tweaks to the crafting amount gui
number starts selected if want to override the default of 1.
keypad enter also works to start craft
2022-04-28 22:57:22 -03:00
PrototypeTrousers 3a6ab149e4 Merge pull request #100 from GTModpackTeam/fix-japan-lang
fix ja_JP.lang
2022-04-28 22:43:30 -03:00
tier940 9337eceb82 [fix] lang record & SearchMode 2022-04-28 20:53:27 +09:00
PrototypeTrousers 35f91bf0d0 reduce packets sent while dragging items around in GUIs 2022-04-25 12:10:41 -03:00
PrototypeTrousers 6d14d082b0 hold items inplace 2022-04-25 12:09:29 -03:00
PrototypeTrousers 98ad919f1b items oredicted "crystalCertusQuartz" can go into the charger
and change to ae2 charged certus quartz
2022-04-15 15:42:35 -03:00
PrototypeTrousers fb4af262b7 Merge pull request #88 from Mr-Ao-Dragon/AE2-Omnifactory
Update zh-cn lang file.
2022-04-15 14:27:10 -03:00
PrototypeTrousers 5f774749e8 Merge pull request #94 from GTModpackTeam/add-japanese-lang
Japanese translation files
2022-04-15 14:26:58 -03:00
PrototypeTrousers 81b3ff6976 fix autocrafting with substitute crafting option enabled 2022-04-13 15:38:47 -03:00
PrototypeTrousers c8698fc2bf enable controller and smart cables registration, even with channels off 2022-04-12 17:39:20 -03:00
PrototypeTrousers be9fb6d04c try to hold hold items in place while extracting holding down shift 2022-04-11 23:51:03 -03:00
PrototypeTrousers 90ca2c7e92 Fix condenser not creating new items after item extraction without
inserting new items
reworked pattern terminal and crafting terminal search expression matching
2022-04-11 15:15:29 -03:00
PrototypeTrousers 39ac308889 wip 2022-04-11 05:13:16 -03:00
PrototypeTrousers 4d268b97a9 cache itemstack on export bus 2022-04-11 03:50:33 -03:00
PrototypeTrousers 4b6fbf68b6 Added config for auto crafting of substitutions
Change missing items information to a packet (missing localization stuff yet)
2022-04-11 02:00:31 -03:00
PrototypeTrousers a289dec832 fix crash with GTCEu 2.2 and higher 2022-04-06 14:34:37 -03:00
PrototypeTrousers a4f50ea9ef actually fixes 2022-04-04 08:25:11 -03:00
PrototypeTrousers 0e8f7c9d03 added packets for missing items report 2022-04-04 03:57:04 -03:00
PrototypeTrousers 7c0935f447 fix (?) weird substitution items on crafting tree 2022-04-04 03:20:21 -03:00
PrototypeTrousers 1e9e8d2639 more checks if "gregtech" mod is loaded 2022-03-31 21:16:14 -03:00
tier940 3455e815b8 [fix] Rename crafting_accelerator 2022-03-29 16:50:38 +09:00
tier940 a08e61b818 [fix] lang table 2022-03-29 16:39:47 +09:00
PrototypeTrousers 19c6e2ff2d support for IC2 damageable items 2022-03-27 08:52:37 -03:00
PrototypeTrousers 4f25c1551b increase internal buffer of ME Chest
Fix item amount not refreshing when inserted/extracted
2022-03-27 08:10:02 -03:00
PrototypeTrousers 3b94e9420d fix NPE with ae2fc and blocking mode 2022-03-25 23:46:52 -03:00
PrototypeTrousers f30f334a23 move nonblocking call out of method used by ae2fc coremod 2022-03-24 23:25:28 -03:00
tier940 ed702a5c73 [fix] タイポ 2022-03-18 22:20:43 +09:00
tier940 1364117374 [update] change to latest 2022-03-18 21:52:43 +09:00
tier940 ed4b864ba2 [add] Japanese lang file 2022-03-17 18:24:48 +09:00
PrototypeTrousers 706e577dab Fix container item crafting (again)
avoid making some copies
fix crash without JEI
2022-03-16 00:52:38 -03:00
PrototypeTrousers ccc8486571 check if gregtech is loaded before checking for MetaTools 2022-03-12 22:36:22 -03:00
PrototypeTrousers 3e8440644e fix autocrafting with container items 2022-03-12 22:21:04 -03:00
PrototypeTrousers 50f4e08b64 Merge remote-tracking branch 'origin/AE2-Omnifactory' into AE2-Omnifactory 2022-03-12 17:27:17 -03:00
PrototypeTrousers cfa9fa2843 invalidate cached itemstack if its gonna be used in a real insertion 2022-03-12 17:14:37 -03:00
PrototypeTrousers 47f819e021 invalidate cached itemstack if its gonna be used in a real insertion 2022-03-12 11:03:04 -03:00
MrAoDragon e67b196e19 update zh-cn lang file 2022-03-12 17:34:14 +08:00
PrototypeTrousers 6d151bb890 GTCEu blocking mode fix 2022-03-11 23:11:52 -03:00
PrototypeTrousers 3305270a71 clean-up 2022-03-11 22:04:58 -03:00
PrototypeTrousers f824bfd2e1 small optimization 2022-03-10 21:35:18 -03:00
PrototypeTrousers 036f4e1c5b heavily tweaked auto-crafting 2022-03-09 23:14:02 -03:00
PrototypeTrousers 146d3f5628 fix fluid dupe 2022-03-06 08:24:29 -03:00
PrototypeTrousers 9c821cb015 cleaning 2022-03-05 23:29:20 -03:00
PrototypeTrousers 3a83c99b1f fix container items return properly 2022-03-05 11:15:32 -03:00
PrototypeTrousers 447c6debab account for interfaces priority affecting which items are extractable 2022-03-04 22:49:55 -03:00
PrototypeTrousers 50470ae3cf version 2022-03-04 21:44:58 -03:00
PrototypeTrousers 993be652c9 delay container item return when simulating crafting tree 2022-03-04 21:30:26 -03:00
PrototypeTrousers b3bfbd0b58 remove debugging log 2022-03-04 17:08:23 -03:00
PrototypeTrousers 49b3dc8b60 undo partially pattern cache rebuild optimization
enabled pattern substitution now can use substitute patterned items
2022-03-03 22:25:10 -03:00
PrototypeTrousers 71ffcfb839 JEI transfer handler OutOfBounds fix 2022-03-01 13:02:09 -03:00
PrototypeTrousers 73f76a6654 clean up 2022-02-28 23:30:52 -03:00
PrototypeTrousers 645de1d868 Merge branch 'craftingtree-tweaks' into AE2-Omnifactory 2022-02-28 23:17:21 -03:00
PrototypeTrousers 8f40478695 version 2022-02-28 23:16:53 -03:00
PrototypeTrousers 056fcc3818 switch to extractable instead of cached item list 2022-02-28 23:16:53 -03:00
PrototypeTrousers 0ed0eb9d5f better logging 2022-02-28 23:16:49 -03:00
PrototypeTrousers 3ddc846648 Merge branch 'craftingtree-tweaks' into AE2-Omnifactory 2022-02-28 23:06:11 -03:00
PrototypeTrousers f98f6ef852 misc cleaning 2022-02-28 22:57:35 -03:00
PrototypeTrousers 4192d721a0 only fire simulation if a player requested it 2022-02-28 21:25:33 -03:00
PrototypeTrousers a0f3ef9d86 cut crafting tree earlier if ingredients are available 2022-02-28 21:25:13 -03:00
PrototypeTrousers 6b29288de6 remove crafting penalties 2022-02-28 00:13:07 -03:00
PrototypeTrousers 285fc6314c small optimization to crafting tree 2022-02-27 23:04:29 -03:00
PrototypeTrousers 50fd83e96b adjust default blocking mode settings 2022-02-25 00:09:33 -03:00
PrototypeTrousers cc51138a6a blocking mode changes again
misc cleaning
2022-02-24 23:54:50 -03:00
PrototypeTrousers 918df0bf7f clean up 2022-02-22 23:55:52 -03:00
PrototypeTrousers c852199901 bump version 2022-02-22 22:55:44 -03:00
PrototypeTrousers fd95d3de47 fixed typo gtceu -> gteu 2022-02-22 22:37:28 -03:00
PrototypeTrousers c3dd6dabe1 fix blocking mode again... 2022-02-22 22:11:57 -03:00
PrototypeTrousers b0e81ac2d1 fix blocking mode somehow voiding items 2022-02-22 19:40:15 -03:00
PrototypeTrousers 30f4cdf545 attempt at pattern rebuild optimization 2022-02-22 00:02:17 -03:00
PrototypeTrousers ee9441474e tweak cache reset on interface config 2022-02-21 18:25:58 -03:00
PrototypeTrousers 8846202270 More itemstacks caching
Micro optimization on molecular assemblers
2022-02-21 15:11:16 -03:00
PrototypeTrousers 17a900ae9a actually return if a crafting job is running 2022-02-19 23:03:33 -03:00
PrototypeTrousers 66bc243b41 cache more itemstacks 2022-02-19 23:02:40 -03:00
PrototypeTrousers a2bda8f449 tile fluid textures on fluid interfaces properly 2022-02-17 20:15:29 -03:00
PrototypeTrousers a2c2a4df0f oops, add integrated circuit to default non blocking items 2022-02-15 19:33:56 -03:00
PrototypeTrousers b4e237244a fix interfaces with crafting cards attached to storage bus not working
add missing buttons to oredict storagebus
2022-02-14 17:15:51 -03:00
PrototypeTrousers b541ad8d18 misc cleaning
add lenses to non blocking list
2022-02-10 20:15:58 -03:00
PrototypeTrousers 64f29a7dba make it work 2022-02-10 17:59:03 -03:00
PrototypeTrousers 6d25b7ef3c reworked blocking mode. now items are configurable per mod 2022-02-09 22:15:44 -03:00
PrototypeTrousers c3a608ef59 fix export busses exporting items out of nowhere 2022-01-31 16:51:06 -03:00
PrototypeTrousers af1f5c34d2 fix npe when placing down an ore dict storage bus 2022-01-30 17:19:01 -03:00
PrototypeTrousers f5378e060e fix importing from storage drawers 2022-01-29 17:21:12 -03:00
PrototypeTrousers 47407acc42 backport of #5823 - try emptying interfaces first before handling crafting jobs 2022-01-29 17:03:15 -03:00
PrototypeTrousers d7f3428824 fix for infinite loop while loading 2022-01-24 13:19:31 -03:00
PrototypeTrousers 63e339b88b cache itemstacks more aggressively 2022-01-24 13:17:50 -03:00
PrototypeTrousers 98761809fd add the patterns inside the terminal to the drop list of the terminal 2022-01-23 23:08:47 -03:00
PrototypeTrousers 8cb013b686 versioning 2022-01-22 23:19:49 -03:00
PrototypeTrousers f2fe376982 Merge pull request #74 from Syrcan/GTEU-fix
GTEU input fix
2022-01-22 23:06:39 -03:00
Syrcan 603452de1f GTEU input fix 2022-01-22 10:11:23 +01:00
PrototypeTrousers 40bd96d21c tweak crafting job size again
null check
2022-01-21 18:12:18 -03:00
PrototypeTrousers a14d160a07 Reworked oredict storage bus
have a recipe now
expression matcher and validator from GTCEU by brachy84
2022-01-20 22:43:18 -03:00
PrototypeTrousers df28a5520f fix mod name
implement GTCEU Energy adapter
2022-01-20 20:02:26 -03:00
PrototypeTrousers 0d096944cc Merge branch 'gtceu-p2p' into AE2-Omnifactory 2022-01-20 17:48:07 -03:00
PrototypeTrousers 963d3414d8 update version
more of renaming mod
2022-01-20 17:46:07 -03:00
PrototypeTrousers 4414451f5e more gtceu p2p fixes 2022-01-20 17:05:21 -03:00
PrototypeTrousers e0ddb92b81 attune gtce p2p with cables 2022-01-20 13:28:08 -03:00
PrototypeTrousers 6f551ad67f wip gtceu p2p 2022-01-20 00:04:04 -03:00
PrototypeTrousers fd3349614d fix terminal crashing and not cleaning leftovers of larger recipe patterns 2022-01-11 11:23:40 -03:00
PrototypeTrousers 903f211044 fix crash while configuring fluid storage bus 2022-01-10 03:17:46 -03:00
PrototypeTrousers 78e1e26a11 Fix issues with the expanded pattern terminal and its patterns crafting 2022-01-05 21:36:49 -03:00
PrototypeTrousers 2a6de11597 update version 2022-01-04 17:08:55 -03:00
PrototypeTrousers cd2b53af85 Cherry-picked 5554ba903e74c2980b2e395c78555b40fc379e80
Be more lenient with extended block states being passed by other mods.
2022-01-04 17:01:55 -03:00
PrototypeTrousers 1c5565491a finish oredict storage bus 2022-01-03 13:16:27 -03:00
PrototypeTrousers 311cc5c6f6 more oredictbus work 2022-01-03 11:32:48 -03:00
PrototypeTrousers 41796449ed cache oredict filter list 2022-01-03 10:47:35 -03:00
PrototypeTrousers 9eef9d3840 partial implementation of oredict storage bus
missing proper GUI, text, item models, memorycard support.
logic works
2022-01-03 02:33:08 -03:00
PrototypeTrousers 13afa6908a implement expanded processing pattern terminal 2022-01-02 18:27:41 -03:00
PrototypeTrousers 103438f805 do full reset level emitter on stack update 2021-12-13 02:02:02 -03:00
PrototypeTrousers eaa01f7648 flip some boolean so craftables actually show up 2021-12-10 20:26:29 -03:00
PrototypeTrousers e81fb09599 when in off-hand, memory card wild paste as input 2021-12-10 14:02:56 -03:00
PrototypeTrousers 94d73aec7c wwww 2021-12-09 23:34:57 -03:00
PrototypeTrousers b51af43dba item/fluid count changes.. again 2021-12-07 21:10:04 -03:00
PrototypeTrousers 85dc8ae7c1 item costs/ghost fixes 2021-11-29 00:50:32 -03:00
PrototypeTrousers c34176f392 fix (?) item desync issues 2021-11-23 20:25:05 -03:00
PrototypeTrousers 76fe2175a0 moved p2p forge event to an upper class
add an extra update after the network has finished booting
2021-11-15 00:09:04 -03:00
PrototypeTrousers c5d33ed892 p2p fixes redton, light, items 2021-11-11 20:54:40 -03:00
PrototypeTrousers b423d99879 tweak crafting byte costs 2021-11-02 17:56:12 -03:00
PrototypeTrousers 81156b411d version 2021-11-02 15:34:45 -03:00
PrototypeTrousers 6be1660d41 Merge branch 'item-issues' into AE2-Omnifactory 2021-11-02 15:34:02 -03:00
PrototypeTrousers 304f394497 cut crafting tree earlier if the item is available
fix job byte size to 8 per crafting + 1 per item used/stored
2021-11-02 15:33:14 -03:00
PrototypeTrousers 50f21125c8 log if non-patterned items go missing before starting a craft 2021-11-02 02:00:01 -03:00
PrototypeTrousers 30b85bd239 potential fix for showing proper item names when failing to start craft 2021-11-01 23:23:45 -03:00
PrototypeTrousers 9ce00d338f only try to extract if its already in the cache 2021-10-29 17:04:24 -03:00
PrototypeTrousers 11f5b71089 update directly instead of relying on forge events 2021-10-29 15:14:33 -03:00
PrototypeTrousers e7da72163b backported #5349 2021-10-29 15:13:46 -03:00
PrototypeTrousers 6d7c65dd70 potential fix for an infinite loop while adding nodes 2021-10-29 14:09:19 -03:00
PrototypeTrousers 5e21101619 n-to-n p2p
network monitor checks nesting by action source
2021-10-28 23:49:16 -03:00
PrototypeTrousers 3db8d0185f fix security terminal and portable cell stored items not showing 2021-10-23 17:56:15 -03:00
PrototypeTrousers 2f5ecfe638 energy fixes 2021-10-22 15:37:08 -03:00
PrototypeTrousers 75843e802d WIP 2021-10-21 12:22:00 -03:00
PrototypeTrousers e41b6943aa fix swapping cells giving wrong item/fluid count 2021-09-28 23:29:52 -03:00
PrototypeTrousers 92347ad2f5 fix looping item count and hopefully energy issues 2021-09-26 22:07:16 -03:00
PrototypeTrousers 517bd77df7 yet another try at energy issues
fix requesters not being added to the energy grid


partially revert the energy 'fixes'


potential desync on item count


energy and items change
2021-09-17 00:09:49 -03:00
PrototypeTrousers 19f928a9a5 fluid pass 2021-09-13 04:22:52 -03:00
PrototypeTrousers 73251a0fe5 more item count changes.... 2021-09-13 02:10:28 -03:00
PrototypeTrousers 9335daff7d Revert "fixes item showing incorrect amounts"
This reverts commit 618e9390c6.
2021-09-11 22:48:45 -03:00
PrototypeTrousers cc5377d53b fluid storage bus handler cache tweaks and simplify energy cache 2021-09-06 23:51:32 -03:00
Salomão 059f20d801 yet another try at fixing power issues 2021-09-05 20:28:37 -03:00
Salomão d229570495 try to fix energy issues again
fix issue with voiding p2p parts when shift-right clicking with a memory card
2021-09-04 18:59:46 -03:00
PrototypeTrousers c284748b6c fix p2p not updating properly on memory card loading 2021-09-02 20:42:02 -03:00
PrototypeTrousers 880a9c8821 another case of wrong item count caused by weak reset logic overriding
a full reset needed
2021-09-01 16:11:45 -03:00
PrototypeTrousers c68c02ef3b more cases of wrong item counting fixed 2021-08-26 22:03:23 -03:00
PrototypeTrousers 89c4d2736c borrowed some fancy, colored, fluid rendering from gregicality
thank you @Yefancy
2021-08-23 22:35:26 -03:00
PrototypeTrousers 01778794e5 try to fix #51 2021-08-22 23:59:02 -03:00
PrototypeTrousers 8f2a06e457 fix #49. you can now actually clear storage and conversion monitors 2021-08-20 23:26:33 -03:00
PrototypeTrousers 2d71b75019 actually fix it 2021-08-17 07:46:47 -03:00
PrototypeTrousers 9f09cd04d4 enforce cache reset of storage bus attached to interfaces were configs
changed
2021-08-16 21:55:35 -03:00
PrototypeTrousers b041fae0d5 fix storage/monitors wrong item count and interactions 2021-08-16 19:26:25 -03:00
Salomão c466a0e00e fix items in level emitters with crafting cards not showing up 2021-08-14 09:44:47 -03:00
1213 changed files with 97615 additions and 107876 deletions
+9 -6
View File
@@ -1,17 +1,21 @@
This is a fork of AE2 i made for trying to solve issues for the [Omnifactory](https://www.curseforge.com/minecraft/modpacks/omnifactory) modpack. This is a fork of AE2 i made for trying to solve issues for the [Omnifactory](https://www.curseforge.com/minecraft/modpacks/omnifactory) modpack.
See https://github.com/PrototypeTrousers/Applied-Energistics-2/tree/AE2-Omnifactory branch for commits See [AE2-Omnifactory](https://github.com/PrototypeTrousers/Applied-Energistics-2/tree/AE2-Omnifactory) branch for commits and [Releases](https://github.com/PrototypeTrousers/Applied-Energistics-2/releases) for the compiled jars.
and
https://github.com/PrototypeTrousers/Applied-Energistics-2/releases for the compiled jars.
# Applied Energistics 2 (PrototypeTrousers fork for Omnifactory) # Applied Energistics 2 (PrototypeTrousers fork for Omnifactory)
## About ## About
A Mod about Matter, Energy and using them to conquer the world.
A Mod about Matter, Energy and using them to conquer the world.. ## RecipeStages
You need to add the following into a CraftTweaker script:
```
mods.recipestages.Recipes.setPackageStage("appeng", allStages);
```
The second argument allows you to customize which stages exactly you want to be craftable with AE2. Idk why would you like to restrict any, but you can.
## License ## License
* Applied Energistics 2 API * Applied Energistics 2 API
- (c) 2013 - 2018 AlgorithmX2 et al - (c) 2013 - 2018 AlgorithmX2 et al
- [![License](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](http://opensource.org/licenses/MIT) - [![License](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](http://opensource.org/licenses/MIT)
@@ -25,7 +29,6 @@ A Mod about Matter, Energy and using them to conquer the world..
- [![License](https://img.shields.io/badge/License-No%20Restriction-green.svg?style=flat-square)](https://creativecommons.org/publicdomain/zero/1.0/) - [![License](https://img.shields.io/badge/License-No%20Restriction-green.svg?style=flat-square)](https://creativecommons.org/publicdomain/zero/1.0/)
## Credits ## Credits
Thanks to Thanks to
* Notch et al for Minecraft * Notch et al for Minecraft
+4 -1
View File
@@ -21,6 +21,7 @@ buildscript {
mavenLocal() mavenLocal()
jcenter() jcenter()
mavenCentral() mavenCentral()
maven { maven {
name = "forge" name = "forge"
url = "http://files.minecraftforge.net/maven" url = "http://files.minecraftforge.net/maven"
@@ -57,7 +58,7 @@ tasks.withType(JavaCompile) {
options.encoding = 'UTF-8' options.encoding = 'UTF-8'
} }
version = aeversion + "-" + aechannel + "-" + aebuild + " " + trousers version = aeversion + "-" + aechannel + "-" + aebuild + "-" + extended + "-" + extendedversion
group = aegroup group = aegroup
archivesBaseName = aebasename archivesBaseName = aebasename
@@ -65,6 +66,8 @@ archivesBaseName = aebasename
jar { jar {
manifest { manifest {
attributes 'FMLAT': 'appeng_at.cfg' attributes 'FMLAT': 'appeng_at.cfg'
attributes "FMLCorePlugin": "appeng.core.AE2ELCore"
attributes "FMLCorePluginContainsFMLMod": "true"
} }
from sourceSets.api.output from sourceSets.api.output
+3 -6
View File
@@ -3,20 +3,18 @@ aechannel=stable
aebuild=7 aebuild=7
aegroup=appeng aegroup=appeng
aebasename=appliedenergistics2 aebasename=appliedenergistics2
trousers=omni-fixes-v46e extended=extended_life
extendedversion=v0.54.20
######################################################### #########################################################
# Versions # # Versions #
######################################################### #########################################################
minecraft_version=1.12.2 minecraft_version=1.12.2
mcp_mappings=snapshot_20171003 mcp_mappings=snapshot_20171003
forge_version=14.23.5.2847 forge_version=14.23.5.2847
######################################################### #########################################################
# Installable # # Installable #
######################################################### #########################################################
hwyla_version=1.8.26-B41_1.12.2 hwyla_version=1.8.26-B41_1.12.2
######################################################### #########################################################
# Provided APIs # # Provided APIs #
######################################################### #########################################################
@@ -26,9 +24,8 @@ ic2_version=2.8.73-ex112
top_version=1.12-1.4.23-16 top_version=1.12-1.4.23-16
cofhcore_version=1.12.2-4.5.2.19 cofhcore_version=1.12.2-4.5.2.19
crafttweaker_version=4.1.8.9 crafttweaker_version=4.1.8.9
inventorytweaks_version=1.63
ctm_version=MC1.12.2-0.3.1.16 ctm_version=MC1.12.2-0.3.1.16
forestry_version=5.8.2.387
######################################################### #########################################################
# Deployment # # Deployment #
######################################################### #########################################################
+8
View File
@@ -60,8 +60,16 @@ task sourceJar(type: Jar, overwrite: true) {
classifier = 'sources' classifier = 'sources'
} }
task devJar(type: Jar, overwrite: true) {
from sourceSets.api.output
from sourceSets.main.output
classifier = 'dev'
}
artifacts { artifacts {
archives apiJar archives apiJar
archives javadocJar archives javadocJar
archives sourceJar archives sourceJar
archives devJar
} }
+29 -16
View File
@@ -19,6 +19,15 @@
repositories { repositories {
mavenLocal() mavenLocal()
maven {
url "https://cursemaven.com"
}
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
maven { maven {
name "Mobius" name "Mobius"
url "http://mobiusstrip.eu/maven" url "http://mobiusstrip.eu/maven"
@@ -29,11 +38,6 @@ repositories {
url "http://dvs1.progwml6.com/files/maven" url "http://dvs1.progwml6.com/files/maven"
} }
maven {
name = "Tesla repo"
url "http://maven.mcmoddev.com"
}
maven { maven {
name "Ellpeck" name "Ellpeck"
url "https://maven.ellpeck.de" url "https://maven.ellpeck.de"
@@ -59,7 +63,7 @@ repositories {
url "http://maven.k-4u.nl/" url "http://maven.k-4u.nl/"
} }
maven { // CraftTweaker maven { // CraftTweaker
name 'jared maven' name 'jared maven'
url "http://maven.blamejared.com/" url "http://maven.blamejared.com/"
} }
@@ -68,11 +72,6 @@ repositories {
// name 'modmaven' // name 'modmaven'
// url "https://modmaven.k-4u.nl/" // url "https://modmaven.k-4u.nl/"
//} //}
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
} }
configurations { configurations {
@@ -80,24 +79,38 @@ configurations {
} }
dependencies { dependencies {
compileOnly "gregtechce:gregtech:1.12.2:1.15.1.735" // deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735"
// installable runtime dependencies // installable runtime dependencies
mods "mcp.mobius.waila:Hwyla:${hwyla_version}" deobfCompile "curse.maven:gregtechceu-557242:3949406"
compileOnly "curse.maven:chisel-235279:2915375"
deobfCompile "baubles:Baubles:1.12:1.5.2"
//mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
mods "curse.maven:hwyla-253449:2568751"
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev" mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
mods "mcjty.theoneprobe:TheOneProbe-${minecraft_version}:${top_version}" mods "mcjty.theoneprobe:TheOneProbe-${minecraft_version}:${top_version}"
// compile against provided APIs // compile against provided APIs
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api" compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
compileOnly "mcp.mobius.waila:Hwyla:${hwyla_version}" //compileOnly "mcp.mobius.waila:Hwyla:${hwyla_version}"
compileOnly "curse.maven:hwyla-253449:2568751"
//Code chicken lib, GTCE dependency
deobfCompile "curse.maven:CCL-242818:2779848"
compileOnly "curse.maven:recipe-stages-280554:3405072"
compileOnly "curse.maven:item-stages-280316:2696769"
compileOnly "curse.maven:game-stages-268655:2951844"
compileOnly "net.darkhax.tesla:Tesla-1.12.2:${tesla_version}" compileOnly "net.darkhax.tesla:Tesla-1.12.2:${tesla_version}"
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api" compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api" compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf" compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}" compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api" compileOnly "curse.maven:inventory-tweaks-223094:2482482"
compileOnly "curse.maven:inventory-bogo-sorter-632327:3975184"
compileOnly "team.chisel.ctm:CTM:${ctm_version}" compileOnly "team.chisel.ctm:CTM:${ctm_version}"
compileOnly "de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.2-r152.16:api" compileOnly "de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.2-r152.16:api"
deobfCompile "net.sengir.forestry:forestry_${minecraft_version}:$forestry_version"
// at runtime, use the full JEI jar // at runtime, use the full JEI jar
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}" runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
@@ -28,7 +28,8 @@ public enum PowerUnits
{ {
AE( "gui.appliedenergistics2.units.appliedenergstics" ), // Native Units - AE Energy AE( "gui.appliedenergistics2.units.appliedenergstics" ), // Native Units - AE Energy
EU( "gui.appliedenergistics2.units.ic2" ), // IndustrialCraft 2 - Energy Units EU( "gui.appliedenergistics2.units.ic2" ), // IndustrialCraft 2 - Energy Units
RF( "gui.appliedenergistics2.units.rf" ); // RF - Redstone Flux RF( "gui.appliedenergistics2.units.rf" ), // RF - Redstone Flux
GTEU( "gui.appliedenergistics2.units.gteu" ); // RF - Redstone Flux
/** /**
* unlocalized name for the power unit. * unlocalized name for the power unit.
@@ -46,14 +47,13 @@ public enum PowerUnits
/** /**
* do power conversion using AE's conversion rates. * do power conversion using AE's conversion rates.
* * <p>
* Example: PowerUnits.EU.convertTo( PowerUnits.AE, 32 ); * Example: PowerUnits.EU.convertTo( PowerUnits.AE, 32 );
* * <p>
* will normally returns 64, as it will convert the EU, to AE with AE's power settings. * will normally returns 64, as it will convert the EU, to AE with AE's power settings.
* *
* @param target target power unit * @param target target power unit
* @param value value * @param value value
*
* @return value converted to target units, from this units. * @return value converted to target units, from this units.
*/ */
public double convertTo( final PowerUnits target, final double value ) public double convertTo( final PowerUnits target, final double value )
@@ -29,6 +29,7 @@ public enum TunnelType
ME, // Network Tunnel ME, // Network Tunnel
IC2_POWER, // EU Tunnel IC2_POWER, // EU Tunnel
FE_POWER, // Forge Energy tunnel FE_POWER, // Forge Energy tunnel
GTEU_POWER, // Forge Energy tunnel
REDSTONE, // Redstone Tunnel REDSTONE, // Redstone Tunnel
FLUID, // Fluid Tunnel FLUID, // Fluid Tunnel
ITEM, // Item Tunnel ITEM, // Item Tunnel
+50 -55
View File
@@ -32,66 +32,61 @@ import net.minecraft.item.ItemStack;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
public enum Upgrades public enum Upgrades {
{ /**
/** * Gold Tier Upgrades.
* Gold Tier Upgrades. */
*/ CAPACITY(0),
CAPACITY( 0 ), REDSTONE(0),
REDSTONE( 0 ), CRAFTING(0),
CRAFTING( 0 ), MAGNET(0),
/** /**
* Diamond Tier Upgrades. * Diamond Tier Upgrades.
*/ */
FUZZY( 1 ), FUZZY(1),
SPEED( 1 ), SPEED(1),
INVERTER( 1 ), INVERTER(1),
PATTERN_EXPANSION(1); PATTERN_EXPANSION(1),
QUANTUM_LINK(1);
private final int tier; private final int tier;
private final Map<ItemStack, Integer> supportedMax = new HashMap<>(); private final Map<ItemStack, Integer> supportedMax = new HashMap<>();
Upgrades( final int tier ) Upgrades(final int tier) {
{ this.tier = tier;
this.tier = tier; }
}
/** /**
* @return list of Items/Blocks that support this upgrade, and how many it supports. * @return list of Items/Blocks that support this upgrade, and how many it supports.
*/ */
public Map<ItemStack, Integer> getSupported() public Map<ItemStack, Integer> getSupported() {
{ return this.supportedMax;
return this.supportedMax; }
}
/** /**
* Registers a specific amount of this upgrade into a specific machine * Registers a specific amount of this upgrade into a specific machine
* *
* @param item machine in which this upgrade can be installed * @param item machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed * @param maxSupported amount how many upgrades can be installed
*/ */
public void registerItem( final IItemDefinition item, final int maxSupported ) public void registerItem(final IItemDefinition item, final int maxSupported) {
{ item.maybeStack(1).ifPresent(is -> this.registerItem(is, maxSupported));
item.maybeStack( 1 ).ifPresent( is -> this.registerItem( is, maxSupported ) ); }
}
/** /**
* Registers a specific amount of this upgrade into a specific machine * Registers a specific amount of this upgrade into a specific machine
* *
* @param stack machine in which this upgrade can be installed * @param stack machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed * @param maxSupported amount how many upgrades can be installed
*/ */
public void registerItem( final ItemStack stack, final int maxSupported ) public void registerItem(final ItemStack stack, final int maxSupported) {
{ if (stack != null) {
if( stack != null ) this.supportedMax.put(stack, maxSupported);
{ }
this.supportedMax.put( stack, maxSupported ); }
}
}
public int getTier() public int getTier() {
{ return this.tier;
return this.tier; }
}
} }
@@ -30,8 +30,7 @@ import appeng.api.util.AEColoredItemDefinition;
/** /**
* A list of all items in AE * A list of all items in AE
*/ */
public interface IItems public interface IItems {
{
IItemDefinition certusQuartzAxe(); IItemDefinition certusQuartzAxe();
IItemDefinition certusQuartzHoe(); IItemDefinition certusQuartzHoe();
@@ -64,6 +63,12 @@ public interface IItems
IItemDefinition wirelessTerminal(); IItemDefinition wirelessTerminal();
IItemDefinition wirelessCraftingTerminal();
IItemDefinition wirelessPatternTerminal();
IItemDefinition wirelessFluidTerminal();
IItemDefinition biometricCard(); IItemDefinition biometricCard();
IItemDefinition chargedStaff(); IItemDefinition chargedStaff();
@@ -27,121 +27,124 @@ package appeng.api.definitions;
/** /**
* A list of all materials in AE * A list of all materials in AE
*/ */
public interface IMaterials public interface IMaterials {
{ IItemDefinition cell2SpatialPart();
IItemDefinition cell2SpatialPart();
IItemDefinition cell16SpatialPart(); IItemDefinition cell16SpatialPart();
IItemDefinition cell128SpatialPart(); IItemDefinition cell128SpatialPart();
IItemDefinition silicon(); IItemDefinition silicon();
IItemDefinition skyDust(); IItemDefinition skyDust();
IItemDefinition calcProcessorPress(); IItemDefinition calcProcessorPress();
IItemDefinition engProcessorPress(); IItemDefinition engProcessorPress();
IItemDefinition logicProcessorPress(); IItemDefinition logicProcessorPress();
IItemDefinition calcProcessorPrint(); IItemDefinition calcProcessorPrint();
IItemDefinition engProcessorPrint(); IItemDefinition engProcessorPrint();
IItemDefinition logicProcessorPrint(); IItemDefinition logicProcessorPrint();
IItemDefinition siliconPress(); IItemDefinition siliconPress();
IItemDefinition siliconPrint(); IItemDefinition siliconPrint();
IItemDefinition namePress(); IItemDefinition namePress();
IItemDefinition logicProcessor(); IItemDefinition logicProcessor();
IItemDefinition calcProcessor(); IItemDefinition calcProcessor();
IItemDefinition engProcessor(); IItemDefinition engProcessor();
IItemDefinition basicCard(); IItemDefinition basicCard();
IItemDefinition advCard(); IItemDefinition advCard();
IItemDefinition purifiedCertusQuartzCrystal(); IItemDefinition purifiedCertusQuartzCrystal();
IItemDefinition purifiedNetherQuartzCrystal(); IItemDefinition purifiedNetherQuartzCrystal();
IItemDefinition purifiedFluixCrystal(); IItemDefinition purifiedFluixCrystal();
IItemDefinition cell1kPart(); IItemDefinition cell1kPart();
IItemDefinition cell4kPart(); IItemDefinition cell4kPart();
IItemDefinition cell16kPart(); IItemDefinition cell16kPart();
IItemDefinition cell64kPart(); IItemDefinition cell64kPart();
IItemDefinition emptyStorageCell(); IItemDefinition emptyStorageCell();
IItemDefinition cardRedstone(); IItemDefinition cardRedstone();
IItemDefinition cardSpeed(); IItemDefinition cardSpeed();
IItemDefinition cardCapacity(); IItemDefinition cardCapacity();
IItemDefinition cardPatternExpansion(); IItemDefinition cardPatternExpansion();
IItemDefinition cardFuzzy(); IItemDefinition cardQuantumLink();
IItemDefinition cardInverter(); IItemDefinition cardMagnet();
IItemDefinition cardCrafting(); IItemDefinition cardFuzzy();
IItemDefinition enderDust(); IItemDefinition cardInverter();
IItemDefinition flour(); IItemDefinition cardCrafting();
IItemDefinition goldDust(); IItemDefinition enderDust();
IItemDefinition ironDust(); IItemDefinition flour();
IItemDefinition fluixDust(); IItemDefinition goldDust();
IItemDefinition certusQuartzDust(); IItemDefinition ironDust();
IItemDefinition netherQuartzDust(); IItemDefinition fluixDust();
IItemDefinition matterBall(); IItemDefinition certusQuartzDust();
IItemDefinition certusQuartzCrystal(); IItemDefinition netherQuartzDust();
IItemDefinition certusQuartzCrystalCharged(); IItemDefinition matterBall();
IItemDefinition fluixCrystal(); IItemDefinition certusQuartzCrystal();
IItemDefinition fluixPearl(); IItemDefinition certusQuartzCrystalCharged();
IItemDefinition woodenGear(); IItemDefinition fluixCrystal();
IItemDefinition wirelessReceiver(); IItemDefinition fluixPearl();
IItemDefinition wirelessBooster(); IItemDefinition woodenGear();
IItemDefinition annihilationCore(); IItemDefinition wirelessReceiver();
IItemDefinition formationCore(); IItemDefinition wirelessBooster();
IItemDefinition singularity(); IItemDefinition annihilationCore();
IItemDefinition qESingularity(); IItemDefinition formationCore();
IItemDefinition blankPattern(); IItemDefinition singularity();
IItemDefinition fluidCell1kPart(); IItemDefinition qESingularity();
IItemDefinition fluidCell4kPart(); IItemDefinition blankPattern();
IItemDefinition fluidCell16kPart(); IItemDefinition fluidCell1kPart();
IItemDefinition fluidCell64kPart(); IItemDefinition fluidCell4kPart();
IItemDefinition fluidCell16kPart();
IItemDefinition fluidCell64kPart();
} }
+57 -48
View File
@@ -30,97 +30,106 @@ import appeng.api.util.AEColoredItemDefinition;
/** /**
* A list of all parts in AE * A list of all parts in AE
*/ */
public interface IParts public interface IParts {
{ AEColoredItemDefinition cableSmart();
AEColoredItemDefinition cableSmart();
AEColoredItemDefinition cableCovered(); AEColoredItemDefinition cableCovered();
AEColoredItemDefinition cableGlass(); AEColoredItemDefinition cableGlass();
AEColoredItemDefinition cableDenseCovered(); AEColoredItemDefinition cableDenseCovered();
AEColoredItemDefinition cableDenseSmart(); AEColoredItemDefinition cableDenseSmart();
AEColoredItemDefinition lumenCableSmart(); AEColoredItemDefinition lumenCableSmart();
AEColoredItemDefinition lumenCableCovered(); AEColoredItemDefinition lumenCableCovered();
AEColoredItemDefinition lumenCableGlass(); AEColoredItemDefinition lumenCableGlass();
AEColoredItemDefinition lumenDenseCableSmart(); AEColoredItemDefinition lumenDenseCableSmart();
IItemDefinition quartzFiber(); IItemDefinition quartzFiber();
IItemDefinition toggleBus(); IItemDefinition toggleBus();
IItemDefinition invertedToggleBus(); IItemDefinition invertedToggleBus();
IItemDefinition storageBus(); IItemDefinition storageBus();
IItemDefinition importBus(); IItemDefinition oreDictStorageBus();
IItemDefinition exportBus(); IItemDefinition importBus();
IItemDefinition iface(); IItemDefinition exportBus();
IItemDefinition fluidIface(); IItemDefinition iface();
IItemDefinition levelEmitter(); IItemDefinition fluidIface();
IItemDefinition annihilationPlane(); IItemDefinition levelEmitter();
IItemDefinition identityAnnihilationPlane(); IItemDefinition annihilationPlane();
IItemDefinition formationPlane(); IItemDefinition identityAnnihilationPlane();
IItemDefinition p2PTunnelME(); IItemDefinition formationPlane();
IItemDefinition p2PTunnelRedstone(); IItemDefinition p2PTunnelME();
IItemDefinition p2PTunnelItems(); IItemDefinition p2PTunnelRedstone();
IItemDefinition p2PTunnelFluids(); IItemDefinition p2PTunnelItems();
IItemDefinition p2PTunnelEU(); IItemDefinition p2PTunnelFluids();
IItemDefinition p2PTunnelFE(); IItemDefinition p2PTunnelEU();
IItemDefinition p2PTunnelLight(); IItemDefinition p2PTunnelFE();
// IItemDefinition p2PTunnelOpenComputers(); IItemDefinition p2PTunnelGTEU();
IItemDefinition cableAnchor(); IItemDefinition p2PTunnelLight();
IItemDefinition monitor(); // IItemDefinition p2PTunnelOpenComputers();
IItemDefinition semiDarkMonitor(); IItemDefinition cableAnchor();
IItemDefinition darkMonitor(); IItemDefinition monitor();
IItemDefinition interfaceTerminal(); IItemDefinition semiDarkMonitor();
IItemDefinition patternTerminal(); IItemDefinition darkMonitor();
IItemDefinition craftingTerminal(); IItemDefinition interfaceTerminal();
IItemDefinition terminal(); IItemDefinition patternTerminal();
IItemDefinition storageMonitor(); IItemDefinition expandedProcessingPatternTerminal();
IItemDefinition conversionMonitor(); IItemDefinition interfaceConfigurationTerminal();
IItemDefinition fluidTerminal(); IItemDefinition fluidInterfaceConfigurationTerminal();
IItemDefinition fluidImportBus(); IItemDefinition craftingTerminal();
IItemDefinition fluidExportBus(); IItemDefinition terminal();
IItemDefinition fluidStorageBus(); IItemDefinition storageMonitor();
IItemDefinition fluidLevelEmitter(); IItemDefinition conversionMonitor();
IItemDefinition fluidAnnihilationPlane(); IItemDefinition fluidTerminal();
IItemDefinition fluidFormationnPlane(); IItemDefinition fluidImportBus();
IItemDefinition fluidExportBus();
IItemDefinition fluidStorageBus();
IItemDefinition fluidLevelEmitter();
IItemDefinition fluidAnnihilationPlane();
IItemDefinition fluidFormationnPlane();
} }
@@ -28,47 +28,45 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import net.minecraftforge.fml.common.network.IGuiHandler;
/** /**
* A handler for a wireless terminal. * A handler for a wireless terminal.
*/ */
public interface IWirelessTermHandler extends INetworkEncodable public interface IWirelessTermHandler extends INetworkEncodable {
{
/** /**
* @param is wireless terminal * @param is wireless terminal
* * @return true, if usePower, hasPower, etc... can be called for the provided item
* @return true, if usePower, hasPower, etc... can be called for the provided item */
*/ boolean canHandle(ItemStack is);
boolean canHandle( ItemStack is );
/** /**
* use an amount of power, in AE units * use an amount of power, in AE units
* *
* @param amount is in AE units ( 5 per MJ ), if you return false, the item should be dead and return false for * @param amount is in AE units ( 5 per MJ ), if you return false, the item should be dead and return false for
* hasPower * hasPower
* @param is wireless terminal * @param is wireless terminal
* * @return true if wireless terminal uses power
* @return true if wireless terminal uses power */
*/ boolean usePower(EntityPlayer player, double amount, ItemStack is);
boolean usePower( EntityPlayer player, double amount, ItemStack is );
/** /**
* gets the power status of the item. * gets the power status of the item.
* *
* @param is wireless terminal * @param is wireless terminal
* * @return returns true if there is any power left.
* @return returns true if there is any power left. */
*/ boolean hasPower(EntityPlayer player, double amount, ItemStack is);
boolean hasPower( EntityPlayer player, double amount, ItemStack is );
/** /**
* Return the config manager for the wireless terminal. * Return the config manager for the wireless terminal.
* *
* @param is wireless terminal * @param is wireless terminal
* * @return config manager of wireless terminal
* @return config manager of wireless terminal */
*/ IConfigManager getConfigManager(ItemStack is);
IConfigManager getConfigManager( ItemStack is );
IGuiHandler getGuiHandler(ItemStack is);
} }
@@ -0,0 +1,7 @@
package appeng.api.implementations;
public interface IUpgradeableCellContainer {
int availableUpgrades();
void setupUpgrades();
}
@@ -0,0 +1,41 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.implementations;
import appeng.api.config.Upgrades;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.util.IConfigurableObject;
public interface IUpgradeableCellHost extends IConfigurableObject, ISegmentedInventory {
/**
* determine how many of an upgrade are installed.
*/
default int getInstalledUpgrades(Upgrades u) {
return 0;
}
}
@@ -28,6 +28,8 @@ import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor; import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import javax.annotation.Nullable;
public interface ICraftingCPU extends IBaseMonitor<IAEItemStack> public interface ICraftingCPU extends IBaseMonitor<IAEItemStack>
{ {
@@ -56,4 +58,30 @@ public interface ICraftingCPU extends IBaseMonitor<IAEItemStack>
* @return an empty string or the name of the cpu. * @return an empty string or the name of the cpu.
*/ */
String getName(); String getName();
/**
* @return final output of the current crafting operation, or null if not crafting
*/
@Nullable
default IAEItemStack getFinalOutput()
{
return null;
}
/**
* @return remaining count of items (or other units of processing) for the current crafting job
*/
default long getRemainingItemCount()
{
return 0;
}
/**
* @return total count of items (or other units of processing) for the current crafting job
*/
default long getStartItemCount()
{
return 0;
}
} }
@@ -119,6 +119,10 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
* *
* @param is An item stack * @param is An item stack
*/ */
boolean equals(ItemStack is); boolean equals( ItemStack is );
ItemStack getCachedItemStack( long stackSize );
void setCachedItemStack( ItemStack is );
} }
@@ -0,0 +1,11 @@
package com.enderio.core.common.interfaces;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public interface IOverlayRenderAware {
public void renderItemOverlayIntoGUI(@Nonnull ItemStack stack, int xPosition, int yPosition);
}
+379 -464
View File
@@ -19,11 +19,12 @@
package appeng.block; package appeng.block;
import java.util.ArrayList; import appeng.api.util.IOrientable;
import java.util.List; import appeng.api.util.IOrientableBlock;
import appeng.helpers.AEGlassMaterial;
import javax.annotation.Nullable; import appeng.helpers.ICustomCollision;
import appeng.util.LookDirection;
import appeng.util.Platform;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -46,464 +47,378 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable; import javax.annotation.Nullable;
import appeng.api.util.IOrientableBlock; import java.util.ArrayList;
import appeng.helpers.AEGlassMaterial; import java.util.List;
import appeng.helpers.ICustomCollision;
import appeng.util.LookDirection;
import appeng.util.Platform; public abstract class AEBaseBlock extends Block {
private boolean isOpaque = true;
public abstract class AEBaseBlock extends Block private boolean isFullSize = true;
{ private boolean hasSubtypes = false;
private boolean isInventory = false;
private boolean isOpaque = true;
private boolean isFullSize = true; protected AxisAlignedBB boundingBox = FULL_BLOCK_AABB;
private boolean hasSubtypes = false;
private boolean isInventory = false; protected AEBaseBlock(final Material mat) {
super(mat);
protected AxisAlignedBB boundingBox = FULL_BLOCK_AABB;
if (mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS) {
protected AEBaseBlock( final Material mat ) this.setSoundType(SoundType.GLASS);
{ } else if (mat == Material.ROCK) {
super( mat ); this.setSoundType(SoundType.STONE);
} else if (mat == Material.WOOD) {
if( mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS ) this.setSoundType(SoundType.WOOD);
{ } else {
this.setSoundType( SoundType.GLASS ); this.setSoundType(SoundType.METAL);
} }
else if( mat == Material.ROCK )
{ this.setLightOpacity(255);
this.setSoundType( SoundType.STONE ); this.setLightLevel(0);
} this.setHardness(2.2F);
else if( mat == Material.WOOD ) this.setHarvestLevel("pickaxe", 0);
{
this.setSoundType( SoundType.WOOD ); // Workaround as vanilla sets it way too early.
} this.fullBlock = this.isFullSize();
else }
{
this.setSoundType( SoundType.METAL ); @Override
} protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, this.getAEStates());
this.setLightOpacity( 255 ); }
this.setLightLevel( 0 );
this.setHardness( 2.2F ); @Override
this.setHarvestLevel( "pickaxe", 0 ); public final boolean isNormalCube(IBlockState state) {
return this.isFullSize() && this.isOpaque();
// Workaround as vanilla sets it way too early. }
this.fullBlock = this.isFullSize();
} @Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
@Override return this.boundingBox;
protected BlockStateContainer createBlockState() }
{
return new BlockStateContainer( this, this.getAEStates() ); @SuppressWarnings("deprecation")
} @Override
public void addCollisionBoxToList(final IBlockState state, final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, @Nullable final Entity e, boolean p_185477_7_) {
@Override final ICustomCollision collisionHandler = this.getCustomCollision(w, pos);
public final boolean isNormalCube( IBlockState state )
{ if (collisionHandler != null && bb != null) {
return this.isFullSize() && this.isOpaque(); final List<AxisAlignedBB> tmp = new ArrayList<>();
} collisionHandler.addCollidingBlockToList(w, pos, bb, tmp, e);
for (final AxisAlignedBB b : tmp) {
@Override final AxisAlignedBB offset = b.offset(pos.getX(), pos.getY(), pos.getZ());
public AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess source, BlockPos pos ) if (bb.intersects(offset)) {
{ out.add(offset);
return this.boundingBox; }
} }
} else {
@SuppressWarnings( "deprecation" ) super.addCollisionBoxToList(state, w, pos, bb, out, e, p_185477_7_);
@Override }
public void addCollisionBoxToList( final IBlockState state, final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, @Nullable final Entity e, boolean p_185477_7_ ) }
{
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos ); @SuppressWarnings("deprecation")
@Override
if( collisionHandler != null && bb != null ) @SideOnly(Side.CLIENT)
{ public AxisAlignedBB getSelectedBoundingBox(IBlockState state, final World w, final BlockPos pos) {
final List<AxisAlignedBB> tmp = new ArrayList<>(); final ICustomCollision collisionHandler = this.getCustomCollision(w, pos);
collisionHandler.addCollidingBlockToList( w, pos, bb, tmp, e );
for( final AxisAlignedBB b : tmp ) if (collisionHandler != null) {
{ if (Platform.isClient()) {
final AxisAlignedBB offset = b.offset( pos.getX(), pos.getY(), pos.getZ() ); final EntityPlayer player = Minecraft.getMinecraft().player;
if( bb.intersects( offset ) ) final LookDirection ld = Platform.getPlayerRay(player, Platform.getEyeOffset(player));
{
out.add( offset ); final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool(w, pos, Minecraft.getMinecraft().player, true);
} AxisAlignedBB br = null;
}
} double lastDist = 0;
else
{ for (final AxisAlignedBB bb : bbs) {
super.addCollisionBoxToList( state, w, pos, bb, out, e, p_185477_7_ ); this.boundingBox = bb;
}
} final RayTraceResult r = super.collisionRayTrace(state, w, pos, ld.getA(), ld.getB());
@SuppressWarnings( "deprecation" ) this.boundingBox = FULL_BLOCK_AABB;
@Override
@SideOnly( Side.CLIENT ) if (r != null) {
public AxisAlignedBB getSelectedBoundingBox( IBlockState state, final World w, final BlockPos pos ) final double xLen = (ld.getA().x - r.hitVec.x);
{ final double yLen = (ld.getA().y - r.hitVec.y);
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos ); final double zLen = (ld.getA().z - r.hitVec.z);
if( collisionHandler != null ) final double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
{
if( Platform.isClient() ) if (br == null || lastDist > thisDist) {
{ lastDist = thisDist;
final EntityPlayer player = Minecraft.getMinecraft().player; br = bb;
final LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) ); }
}
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, Minecraft.getMinecraft().player, true ); }
AxisAlignedBB br = null;
if (br != null) {
double lastDist = 0; br = new AxisAlignedBB(br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos
.getY(), br.maxZ + pos.getZ());
for( final AxisAlignedBB bb : bbs ) return br;
{ }
this.boundingBox = bb; }
final RayTraceResult r = super.collisionRayTrace( state, w, pos, ld.getA(), ld.getB() ); AxisAlignedBB b = null; // new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d );
this.boundingBox = FULL_BLOCK_AABB; for (final AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool(w, pos, null, false)) {
if (b == null) {
if( r != null ) b = bx;
{ continue;
final double xLen = ( ld.getA().x - r.hitVec.x ); }
final double yLen = ( ld.getA().y - r.hitVec.y );
final double zLen = ( ld.getA().z - r.hitVec.z ); final double minX = Math.min(b.minX, bx.minX);
final double minY = Math.min(b.minY, bx.minY);
final double thisDist = xLen * xLen + yLen * yLen + zLen * zLen; final double minZ = Math.min(b.minZ, bx.minZ);
final double maxX = Math.max(b.maxX, bx.maxX);
if( br == null || lastDist > thisDist ) final double maxY = Math.max(b.maxY, bx.maxY);
{ final double maxZ = Math.max(b.maxZ, bx.maxZ);
lastDist = thisDist;
br = bb; b = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
} }
}
} if (b == null) {
b = new AxisAlignedBB(16d, 16d, 16d, 0d, 0d, 0d);
if( br != null ) } else {
{ b = new AxisAlignedBB(b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX + pos.getX(), b.maxY + pos.getY(), b.maxZ + pos
br = new AxisAlignedBB( br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos .getZ());
.getY(), br.maxZ + pos.getZ() ); }
return br;
} return b;
} }
AxisAlignedBB b = null; // new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d ); return super.getSelectedBoundingBox(state, w, pos);
}
for( final AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, false ) )
{ @Override
if( b == null ) public final boolean isOpaqueCube(IBlockState state) {
{ return this.isOpaque();
b = bx; }
continue;
} @SuppressWarnings("deprecation")
@Override
final double minX = Math.min( b.minX, bx.minX ); public RayTraceResult collisionRayTrace(final IBlockState state, final World w, final BlockPos pos, final Vec3d a, final Vec3d b) {
final double minY = Math.min( b.minY, bx.minY ); final ICustomCollision collisionHandler = this.getCustomCollision(w, pos);
final double minZ = Math.min( b.minZ, bx.minZ );
final double maxX = Math.max( b.maxX, bx.maxX ); if (collisionHandler != null) {
final double maxY = Math.max( b.maxY, bx.maxY ); final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool(w, pos, null, true);
final double maxZ = Math.max( b.maxZ, bx.maxZ ); RayTraceResult br = null;
b = new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ); double lastDist = 0;
}
for (final AxisAlignedBB bb : bbs) {
if( b == null ) this.boundingBox = bb;
{
b = new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d ); final RayTraceResult r = super.collisionRayTrace(state, w, pos, a, b);
}
else this.boundingBox = FULL_BLOCK_AABB;
{
b = new AxisAlignedBB( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX + pos.getX(), b.maxY + pos.getY(), b.maxZ + pos if (r != null) {
.getZ() ); final double xLen = (a.x - r.hitVec.x);
} final double yLen = (a.y - r.hitVec.y);
final double zLen = (a.z - r.hitVec.z);
return b;
} final double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
if (br == null || lastDist > thisDist) {
return super.getSelectedBoundingBox( state, w, pos ); lastDist = thisDist;
} br = r;
}
@Override }
public final boolean isOpaqueCube( IBlockState state ) }
{
return this.isOpaque(); return br;
} }
@SuppressWarnings( "deprecation" ) this.boundingBox = FULL_BLOCK_AABB;
@Override return super.collisionRayTrace(state, w, pos, a, b);
public RayTraceResult collisionRayTrace( final IBlockState state, final World w, final BlockPos pos, final Vec3d a, final Vec3d b ) }
{
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos ); @Override
public boolean hasComparatorInputOverride(IBlockState state) {
if( collisionHandler != null ) return this.isInventory();
{ }
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, true );
RayTraceResult br = null; @Override
public int getComparatorInputOverride(IBlockState state, final World worldIn, final BlockPos pos) {
double lastDist = 0; return 0;
}
for( final AxisAlignedBB bb : bbs )
{ @Override
this.boundingBox = bb; public final boolean isNormalCube(IBlockState state, final IBlockAccess world, final BlockPos pos) {
return this.isFullSize();
final RayTraceResult r = super.collisionRayTrace( state, w, pos, a, b ); }
this.boundingBox = FULL_BLOCK_AABB; @Override
public boolean rotateBlock(final World w, final BlockPos pos, final EnumFacing axis) {
if( r != null ) final IOrientable rotatable = this.getOrientable(w, pos);
{
final double xLen = ( a.x - r.hitVec.x ); if (rotatable != null && rotatable.canBeRotated()) {
final double yLen = ( a.y - r.hitVec.y ); if (this.hasCustomRotation()) {
final double zLen = ( a.z - r.hitVec.z ); this.customRotateBlock(rotatable, axis);
return true;
final double thisDist = xLen * xLen + yLen * yLen + zLen * zLen; } else {
if( br == null || lastDist > thisDist ) EnumFacing forward = rotatable.getForward();
{ EnumFacing up = rotatable.getUp();
lastDist = thisDist;
br = r; for (int rs = 0; rs < 4; rs++) {
} forward = Platform.rotateAround(forward, axis);
} up = Platform.rotateAround(up, axis);
}
if (this.isValidOrientation(w, pos, forward, up)) {
if( br != null ) rotatable.setOrientation(forward, up);
{ return true;
return br; }
} }
}
return null; }
}
return super.rotateBlock(w, pos, axis);
this.boundingBox = FULL_BLOCK_AABB; }
return super.collisionRayTrace( state, w, pos, a, b );
} @Override
public EnumFacing[] getValidRotations(final World w, final BlockPos pos) {
@Override return new EnumFacing[0];
public boolean hasComparatorInputOverride( IBlockState state ) }
{
return this.isInventory(); @SideOnly(Side.CLIENT)
} @Override
public void addInformation(final ItemStack is, final World world, final List<String> lines, final ITooltipFlag advancedItemTooltips) {
@Override
public int getComparatorInputOverride( IBlockState state, final World worldIn, final BlockPos pos ) }
{
return 0; public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
} return false;
}
@Override
public final boolean isNormalCube( IBlockState state, final IBlockAccess world, final BlockPos pos ) public final EnumFacing mapRotation(final IOrientable ori, final EnumFacing dir) {
{ // case DOWN: return bottomIcon;
return this.isFullSize(); // case UP: return blockIcon;
} // case NORTH: return northIcon;
// case SOUTH: return southIcon;
@Override // case WEST: return sideIcon;
public boolean rotateBlock( final World w, final BlockPos pos, final EnumFacing axis ) // case EAST: return sideIcon;
{
final IOrientable rotatable = this.getOrientable( w, pos ); final EnumFacing forward = ori.getForward();
final EnumFacing up = ori.getUp();
if( rotatable != null && rotatable.canBeRotated() )
{ if (forward == null || up == null) {
if( this.hasCustomRotation() ) return dir;
{ }
this.customRotateBlock( rotatable, axis );
return true; final int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY();
} final int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ();
else final int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX();
{
EnumFacing forward = rotatable.getForward(); EnumFacing west = null;
EnumFacing up = rotatable.getUp(); for (final EnumFacing dx : EnumFacing.VALUES) {
if (dx.getFrontOffsetX() == west_x && dx.getFrontOffsetY() == west_y && dx.getFrontOffsetZ() == west_z) {
for( int rs = 0; rs < 4; rs++ ) west = dx;
{ }
forward = Platform.rotateAround( forward, axis ); }
up = Platform.rotateAround( up, axis );
if (west == null) {
if( this.isValidOrientation( w, pos, forward, up ) ) return dir;
{ }
rotatable.setOrientation( forward, up );
return true; if (dir == forward) {
} return EnumFacing.SOUTH;
} }
} if (dir == forward.getOpposite()) {
} return EnumFacing.NORTH;
}
return super.rotateBlock( w, pos, axis );
} if (dir == up) {
return EnumFacing.UP;
@Override }
public EnumFacing[] getValidRotations( final World w, final BlockPos pos ) if (dir == up.getOpposite()) {
{ return EnumFacing.DOWN;
return new EnumFacing[0]; }
}
if (dir == west) {
@SideOnly( Side.CLIENT ) return EnumFacing.WEST;
@Override }
public void addInformation( final ItemStack is, final World world, final List<String> lines, final ITooltipFlag advancedItemTooltips ) if (dir == west.getOpposite()) {
{ return EnumFacing.EAST;
}
}
return null;
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) }
{
return false; @Override
} public String toString() {
String regName = this.getRegistryName() != null ? this.getRegistryName().getResourcePath() : "unregistered";
public final EnumFacing mapRotation( final IOrientable ori, final EnumFacing dir ) return this.getClass().getSimpleName() + "[" + regName + "]";
{ }
// case DOWN: return bottomIcon;
// case UP: return blockIcon; protected String getUnlocalizedName(final ItemStack is) {
// case NORTH: return northIcon; return this.getUnlocalizedName();
// case SOUTH: return southIcon; }
// case WEST: return sideIcon;
// case EAST: return sideIcon; protected boolean hasCustomRotation() {
return false;
final EnumFacing forward = ori.getForward(); }
final EnumFacing up = ori.getUp();
protected void customRotateBlock(final IOrientable rotatable, final EnumFacing axis) {
if( forward == null || up == null )
{ }
return dir;
} protected IOrientable getOrientable(final IBlockAccess w, final BlockPos pos) {
if (this instanceof IOrientableBlock) {
final int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY(); IOrientableBlock orientable = (IOrientableBlock) this;
final int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ(); return orientable.getOrientable(w, pos);
final int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX(); }
return null;
EnumFacing west = null; }
for( final EnumFacing dx : EnumFacing.VALUES )
{ protected boolean isValidOrientation(final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up) {
if( dx.getFrontOffsetX() == west_x && dx.getFrontOffsetY() == west_y && dx.getFrontOffsetZ() == west_z ) return true;
{ }
west = dx;
} protected ICustomCollision getCustomCollision(final World w, final BlockPos pos) {
} if (this instanceof ICustomCollision) {
return (ICustomCollision) this;
if( west == null ) }
{ return null;
return dir; }
}
protected IProperty[] getAEStates() {
if( dir == forward ) return new IProperty[0];
{ }
return EnumFacing.SOUTH;
} protected boolean isOpaque() {
if( dir == forward.getOpposite() ) return this.isOpaque;
{ }
return EnumFacing.NORTH;
} protected boolean setOpaque(final boolean isOpaque) {
this.isOpaque = isOpaque;
if( dir == up ) return isOpaque;
{ }
return EnumFacing.UP;
} protected boolean hasSubtypes() {
if( dir == up.getOpposite() ) return this.hasSubtypes;
{ }
return EnumFacing.DOWN;
} protected void setHasSubtypes(final boolean hasSubtypes) {
this.hasSubtypes = hasSubtypes;
if( dir == west ) }
{
return EnumFacing.WEST; protected boolean isFullSize() {
} return this.isFullSize;
if( dir == west.getOpposite() ) }
{
return EnumFacing.EAST; protected boolean setFullSize(final boolean isFullSize) {
} this.isFullSize = isFullSize;
return isFullSize;
return null; }
}
protected boolean isInventory() {
@Override return this.isInventory;
public String toString() }
{
String regName = this.getRegistryName() != null ? this.getRegistryName().getResourcePath() : "unregistered"; protected void setInventory(final boolean isInventory) {
return this.getClass().getSimpleName() + "[" + regName + "]"; this.isInventory = isInventory;
} }
protected String getUnlocalizedName( final ItemStack is )
{
return this.getUnlocalizedName();
}
protected boolean hasCustomRotation()
{
return false;
}
protected void customRotateBlock( final IOrientable rotatable, final EnumFacing axis )
{
}
protected IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
if( this instanceof IOrientableBlock )
{
IOrientableBlock orientable = (IOrientableBlock) this;
return orientable.getOrientable( w, pos );
}
return null;
}
protected boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up )
{
return true;
}
protected ICustomCollision getCustomCollision( final World w, final BlockPos pos )
{
if( this instanceof ICustomCollision )
{
return (ICustomCollision) this;
}
return null;
}
protected IProperty[] getAEStates()
{
return new IProperty[0];
}
protected boolean isOpaque()
{
return this.isOpaque;
}
protected boolean setOpaque( final boolean isOpaque )
{
this.isOpaque = isOpaque;
return isOpaque;
}
protected boolean hasSubtypes()
{
return this.hasSubtypes;
}
protected void setHasSubtypes( final boolean hasSubtypes )
{
this.hasSubtypes = hasSubtypes;
}
protected boolean isFullSize()
{
return this.isFullSize;
}
protected boolean setFullSize( final boolean isFullSize )
{
this.isFullSize = isFullSize;
return isFullSize;
}
protected boolean isInventory()
{
return this.isInventory;
}
protected void setInventory( final boolean isInventory )
{
this.isInventory = isInventory;
}
} }
+118 -154
View File
@@ -19,8 +19,13 @@
package appeng.block; package appeng.block;
import java.util.List; import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.misc.BlockLightDetector;
import appeng.block.misc.BlockSkyCompass;
import appeng.block.networking.BlockWireless;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseTile;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
@@ -34,178 +39,137 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable; import java.util.List;
import appeng.api.util.IOrientableBlock;
import appeng.block.misc.BlockLightDetector;
import appeng.block.misc.BlockSkyCompass;
import appeng.block.networking.BlockWireless;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseTile;
public class AEBaseItemBlock extends ItemBlock public class AEBaseItemBlock extends ItemBlock {
{
private final AEBaseBlock blockType; private final AEBaseBlock blockType;
public AEBaseItemBlock( final Block id ) public AEBaseItemBlock(final Block id) {
{ super(id);
super( id ); this.blockType = (AEBaseBlock) id;
this.blockType = (AEBaseBlock) id; this.hasSubtypes = this.blockType.hasSubtypes();
this.hasSubtypes = this.blockType.hasSubtypes(); }
}
@Override @Override
public int getMetadata( final int dmg ) public int getMetadata(final int dmg) {
{ if (this.hasSubtypes) {
if( this.hasSubtypes ) return dmg;
{ }
return dmg; return 0;
} }
return 0;
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public final void addInformation( final ItemStack itemStack, final World world, final List<String> toolTip, final ITooltipFlag advancedTooltips ) public final void addInformation(final ItemStack itemStack, final World world, final List<String> toolTip, final ITooltipFlag advancedTooltips) {
{ this.addCheckedInformation(itemStack, world, toolTip, advancedTooltips);
this.addCheckedInformation( itemStack, world, toolTip, advancedTooltips ); }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void addCheckedInformation( final ItemStack itemStack, final World world, final List<String> toolTip, final ITooltipFlag advancedTooltips ) public void addCheckedInformation(final ItemStack itemStack, final World world, final List<String> toolTip, final ITooltipFlag advancedTooltips) {
{ this.blockType.addInformation(itemStack, world, toolTip, advancedTooltips);
this.blockType.addInformation( itemStack, world, toolTip, advancedTooltips ); }
}
@Override @Override
public boolean isBookEnchantable( final ItemStack itemstack1, final ItemStack itemstack2 ) public boolean isBookEnchantable(final ItemStack itemstack1, final ItemStack itemstack2) {
{ return false;
return false; }
}
@Override @Override
public String getUnlocalizedName( final ItemStack is ) public String getUnlocalizedName(final ItemStack is) {
{ return this.blockType.getUnlocalizedName(is);
return this.blockType.getUnlocalizedName( is ); }
}
@Override @Override
public boolean placeBlockAt( final ItemStack stack, final EntityPlayer player, final World w, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final IBlockState newState ) public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World w, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final IBlockState newState) {
{ EnumFacing up = null;
EnumFacing up = null; EnumFacing forward = null;
EnumFacing forward = null;
if( this.blockType instanceof AEBaseTileBlock ) if (this.blockType instanceof AEBaseTileBlock) {
{ if (this.blockType instanceof BlockLightDetector) {
if( this.blockType instanceof BlockLightDetector ) up = side;
{ if (up == EnumFacing.UP || up == EnumFacing.DOWN) {
up = side; forward = EnumFacing.SOUTH;
if( up == EnumFacing.UP || up == EnumFacing.DOWN ) } else {
{ forward = EnumFacing.UP;
forward = EnumFacing.SOUTH; }
} } else if (this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass) {
else forward = side;
{ if (forward == EnumFacing.UP || forward == EnumFacing.DOWN) {
forward = EnumFacing.UP; up = EnumFacing.SOUTH;
} } else {
} up = EnumFacing.UP;
else if( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass ) }
{ } else {
forward = side; up = EnumFacing.UP;
if( forward == EnumFacing.UP || forward == EnumFacing.DOWN )
{
up = EnumFacing.SOUTH;
}
else
{
up = EnumFacing.UP;
}
}
else
{
up = EnumFacing.UP;
final byte rotation = (byte) ( MathHelper.floor( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 ); final byte rotation = (byte) (MathHelper.floor((player.rotationYaw * 4F) / 360F + 2.5D) & 3);
switch( rotation ) switch (rotation) {
{ default:
default: case 0:
case 0: forward = EnumFacing.SOUTH;
forward = EnumFacing.SOUTH; break;
break; case 1:
case 1: forward = EnumFacing.WEST;
forward = EnumFacing.WEST; break;
break; case 2:
case 2: forward = EnumFacing.NORTH;
forward = EnumFacing.NORTH; break;
break; case 3:
case 3: forward = EnumFacing.EAST;
forward = EnumFacing.EAST; break;
break; }
}
if( player.rotationPitch > 65 ) if (player.rotationPitch > 65) {
{ up = forward.getOpposite();
up = forward.getOpposite(); forward = EnumFacing.UP;
forward = EnumFacing.UP; } else if (player.rotationPitch < -65) {
} up = forward.getOpposite();
else if( player.rotationPitch < -65 ) forward = EnumFacing.DOWN;
{ }
up = forward.getOpposite(); }
forward = EnumFacing.DOWN; }
}
}
}
IOrientable ori = null; IOrientable ori = null;
if( this.blockType instanceof IOrientableBlock ) if (this.blockType instanceof IOrientableBlock) {
{ ori = ((IOrientableBlock) this.blockType).getOrientable(w, pos);
ori = ( (IOrientableBlock) this.blockType ).getOrientable( w, pos ); up = side;
up = side; forward = EnumFacing.SOUTH;
forward = EnumFacing.SOUTH; if (up.getFrontOffsetY() == 0) {
if( up.getFrontOffsetY() == 0 ) forward = EnumFacing.UP;
{ }
forward = EnumFacing.UP; }
}
}
if( !this.blockType.isValidOrientation( w, pos, forward, up ) ) if (!this.blockType.isValidOrientation(w, pos, forward, up)) {
{ return false;
return false; }
}
if( super.placeBlockAt( stack, player, w, pos, side, hitX, hitY, hitZ, newState ) ) if (super.placeBlockAt(stack, player, w, pos, side, hitX, hitY, hitZ, newState)) {
{ if (this.blockType instanceof AEBaseTileBlock && !(this.blockType instanceof BlockLightDetector)) {
if( this.blockType instanceof AEBaseTileBlock && !( this.blockType instanceof BlockLightDetector ) ) final AEBaseTile tile = ((AEBaseTileBlock) this.blockType).getTileEntity(w, pos);
{ ori = tile;
final AEBaseTile tile = ( (AEBaseTileBlock) this.blockType ).getTileEntity( w, pos );
ori = tile;
if( tile == null ) if (tile == null) {
{ return true;
return true; }
}
if( ori.canBeRotated() && !this.blockType.hasCustomRotation() ) if (ori.canBeRotated() && !this.blockType.hasCustomRotation()) {
{ ori.setOrientation(forward, up);
ori.setOrientation( forward, up ); }
}
if( tile instanceof IGridProxyable ) if (tile instanceof IGridProxyable) {
{ ((IGridProxyable) tile).getProxy().setOwner(player);
( (IGridProxyable) tile ).getProxy().setOwner( player ); }
}
tile.onPlacement( stack, player, side ); tile.onPlacement(stack, player, side);
} } else if (this.blockType instanceof IOrientableBlock) {
else if( this.blockType instanceof IOrientableBlock ) ori.setOrientation(forward, up);
{ }
ori.setOrientation( forward, up );
}
return true; return true;
} }
return false; return false;
} }
} }
@@ -19,17 +19,6 @@
package appeng.block; package appeng.block;
import java.text.MessageFormat;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits; import appeng.api.config.PowerUnits;
@@ -38,118 +27,110 @@ import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.core.Api; import appeng.core.Api;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.text.MessageFormat;
import java.util.List;
public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEItemPowerStorage public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEItemPowerStorage {
{
public AEBaseItemBlockChargeable( final Block id ) public AEBaseItemBlockChargeable(final Block id) {
{ super(id);
super( id ); }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips ) public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
{ final NBTTagCompound tag = stack.getTagCompound();
final NBTTagCompound tag = stack.getTagCompound(); double internalCurrentPower = 0;
double internalCurrentPower = 0; final double internalMaxPower = this.getMaxEnergyCapacity();
final double internalMaxPower = this.getMaxEnergyCapacity();
if( internalMaxPower > 0 ) if (internalMaxPower > 0) {
{ if (tag != null) {
if( tag != null ) internalCurrentPower = tag.getDouble("internalCurrentPower");
{ }
internalCurrentPower = tag.getDouble( "internalCurrentPower" );
}
final double percent = internalCurrentPower / internalMaxPower; final double percent = internalCurrentPower / internalMaxPower;
lines.add( GuiText.StoredEnergy.getLocal() + ':' + MessageFormat.format( " {0,number,#} ", internalCurrentPower ) + Platform lines.add(GuiText.StoredEnergy.getLocal() + ':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower) + Platform
.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) ); .gui_localize(PowerUnits.AE.unlocalizedName) + " - " + MessageFormat.format(" {0,number,#.##%} ", percent));
} }
} }
@Override @Override
public double injectAEPower( final ItemStack is, double amount, Actionable mode ) public double injectAEPower(final ItemStack is, double amount, Actionable mode) {
{ final double internalCurrentPower = this.getInternal(is);
final double internalCurrentPower = this.getInternal( is ); final double internalMaxPower = this.getAEMaxPower(is);
final double internalMaxPower = this.getAEMaxPower( is ); final double required = internalMaxPower - internalCurrentPower;
final double required = internalMaxPower - internalCurrentPower; final double overflow = Math.max(0, amount - required);
final double overflow = Math.max( 0, amount - required );
if( mode == Actionable.MODULATE ) if (mode == Actionable.MODULATE) {
{ final double toAdd = Math.min(required, amount);
final double toAdd = Math.min( required, amount ); final double newPowerStored = internalCurrentPower + toAdd;
final double newPowerStored = internalCurrentPower + toAdd;
this.setInternal( is, newPowerStored ); this.setInternal(is, newPowerStored);
} }
return overflow; return overflow;
} }
@Override @Override
public double extractAEPower( final ItemStack is, double amount, Actionable mode ) public double extractAEPower(final ItemStack is, double amount, Actionable mode) {
{ final double internalCurrentPower = this.getInternal(is);
final double internalCurrentPower = this.getInternal( is ); final double fulfillable = Math.min(amount, internalCurrentPower);
final double fulfillable = Math.min( amount, internalCurrentPower );
if( mode == Actionable.MODULATE ) if (mode == Actionable.MODULATE) {
{ final double newPowerStored = internalCurrentPower - fulfillable;
final double newPowerStored = internalCurrentPower - fulfillable;
this.setInternal( is, newPowerStored ); this.setInternal(is, newPowerStored);
} }
return fulfillable; return fulfillable;
} }
@Override @Override
public double getAEMaxPower( final ItemStack is ) public double getAEMaxPower(final ItemStack is) {
{ return this.getMaxEnergyCapacity();
return this.getMaxEnergyCapacity(); }
}
@Override @Override
public double getAECurrentPower( final ItemStack is ) public double getAECurrentPower(final ItemStack is) {
{ return this.getInternal(is);
return this.getInternal( is ); }
}
@Override @Override
public AccessRestriction getPowerFlow( final ItemStack is ) public AccessRestriction getPowerFlow(final ItemStack is) {
{ return AccessRestriction.WRITE;
return AccessRestriction.WRITE; }
}
private double getMaxEnergyCapacity() private double getMaxEnergyCapacity() {
{ final Block blockID = Block.getBlockFromItem(this);
final Block blockID = Block.getBlockFromItem( this ); final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
return energyCell.maybeBlock().map( block -> return energyCell.maybeBlock().map(block ->
{ {
if( blockID == block ) if (blockID == block) {
{ return 200000;
return 200000; } else {
} return 8 * 200000;
else }
{ }).orElse(0);
return 8 * 200000; }
}
} ).orElse( 0 );
}
private double getInternal( final ItemStack is ) private double getInternal(final ItemStack is) {
{ final NBTTagCompound nbt = Platform.openNbtData(is);
final NBTTagCompound nbt = Platform.openNbtData( is ); return nbt.getDouble("internalCurrentPower");
return nbt.getDouble( "internalCurrentPower" ); }
}
private void setInternal( final ItemStack is, final double amt ) private void setInternal(final ItemStack is, final double amt) {
{ final NBTTagCompound nbt = Platform.openNbtData(is);
final NBTTagCompound nbt = Platform.openNbtData( is ); nbt.setDouble("internalCurrentPower", amt);
nbt.setDouble( "internalCurrentPower", amt ); }
}
} }
@@ -20,31 +20,27 @@ package appeng.block;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs; import net.minecraft.block.BlockStairs;
public abstract class AEBaseStairBlock extends BlockStairs public abstract class AEBaseStairBlock extends BlockStairs {
{
protected AEBaseStairBlock( final Block block, final String type ) protected AEBaseStairBlock(final Block block, final String type) {
{ super(block.getDefaultState());
super( block.getDefaultState() );
Preconditions.checkNotNull( block ); Preconditions.checkNotNull(block);
Preconditions.checkNotNull( block.getUnlocalizedName() ); Preconditions.checkNotNull(block.getUnlocalizedName());
Preconditions.checkArgument( block.getUnlocalizedName().length() > 0 ); Preconditions.checkArgument(block.getUnlocalizedName().length() > 0);
this.setUnlocalizedName( "stair." + type ); this.setUnlocalizedName("stair." + type);
this.setLightOpacity( 0 ); this.setLightOpacity(0);
} }
@Override @Override
public String toString() public String toString() {
{ String regName = this.getRegistryName() != null ? this.getRegistryName().getResourcePath() : "unregistered";
String regName = this.getRegistryName() != null ? this.getRegistryName().getResourcePath() : "unregistered"; return this.getClass().getSimpleName() + "[" + regName + "]";
return this.getClass().getSimpleName() + "[" + regName + "]"; }
}
} }
+244 -296
View File
@@ -19,14 +19,23 @@
package appeng.block; package appeng.block;
import java.util.ArrayList; import appeng.api.implementations.items.IMemoryCard;
import java.util.List; import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.implementations.tiles.IColorableTile;
import javax.annotation.Nonnull; import appeng.api.util.AEColor;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.api.util.IOrientable;
import appeng.block.networking.BlockCableBus;
import appeng.core.sync.GuiBridge;
import appeng.helpers.ICustomCollision;
import appeng.items.tools.quartz.ToolQuartzCuttingKnife;
import appeng.tile.AEBaseInvTile;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -46,348 +55,287 @@ import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState; import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.implementations.items.IMemoryCard; import javax.annotation.Nonnull;
import appeng.api.implementations.items.MemoryCardMessages; import javax.annotation.Nullable;
import appeng.api.implementations.tiles.IColorableTile; import java.util.ArrayList;
import appeng.api.util.AEColor; import java.util.List;
import appeng.api.util.IOrientable;
import appeng.block.networking.BlockCableBus;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseInvTile;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntityProvider public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntityProvider {
{
@Nonnull @Nonnull
private Class<? extends AEBaseTile> tileEntityType; private Class<? extends AEBaseTile> tileEntityType;
public AEBaseTileBlock( final Material mat ) public AEBaseTileBlock(final Material mat) {
{ super(mat);
super( mat ); }
}
public static final UnlistedDirection FORWARD = new UnlistedDirection( "forward" ); public static final UnlistedDirection FORWARD = new UnlistedDirection("forward");
public static final UnlistedDirection UP = new UnlistedDirection( "up" ); public static final UnlistedDirection UP = new UnlistedDirection("up");
@Override @Override
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ // A subclass may decide it doesn't want extended block state for whatever reason
// A subclass may decide it doesn't want extended block state for whatever reason if (!(state instanceof IExtendedBlockState)) {
if( !( state instanceof IExtendedBlockState ) ) return state;
{ }
return state;
}
AEBaseTile tile = this.getTileEntity( world, pos ); AEBaseTile tile = this.getTileEntity(world, pos);
if( tile == null ) if (tile == null) {
{ return state; // No info available
return state; // No info available }
}
IExtendedBlockState extState = (IExtendedBlockState) state; IExtendedBlockState extState = (IExtendedBlockState) state;
return extState.withProperty( FORWARD, tile.getForward() ).withProperty( UP, tile.getUp() ); return extState.withProperty(FORWARD, tile.getForward()).withProperty(UP, tile.getUp());
} }
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { FORWARD,
FORWARD, UP
UP });
} ); }
}
@Override @Override
public int getMetaFromState( IBlockState state ) public int getMetaFromState(IBlockState state) {
{ return 0;
return 0; }
}
// TODO : Was this change needed? // TODO : Was this change needed?
public void setTileEntity( final Class<? extends AEBaseTile> c ) public void setTileEntity(final Class<? extends AEBaseTile> c) {
{ this.tileEntityType = c;
this.tileEntityType = c; this.setInventory(AEBaseInvTile.class.isAssignableFrom(c));
this.setInventory( AEBaseInvTile.class.isAssignableFrom( c ) ); }
}
@Override @Override
public boolean hasTileEntity( IBlockState state ) public boolean hasTileEntity(IBlockState state) {
{ return this.hasBlockTileEntity();
return this.hasBlockTileEntity(); }
}
private boolean hasBlockTileEntity() private boolean hasBlockTileEntity() {
{ return this.tileEntityType != null;
return this.tileEntityType != null; }
}
public Class<? extends AEBaseTile> getTileEntityClass() public Class<? extends AEBaseTile> getTileEntityClass() {
{ return this.tileEntityType;
return this.tileEntityType; }
}
@Nullable @Nullable
public <T extends AEBaseTile> T getTileEntity( final IBlockAccess w, final int x, final int y, final int z ) public <T extends AEBaseTile> T getTileEntity(final IBlockAccess w, final int x, final int y, final int z) {
{ return this.getTileEntity(w, new BlockPos(x, y, z));
return this.getTileEntity( w, new BlockPos( x, y, z ) ); }
}
@Nullable @Nullable
public <T extends AEBaseTile> T getTileEntity( final IBlockAccess w, final BlockPos pos ) public <T extends AEBaseTile> T getTileEntity(final IBlockAccess w, final BlockPos pos) {
{ if (!this.hasBlockTileEntity()) {
if( !this.hasBlockTileEntity() ) return null;
{ }
return null;
}
final TileEntity te = w.getTileEntity( pos ); final TileEntity te = w.getTileEntity(pos);
if( this.tileEntityType.isInstance( te ) ) if (this.tileEntityType.isInstance(te)) {
{ return (T) te;
return (T) te; }
}
return null; return null;
} }
@Override @Override
public final TileEntity createNewTileEntity( final World var1, final int var2 ) public final TileEntity createNewTileEntity(final World var1, final int var2) {
{ if (this.hasBlockTileEntity()) {
if( this.hasBlockTileEntity() ) try {
{ return this.tileEntityType.newInstance();
try } catch (final InstantiationException e) {
{ throw new IllegalStateException("Failed to create a new instance of an illegal class " + this.tileEntityType, e);
return this.tileEntityType.newInstance(); } catch (final IllegalAccessException e) {
} throw new IllegalStateException("Failed to create a new instance of " + this.tileEntityType + ", because lack of permissions", e);
catch( final InstantiationException e ) }
{ }
throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.tileEntityType, e );
}
catch( final IllegalAccessException e )
{
throw new IllegalStateException( "Failed to create a new instance of " + this.tileEntityType + ", because lack of permissions", e );
}
}
return null; return null;
} }
@Override @Override
public void breakBlock( final World w, final BlockPos pos, final IBlockState state ) public void breakBlock(final World w, final BlockPos pos, final IBlockState state) {
{ final AEBaseTile te = this.getTileEntity(w, pos);
final AEBaseTile te = this.getTileEntity( w, pos ); if (te != null) {
if( te != null ) final ArrayList<ItemStack> drops = new ArrayList<>();
{ if (te.dropItems()) {
final ArrayList<ItemStack> drops = new ArrayList<>(); te.getDrops(w, pos, drops);
if( te.dropItems() ) } else {
{ te.getNoDrops(w, pos, drops);
te.getDrops( w, pos, drops ); }
}
else
{
te.getNoDrops( w, pos, drops );
}
// Cry ;_; ... // Cry ;_; ...
Platform.spawnDrops( w, pos, drops ); Platform.spawnDrops(w, pos, drops);
} }
// super will remove the TE, as it is not an instance of BlockContainer // super will remove the TE, as it is not an instance of BlockContainer
super.breakBlock( w, pos, state ); super.breakBlock(w, pos, state);
} }
@Override @Override
public final EnumFacing[] getValidRotations( final World w, final BlockPos pos ) public final EnumFacing[] getValidRotations(final World w, final BlockPos pos) {
{ final AEBaseTile obj = this.getTileEntity(w, pos);
final AEBaseTile obj = this.getTileEntity( w, pos ); if (obj != null && obj.canBeRotated()) {
if( obj != null && obj.canBeRotated() ) return EnumFacing.VALUES;
{ }
return EnumFacing.VALUES;
}
return super.getValidRotations( w, pos ); return super.getValidRotations(w, pos);
} }
@Override @Override
public boolean recolorBlock( final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color ) public boolean recolorBlock(final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color) {
{ final TileEntity te = this.getTileEntity(world, pos);
final TileEntity te = this.getTileEntity( world, pos );
if( te instanceof IColorableTile ) if (te instanceof IColorableTile) {
{ final IColorableTile ct = (IColorableTile) te;
final IColorableTile ct = (IColorableTile) te; final AEColor c = ct.getColor();
final AEColor c = ct.getColor(); final AEColor newColor = AEColor.values()[color.getMetadata()];
final AEColor newColor = AEColor.values()[color.getMetadata()];
if( c != newColor ) if (c != newColor) {
{ ct.recolourBlock(side, newColor, null);
ct.recolourBlock( side, newColor, null ); return true;
return true; }
} return false;
return false; }
}
return super.recolorBlock( world, pos, side, color ); return super.recolorBlock(world, pos, side, color);
} }
@Override @Override
public int getComparatorInputOverride( IBlockState state, final World w, final BlockPos pos ) public int getComparatorInputOverride(IBlockState state, final World w, final BlockPos pos) {
{ final TileEntity te = this.getTileEntity(w, pos);
final TileEntity te = this.getTileEntity( w, pos ); if (te instanceof AEBaseInvTile) {
if( te instanceof AEBaseInvTile ) AEBaseInvTile invTile = (AEBaseInvTile) te;
{ if (invTile.getInternalInventory().getSlots() > 0) {
AEBaseInvTile invTile = (AEBaseInvTile) te; return ItemHandlerHelper.calcRedstoneFromInventory(invTile.getInternalInventory());
if( invTile.getInternalInventory().getSlots() > 0 ) }
{ }
return ItemHandlerHelper.calcRedstoneFromInventory( invTile.getInternalInventory() ); return 0;
} }
}
return 0;
}
@Override @Override
public boolean eventReceived( final IBlockState state, final World worldIn, final BlockPos pos, final int eventID, final int eventParam ) public boolean eventReceived(final IBlockState state, final World worldIn, final BlockPos pos, final int eventID, final int eventParam) {
{ super.eventReceived(state, worldIn, pos, eventID, eventParam);
super.eventReceived( state, worldIn, pos, eventID, eventParam ); final TileEntity tileentity = worldIn.getTileEntity(pos);
final TileEntity tileentity = worldIn.getTileEntity( pos ); return tileentity != null && tileentity.receiveClientEvent(eventID, eventParam);
return tileentity != null ? tileentity.receiveClientEvent( eventID, eventParam ) : false; }
}
@Override @Override
public void onBlockPlacedBy( final World w, final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack is ) public void onBlockPlacedBy(final World w, final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack is) {
{ if (is.hasDisplayName()) {
if( is.hasDisplayName() ) final TileEntity te = this.getTileEntity(w, pos);
{ if (te instanceof AEBaseTile) {
final TileEntity te = this.getTileEntity( w, pos ); ((AEBaseTile) w.getTileEntity(pos)).setName(is.getDisplayName());
if( te instanceof AEBaseTile ) }
{ }
( (AEBaseTile) w.getTileEntity( pos ) ).setName( is.getDisplayName() ); }
}
}
}
@Override @Override
public boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
{ ItemStack heldItem;
ItemStack heldItem; if (player != null && !player.getHeldItem(hand).isEmpty()) {
if( player != null && !player.getHeldItem( hand ).isEmpty() ) heldItem = player.getHeldItem(hand);
{
heldItem = player.getHeldItem( hand );
if( Platform.isWrench( player, heldItem, pos ) && player.isSneaking() ) if (Platform.isWrench(player, heldItem, pos) && player.isSneaking()) {
{ final IBlockState blockState = world.getBlockState(pos);
final IBlockState blockState = world.getBlockState( pos ); final Block block = blockState.getBlock();
final Block block = blockState.getBlock();
if( block == null ) if (block == null) {
{ return false;
return false; }
}
final AEBaseTile tile = this.getTileEntity( world, pos ); final AEBaseTile tile = this.getTileEntity(world, pos);
if( tile == null ) if (tile == null) {
{ return false;
return false; }
}
if( tile instanceof TileCableBus || tile instanceof TileSkyChest ) if (tile instanceof TileCableBus || tile instanceof TileSkyChest) {
{ return false;
return false; }
}
final ItemStack[] itemDropCandidates = Platform.getBlockDrops( world, pos ); final ItemStack[] itemDropCandidates = Platform.getBlockDrops(world, pos);
final ItemStack op = new ItemStack( this ); final ItemStack op = new ItemStack(this);
for( final ItemStack ol : itemDropCandidates ) for (final ItemStack ol : itemDropCandidates) {
{ if (Platform.itemComparisons().isEqualItemType(ol, op)) {
if( Platform.itemComparisons().isEqualItemType( ol, op ) ) final NBTTagCompound tag = tile.downloadSettings(SettingsFrom.DISMANTLE_ITEM);
{ if (tag != null) {
final NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM ); ol.setTagCompound(tag);
if( tag != null ) }
{ }
ol.setTagCompound( tag ); }
}
}
}
if( block.removedByPlayer( blockState, world, pos, player, false ) ) if (block.removedByPlayer(blockState, world, pos, player, false)) {
{ final List<ItemStack> itemsToDrop = Lists.newArrayList(itemDropCandidates);
final List<ItemStack> itemsToDrop = Lists.newArrayList( itemDropCandidates ); Platform.spawnDrops(world, pos, itemsToDrop);
Platform.spawnDrops( world, pos, itemsToDrop ); world.setBlockToAir(pos);
world.setBlockToAir( pos ); }
}
return false; return false;
} }
if( heldItem.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus ) ) if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof BlockCableBus)) {
{ final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem();
final IMemoryCard memoryCard = (IMemoryCard) heldItem.getItem(); final AEBaseTile tileEntity = this.getTileEntity(world, pos);
final AEBaseTile tileEntity = this.getTileEntity( world, pos );
if( tileEntity == null ) if (tileEntity == null) {
{ return false;
return false; }
}
final String name = this.getUnlocalizedName(); final String name = this.getUnlocalizedName();
if( player.isSneaking() ) if (player.isSneaking()) {
{ final NBTTagCompound data = tileEntity.downloadSettings(SettingsFrom.MEMORY_CARD);
final NBTTagCompound data = tileEntity.downloadSettings( SettingsFrom.MEMORY_CARD ); if (data != null) {
if( data != null ) memoryCard.setMemoryCardContents(heldItem, name, data);
{ memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_SAVED);
memoryCard.setMemoryCardContents( heldItem, name, data ); }
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED ); } else {
} final String savedName = memoryCard.getSettingsName(heldItem);
} final NBTTagCompound data = memoryCard.getData(heldItem);
else
{
final String savedName = memoryCard.getSettingsName( heldItem );
final NBTTagCompound data = memoryCard.getData( heldItem );
if( this.getUnlocalizedName().equals( savedName ) ) if (this.getUnlocalizedName().equals(savedName)) {
{ tileEntity.uploadSettings(SettingsFrom.MEMORY_CARD, data, player);
tileEntity.uploadSettings( SettingsFrom.MEMORY_CARD, data ); memoryCard.notifyUser(player, MemoryCardMessages.SETTINGS_LOADED);
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED ); } else {
} memoryCard.notifyUser(player, MemoryCardMessages.INVALID_MACHINE);
else }
{ }
memoryCard.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
}
}
return true; return true;
} }
}
return this.onActivated( world, pos, player, hand, player.getHeldItem( hand ), facing, hitX, hitY, hitZ ); if (heldItem.getItem() instanceof ToolQuartzCuttingKnife && !(this instanceof BlockCableBus)) {
} if (ForgeEventFactory.onItemUseStart(player, heldItem, 1) <= 0) return false;
final AEBaseTile tile = this.getTileEntity(world, pos);
if (tile == null) return false;
Platform.openGUI(player, tile, AEPartLocation.fromFacing(facing), GuiBridge.GUI_RENAMER);
return true;
}
}
@Override return this.onActivated(world, pos, player, hand, player.getHeldItem(hand), facing, hitX, hitY, hitZ);
public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos ) }
{
return this.getTileEntity( w, pos );
}
@Override @Override
public ICustomCollision getCustomCollision( final World w, final BlockPos pos ) public IOrientable getOrientable(final IBlockAccess w, final BlockPos pos) {
{ return this.getTileEntity(w, pos);
final AEBaseTile te = this.getTileEntity( w, pos ); }
if( te instanceof ICustomCollision )
{
return (ICustomCollision) te;
}
return super.getCustomCollision( w, pos ); @Override
} public ICustomCollision getCustomCollision(final World w, final BlockPos pos) {
final AEBaseTile te = this.getTileEntity(w, pos);
if (te instanceof ICustomCollision) {
return (ICustomCollision) te;
}
return super.getCustomCollision(w, pos);
}
} }
@@ -22,10 +22,8 @@ package appeng.block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
public abstract class AEDecorativeBlock extends AEBaseBlock public abstract class AEDecorativeBlock extends AEBaseBlock {
{ public AEDecorativeBlock(final Material mat) {
public AEDecorativeBlock( final Material mat ) super(mat);
{ }
super( mat );
}
} }
@@ -23,29 +23,24 @@ import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
public final class UnlistedBlockAccess implements IUnlistedProperty<IBlockAccess> public final class UnlistedBlockAccess implements IUnlistedProperty<IBlockAccess> {
{ @Override
@Override public String getName() {
public String getName() return "ba";
{ }
return "ba";
}
@Override @Override
public boolean isValid( final IBlockAccess value ) public boolean isValid(final IBlockAccess value) {
{ return true;
return true; }
}
@Override @Override
public Class<IBlockAccess> getType() public Class<IBlockAccess> getType() {
{ return IBlockAccess.class;
return IBlockAccess.class; }
}
@Override @Override
public String valueToString( final IBlockAccess value ) public String valueToString(final IBlockAccess value) {
{ return null;
return null; }
}
} }
@@ -23,29 +23,24 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
public final class UnlistedBlockPos implements IUnlistedProperty<BlockPos> public final class UnlistedBlockPos implements IUnlistedProperty<BlockPos> {
{ @Override
@Override public String getName() {
public String getName() return "pos";
{ }
return "pos";
}
@Override @Override
public boolean isValid( final BlockPos value ) public boolean isValid(final BlockPos value) {
{ return true;
return true; }
}
@Override @Override
public Class<BlockPos> getType() public Class<BlockPos> getType() {
{ return BlockPos.class;
return BlockPos.class; }
}
@Override @Override
public String valueToString( final BlockPos value ) public String valueToString(final BlockPos value) {
{ return null;
return null; }
}
} }
@@ -23,38 +23,32 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
public class UnlistedDirection implements IUnlistedProperty<EnumFacing> public class UnlistedDirection implements IUnlistedProperty<EnumFacing> {
{
private final String name; private final String name;
public UnlistedDirection( String name ) public UnlistedDirection(String name) {
{ this.name = name;
this.name = name; }
}
@Override @Override
public String getName() public String getName() {
{ return this.name;
return this.name; }
}
@Override @Override
public boolean isValid( EnumFacing value ) public boolean isValid(EnumFacing value) {
{ return value != null;
return value != null; }
}
@Override @Override
public Class<EnumFacing> getType() public Class<EnumFacing> getType() {
{ return EnumFacing.class;
return EnumFacing.class; }
}
@Override @Override
public String valueToString( EnumFacing value ) public String valueToString(EnumFacing value) {
{ return value.getName();
return value.getName(); }
}
} }
@@ -19,6 +19,9 @@
package appeng.block.crafting; package appeng.block.crafting;
import appeng.api.util.AEColor;
import appeng.client.UnlistedProperty;
import appeng.tile.crafting.TileCraftingMonitorTile;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@@ -33,57 +36,47 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEColor;
import appeng.client.UnlistedProperty;
import appeng.tile.crafting.TileCraftingMonitorTile;
public class BlockCraftingMonitor extends BlockCraftingUnit {
public class BlockCraftingMonitor extends BlockCraftingUnit public static final UnlistedProperty<AEColor> COLOR = new UnlistedProperty<>("color", AEColor.class);
{
public static final UnlistedProperty<AEColor> COLOR = new UnlistedProperty<>( "color", AEColor.class ); public BlockCraftingMonitor() {
super(CraftingUnitType.MONITOR);
}
public BlockCraftingMonitor() @Override
{ protected BlockStateContainer createBlockState() {
super( CraftingUnitType.MONITOR ); return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{
} STATE,
COLOR,
FORWARD,
UP
});
}
@Override @Override
protected BlockStateContainer createBlockState() public IExtendedBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ AEColor color = AEColor.TRANSPARENT;
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { EnumFacing forward = EnumFacing.NORTH;
STATE, EnumFacing up = EnumFacing.UP;
COLOR,
FORWARD,
UP
} );
}
@Override TileCraftingMonitorTile te = this.getTileEntity(world, pos);
public IExtendedBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) if (te != null) {
{ color = te.getColor();
AEColor color = AEColor.TRANSPARENT; forward = te.getForward();
EnumFacing forward = EnumFacing.NORTH; up = te.getUp();
EnumFacing up = EnumFacing.UP; }
TileCraftingMonitorTile te = this.getTileEntity( world, pos ); return super.getExtendedState(state, world, pos)
if( te != null ) .withProperty(COLOR, color)
{ .withProperty(FORWARD, forward)
color = te.getColor(); .withProperty(UP, up);
forward = te.getForward(); }
up = te.getUp();
}
return super.getExtendedState( state, world, pos ) @Override
.withProperty( COLOR, color ) @SideOnly(Side.CLIENT)
.withProperty( FORWARD, forward ) public void getSubBlocks(final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks) {
.withProperty( UP, up ); itemStacks.add(new ItemStack(this, 1, 0));
} }
@Override
@SideOnly( Side.CLIENT )
public void getSubBlocks( final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks )
{
itemStacks.add( new ItemStack( this, 1, 0 ) );
}
} }
@@ -19,12 +19,10 @@
package appeng.block.crafting; package appeng.block.crafting;
public class BlockCraftingStorage extends BlockCraftingUnit public class BlockCraftingStorage extends BlockCraftingUnit {
{
public BlockCraftingStorage( final CraftingUnitType type ) public BlockCraftingStorage(final CraftingUnitType type) {
{ super(type);
super( type ); }
}
} }
@@ -19,8 +19,13 @@
package appeng.block.crafting; package appeng.block.crafting;
import java.util.EnumSet; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.UnlistedProperty;
import appeng.client.render.crafting.CraftingCubeState;
import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@@ -38,130 +43,105 @@ import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
import appeng.api.util.AEPartLocation; import java.util.EnumSet;
import appeng.block.AEBaseTileBlock;
import appeng.client.UnlistedProperty;
import appeng.client.render.crafting.CraftingCubeState;
import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
public class BlockCraftingUnit extends AEBaseTileBlock public class BlockCraftingUnit extends AEBaseTileBlock {
{ public static final PropertyBool FORMED = PropertyBool.create("formed");
public static final PropertyBool FORMED = PropertyBool.create( "formed" ); public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyBool POWERED = PropertyBool.create( "powered" ); public static final UnlistedProperty<CraftingCubeState> STATE = new UnlistedProperty<>("state", CraftingCubeState.class);
public static final UnlistedProperty<CraftingCubeState> STATE = new UnlistedProperty<>( "state", CraftingCubeState.class );
public final CraftingUnitType type; public final CraftingUnitType type;
public BlockCraftingUnit( final CraftingUnitType type ) public BlockCraftingUnit(final CraftingUnitType type) {
{ super(Material.IRON);
super( Material.IRON );
this.type = type; this.type = type;
} }
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{POWERED, FORMED};
return new IProperty[] { POWERED, FORMED }; }
}
@Override @Override
public IExtendedBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) public IExtendedBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
{
EnumSet<EnumFacing> connections = EnumSet.noneOf( EnumFacing.class ); EnumSet<EnumFacing> connections = EnumSet.noneOf(EnumFacing.class);
for( EnumFacing facing : EnumFacing.values() ) for (EnumFacing facing : EnumFacing.values()) {
{ if (this.isConnected(world, pos, facing)) {
if( this.isConnected( world, pos, facing ) ) connections.add(facing);
{ }
connections.add( facing ); }
}
}
IExtendedBlockState extState = (IExtendedBlockState) state; IExtendedBlockState extState = (IExtendedBlockState) state;
return extState.withProperty( STATE, new CraftingCubeState( connections ) ); return extState.withProperty(STATE, new CraftingCubeState(connections));
} }
private boolean isConnected( IBlockAccess world, BlockPos pos, EnumFacing side ) private boolean isConnected(IBlockAccess world, BlockPos pos, EnumFacing side) {
{ BlockPos adjacentPos = pos.offset(side);
BlockPos adjacentPos = pos.offset( side ); return world.getBlockState(adjacentPos).getBlock() instanceof BlockCraftingUnit;
return world.getBlockState( adjacentPos ).getBlock() instanceof BlockCraftingUnit; }
}
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{STATE});
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { STATE } ); }
}
@Override @Override
public IBlockState getStateFromMeta( final int meta ) public IBlockState getStateFromMeta(final int meta) {
{ return this.getDefaultState().withProperty(POWERED, (meta & 1) == 1).withProperty(FORMED, (meta & 2) == 2);
return this.getDefaultState().withProperty( POWERED, ( meta & 1 ) == 1 ).withProperty( FORMED, ( meta & 2 ) == 2 ); }
}
@Override @Override
public int getMetaFromState( final IBlockState state ) public int getMetaFromState(final IBlockState state) {
{ boolean p = state.getValue(POWERED);
boolean p = state.getValue( POWERED ); boolean f = state.getValue(FORMED);
boolean f = state.getValue( FORMED ); return (p ? 1 : 0) | (f ? 2 : 0);
return ( p ? 1 : 0 ) | ( f ? 2 : 0 ); }
}
@Override @Override
public void neighborChanged( final IBlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos ) public void neighborChanged(final IBlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos) {
{ final TileCraftingTile cp = this.getTileEntity(worldIn, pos);
final TileCraftingTile cp = this.getTileEntity( worldIn, pos ); if (cp != null) {
if( cp != null ) cp.updateMultiBlock();
{ }
cp.updateMultiBlock(); }
}
}
@Override @Override
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
@Override @Override
public void breakBlock( final World w, final BlockPos pos, final IBlockState state ) public void breakBlock(final World w, final BlockPos pos, final IBlockState state) {
{ final TileCraftingTile cp = this.getTileEntity(w, pos);
final TileCraftingTile cp = this.getTileEntity( w, pos ); if (cp != null) {
if( cp != null ) cp.breakCluster();
{ }
cp.breakCluster();
}
super.breakBlock( w, pos, state ); super.breakBlock(w, pos, state);
} }
@Override @Override
public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onBlockActivated(final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ final TileCraftingTile tg = this.getTileEntity(w, pos);
final TileCraftingTile tg = this.getTileEntity( w, pos );
if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() ) if (tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive()) {
{ if (Platform.isClient()) {
if( Platform.isClient() ) return true;
{ }
return true;
}
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CRAFTING_CPU ); Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_CRAFTING_CPU);
return true; return true;
} }
return super.onBlockActivated( w, pos, state, p, hand, side, hitX, hitY, hitZ ); return super.onBlockActivated(w, pos, state, p, hand, side, hitX, hitY, hitZ);
} }
public enum CraftingUnitType public enum CraftingUnitType {
{ UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
UNIT, ACCELERATOR, STORAGE_1K, STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR }
}
} }
@@ -19,6 +19,11 @@
package appeng.block.crafting; package appeng.block.crafting;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
@@ -33,79 +38,71 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
public class BlockMolecularAssembler extends AEBaseTileBlock {
public class BlockMolecularAssembler extends AEBaseTileBlock public static final PropertyBool POWERED = PropertyBool.create("powered");
{
public static final PropertyBool POWERED = PropertyBool.create( "powered" ); public BlockMolecularAssembler() {
super(Material.IRON);
public BlockMolecularAssembler() this.setOpaque(false);
{ this.lightOpacity = 1;
super( Material.IRON ); }
this.setOpaque( false ); @Override
this.lightOpacity = 1; protected IProperty[] getAEStates() {
} return new IProperty[]{POWERED};
}
@Override @Override
protected IProperty[] getAEStates() public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
{ boolean powered = false;
return new IProperty[] { POWERED }; TileMolecularAssembler te = this.getTileEntity(worldIn, pos);
} if (te != null) {
powered = te.isPowered();
}
@Override return super.getActualState(state, worldIn, pos).withProperty(POWERED, powered);
public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos ) }
{
boolean powered = false;
TileMolecularAssembler te = this.getTileEntity( worldIn, pos );
if( te != null )
{
powered = te.isPowered();
}
return super.getActualState( state, worldIn, pos ).withProperty( POWERED, powered ); /**
} * NOTE: This is only used to determine how to render an item being held in hand.
* For determining block rendering, the method below is used (canRenderInLayer).
*/
@SideOnly(Side.CLIENT)
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}
/** @SideOnly(Side.CLIENT)
* NOTE: This is only used to determine how to render an item being held in hand. @Override
* For determining block rendering, the method below is used (canRenderInLayer). public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
*/ return layer == BlockRenderLayer.CUTOUT || layer == BlockRenderLayer.TRANSLUCENT;
@SideOnly( Side.CLIENT ) }
@Override
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@SideOnly( Side.CLIENT ) @Override
@Override public boolean isFullCube(IBlockState state) {
public boolean canRenderInLayer( IBlockState state, BlockRenderLayer layer ) return false;
{ }
return layer == BlockRenderLayer.CUTOUT || layer == BlockRenderLayer.TRANSLUCENT;
}
@Override @Override
public boolean isFullCube( IBlockState state ) public boolean onBlockActivated(final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ final TileMolecularAssembler tg = this.getTileEntity(w, pos);
return false; if (tg != null && !p.isSneaking()) {
} Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_MAC);
return true;
}
@Override return super.onBlockActivated(w, pos, state, p, hand, side, hitX, hitY, hitZ);
public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer p, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) }
{
final TileMolecularAssembler tg = this.getTileEntity( w, pos );
if( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC );
return true;
}
return super.onBlockActivated( w, pos, state, p, hand, side, hitX, hitY, hitZ ); @Override
} public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
final TileMolecularAssembler tg = this.getTileEntity(world, pos);
if (tg != null) {
tg.updateNeighbors(world, pos, neighbor);
}
}
} }
@@ -19,32 +19,27 @@
package appeng.block.crafting; package appeng.block.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.block.AEBaseItemBlock; import appeng.block.AEBaseItemBlock;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
public class ItemCraftingStorage extends AEBaseItemBlock public class ItemCraftingStorage extends AEBaseItemBlock {
{
public ItemCraftingStorage( final Block id ) public ItemCraftingStorage(final Block id) {
{ super(id);
super( id ); }
}
@Override @Override
public ItemStack getContainerItem( final ItemStack itemStack ) public ItemStack getContainerItem(final ItemStack itemStack) {
{ return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( ItemStack.EMPTY ); }
}
@Override @Override
public boolean hasContainerItem( final ItemStack stack ) public boolean hasContainerItem(final ItemStack stack) {
{ return AEConfig.instance().isFeatureEnabled(AEFeature.ENABLE_DISASSEMBLY_CRAFTING);
return AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ); }
}
} }
@@ -19,8 +19,11 @@
package appeng.block.grindstone; package appeng.block.grindstone;
import javax.annotation.Nullable; import appeng.api.implementations.tiles.ICrankable;
import appeng.block.AEBaseTileBlock;
import appeng.core.stats.Stats;
import appeng.tile.AEBaseTile;
import appeng.tile.grindstone.TileCrank;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockFaceShape;
@@ -37,145 +40,114 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import appeng.api.implementations.tiles.ICrankable; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.stats.Stats;
import appeng.tile.AEBaseTile;
import appeng.tile.grindstone.TileCrank;
public class BlockCrank extends AEBaseTileBlock public class BlockCrank extends AEBaseTileBlock {
{
public BlockCrank() public BlockCrank() {
{ super(Material.WOOD);
super( Material.WOOD );
this.setLightOpacity( 0 ); this.setLightOpacity(0);
this.setHarvestLevel( "axe", 0 ); this.setHarvestLevel("axe", 0);
this.setFullSize( this.setOpaque( false ) ); this.setFullSize(this.setOpaque(false));
} }
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (player instanceof FakePlayer || player == null) {
if( player instanceof FakePlayer || player == null ) this.dropCrank(w, pos);
{ return true;
this.dropCrank( w, pos ); }
return true;
}
final AEBaseTile tile = this.getTileEntity( w, pos ); final AEBaseTile tile = this.getTileEntity(w, pos);
if( tile instanceof TileCrank ) if (tile instanceof TileCrank) {
{ if (((TileCrank) tile).power()) {
if( ( (TileCrank) tile ).power() ) Stats.TurnedCranks.addToPlayer(player, 1);
{ }
Stats.TurnedCranks.addToPlayer( player, 1 ); }
}
}
return true; return true;
} }
private void dropCrank( final World world, final BlockPos pos ) private void dropCrank(final World world, final BlockPos pos) {
{ world.destroyBlock(pos, true); // w.destroyBlock( x, y, z, true );
world.destroyBlock( pos, true ); // w.destroyBlock( x, y, z, true ); world.notifyBlockUpdate(pos, this.getDefaultState(), world.getBlockState(pos), 3);
world.notifyBlockUpdate( pos, this.getDefaultState(), world.getBlockState( pos ), 3 ); }
}
@Override @Override
public void onBlockPlacedBy( final World world, final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack ) public void onBlockPlacedBy(final World world, final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack) {
{ final AEBaseTile tile = this.getTileEntity(world, pos);
final AEBaseTile tile = this.getTileEntity( world, pos ); if (tile != null) {
if( tile != null ) final EnumFacing mnt = this.findCrankable(world, pos);
{ EnumFacing forward = EnumFacing.UP;
final EnumFacing mnt = this.findCrankable( world, pos ); if (mnt == EnumFacing.UP || mnt == EnumFacing.DOWN) {
EnumFacing forward = EnumFacing.UP; forward = EnumFacing.SOUTH;
if( mnt == EnumFacing.UP || mnt == EnumFacing.DOWN ) }
{ tile.setOrientation(forward, mnt.getOpposite());
forward = EnumFacing.SOUTH; } else {
} this.dropCrank(world, pos);
tile.setOrientation( forward, mnt.getOpposite() ); }
} }
else
{
this.dropCrank( world, pos );
}
}
@Override @Override
public boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up ) public boolean isValidOrientation(final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up) {
{ final TileEntity te = w.getTileEntity(pos);
final TileEntity te = w.getTileEntity( pos ); return !(te instanceof TileCrank) || this.isCrankable(w, pos, up.getOpposite());
return !( te instanceof TileCrank ) || this.isCrankable( w, pos, up.getOpposite() ); }
}
private EnumFacing findCrankable( final World world, final BlockPos pos ) private EnumFacing findCrankable(final World world, final BlockPos pos) {
{ for (final EnumFacing dir : EnumFacing.VALUES) {
for( final EnumFacing dir : EnumFacing.VALUES ) if (this.isCrankable(world, pos, dir)) {
{ return dir;
if( this.isCrankable( world, pos, dir ) ) }
{ }
return dir; return null;
} }
}
return null;
}
private boolean isCrankable( final World world, final BlockPos pos, final EnumFacing offset ) private boolean isCrankable(final World world, final BlockPos pos, final EnumFacing offset) {
{ final BlockPos o = pos.offset(offset);
final BlockPos o = pos.offset( offset ); final TileEntity te = world.getTileEntity(o);
final TileEntity te = world.getTileEntity( o );
return te instanceof ICrankable && ( (ICrankable) te ).canCrankAttach( offset.getOpposite() ); return te instanceof ICrankable && ((ICrankable) te).canCrankAttach(offset.getOpposite());
} }
@Override @Override
public EnumBlockRenderType getRenderType( IBlockState state ) public EnumBlockRenderType getRenderType(IBlockState state) {
{ return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; }
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{
final AEBaseTile tile = this.getTileEntity( world, pos ); final AEBaseTile tile = this.getTileEntity(world, pos);
if( tile != null ) if (tile != null) {
{ if (!this.isCrankable(world, pos, tile.getUp().getOpposite())) {
if( !this.isCrankable( world, pos, tile.getUp().getOpposite() ) ) this.dropCrank(world, pos);
{ }
this.dropCrank( world, pos ); } else {
} this.dropCrank(world, pos);
} }
else }
{
this.dropCrank( world, pos );
}
}
@Override @Override
public boolean canPlaceBlockAt( final World world, final BlockPos pos ) public boolean canPlaceBlockAt(final World world, final BlockPos pos) {
{ return this.findCrankable(world, pos) != null;
return this.findCrankable( world, pos ) != null; }
}
@Override @Override
public boolean isFullCube( IBlockState state ) public boolean isFullCube(IBlockState state) {
{ return false;
return false; }
}
@Override @Override
public boolean canPlaceTorchOnTop( IBlockState state, IBlockAccess world, BlockPos pos ) public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos) {
{ return false;
return false; }
}
@Override @Override
public BlockFaceShape getBlockFaceShape( IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face ) public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
{ return BlockFaceShape.UNDEFINED;
return BlockFaceShape.UNDEFINED; }
}
} }
@@ -19,8 +19,11 @@
package appeng.block.grindstone; package appeng.block.grindstone;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.grindstone.TileGrinder;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -29,32 +32,24 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.grindstone.TileGrinder;
import appeng.util.Platform;
public class BlockGrinder extends AEBaseTileBlock public class BlockGrinder extends AEBaseTileBlock {
{
public BlockGrinder() public BlockGrinder() {
{ super(Material.ROCK);
super( Material.ROCK );
this.setHardness( 3.2F ); this.setHardness(3.2F);
} }
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ final TileGrinder tg = this.getTileEntity(w, pos);
final TileGrinder tg = this.getTileEntity( w, pos ); if (tg != null && !p.isSneaking()) {
if( tg != null && !p.isSneaking() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_GRINDER);
{ return true;
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_GRINDER ); }
return true; return false;
} }
return false;
}
} }
@@ -19,22 +19,19 @@
package appeng.block.grindstone; package appeng.block.grindstone;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.tesr.CrankTESR; import appeng.client.render.tesr.CrankTESR;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class CrankRendering extends BlockRenderingCustomizer public class CrankRendering extends BlockRenderingCustomizer {
{
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.tesr(new CrankTESR());
rendering.tesr( new CrankTESR() ); }
}
} }
@@ -19,8 +19,11 @@
package appeng.block.misc; package appeng.block.misc;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -29,38 +32,28 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
public class BlockCellWorkbench extends AEBaseTileBlock public class BlockCellWorkbench extends AEBaseTileBlock {
{
public BlockCellWorkbench() public BlockCellWorkbench() {
{ super(Material.IRON);
super( Material.IRON ); }
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileCellWorkbench tg = this.getTileEntity( w, pos ); final TileCellWorkbench tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_CELL_WORKBENCH);
{ }
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CELL_WORKBENCH ); return true;
} }
return true; return false;
} }
return false;
}
} }
+125 -150
View File
@@ -19,17 +19,18 @@
package appeng.block.misc; package appeng.block.misc;
import java.util.Collections; import appeng.api.AEApi;
import java.util.List; import appeng.api.util.AEAxisAlignedBB;
import java.util.Random; import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.LightningFX;
import javax.annotation.Nullable; import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR;
import org.apache.commons.lang3.tuple.ImmutablePair; import appeng.core.AEConfig;
import org.apache.commons.lang3.tuple.Pair; import appeng.core.AppEng;
import org.lwjgl.util.vector.Matrix4f; import appeng.helpers.ICustomCollision;
import org.lwjgl.util.vector.Vector3f; import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileCharger;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -44,164 +45,138 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import appeng.api.AEApi; import javax.annotation.Nullable;
import appeng.api.util.AEAxisAlignedBB; import java.util.Collections;
import appeng.block.AEBaseTileBlock; import java.util.List;
import appeng.client.render.effects.LightningFX; import java.util.Random;
import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileCharger;
import appeng.util.Platform;
public class BlockCharger extends AEBaseTileBlock implements ICustomCollision public class BlockCharger extends AEBaseTileBlock implements ICustomCollision {
{
public BlockCharger() public BlockCharger() {
{ super(Material.IRON);
super( Material.IRON );
this.setLightOpacity( 2 ); this.setLightOpacity(2);
this.setFullSize( this.setOpaque( false ) ); this.setFullSize(this.setOpaque(false));
} }
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (player.isSneaking()) {
if( player.isSneaking() ) return false;
{ }
return false;
}
if( Platform.isServer() ) if (Platform.isServer()) {
{ final TileCharger tc = this.getTileEntity(w, pos);
final TileCharger tc = this.getTileEntity( w, pos ); if (tc != null) {
if( tc != null ) tc.activate(player);
{ }
tc.activate( player ); }
}
}
return true; return true;
} }
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r ) public void randomDisplayTick(final IBlockState state, final World w, final BlockPos pos, final Random r) {
{ if (!AEConfig.instance().isEnableEffects()) {
if( !AEConfig.instance().isEnableEffects() ) return;
{ }
return;
}
if( r.nextFloat() < 0.98 ) if (r.nextFloat() < 0.98) {
{ return;
return; }
}
final AEBaseTile tile = this.getTileEntity( w, pos ); final AEBaseTile tile = this.getTileEntity(w, pos);
if( tile instanceof TileCharger ) if (tile instanceof TileCharger) {
{ final TileCharger tc = (TileCharger) tile;
final TileCharger tc = (TileCharger) tile;
if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getInternalInventory().getStackInSlot( 0 ) ) ) if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs(tc.getInternalInventory().getStackInSlot(0))) {
{ final double xOff = 0.0;
final double xOff = 0.0; final double yOff = 0.0;
final double yOff = 0.0; final double zOff = 0.0;
final double zOff = 0.0;
for( int bolts = 0; bolts < 3; bolts++ ) for (int bolts = 0; bolts < 3; bolts++) {
{ if (AppEng.proxy.shouldAddParticles(r)) {
if( AppEng.proxy.shouldAddParticles( r ) ) final LightningFX fx = new LightningFX(w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos
{ .getZ(), 0.0D, 0.0D, 0.0D);
final LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos Minecraft.getMinecraft().effectRenderer.addEffect(fx);
.getZ(), 0.0D, 0.0D, 0.0D ); }
Minecraft.getMinecraft().effectRenderer.addEffect( fx ); }
} }
} }
} }
}
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ final TileCharger tile = this.getTileEntity(w, pos);
final TileCharger tile = this.getTileEntity( w, pos ); if (tile != null) {
if( tile != null ) final double twoPixels = 2.0 / 16.0;
{ final EnumFacing up = tile.getUp();
final double twoPixels = 2.0 / 16.0; final EnumFacing forward = tile.getForward();
final EnumFacing up = tile.getUp(); final AEAxisAlignedBB bb = new AEAxisAlignedBB(twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels);
final EnumFacing forward = tile.getForward();
final AEAxisAlignedBB bb = new AEAxisAlignedBB( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
if( up.getFrontOffsetX() != 0 ) if (up.getFrontOffsetX() != 0) {
{ bb.minX = 0;
bb.minX = 0; bb.maxX = 1;
bb.maxX = 1; }
} if (up.getFrontOffsetY() != 0) {
if( up.getFrontOffsetY() != 0 ) bb.minY = 0;
{ bb.maxY = 1;
bb.minY = 0; }
bb.maxY = 1; if (up.getFrontOffsetZ() != 0) {
} bb.minZ = 0;
if( up.getFrontOffsetZ() != 0 ) bb.maxZ = 1;
{ }
bb.minZ = 0;
bb.maxZ = 1;
}
switch( forward ) switch (forward) {
{ case DOWN:
case DOWN: bb.maxY = 1;
bb.maxY = 1; break;
break; case UP:
case UP: bb.minY = 0;
bb.minY = 0; break;
break; case NORTH:
case NORTH: bb.maxZ = 1;
bb.maxZ = 1; break;
break; case SOUTH:
case SOUTH: bb.minZ = 0;
bb.minZ = 0; break;
break; case EAST:
case EAST: bb.minX = 0;
bb.minX = 0; break;
break; case WEST:
case WEST: bb.maxX = 1;
bb.maxX = 1; break;
break; default:
default: break;
break; }
}
return Collections.singletonList( bb.getBoundingBox() ); return Collections.singletonList(bb.getBoundingBox());
} }
return Collections.singletonList( new AxisAlignedBB( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) ); return Collections.singletonList(new AxisAlignedBB(0.0, 0, 0.0, 1.0, 1.0, 1.0));
} }
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{ out.add(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
out.add( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) ); }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public static TileEntitySpecialRenderer<TileCharger> createTesr() public static TileEntitySpecialRenderer<TileCharger> createTesr() {
{ return new ModularTESR<>(new ItemRenderable<>(BlockCharger::getRenderedItem));
return new ModularTESR<>( new ItemRenderable<>( BlockCharger::getRenderedItem ) ); }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private static Pair<ItemStack, Matrix4f> getRenderedItem( TileCharger tile ) private static Pair<ItemStack, Matrix4f> getRenderedItem(TileCharger tile) {
{ Matrix4f transform = new Matrix4f();
Matrix4f transform = new Matrix4f(); transform.translate(new Vector3f(0.5f, 0.4f, 0.5f));
transform.translate( new Vector3f( 0.5f, 0.4f, 0.5f ) ); return new ImmutablePair<>(tile.getInternalInventory().getStackInSlot(0), transform);
return new ImmutablePair<>( tile.getInternalInventory().getStackInSlot( 0 ), transform ); }
}
} }
@@ -19,8 +19,11 @@
package appeng.block.misc; package appeng.block.misc;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -29,39 +32,29 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
public class BlockCondenser extends AEBaseTileBlock public class BlockCondenser extends AEBaseTileBlock {
{
public BlockCondenser() public BlockCondenser() {
{ super(Material.IRON);
super( Material.IRON ); }
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (player.isSneaking()) {
if( player.isSneaking() ) return false;
{ }
return false;
}
if( Platform.isServer() ) if (Platform.isServer()) {
{ final TileCondenser tc = this.getTileEntity(w, pos);
final TileCondenser tc = this.getTileEntity( w, pos ); if (tc != null && !player.isSneaking()) {
if( tc != null && !player.isSneaking() ) Platform.openGUI(player, tc, AEPartLocation.fromFacing(side), GuiBridge.GUI_CONDENSER);
{ return true;
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CONDENSER ); }
return true; }
}
}
return true; return true;
} }
} }
@@ -19,8 +19,11 @@
package appeng.block.misc; package appeng.block.misc;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -31,53 +34,41 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
public class BlockInscriber extends AEBaseTileBlock public class BlockInscriber extends AEBaseTileBlock {
{
public BlockInscriber() public BlockInscriber() {
{ super(Material.IRON);
super( Material.IRON );
this.setLightOpacity( 2 ); this.setLightOpacity(2);
this.setFullSize( this.setOpaque( false ) ); this.setFullSize(this.setOpaque(false));
} }
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileInscriber tg = this.getTileEntity( w, pos ); final TileInscriber tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_INSCRIBER);
{ }
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INSCRIBER ); return true;
} }
return true; return false;
} }
return false;
}
@Override @Override
public EnumBlockRenderType getRenderType( IBlockState state ) public EnumBlockRenderType getRenderType(IBlockState state) {
{ return EnumBlockRenderType.MODEL;
return EnumBlockRenderType.MODEL; }
}
@Override @Override
public String getUnlocalizedName( final ItemStack is ) public String getUnlocalizedName(final ItemStack is) {
{ return super.getUnlocalizedName(is);
return super.getUnlocalizedName( is ); }
}
} }
@@ -19,8 +19,12 @@
package appeng.block.misc; package appeng.block.misc;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
@@ -33,77 +37,60 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
public class BlockInterface extends AEBaseTileBlock public class BlockInterface extends AEBaseTileBlock {
{
private static final PropertyBool OMNIDIRECTIONAL = PropertyBool.create( "omnidirectional" ); private static final PropertyBool OMNIDIRECTIONAL = PropertyBool.create("omnidirectional");
public BlockInterface() public BlockInterface() {
{ super(Material.IRON);
super( Material.IRON ); }
}
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{OMNIDIRECTIONAL};
return new IProperty[] { OMNIDIRECTIONAL }; }
}
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ // Determine whether the interface is omni-directional or not
// Determine whether the interface is omni-directional or not TileInterface te = this.getTileEntity(world, pos);
TileInterface te = this.getTileEntity( world, pos ); boolean omniDirectional = true; // The default
boolean omniDirectional = true; // The default if (te != null) {
if( te != null ) omniDirectional = te.isOmniDirectional();
{ }
omniDirectional = te.isOmniDirectional();
}
return super.getActualState( state, world, pos ) return super.getActualState(state, world, pos)
.withProperty( OMNIDIRECTIONAL, omniDirectional ); .withProperty(OMNIDIRECTIONAL, omniDirectional);
} }
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileInterface tg = this.getTileEntity( w, pos ); final TileInterface tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_INTERFACE);
{ }
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INTERFACE ); return true;
} }
return true; return false;
} }
return false;
}
@Override @Override
protected boolean hasCustomRotation() protected boolean hasCustomRotation() {
{ return true;
return true; }
}
@Override @Override
protected void customRotateBlock( final IOrientable rotatable, final EnumFacing axis ) protected void customRotateBlock(final IOrientable rotatable, final EnumFacing axis) {
{ if (rotatable instanceof TileInterface) {
if( rotatable instanceof TileInterface ) ((TileInterface) rotatable).setSide(axis);
{ }
( (TileInterface) rotatable ).setSide( axis ); }
}
}
} }
@@ -19,10 +19,12 @@
package appeng.block.misc; package appeng.block.misc;
import java.util.Collections; import appeng.api.util.IOrientable;
import java.util.List; import appeng.api.util.IOrientableBlock;
import java.util.Random; import appeng.block.AEBaseTileBlock;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileLightDetector;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@@ -39,166 +41,139 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable; import java.util.Collections;
import appeng.api.util.IOrientableBlock; import java.util.List;
import appeng.block.AEBaseTileBlock; import java.util.Random;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileLightDetector;
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock, ICustomCollision public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock, ICustomCollision {
{
// Cannot use the vanilla FACING property here because it excludes facing DOWN // Cannot use the vanilla FACING property here because it excludes facing DOWN
public static final PropertyDirection FACING = PropertyDirection.create( "facing" ); public static final PropertyDirection FACING = PropertyDirection.create("facing");
// Used to alternate between two variants of the fixture on adjacent blocks // Used to alternate between two variants of the fixture on adjacent blocks
public static final PropertyBool ODD = PropertyBool.create( "odd" ); public static final PropertyBool ODD = PropertyBool.create("odd");
public BlockLightDetector() public BlockLightDetector() {
{ super(Material.CIRCUITS);
super( Material.CIRCUITS );
this.setDefaultState( this.blockState.getBaseState().withProperty( FACING, EnumFacing.UP ).withProperty( ODD, false ) ); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.UP).withProperty(ODD, false));
this.setLightOpacity( 0 ); this.setLightOpacity(0);
this.setFullSize( false ); this.setFullSize(false);
this.setOpaque( false ); this.setOpaque(false);
} }
@Override @Override
public int getMetaFromState( final IBlockState state ) public int getMetaFromState(final IBlockState state) {
{ return state.getValue(FACING).ordinal();
return state.getValue( FACING ).ordinal(); }
}
@Override @Override
public IBlockState getStateFromMeta( final int meta ) public IBlockState getStateFromMeta(final int meta) {
{ EnumFacing facing = EnumFacing.values()[meta];
EnumFacing facing = EnumFacing.values()[meta]; return this.getDefaultState().withProperty(FACING, facing);
return this.getDefaultState().withProperty( FACING, facing ); }
}
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{FACING, ODD};
return new IProperty[] { FACING, ODD }; }
}
@Override @Override
public int getWeakPower( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side ) public int getWeakPower(final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side) {
{ if (w instanceof World && ((TileLightDetector) this.getTileEntity(w, pos)).isReady()) {
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, pos ) ).isReady() ) return ((World) w).getLightFromNeighbors(pos) - 6;
{ }
return ( (World) w ).getLightFromNeighbors( pos ) - 6;
}
return 0; return 0;
} }
@Override @Override
public void onNeighborChange( final IBlockAccess world, final BlockPos pos, final BlockPos neighbor ) public void onNeighborChange(final IBlockAccess world, final BlockPos pos, final BlockPos neighbor) {
{ super.onNeighborChange(world, pos, neighbor);
super.onNeighborChange( world, pos, neighbor );
final TileLightDetector tld = this.getTileEntity( world, pos ); final TileLightDetector tld = this.getTileEntity(world, pos);
if( tld != null ) if (tld != null) {
{ tld.updateLight();
tld.updateLight(); }
} }
}
@Override @Override
public void randomDisplayTick( final IBlockState state, final World worldIn, final BlockPos pos, final Random rand ) public void randomDisplayTick(final IBlockState state, final World worldIn, final BlockPos pos, final Random rand) {
{ // cancel out lightning
// cancel out lightning }
}
@Override @Override
public boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up ) public boolean isValidOrientation(final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up) {
{ return this.canPlaceAt(w, pos, up.getOpposite());
return this.canPlaceAt( w, pos, up.getOpposite() ); }
}
private boolean canPlaceAt( final World w, final BlockPos pos, final EnumFacing dir ) private boolean canPlaceAt(final World w, final BlockPos pos, final EnumFacing dir) {
{ return w.isSideSolid(pos.offset(dir), dir.getOpposite(), false);
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false ); }
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ final EnumFacing up = this.getOrientable(w, pos).getUp();
final EnumFacing up = this.getOrientable( w, pos ).getUp(); final double xOff = -0.3 * up.getFrontOffsetX();
final double xOff = -0.3 * up.getFrontOffsetX(); final double yOff = -0.3 * up.getFrontOffsetY();
final double yOff = -0.3 * up.getFrontOffsetY(); final double zOff = -0.3 * up.getFrontOffsetZ();
final double zOff = -0.3 * up.getFrontOffsetZ(); return Collections.singletonList(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
return Collections.singletonList( new AxisAlignedBB( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) ); }
}
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {/*
{/* * double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 *
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * * getUp().offsetY; double zOff = -0.15 * getUp().offsetZ; out.add(
* getUp().offsetY; double zOff = -0.15 * getUp().offsetZ; out.add( * AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff +
* AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + * (double) y + 0.15, zOff + (double) z + 0.15,// ahh xOff + (double) x
* (double) y + 0.15, zOff + (double) z + 0.15,// ahh xOff + (double) x * + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
* + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) ); */
*/ }
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final EnumFacing up = this.getOrientable(world, pos).getUp();
final EnumFacing up = this.getOrientable( world, pos ).getUp(); if (!this.canPlaceAt(world, pos, up.getOpposite())) {
if( !this.canPlaceAt( world, pos, up.getOpposite() ) ) this.dropTorch(world, pos);
{ }
this.dropTorch( world, pos ); }
}
}
private void dropTorch( final World w, final BlockPos pos ) private void dropTorch(final World w, final BlockPos pos) {
{ final IBlockState prev = w.getBlockState(pos);
final IBlockState prev = w.getBlockState( pos ); w.destroyBlock(pos, true);
w.destroyBlock( pos, true ); w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 ); }
}
@Override @Override
public boolean canPlaceBlockAt( final World w, final BlockPos pos ) public boolean canPlaceBlockAt(final World w, final BlockPos pos) {
{ for (final EnumFacing dir : EnumFacing.VALUES) {
for( final EnumFacing dir : EnumFacing.VALUES ) if (this.canPlaceAt(w, pos, dir)) {
{ return true;
if( this.canPlaceAt( w, pos, dir ) ) }
{ }
return true; return false;
} }
}
return false;
}
@Override @Override
public boolean usesMetadata() public boolean usesMetadata() {
{ return false;
return false; }
}
@Override @Override
public boolean isFullCube( IBlockState state ) public boolean isFullCube(IBlockState state) {
{ return false;
return false; }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
@Override @Override
public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos ) public IOrientable getOrientable(final IBlockAccess w, final BlockPos pos) {
{ return new MetaRotation(w, pos, FACING);
return new MetaRotation( w, pos, FACING ); }
}
} }
@@ -19,10 +19,14 @@
package appeng.block.misc; package appeng.block.misc;
import java.util.Collections; import appeng.api.util.IOrientable;
import java.util.List; import appeng.api.util.IOrientableBlock;
import java.util.Random; import appeng.block.AEBaseBlock;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@@ -40,187 +44,156 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable; import java.util.Collections;
import appeng.api.util.IOrientableBlock; import java.util.List;
import appeng.block.AEBaseBlock; import java.util.Random;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock, ICustomCollision public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock, ICustomCollision {
{
// Cannot use the vanilla FACING property here because it excludes facing DOWN // Cannot use the vanilla FACING property here because it excludes facing DOWN
public static final PropertyDirection FACING = PropertyDirection.create( "facing" ); public static final PropertyDirection FACING = PropertyDirection.create("facing");
// Used to alternate between two variants of the fixture on adjacent blocks // Used to alternate between two variants of the fixture on adjacent blocks
public static final PropertyBool ODD = PropertyBool.create( "odd" ); public static final PropertyBool ODD = PropertyBool.create("odd");
public BlockQuartzFixture() public BlockQuartzFixture() {
{ super(Material.CIRCUITS);
super( Material.CIRCUITS );
this.setDefaultState( this.blockState.getBaseState().withProperty( FACING, EnumFacing.UP ).withProperty( ODD, false ) ); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.UP).withProperty(ODD, false));
this.setLightLevel( 0.9375F ); this.setLightLevel(0.9375F);
this.setLightOpacity( 0 ); this.setLightOpacity(0);
this.setFullSize( false ); this.setFullSize(false);
this.setOpaque( false ); this.setOpaque(false);
} }
/** /**
* Sets the "ODD" property of the block state according to the placement of the block. * Sets the "ODD" property of the block state according to the placement of the block.
*/ */
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos ) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
{ boolean oddPlacement = ((pos.getX() + pos.getY() + pos.getZ()) % 2) != 0;
boolean oddPlacement = ( ( pos.getX() + pos.getY() + pos.getZ() ) % 2 ) != 0;
return super.getActualState( state, worldIn, pos ) return super.getActualState(state, worldIn, pos)
.withProperty( ODD, oddPlacement ); .withProperty(ODD, oddPlacement);
} }
@Override @Override
public int getMetaFromState( final IBlockState state ) public int getMetaFromState(final IBlockState state) {
{ return state.getValue(FACING).ordinal();
return state.getValue( FACING ).ordinal(); }
}
@Override @Override
public IBlockState getStateFromMeta( final int meta ) public IBlockState getStateFromMeta(final int meta) {
{ EnumFacing facing = EnumFacing.values()[meta];
EnumFacing facing = EnumFacing.values()[meta]; return this.getDefaultState().withProperty(FACING, facing);
return this.getDefaultState().withProperty( FACING, facing ); }
}
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{FACING, ODD};
return new IProperty[] { FACING, ODD }; }
}
@Override @Override
public boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up ) public boolean isValidOrientation(final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up) {
{ return this.canPlaceAt(w, pos, up.getOpposite());
return this.canPlaceAt( w, pos, up.getOpposite() ); }
}
private boolean canPlaceAt( final World w, final BlockPos pos, final EnumFacing dir ) private boolean canPlaceAt(final World w, final BlockPos pos, final EnumFacing dir) {
{ final BlockPos test = pos.offset(dir);
final BlockPos test = pos.offset( dir ); return w.isSideSolid(test, dir.getOpposite(), false);
return w.isSideSolid( test, dir.getOpposite(), false ); }
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity e, final boolean isVisual ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity e, final boolean isVisual) {
{ final EnumFacing up = this.getOrientable(w, pos).getUp();
final EnumFacing up = this.getOrientable( w, pos ).getUp(); final double xOff = -0.3 * up.getFrontOffsetX();
final double xOff = -0.3 * up.getFrontOffsetX(); final double yOff = -0.3 * up.getFrontOffsetY();
final double yOff = -0.3 * up.getFrontOffsetY(); final double zOff = -0.3 * up.getFrontOffsetZ();
final double zOff = -0.3 * up.getFrontOffsetZ(); return Collections.singletonList(new AxisAlignedBB(xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7));
return Collections.singletonList( new AxisAlignedBB( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) ); }
}
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List out, final Entity e) {/*
{/* * double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 * * getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15,
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, * zOff
* zOff * + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) ); */
*/ }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r ) public void randomDisplayTick(final IBlockState state, final World w, final BlockPos pos, final Random r) {
{ if (!AEConfig.instance().isEnableEffects()) {
if( !AEConfig.instance().isEnableEffects() ) return;
{ }
return;
}
if( r.nextFloat() < 0.98 ) if (r.nextFloat() < 0.98) {
{ return;
return; }
}
final EnumFacing up = this.getOrientable( w, pos ).getUp(); final EnumFacing up = this.getOrientable(w, pos).getUp();
final double xOff = -0.3 * up.getFrontOffsetX(); final double xOff = -0.3 * up.getFrontOffsetX();
final double yOff = -0.3 * up.getFrontOffsetY(); final double yOff = -0.3 * up.getFrontOffsetY();
final double zOff = -0.3 * up.getFrontOffsetZ(); final double zOff = -0.3 * up.getFrontOffsetZ();
for( int bolts = 0; bolts < 3; bolts++ ) for (int bolts = 0; bolts < 3; bolts++) {
{ if (AppEng.proxy.shouldAddParticles(r)) {
if( AppEng.proxy.shouldAddParticles( r ) ) final LightningFX fx = new LightningFX(w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D);
{
final LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx ); Minecraft.getMinecraft().effectRenderer.addEffect(fx);
} }
} }
} }
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final EnumFacing up = this.getOrientable(world, pos).getUp();
final EnumFacing up = this.getOrientable( world, pos ).getUp(); if (!this.canPlaceAt(world, pos, up.getOpposite())) {
if( !this.canPlaceAt( world, pos, up.getOpposite() ) ) this.dropTorch(world, pos);
{ }
this.dropTorch( world, pos ); }
}
}
private void dropTorch( final World w, final BlockPos pos ) private void dropTorch(final World w, final BlockPos pos) {
{ final IBlockState prev = w.getBlockState(pos);
final IBlockState prev = w.getBlockState( pos ); w.destroyBlock(pos, true);
w.destroyBlock( pos, true ); w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 ); }
}
@Override @Override
public boolean canPlaceBlockAt( final World w, final BlockPos pos ) public boolean canPlaceBlockAt(final World w, final BlockPos pos) {
{ for (final EnumFacing dir : EnumFacing.VALUES) {
for( final EnumFacing dir : EnumFacing.VALUES ) if (this.canPlaceAt(w, pos, dir)) {
{ return true;
if( this.canPlaceAt( w, pos, dir ) ) }
{ }
return true; return false;
} }
}
return false;
}
@Override @Override
public boolean usesMetadata() public boolean usesMetadata() {
{ return true;
return true; }
}
@Override @Override
public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos ) public IOrientable getOrientable(final IBlockAccess w, final BlockPos pos) {
{ return new MetaRotation(w, pos, FACING);
return new MetaRotation( w, pos, FACING ); }
}
@Override @Override
public boolean isOpaque() public boolean isOpaque() {
{ return false;
return false; }
}
@Override @Override
public boolean isFullCube( IBlockState state ) public boolean isFullCube(IBlockState state) {
{ return false;
return false; }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
} }
@@ -19,8 +19,13 @@
package appeng.block.misc; package appeng.block.misc;
import java.util.Random; import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.tile.misc.TileQuartzGrowthAccelerator;
import appeng.util.Platform;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@@ -34,129 +39,113 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientableBlock; import java.util.Random;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.tile.misc.TileQuartzGrowthAccelerator;
import appeng.util.Platform;
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOrientableBlock public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOrientableBlock {
{
private static final PropertyBool POWERED = PropertyBool.create( "powered" ); private static final PropertyBool POWERED = PropertyBool.create("powered");
public BlockQuartzGrowthAccelerator() public BlockQuartzGrowthAccelerator() {
{ super(Material.ROCK);
super( Material.ROCK ); this.setSoundType(SoundType.METAL);
this.setSoundType( SoundType.METAL ); this.setDefaultState(this.getDefaultState().withProperty(POWERED, false));
this.setDefaultState( this.getDefaultState().withProperty( POWERED, false ) ); }
}
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ TileQuartzGrowthAccelerator te = this.getTileEntity(world, pos);
TileQuartzGrowthAccelerator te = this.getTileEntity( world, pos ); boolean powered = te != null && te.isPowered();
boolean powered = te != null && te.isPowered();
return super.getActualState( state, world, pos ) return super.getActualState(state, world, pos)
.withProperty( POWERED, powered ); .withProperty(POWERED, powered);
} }
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{POWERED};
return new IProperty[] { POWERED }; }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
@Override @Override
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r ) public void randomDisplayTick(final IBlockState state, final World w, final BlockPos pos, final Random r) {
{ if (!AEConfig.instance().isEnableEffects()) {
if( !AEConfig.instance().isEnableEffects() ) return;
{ }
return;
}
final TileQuartzGrowthAccelerator cga = this.getTileEntity( w, pos ); final TileQuartzGrowthAccelerator cga = this.getTileEntity(w, pos);
if( cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles( r ) ) if (cga != null && cga.isPowered() && AppEng.proxy.shouldAddParticles(r)) {
{ final double d0 = r.nextFloat() - 0.5F;
final double d0 = r.nextFloat() - 0.5F; final double d1 = r.nextFloat() - 0.5F;
final double d1 = r.nextFloat() - 0.5F;
final EnumFacing up = cga.getUp(); final EnumFacing up = cga.getUp();
final EnumFacing forward = cga.getForward(); final EnumFacing forward = cga.getForward();
final EnumFacing west = Platform.crossProduct( forward, up ); final EnumFacing west = Platform.crossProduct(forward, up);
double rx = 0.5 + pos.getX(); double rx = 0.5 + pos.getX();
double ry = 0.5 + pos.getY(); double ry = 0.5 + pos.getY();
double rz = 0.5 + pos.getZ(); double rz = 0.5 + pos.getZ();
rx += up.getFrontOffsetX() * d0; rx += up.getFrontOffsetX() * d0;
ry += up.getFrontOffsetY() * d0; ry += up.getFrontOffsetY() * d0;
rz += up.getFrontOffsetZ() * d0; rz += up.getFrontOffsetZ() * d0;
final int x = pos.getX(); final int x = pos.getX();
final int y = pos.getY(); final int y = pos.getY();
final int z = pos.getZ(); final int z = pos.getZ();
double dz = 0; double dz = 0;
double dx = 0; double dx = 0;
BlockPos pt = null; BlockPos pt = null;
switch( r.nextInt( 4 ) ) switch (r.nextInt(4)) {
{ case 0:
case 0: dx = 0.6;
dx = 0.6; dz = d1;
dz = d1; pt = new BlockPos(x + west.getFrontOffsetX(), y + west.getFrontOffsetY(), z + west.getFrontOffsetZ());
pt = new BlockPos( x + west.getFrontOffsetX(), y + west.getFrontOffsetY(), z + west.getFrontOffsetZ() );
break; break;
case 1: case 1:
dx = d1; dx = d1;
dz += 0.6; dz += 0.6;
pt = new BlockPos( x + forward.getFrontOffsetX(), y + forward.getFrontOffsetY(), z + forward.getFrontOffsetZ() ); pt = new BlockPos(x + forward.getFrontOffsetX(), y + forward.getFrontOffsetY(), z + forward.getFrontOffsetZ());
break; break;
case 2: case 2:
dx = d1; dx = d1;
dz = -0.6; dz = -0.6;
pt = new BlockPos( x - forward.getFrontOffsetX(), y - forward.getFrontOffsetY(), z - forward.getFrontOffsetZ() ); pt = new BlockPos(x - forward.getFrontOffsetX(), y - forward.getFrontOffsetY(), z - forward.getFrontOffsetZ());
break; break;
case 3: case 3:
dx = -0.6; dx = -0.6;
dz = d1; dz = d1;
pt = new BlockPos( x - west.getFrontOffsetX(), y - west.getFrontOffsetY(), z - west.getFrontOffsetZ() ); pt = new BlockPos(x - west.getFrontOffsetX(), y - west.getFrontOffsetY(), z - west.getFrontOffsetZ());
break; break;
} }
if( !w.getBlockState( pt ).getBlock().isAir( w.getBlockState( pt ), w, pt ) ) if (!w.getBlockState(pt).getBlock().isAir(w.getBlockState(pt), w, pt)) {
{ return;
return; }
}
rx += dx * west.getFrontOffsetX(); rx += dx * west.getFrontOffsetX();
ry += dx * west.getFrontOffsetY(); ry += dx * west.getFrontOffsetY();
rz += dx * west.getFrontOffsetZ(); rz += dx * west.getFrontOffsetZ();
rx += dz * forward.getFrontOffsetX(); rx += dz * forward.getFrontOffsetX();
ry += dz * forward.getFrontOffsetY(); ry += dz * forward.getFrontOffsetY();
rz += dz * forward.getFrontOffsetZ(); rz += dz * forward.getFrontOffsetZ();
final LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D ); final LightningFX fx = new LightningFX(w, rx, ry, rz, 0.0D, 0.0D, 0.0D);
Minecraft.getMinecraft().effectRenderer.addEffect( fx ); Minecraft.getMinecraft().effectRenderer.addEffect(fx);
} }
} }
@Override @Override
public boolean usesMetadata() public boolean usesMetadata() {
{ return false;
return false; }
}
} }
@@ -19,8 +19,11 @@
package appeng.block.misc; package appeng.block.misc;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileSecurityStation;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
@@ -34,70 +37,56 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileSecurityStation;
import appeng.util.Platform;
public class BlockSecurityStation extends AEBaseTileBlock public class BlockSecurityStation extends AEBaseTileBlock {
{
private static final PropertyBool POWERED = PropertyBool.create( "powered" ); private static final PropertyBool POWERED = PropertyBool.create("powered");
public BlockSecurityStation() public BlockSecurityStation() {
{ super(Material.IRON);
super( Material.IRON );
this.setDefaultState( this.getDefaultState().withProperty( POWERED, false ) ); this.setDefaultState(this.getDefaultState().withProperty(POWERED, false));
} }
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{POWERED};
return new IProperty[] { POWERED }; }
}
@Override @Override
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ boolean powered = false;
boolean powered = false; TileSecurityStation te = this.getTileEntity(world, pos);
TileSecurityStation te = this.getTileEntity( world, pos ); if (te != null) {
if( te != null ) powered = te.isActive();
{ }
powered = te.isActive();
}
return super.getActualState( state, world, pos ) return super.getActualState(state, world, pos)
.withProperty( POWERED, powered ); .withProperty(POWERED, powered);
} }
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileSecurityStation tg = this.getTileEntity( w, pos ); final TileSecurityStation tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isClient()) {
if( Platform.isClient() ) return true;
{ }
return true;
}
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_SECURITY ); Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_SECURITY);
return true; return true;
} }
return false; return false;
} }
} }
@@ -19,9 +19,9 @@
package appeng.block.misc; package appeng.block.misc;
import java.util.Collections; import appeng.block.AEBaseTileBlock;
import java.util.List; import appeng.helpers.ICustomCollision;
import appeng.tile.misc.TileSkyCompass;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
@@ -36,156 +36,137 @@ import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.PropertyFloat; import net.minecraftforge.common.property.PropertyFloat;
import appeng.block.AEBaseTileBlock; import java.util.Collections;
import appeng.helpers.ICustomCollision; import java.util.List;
import appeng.tile.misc.TileSkyCompass;
public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision {
{
// Rotation is expressed as radians // Rotation is expressed as radians
public static final PropertyFloat ROTATION = new PropertyFloat( "rotation" ); public static final PropertyFloat ROTATION = new PropertyFloat("rotation");
public BlockSkyCompass() public BlockSkyCompass() {
{ super(Material.CIRCUITS);
super( Material.CIRCUITS ); this.setLightOpacity(0);
this.setLightOpacity( 0 ); this.setFullSize(false);
this.setFullSize( false ); this.setOpaque(false);
this.setOpaque( false ); }
}
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{FORWARD, UP, ROTATION});
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { FORWARD, UP, ROTATION } ); }
}
@Override @Override
public boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up ) public boolean isValidOrientation(final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up) {
{ final TileSkyCompass sc = this.getTileEntity(w, pos);
final TileSkyCompass sc = this.getTileEntity( w, pos ); if (sc != null) {
if( sc != null ) return false;
{ }
return false; return this.canPlaceAt(w, pos, forward.getOpposite());
} }
return this.canPlaceAt( w, pos, forward.getOpposite() );
}
private boolean canPlaceAt( final World w, final BlockPos pos, final EnumFacing dir ) private boolean canPlaceAt(final World w, final BlockPos pos, final EnumFacing dir) {
{ return w.isSideSolid(pos.offset(dir), dir.getOpposite(), false);
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false ); }
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final TileSkyCompass sc = this.getTileEntity(world, pos);
final TileSkyCompass sc = this.getTileEntity( world, pos ); final EnumFacing forward = sc.getForward();
final EnumFacing forward = sc.getForward(); if (!this.canPlaceAt(world, pos, forward.getOpposite())) {
if( !this.canPlaceAt( world, pos, forward.getOpposite() ) ) this.dropTorch(world, pos);
{ }
this.dropTorch( world, pos ); }
}
}
private void dropTorch( final World w, final BlockPos pos ) private void dropTorch(final World w, final BlockPos pos) {
{ final IBlockState prev = w.getBlockState(pos);
final IBlockState prev = w.getBlockState( pos ); w.destroyBlock(pos, true);
w.destroyBlock( pos, true ); w.notifyBlockUpdate(pos, prev, w.getBlockState(pos), 3);
w.notifyBlockUpdate( pos, prev, w.getBlockState( pos ), 3 ); }
}
@Override @Override
public boolean canPlaceBlockAt( final World w, final BlockPos pos ) public boolean canPlaceBlockAt(final World w, final BlockPos pos) {
{ for (final EnumFacing dir : EnumFacing.VALUES) {
for( final EnumFacing dir : EnumFacing.VALUES ) if (this.canPlaceAt(w, pos, dir)) {
{ return true;
if( this.canPlaceAt( w, pos, dir ) ) }
{ }
return true; return false;
} }
}
return false;
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ final TileSkyCompass tile = this.getTileEntity(w, pos);
final TileSkyCompass tile = this.getTileEntity( w, pos ); if (tile != null) {
if( tile != null ) final EnumFacing forward = tile.getForward();
{
final EnumFacing forward = tile.getForward();
double minX = 0; double minX = 0;
double minY = 0; double minY = 0;
double minZ = 0; double minZ = 0;
double maxX = 1; double maxX = 1;
double maxY = 1; double maxY = 1;
double maxZ = 1; double maxZ = 1;
switch( forward ) switch (forward) {
{ case DOWN:
case DOWN: minZ = minX = 5.0 / 16.0;
minZ = minX = 5.0 / 16.0; maxZ = maxX = 11.0 / 16.0;
maxZ = maxX = 11.0 / 16.0; maxY = 1.0;
maxY = 1.0; minY = 14.0 / 16.0;
minY = 14.0 / 16.0; break;
break; case EAST:
case EAST: minZ = minY = 5.0 / 16.0;
minZ = minY = 5.0 / 16.0; maxZ = maxY = 11.0 / 16.0;
maxZ = maxY = 11.0 / 16.0; maxX = 2.0 / 16.0;
maxX = 2.0 / 16.0; minX = 0.0;
minX = 0.0; break;
break; case NORTH:
case NORTH: minY = minX = 5.0 / 16.0;
minY = minX = 5.0 / 16.0; maxY = maxX = 11.0 / 16.0;
maxY = maxX = 11.0 / 16.0; maxZ = 1.0;
maxZ = 1.0; minZ = 14.0 / 16.0;
minZ = 14.0 / 16.0; break;
break; case SOUTH:
case SOUTH: minY = minX = 5.0 / 16.0;
minY = minX = 5.0 / 16.0; maxY = maxX = 11.0 / 16.0;
maxY = maxX = 11.0 / 16.0; maxZ = 2.0 / 16.0;
maxZ = 2.0 / 16.0; minZ = 0.0;
minZ = 0.0; break;
break; case UP:
case UP: minZ = minX = 5.0 / 16.0;
minZ = minX = 5.0 / 16.0; maxZ = maxX = 11.0 / 16.0;
maxZ = maxX = 11.0 / 16.0; maxY = 2.0 / 16.0;
maxY = 2.0 / 16.0; minY = 0.0;
minY = 0.0; break;
break; case WEST:
case WEST: minZ = minY = 5.0 / 16.0;
minZ = minY = 5.0 / 16.0; maxZ = maxY = 11.0 / 16.0;
maxZ = maxY = 11.0 / 16.0; maxX = 1.0;
maxX = 1.0; minX = 14.0 / 16.0;
minX = 14.0 / 16.0; break;
break; default:
default: break;
break; }
}
return Collections.singletonList( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) ); return Collections.singletonList(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
} }
return Collections.singletonList( new AxisAlignedBB( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) ); return Collections.singletonList(new AxisAlignedBB(0.0, 0, 0.0, 1.0, 1.0, 1.0));
} }
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{
} }
@Override @Override
public EnumBlockRenderType getRenderType( IBlockState state ) public EnumBlockRenderType getRenderType(IBlockState state) {
{ return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; }
}
@Override @Override
public boolean isFullBlock( IBlockState state ) public boolean isFullBlock(IBlockState state) {
{ return false;
return false; }
}
} }
+86 -109
View File
@@ -19,11 +19,9 @@
package appeng.block.misc; package appeng.block.misc;
import java.util.Collections; import appeng.block.AEBaseBlock;
import java.util.List; import appeng.entity.EntityTinyTNTPrimed;
import appeng.helpers.ICustomCollision;
import javax.annotation.Nullable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -43,126 +41,105 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion; import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseBlock; import javax.annotation.Nullable;
import appeng.entity.EntityTinyTNTPrimed; import java.util.Collections;
import appeng.helpers.ICustomCollision; import java.util.List;
public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision {
{
public BlockTinyTNT() public BlockTinyTNT() {
{ super(Material.TNT);
super( Material.TNT );
this.boundingBox = new AxisAlignedBB( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f ); this.boundingBox = new AxisAlignedBB(0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f);
this.setLightOpacity( 2 ); this.setLightOpacity(2);
this.setFullSize( false ); this.setFullSize(false);
this.setOpaque( false ); this.setOpaque(false);
this.setSoundType( SoundType.GROUND ); this.setSoundType(SoundType.GROUND);
this.setHardness( 0F ); this.setHardness(0F);
} }
@Override @Override
public boolean isFullCube( IBlockState state ) public boolean isFullCube(IBlockState state) {
{ return false;
return false; }
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL) {
if( heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL ) this.startFuse(w, pos, player);
{ w.setBlockToAir(pos);
this.startFuse( w, pos, player ); heldItem.damageItem(1, player);
w.setBlockToAir( pos ); return true;
heldItem.damageItem( 1, player ); } else {
return true; return super.onActivated(w, pos, player, hand, heldItem, side, hitX, hitY, hitZ);
} }
else }
{
return super.onActivated( w, pos, player, hand, heldItem, side, hitX, hitY, hitZ );
}
}
public void startFuse( final World w, final BlockPos pos, final EntityLivingBase igniter ) public void startFuse(final World w, final BlockPos pos, final EntityLivingBase igniter) {
{ if (!w.isRemote) {
if( !w.isRemote ) final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed(w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
{ w.spawnEntity(primedTinyTNTEntity);
final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter ); w.playSound(null, primedTinyTNTEntity.posX, primedTinyTNTEntity.posY, primedTinyTNTEntity.posZ, SoundEvents.ENTITY_TNT_PRIMED,
w.spawnEntity( primedTinyTNTEntity ); SoundCategory.BLOCKS, 1, 1);
w.playSound( null, primedTinyTNTEntity.posX, primedTinyTNTEntity.posY, primedTinyTNTEntity.posZ, SoundEvents.ENTITY_TNT_PRIMED, }
SoundCategory.BLOCKS, 1, 1 ); }
}
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ if (world.isBlockIndirectlyGettingPowered(pos) > 0) {
if( world.isBlockIndirectlyGettingPowered( pos ) > 0 ) this.startFuse(world, pos, null);
{ world.setBlockToAir(pos);
this.startFuse( world, pos, null ); }
world.setBlockToAir( pos ); }
}
}
@Override @Override
public void onBlockAdded( final World w, final BlockPos pos, final IBlockState state ) public void onBlockAdded(final World w, final BlockPos pos, final IBlockState state) {
{ super.onBlockAdded(w, pos, state);
super.onBlockAdded( w, pos, state );
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 ) if (w.isBlockIndirectlyGettingPowered(pos) > 0) {
{ this.startFuse(w, pos, null);
this.startFuse( w, pos, null ); w.setBlockToAir(pos);
w.setBlockToAir( pos ); }
} }
}
@Override @Override
public void onEntityWalk( final World w, final BlockPos pos, final Entity entity ) public void onEntityWalk(final World w, final BlockPos pos, final Entity entity) {
{ if (entity instanceof EntityArrow && !w.isRemote) {
if( entity instanceof EntityArrow && !w.isRemote ) final EntityArrow entityarrow = (EntityArrow) entity;
{
final EntityArrow entityarrow = (EntityArrow) entity;
if( entityarrow.isBurning() ) if (entityarrow.isBurning()) {
{ this.startFuse(w, pos, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null);
this.startFuse( w, pos, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null ); w.setBlockToAir(pos);
w.setBlockToAir( pos ); }
} }
} }
}
@Override @Override
public boolean canDropFromExplosion( final Explosion exp ) public boolean canDropFromExplosion(final Explosion exp) {
{ return false;
return false; }
}
@Override @Override
public void onBlockExploded( final World w, final BlockPos pos, final Explosion exp ) public void onBlockExploded(final World w, final BlockPos pos, final Explosion exp) {
{ super.onBlockExploded(w, pos, exp);
super.onBlockExploded( w, pos, exp ); if (!w.isRemote) {
if( !w.isRemote ) final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed(w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp
{ .getExplosivePlacedBy());
final EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp primedTinyTNTEntity.setFuse(w.rand.nextInt(primedTinyTNTEntity.getFuse() / 4) + primedTinyTNTEntity.getFuse() / 8);
.getExplosivePlacedBy() ); w.spawnEntity(primedTinyTNTEntity);
primedTinyTNTEntity.setFuse( w.rand.nextInt( primedTinyTNTEntity.getFuse() / 4 ) + primedTinyTNTEntity.getFuse() / 8 ); }
w.spawnEntity( primedTinyTNTEntity ); }
}
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ return Collections.singletonList(new AxisAlignedBB(0.25, 0, 0.25, 0.75, 0.5, 0.75));
return Collections.singletonList( new AxisAlignedBB( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) ); }
}
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{ out.add(new AxisAlignedBB(0.25, 0, 0.25, 0.75, 0.5, 0.75));
out.add( new AxisAlignedBB( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) ); }
}
} }
@@ -19,10 +19,13 @@
package appeng.block.misc; package appeng.block.misc;
import java.util.Random; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import javax.annotation.Nullable; import appeng.core.AEConfig;
import appeng.core.sync.GuiBridge;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
@@ -36,108 +39,91 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock; import java.util.Random;
import appeng.core.AEConfig;
import appeng.core.sync.GuiBridge;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
public final class BlockVibrationChamber extends AEBaseTileBlock public final class BlockVibrationChamber extends AEBaseTileBlock {
{
// Indicates that the vibration chamber is currently working // Indicates that the vibration chamber is currently working
private static final PropertyBool ACTIVE = PropertyBool.create( "active" ); private static final PropertyBool ACTIVE = PropertyBool.create("active");
public BlockVibrationChamber() public BlockVibrationChamber() {
{ super(Material.IRON);
super( Material.IRON ); this.setHardness(4.2F);
this.setHardness( 4.2F ); this.setDefaultState(this.getDefaultState().withProperty(ACTIVE, false));
this.setDefaultState( this.getDefaultState().withProperty( ACTIVE, false ) ); }
}
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ TileVibrationChamber te = this.getTileEntity(world, pos);
TileVibrationChamber te = this.getTileEntity( world, pos ); boolean active = te != null && te.isOn;
boolean active = te != null && te.isOn;
return super.getActualState( state, world, pos ) return super.getActualState(state, world, pos)
.withProperty( ACTIVE, active ); .withProperty(ACTIVE, active);
} }
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{ACTIVE};
return new IProperty[] { ACTIVE }; }
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (player.isSneaking()) {
if( player.isSneaking() ) return false;
{ }
return false;
}
if( Platform.isServer() ) if (Platform.isServer()) {
{ final TileVibrationChamber tc = this.getTileEntity(w, pos);
final TileVibrationChamber tc = this.getTileEntity( w, pos ); if (tc != null && !player.isSneaking()) {
if( tc != null && !player.isSneaking() ) Platform.openGUI(player, tc, AEPartLocation.fromFacing(side), GuiBridge.GUI_VIBRATION_CHAMBER);
{ return true;
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_VIBRATION_CHAMBER ); }
return true; }
}
}
return true; return true;
} }
@Override @Override
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r ) public void randomDisplayTick(final IBlockState state, final World w, final BlockPos pos, final Random r) {
{ if (!AEConfig.instance().isEnableEffects()) {
if( !AEConfig.instance().isEnableEffects() ) return;
{ }
return;
}
final AEBaseTile tile = this.getTileEntity( w, pos ); final AEBaseTile tile = this.getTileEntity(w, pos);
if( tile instanceof TileVibrationChamber ) if (tile instanceof TileVibrationChamber) {
{ final TileVibrationChamber tc = (TileVibrationChamber) tile;
final TileVibrationChamber tc = (TileVibrationChamber) tile; if (tc.isOn) {
if( tc.isOn ) float f1 = pos.getX() + 0.5F;
{ float f2 = pos.getY() + 0.5F;
float f1 = pos.getX() + 0.5F; float f3 = pos.getZ() + 0.5F;
float f2 = pos.getY() + 0.5F;
float f3 = pos.getZ() + 0.5F;
final EnumFacing forward = tc.getForward(); final EnumFacing forward = tc.getForward();
final EnumFacing up = tc.getUp(); final EnumFacing up = tc.getUp();
final int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY(); final int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY();
final int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ(); final int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ();
final int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX(); final int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX();
f1 += forward.getFrontOffsetX() * 0.6; f1 += forward.getFrontOffsetX() * 0.6;
f2 += forward.getFrontOffsetY() * 0.6; f2 += forward.getFrontOffsetY() * 0.6;
f3 += forward.getFrontOffsetZ() * 0.6; f3 += forward.getFrontOffsetZ() * 0.6;
final float ox = r.nextFloat(); final float ox = r.nextFloat();
final float oy = r.nextFloat() * 0.2f; final float oy = r.nextFloat() * 0.2f;
f1 += up.getFrontOffsetX() * ( -0.3 + oy ); f1 += up.getFrontOffsetX() * (-0.3 + oy);
f2 += up.getFrontOffsetY() * ( -0.3 + oy ); f2 += up.getFrontOffsetY() * (-0.3 + oy);
f3 += up.getFrontOffsetZ() * ( -0.3 + oy ); f3 += up.getFrontOffsetZ() * (-0.3 + oy);
f1 += west_x * ( 0.3 * ox - 0.15 ); f1 += west_x * (0.3 * ox - 0.15);
f2 += west_y * ( 0.3 * ox - 0.15 ); f2 += west_y * (0.3 * ox - 0.15);
f3 += west_z * ( 0.3 * ox - 0.15 ); f3 += west_z * (0.3 * ox - 0.15);
w.spawnParticle( EnumParticleTypes.SMOKE_NORMAL, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] ); w.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f1, f2, f3, 0.0D, 0.0D, 0.0D);
w.spawnParticle( EnumParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] ); w.spawnParticle(EnumParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D);
} }
} }
} }
} }
@@ -1,24 +1,20 @@
package appeng.block.misc; package appeng.block.misc;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.tesr.InscriberTESR; import appeng.client.render.tesr.InscriberTESR;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class InscriberRendering extends BlockRenderingCustomizer public class InscriberRendering extends BlockRenderingCustomizer {
{
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
@Override @Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.tesr(new InscriberTESR());
rendering.tesr( new InscriberTESR() ); }
}
} }
@@ -19,25 +19,22 @@
package appeng.block.misc; package appeng.block.misc;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.ColorableTileBlockColor; import appeng.client.render.ColorableTileBlockColor;
import appeng.client.render.StaticItemColor; import appeng.client.render.StaticItemColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class SecurityStationRendering extends BlockRenderingCustomizer public class SecurityStationRendering extends BlockRenderingCustomizer {
{
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.blockColor(ColorableTileBlockColor.INSTANCE);
rendering.blockColor( ColorableTileBlockColor.INSTANCE ); itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
itemRendering.color( new StaticItemColor( AEColor.TRANSPARENT ) ); }
}
} }
@@ -19,29 +19,26 @@
package appeng.block.misc; package appeng.block.misc;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.model.SkyCompassModel; import appeng.client.render.model.SkyCompassModel;
import appeng.client.render.tesr.SkyCompassTESR; import appeng.client.render.tesr.SkyCompassTESR;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class SkyCompassRendering extends BlockRenderingCustomizer public class SkyCompassRendering extends BlockRenderingCustomizer {
{
private static final ModelResourceLocation ITEM_MODEL = new ModelResourceLocation( "appliedenergistics2:sky_compass", "normal" ); private static final ModelResourceLocation ITEM_MODEL = new ModelResourceLocation("appliedenergistics2:sky_compass", "normal");
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.tesr(new SkyCompassTESR());
rendering.tesr( new SkyCompassTESR() ); itemRendering.model(ITEM_MODEL);
itemRendering.model( ITEM_MODEL ); itemRendering.builtInModel("models/block/builtin/sky_compass", new SkyCompassModel());
itemRendering.builtInModel( "models/block/builtin/sky_compass", new SkyCompassModel() ); }
}
} }
@@ -19,14 +19,32 @@
package appeng.block.networking; package appeng.block.networking;
import java.util.EnumSet; import appeng.api.parts.IFacadeContainer;
import java.util.List; import appeng.api.parts.IFacadePart;
import java.util.Random; import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import javax.annotation.Nullable; import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.UnlistedProperty;
import appeng.client.render.cablebus.CableBusBakedModel;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial;
import appeng.integration.abstraction.IAEFacade;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.CableBusTESR;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR;
import appeng.util.Platform;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -61,439 +79,378 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.parts.IFacadeContainer; import javax.annotation.Nullable;
import appeng.api.parts.IFacadePart; import java.util.EnumSet;
import appeng.api.parts.PartItemStack; import java.util.List;
import appeng.api.parts.SelectedPart; import java.util.Random;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock; public class BlockCableBus extends AEBaseTileBlock implements IAEFacade {
import appeng.client.UnlistedProperty;
import appeng.client.render.cablebus.CableBusBakedModel; public static final UnlistedProperty<CableBusRenderState> RENDER_STATE_PROPERTY = new UnlistedProperty<>("cable_bus_render_state", CableBusRenderState.class);
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.Api; private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler; private static Class<? extends AEBaseTile> noTesrTile;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial; private static Class<? extends AEBaseTile> tesrTile;
import appeng.integration.abstraction.IAEFacade;
import appeng.parts.ICableBusContainer; public BlockCableBus() {
import appeng.parts.NullCableBusContainer; super(AEGlassMaterial.INSTANCE);
import appeng.tile.AEBaseTile; this.setLightOpacity(0);
import appeng.tile.networking.CableBusTESR; this.setFullSize(false);
import appeng.tile.networking.TileCableBus; this.setOpaque(false);
import appeng.tile.networking.TileCableBusTESR;
import appeng.util.Platform; // this will actually be overwritten later through setupTile and the
// combined layers
this.setTileEntity(TileCableBus.class);
public class BlockCableBus extends AEBaseTileBlock implements IAEFacade }
{
@Override
public static final UnlistedProperty<CableBusRenderState> RENDER_STATE_PROPERTY = new UnlistedProperty<>( "cable_bus_render_state", CableBusRenderState.class ); public boolean isFullCube(IBlockState state) {
return false;
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer(); }
private static Class<? extends AEBaseTile> noTesrTile; @Override
protected BlockStateContainer createBlockState() {
private static Class<? extends AEBaseTile> tesrTile; return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{RENDER_STATE_PROPERTY});
}
public BlockCableBus()
{ @Override
super( AEGlassMaterial.INSTANCE ); public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
this.setLightOpacity( 0 ); CableBusRenderState renderState = this.cb(world, pos).getRenderState();
this.setFullSize( false ); renderState.setWorld(world);
this.setOpaque( false ); renderState.setPos(pos);
return ((IExtendedBlockState) state).withProperty(RENDER_STATE_PROPERTY, renderState);
// this will actually be overwritten later through setupTile and the }
// combined layers
this.setTileEntity( TileCableBus.class ); @Override
} public void randomDisplayTick(final IBlockState state, final World worldIn, final BlockPos pos, final Random rand) {
this.cb(worldIn, pos).randomDisplayTick(worldIn, pos, rand);
@Override }
public boolean isFullCube( IBlockState state )
{ @Override
return false; public void onNeighborChange(final IBlockAccess w, final BlockPos pos, final BlockPos neighbor) {
} this.cb(w, pos).onNeighborChanged(w, pos, neighbor);
}
@Override
protected BlockStateContainer createBlockState() @Override
{ public Item getItemDropped(final IBlockState state, final Random rand, final int fortune) {
return new ExtendedBlockState( this, new IProperty[0], new IUnlistedProperty[] { RENDER_STATE_PROPERTY } ); return null;
} }
@Override @Override
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) public int getWeakPower(final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side) {
{ return this.cb(w, pos).isProvidingWeakPower(side.getOpposite()); // TODO:
CableBusRenderState renderState = this.cb( world, pos ).getRenderState(); // IS
renderState.setWorld( world ); // OPPOSITE!?
renderState.setPos( pos ); }
return ( (IExtendedBlockState) state ).withProperty( RENDER_STATE_PROPERTY, renderState );
} @Override
public boolean canProvidePower(final IBlockState state) {
@Override return true;
public void randomDisplayTick( final IBlockState state, final World worldIn, final BlockPos pos, final Random rand ) }
{
this.cb( worldIn, pos ).randomDisplayTick( worldIn, pos, rand ); @Override
} public void onEntityCollidedWithBlock(final World w, final BlockPos pos, final IBlockState state, final Entity entityIn) {
this.cb(w, pos).onEntityCollision(entityIn);
@Override }
public void onNeighborChange( final IBlockAccess w, final BlockPos pos, final BlockPos neighbor )
{ @Override
this.cb( w, pos ).onNeighborChanged( w, pos, neighbor ); public int getStrongPower(final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side) {
} return this.cb(w, pos).isProvidingStrongPower(side.getOpposite()); // TODO:
// IS
@Override // OPPOSITE!?
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune ) }
{
return null; @Override
} public int getLightValue(final IBlockState state, final IBlockAccess world, final BlockPos pos) {
if (state.getBlock() != this) {
@Override return state.getBlock().getLightValue(state, world, pos);
public int getWeakPower( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side ) }
{ return this.cb(world, pos).getLightValue();
return this.cb( w, pos ).isProvidingWeakPower( side.getOpposite() ); // TODO: }
// IS
// OPPOSITE!? @Override
} public boolean isLadder(final IBlockState state, final IBlockAccess world, final BlockPos pos, final EntityLivingBase entity) {
return this.cb(world, pos).isLadder(entity);
@Override }
public boolean canProvidePower( final IBlockState state )
{ @Override
return true; public boolean isSideSolid(final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side) {
} return this.cb(w, pos).isSolidOnSide(side);
}
@Override
public void onEntityCollidedWithBlock( final World w, final BlockPos pos, final IBlockState state, final Entity entityIn ) @Override
{ public boolean isReplaceable(final IBlockAccess w, final BlockPos pos) {
this.cb( w, pos ).onEntityCollision( entityIn ); return this.cb(w, pos).isEmpty();
} }
@Override @Override
public int getStrongPower( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side ) public boolean removedByPlayer(final IBlockState state, final World world, final BlockPos pos, final EntityPlayer player, final boolean willHarvest) {
{ if (player.capabilities.isCreativeMode) {
return this.cb( w, pos ).isProvidingStrongPower( side.getOpposite() ); // TODO: final AEBaseTile tile = this.getTileEntity(world, pos);
// IS if (tile != null) {
// OPPOSITE!? tile.disableDrops();
} }
// maybe ray trace?
@Override }
public int getLightValue( final IBlockState state, final IBlockAccess world, final BlockPos pos ) return super.removedByPlayer(state, world, pos, player, willHarvest);
{ }
if( state.getBlock() != this )
{ @Override
return state.getBlock().getLightValue( state, world, pos ); public boolean canConnectRedstone(final IBlockState state, final IBlockAccess w, final BlockPos pos, EnumFacing side) {
} if (side == null) {
return this.cb( world, pos ).getLightValue(); side = EnumFacing.UP;
} }
@Override return this.cb(w, pos).canConnectRedstone(EnumSet.of(side));
public boolean isLadder( final IBlockState state, final IBlockAccess world, final BlockPos pos, final EntityLivingBase entity ) }
{
return this.cb( world, pos ).isLadder( entity ); @Override
} public ItemStack getPickBlock(final IBlockState state, final RayTraceResult target, final World world, final BlockPos pos, final EntityPlayer player) {
final Vec3d v3 = target.hitVec.subtract(pos.getX(), pos.getY(), pos.getZ());
@Override final SelectedPart sp = this.cb(world, pos).selectPart(v3);
public boolean isSideSolid( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side )
{ if (sp.part != null) {
return this.cb( w, pos ).isSolidOnSide( side ); return sp.part.getItemStack(PartItemStack.PICK);
} } else if (sp.facade != null) {
return sp.facade.getItemStack();
@Override }
public boolean isReplaceable( final IBlockAccess w, final BlockPos pos )
{ return ItemStack.EMPTY;
return this.cb( w, pos ).isEmpty(); }
}
@Override
@Override @SideOnly(Side.CLIENT)
public boolean removedByPlayer( final IBlockState state, final World world, final BlockPos pos, final EntityPlayer player, final boolean willHarvest ) public boolean addHitEffects(final IBlockState state, final World world, final RayTraceResult target, final ParticleManager effectRenderer) {
{
if( player.capabilities.isCreativeMode ) // Half the particle rate. Since we're spawning concentrated on a specific spot,
{ // our particle effect otherwise looks too strong
final AEBaseTile tile = this.getTileEntity( world, pos ); if (Platform.getRandom().nextBoolean()) {
if( tile != null ) return true;
{ }
tile.disableDrops();
} ICableBusContainer cb = this.cb(world, target.getBlockPos());
// maybe ray trace?
} // Our built-in model has the actual baked sprites we need
return super.removedByPlayer( state, world, pos, player, willHarvest ); IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
}
// We cannot add the effect if we don't have the model
@Override if (!(model instanceof CableBusBakedModel)) {
public boolean canConnectRedstone( final IBlockState state, final IBlockAccess w, final BlockPos pos, EnumFacing side ) return true;
{ }
if( side == null )
{ CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
side = EnumFacing.UP;
} CableBusRenderState renderState = cb.getRenderState();
return this.cb( w, pos ).canConnectRedstone( EnumSet.of( side ) ); // Spawn a particle for one of the particle textures
} TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
if (texture != null) {
@Override double x = target.hitVec.x;
public ItemStack getPickBlock( final IBlockState state, final RayTraceResult target, final World world, final BlockPos pos, final EntityPlayer player ) double y = target.hitVec.y;
{ double z = target.hitVec.z;
final Vec3d v3 = target.hitVec.subtract( pos.getX(), pos.getY(), pos.getZ() );
final SelectedPart sp = this.cb( world, pos ).selectPart( v3 ); Particle fx = new DestroyFX(world, x, y, z, 0.0D, 0.0D, 0.0D, state).setBlockPos(target.getBlockPos()).multipleParticleScaleBy(0.8F);
fx.setParticleTexture(texture);
if( sp.part != null ) effectRenderer.addEffect(fx);
{ }
return sp.part.getItemStack( PartItemStack.PICK );
} return true;
else if( sp.facade != null ) }
{
return sp.facade.getItemStack(); @Override
} @SideOnly(Side.CLIENT)
public boolean addDestroyEffects(final World world, final BlockPos pos, final ParticleManager effectRenderer) {
return ItemStack.EMPTY; ICableBusContainer cb = this.cb(world, pos);
}
// Our built-in model has the actual baked sprites we need
@Override IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(this.getDefaultState());
@SideOnly( Side.CLIENT )
public boolean addHitEffects( final IBlockState state, final World world, final RayTraceResult target, final ParticleManager effectRenderer ) // We cannot add the effect if we dont have the model
{ if (!(model instanceof CableBusBakedModel)) {
return true;
// Half the particle rate. Since we're spawning concentrated on a specific spot, }
// our particle effect otherwise looks too strong
if( Platform.getRandom().nextBoolean() ) CableBusBakedModel cableBusModel = (CableBusBakedModel) model;
{
return true; CableBusRenderState renderState = cb.getRenderState();
}
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures(renderState);
ICableBusContainer cb = this.cb( world, target.getBlockPos() );
if (!textures.isEmpty()) {
// Our built-in model has the actual baked sprites we need // Shamelessly inspired by ParticleManager.addBlockDestroyEffects
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState( this.getDefaultState() ); for (int j = 0; j < 4; ++j) {
for (int k = 0; k < 4; ++k) {
// We cannot add the effect if we don't have the model for (int l = 0; l < 4; ++l) {
if( !( model instanceof CableBusBakedModel ) ) // Randomly select one of the textures if the cable bus has more than just one possibility here
{ final TextureAtlasSprite texture = Platform.pickRandom(textures);
return true;
} final double d0 = pos.getX() + (j + 0.5D) / 4.0D;
final double d1 = pos.getY() + (k + 0.5D) / 4.0D;
CableBusBakedModel cableBusModel = (CableBusBakedModel) model; final double d2 = pos.getZ() + (l + 0.5D) / 4.0D;
final ParticleDigging particle = new DestroyFX(world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos
CableBusRenderState renderState = cb.getRenderState(); .getY() - 0.5D, d2 - pos.getZ() - 0.5D, this.getDefaultState()).setBlockPos(pos);
// Spawn a particle for one of the particle textures particle.setParticleTexture(texture);
TextureAtlasSprite texture = Platform.pickRandom( cableBusModel.getParticleTextures( renderState ) ); effectRenderer.addEffect(particle);
if( texture != null ) }
{ }
double x = target.hitVec.x; }
double y = target.hitVec.y; }
double z = target.hitVec.z;
return true;
Particle fx = new DestroyFX( world, x, y, z, 0.0D, 0.0D, 0.0D, state ).setBlockPos( target.getBlockPos() ).multipleParticleScaleBy( 0.8F ); }
fx.setParticleTexture( texture );
effectRenderer.addEffect( fx ); @Override
} public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
if (Platform.isServer()) {
return true; this.cb(world, pos).onNeighborChanged(world, pos, fromPos);
} }
}
@Override
@SideOnly( Side.CLIENT ) private ICableBusContainer cb(final IBlockAccess w, final BlockPos pos) {
public boolean addDestroyEffects( final World world, final BlockPos pos, final ParticleManager effectRenderer ) final TileEntity te = w.getTileEntity(pos);
{ ICableBusContainer out = null;
ICableBusContainer cb = this.cb( world, pos );
if (te instanceof TileCableBus) {
// Our built-in model has the actual baked sprites we need out = ((TileCableBus) te).getCableBus();
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState( this.getDefaultState() ); }
// We cannot add the effect if we dont have the model return out == null ? NULL_CABLE_BUS : out;
if( !( model instanceof CableBusBakedModel ) ) }
{
return true; @Nullable
} private IFacadeContainer fc(final IBlockAccess w, final BlockPos pos) {
final TileEntity te = w.getTileEntity(pos);
CableBusBakedModel cableBusModel = (CableBusBakedModel) model; IFacadeContainer out = null;
CableBusRenderState renderState = cb.getRenderState(); if (te instanceof TileCableBus) {
out = ((TileCableBus) te).getCableBus().getFacadeContainer();
List<TextureAtlasSprite> textures = cableBusModel.getParticleTextures( renderState ); }
if( !textures.isEmpty() ) return out;
{ }
// Shamelessly inspired by ParticleManager.addBlockDestroyEffects
for( int j = 0; j < 4; ++j ) @Override
{ public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
for( int k = 0; k < 4; ++k ) if (Platform.isClient()) {
{ final RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
for( int l = 0; l < 4; ++l ) if (rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals(rtr.getBlockPos())) {
{ final Vec3d hitVec = rtr.hitVec.subtract(new Vec3d(pos));
// Randomly select one of the textures if the cable bus has more than just one possibility here
final TextureAtlasSprite texture = Platform.pickRandom( textures ); if (this.cb(worldIn, pos).clicked(playerIn, EnumHand.MAIN_HAND, hitVec)) {
NetworkHandler.instance()
final double d0 = pos.getX() + ( j + 0.5D ) / 4.0D; .sendToServer(
final double d1 = pos.getY() + ( k + 0.5D ) / 4.0D; new PacketClick(pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, EnumHand.MAIN_HAND, true));
final double d2 = pos.getZ() + ( l + 0.5D ) / 4.0D; }
final ParticleDigging particle = new DestroyFX( world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos }
.getY() - 0.5D, d2 - pos.getZ() - 0.5D, this.getDefaultState() ).setBlockPos( pos ); }
}
particle.setParticleTexture( texture );
effectRenderer.addEffect( particle ); public void onBlockClickPacket(World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, Vec3d hitVec) {
} this.cb(worldIn, pos).clicked(playerIn, hand, hitVec);
} }
}
} @Override
public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
return true; return this.cb(w, pos).activate(player, hand, new Vec3d(hitX, hitY, hitZ));
} }
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public boolean recolorBlock(final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color) {
{ return this.recolorBlock(world, pos, side, color, null);
if( Platform.isServer() ) }
{
this.cb( world, pos ).onNeighborChanged( world, pos, fromPos ); public boolean recolorBlock(final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color, final EntityPlayer who) {
} try {
} return this.cb(world, pos).recolourBlock(side, AEColor.values()[color.ordinal()], who);
} catch (final Throwable ignored) {
private ICableBusContainer cb( final IBlockAccess w, final BlockPos pos ) }
{ return false;
final TileEntity te = w.getTileEntity( pos ); }
ICableBusContainer out = null;
@Override
if( te instanceof TileCableBus ) @SideOnly(Side.CLIENT)
{ public void getSubBlocks(final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks) {
out = ( (TileCableBus) te ).getCableBus(); // do nothing
} }
return out == null ? NULL_CABLE_BUS : out; public void setupTile() {
} noTesrTile = Api.INSTANCE.partHelper().getCombinedInstance(TileCableBus.class);
this.setTileEntity(noTesrTile);
@Nullable
private IFacadeContainer fc( final IBlockAccess w, final BlockPos pos ) GameRegistry.registerTileEntity(noTesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "BlockCableBus");
{
final TileEntity te = w.getTileEntity( pos ); if (Platform.isClient()) {
IFacadeContainer out = null; setupTesr();
}
if( te instanceof TileCableBus ) }
{
out = ( (TileCableBus) te ).getCableBus().getFacadeContainer(); @SideOnly(Side.CLIENT)
} private static void setupTesr() {
tesrTile = Api.INSTANCE.partHelper().getCombinedInstance(TileCableBusTESR.class);
return out; GameRegistry.registerTileEntity(tesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "ClientOnly_TESR_CableBus");
} ClientRegistry.bindTileEntitySpecialRenderer(BlockCableBus.getTesrTile(), new CableBusTESR());
}
@Override
public void onBlockClicked( World worldIn, BlockPos pos, EntityPlayer playerIn ) @Override
{ public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
if( Platform.isClient() ) return true;
{ }
final RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
if( rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals( rtr.getBlockPos() ) ) @Override
{ public IBlockState getFacadeState(IBlockAccess world, BlockPos pos, EnumFacing side) {
final Vec3d hitVec = rtr.hitVec.subtract( new Vec3d( pos ) ); if (side != null) {
IFacadeContainer container = this.fc(world, pos);
if( this.cb( worldIn, pos ).clicked( playerIn, EnumHand.MAIN_HAND, hitVec ) ) if (container != null) {
{ IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(side));
NetworkHandler.instance() if (facade != null) {
.sendToServer( return facade.getBlockState();
new PacketClick( pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, EnumHand.MAIN_HAND, true ) ); }
} }
} }
} return world.getBlockState(pos);
} }
public void onBlockClickPacket( World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, Vec3d hitVec ) @Override
{ public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) {
this.cb( worldIn, pos ).clicked( playerIn, hand, hitVec ); IFacadeContainer container = this.fc(world, pos);
} if (container != null) {
IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(side));
@Override if (facade != null) {
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) return BlockFaceShape.SOLID;
{ }
return this.cb( w, pos ).activate( player, hand, new Vec3d( hitX, hitY, hitZ ) ); }
} return BlockFaceShape.UNDEFINED;
}
@Override
public boolean recolorBlock( final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color ) @Override
{ public void onEntityWalk(World world, BlockPos pos, Entity entityIn) {
return this.recolorBlock( world, pos, side, color, null ); IFacadeContainer container = this.fc(world, pos);
} if (container != null) {
IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(EnumFacing.UP));
public boolean recolorBlock( final World world, final BlockPos pos, final EnumFacing side, final EnumDyeColor color, final EntityPlayer who ) if (facade != null) {
{ facade.getBlockState().getBlock().onEntityWalk(world, pos, entityIn);
try }
{ }
return this.cb( world, pos ).recolourBlock( side, AEColor.values()[color.ordinal()], who ); super.onEntityWalk(world, pos, entityIn);
} }
catch( final Throwable ignored )
{ public static Class<? extends AEBaseTile> getNoTesrTile() {
} return noTesrTile;
return false; }
}
public static Class<? extends AEBaseTile> getTesrTile() {
@Override return tesrTile;
@SideOnly( Side.CLIENT ) }
public void getSubBlocks( final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks )
{ // Helper to get access to the protected constructor
// do nothing @SideOnly(Side.CLIENT)
} private static class DestroyFX extends ParticleDigging {
DestroyFX(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, IBlockState state) {
public void setupTile() super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, state);
{ }
noTesrTile = Api.INSTANCE.partHelper().getCombinedInstance( TileCableBus.class ); }
this.setTileEntity( noTesrTile );
GameRegistry.registerTileEntity( noTesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "BlockCableBus" );
if( Platform.isClient() )
{
setupTesr();
}
}
@SideOnly( Side.CLIENT )
private static void setupTesr()
{
tesrTile = Api.INSTANCE.partHelper().getCombinedInstance( TileCableBusTESR.class );
GameRegistry.registerTileEntity( tesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "ClientOnly_TESR_CableBus" );
ClientRegistry.bindTileEntitySpecialRenderer( BlockCableBus.getTesrTile(), new CableBusTESR() );
}
@Override
public boolean canRenderInLayer( IBlockState state, BlockRenderLayer layer )
{
return true;
}
@Override
public IBlockState getFacadeState( IBlockAccess world, BlockPos pos, EnumFacing side )
{
if( side != null )
{
IFacadeContainer container = this.fc( world, pos );
if( container != null )
{
IFacadePart facade = container.getFacade( AEPartLocation.fromFacing( side ) );
if( facade != null )
{
return facade.getBlockState();
}
}
}
return world.getBlockState( pos );
}
public static Class<? extends AEBaseTile> getNoTesrTile()
{
return noTesrTile;
}
public static Class<? extends AEBaseTile> getTesrTile()
{
return tesrTile;
}
// Helper to get access to the protected constructor
@SideOnly( Side.CLIENT )
private static class DestroyFX extends ParticleDigging
{
DestroyFX( World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, IBlockState state )
{
super( worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, state );
}
}
} }
@@ -19,6 +19,8 @@
package appeng.block.networking; package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.TileController;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@@ -31,154 +33,126 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.TileController;
public class BlockController extends AEBaseTileBlock {
public class BlockController extends AEBaseTileBlock public enum ControllerBlockState implements IStringSerializable {
{ offline, online, conflicted;
public enum ControllerBlockState implements IStringSerializable @Override
{ public String getName() {
offline, online, conflicted; return this.name();
}
@Override }
public String getName()
{
return this.name();
}
} /**
* Controls the rendering of the controller block (connected texture style).
* inside_a and inside_b are alternating patterns for a controller that is enclosed by other controllers,
* and since they are always offline, they do not have the usual sub-states.
*/
public enum ControllerRenderType implements IStringSerializable {
block, column_x, column_y, column_z, inside_a, inside_b;
/** @Override
* Controls the rendering of the controller block (connected texture style). public String getName() {
* inside_a and inside_b are alternating patterns for a controller that is enclosed by other controllers, return this.name();
* and since they are always offline, they do not have the usual sub-states. }
*/
public enum ControllerRenderType implements IStringSerializable
{
block, column_x, column_y, column_z, inside_a, inside_b;
@Override }
public String getName()
{
return this.name();
}
} public static final PropertyEnum<ControllerBlockState> CONTROLLER_STATE = PropertyEnum.create("state", ControllerBlockState.class);
public static final PropertyEnum<ControllerBlockState> CONTROLLER_STATE = PropertyEnum.create( "state", ControllerBlockState.class ); public static final PropertyEnum<ControllerRenderType> CONTROLLER_TYPE = PropertyEnum.create("type", ControllerRenderType.class);
public static final PropertyEnum<ControllerRenderType> CONTROLLER_TYPE = PropertyEnum.create( "type", ControllerRenderType.class ); public BlockController() {
super(Material.IRON);
this.setHardness(6);
this.setDefaultState(this.getDefaultState()
.withProperty(CONTROLLER_STATE, ControllerBlockState.offline)
.withProperty(CONTROLLER_TYPE, ControllerRenderType.block));
}
public BlockController() @Override
{ protected IProperty[] getAEStates() {
super( Material.IRON ); return new IProperty[]{CONTROLLER_STATE, CONTROLLER_TYPE};
this.setHardness( 6 ); }
this.setDefaultState( this.getDefaultState()
.withProperty( CONTROLLER_STATE, ControllerBlockState.offline )
.withProperty( CONTROLLER_TYPE, ControllerRenderType.block ) );
}
@Override @Override
protected IProperty[] getAEStates() protected BlockStateContainer createBlockState() {
{ return new BlockStateContainer(this, this.getAEStates());
return new IProperty[] { CONTROLLER_STATE, CONTROLLER_TYPE }; }
}
@Override /**
protected BlockStateContainer createBlockState() * This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block states based on adjacent
{ * controllers and the network state of this controller (offline, online, conflicted). This is used to
return new BlockStateContainer( this, this.getAEStates() ); * get a rudimentary connected texture feel for the controller based on how it is placed.
} */
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
/** // Only used for columns, really
* This will compute the AE_BLOCK_FORWARD, AE_BLOCK_UP and CONTROLLER_TYPE block states based on adjacent ControllerRenderType type = ControllerRenderType.block;
* controllers and the network state of this controller (offline, online, conflicted). This is used to
* get a rudimentary connected texture feel for the controller based on how it is placed.
*/
@Override
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
{
// Only used for columns, really int x = pos.getX();
ControllerRenderType type = ControllerRenderType.block; int y = pos.getY();
int z = pos.getZ();
int x = pos.getX(); // Detect whether controllers are on both sides of the x, y, and z axes
int y = pos.getY(); final boolean xx = this.getTileEntity(world, x - 1, y, z) instanceof TileController && this.getTileEntity(world, x + 1, y,
int z = pos.getZ(); z) instanceof TileController;
final boolean yy = this.getTileEntity(world, x, y - 1, z) instanceof TileController && this.getTileEntity(world, x, y + 1,
z) instanceof TileController;
final boolean zz = this.getTileEntity(world, x, y, z - 1) instanceof TileController && this.getTileEntity(world, x, y,
z + 1) instanceof TileController;
// Detect whether controllers are on both sides of the x, y, and z axes if (xx && !yy && !zz) {
final boolean xx = this.getTileEntity( world, x - 1, y, z ) instanceof TileController && this.getTileEntity( world, x + 1, y, type = ControllerRenderType.column_x;
z ) instanceof TileController; } else if (!xx && yy && !zz) {
final boolean yy = this.getTileEntity( world, x, y - 1, z ) instanceof TileController && this.getTileEntity( world, x, y + 1, type = ControllerRenderType.column_y;
z ) instanceof TileController; } else if (!xx && !yy && zz) {
final boolean zz = this.getTileEntity( world, x, y, z - 1 ) instanceof TileController && this.getTileEntity( world, x, y, type = ControllerRenderType.column_z;
z + 1 ) instanceof TileController; } else if ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2) {
final int v = (Math.abs(x) + Math.abs(y) + Math.abs(z)) % 2;
if( xx && !yy && !zz ) // While i'd like this to be based on the blockstate randomization feature, this generates
{ // an alternating pattern based on world position, so this is not 100% doable with blockstates.
type = ControllerRenderType.column_x; if (v == 0) {
} type = ControllerRenderType.inside_a;
else if( !xx && yy && !zz ) } else {
{ type = ControllerRenderType.inside_b;
type = ControllerRenderType.column_y; }
} }
else if( !xx && !yy && zz )
{
type = ControllerRenderType.column_z;
}
else if( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) >= 2 )
{
final int v = ( Math.abs( x ) + Math.abs( y ) + Math.abs( z ) ) % 2;
// While i'd like this to be based on the blockstate randomization feature, this generates return state.withProperty(CONTROLLER_TYPE, type);
// an alternating pattern based on world position, so this is not 100% doable with blockstates. }
if( v == 0 )
{
type = ControllerRenderType.inside_a;
}
else
{
type = ControllerRenderType.inside_b;
}
}
return state.withProperty( CONTROLLER_TYPE, type ); @Override
} public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
return state;
}
@Override @Override
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) public int getMetaFromState(final IBlockState state) {
{ return state.getValue(CONTROLLER_STATE).ordinal();
return state; }
}
@Override @Override
public int getMetaFromState( final IBlockState state ) public IBlockState getStateFromMeta(final int meta) {
{ ControllerBlockState state = ControllerBlockState.values()[meta];
return state.getValue( CONTROLLER_STATE ).ordinal(); return this.getDefaultState().withProperty(CONTROLLER_STATE, state);
} }
@Override @Override
public IBlockState getStateFromMeta( final int meta ) public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
ControllerBlockState state = ControllerBlockState.values()[meta]; }
return this.getDefaultState().withProperty( CONTROLLER_STATE, state );
}
@Override @Override
public BlockRenderLayer getBlockLayer() public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final TileController tc = this.getTileEntity(world, pos);
return BlockRenderLayer.CUTOUT; if (tc != null) {
} tc.onNeighborChange(false);
}
@Override }
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos )
{
final TileController tc = this.getTileEntity( world, pos );
if( tc != null )
{
tc.onNeighborChange( false );
}
}
} }
@@ -23,11 +23,9 @@ import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial; import appeng.helpers.AEGlassMaterial;
public class BlockCreativeEnergyCell extends AEBaseTileBlock public class BlockCreativeEnergyCell extends AEBaseTileBlock {
{
public BlockCreativeEnergyCell() public BlockCreativeEnergyCell() {
{ super(AEGlassMaterial.INSTANCE);
super( AEGlassMaterial.INSTANCE ); }
}
} }
@@ -19,17 +19,14 @@
package appeng.block.networking; package appeng.block.networking;
public class BlockDenseEnergyCell extends BlockEnergyCell public class BlockDenseEnergyCell extends BlockEnergyCell {
{
public BlockDenseEnergyCell() public BlockDenseEnergyCell() {
{
} }
@Override @Override
public double getMaxPower() public double getMaxPower() {
{ return 200000.0 * 8.0;
return 200000.0 * 8.0; }
}
} }
@@ -19,16 +19,13 @@
package appeng.block.networking; package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import appeng.block.AEBaseTileBlock;
public class BlockEnergyAcceptor extends AEBaseTileBlock {
public class BlockEnergyAcceptor extends AEBaseTileBlock public BlockEnergyAcceptor() {
{ super(Material.IRON);
}
public BlockEnergyAcceptor()
{
super( Material.IRON );
}
} }
@@ -19,6 +19,9 @@
package appeng.block.networking; package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.util.Platform;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@@ -29,56 +32,45 @@ import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.util.Platform;
public class BlockEnergyCell extends AEBaseTileBlock {
public class BlockEnergyCell extends AEBaseTileBlock public static final PropertyInteger ENERGY_STORAGE = PropertyInteger.create("fullness", 0, 7);
{
public static final PropertyInteger ENERGY_STORAGE = PropertyInteger.create( "fullness", 0, 7 ); @Override
public int getMetaFromState(final IBlockState state) {
return state.getValue(ENERGY_STORAGE);
}
@Override @Override
public int getMetaFromState( final IBlockState state ) public IBlockState getStateFromMeta(final int meta) {
{ return this.getDefaultState().withProperty(ENERGY_STORAGE, Math.min(7, Math.max(0, meta)));
return state.getValue( ENERGY_STORAGE ); }
}
@Override public BlockEnergyCell() {
public IBlockState getStateFromMeta( final int meta ) super(AEGlassMaterial.INSTANCE);
{ }
return this.getDefaultState().withProperty( ENERGY_STORAGE, Math.min( 7, Math.max( 0, meta ) ) );
}
public BlockEnergyCell() @Override
{ @SideOnly(Side.CLIENT)
super( AEGlassMaterial.INSTANCE ); public void getSubBlocks(final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks) {
} super.getSubBlocks(tabs, itemStacks);
@Override final ItemStack charged = new ItemStack(this, 1);
@SideOnly( Side.CLIENT ) final NBTTagCompound tag = Platform.openNbtData(charged);
public void getSubBlocks( final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks ) tag.setDouble("internalCurrentPower", this.getMaxPower());
{ tag.setDouble("internalMaxPower", this.getMaxPower());
super.getSubBlocks( tabs, itemStacks );
final ItemStack charged = new ItemStack( this, 1 ); itemStacks.add(charged);
final NBTTagCompound tag = Platform.openNbtData( charged ); }
tag.setDouble( "internalCurrentPower", this.getMaxPower() );
tag.setDouble( "internalMaxPower", this.getMaxPower() );
itemStacks.add( charged ); public double getMaxPower() {
} return 200000.0;
}
public double getMaxPower() @Override
{ protected IProperty[] getAEStates() {
return 200000.0; return new IProperty[]{ENERGY_STORAGE};
} }
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { ENERGY_STORAGE };
}
} }
@@ -19,62 +19,55 @@
package appeng.block.networking; package appeng.block.networking;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.api.implementations.items.IAEItemPowerStorage; import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.block.AEBaseItemBlockChargeable; import appeng.block.AEBaseItemBlockChargeable;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.tile.networking.TileEnergyCell; import appeng.tile.networking.TileEnergyCell;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class BlockEnergyCellRendering extends BlockRenderingCustomizer public class BlockEnergyCellRendering extends BlockRenderingCustomizer {
{
private final ResourceLocation baseModel; private final ResourceLocation baseModel;
public BlockEnergyCellRendering( ResourceLocation baseModel ) public BlockEnergyCellRendering(ResourceLocation baseModel) {
{ this.baseModel = baseModel;
this.baseModel = baseModel; }
}
@Override @Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ itemRendering.meshDefinition(this::getItemModel);
itemRendering.meshDefinition( this::getItemModel ); // Note: Since we use the block models, we dont need to register custom variants
// Note: Since we use the block models, we dont need to register custom variants }
}
/** /**
* Determines which version of the energy cell model should be used depending on the fill factor * Determines which version of the energy cell model should be used depending on the fill factor
* of the item stack. * of the item stack.
*/ */
private ModelResourceLocation getItemModel( ItemStack is ) private ModelResourceLocation getItemModel(ItemStack is) {
{ double fillFactor = getFillFactor(is);
double fillFactor = getFillFactor( is );
int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor( fillFactor ); int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor(fillFactor);
return new ModelResourceLocation( this.baseModel, "fullness=" + storageLevel ); return new ModelResourceLocation(this.baseModel, "fullness=" + storageLevel);
} }
/** /**
* Helper method that returns the energy fill factor (between 0 and 1) of a given item stack. * Helper method that returns the energy fill factor (between 0 and 1) of a given item stack.
* Returns 0 if the item stack has no fill factor. * Returns 0 if the item stack has no fill factor.
*/ */
private static double getFillFactor( ItemStack is ) private static double getFillFactor(ItemStack is) {
{ if (!(is.getItem() instanceof IAEItemPowerStorage)) {
if( !( is.getItem() instanceof IAEItemPowerStorage ) ) return 0;
{ }
return 0;
}
AEBaseItemBlockChargeable itemChargeable = (AEBaseItemBlockChargeable) is.getItem(); AEBaseItemBlockChargeable itemChargeable = (AEBaseItemBlockChargeable) is.getItem();
double curPower = itemChargeable.getAECurrentPower( is ); double curPower = itemChargeable.getAECurrentPower(is);
double maxPower = itemChargeable.getAEMaxPower( is ); double maxPower = itemChargeable.getAEMaxPower(is);
return curPower / maxPower; return curPower / maxPower;
} }
} }
@@ -19,9 +19,13 @@
package appeng.block.networking; package appeng.block.networking;
import java.util.Collections; import appeng.api.util.AEPartLocation;
import java.util.List; import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.ICustomCollision;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@@ -36,224 +40,196 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import java.util.Collections;
import appeng.block.AEBaseTileBlock; import java.util.List;
import appeng.core.sync.GuiBridge;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.ICustomCollision;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision public class BlockWireless extends AEBaseTileBlock implements ICustomCollision {
{
enum State implements IStringSerializable enum State implements IStringSerializable {
{ OFF,
OFF, ON,
ON, HAS_CHANNEL;
HAS_CHANNEL;
@Override @Override
public String getName() public String getName() {
{ return this.name().toLowerCase();
return this.name().toLowerCase(); }
} }
}
public static final PropertyEnum<State> STATE = PropertyEnum.create( "state", State.class ); public static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
public BlockWireless() public BlockWireless() {
{ super(AEGlassMaterial.INSTANCE);
super( AEGlassMaterial.INSTANCE ); this.setLightOpacity(0);
this.setLightOpacity( 0 ); this.setFullSize(false);
this.setFullSize( false ); this.setOpaque(false);
this.setOpaque( false ); this.setDefaultState(this.getDefaultState().withProperty(STATE, State.OFF));
this.setDefaultState( this.getDefaultState().withProperty( STATE, State.OFF ) ); }
}
@Override @Override
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos ) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
{ State teState = State.OFF;
State teState = State.OFF;
TileWireless te = this.getTileEntity( worldIn, pos ); TileWireless te = this.getTileEntity(worldIn, pos);
if( te != null ) if (te != null) {
{ if (te.isActive()) {
if( te.isActive() ) teState = State.HAS_CHANNEL;
{ } else if (te.isPowered()) {
teState = State.HAS_CHANNEL; teState = State.ON;
} }
else if( te.isPowered() ) }
{
teState = State.ON;
}
}
return super.getActualState( state, worldIn, pos ) return super.getActualState(state, worldIn, pos)
.withProperty( STATE, teState ); .withProperty(STATE, teState);
} }
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{STATE};
return new IProperty[] { STATE }; }
}
@Override @Override
public boolean onBlockActivated( final World w, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onBlockActivated(final World w, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ final TileWireless tg = this.getTileEntity(w, pos);
final TileWireless tg = this.getTileEntity( w, pos );
if( tg != null && !player.isSneaking() ) if (tg != null && !player.isSneaking()) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(player, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_WIRELESS);
{ }
Platform.openGUI( player, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_WIRELESS ); return true;
} }
return true;
}
return super.onBlockActivated( w, pos, state, player, hand, side, hitX, hitY, hitZ ); return super.onBlockActivated(w, pos, state, player, hand, side, hitX, hitY, hitZ);
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ final TileWireless tile = this.getTileEntity(w, pos);
final TileWireless tile = this.getTileEntity( w, pos ); if (tile != null) {
if( tile != null ) final EnumFacing forward = tile.getForward();
{
final EnumFacing forward = tile.getForward();
double minX = 0; double minX = 0;
double minY = 0; double minY = 0;
double minZ = 0; double minZ = 0;
double maxX = 1; double maxX = 1;
double maxY = 1; double maxY = 1;
double maxZ = 1; double maxZ = 1;
switch( forward ) switch (forward) {
{ case DOWN:
case DOWN: minZ = minX = 3.0 / 16.0;
minZ = minX = 3.0 / 16.0; maxZ = maxX = 13.0 / 16.0;
maxZ = maxX = 13.0 / 16.0; maxY = 1.0;
maxY = 1.0; minY = 5.0 / 16.0;
minY = 5.0 / 16.0; break;
break; case EAST:
case EAST: minZ = minY = 3.0 / 16.0;
minZ = minY = 3.0 / 16.0; maxZ = maxY = 13.0 / 16.0;
maxZ = maxY = 13.0 / 16.0; maxX = 11.0 / 16.0;
maxX = 11.0 / 16.0; minX = 0.0;
minX = 0.0; break;
break; case NORTH:
case NORTH: minY = minX = 3.0 / 16.0;
minY = minX = 3.0 / 16.0; maxY = maxX = 13.0 / 16.0;
maxY = maxX = 13.0 / 16.0; maxZ = 1.0;
maxZ = 1.0; minZ = 5.0 / 16.0;
minZ = 5.0 / 16.0; break;
break; case SOUTH:
case SOUTH: minY = minX = 3.0 / 16.0;
minY = minX = 3.0 / 16.0; maxY = maxX = 13.0 / 16.0;
maxY = maxX = 13.0 / 16.0; maxZ = 11.0 / 16.0;
maxZ = 11.0 / 16.0; minZ = 0.0;
minZ = 0.0; break;
break; case UP:
case UP: minZ = minX = 3.0 / 16.0;
minZ = minX = 3.0 / 16.0; maxZ = maxX = 13.0 / 16.0;
maxZ = maxX = 13.0 / 16.0; maxY = 11.0 / 16.0;
maxY = 11.0 / 16.0; minY = 0.0;
minY = 0.0; break;
break; case WEST:
case WEST: minZ = minY = 3.0 / 16.0;
minZ = minY = 3.0 / 16.0; maxZ = maxY = 13.0 / 16.0;
maxZ = maxY = 13.0 / 16.0; maxX = 1.0;
maxX = 1.0; minX = 5.0 / 16.0;
minX = 5.0 / 16.0; break;
break; default:
default: break;
break; }
}
return Collections.singletonList( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) ); return Collections.singletonList(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
} }
return Collections.singletonList( new AxisAlignedBB( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) ); return Collections.singletonList(new AxisAlignedBB(0.0, 0, 0.0, 1.0, 1.0, 1.0));
} }
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{ final TileWireless tile = this.getTileEntity(w, pos);
final TileWireless tile = this.getTileEntity( w, pos ); if (tile != null) {
if( tile != null ) final EnumFacing forward = tile.getForward();
{
final EnumFacing forward = tile.getForward();
double minX = 0; double minX = 0;
double minY = 0; double minY = 0;
double minZ = 0; double minZ = 0;
double maxX = 1; double maxX = 1;
double maxY = 1; double maxY = 1;
double maxZ = 1; double maxZ = 1;
switch( forward ) switch (forward) {
{ case DOWN:
case DOWN: minZ = minX = 3.0 / 16.0;
minZ = minX = 3.0 / 16.0; maxZ = maxX = 13.0 / 16.0;
maxZ = maxX = 13.0 / 16.0; maxY = 1.0;
maxY = 1.0; minY = 5.0 / 16.0;
minY = 5.0 / 16.0; break;
break; case EAST:
case EAST: minZ = minY = 3.0 / 16.0;
minZ = minY = 3.0 / 16.0; maxZ = maxY = 13.0 / 16.0;
maxZ = maxY = 13.0 / 16.0; maxX = 11.0 / 16.0;
maxX = 11.0 / 16.0; minX = 0.0;
minX = 0.0; break;
break; case NORTH:
case NORTH: minY = minX = 3.0 / 16.0;
minY = minX = 3.0 / 16.0; maxY = maxX = 13.0 / 16.0;
maxY = maxX = 13.0 / 16.0; maxZ = 1.0;
maxZ = 1.0; minZ = 5.0 / 16.0;
minZ = 5.0 / 16.0; break;
break; case SOUTH:
case SOUTH: minY = minX = 3.0 / 16.0;
minY = minX = 3.0 / 16.0; maxY = maxX = 13.0 / 16.0;
maxY = maxX = 13.0 / 16.0; maxZ = 11.0 / 16.0;
maxZ = 11.0 / 16.0; minZ = 0.0;
minZ = 0.0; break;
break; case UP:
case UP: minZ = minX = 3.0 / 16.0;
minZ = minX = 3.0 / 16.0; maxZ = maxX = 13.0 / 16.0;
maxZ = maxX = 13.0 / 16.0; maxY = 11.0 / 16.0;
maxY = 11.0 / 16.0; minY = 0.0;
minY = 0.0; break;
break; case WEST:
case WEST: minZ = minY = 3.0 / 16.0;
minZ = minY = 3.0 / 16.0; maxZ = maxY = 13.0 / 16.0;
maxZ = maxY = 13.0 / 16.0; maxX = 1.0;
maxX = 1.0; minX = 5.0 / 16.0;
minX = 5.0 / 16.0; break;
break; default:
default: break;
break; }
}
out.add( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) ); out.add(new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ));
} } else {
else out.add(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
{ }
out.add( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) ); }
}
}
@Override @Override
public boolean isFullCube( IBlockState state ) public boolean isFullCube(IBlockState state) {
{ return false;
return false; }
}
} }
@@ -19,6 +19,8 @@
package appeng.block.networking; package appeng.block.networking;
import appeng.api.util.AEColor;
import appeng.client.render.cablebus.CableBusRenderState;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -27,33 +29,26 @@ import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEColor;
import appeng.client.render.cablebus.CableBusRenderState;
/** /**
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium variant) and 2 (bright variant). * Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium variant) and 2 (bright variant).
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public class CableBusColor implements IBlockColor public class CableBusColor implements IBlockColor {
{
@Override @Override
public int colorMultiplier( IBlockState state, IBlockAccess worldIn, BlockPos pos, int color ) public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int color) {
{
AEColor busColor = AEColor.TRANSPARENT; AEColor busColor = AEColor.TRANSPARENT;
if( state instanceof IExtendedBlockState ) if (state instanceof IExtendedBlockState) {
{ CableBusRenderState renderState = ((IExtendedBlockState) state).getValue(BlockCableBus.RENDER_STATE_PROPERTY);
CableBusRenderState renderState = ( (IExtendedBlockState) state ).getValue( BlockCableBus.RENDER_STATE_PROPERTY ); if (renderState != null) {
if( renderState != null ) busColor = renderState.getCableColor();
{ }
busColor = renderState.getCableColor(); }
}
}
return busColor.getVariantByTintIndex( color ); return busColor.getVariantByTintIndex(color);
} }
} }
@@ -19,34 +19,30 @@
package appeng.block.networking; package appeng.block.networking;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.cablebus.CableBusModel; import appeng.client.render.cablebus.CableBusModel;
import appeng.core.features.registries.PartModels; import appeng.core.features.registries.PartModels;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/** /**
* Customizes the rendering behavior for cable busses, which are the biggest multipart of AE2. * Customizes the rendering behavior for cable busses, which are the biggest multipart of AE2.
*/ */
public class CableBusRendering extends BlockRenderingCustomizer public class CableBusRendering extends BlockRenderingCustomizer {
{ private final PartModels partModels;
private final PartModels partModels;
public CableBusRendering( PartModels partModels ) public CableBusRendering(PartModels partModels) {
{ this.partModels = partModels;
this.partModels = partModels; }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.builtInModel("models/block/builtin/cable_bus", new CableBusModel(this.partModels));
rendering.builtInModel( "models/block/builtin/cable_bus", new CableBusModel( this.partModels ) ); rendering.blockColor(new CableBusColor());
rendering.blockColor( new CableBusColor() ); rendering.modelCustomizer((loc, model) -> model);
rendering.modelCustomizer( ( loc, model ) -> model ); }
}
} }
@@ -24,12 +24,10 @@ import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
public class ControllerRendering extends BlockRenderingCustomizer public class ControllerRendering extends BlockRenderingCustomizer {
{ @Override
@Override public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) // Disables the default model rotator
{ rendering.modelCustomizer((loc, model) -> model);
// Disables the default model rotator }
rendering.modelCustomizer( ( loc, model ) -> model );
}
} }
@@ -1,23 +1,19 @@
package appeng.block.networking; package appeng.block.networking;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.StaticBlockColor; import appeng.client.render.StaticBlockColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class WirelessRendering extends BlockRenderingCustomizer public class WirelessRendering extends BlockRenderingCustomizer {
{ @Override
@Override @SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) rendering.blockColor(new StaticBlockColor(AEColor.TRANSPARENT));
{ }
rendering.blockColor( new StaticBlockColor( AEColor.TRANSPARENT ) );
}
} }
+82 -102
View File
@@ -19,10 +19,10 @@
package appeng.block.paint; package appeng.block.paint;
import java.util.Collection; import appeng.block.AEBaseTileBlock;
import java.util.Collections; import appeng.helpers.Splotch;
import java.util.Random; import appeng.tile.misc.TilePaint;
import appeng.util.Platform;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.MaterialLiquid; import net.minecraft.block.material.MaterialLiquid;
@@ -44,128 +44,108 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.block.AEBaseTileBlock; import java.util.Collection;
import appeng.helpers.Splotch; import java.util.Collections;
import appeng.tile.misc.TilePaint; import java.util.Random;
import appeng.util.Platform;
public class BlockPaint extends AEBaseTileBlock public class BlockPaint extends AEBaseTileBlock {
{
static final PaintSplotchesProperty SPLOTCHES = new PaintSplotchesProperty(); static final PaintSplotchesProperty SPLOTCHES = new PaintSplotchesProperty();
public BlockPaint() public BlockPaint() {
{ super(new MaterialLiquid(MapColor.AIR));
super( new MaterialLiquid( MapColor.AIR ) );
this.setLightOpacity( 0 ); this.setLightOpacity(0);
this.setFullSize( false ); this.setFullSize(false);
this.setOpaque( false ); this.setOpaque(false);
} }
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{SPLOTCHES});
return new ExtendedBlockState( this, new IProperty[0], new IUnlistedProperty[] { SPLOTCHES } ); }
}
@Override @Override
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ IExtendedBlockState extState = (IExtendedBlockState) state;
IExtendedBlockState extState = (IExtendedBlockState) state;
TilePaint te = this.getTileEntity( world, pos ); TilePaint te = this.getTileEntity(world, pos);
Collection<Splotch> splotches = Collections.emptyList(); Collection<Splotch> splotches = Collections.emptyList();
if( te != null ) if (te != null) {
{ splotches = te.getDots();
splotches = te.getDots(); }
}
return extState.withProperty( SPLOTCHES, new PaintSplotches( splotches ) ); return extState.withProperty(SPLOTCHES, new PaintSplotches(splotches));
} }
@Override @Override
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void getSubBlocks( final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks ) public void getSubBlocks(final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks) {
{ // do nothing
// do nothing }
}
@Override @Override
public AxisAlignedBB getCollisionBoundingBox( IBlockState blockState, IBlockAccess worldIn, BlockPos pos ) public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
{ return null;
return null; }
}
@Override @Override
public boolean canCollideCheck( final IBlockState state, final boolean hitIfLiquid ) public boolean canCollideCheck(final IBlockState state, final boolean hitIfLiquid) {
{ return false;
return false; }
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final TilePaint tp = this.getTileEntity(world, pos);
final TilePaint tp = this.getTileEntity( world, pos );
if( tp != null ) if (tp != null) {
{ tp.neighborChanged();
tp.neighborChanged(); }
} }
}
@Override @Override
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune ) public Item getItemDropped(final IBlockState state, final Random rand, final int fortune) {
{ return null;
return null; }
}
@Override @Override
public void dropBlockAsItemWithChance( final World worldIn, final BlockPos pos, final IBlockState state, final float chance, final int fortune ) public void dropBlockAsItemWithChance(final World worldIn, final BlockPos pos, final IBlockState state, final float chance, final int fortune) {
{
} }
@Override @Override
public void fillWithRain( final World w, final BlockPos pos ) public void fillWithRain(final World w, final BlockPos pos) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) w.setBlockToAir(pos);
{ }
w.setBlockToAir( pos ); }
}
}
@Override @Override
public int getLightValue( final IBlockState state, final IBlockAccess w, final BlockPos pos ) public int getLightValue(final IBlockState state, final IBlockAccess w, final BlockPos pos) {
{ final TilePaint tp = this.getTileEntity(w, pos);
final TilePaint tp = this.getTileEntity( w, pos );
if( tp != null ) if (tp != null) {
{ return tp.getLightLevel();
return tp.getLightLevel(); }
}
return 0; return 0;
} }
@Override @Override
public boolean isAir( final IBlockState state, final IBlockAccess world, final BlockPos pos ) public boolean isAir(final IBlockState state, final IBlockAccess world, final BlockPos pos) {
{ return true;
return true; }
}
@Override @Override
public boolean isReplaceable( final IBlockAccess worldIn, final BlockPos pos ) public boolean isReplaceable(final IBlockAccess worldIn, final BlockPos pos) {
{ return true;
return true; }
}
} }
@@ -1,16 +1,10 @@
package appeng.block.paint; package appeng.block.paint;
import java.util.ArrayList; import appeng.client.render.cablebus.CubeBuilder;
import java.util.Collections; import appeng.core.AppEng;
import java.util.List; import appeng.helpers.Splotch;
import java.util.function.Function;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
@@ -22,9 +16,11 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.client.render.cablebus.CubeBuilder; import javax.annotation.Nullable;
import appeng.core.AppEng; import java.util.ArrayList;
import appeng.helpers.Splotch; import java.util.Collections;
import java.util.List;
import java.util.function.Function;
/** /**
@@ -32,168 +28,150 @@ import appeng.helpers.Splotch;
* a * a
* matter cannon with paint balls. * matter cannon with paint balls.
*/ */
class PaintBakedModel implements IBakedModel class PaintBakedModel implements IBakedModel {
{
private static final ResourceLocation TEXTURE_PAINT1 = new ResourceLocation( AppEng.MOD_ID, "blocks/paint1" ); private static final ResourceLocation TEXTURE_PAINT1 = new ResourceLocation(AppEng.MOD_ID, "blocks/paint1");
private static final ResourceLocation TEXTURE_PAINT2 = new ResourceLocation( AppEng.MOD_ID, "blocks/paint2" ); private static final ResourceLocation TEXTURE_PAINT2 = new ResourceLocation(AppEng.MOD_ID, "blocks/paint2");
private static final ResourceLocation TEXTURE_PAINT3 = new ResourceLocation( AppEng.MOD_ID, "blocks/paint3" ); private static final ResourceLocation TEXTURE_PAINT3 = new ResourceLocation(AppEng.MOD_ID, "blocks/paint3");
private final VertexFormat vertexFormat; private final VertexFormat vertexFormat;
private final TextureAtlasSprite[] textures; private final TextureAtlasSprite[] textures;
PaintBakedModel( VertexFormat vertexFormat, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) PaintBakedModel(VertexFormat vertexFormat, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
{ this.vertexFormat = vertexFormat;
this.vertexFormat = vertexFormat; this.textures = new TextureAtlasSprite[]{
this.textures = new TextureAtlasSprite[] { bakedTextureGetter.apply(TEXTURE_PAINT1),
bakedTextureGetter.apply( TEXTURE_PAINT1 ), bakedTextureGetter.apply(TEXTURE_PAINT2),
bakedTextureGetter.apply( TEXTURE_PAINT2 ), bakedTextureGetter.apply(TEXTURE_PAINT3)
bakedTextureGetter.apply( TEXTURE_PAINT3 ) };
}; }
}
@Override @Override
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand ) public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
{ if (side != null) {
if( side != null ) return Collections.emptyList();
{ }
return Collections.emptyList();
}
if( !( state instanceof IExtendedBlockState ) ) if (!(state instanceof IExtendedBlockState)) {
{ // This is the inventory model which should usually not be used other than in special cases
// This is the inventory model which should usually not be used other than in special cases List<BakedQuad> quads = new ArrayList<>(1);
List<BakedQuad> quads = new ArrayList<>( 1 ); CubeBuilder builder = new CubeBuilder(this.vertexFormat, quads);
CubeBuilder builder = new CubeBuilder( this.vertexFormat, quads ); builder.setTexture(this.textures[0]);
builder.setTexture( this.textures[0] ); builder.addCube(0, 0, 0, 16, 16, 16);
builder.addCube( 0, 0, 0, 16, 16, 16 ); return quads;
return quads; }
}
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state; IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
PaintSplotches splotchesState = extendedBlockState.getValue( BlockPaint.SPLOTCHES ); PaintSplotches splotchesState = extendedBlockState.getValue(BlockPaint.SPLOTCHES);
if( splotchesState == null ) if (splotchesState == null) {
{ return Collections.emptyList();
return Collections.emptyList(); }
}
List<Splotch> splotches = splotchesState.getSplotches(); List<Splotch> splotches = splotchesState.getSplotches();
CubeBuilder builder = new CubeBuilder( this.vertexFormat ); CubeBuilder builder = new CubeBuilder(this.vertexFormat);
float offsetConstant = 0.001f; float offsetConstant = 0.001f;
for( final Splotch s : splotches ) for (final Splotch s : splotches) {
{
if( s.isLumen() ) if (s.isLumen()) {
{ builder.setColorRGB(s.getColor().whiteVariant);
builder.setColorRGB( s.getColor().whiteVariant ); builder.setRenderFullBright(true);
builder.setRenderFullBright( true ); } else {
} builder.setColorRGB(s.getColor().mediumVariant);
else builder.setRenderFullBright(false);
{ }
builder.setColorRGB( s.getColor().mediumVariant );
builder.setRenderFullBright( false );
}
float offset = offsetConstant; float offset = offsetConstant;
offsetConstant += 0.001f; offsetConstant += 0.001f;
final float buffer = 0.1f; final float buffer = 0.1f;
float pos_x = s.x(); float pos_x = s.x();
float pos_y = s.y(); float pos_y = s.y();
pos_x = Math.max( buffer, Math.min( 1.0f - buffer, pos_x ) ); pos_x = Math.max(buffer, Math.min(1.0f - buffer, pos_x));
pos_y = Math.max( buffer, Math.min( 1.0f - buffer, pos_y ) ); pos_y = Math.max(buffer, Math.min(1.0f - buffer, pos_y));
TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length]; TextureAtlasSprite ico = this.textures[s.getSeed() % this.textures.length];
builder.setTexture( ico ); builder.setTexture(ico);
builder.setCustomUv( s.getSide().getOpposite(), 0, 0, 16, 16 ); builder.setCustomUv(s.getSide().getOpposite(), 0, 0, 16, 16);
switch( s.getSide() ) switch (s.getSide()) {
{ case UP:
case UP: offset = 1.0f - offset;
offset = 1.0f - offset; builder.addQuad(EnumFacing.DOWN, pos_x - buffer, offset, pos_y - buffer,
builder.addQuad( EnumFacing.DOWN, pos_x - buffer, offset, pos_y - buffer, pos_x + buffer, offset, pos_y + buffer);
pos_x + buffer, offset, pos_y + buffer ); break;
break;
case DOWN: case DOWN:
builder.addQuad( EnumFacing.UP, pos_x - buffer, offset, pos_y - buffer, builder.addQuad(EnumFacing.UP, pos_x - buffer, offset, pos_y - buffer,
pos_x + buffer, offset, pos_y + buffer ); pos_x + buffer, offset, pos_y + buffer);
break; break;
case EAST: case EAST:
offset = 1.0f - offset; offset = 1.0f - offset;
builder.addQuad( EnumFacing.WEST, offset, pos_x - buffer, pos_y - buffer, builder.addQuad(EnumFacing.WEST, offset, pos_x - buffer, pos_y - buffer,
offset, pos_x + buffer, pos_y + buffer ); offset, pos_x + buffer, pos_y + buffer);
break; break;
case WEST: case WEST:
builder.addQuad( EnumFacing.EAST, offset, pos_x - buffer, pos_y - buffer, builder.addQuad(EnumFacing.EAST, offset, pos_x - buffer, pos_y - buffer,
offset, pos_x + buffer, pos_y + buffer ); offset, pos_x + buffer, pos_y + buffer);
break; break;
case SOUTH: case SOUTH:
offset = 1.0f - offset; offset = 1.0f - offset;
builder.addQuad( EnumFacing.NORTH, pos_x - buffer, pos_y - buffer, offset, builder.addQuad(EnumFacing.NORTH, pos_x - buffer, pos_y - buffer, offset,
pos_x + buffer, pos_y + buffer, offset ); pos_x + buffer, pos_y + buffer, offset);
break; break;
case NORTH: case NORTH:
builder.addQuad( EnumFacing.SOUTH, pos_x - buffer, pos_y - buffer, offset, builder.addQuad(EnumFacing.SOUTH, pos_x - buffer, pos_y - buffer, offset,
pos_x + buffer, pos_y + buffer, offset ); pos_x + buffer, pos_y + buffer, offset);
break; break;
default: default:
} }
} }
return builder.getOutput(); return builder.getOutput();
} }
@Override @Override
public boolean isAmbientOcclusion() public boolean isAmbientOcclusion() {
{ return false;
return false; }
}
@Override @Override
public boolean isGui3d() public boolean isGui3d() {
{ return true;
return true; }
}
@Override @Override
public boolean isBuiltInRenderer() public boolean isBuiltInRenderer() {
{ return false;
return false; }
}
@Override @Override
public TextureAtlasSprite getParticleTexture() public TextureAtlasSprite getParticleTexture() {
{ return this.textures[0];
return this.textures[0]; }
}
@Override @Override
public ItemCameraTransforms getItemCameraTransforms() public ItemCameraTransforms getItemCameraTransforms() {
{ return ItemCameraTransforms.DEFAULT;
return ItemCameraTransforms.DEFAULT; }
}
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides() {
{ return ItemOverrideList.NONE;
return ItemOverrideList.NONE; }
}
static List<ResourceLocation> getRequiredTextures() static List<ResourceLocation> getRequiredTextures() {
{ return ImmutableList.of(
return ImmutableList.of( TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3);
TEXTURE_PAINT1, TEXTURE_PAINT2, TEXTURE_PAINT3 ); }
}
} }
@@ -1,11 +1,6 @@
package appeng.block.paint; package appeng.block.paint;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
@@ -14,32 +9,31 @@ import net.minecraftforge.client.model.IModel;
import net.minecraftforge.common.model.IModelState; import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.model.TRSRTransformation;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
class PaintModel implements IModel
{
@Override class PaintModel implements IModel {
public Collection<ResourceLocation> getDependencies()
{
return Collections.emptyList();
}
@Override @Override
public Collection<ResourceLocation> getTextures() public Collection<ResourceLocation> getDependencies() {
{ return Collections.emptyList();
return PaintBakedModel.getRequiredTextures(); }
}
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public Collection<ResourceLocation> getTextures() {
{ return PaintBakedModel.getRequiredTextures();
return new PaintBakedModel( format, bakedTextureGetter ); }
}
@Override @Override
public IModelState getDefaultState() public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
{ return new PaintBakedModel(format, bakedTextureGetter);
return TRSRTransformation.identity(); }
}
@Override
public IModelState getDefaultState() {
return TRSRTransformation.identity();
}
} }
@@ -1,24 +1,20 @@
package appeng.block.paint; package appeng.block.paint;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class PaintRendering extends BlockRenderingCustomizer public class PaintRendering extends BlockRenderingCustomizer {
{
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.builtInModel("models/block/paint", new PaintModel());
rendering.builtInModel( "models/block/paint", new PaintModel() ); // Disable auto rotation
// Disable auto rotation rendering.modelCustomizer((location, model) -> model);
rendering.modelCustomizer( ( location, model ) -> model ); }
}
} }
@@ -1,31 +1,26 @@
package appeng.block.paint; package appeng.block.paint;
import java.util.Collection; import appeng.helpers.Splotch;
import java.util.List;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import appeng.helpers.Splotch; import java.util.Collection;
import java.util.List;
/** /**
* Used to transfer the state about paint splotches from the game thread to the render thread. * Used to transfer the state about paint splotches from the game thread to the render thread.
*/ */
class PaintSplotches class PaintSplotches {
{
private final List<Splotch> splotches; private final List<Splotch> splotches;
PaintSplotches( Collection<Splotch> splotches ) PaintSplotches(Collection<Splotch> splotches) {
{ this.splotches = ImmutableList.copyOf(splotches);
this.splotches = ImmutableList.copyOf( splotches ); }
}
List<Splotch> getSplotches() List<Splotch> getSplotches() {
{ return this.splotches;
return this.splotches; }
}
} }
@@ -1,34 +1,28 @@
package appeng.block.paint; package appeng.block.paint;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
class PaintSplotchesProperty implements IUnlistedProperty<PaintSplotches> class PaintSplotchesProperty implements IUnlistedProperty<PaintSplotches> {
{
@Override @Override
public String getName() public String getName() {
{ return "paint_splots";
return "paint_splots"; }
}
@Override @Override
public boolean isValid( PaintSplotches value ) public boolean isValid(PaintSplotches value) {
{ return value != null;
return value != null; }
}
@Override @Override
public Class<PaintSplotches> getType() public Class<PaintSplotches> getType() {
{ return PaintSplotches.class;
return PaintSplotches.class; }
}
@Override @Override
public String valueToString( PaintSplotches value ) public String valueToString(PaintSplotches value) {
{ return null;
return null; }
}
} }
@@ -19,6 +19,9 @@
package appeng.block.qnb; package appeng.block.qnb;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.ICustomCollision;
import appeng.tile.qnb.TileQuantumBridge;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@@ -34,97 +37,79 @@ import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.ICustomCollision;
import appeng.tile.qnb.TileQuantumBridge;
public abstract class BlockQuantumBase extends AEBaseTileBlock implements ICustomCollision {
public abstract class BlockQuantumBase extends AEBaseTileBlock implements ICustomCollision public static final PropertyBool FORMED = PropertyBool.create("formed");
{
public static final PropertyBool FORMED = PropertyBool.create( "formed" ); public static final QnbFormedStateProperty FORMED_STATE = new QnbFormedStateProperty();
public static final QnbFormedStateProperty FORMED_STATE = new QnbFormedStateProperty(); public BlockQuantumBase(final Material mat) {
super(mat);
final float shave = 2.0f / 16.0f;
this.boundingBox = new AxisAlignedBB(shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave);
this.setLightOpacity(0);
this.setFullSize(this.setOpaque(false));
this.setDefaultState(this.getDefaultState().withProperty(FORMED, false));
}
public BlockQuantumBase( final Material mat ) @Override
{ protected IProperty[] getAEStates() {
super( mat ); return new IProperty[]{FORMED};
final float shave = 2.0f / 16.0f; }
this.boundingBox = new AxisAlignedBB( shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave );
this.setLightOpacity( 0 );
this.setFullSize( this.setOpaque( false ) );
this.setDefaultState( this.getDefaultState().withProperty( FORMED, false ) );
}
@Override @Override
protected IProperty[] getAEStates() protected BlockStateContainer createBlockState() {
{ return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{FORMED_STATE});
return new IProperty[] { FORMED }; }
}
@Override @Override
protected BlockStateContainer createBlockState() public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ IExtendedBlockState extState = (IExtendedBlockState) state;
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { FORMED_STATE } );
}
@Override TileQuantumBridge bridge = this.getTileEntity(world, pos);
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) if (bridge != null) {
{ QnbFormedState formedState = new QnbFormedState(bridge.getAdjacentQuantumBridges(), bridge.isCorner(), bridge.isPowered());
IExtendedBlockState extState = (IExtendedBlockState) state; extState = extState.withProperty(FORMED_STATE, formedState);
}
TileQuantumBridge bridge = this.getTileEntity( world, pos ); return extState;
if( bridge != null ) }
{
QnbFormedState formedState = new QnbFormedState( bridge.getAdjacentQuantumBridges(), bridge.isCorner(), bridge.isPowered() );
extState = extState.withProperty( FORMED_STATE, formedState );
}
return extState; @Override
} public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
TileQuantumBridge bridge = this.getTileEntity(worldIn, pos);
if (bridge != null) {
state = state.withProperty(FORMED, bridge.isFormed());
}
return state;
}
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos ) public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
TileQuantumBridge bridge = this.getTileEntity( worldIn, pos ); }
if( bridge != null )
{
state = state.withProperty( FORMED, bridge.isFormed() );
}
return state;
}
@Override @Override
public BlockRenderLayer getBlockLayer() public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final TileQuantumBridge bridge = this.getTileEntity(world, pos);
return BlockRenderLayer.CUTOUT; if (bridge != null) {
} bridge.neighborUpdate();
}
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void breakBlock(final World w, final BlockPos pos, final IBlockState state) {
{ final TileQuantumBridge bridge = this.getTileEntity(w, pos);
final TileQuantumBridge bridge = this.getTileEntity( world, pos ); if (bridge != null) {
if( bridge != null ) bridge.breakCluster();
{ }
bridge.neighborUpdate();
}
}
@Override super.breakBlock(w, pos, state);
public void breakBlock( final World w, final BlockPos pos, final IBlockState state ) }
{
final TileQuantumBridge bridge = this.getTileEntity( w, pos );
if( bridge != null )
{
bridge.breakCluster();
}
super.breakBlock( w, pos, state ); @Override
} public boolean isFullCube(IBlockState state) {
return false;
@Override }
public boolean isFullCube( IBlockState state )
{
return false;
}
} }
@@ -19,12 +19,13 @@
package appeng.block.qnb; package appeng.block.qnb;
import java.util.Collections; import appeng.api.util.AEPartLocation;
import java.util.List; import appeng.client.EffectType;
import java.util.Random; import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import javax.annotation.Nullable; import appeng.helpers.AEGlassMaterial;
import appeng.tile.qnb.TileQuantumBridge;
import appeng.util.Platform;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -35,70 +36,55 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.client.EffectType; import java.util.Collections;
import appeng.core.AppEng; import java.util.List;
import appeng.core.sync.GuiBridge; import java.util.Random;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.qnb.TileQuantumBridge;
import appeng.util.Platform;
public class BlockQuantumLinkChamber extends BlockQuantumBase public class BlockQuantumLinkChamber extends BlockQuantumBase {
{
public BlockQuantumLinkChamber() public BlockQuantumLinkChamber() {
{ super(AEGlassMaterial.INSTANCE);
super( AEGlassMaterial.INSTANCE ); }
}
@Override @Override
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random rand ) public void randomDisplayTick(final IBlockState state, final World w, final BlockPos pos, final Random rand) {
{ final TileQuantumBridge bridge = this.getTileEntity(w, pos);
final TileQuantumBridge bridge = this.getTileEntity( w, pos ); if (bridge != null) {
if( bridge != null ) if (bridge.hasQES()) {
{ if (AppEng.proxy.shouldAddParticles(rand)) {
if( bridge.hasQES() ) AppEng.proxy.spawnEffect(EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, null);
{ }
if( AppEng.proxy.shouldAddParticles( rand ) ) }
{ }
AppEng.proxy.spawnEffect( EffectType.Energy, w, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, null ); }
}
}
}
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileQuantumBridge tg = this.getTileEntity( w, pos ); final TileQuantumBridge tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_QNB);
{ }
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_QNB ); return true;
} }
return true; return false;
} }
return false;
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ final double onePixel = 2.0 / 16.0;
final double onePixel = 2.0 / 16.0; return Collections.singletonList(new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
return Collections.singletonList( new AxisAlignedBB( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) ); }
}
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{ final double onePixel = 2.0 / 16.0;
final double onePixel = 2.0 / 16.0; out.add(new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
out.add( new AxisAlignedBB( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) ); }
}
} }
@@ -19,55 +19,44 @@
package appeng.block.qnb; package appeng.block.qnb;
import java.util.Collections; import appeng.tile.qnb.TileQuantumBridge;
import java.util.List;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.tile.qnb.TileQuantumBridge; import java.util.Collections;
import java.util.List;
public class BlockQuantumRing extends BlockQuantumBase public class BlockQuantumRing extends BlockQuantumBase {
{
public BlockQuantumRing() public BlockQuantumRing() {
{ super(Material.IRON);
super( Material.IRON ); }
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ double onePixel = 2.0 / 16.0;
double onePixel = 2.0 / 16.0; final TileQuantumBridge bridge = this.getTileEntity(w, pos);
final TileQuantumBridge bridge = this.getTileEntity( w, pos ); if (bridge != null && bridge.isCorner()) {
if( bridge != null && bridge.isCorner() ) onePixel = 4.0 / 16.0;
{ } else if (bridge != null && bridge.isFormed()) {
onePixel = 4.0 / 16.0; onePixel = 1.0 / 16.0;
} }
else if( bridge != null && bridge.isFormed() ) return Collections.singletonList(new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
{ }
onePixel = 1.0 / 16.0;
}
return Collections.singletonList( new AxisAlignedBB( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
}
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{ double onePixel = 2.0 / 16.0;
double onePixel = 2.0 / 16.0; final TileQuantumBridge bridge = this.getTileEntity(w, pos);
final TileQuantumBridge bridge = this.getTileEntity( w, pos ); if (bridge != null && bridge.isCorner()) {
if( bridge != null && bridge.isCorner() ) onePixel = 4.0 / 16.0;
{ } else if (bridge != null && bridge.isFormed()) {
onePixel = 4.0 / 16.0; onePixel = 1.0 / 16.0;
} }
else if( bridge != null && bridge.isFormed() ) out.add(new AxisAlignedBB(onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel));
{ }
onePixel = 1.0 / 16.0;
}
out.add( new AxisAlignedBB( onePixel, onePixel, onePixel, 1.0 - onePixel, 1.0 - onePixel, 1.0 - onePixel ) );
}
} }
@@ -1,16 +1,10 @@
package appeng.block.qnb; package appeng.block.qnb;
import java.util.EnumSet; import appeng.api.AEApi;
import java.util.List; import appeng.client.render.cablebus.CubeBuilder;
import java.util.Set; import appeng.core.AppEng;
import java.util.function.Function;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
@@ -23,222 +17,195 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.api.AEApi; import javax.annotation.Nullable;
import appeng.client.render.cablebus.CubeBuilder; import java.util.EnumSet;
import appeng.core.AppEng; import java.util.List;
import java.util.Set;
import java.util.function.Function;
class QnbFormedBakedModel implements IBakedModel class QnbFormedBakedModel implements IBakedModel {
{
private static final ResourceLocation TEXTURE_LINK = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_link" ); private static final ResourceLocation TEXTURE_LINK = new ResourceLocation(AppEng.MOD_ID, "blocks/quantum_link");
private static final ResourceLocation TEXTURE_RING = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring" ); private static final ResourceLocation TEXTURE_RING = new ResourceLocation(AppEng.MOD_ID, "blocks/quantum_ring");
private static final ResourceLocation TEXTURE_RING_LIGHT = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring_light" ); private static final ResourceLocation TEXTURE_RING_LIGHT = new ResourceLocation(AppEng.MOD_ID, "blocks/quantum_ring_light");
private static final ResourceLocation TEXTURE_RING_LIGHT_CORNER = new ResourceLocation( AppEng.MOD_ID, "blocks/quantum_ring_light_corner" ); private static final ResourceLocation TEXTURE_RING_LIGHT_CORNER = new ResourceLocation(AppEng.MOD_ID, "blocks/quantum_ring_light_corner");
private static final ResourceLocation TEXTURE_CABLE_GLASS = new ResourceLocation( AppEng.MOD_ID, "parts/cable/glass/transparent" ); private static final ResourceLocation TEXTURE_CABLE_GLASS = new ResourceLocation(AppEng.MOD_ID, "parts/cable/glass/transparent");
private static final ResourceLocation TEXTURE_COVERED_CABLE = new ResourceLocation( AppEng.MOD_ID, "parts/cable/covered/transparent" ); private static final ResourceLocation TEXTURE_COVERED_CABLE = new ResourceLocation(AppEng.MOD_ID, "parts/cable/covered/transparent");
private static final float DEFAULT_RENDER_MIN = 2.0f; private static final float DEFAULT_RENDER_MIN = 2.0f;
private static final float DEFAULT_RENDER_MAX = 14.0f; private static final float DEFAULT_RENDER_MAX = 14.0f;
private static final float CORNER_POWERED_RENDER_MIN = 3.9f; private static final float CORNER_POWERED_RENDER_MIN = 3.9f;
private static final float CORNER_POWERED_RENDER_MAX = 12.1f; private static final float CORNER_POWERED_RENDER_MAX = 12.1f;
private static final float CENTER_POWERED_RENDER_MIN = -0.01f; private static final float CENTER_POWERED_RENDER_MIN = -0.01f;
private static final float CENTER_POWERED_RENDER_MAX = 16.01f; private static final float CENTER_POWERED_RENDER_MAX = 16.01f;
private final VertexFormat vertexFormat; private final VertexFormat vertexFormat;
private final IBakedModel baseModel; private final IBakedModel baseModel;
private final Block linkBlock; private final Block linkBlock;
private final TextureAtlasSprite linkTexture; private final TextureAtlasSprite linkTexture;
private final TextureAtlasSprite ringTexture; private final TextureAtlasSprite ringTexture;
private final TextureAtlasSprite glassCableTexture; private final TextureAtlasSprite glassCableTexture;
private final TextureAtlasSprite coveredCableTexture; private final TextureAtlasSprite coveredCableTexture;
private final TextureAtlasSprite lightTexture; private final TextureAtlasSprite lightTexture;
private final TextureAtlasSprite lightCornerTexture; private final TextureAtlasSprite lightCornerTexture;
public QnbFormedBakedModel( VertexFormat vertexFormat, IBakedModel baseModel, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public QnbFormedBakedModel(VertexFormat vertexFormat, IBakedModel baseModel, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
{ this.vertexFormat = vertexFormat;
this.vertexFormat = vertexFormat; this.baseModel = baseModel;
this.baseModel = baseModel; this.linkTexture = bakedTextureGetter.apply(TEXTURE_LINK);
this.linkTexture = bakedTextureGetter.apply( TEXTURE_LINK ); this.ringTexture = bakedTextureGetter.apply(TEXTURE_RING);
this.ringTexture = bakedTextureGetter.apply( TEXTURE_RING ); this.glassCableTexture = bakedTextureGetter.apply(TEXTURE_CABLE_GLASS);
this.glassCableTexture = bakedTextureGetter.apply( TEXTURE_CABLE_GLASS ); this.coveredCableTexture = bakedTextureGetter.apply(TEXTURE_COVERED_CABLE);
this.coveredCableTexture = bakedTextureGetter.apply( TEXTURE_COVERED_CABLE ); this.lightTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT);
this.lightTexture = bakedTextureGetter.apply( TEXTURE_RING_LIGHT ); this.lightCornerTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT_CORNER);
this.lightCornerTexture = bakedTextureGetter.apply( TEXTURE_RING_LIGHT_CORNER ); this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse(null);
this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse( null ); }
}
@Override @Override
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand ) public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
{ // Get the correct base model
// Get the correct base model if (!(state instanceof IExtendedBlockState)) {
if( !( state instanceof IExtendedBlockState ) ) return this.baseModel.getQuads(state, side, rand);
{ }
return this.baseModel.getQuads( state, side, rand );
}
IExtendedBlockState extendedBlockState = (IExtendedBlockState) state; IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
QnbFormedState formedState = extendedBlockState.getValue( BlockQuantumBase.FORMED_STATE ); QnbFormedState formedState = extendedBlockState.getValue(BlockQuantumBase.FORMED_STATE);
return this.getQuads( formedState, state, side, rand ); return this.getQuads(formedState, state, side, rand);
} }
private List<BakedQuad> getQuads( QnbFormedState formedState, IBlockState state, EnumFacing side, long rand ) private List<BakedQuad> getQuads(QnbFormedState formedState, IBlockState state, EnumFacing side, long rand) {
{ CubeBuilder builder = new CubeBuilder(this.vertexFormat);
CubeBuilder builder = new CubeBuilder( this.vertexFormat );
if( state.getBlock() == this.linkBlock ) if (state.getBlock() == this.linkBlock) {
{ Set<EnumFacing> sides = formedState.getAdjacentQuantumBridges();
Set<EnumFacing> sides = formedState.getAdjacentQuantumBridges();
this.renderCableAt( builder, 0.11f * 16, this.glassCableTexture, 0.141f * 16, sides ); this.renderCableAt(builder, 0.11f * 16, this.glassCableTexture, 0.141f * 16, sides);
this.renderCableAt( builder, 0.188f * 16, this.coveredCableTexture, 0.1875f * 16, sides ); this.renderCableAt(builder, 0.188f * 16, this.coveredCableTexture, 0.1875f * 16, sides);
builder.setTexture( this.linkTexture ); builder.setTexture(this.linkTexture);
builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX ); builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX);
} } else {
else if (formedState.isCorner()) {
{ this.renderCableAt(builder, 0.188f * 16, this.coveredCableTexture, 0.05f * 16, formedState.getAdjacentQuantumBridges());
if( formedState.isCorner() )
{
this.renderCableAt( builder, 0.188f * 16, this.coveredCableTexture, 0.05f * 16, formedState.getAdjacentQuantumBridges() );
builder.setTexture( this.ringTexture ); builder.setTexture(this.ringTexture);
builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX ); builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX);
if( formedState.isPowered() ) if (formedState.isPowered()) {
{ builder.setTexture(this.lightCornerTexture);
builder.setTexture( this.lightCornerTexture ); builder.setRenderFullBright(true);
builder.setRenderFullBright( true ); for (EnumFacing facing : EnumFacing.values()) {
for( EnumFacing facing : EnumFacing.values() ) // Offset the face by a slight amount so that it is drawn over the already drawn ring texture
{ // (avoids z-fighting)
// Offset the face by a slight amount so that it is drawn over the already drawn ring texture float xOffset = Math.abs(facing.getFrontOffsetX() * 0.01f);
// (avoids z-fighting) float yOffset = Math.abs(facing.getFrontOffsetY() * 0.01f);
float xOffset = Math.abs( facing.getFrontOffsetX() * 0.01f ); float zOffset = Math.abs(facing.getFrontOffsetZ() * 0.01f);
float yOffset = Math.abs( facing.getFrontOffsetY() * 0.01f );
float zOffset = Math.abs( facing.getFrontOffsetZ() * 0.01f );
builder.setDrawFaces( EnumSet.of( facing ) ); builder.setDrawFaces(EnumSet.of(facing));
builder.addCube( builder.addCube(
DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset, DEFAULT_RENDER_MIN - zOffset, DEFAULT_RENDER_MIN - xOffset, DEFAULT_RENDER_MIN - yOffset, DEFAULT_RENDER_MIN - zOffset,
DEFAULT_RENDER_MAX + xOffset, DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset ); DEFAULT_RENDER_MAX + xOffset, DEFAULT_RENDER_MAX + yOffset, DEFAULT_RENDER_MAX + zOffset);
} }
} }
} } else {
else builder.setTexture(this.ringTexture);
{
builder.setTexture( this.ringTexture );
builder.addCube( 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 16, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX ); builder.addCube(0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 16, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX);
builder.addCube( DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, 16, DEFAULT_RENDER_MAX ); builder.addCube(DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MIN, DEFAULT_RENDER_MAX, 16, DEFAULT_RENDER_MAX);
builder.addCube( DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, 16 ); builder.addCube(DEFAULT_RENDER_MIN, DEFAULT_RENDER_MIN, 0, DEFAULT_RENDER_MAX, DEFAULT_RENDER_MAX, 16);
if( formedState.isPowered() ) if (formedState.isPowered()) {
{ builder.setTexture(this.lightTexture);
builder.setTexture( this.lightTexture ); builder.setRenderFullBright(true);
builder.setRenderFullBright( true ); for (EnumFacing facing : EnumFacing.values()) {
for( EnumFacing facing : EnumFacing.values() ) // Offset the face by a slight amount so that it is drawn over the already drawn ring texture
{ // (avoids z-fighting)
// Offset the face by a slight amount so that it is drawn over the already drawn ring texture float xOffset = Math.abs(facing.getFrontOffsetX() * 0.01f);
// (avoids z-fighting) float yOffset = Math.abs(facing.getFrontOffsetY() * 0.01f);
float xOffset = Math.abs( facing.getFrontOffsetX() * 0.01f ); float zOffset = Math.abs(facing.getFrontOffsetZ() * 0.01f);
float yOffset = Math.abs( facing.getFrontOffsetY() * 0.01f );
float zOffset = Math.abs( facing.getFrontOffsetZ() * 0.01f );
builder.setDrawFaces( EnumSet.of( facing ) ); builder.setDrawFaces(EnumSet.of(facing));
builder.addCube( builder.addCube(
-xOffset, -yOffset, -zOffset, -xOffset, -yOffset, -zOffset,
16 + xOffset, 16 + yOffset, 16 + zOffset ); 16 + xOffset, 16 + yOffset, 16 + zOffset);
} }
} }
} }
} }
return builder.getOutput(); return builder.getOutput();
} }
private void renderCableAt( CubeBuilder builder, float thickness, TextureAtlasSprite texture, float pull, Set<EnumFacing> connections ) private void renderCableAt(CubeBuilder builder, float thickness, TextureAtlasSprite texture, float pull, Set<EnumFacing> connections) {
{ builder.setTexture(texture);
builder.setTexture( texture );
if( connections.contains( EnumFacing.WEST ) ) if (connections.contains(EnumFacing.WEST)) {
{ builder.addCube(0, 8 - thickness, 8 - thickness, 8 - thickness - pull, 8 + thickness, 8 + thickness);
builder.addCube( 0, 8 - thickness, 8 - thickness, 8 - thickness - pull, 8 + thickness, 8 + thickness ); }
}
if( connections.contains( EnumFacing.EAST ) ) if (connections.contains(EnumFacing.EAST)) {
{ builder.addCube(8 + thickness + pull, 8 - thickness, 8 - thickness, 16, 8 + thickness, 8 + thickness);
builder.addCube( 8 + thickness + pull, 8 - thickness, 8 - thickness, 16, 8 + thickness, 8 + thickness ); }
}
if( connections.contains( EnumFacing.NORTH ) ) if (connections.contains(EnumFacing.NORTH)) {
{ builder.addCube(8 - thickness, 8 - thickness, 0, 8 + thickness, 8 + thickness, 8 - thickness - pull);
builder.addCube( 8 - thickness, 8 - thickness, 0, 8 + thickness, 8 + thickness, 8 - thickness - pull ); }
}
if( connections.contains( EnumFacing.SOUTH ) ) if (connections.contains(EnumFacing.SOUTH)) {
{ builder.addCube(8 - thickness, 8 - thickness, 8 + thickness + pull, 8 + thickness, 8 + thickness, 16);
builder.addCube( 8 - thickness, 8 - thickness, 8 + thickness + pull, 8 + thickness, 8 + thickness, 16 ); }
}
if( connections.contains( EnumFacing.DOWN ) ) if (connections.contains(EnumFacing.DOWN)) {
{ builder.addCube(8 - thickness, 0, 8 - thickness, 8 + thickness, 8 - thickness - pull, 8 + thickness);
builder.addCube( 8 - thickness, 0, 8 - thickness, 8 + thickness, 8 - thickness - pull, 8 + thickness ); }
}
if( connections.contains( EnumFacing.UP ) ) if (connections.contains(EnumFacing.UP)) {
{ builder.addCube(8 - thickness, 8 + thickness + pull, 8 - thickness, 8 + thickness, 16, 8 + thickness);
builder.addCube( 8 - thickness, 8 + thickness + pull, 8 - thickness, 8 + thickness, 16, 8 + thickness ); }
} }
}
@Override @Override
public boolean isAmbientOcclusion() public boolean isAmbientOcclusion() {
{ return this.baseModel.isAmbientOcclusion();
return this.baseModel.isAmbientOcclusion(); }
}
@Override @Override
public boolean isGui3d() public boolean isGui3d() {
{ return true;
return true; }
}
@Override @Override
public boolean isBuiltInRenderer() public boolean isBuiltInRenderer() {
{ return false;
return false; }
}
@Override @Override
public TextureAtlasSprite getParticleTexture() public TextureAtlasSprite getParticleTexture() {
{ return this.baseModel.getParticleTexture();
return this.baseModel.getParticleTexture(); }
}
@Override @Override
public ItemCameraTransforms getItemCameraTransforms() public ItemCameraTransforms getItemCameraTransforms() {
{ return this.baseModel.getItemCameraTransforms();
return this.baseModel.getItemCameraTransforms(); }
}
@Override @Override
public ItemOverrideList getOverrides() public ItemOverrideList getOverrides() {
{ return this.baseModel.getOverrides();
return this.baseModel.getOverrides(); }
}
public static List<ResourceLocation> getRequiredTextures() public static List<ResourceLocation> getRequiredTextures() {
{ return ImmutableList.of(
return ImmutableList.of( TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE, TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER);
TEXTURE_LINK, TEXTURE_RING, TEXTURE_CABLE_GLASS, TEXTURE_COVERED_CABLE, TEXTURE_RING_LIGHT, TEXTURE_RING_LIGHT_CORNER ); }
}
} }
@@ -1,12 +1,8 @@
package appeng.block.qnb; package appeng.block.qnb;
import java.util.Collection; import appeng.core.AppEng;
import java.util.function.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
@@ -16,49 +12,41 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.model.IModelState; import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.model.TRSRTransformation;
import appeng.core.AppEng; import java.util.Collection;
import java.util.function.Function;
public class QnbFormedModel implements IModel public class QnbFormedModel implements IModel {
{
private static final ResourceLocation MODEL_RING = new ResourceLocation( AppEng.MOD_ID, "block/qnb/ring" ); private static final ResourceLocation MODEL_RING = new ResourceLocation(AppEng.MOD_ID, "block/qnb/ring");
@Override @Override
public Collection<ResourceLocation> getDependencies() public Collection<ResourceLocation> getDependencies() {
{ return ImmutableList.of(MODEL_RING);
return ImmutableList.of( MODEL_RING ); }
}
@Override @Override
public Collection<ResourceLocation> getTextures() public Collection<ResourceLocation> getTextures() {
{ return QnbFormedBakedModel.getRequiredTextures();
return QnbFormedBakedModel.getRequiredTextures(); }
}
@Override @Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
{ IBakedModel ringModel = this.getBaseModel(MODEL_RING, state, format, bakedTextureGetter);
IBakedModel ringModel = this.getBaseModel( MODEL_RING, state, format, bakedTextureGetter ); return new QnbFormedBakedModel(format, ringModel, bakedTextureGetter);
return new QnbFormedBakedModel( format, ringModel, bakedTextureGetter ); }
}
@Override @Override
public IModelState getDefaultState() public IModelState getDefaultState() {
{ return TRSRTransformation.identity();
return TRSRTransformation.identity(); }
}
private IBakedModel getBaseModel( ResourceLocation model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter ) private IBakedModel getBaseModel(ResourceLocation model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
{ // Load the base model
// Load the base model try {
try return ModelLoaderRegistry.getModel(model).bake(state, format, bakedTextureGetter);
{ } catch (Exception e) {
return ModelLoaderRegistry.getModel( model ).bake( state, format, bakedTextureGetter ); throw new RuntimeException(e);
} }
catch( Exception e ) }
{
throw new RuntimeException( e );
}
}
} }
@@ -1,41 +1,35 @@
package appeng.block.qnb; package appeng.block.qnb;
import java.util.Set;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import java.util.Set;
public class QnbFormedState
{
private final Set<EnumFacing> adjacentQuantumBridges; public class QnbFormedState {
private final boolean corner; private final Set<EnumFacing> adjacentQuantumBridges;
private final boolean powered; private final boolean corner;
public QnbFormedState( Set<EnumFacing> adjacentQuantumBridges, boolean corner, boolean powered ) private final boolean powered;
{
this.adjacentQuantumBridges = adjacentQuantumBridges;
this.corner = corner;
this.powered = powered;
}
public Set<EnumFacing> getAdjacentQuantumBridges() public QnbFormedState(Set<EnumFacing> adjacentQuantumBridges, boolean corner, boolean powered) {
{ this.adjacentQuantumBridges = adjacentQuantumBridges;
return this.adjacentQuantumBridges; this.corner = corner;
} this.powered = powered;
}
public boolean isCorner() public Set<EnumFacing> getAdjacentQuantumBridges() {
{ return this.adjacentQuantumBridges;
return this.corner; }
}
public boolean isPowered() public boolean isCorner() {
{ return this.corner;
return this.powered; }
}
public boolean isPowered() {
return this.powered;
}
} }
@@ -1,34 +1,28 @@
package appeng.block.qnb; package appeng.block.qnb;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
public class QnbFormedStateProperty implements IUnlistedProperty<QnbFormedState> public class QnbFormedStateProperty implements IUnlistedProperty<QnbFormedState> {
{
@Override @Override
public String getName() public String getName() {
{ return "qnb_formed";
return "qnb_formed"; }
}
@Override @Override
public boolean isValid( QnbFormedState value ) public boolean isValid(QnbFormedState value) {
{ return value != null;
return value != null; }
}
@Override @Override
public Class<QnbFormedState> getType() public Class<QnbFormedState> getType() {
{ return QnbFormedState.class;
return QnbFormedState.class; }
}
@Override @Override
public String valueToString( QnbFormedState value ) public String valueToString(QnbFormedState value) {
{ return null;
return null; }
}
} }
@@ -1,24 +1,20 @@
package appeng.block.qnb; package appeng.block.qnb;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class QuantumBridgeRendering extends BlockRenderingCustomizer public class QuantumBridgeRendering extends BlockRenderingCustomizer {
{
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.builtInModel("models/block/qnb/qnb_formed", new QnbFormedModel());
rendering.builtInModel( "models/block/qnb/qnb_formed", new QnbFormedModel() ); // Disable auto rotation
// Disable auto rotation rendering.modelCustomizer((location, model) -> model);
rendering.modelCustomizer( ( location, model ) -> model ); }
}
} }
@@ -19,9 +19,8 @@
package appeng.block.spatial; package appeng.block.spatial;
import java.util.Arrays; import appeng.block.AEBaseBlock;
import java.util.List; import appeng.helpers.ICustomCollision;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@@ -36,57 +35,49 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.block.AEBaseBlock; import java.util.Arrays;
import appeng.helpers.ICustomCollision; import java.util.List;
public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision {
{
public BlockMatrixFrame() public BlockMatrixFrame() {
{ super(Material.ANVIL);
super( Material.ANVIL ); this.setResistance(6000000.0F);
this.setResistance( 6000000.0F ); this.setBlockUnbreakable();
this.setBlockUnbreakable(); this.setLightOpacity(0);
this.setLightOpacity( 0 ); this.setOpaque(false);
this.setOpaque( false ); }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void getSubBlocks( final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks ) public void getSubBlocks(final CreativeTabs tabs, final NonNullList<ItemStack> itemStacks) {
{ // do nothing
// do nothing }
}
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ return Arrays.asList(new AxisAlignedBB[]{});// AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 )
return Arrays.asList( new AxisAlignedBB[] {} );// AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) // } );
// } ); }
}
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{ out.add(new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0));
out.add( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) ); }
}
@Override @Override
public boolean canPlaceBlockAt( final World worldIn, final BlockPos pos ) public boolean canPlaceBlockAt(final World worldIn, final BlockPos pos) {
{ return false;
return false; }
}
@Override @Override
public void onBlockExploded( final World world, final BlockPos pos, final Explosion explosion ) public void onBlockExploded(final World world, final BlockPos pos, final Explosion explosion) {
{ // Don't explode.
// Don't explode. }
}
@Override @Override
public boolean canEntityDestroy( final IBlockState state, final IBlockAccess world, final BlockPos pos, final Entity entity ) public boolean canEntityDestroy(final IBlockState state, final IBlockAccess world, final BlockPos pos, final Entity entity) {
{ return false;
return false; }
}
} }
@@ -19,8 +19,11 @@
package appeng.block.spatial; package appeng.block.spatial;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@@ -31,48 +34,36 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class BlockSpatialIOPort extends AEBaseTileBlock public class BlockSpatialIOPort extends AEBaseTileBlock {
{
public BlockSpatialIOPort() public BlockSpatialIOPort() {
{ super(Material.IRON);
super( Material.IRON ); }
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final TileSpatialIOPort te = this.getTileEntity(world, pos);
final TileSpatialIOPort te = this.getTileEntity( world, pos ); if (te != null) {
if( te != null ) te.updateRedstoneState();
{ }
te.updateRedstoneState(); }
}
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileSpatialIOPort tg = this.getTileEntity( w, pos ); final TileSpatialIOPort tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_SPATIAL_IO_PORT);
{ }
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_SPATIAL_IO_PORT ); return true;
} }
return true; return false;
} }
return false;
}
} }
@@ -19,6 +19,10 @@
package appeng.block.spatial; package appeng.block.spatial;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.spatial.SpatialPylonStateProperty;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.spatial.TileSpatialPylon;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@@ -30,73 +34,57 @@ import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.spatial.SpatialPylonStateProperty;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.spatial.TileSpatialPylon;
public class BlockSpatialPylon extends AEBaseTileBlock {
public class BlockSpatialPylon extends AEBaseTileBlock public static final SpatialPylonStateProperty STATE = new SpatialPylonStateProperty();
{
public static final SpatialPylonStateProperty STATE = new SpatialPylonStateProperty(); public BlockSpatialPylon() {
super(AEGlassMaterial.INSTANCE);
}
public BlockSpatialPylon() @Override
{ protected BlockStateContainer createBlockState() {
super( AEGlassMaterial.INSTANCE ); return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{STATE});
} }
@Override @Override
protected BlockStateContainer createBlockState() public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ IExtendedBlockState extState = (IExtendedBlockState) state;
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { STATE } );
}
@Override return extState.withProperty(STATE, this.getDisplayState(world, pos));
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) }
{
IExtendedBlockState extState = (IExtendedBlockState) state;
return extState.withProperty( STATE, this.getDisplayState( world, pos ) ); @Override
} public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
final TileSpatialPylon tsp = this.getTileEntity(world, pos);
if (tsp != null) {
tsp.neighborChanged();
}
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public int getLightValue(final IBlockState state, final IBlockAccess w, final BlockPos pos) {
{ final TileSpatialPylon tsp = this.getTileEntity(w, pos);
final TileSpatialPylon tsp = this.getTileEntity( world, pos ); if (tsp != null) {
if( tsp != null ) return tsp.getLightValue();
{ }
tsp.neighborChanged(); return super.getLightValue(state, w, pos);
} }
}
@Override private int getDisplayState(IBlockAccess world, BlockPos pos) {
public int getLightValue( final IBlockState state, final IBlockAccess w, final BlockPos pos ) TileSpatialPylon te = this.getTileEntity(world, pos);
{
final TileSpatialPylon tsp = this.getTileEntity( w, pos );
if( tsp != null )
{
return tsp.getLightValue();
}
return super.getLightValue( state, w, pos );
}
private int getDisplayState( IBlockAccess world, BlockPos pos ) if (te == null) {
{ return 0;
TileSpatialPylon te = this.getTileEntity( world, pos ); }
if( te == null ) return te.getDisplayBits();
{ }
return 0;
}
return te.getDisplayBits(); @Override
} public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
@Override }
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
} }
@@ -19,8 +19,12 @@
package appeng.block.storage; package appeng.block.storage;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileChest;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
@@ -34,87 +38,67 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileChest;
import appeng.util.Platform;
public class BlockChest extends AEBaseTileBlock public class BlockChest extends AEBaseTileBlock {
{
private final static PropertyEnum<DriveSlotState> SLOT_STATE = PropertyEnum.create( "slot_state", DriveSlotState.class ); private final static PropertyEnum<DriveSlotState> SLOT_STATE = PropertyEnum.create("slot_state", DriveSlotState.class);
public BlockChest() public BlockChest() {
{ super(Material.IRON);
super( Material.IRON ); this.setDefaultState(this.getDefaultState().withProperty(SLOT_STATE, DriveSlotState.EMPTY));
this.setDefaultState( this.getDefaultState().withProperty( SLOT_STATE, DriveSlotState.EMPTY ) ); }
}
@Override @Override
protected IProperty[] getAEStates() protected IProperty[] getAEStates() {
{ return new IProperty[]{SLOT_STATE};
return new IProperty[] { SLOT_STATE }; }
}
@Override @Override
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
@Override @Override
public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos ) public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
{ DriveSlotState slotState = DriveSlotState.EMPTY;
DriveSlotState slotState = DriveSlotState.EMPTY;
TileChest te = this.getTileEntity( worldIn, pos ); TileChest te = this.getTileEntity(worldIn, pos);
if( te != null ) if (te != null) {
{ if (te.getCellCount() >= 1) {
if( te.getCellCount() >= 1 ) slotState = DriveSlotState.fromCellStatus(te.getCellStatus(0));
{ }
slotState = DriveSlotState.fromCellStatus( te.getCellStatus( 0 ) ); // Power-state has to be checked separately
} if (!te.isPowered() && slotState != DriveSlotState.EMPTY) {
// Power-state has to be checked separately slotState = DriveSlotState.OFFLINE;
if( !te.isPowered() && slotState != DriveSlotState.EMPTY ) }
{ }
slotState = DriveSlotState.OFFLINE;
}
}
return super.getActualState( state, worldIn, pos ) return super.getActualState(state, worldIn, pos)
.withProperty( SLOT_STATE, slotState ); .withProperty(SLOT_STATE, slotState);
} }
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ final TileChest tg = this.getTileEntity(w, pos);
final TileChest tg = this.getTileEntity( w, pos ); if (tg != null && !p.isSneaking()) {
if( tg != null && !p.isSneaking() ) if (Platform.isClient()) {
{ return true;
if( Platform.isClient() ) }
{
return true;
}
if( side != tg.getUp() ) if (side != tg.getUp()) {
{ Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_CHEST);
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CHEST ); } else {
} if (!tg.openGui(p)) {
else p.sendMessage(PlayerMessages.ChestCannotReadStorageCell.get());
{ }
if( !tg.openGui( p ) ) }
{
p.sendMessage( PlayerMessages.ChestCannotReadStorageCell.get() );
}
}
return true; return true;
} }
return false; return false;
} }
} }
@@ -19,8 +19,12 @@
package appeng.block.storage; package appeng.block.storage;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.UnlistedProperty;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileDrive;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@@ -36,65 +40,51 @@ import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.IUnlistedProperty;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.client.UnlistedProperty;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileDrive;
import appeng.util.Platform;
public class BlockDrive extends AEBaseTileBlock public class BlockDrive extends AEBaseTileBlock {
{
public static final UnlistedProperty<DriveSlotsState> SLOTS_STATE = new UnlistedProperty<>( "drive_slots_state", DriveSlotsState.class ); public static final UnlistedProperty<DriveSlotsState> SLOTS_STATE = new UnlistedProperty<>("drive_slots_state", DriveSlotsState.class);
public BlockDrive() public BlockDrive() {
{ super(Material.IRON);
super( Material.IRON ); }
}
@Override @Override
public BlockRenderLayer getBlockLayer() public BlockRenderLayer getBlockLayer() {
{ return BlockRenderLayer.CUTOUT;
return BlockRenderLayer.CUTOUT; }
}
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState() {
{ return new ExtendedBlockState(this, this.getAEStates(), new IUnlistedProperty[]{
return new ExtendedBlockState( this, this.getAEStates(), new IUnlistedProperty[] { SLOTS_STATE,
SLOTS_STATE, FORWARD,
FORWARD, UP
UP });
} ); }
}
@Override @Override
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos ) public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
{ TileDrive te = this.getTileEntity(world, pos);
TileDrive te = this.getTileEntity( world, pos ); IExtendedBlockState extState = (IExtendedBlockState) super.getExtendedState(state, world, pos);
IExtendedBlockState extState = (IExtendedBlockState) super.getExtendedState( state, world, pos ); return extState.withProperty(SLOTS_STATE, te == null ? DriveSlotsState.createEmpty(10) : DriveSlotsState.fromChestOrDrive(te));
return extState.withProperty( SLOTS_STATE, te == null ? DriveSlotsState.createEmpty( 10 ) : DriveSlotsState.fromChestOrDrive( te ) ); }
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileDrive tg = this.getTileEntity( w, pos ); final TileDrive tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_DRIVE);
{ }
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_DRIVE ); return true;
} }
return true; return false;
} }
return false;
}
} }
@@ -19,8 +19,11 @@
package appeng.block.storage; package appeng.block.storage;
import javax.annotation.Nullable; import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileIOPort;
import appeng.util.Platform;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@@ -31,48 +34,36 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import appeng.tile.storage.TileIOPort;
import appeng.util.Platform;
public class BlockIOPort extends AEBaseTileBlock public class BlockIOPort extends AEBaseTileBlock {
{
public BlockIOPort() public BlockIOPort() {
{ super(Material.IRON);
super( Material.IRON ); }
}
@Override @Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos ) public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
{ final TileIOPort te = this.getTileEntity(world, pos);
final TileIOPort te = this.getTileEntity( world, pos ); if (te != null) {
if( te != null ) te.updateRedstoneState();
{ }
te.updateRedstoneState(); }
}
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (p.isSneaking()) {
if( p.isSneaking() ) return false;
{ }
return false;
}
final TileIOPort tg = this.getTileEntity( w, pos ); final TileIOPort tg = this.getTileEntity(w, pos);
if( tg != null ) if (tg != null) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(p, tg, AEPartLocation.fromFacing(side), GuiBridge.GUI_IOPORT);
{ }
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_IOPORT ); return true;
} }
return true; return false;
} }
return false;
}
} }
@@ -19,11 +19,12 @@
package appeng.block.storage; package appeng.block.storage;
import java.util.Collections; import appeng.api.util.AEPartLocation;
import java.util.List; import appeng.block.AEBaseTileBlock;
import appeng.core.sync.GuiBridge;
import javax.annotation.Nullable; import appeng.helpers.ICustomCollision;
import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@@ -36,94 +37,81 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.util.AEPartLocation; import javax.annotation.Nullable;
import appeng.block.AEBaseTileBlock; import java.util.Collections;
import appeng.core.sync.GuiBridge; import java.util.List;
import appeng.helpers.ICustomCollision;
import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform;
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision {
{
private static final double AABB_OFFSET_BOTTOM = 0.00; private static final double AABB_OFFSET_BOTTOM = 0.00;
private static final double AABB_OFFSET_SIDES = 0.06; private static final double AABB_OFFSET_SIDES = 0.06;
private static final double AABB_OFFSET_TOP = 0.125; private static final double AABB_OFFSET_TOP = 0.125;
public enum SkyChestType public enum SkyChestType {
{ STONE, BLOCK
STONE, BLOCK }
};
public final SkyChestType type; public final SkyChestType type;
public BlockSkyChest( final SkyChestType type ) public BlockSkyChest(final SkyChestType type) {
{ super(Material.ROCK);
super( Material.ROCK ); this.setOpaque(this.setFullSize(false));
this.setOpaque( this.setFullSize( false ) ); this.lightOpacity = 0;
this.lightOpacity = 0; this.setHardness(50);
this.setHardness( 50 ); this.blockResistance = 150.0f;
this.blockResistance = 150.0f; this.type = type;
this.type = type; }
}
@Override @Override
public EnumBlockRenderType getRenderType( IBlockState state ) public EnumBlockRenderType getRenderType(IBlockState state) {
{ return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; }
}
@Override @Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) public boolean onActivated(final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ) {
{ if (Platform.isServer()) {
if( Platform.isServer() ) Platform.openGUI(player, this.getTileEntity(w, pos), AEPartLocation.fromFacing(side), GuiBridge.GUI_SKYCHEST);
{ }
Platform.openGUI( player, this.getTileEntity( w, pos ), AEPartLocation.fromFacing( side ), GuiBridge.GUI_SKYCHEST );
}
return true; return true;
} }
@Override @Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b ) public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity thePlayer, final boolean b) {
{ final AxisAlignedBB aabb = this.computeAABB(w, pos);
final AxisAlignedBB aabb = this.computeAABB( w, pos );
return Collections.singletonList( aabb ); return Collections.singletonList(aabb);
} }
@Override @Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e ) public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
{ final AxisAlignedBB aabb = this.computeAABB(w, pos);
final AxisAlignedBB aabb = this.computeAABB( w, pos );
out.add( aabb ); out.add(aabb);
} }
private AxisAlignedBB computeAABB( final World w, final BlockPos pos ) private AxisAlignedBB computeAABB(final World w, final BlockPos pos) {
{ final TileSkyChest sk = this.getTileEntity(w, pos);
final TileSkyChest sk = this.getTileEntity( w, pos ); EnumFacing o = EnumFacing.UP;
EnumFacing o = EnumFacing.UP;
if( sk != null ) if (sk != null) {
{ o = sk.getUp();
o = sk.getUp(); }
}
final double offsetX = o.getFrontOffsetX() == 0 ? AABB_OFFSET_SIDES : 0.0; final double offsetX = o.getFrontOffsetX() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = o.getFrontOffsetY() == 0 ? AABB_OFFSET_SIDES : 0.0; final double offsetY = o.getFrontOffsetY() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = o.getFrontOffsetZ() == 0 ? AABB_OFFSET_SIDES : 0.0; final double offsetZ = o.getFrontOffsetZ() == 0 ? AABB_OFFSET_SIDES : 0.0;
// for x/z top and bottom is swapped // for x/z top and bottom is swapped
final double minX = Math.max( 0.0, offsetX + ( o.getFrontOffsetX() < 0 ? AABB_OFFSET_BOTTOM : ( o.getFrontOffsetX() * AABB_OFFSET_TOP ) ) ); final double minX = Math.max(0.0, offsetX + (o.getFrontOffsetX() < 0 ? AABB_OFFSET_BOTTOM : (o.getFrontOffsetX() * AABB_OFFSET_TOP)));
final double minY = Math.max( 0.0, offsetY + ( o.getFrontOffsetY() < 0 ? AABB_OFFSET_TOP : ( o.getFrontOffsetY() * AABB_OFFSET_BOTTOM ) ) ); final double minY = Math.max(0.0, offsetY + (o.getFrontOffsetY() < 0 ? AABB_OFFSET_TOP : (o.getFrontOffsetY() * AABB_OFFSET_BOTTOM)));
final double minZ = Math.max( 0.0, offsetZ + ( o.getFrontOffsetZ() < 0 ? AABB_OFFSET_BOTTOM : ( o.getFrontOffsetZ() * AABB_OFFSET_TOP ) ) ); final double minZ = Math.max(0.0, offsetZ + (o.getFrontOffsetZ() < 0 ? AABB_OFFSET_BOTTOM : (o.getFrontOffsetZ() * AABB_OFFSET_TOP)));
final double maxX = Math.min( 1.0, 1.0 - offsetX - ( o.getFrontOffsetX() < 0 ? AABB_OFFSET_TOP : ( o.getFrontOffsetX() * AABB_OFFSET_BOTTOM ) ) ); final double maxX = Math.min(1.0, 1.0 - offsetX - (o.getFrontOffsetX() < 0 ? AABB_OFFSET_TOP : (o.getFrontOffsetX() * AABB_OFFSET_BOTTOM)));
final double maxY = Math.min( 1.0, 1.0 - offsetY - ( o.getFrontOffsetY() < 0 ? AABB_OFFSET_BOTTOM : ( o.getFrontOffsetY() * AABB_OFFSET_TOP ) ) ); final double maxY = Math.min(1.0, 1.0 - offsetY - (o.getFrontOffsetY() < 0 ? AABB_OFFSET_BOTTOM : (o.getFrontOffsetY() * AABB_OFFSET_TOP)));
final double maxZ = Math.min( 1.0, 1.0 - offsetZ - ( o.getFrontOffsetZ() < 0 ? AABB_OFFSET_TOP : ( o.getFrontOffsetZ() * AABB_OFFSET_BOTTOM ) ) ); final double maxZ = Math.min(1.0, 1.0 - offsetZ - (o.getFrontOffsetZ() < 0 ? AABB_OFFSET_TOP : (o.getFrontOffsetZ() * AABB_OFFSET_BOTTOM)));
return new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ); return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
} }
} }
@@ -19,27 +19,24 @@
package appeng.block.storage; package appeng.block.storage;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.ColorableTileBlockColor; import appeng.client.render.ColorableTileBlockColor;
import appeng.client.render.StaticItemColor; import appeng.client.render.StaticItemColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ChestRendering extends BlockRenderingCustomizer public class ChestRendering extends BlockRenderingCustomizer {
{
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ // I checked, the ME chest doesn't keep its color in item form
// I checked, the ME chest doesn't keep its color in item form itemRendering.color(new StaticItemColor(AEColor.TRANSPARENT));
itemRendering.color( new StaticItemColor( AEColor.TRANSPARENT ) ); rendering.blockColor(new ColorableTileBlockColor());
rendering.blockColor( new ColorableTileBlockColor() ); }
}
} }
@@ -25,11 +25,9 @@ import appeng.bootstrap.IItemRendering;
import appeng.client.render.model.DriveModel; import appeng.client.render.model.DriveModel;
public class DriveRendering extends BlockRenderingCustomizer public class DriveRendering extends BlockRenderingCustomizer {
{ @Override
@Override public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) rendering.builtInModel("models/block/builtin/drive", new DriveModel());
{ }
rendering.builtInModel( "models/block/builtin/drive", new DriveModel() );
}
} }
@@ -25,51 +25,46 @@ import net.minecraft.util.IStringSerializable;
/** /**
* Describes the different states a single slot of a BlockDrive can be in in terms of rendering. * Describes the different states a single slot of a BlockDrive can be in in terms of rendering.
*/ */
public enum DriveSlotState implements IStringSerializable public enum DriveSlotState implements IStringSerializable {
{
// No cell in slot // No cell in slot
EMPTY( "empty" ), EMPTY("empty"),
// Cell in slot, but unpowered // Cell in slot, but unpowered
OFFLINE( "offline" ), OFFLINE("offline"),
// Online and free space // Online and free space
ONLINE( "online" ), ONLINE("online"),
// Types full, space left // Types full, space left
TYPES_FULL( "types_full" ), TYPES_FULL("types_full"),
// Completely full // Completely full
FULL( "full" ); FULL("full");
private final String name; private final String name;
DriveSlotState( String name ) DriveSlotState(String name) {
{ this.name = name;
this.name = name; }
}
@Override @Override
public String getName() public String getName() {
{ return this.name;
return this.name; }
}
public static DriveSlotState fromCellStatus( int cellStatus ) public static DriveSlotState fromCellStatus(int cellStatus) {
{ switch (cellStatus) {
switch( cellStatus ) default:
{ case 0:
default: return DriveSlotState.EMPTY;
case 0: case 1:
return DriveSlotState.EMPTY; return DriveSlotState.ONLINE;
case 1: case 2:
return DriveSlotState.ONLINE; return DriveSlotState.TYPES_FULL;
case 2: case 3:
return DriveSlotState.TYPES_FULL; return DriveSlotState.FULL;
case 3: }
return DriveSlotState.FULL; }
}
}
} }
@@ -25,64 +25,49 @@ import appeng.api.implementations.tiles.IChestOrDrive;
/** /**
* Contains the full information about what the state of the slots in a BlockDrive is. * Contains the full information about what the state of the slots in a BlockDrive is.
*/ */
public class DriveSlotsState public class DriveSlotsState {
{
private final DriveSlotState[] slots; private final DriveSlotState[] slots;
private DriveSlotsState( DriveSlotState[] slots ) private DriveSlotsState(DriveSlotState[] slots) {
{ this.slots = slots;
this.slots = slots; }
}
public DriveSlotState getState( int index ) public DriveSlotState getState(int index) {
{ if (index >= this.slots.length) {
if( index >= this.slots.length ) return DriveSlotState.EMPTY;
{ }
return DriveSlotState.EMPTY; return this.slots[index];
} }
return this.slots[index];
}
public int getSlotCount() public int getSlotCount() {
{ return this.slots.length;
return this.slots.length; }
}
/** /**
* Retrieve an array that describes the state of each slot in this drive or chest. * Retrieve an array that describes the state of each slot in this drive or chest.
*/ */
public static DriveSlotsState fromChestOrDrive( IChestOrDrive chestOrDrive ) public static DriveSlotsState fromChestOrDrive(IChestOrDrive chestOrDrive) {
{ DriveSlotState[] slots = new DriveSlotState[chestOrDrive.getCellCount()];
DriveSlotState[] slots = new DriveSlotState[chestOrDrive.getCellCount()]; for (int i = 0; i < chestOrDrive.getCellCount(); i++) {
for( int i = 0; i < chestOrDrive.getCellCount(); i++ ) if (!chestOrDrive.isPowered()) {
{ if (chestOrDrive.getCellStatus(i) != 0) {
if( !chestOrDrive.isPowered() ) slots[i] = DriveSlotState.OFFLINE;
{ } else {
if( chestOrDrive.getCellStatus( i ) != 0 ) slots[i] = DriveSlotState.EMPTY;
{ }
slots[i] = DriveSlotState.OFFLINE; } else {
} slots[i] = DriveSlotState.fromCellStatus(chestOrDrive.getCellStatus(i));
else }
{ }
slots[i] = DriveSlotState.EMPTY; return new DriveSlotsState(slots);
} }
}
else
{
slots[i] = DriveSlotState.fromCellStatus( chestOrDrive.getCellStatus( i ) );
}
}
return new DriveSlotsState( slots );
}
public static DriveSlotsState createEmpty( int slotCount ) public static DriveSlotsState createEmpty(int slotCount) {
{ DriveSlotState[] slots = new DriveSlotState[slotCount];
DriveSlotState[] slots = new DriveSlotState[slotCount]; for (int i = 0; i < slotCount; i++) {
for( int i = 0; i < slotCount; i++ ) slots[i] = DriveSlotState.EMPTY;
{ }
slots[i] = DriveSlotState.EMPTY; return new DriveSlotsState(slots);
} }
return new DriveSlotsState( slots );
}
} }
@@ -19,51 +19,45 @@
package appeng.block.storage; package appeng.block.storage;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.BlockRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering; import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering; import appeng.bootstrap.IItemRendering;
import appeng.client.render.tesr.SkyChestTESR; import appeng.client.render.tesr.SkyChestTESR;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class SkyChestRenderingCustomizer extends BlockRenderingCustomizer public class SkyChestRenderingCustomizer extends BlockRenderingCustomizer {
{
private final BlockSkyChest.SkyChestType type; private final BlockSkyChest.SkyChestType type;
public SkyChestRenderingCustomizer( BlockSkyChest.SkyChestType type ) public SkyChestRenderingCustomizer(BlockSkyChest.SkyChestType type) {
{ this.type = type;
this.type = type; }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
@Override @Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
{ rendering.tesr(new SkyChestTESR());
rendering.tesr( new SkyChestTESR() );
// Register a custom non-tesr item model // Register a custom non-tesr item model
String modelName = this.getModelFromType(); String modelName = this.getModelFromType();
ModelResourceLocation model = new ModelResourceLocation( "appliedenergistics2:" + modelName, "inventory" ); ModelResourceLocation model = new ModelResourceLocation("appliedenergistics2:" + modelName, "inventory");
itemRendering.model( model ).variants( model ); itemRendering.model(model).variants(model);
} }
private String getModelFromType() private String getModelFromType() {
{ final String modelName;
final String modelName; switch (this.type) {
switch( this.type ) default:
{ case STONE:
default: modelName = "sky_stone_chest";
case STONE: break;
modelName = "sky_stone_chest"; case BLOCK:
break; modelName = "smooth_sky_stone_chest";
case BLOCK: break;
modelName = "smooth_sky_stone_chest"; }
break; return modelName;
} }
return modelName;
}
} }
@@ -19,25 +19,6 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.definitions.IBlockDefinition; import appeng.api.definitions.IBlockDefinition;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
import appeng.block.AEBaseItemBlock; import appeng.block.AEBaseItemBlock;
@@ -49,233 +30,209 @@ import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.CreativeTab; import appeng.core.CreativeTab;
import appeng.core.features.AEFeature; import appeng.core.features.*;
import appeng.core.features.ActivityState;
import appeng.core.features.BlockDefinition;
import appeng.core.features.BlockStackSrc;
import appeng.core.features.TileDefinition;
import appeng.tile.AEBaseTile; import appeng.tile.AEBaseTile;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
class BlockDefinitionBuilder implements IBlockBuilder class BlockDefinitionBuilder implements IBlockBuilder {
{
private final FeatureFactory factory; private final FeatureFactory factory;
private final String registryName; private final String registryName;
private final Supplier<? extends Block> blockSupplier; private final Supplier<? extends Block> blockSupplier;
private final List<BiFunction<Block, Item, IBootstrapComponent>> bootstrapComponents = new ArrayList<>(); private final List<BiFunction<Block, Item, IBootstrapComponent>> bootstrapComponents = new ArrayList<>();
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class ); private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
private CreativeTabs creativeTab = CreativeTab.instance; private final CreativeTabs creativeTab = CreativeTab.instance;
private TileEntityDefinition tileEntityDefinition; private TileEntityDefinition tileEntityDefinition;
private boolean disableItem = false; private boolean disableItem = false;
private Function<Block, ItemBlock> itemFactory; private Function<Block, ItemBlock> itemFactory;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private BlockRendering blockRendering; private BlockRendering blockRendering;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private ItemRendering itemRendering; private ItemRendering itemRendering;
BlockDefinitionBuilder( FeatureFactory factory, String id, Supplier<? extends Block> blockSupplier ) BlockDefinitionBuilder(FeatureFactory factory, String id, Supplier<? extends Block> blockSupplier) {
{ this.factory = factory;
this.factory = factory; this.registryName = id;
this.registryName = id; this.blockSupplier = blockSupplier;
this.blockSupplier = blockSupplier;
if( Platform.isClient() ) if (Platform.isClient()) {
{ this.blockRendering = new BlockRendering();
this.blockRendering = new BlockRendering(); this.itemRendering = new ItemRendering();
this.itemRendering = new ItemRendering(); }
} }
}
@Override @Override
public BlockDefinitionBuilder bootstrap( BiFunction<Block, Item, IBootstrapComponent> callback ) public BlockDefinitionBuilder bootstrap(BiFunction<Block, Item, IBootstrapComponent> callback) {
{ this.bootstrapComponents.add(callback);
this.bootstrapComponents.add( callback ); return this;
return this; }
}
@Override @Override
public IBlockBuilder features( AEFeature... features ) public IBlockBuilder features(AEFeature... features) {
{ this.features.clear();
this.features.clear(); this.addFeatures(features);
this.addFeatures( features ); return this;
return this; }
}
@Override @Override
public IBlockBuilder addFeatures( AEFeature... features ) public IBlockBuilder addFeatures(AEFeature... features) {
{ Collections.addAll(this.features, features);
Collections.addAll( this.features, features ); return this;
return this; }
}
@Override @Override
public BlockDefinitionBuilder rendering( BlockRenderingCustomizer callback ) public BlockDefinitionBuilder rendering(BlockRenderingCustomizer callback) {
{ if (Platform.isClient()) {
if( Platform.isClient() ) this.customizeForClient(callback);
{ }
this.customizeForClient( callback );
}
return this; return this;
} }
@Override @Override
public IBlockBuilder tileEntity( TileEntityDefinition tileEntityDefinition ) public IBlockBuilder tileEntity(TileEntityDefinition tileEntityDefinition) {
{ this.tileEntityDefinition = tileEntityDefinition;
this.tileEntityDefinition = tileEntityDefinition; return this;
return this; }
}
@Override @Override
public IBlockBuilder useCustomItemModel() public IBlockBuilder useCustomItemModel() {
{ this.rendering(new BlockRenderingCustomizer() {
this.rendering( new BlockRenderingCustomizer() @Override
{ @SideOnly(Side.CLIENT)
@Override public void customize(IBlockRendering rendering, IItemRendering itemRendering) {
@SideOnly( Side.CLIENT ) ModelResourceLocation model = new ModelResourceLocation(new ResourceLocation(AppEng.MOD_ID, BlockDefinitionBuilder.this.registryName), "inventory");
public void customize( IBlockRendering rendering, IItemRendering itemRendering ) itemRendering.model(model).variants(model);
{ }
ModelResourceLocation model = new ModelResourceLocation( new ResourceLocation( AppEng.MOD_ID, BlockDefinitionBuilder.this.registryName ), "inventory" ); });
itemRendering.model( model ).variants( model );
}
} );
return this; return this;
} }
@Override @Override
public IBlockBuilder item( Function<Block, ItemBlock> factory ) public IBlockBuilder item(Function<Block, ItemBlock> factory) {
{ this.itemFactory = factory;
this.itemFactory = factory; return this;
return this; }
}
@Override @Override
public IBlockBuilder disableItem() public IBlockBuilder disableItem() {
{ this.disableItem = true;
this.disableItem = true; return this;
return this; }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private void customizeForClient( BlockRenderingCustomizer callback ) private void customizeForClient(BlockRenderingCustomizer callback) {
{ callback.customize(this.blockRendering, this.itemRendering);
callback.customize( this.blockRendering, this.itemRendering ); }
}
@SuppressWarnings( "unchecked" ) @SuppressWarnings("unchecked")
@Override @Override
public <T extends IBlockDefinition> T build() public <T extends IBlockDefinition> T build() {
{ if (!AEConfig.instance().areFeaturesEnabled(this.features)) {
if( !AEConfig.instance().areFeaturesEnabled( this.features ) ) return (T) new TileDefinition(this.registryName, null, null);
{ }
return (T) new TileDefinition( this.registryName, null, null );
}
// Create block and matching item, and set factory name of both // Create block and matching item, and set factory name of both
Block block = this.blockSupplier.get(); Block block = this.blockSupplier.get();
block.setRegistryName( AppEng.MOD_ID, this.registryName ); block.setRegistryName(AppEng.MOD_ID, this.registryName);
block.setUnlocalizedName( "appliedenergistics2." + this.registryName ); block.setUnlocalizedName("appliedenergistics2." + this.registryName);
ItemBlock item = this.constructItemFromBlock( block ); ItemBlock item = this.constructItemFromBlock(block);
if( item != null ) if (item != null) {
{ item.setRegistryName(AppEng.MOD_ID, this.registryName);
item.setRegistryName( AppEng.MOD_ID, this.registryName ); }
}
// Register the item and block with the game // Register the item and block with the game
this.factory.addBootstrapComponent( (IBlockRegistrationComponent) ( side, registry ) -> registry.register( block ) ); this.factory.addBootstrapComponent((IBlockRegistrationComponent) (side, registry) -> registry.register(block));
if( item != null ) if (item != null) {
{ this.factory.addBootstrapComponent((IItemRegistrationComponent) (side, registry) -> registry.register(item));
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, registry ) -> registry.register( item ) ); }
}
block.setCreativeTab( this.creativeTab ); block.setCreativeTab(this.creativeTab);
// Register all extra handlers // Register all extra handlers
this.bootstrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( block, item ) ) ); this.bootstrapComponents.forEach(component -> this.factory.addBootstrapComponent(component.apply(block, item)));
if( this.tileEntityDefinition != null && block instanceof AEBaseTileBlock ) if (this.tileEntityDefinition != null && block instanceof AEBaseTileBlock) {
{ ((AEBaseTileBlock) block).setTileEntity(this.tileEntityDefinition.getTileEntityClass());
( (AEBaseTileBlock) block ).setTileEntity( this.tileEntityDefinition.getTileEntityClass() ); if (this.tileEntityDefinition.getName() == null) {
if( this.tileEntityDefinition.getName() == null ) this.tileEntityDefinition.setName(this.registryName);
{ }
this.tileEntityDefinition.setName( this.registryName );
}
} }
if( Platform.isClient() ) if (Platform.isClient()) {
{ if (block instanceof AEBaseTileBlock) {
if( block instanceof AEBaseTileBlock ) AEBaseTileBlock tileBlock = (AEBaseTileBlock) block;
{ this.blockRendering.apply(this.factory, block, tileBlock.getTileEntityClass());
AEBaseTileBlock tileBlock = (AEBaseTileBlock) block; } else {
this.blockRendering.apply( this.factory, block, tileBlock.getTileEntityClass() ); this.blockRendering.apply(this.factory, block, null);
} }
else
{
this.blockRendering.apply( this.factory, block, null );
}
if( item != null ) if (item != null) {
{ this.itemRendering.apply(this.factory, item);
this.itemRendering.apply( this.factory, item ); }
} }
}
if( block instanceof AEBaseTileBlock ) if (block instanceof AEBaseTileBlock) {
{ this.factory.addBootstrapComponent((IPreInitComponent) side ->
this.factory.addBootstrapComponent( (IPreInitComponent) side -> {
{ AEBaseTile.registerTileItem(
AEBaseTile.registerTileItem( this.tileEntityDefinition == null ? ((AEBaseTileBlock) block).getTileEntityClass() : this.tileEntityDefinition.getTileEntityClass(),
this.tileEntityDefinition == null ? ( (AEBaseTileBlock) block ).getTileEntityClass() : this.tileEntityDefinition.getTileEntityClass(), new BlockStackSrc(block, 0, ActivityState.Enabled));
new BlockStackSrc( block, 0, ActivityState.Enabled ) ); });
} );
if( this.tileEntityDefinition != null ) if (this.tileEntityDefinition != null) {
{ this.factory.tileEntityComponent.addTileEntity(this.tileEntityDefinition);
this.factory.tileEntityComponent.addTileEntity( this.tileEntityDefinition ); }
}
return (T) new TileDefinition( this.registryName, (AEBaseTileBlock) block, item ); return (T) new TileDefinition(this.registryName, (AEBaseTileBlock) block, item);
} } else {
else return (T) new BlockDefinition(this.registryName, block, item);
{ }
return (T) new BlockDefinition( this.registryName, block, item ); }
}
}
@Nullable @Nullable
private ItemBlock constructItemFromBlock( Block block ) private ItemBlock constructItemFromBlock(Block block) {
{ if (this.disableItem) {
if( this.disableItem ) return null;
{ }
return null;
}
if( this.itemFactory != null ) if (this.itemFactory != null) {
{ return this.itemFactory.apply(block);
return this.itemFactory.apply( block ); } else if (block instanceof AEBaseBlock) {
} return new AEBaseItemBlock(block);
else if( block instanceof AEBaseBlock ) } else {
{ return new ItemBlock(block);
return new AEBaseItemBlock( block ); }
} }
else
{
return new ItemBlock( block );
}
}
} }
@@ -19,10 +19,11 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.HashMap; import appeng.block.AEBaseTileBlock;
import java.util.Map; import appeng.bootstrap.components.BlockColorComponent;
import java.util.function.BiFunction; import appeng.bootstrap.components.StateMapperComponent;
import appeng.bootstrap.components.TesrComponent;
import appeng.client.render.model.AutoRotatingModel;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@@ -33,103 +34,87 @@ import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.block.AEBaseTileBlock; import java.util.HashMap;
import appeng.bootstrap.components.BlockColorComponent; import java.util.Map;
import appeng.bootstrap.components.StateMapperComponent; import java.util.function.BiFunction;
import appeng.bootstrap.components.TesrComponent;
import appeng.client.render.model.AutoRotatingModel;
class BlockRendering implements IBlockRendering class BlockRendering implements IBlockRendering {
{
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> modelCustomizer; private BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> modelCustomizer;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private IBlockColor blockColor; private IBlockColor blockColor;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private TileEntitySpecialRenderer<?> tesr; private TileEntitySpecialRenderer<?> tesr;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private IStateMapper stateMapper; private IStateMapper stateMapper;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private Map<String, IModel> builtInModels = new HashMap<>(); private final Map<String, IModel> builtInModels = new HashMap<>();
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public IBlockRendering modelCustomizer( BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer ) public IBlockRendering modelCustomizer(BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer) {
{ this.modelCustomizer = customizer;
this.modelCustomizer = customizer; return this;
return this; }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
@Override @Override
public IBlockRendering blockColor( IBlockColor blockColor ) public IBlockRendering blockColor(IBlockColor blockColor) {
{ this.blockColor = blockColor;
this.blockColor = blockColor; return this;
return this; }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
@Override @Override
public IBlockRendering tesr( TileEntitySpecialRenderer<?> tesr ) public IBlockRendering tesr(TileEntitySpecialRenderer<?> tesr) {
{ this.tesr = tesr;
this.tesr = tesr; return this;
return this; }
}
@Override @Override
public IBlockRendering builtInModel( String name, IModel model ) public IBlockRendering builtInModel(String name, IModel model) {
{ this.builtInModels.put(name, model);
this.builtInModels.put( name, model ); return this;
return this; }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
@Override @Override
public IBlockRendering stateMapper( IStateMapper mapper ) public IBlockRendering stateMapper(IStateMapper mapper) {
{ this.stateMapper = mapper;
this.stateMapper = mapper; return this;
return this; }
}
void apply( FeatureFactory factory, Block block, Class<?> tileEntityClass ) void apply(FeatureFactory factory, Block block, Class<?> tileEntityClass) {
{ if (this.tesr != null) {
if( this.tesr != null ) if (tileEntityClass == null) {
{ throw new IllegalStateException("Tried to register a TESR for " + block + " even though no tile entity has been specified.");
if( tileEntityClass == null ) }
{ factory.addBootstrapComponent(new TesrComponent(tileEntityClass, this.tesr));
throw new IllegalStateException( "Tried to register a TESR for " + block + " even though no tile entity has been specified." ); }
}
factory.addBootstrapComponent( new TesrComponent( tileEntityClass, this.tesr ) );
}
if( this.modelCustomizer != null ) if (this.modelCustomizer != null) {
{ factory.addModelOverride(block.getRegistryName().getResourcePath(), this.modelCustomizer);
factory.addModelOverride( block.getRegistryName().getResourcePath(), this.modelCustomizer ); } else if (block instanceof AEBaseTileBlock) {
} // This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as
else if( block instanceof AEBaseTileBlock ) // extended props
{ factory.addModelOverride(block.getRegistryName().getResourcePath(), (l, m) -> new AutoRotatingModel(m));
// This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as }
// extended props
factory.addModelOverride( block.getRegistryName().getResourcePath(), ( l, m ) -> new AutoRotatingModel( m ) );
}
// TODO : 1.12 // TODO : 1.12
this.builtInModels.forEach( factory::addBuiltInModel ); this.builtInModels.forEach(factory::addBuiltInModel);
if( this.blockColor != null ) if (this.blockColor != null) {
{ factory.addBootstrapComponent(new BlockColorComponent(block, this.blockColor));
factory.addBootstrapComponent( new BlockColorComponent( block, this.blockColor ) ); }
}
if( this.stateMapper != null ) if (this.stateMapper != null) {
{ factory.addBootstrapComponent(new StateMapperComponent(block, this.stateMapper));
factory.addBootstrapComponent( new StateMapperComponent( block, this.stateMapper ) ); }
} }
}
} }
@@ -28,10 +28,9 @@ import net.minecraftforge.fml.relauncher.SideOnly;
* used * used
* due to them not being able to be annotated with @SideOnly(CLIENT). * due to them not being able to be annotated with @SideOnly(CLIENT).
*/ */
public abstract class BlockRenderingCustomizer public abstract class BlockRenderingCustomizer {
{
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public abstract void customize( IBlockRendering rendering, IItemRendering itemRendering ); public abstract void customize(IBlockRendering rendering, IItemRendering itemRendering);
} }
@@ -19,24 +19,6 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition; import appeng.api.util.AEColoredItemDefinition;
@@ -48,111 +30,107 @@ import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition; import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.ItemStackSrc; import appeng.core.features.ItemStackSrc;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Supplier;
public class FeatureFactory public class FeatureFactory {
{
private final AEFeature[] defaultFeatures; private final AEFeature[] defaultFeatures;
private final Map<Class<? extends IBootstrapComponent>, List<IBootstrapComponent>> bootstrapComponents; private final Map<Class<? extends IBootstrapComponent>, List<IBootstrapComponent>> bootstrapComponents;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private ModelOverrideComponent modelOverrideComponent; private ModelOverrideComponent modelOverrideComponent;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private BuiltInModelComponent builtInModelComponent; private BuiltInModelComponent builtInModelComponent;
public final TileEntityComponent tileEntityComponent; public final TileEntityComponent tileEntityComponent;
public FeatureFactory() public FeatureFactory() {
{ this.defaultFeatures = new AEFeature[]{AEFeature.CORE};
this.defaultFeatures = new AEFeature[] { AEFeature.CORE }; this.bootstrapComponents = new HashMap<>();
this.bootstrapComponents = new HashMap<>();
this.tileEntityComponent = new TileEntityComponent(); this.tileEntityComponent = new TileEntityComponent();
this.addBootstrapComponent( this.tileEntityComponent ); this.addBootstrapComponent(this.tileEntityComponent);
if( Platform.isClient() ) if (Platform.isClient()) {
{ this.modelOverrideComponent = new ModelOverrideComponent();
this.modelOverrideComponent = new ModelOverrideComponent(); this.addBootstrapComponent(this.modelOverrideComponent);
this.addBootstrapComponent( this.modelOverrideComponent );
this.builtInModelComponent = new BuiltInModelComponent(); this.builtInModelComponent = new BuiltInModelComponent();
this.addBootstrapComponent( this.builtInModelComponent ); this.addBootstrapComponent(this.builtInModelComponent);
} }
} }
private FeatureFactory( FeatureFactory parent, AEFeature... defaultFeatures ) private FeatureFactory(FeatureFactory parent, AEFeature... defaultFeatures) {
{ this.defaultFeatures = defaultFeatures.clone();
this.defaultFeatures = defaultFeatures.clone(); this.bootstrapComponents = parent.bootstrapComponents;
this.bootstrapComponents = parent.bootstrapComponents; this.tileEntityComponent = parent.tileEntityComponent;
this.tileEntityComponent = parent.tileEntityComponent; if (Platform.isClient()) {
if( Platform.isClient() ) this.modelOverrideComponent = parent.modelOverrideComponent;
{ this.builtInModelComponent = parent.builtInModelComponent;
this.modelOverrideComponent = parent.modelOverrideComponent; }
this.builtInModelComponent = parent.builtInModelComponent; }
}
}
public IBlockBuilder block( String id, Supplier<Block> block ) public IBlockBuilder block(String id, Supplier<Block> block) {
{ return new BlockDefinitionBuilder(this, id, block).features(this.defaultFeatures);
return new BlockDefinitionBuilder( this, id, block ).features( this.defaultFeatures ); }
}
public IItemBuilder item( String id, Supplier<Item> item ) public IItemBuilder item(String id, Supplier<Item> item) {
{ return new ItemDefinitionBuilder(this, id, item).features(this.defaultFeatures);
return new ItemDefinitionBuilder( this, id, item ).features( this.defaultFeatures ); }
}
public AEColoredItemDefinition colored( IItemDefinition target, int offset ) public AEColoredItemDefinition colored(IItemDefinition target, int offset) {
{ ColoredItemDefinition definition = new ColoredItemDefinition();
ColoredItemDefinition definition = new ColoredItemDefinition();
target.maybeItem().ifPresent( targetItem -> target.maybeItem().ifPresent(targetItem ->
{ {
for( final AEColor color : AEColor.VALID_COLORS ) for (final AEColor color : AEColor.VALID_COLORS) {
{ final ActivityState state = ActivityState.from(target.isEnabled());
final ActivityState state = ActivityState.from( target.isEnabled() );
definition.add( color, new ItemStackSrc( targetItem, offset + color.ordinal(), state ) ); definition.add(color, new ItemStackSrc(targetItem, offset + color.ordinal(), state));
} }
} ); });
return definition; return definition;
} }
public FeatureFactory features( AEFeature... features ) public FeatureFactory features(AEFeature... features) {
{ return new FeatureFactory(this, features);
return new FeatureFactory( this, features ); }
}
public void addBootstrapComponent( IBootstrapComponent component ) public void addBootstrapComponent(IBootstrapComponent component) {
{ Arrays.stream(component.getClass().getInterfaces())
Arrays.stream( component.getClass().getInterfaces() ) .filter(i -> IBootstrapComponent.class.isAssignableFrom(i))
.filter( i -> IBootstrapComponent.class.isAssignableFrom( i ) ) .forEach(i -> this.addBootstrapComponent((Class<? extends IBootstrapComponent>) i, component));
.forEach( i -> this.addBootstrapComponent( (Class<? extends IBootstrapComponent>) i, component ) ); }
}
private <T extends IBootstrapComponent> void addBootstrapComponent( Class<? extends IBootstrapComponent> eventType, T component ) private <T extends IBootstrapComponent> void addBootstrapComponent(Class<? extends IBootstrapComponent> eventType, T component) {
{ this.bootstrapComponents.computeIfAbsent(eventType, c -> new ArrayList<IBootstrapComponent>()).add(component);
this.bootstrapComponents.computeIfAbsent( eventType, c -> new ArrayList<IBootstrapComponent>() ).add( component ); }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
void addBuiltInModel( String path, IModel model ) void addBuiltInModel(String path, IModel model) {
{ this.builtInModelComponent.addModel(path, model);
this.builtInModelComponent.addModel( path, model ); }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
void addModelOverride( String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer ) void addModelOverride(String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer) {
{ this.modelOverrideComponent.addOverride(resourcePath, customizer);
this.modelOverrideComponent.addOverride( resourcePath, customizer ); }
}
public <T extends IBootstrapComponent> Iterator<T> getBootstrapComponents( Class<T> eventType ) public <T extends IBootstrapComponent> Iterator<T> getBootstrapComponents(Class<T> eventType) {
{ return (Iterator<T>) this.bootstrapComponents.getOrDefault(eventType, Collections.emptyList()).iterator();
return (Iterator<T>) this.bootstrapComponents.getOrDefault( eventType, Collections.emptyList() ).iterator(); }
}
} }
@@ -19,42 +19,40 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.function.BiFunction; import appeng.api.definitions.IBlockDefinition;
import java.util.function.Function; import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.features.AEFeature;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import appeng.api.definitions.IBlockDefinition; import java.util.function.BiFunction;
import appeng.bootstrap.definitions.TileEntityDefinition; import java.util.function.Function;
import appeng.core.features.AEFeature;
public interface IBlockBuilder public interface IBlockBuilder {
{ IBlockBuilder bootstrap(BiFunction<Block, Item, IBootstrapComponent> component);
IBlockBuilder bootstrap( BiFunction<Block, Item, IBootstrapComponent> component );
IBlockBuilder features( AEFeature... features ); IBlockBuilder features(AEFeature... features);
IBlockBuilder addFeatures( AEFeature... features ); IBlockBuilder addFeatures(AEFeature... features);
IBlockBuilder rendering( BlockRenderingCustomizer callback ); IBlockBuilder rendering(BlockRenderingCustomizer callback);
IBlockBuilder tileEntity( TileEntityDefinition tileEntityDefinition ); IBlockBuilder tileEntity(TileEntityDefinition tileEntityDefinition);
/** /**
* Don't register an item for this block. * Don't register an item for this block.
*/ */
IBlockBuilder disableItem(); IBlockBuilder disableItem();
/** /**
* Forces this block's item to uses a custom model, instead of using the default block state as the item model. * Forces this block's item to uses a custom model, instead of using the default block state as the item model.
* The model has the same name as the registry name. * The model has the same name as the registry name.
*/ */
IBlockBuilder useCustomItemModel(); IBlockBuilder useCustomItemModel();
IBlockBuilder item( Function<Block, ItemBlock> factory ); IBlockBuilder item(Function<Block, ItemBlock> factory);
<T extends IBlockDefinition> T build(); <T extends IBlockDefinition> T build();
} }
@@ -19,8 +19,6 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.function.BiFunction;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper; import net.minecraft.client.renderer.block.statemap.IStateMapper;
@@ -30,29 +28,30 @@ import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.function.BiFunction;
/** /**
* Allows for client-side rendering to be customized in the context of block/item registration. * Allows for client-side rendering to be customized in the context of block/item registration.
*/ */
public interface IBlockRendering public interface IBlockRendering {
{
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IBlockRendering modelCustomizer( BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer ); IBlockRendering modelCustomizer(BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer);
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IBlockRendering blockColor( IBlockColor blockColor ); IBlockRendering blockColor(IBlockColor blockColor);
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IBlockRendering stateMapper( IStateMapper mapper ); IBlockRendering stateMapper(IStateMapper mapper);
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IBlockRendering tesr( TileEntitySpecialRenderer<?> tesr ); IBlockRendering tesr(TileEntitySpecialRenderer<?> tesr);
/** /**
* Registers a built-in model under the given resource path. * Registers a built-in model under the given resource path.
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IBlockRendering builtInModel( String name, IModel model ); IBlockRendering builtInModel(String name, IModel model);
} }
@@ -23,6 +23,5 @@ package appeng.bootstrap;
* Bootstrap components can be registered to take part in the various initialization phases of Forge. * Bootstrap components can be registered to take part in the various initialization phases of Forge.
* See the individual subclasses for a specific forge initalization event. * See the individual subclasses for a specific forge initalization event.
*/ */
public interface IBootstrapComponent public interface IBootstrapComponent {
{
} }
@@ -24,7 +24,6 @@ import net.minecraft.advancements.ICriterionTrigger;
@FunctionalInterface @FunctionalInterface
public interface ICriterionTriggerRegistry public interface ICriterionTriggerRegistry {
{ void register(ICriterionTrigger<? extends ICriterionInstance> trigger);
void register( ICriterionTrigger<? extends ICriterionInstance> trigger );
} }
@@ -19,37 +19,35 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.function.Function; import appeng.core.features.AEFeature;
import java.util.function.Supplier; import appeng.core.features.ItemDefinition;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.IBehaviorDispenseItem; import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import appeng.core.features.AEFeature; import java.util.function.Function;
import appeng.core.features.ItemDefinition; import java.util.function.Supplier;
/** /**
* Allows an item to be defined and registered with the game. * Allows an item to be defined and registered with the game.
* The item is only registered once build is called. * The item is only registered once build is called.
*/ */
public interface IItemBuilder public interface IItemBuilder {
{ IItemBuilder bootstrap(Function<Item, IBootstrapComponent> component);
IItemBuilder bootstrap( Function<Item, IBootstrapComponent> component );
IItemBuilder features( AEFeature... features ); IItemBuilder features(AEFeature... features);
IItemBuilder addFeatures( AEFeature... features ); IItemBuilder addFeatures(AEFeature... features);
IItemBuilder creativeTab( CreativeTabs tab ); IItemBuilder creativeTab(CreativeTabs tab);
IItemBuilder rendering( ItemRenderingCustomizer callback ); IItemBuilder rendering(ItemRenderingCustomizer callback);
/** /**
* Registers a custom dispenser behavior for this item. * Registers a custom dispenser behavior for this item.
*/ */
IItemBuilder dispenserBehavior( Supplier<IBehaviorDispenseItem> behavior ); IItemBuilder dispenserBehavior(Supplier<IBehaviorDispenseItem> behavior);
ItemDefinition build(); ItemDefinition build();
} }
@@ -19,9 +19,6 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
@@ -30,66 +27,66 @@ import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Arrays;
import java.util.Collection;
/** /**
* Allows the rendering of an item to be customized. * Allows the rendering of an item to be customized.
*/ */
public interface IItemRendering public interface IItemRendering {
{
/** /**
* Registers a custom item mesh definition that will be used to dynamically determine the * Registers a custom item mesh definition that will be used to dynamically determine the
* item model to be used for rendering by inspecting the item stack (i.e. for NBT data). * item model to be used for rendering by inspecting the item stack (i.e. for NBT data).
* Please * Please
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IItemRendering meshDefinition( ItemMeshDefinition meshDefinition ); IItemRendering meshDefinition(ItemMeshDefinition meshDefinition);
/** /**
* Registers an item model for meta=0, see {@link #model(int, ModelResourceLocation)}. * Registers an item model for meta=0, see {@link #model(int, ModelResourceLocation)}.
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
default IItemRendering model( ModelResourceLocation model ) default IItemRendering model(ModelResourceLocation model) {
{ return model(0, model);
return model( 0, model ); }
}
/** /**
* Registers an item model for a given meta. * Registers an item model for a given meta.
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IItemRendering model( int meta, ModelResourceLocation model ); IItemRendering model(int meta, ModelResourceLocation model);
/** /**
* Convenient override for {@link #variants(Collection)}. * Convenient override for {@link #variants(Collection)}.
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
default IItemRendering variants( ResourceLocation... resources ) default IItemRendering variants(ResourceLocation... resources) {
{ return variants(Arrays.asList(resources));
return variants( Arrays.asList( resources ) ); }
}
/** /**
* Registers the item variants of this item. This are all models that need to be loaded for this item. * Registers the item variants of this item. This are all models that need to be loaded for this item.
* This has no direct effect on rendering, but is used to load models that are used for example by * This has no direct effect on rendering, but is used to load models that are used for example by
* the ItemMeshDefinition. * the ItemMeshDefinition.
* * <p>
* Models registered via {@link #model(int, ModelResourceLocation)} are automatically added here. * Models registered via {@link #model(int, ModelResourceLocation)} are automatically added here.
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IItemRendering variants( Collection<ResourceLocation> resources ); IItemRendering variants(Collection<ResourceLocation> resources);
/** /**
* Registers a custom item color definition that inspects an item stack and tint and * Registers a custom item color definition that inspects an item stack and tint and
* returns a color multiplier. * returns a color multiplier.
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IItemRendering color( IItemColor itemColor ); IItemRendering color(IItemColor itemColor);
/** /**
* Registers a built-in model under the given resource path. * Registers a built-in model under the given resource path.
*/ */
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
IItemRendering builtInModel( String name, IModel model ); IItemRendering builtInModel(String name, IModel model);
} }
@@ -27,13 +27,12 @@ import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public interface IModelRegistry public interface IModelRegistry {
{ void registerItemVariants(Item item, ResourceLocation... names);
void registerItemVariants( Item item, ResourceLocation... names );
void setCustomModelResourceLocation( Item item, int metadata, ModelResourceLocation model ); void setCustomModelResourceLocation(Item item, int metadata, ModelResourceLocation model);
void setCustomMeshDefinition( Item item, ItemMeshDefinition meshDefinition ); void setCustomMeshDefinition(Item item, ItemMeshDefinition meshDefinition);
void setCustomStateMapper( Block block, IStateMapper mapper ); void setCustomStateMapper(Block block, IStateMapper mapper);
} }
@@ -19,20 +19,6 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.block.BlockDispenser;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.components.IItemRegistrationComponent; import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IPostInitComponent; import appeng.bootstrap.components.IPostInitComponent;
import appeng.core.AEConfig; import appeng.core.AEConfig;
@@ -41,129 +27,127 @@ import appeng.core.CreativeTab;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.features.ItemDefinition; import appeng.core.features.ItemDefinition;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.block.BlockDispenser;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
class ItemDefinitionBuilder implements IItemBuilder class ItemDefinitionBuilder implements IItemBuilder {
{
private final FeatureFactory factory; private final FeatureFactory factory;
private final String registryName; private final String registryName;
private final Supplier<Item> itemSupplier; private final Supplier<Item> itemSupplier;
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class ); private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
private final List<Function<Item, IBootstrapComponent>> boostrapComponents = new ArrayList<>(); private final List<Function<Item, IBootstrapComponent>> boostrapComponents = new ArrayList<>();
private Supplier<IBehaviorDispenseItem> dispenserBehaviorSupplier; private Supplier<IBehaviorDispenseItem> dispenserBehaviorSupplier;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private ItemRendering itemRendering; private ItemRendering itemRendering;
private CreativeTabs creativeTab = CreativeTab.instance; private CreativeTabs creativeTab = CreativeTab.instance;
ItemDefinitionBuilder( FeatureFactory factory, String registryName, Supplier<Item> itemSupplier ) ItemDefinitionBuilder(FeatureFactory factory, String registryName, Supplier<Item> itemSupplier) {
{ this.factory = factory;
this.factory = factory; this.registryName = registryName;
this.registryName = registryName; this.itemSupplier = itemSupplier;
this.itemSupplier = itemSupplier; if (Platform.isClient()) {
if( Platform.isClient() ) this.itemRendering = new ItemRendering();
{ }
this.itemRendering = new ItemRendering(); }
}
}
@Override @Override
public IItemBuilder bootstrap( Function<Item, IBootstrapComponent> component ) public IItemBuilder bootstrap(Function<Item, IBootstrapComponent> component) {
{ this.boostrapComponents.add(component);
this.boostrapComponents.add( component ); return this;
return this; }
}
@Override @Override
public IItemBuilder features( AEFeature... features ) public IItemBuilder features(AEFeature... features) {
{ this.features.clear();
this.features.clear(); this.addFeatures(features);
this.addFeatures( features ); return this;
return this; }
}
@Override @Override
public IItemBuilder addFeatures( AEFeature... features ) public IItemBuilder addFeatures(AEFeature... features) {
{ Collections.addAll(this.features, features);
Collections.addAll( this.features, features ); return this;
return this; }
}
@Override @Override
public IItemBuilder creativeTab( CreativeTabs tab ) public IItemBuilder creativeTab(CreativeTabs tab) {
{ this.creativeTab = tab;
this.creativeTab = tab; return this;
return this; }
}
@Override @Override
public IItemBuilder rendering( ItemRenderingCustomizer callback ) public IItemBuilder rendering(ItemRenderingCustomizer callback) {
{ if (Platform.isClient()) {
if( Platform.isClient() ) this.customizeForClient(callback);
{ }
this.customizeForClient( callback );
}
return this; return this;
} }
@Override @Override
public IItemBuilder dispenserBehavior( Supplier<IBehaviorDispenseItem> behavior ) public IItemBuilder dispenserBehavior(Supplier<IBehaviorDispenseItem> behavior) {
{ this.dispenserBehaviorSupplier = behavior;
this.dispenserBehaviorSupplier = behavior; return this;
return this; }
}
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private void customizeForClient( ItemRenderingCustomizer callback ) private void customizeForClient(ItemRenderingCustomizer callback) {
{ callback.customize(this.itemRendering);
callback.customize( this.itemRendering ); }
}
@Override @Override
public ItemDefinition build() public ItemDefinition build() {
{ if (!AEConfig.instance().areFeaturesEnabled(this.features)) {
if( !AEConfig.instance().areFeaturesEnabled( this.features ) ) return new ItemDefinition(this.registryName, null);
{ }
return new ItemDefinition( this.registryName, null );
}
Item item = this.itemSupplier.get(); Item item = this.itemSupplier.get();
item.setRegistryName( AppEng.MOD_ID, this.registryName ); item.setRegistryName(AppEng.MOD_ID, this.registryName);
ItemDefinition definition = new ItemDefinition( this.registryName, item ); ItemDefinition definition = new ItemDefinition(this.registryName, item);
item.setUnlocalizedName( "appliedenergistics2." + this.registryName ); item.setUnlocalizedName("appliedenergistics2." + this.registryName);
item.setCreativeTab( this.creativeTab ); item.setCreativeTab(this.creativeTab);
// Register all extra handlers // Register all extra handlers
this.boostrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( item ) ) ); this.boostrapComponents.forEach(component -> this.factory.addBootstrapComponent(component.apply(item)));
// Register custom dispenser behavior if requested // Register custom dispenser behavior if requested
if( this.dispenserBehaviorSupplier != null ) if (this.dispenserBehaviorSupplier != null) {
{ this.factory.addBootstrapComponent((IPostInitComponent) side ->
this.factory.addBootstrapComponent( (IPostInitComponent) side -> {
{ IBehaviorDispenseItem behavior = this.dispenserBehaviorSupplier.get();
IBehaviorDispenseItem behavior = this.dispenserBehaviorSupplier.get(); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(item, behavior);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item, behavior ); });
} ); }
}
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, reg ) -> reg.register( item ) ); this.factory.addBootstrapComponent((IItemRegistrationComponent) (side, reg) -> reg.register(item));
if( Platform.isClient() ) if (Platform.isClient()) {
{ this.itemRendering.apply(this.factory, item);
this.itemRendering.apply( this.factory, item ); }
}
return definition; return definition;
} }
} }
+89 -116
View File
@@ -19,15 +19,11 @@
package appeng.bootstrap; package appeng.bootstrap;
import java.util.Collection; import appeng.bootstrap.components.ItemColorComponent;
import java.util.Collections; import appeng.bootstrap.components.ItemMeshDefinitionComponent;
import java.util.HashMap; import appeng.bootstrap.components.ItemModelComponent;
import java.util.HashSet; import appeng.bootstrap.components.ItemVariantsComponent;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
@@ -41,137 +37,114 @@ import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.components.ItemColorComponent; import java.util.*;
import appeng.bootstrap.components.ItemMeshDefinitionComponent;
import appeng.bootstrap.components.ItemModelComponent;
import appeng.bootstrap.components.ItemVariantsComponent;
class ItemRendering implements IItemRendering class ItemRendering implements IItemRendering {
{
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private IItemColor itemColor; private IItemColor itemColor;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private ItemMeshDefinition itemMeshDefinition; private ItemMeshDefinition itemMeshDefinition;
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private Map<Integer, ModelResourceLocation> itemModels = new HashMap<>(); private final Map<Integer, ModelResourceLocation> itemModels = new HashMap<>();
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private Set<ResourceLocation> variants = new HashSet<>(); private final Set<ResourceLocation> variants = new HashSet<>();
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
private Map<String, IModel> builtInModels = new HashMap<>(); private final Map<String, IModel> builtInModels = new HashMap<>();
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public IItemRendering meshDefinition( ItemMeshDefinition meshDefinition ) public IItemRendering meshDefinition(ItemMeshDefinition meshDefinition) {
{ this.itemMeshDefinition = meshDefinition;
this.itemMeshDefinition = meshDefinition; return this;
return this; }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public IItemRendering model( int meta, ModelResourceLocation model ) public IItemRendering model(int meta, ModelResourceLocation model) {
{ this.itemModels.put(meta, model);
this.itemModels.put( meta, model ); return this;
return this; }
}
@Override @Override
public IItemRendering variants( Collection<ResourceLocation> resources ) public IItemRendering variants(Collection<ResourceLocation> resources) {
{ this.variants.addAll(resources);
this.variants.addAll( resources ); return this;
return this; }
}
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly(Side.CLIENT)
public IItemRendering color( IItemColor itemColor ) public IItemRendering color(IItemColor itemColor) {
{ this.itemColor = itemColor;
this.itemColor = itemColor; return this;
return this; }
}
@Override @Override
public IItemRendering builtInModel( String name, IModel model ) public IItemRendering builtInModel(String name, IModel model) {
{ this.builtInModels.put(name, model);
this.builtInModels.put( name, model ); return this;
return this; }
}
void apply( FeatureFactory factory, Item item ) void apply(FeatureFactory factory, Item item) {
{ if (this.itemMeshDefinition != null) {
if( this.itemMeshDefinition != null ) factory.addBootstrapComponent(new ItemMeshDefinitionComponent(item, this.itemMeshDefinition));
{ }
factory.addBootstrapComponent( new ItemMeshDefinitionComponent( item, this.itemMeshDefinition ) );
}
if( !this.itemModels.isEmpty() ) if (!this.itemModels.isEmpty()) {
{ factory.addBootstrapComponent(new ItemModelComponent(item, this.itemModels));
factory.addBootstrapComponent( new ItemModelComponent( item, this.itemModels ) ); }
}
Set<ResourceLocation> resources = new HashSet<>( this.variants ); Set<ResourceLocation> resources = new HashSet<>(this.variants);
// Register a default item model if neither items by meta nor an item mesh definition exist // Register a default item model if neither items by meta nor an item mesh definition exist
if( this.itemMeshDefinition == null && this.itemModels.isEmpty() ) if (this.itemMeshDefinition == null && this.itemModels.isEmpty()) {
{ ModelResourceLocation model;
ModelResourceLocation model;
// For block items, the default will try to use the default state of the associated block // For block items, the default will try to use the default state of the associated block
if( item instanceof ItemBlock ) if (item instanceof ItemBlock) {
{ Block block = ((ItemBlock) item).getBlock();
Block block = ( (ItemBlock) item ).getBlock();
// We can only do this once the blocks are actually registered... // We can only do this once the blocks are actually registered...
StateMapperHelper helper = new StateMapperHelper( item.getRegistryName() ); StateMapperHelper helper = new StateMapperHelper(item.getRegistryName());
model = helper.getModelResourceLocation( block.getDefaultState() ); model = helper.getModelResourceLocation(block.getDefaultState());
} } else {
else model = new ModelResourceLocation(item.getRegistryName(), "inventory");
{ }
model = new ModelResourceLocation( item.getRegistryName(), "inventory" ); factory.addBootstrapComponent(new ItemModelComponent(item, ImmutableMap.of(0, model)));
} }
factory.addBootstrapComponent( new ItemModelComponent( item, ImmutableMap.of( 0, model ) ) );
}
// TODO : 1.12 // TODO : 1.12
this.builtInModels.forEach( factory::addBuiltInModel ); this.builtInModels.forEach(factory::addBuiltInModel);
if( !resources.isEmpty() ) if (!resources.isEmpty()) {
{ factory.addBootstrapComponent(new ItemVariantsComponent(item, resources));
factory.addBootstrapComponent( new ItemVariantsComponent( item, resources ) ); } else if (this.itemMeshDefinition != null) {
} // Adding an empty variant list here will prevent Vanilla from trying to load the default item model in this
else if( this.itemMeshDefinition != null ) // case
{ factory.addBootstrapComponent(new ItemVariantsComponent(item, Collections.emptyList()));
// Adding an empty variant list here will prevent Vanilla from trying to load the default item model in this }
// case
factory.addBootstrapComponent( new ItemVariantsComponent( item, Collections.emptyList() ) );
}
if( this.itemColor != null ) if (this.itemColor != null) {
{ factory.addBootstrapComponent(new ItemColorComponent(item, this.itemColor));
factory.addBootstrapComponent( new ItemColorComponent( item, this.itemColor ) ); }
} }
}
private static class StateMapperHelper extends StateMapperBase private static class StateMapperHelper extends StateMapperBase {
{
private final ResourceLocation registryName; private final ResourceLocation registryName;
public StateMapperHelper( ResourceLocation registryName ) public StateMapperHelper(ResourceLocation registryName) {
{ this.registryName = registryName;
this.registryName = registryName; }
}
@Override @Override
protected ModelResourceLocation getModelResourceLocation( IBlockState state ) protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
{ return new ModelResourceLocation(this.registryName, this.getPropertyString(state.getProperties()));
return new ModelResourceLocation( this.registryName, this.getPropertyString( state.getProperties() ) ); }
} }
}
} }

Some files were not shown because too many files have changed in this diff Show More