Compare commits

...
268 Commits
Author SHA1 Message Date
749ea96c62 Make target Travel Anchor selection snap angle configurable and don't override empty selection server-side (#230)
Co-authored-by: Wilhelm Schuster <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2026-11-11 22:52:22 +01:00
DiscreaterandChitak 985 f4dfa9e6cf Fix the inventory name display issue (#283)
Co-authored-by: Chitak 985 <[email protected]>
2026-11-11 18:54:08 +01:00
UltraProdigy 30958c201a ci: run build and test on release branches 2026-11-09 01:03:11 -05:00
Eldrinn ElanteyandNikolay S. 8ead31ff76 Translate chat messages on the client instead of the server (#275)
Co-authored-by: Nikolay S. <[email protected]>
2026-11-01 19:28:01 +00:00
Eldrinn Elantey 7bebb05573 Respect recipe slot numbers when validating machine inputs (#260) 2026-10-31 22:29:14 +01:00
MissBismuthandMartin Robertz 87e5a32b89 Fix painted blocks missing paint when placed with wand (#280)
Co-authored-by: Martin Robertz <[email protected]>
2026-10-27 20:48:42 +01:00
Ressed c232ea8534 Fix the iteration of getting slot from inventory for existing item filter. (#269) 2026-10-25 19:25:58 +01:00
Fib4ikandM R S E d27f30951a Add redstone signal support for item conduit. (#265)
Co-authored-by: M R S E <[email protected]>
2026-10-06 19:19:44 +02:00
Mykhailo Balaker 8dcda4e822 Prevent fall-through when clicking on the "Show Range" button in Vacuum Chest GUI (#274) 2026-09-27 18:08:03 +00:00
fehling135 e337597a3c Make specialmobs really availale for soul binder (#270) 2026-09-25 17:46:29 +02:00
Nikolay S. a8197e0026 Remove broken NBT-matching logic (#268) 2026-09-20 13:33:30 +02:00
danyadev 9549d9385c optimize recipe checking on mc loading (#263) 2026-09-07 16:18:00 +02:00
Martin Robertz d44c6bb7c7 update deps 2026-09-05 10:11:02 +02:00
Eldrinn ElanteyandCaedis a4a40ee726 Fix night vision deactivating after dimension change via portal (#262)
Co-authored-by: Caedis <[email protected]>
2026-09-04 18:41:45 -05:00
Caedis caec163702 Revert #231 (#261) 2026-09-04 14:09:25 +00:00
Glease 673f832c2d fix PacketTeleport sanitizer false positive (#253) 2026-09-03 07:00:46 +02:00
Eldrinn Elantey ce11a2dcf2 Fix night vision deactivating after dimension change via portal (#231) 2026-09-02 15:09:32 +00:00
vcwdfca 68e209203c Fix Player inventory cannot be shown when the EnderIO fluid conduit tier is lower than Ender (#255) 2026-09-02 15:03:02 +00:00
0715f8b536 remove direct getStackInSlot exploit (#245)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: attempt0 <[email protected]>
2026-09-02 09:38:29 +00:00
boubou19 d356dddedb Temporary revert #256 and #257 (#258) 2026-08-31 15:40:19 +02:00
June 604b47a394 Update en_US.lang (#257) 2026-08-29 23:34:49 -04:00
June 42dc1f43aa Update TileReservoir.java (#256)
it did not make sense previously. was worse than one vanilla water source
2026-08-29 20:47:05 -02:30
Elyspio cbeec42e47 Fix client NPE when placing wireless powered lights on dedicated servers (#252) 2026-08-21 18:16:23 +02:00
boubou19andgithub-actions[bot] 046ad7441d Cache more enum .values() (#249)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-11 02:53:48 +02:00
boubou19andMartin Robertz 8750005be5 Cache enum .values() (#248)
Co-authored-by: Martin Robertz <[email protected]>
2026-08-10 21:03:55 +02:00
Caedis b46cfbb351 fix: billboard toward renderViewEntity (#247) 2026-08-10 11:46:58 -04:00
Dream Master 070ef99694 update+gradle+deps+bs 2026-08-04 11:41:57 +07:00
fec675ef48 Fix many render issues (#232)
Co-authored-by: Alexdoru <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2026-08-03 19:31:40 +02:00
Wilhelm Schuster 503b90a5d0 Fix crash when removing inventory from Inventory Panel network (#243) 2026-07-23 23:33:16 -04:00
Ranzu 84052a1c42 Extend ColorUtil class colors (#242) 2026-07-20 01:24:58 -04:00
Jordan Rey 554a08a515 fix: infinite speed and altitude using glider with elytra (#240) 2026-07-14 21:31:04 -07:00
Martin Robertz 55928c5234 update deps 2026-07-04 19:29:09 +02:00
RanzuandMartin Robertz 65c5d3aec5 Fix "Range" string position and implement ColorUtils (#238)
Co-authored-by: Martin Robertz <[email protected]>
2026-07-04 19:25:23 +02:00
__felix__ 7737598e4f Update required version of gtnhlib in @Mod (#239) 2026-07-04 18:39:58 +02:00
Dream Master eb9845d3a0 update+bs+gradle+deps 2026-06-12 16:36:04 +02:00
7a61bb9dee Add automation to EIO Enchanter (basically a copy-paste from my other two PR's) (#227)
Co-authored-by: koolkrafter5 <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2026-06-12 15:45:50 +02:00
DanandMartin Robertz ed24e1e1f0 divided rocket entity from overworld to dimensions specific (#222)
Co-authored-by: Martin Robertz <[email protected]>
2026-06-07 16:09:19 +02:00
FourIsTheNumber 76e50f8a32 Remove space suit from end steel armor (#237) 2026-06-03 11:46:26 +02:00
Ranzu 5b8810633b Localization of gui title elemets (#236) 2026-06-02 11:16:35 -04:00
Alexdoru 48e30828cf Fix 4 world client leaks (#235) 2026-05-04 14:07:16 +02:00
Alexdoru 924b4dbbf2 Intellij quick fixes (#234) 2026-05-04 13:25:46 +02:00
Alexdoru b5a2693d7c Fix world client leak in TechneMachineRenderer (#233) 2026-05-03 20:38:04 +02:00
ImaMapleTreeandMartin Robertz 372c317077 Fix sort order bounds check on Inventory Panel UI (#228)
Co-authored-by: Martin Robertz <[email protected]>
2026-04-25 19:06:45 +00:00
44ee860a39 Fix Dark Steel Shears duplicating drops from shearable blocks (#224)
Co-authored-by: clawdbot-silly-waddle <[email protected]>
Co-authored-by: Copilot <[email protected]>
2026-04-24 16:44:57 +00:00
Luca Bancale 181d48ac60 Render travel anchor when holding staff in offhand (#226) 2026-04-08 13:28:59 +02:00
UltraProdigy 267adc0a31 Optimize Images & Workflow (#225) 2026-03-16 10:47:08 +01:00
Alexdoru 503a6e7a76 Cache frequent Enum#values() calls (#223) 2026-03-03 19:46:41 +00:00
danyadev ff0e85142d less FluidStack copying in conduits & less HashMap lookups in reservoirs (#221) 2026-02-18 15:33:45 -05:00
Martin Robertz 94bd521739 Update Angelica dependency version in dependencies.gradle 2026-02-07 19:10:46 +01:00
e66c50bc24 Improve tooltip capacitor and farming station efficiency (#215)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Ruling-0 <[email protected]>
2026-02-07 19:07:42 +01:00
Martin Robertz d9df657f35 Update dependencies.gradle (#220) 2026-02-07 19:07:23 +01:00
Martin Robertz 08553f8af2 fix 2026-02-07 19:02:37 +01:00
Martin Robertz 0fe564d007 fix 2026-02-07 18:55:57 +01:00
Martin Robertz 53ba0383fb Merge remote-tracking branch 'origin/master' 2026-02-07 18:46:30 +01:00
Martin Robertz 2c5664ce08 update 2026-02-07 18:46:22 +01:00
Jason Mitchell da70f52b0d Reduce allocation spam on fluid flow in fluid conduits (#219) 2026-02-07 08:32:58 -08:00
SwingURM 46644bc889 Optimize FluidStack copying in EnderLiquidConduitNetwork.doFill (#218) 2026-02-07 15:52:50 +01:00
danyadev f615df5010 compat with WailaPlugins own fluid handler (#217) 2026-01-13 11:27:35 +01:00
PLASMAchicken 73891d20ff Fix Client Crash when breaking Wirelesscharger on Server (#216) 2025-12-26 21:14:36 -05:00
Alexdoru e21793245f [Memory-opti:fix leak] Fix World leak in WirelessChargerController (#212) 2025-12-16 13:41:45 -06:00
Worive ffe4296ef6 Improve NetworkedInventory robustness (#210) 2025-12-10 09:27:33 +01:00
Alexdoru 5083fb2a60 Delete brute forcing of items to generate Thaumcraft aspects (#213) 2025-11-30 07:45:12 +01:00
Alexdoru 05ee12955d Fix World leak in ConduitNetworkTickHandler (#211) 2025-11-22 00:56:09 +01:00
Martin Robertz a7acc7e224 update 2025-10-19 20:30:47 +02:00
Martin Robertz a59bb21e59 update 2025-10-12 20:30:55 +02:00
chochem 5b6c13ff0a Dont register several duplicate items in case of GTNH (#209) 2025-10-12 01:14:36 +01:00
Martin Robertz 6f8b6e2a9c update 2025-10-04 14:26:40 +02:00
TheYoingLadandMartin Robertz 479c8328b4 Added the ability for the farming station to plant Pam's nether seeds (#208)
Co-authored-by: Martin Robertz <[email protected]>
2025-10-04 12:24:54 +00:00
Wilhelm Schuster 0c23f4937d Handle mouse button keybinds (#204) 2025-09-25 19:55:57 +02:00
Wilhelm Schusterandgithub-actions[bot] cde2e4fa60 Fix crash when breaking Painted Glowstone placed by Better Builders Wand (#206)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-09-25 19:35:30 +02:00
Ranzu abbb6dc151 Update bauble slot background in capacitor ui (#203) 2025-09-25 15:20:59 +02:00
Martin Robertz b3def82cde update 2025-09-24 16:49:42 +02:00
EmperorSuper 8b4e7f7ec3 Cap the length of the baubles inventory (#202) 2025-09-24 11:10:22 +02:00
Alexdoru d69d77ecae fix NPE in BlockConduitBundle#onPlaySound (#201) 2025-07-25 08:21:32 +07:00
Dream Master a233f6ba30 update 2025-07-18 09:47:57 +07:00
boubou19andAlexdoru 581150178f Speed up forge event registration (#200)
Co-authored-by: Alexdoru <[email protected]>
2025-07-17 22:37:03 +00:00
Dream Master 313a243bf5 update 2025-07-17 22:29:13 +07:00
Dream Master d5f1008b08 update 2025-07-17 22:28:51 +07:00
koolkrafter5 e1e1f06dc6 Break Dependency Chain (#199) 2025-07-17 02:40:36 +00:00
Martin Robertz aad9c092b1 update 2025-06-12 23:33:37 +02:00
slprime f8c56939cd Update NEI Handlers (#198) 2025-06-12 23:32:01 +02:00
Martin Robertz e2e22d6103 update 2025-05-26 19:22:34 +02:00
dibbydoda a798d2146d Remove deprecated CapacitorBank (#197) 2025-05-26 07:38:39 -04:00
Martin Robertz e829c4168b update 2025-05-23 23:46:07 +02:00
dibbydoda b1f8d99da9 Comparator refactor and Vacuum Chest logic (#196)
Add comparator logic to the Vacuum Chest and refactor comparator logic for Capacitor Banks and Tanks
2025-05-20 04:24:45 -04:00
Maya 304fdef5ec update 2025-05-18 10:35:07 -05:00
glowredman 1f05312ded Small Cleanup (#195) 2025-05-18 10:34:59 -05:00
Maya eb88b1cfe0 update 2025-05-06 17:46:36 -05:00
glowredmanandMaya d4256bda6e Make Fused Quartz blast resistance configurable (#194)
Co-authored-by: Maya <[email protected]>
2025-05-06 17:45:43 -05:00
bda8902709 Feature: Automatable weather obelisk (#193)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: koolkrafter5 <[email protected]>
2025-05-04 19:38:08 -04:00
Maya 63971381cc update 2025-04-24 17:20:42 -05:00
__felix__and__felix__ 09238b09ef Change hazmat Optional decorators' modid from gregtech to gregtech_nh to add gt6 compat (#191)
Co-authored-by: __felix__ <134875831+48a3efa65c881ef567345b17f3910e06@users.noreply.github.com>
2025-04-24 17:19:59 -05:00
Maya 32556e078e update 2025-04-08 16:28:20 -05:00
Niclas Klugmann ace514f628 Move End Steel/ Stellar Armor to GT Hazard API (#189) 2025-04-08 16:27:01 -05:00
Niclas Klugmann 0102b89c33 fix trackman's goggles config (#188) 2025-03-22 14:45:52 +00:00
Maya b65afde754 fix dependencies 2025-03-22 09:01:45 -05:00
Maya 4a0a427186 update 2025-03-22 08:55:17 -05:00
Niclas KlugmannandMaya e04e2e3411 Add trackman's goggles upgrade support to the Dark Helm (#186)
Co-authored-by: Maya <[email protected]>
2025-03-22 08:54:08 -05:00
Niclas Klugmann 316db4bd77 Fix naturalist's eyes (#187) 2025-03-22 08:32:29 -05:00
Maya f43936c29a update 2025-02-14 11:57:41 -06:00
Maya c6471ed6b0 Mark EnderCore as a required dependency (#185) 2025-02-14 17:57:27 +00:00
Maya 654b95da1a update 2025-02-03 15:05:58 -06:00
Dioxop d70263f3af Adding "show range" button to multiple machines (#184) 2025-02-03 15:04:20 -06:00
Martin Robertz c10f74486b update 2024-12-31 14:36:18 +01:00
glowredman c7db2c4840 Add Localizations (#183) 2024-12-30 17:44:29 -06:00
Martin Robertz 948a021f3e update 2024-12-29 18:01:20 +01:00
Simon Zünd 346bbf4e53 Remove left-over code and textures for ultra dense ME conduits (#182) 2024-12-29 16:25:03 +00:00
Martin Robertz 5769ebe3cb update 2024-12-22 01:21:47 +01:00
Pascal 4558f194be ensure TileLightNode instance at breakBlock (#181) 2024-12-21 10:31:30 -06:00
Martin Robertz e12142890e update 2024-11-16 15:28:59 +01:00
Kogepan229andboubou19 e6ebb5dfec Fix Zombie Generator NPE (#180)
Co-authored-by: boubou19 <[email protected]>
2024-11-14 19:22:20 +00:00
54M44R 1d4f6831dd Prevent Silver Capacitor from being used as Upgrade (#178) 2024-11-14 13:32:38 +00:00
Dream Master 726ce46475 update 2024-11-12 12:15:49 +01:00
Noc d01de95e8e removed conduit subtype (#179) 2024-11-12 08:35:28 +01:00
Martin Robertz b15d357f1a update 2024-10-21 21:56:28 +02:00
Darren Eberly 0fbf6f05ba No more TESR on conduits (#176)
* Goodbye TESR, Hello ISBRH

* More fluid conduit rendering work

* more stuff

* spotless

* Add empty check to fluid conduit renderer
2024-10-21 20:08:58 +02:00
Martin Robertz bf9c2cd2c7 update 2024-10-02 15:16:09 +02:00
chochem 51b4c4e74c dont double apply oredicts (#175) 2024-10-01 20:16:52 +01:00
Dream Master cf6b678dd9 update 2024-07-15 23:45:30 +07:00
Under 6c205150b1 Travel Staff Blink Keybind fixes. (#163)
Fixes 2 separate bugs with the SoT keybind.
1. Staff of Teleportation in GTNH pack specifically didn't work due to reporting as having 0 power through the RF API. Fixed this by having it always report that it's full of power since it has infinite.
2. BlackSteelSword and EndSteelSword (The Ender and MKII) both were quite funky with keybind, causing no teleports to happen when they really should have.
Fixed this through tweaks to how this is handled in a number of places to allow for proper handling while not changing the default held/shift held behavior.

Tested in SP, Anchor behavior while holding staffs and Swords with travel thing on them work as expected. Keybind now works and is able to use swords with travel thing on them.
One quirk is that if you are holding a sword with travel upgrade, but NOT shifting, the sword itself stops counting as a valid travel item. So if ONLY using sword no separate SoT the keybind will not work unless you hold shift. If you have another SoT in your inventory it will identify and use that and still blink you upon hitting keybind.
This quirk doesn't really matter in most cases, just something worth noting I guess.
2024-07-15 23:43:39 +07:00
Zoltán Szepesi e39a1e1eb6 Fix LiquidConduit not attempting to pull fluids from all directions if one of external tanks are empty (#174) 2024-07-15 19:09:16 +07:00
glowredman 4a94c1ba90 Remove isModLoaded check for GTNH Lib (#172) 2024-07-11 08:44:35 -05:00
Jason Mitchell 0fc382dd13 Update dependencies.gradle (#170)
Fix server test
2024-07-11 03:31:46 -05:00
Jason Mitchell 04964e15e4 hard dep on gtnhlib 2024-07-10 14:09:43 -07:00
Jason Mitchell 085ccc9d21 Try a CasList, since the Collections.synchronizedList actually needed the reads to be synchronized... 2024-07-10 13:40:46 -07:00
Dream Master 1903589e29 update 2024-07-08 13:26:52 +07:00
Ethryan 46971bbe0e Rename Dark Iron Bars to Dark Steel (#167) 2024-07-05 13:20:31 +07:00
Martin Robertz 4ccecf7bc0 update 2024-07-02 23:50:19 +02:00
Jason Mitchell 92fb58f0c6 Work around CME
* Not entirely sure why it's being concurrently modified.. so let's just make it safe for now
2024-06-30 14:15:24 -07:00
Martin Robertz 54c6db0afc update 2024-06-05 22:49:08 +02:00
OvermindDL1 84d9dcaf00 Fix another thread data race issue introduced in #164. 2024-06-04 21:53:01 -07:00
Jason Mitchell af923d1977 Probably less thread unsafe. (#164) 2024-06-04 18:53:14 -07:00
Martin Robertz efb918fc6d update 2024-06-02 23:05:27 +02:00
6447ffb4d5 Tweaks to EnderIO travel + teleportation (#158)
* Tweak teleport staff controls

* Fix comment

* Fix logic

* spotlessApply (#159)

Co-authored-by: GitHub GTNH Actions <>

* Add configs for teleport staff actions

* Various TP fixes

* Allow TP to unloaded anchor
* Improve TP through wall by checking every 0.5 instead of 2 distance
* Fix blink placing player one block too high
* Fix anchor being incorrectly selected sometimes by constraining to visual angle

* Add server-side handling for two-in-one teleport action

* Clear stored anchors on world load

* Check for obstructed anchor on long-distance teleport

* Check anchor accessibility and require `player != null`

* Handle server-side `travelToLocation`

* Limit backwards teleport check

* 2-in-1 TP: find destination client-side

* spotlessApply (#161)

Co-authored-by: GitHub GTNH Actions <>

* Don't conserve momentum

* Address review comments

* Refactor packet instantiation

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-06-02 17:20:23 +02:00
Martin Robertz fb4c9bde59 update 2024-05-09 10:02:46 +02:00
Oleg Ivanov bd47a39c83 Add config entries for Farming Station particles (#162)
* Decrease number of Farming Station particles

* Set default values for range & number of particles to original
2024-05-08 20:48:35 +02:00
Martin Robertz 43d74c9a7a update 2024-04-24 21:47:04 +02:00
PT400C Jomcraft 6d3a631bb0 Improve FarmingStation portal texture rendering (#157) 2024-04-24 21:26:51 +02:00
Martin Robertz ccdef03296 update 2024-04-18 20:42:39 +02:00
Drathonix 56e163c234 Conduit Replacement Retains Connection Data (#160)
* Replacing Conduits Now maintains all Connection Settings

* Only write/read connection nbt.

* Use Correct Connectionset
2024-04-18 10:24:59 +02:00
Martin Robertz 8ecec5b096 update 2024-02-28 20:07:25 +01:00
boubou19GitHub GTNH Actionsgithub-actions[bot]
4e3fbc7667 Reduce allocation spam in capacitor banks (#155)
* reduce memory allocation

* update dep

* use public

* wrong dep

* spotlessApply (#156)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-02-25 23:26:17 +01:00
Jason Mitchell 845f277497 Actually optional (#154)
* Actually optional

* Tags
2024-02-22 21:21:37 +01:00
Jason Mitchell 94fb952cb0 Angelica compat (#153)
* Angelica Compat - Thread Saftey
* Depends on EnderCore updates for instanced CubeRenderer
* Switches relevant renderers to ThreadLocals, and adds a getRenderer() to Conduits
* Makes ConduitBundleRenderer threadsafe
* Misc reduction in allocations
2024-02-22 07:54:55 -08:00
Martin Robertz 29554c6a40 update 2024-02-22 13:27:10 +01:00
connor135246 fc5cba342c Fix Dark Steel Anvils in WAILA (#152)
Dark Steel Anvils wouldn't show the correct block in WAILA if the "Sneaky Facades" option was on.
2024-02-22 11:33:13 +01:00
Jason Mitchell 05d31b2e70 Some null checks to avoid outright crashing with Angelica, future thread saftey to come (#150) 2024-02-22 11:32:53 +01:00
Martin Robertz 5265340e3c update 2024-02-17 11:13:20 +01:00
Raven Szewczyk 37e239ae81 [ci skip] upgraded build system 2024-02-04 19:58:13 +00:00
Martin Robertz a725ebf120 update bs+deps 2024-01-31 22:47:55 +01:00
Pascal 6affe75674 fix protection mode of travel anchor (#149) 2024-01-31 07:53:01 +01:00
Martin Robertz 19f19d348b update bs+deps 2024-01-24 18:19:30 +01:00
Under 3154d03b4f Fix Anchor always rendering bug (#148)
* Fix Anchor always rendering bug

Also stop inventory scanning from happening every client tick, whoops.
Tested by placing a debug point on line 768 of TravelController (in getRequiredPower) and a debug point at line 656 of TravelController (in findTravelItemInInventoryOrBaubles). Debug points were used to verify that the code was ONLY hit when actual teleport happens, and not happening every tick like what was accidentally happening before.

* Run spotlessApply

Forgot that was a thing I do for GTNH stuff.
2024-01-24 10:58:27 -06:00
Martin Robertz 9e84167012 update bs+deps 2024-01-10 00:42:52 +01:00
bombcar d1a1bf1ed5 add required hard dependency on cofhlib (#146)
* add required hard dependency on cofhlib

* update bs, dependencies, and settings.gradle
2024-01-10 00:41:51 +01:00
Raven Szewczyk c1309fa37d [ci skip] upgraded build system 2024-01-08 21:25:19 +00:00
Martin Robertz 6a0785e1da exchange existing Item filter from newer Ender io version (#145) 2023-12-30 12:09:44 +01:00
Martin Robertz 6a4d655c71 update deps 2023-12-24 20:21:36 +01:00
Under 3639ade571 Staff Of Traveling Keybind Feature (#144)
* Staff Of Traveling Keybind Update

Two main things
1. Added a keybind for Staff of Traveling blink ability
2. Due to the new keybind, also added Baubles support for Staff of Traveling.

By extension, both features 1 and 2 also apply to the Staff of Teleportation.

* Update en_US.lang

* Add config to disable Travel Staff Keybind

Change as per request by @Caedis .
New config option is synced in the PacketConfigSync class.
A helpful info message is displayed when players attempt to use the keybind but it is disabled so it's immediately apparent why it's not working.

* Typo/formatting

Fix type, remove unnecessary null check.

* Annotations and UNIVERSAL bauble type

Added annotations missing from ItemMagnet and ItemTravelStaff for Baubles.
Added option 'UNIVERSAL' to description of magnet and travel staff Bauble type configs.
Changed default of staff to be 'UNIVERSAL', because bauble slots are limited enough as-is.
2023-12-24 20:18:57 +01:00
Martin Robertz 95daa9b035 update deps 2023-12-20 20:21:36 +01:00
Under f249fd2973 Add Config to allow servers to re-enable support for client-side 'hacks' like Staff Of Traveling Keybind mod. (#142)
* Update Config.java

Adding config to allow not validating travel staff packets.

* Update TravelController.java

Disable validation if server config deems it so.

* spotlessApply fix

* Wrong ordering and spotlessApply
2023-12-20 20:06:38 +01:00
9f3f8243f9 Limited Item Filter (#143)
* Limited Item Filter

* simplify inverted limit

Co-authored-by: Alexander Anishin <[email protected]>

* Update src/main/java/crazypants/enderio/conduit/item/filter/ItemFilterLimited.java

Co-authored-by: Alexander Anishin <[email protected]>

* Update src/main/java/crazypants/enderio/conduit/item/filter/ItemFilterLimited.java

Co-authored-by: Alexander Anishin <[email protected]>

* Update ItemFilterLimited.java

---------

Co-authored-by: Alexander Anishin <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2023-12-20 19:50:55 +01:00
Martin Robertz 23a5484ee8 update deps 2023-12-13 15:38:04 +01:00
Bears Dot Zone 4b5837cac2 Fix an edge case pertaining to freshly crafted tanks (#141)
* Update dependencies

* Replace faulty dummy object logic with object creation

* Remove logic that is exiting a function erroneously
2023-12-13 15:32:56 +01:00
Spacebuilder2020andMartin Robertz 1251427388 Fix NBT Match where tag is empty but exists (#138)
* Fix NBT Match where tag is empty but exists

* Apply Splotless

* update deps

* update gradle + bs

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-12-13 09:40:48 +01:00
ghostflyby 3e7d69f460 Open conduit connection GUI with more wrenches (#139) 2023-11-25 16:02:12 +08:00
Martin Robertz 88725a144d update deps 2023-11-16 13:59:12 +01:00
Pelotrio 123f22f20e Add unload event handling to ClientNetworkManager (#137)
Added a new method `onWorldUnload` to `ClientNetworkManager` to destroy and clear any network instances when the world event `Unload` is triggered. The addition of this event handler was necessary to prevent the possibility of any network instances persisting on the client side beyond the World lifetime, thus potentially causing memory leaks.
2023-11-16 15:42:32 +03:00
Martin Robertz 0b0f7a4f1a update deps 2023-11-11 12:13:03 +01:00
Martin Robertz b00c5996f7 update bs+deps 2023-11-11 12:12:45 +01:00
Pelotrio 83f52d15c7 Removed the redundant static IWailaDataAccessor _accessor to not leak the world object 2023-11-10 18:34:39 -08:00
Pelotrio 287c4498d2 Use null for the Item to render to not leak the world 2023-11-10 18:34:39 -08:00
Martin Robertz 2470e81f0e update bs+de+wci 2023-10-15 17:43:47 +02:00
Alexdoru 1af6fcae0b set fluid conduit default to output only 2023-10-15 13:34:45 +02:00
Alexdoru f44111da96 revert changes to conduit default connection modes 2023-10-15 13:34:45 +02:00
Dream-MasterXXL 4ae9ff2d77 update bs+deps 2023-10-05 00:42:17 +02:00
Martin Robertz 71f79536a7 update deps 2023-09-28 20:54:35 +02:00
Alexdoru 0920bf28d6 Change default connection mode of fluid conduits (#134)
* update bs

* change default connection mode of fluid conduits

* fix imports
2023-09-28 20:45:53 +02:00
Martin Robertz 8e4107d11e update bs+deps 2023-09-22 19:09:29 +02:00
Glease 349bcc0926 allow small overshoot of power use for traveling (#133) 2023-09-22 20:04:04 +03:00
Glease 070660efe4 fix travel upgrade items using wrong way to determine power stored (#131)
Signed-off-by: Glease <[email protected]>
2023-07-24 01:45:41 +08:00
Martin RobertzandRaven Szewczyk 0dd56b62ab update bs+sa+deps (#130)
* update bs+sa+deps

* Switch immibis microblocks to modrinth maven

* Remove modrinth from repositories as it's now in the buildscript

---------

Co-authored-by: Raven Szewczyk <[email protected]>
2023-07-23 11:36:28 +02:00
Glease 54d61f5251 valiate tp packets (#128)
* validate tp packets

Signed-off-by: Glease <[email protected]>

* spotless

Signed-off-by: Glease <[email protected]>

---------

Signed-off-by: Glease <[email protected]>
2023-07-23 08:04:14 +02:00
初夏同学 ebcbef851a Fix a bug in NBT usage (#127) 2023-07-05 17:57:26 +02:00
miozune 1717d38632 Validate TE of packet (#126)
* Validate TE of packet

* Remove outdated script
2023-07-03 11:33:32 +09:00
Caedis 5fdd24293a Implement item bar visibility config (#125)
* Implement item bar visibility config

* Forgot about spotless

* Recommit changed files + added magnet, cap bank, and staff bar hiding
2023-06-04 22:09:59 +02:00
miozune 2629076937 Fix fluid conduit connecting to non-fluid GT tiles (#123)
* updateBuildScript & update dependencies

* Fix fluid conduit connecting to non-fluid GT tiles

* spotlessApply

* one less variable
2023-05-22 12:01:16 +02:00
Pilzinsel64 63cbe6e562 fix + more cleanup for PowerConduitEndergy (#122) 2023-05-09 19:29:05 +02:00
Pilzinsel64 3194ecf6e8 Cleanup PowerConduitEndergy (#121)
* cleanup PowerConduitEndergy

* spotlessApply

* re-add POSTFIX again
2023-05-08 18:08:41 +02:00
miozune 638f04a58e Fix crash with outOfRange on server (#120) 2023-05-02 09:09:51 +02:00
Pilzinsel64 e5e6e2fdba use config for transceiver's energy buffer (#119) 2023-05-01 22:55:20 +02:00
Martin Robertz 5b46f376eb Update dependencies.gradle 2023-04-23 11:12:50 +02:00
miozune 1a14946abb Show travel message above hotbar (#117) 2023-04-10 11:21:39 +02:00
Pilzinsel64 8ca820f71c prevent ghostloading (#115)
* prevent ghostloading by MEConduit

* prevent more ghostloading by MEConduit

* spottlessApply

* prevent ghostloading by ConduitUtil
2023-04-01 15:10:20 +02:00
D-Cysteine 4e40230bf3 Try to fix energy overflow (#114) 2023-03-29 17:25:43 +02:00
Pilzinsel64 76708883c0 needUpdateConnections only while updating cons (#113) 2023-03-23 21:12:11 +01:00
Pilzinsel64 0a1ee81780 Add comments for needUpdateConnections (#112)
* imrpove canConnectToExternal()

* needUpdateConnections

* add comments for needUpdateconnections
2023-03-23 06:46:13 +01:00
Pilzinsel64 1fd7ae7567 Improve canConnectToExternal() (#111)
* imrpove canConnectToExternal()

* needUpdateConnections
2023-03-22 23:43:32 +01:00
Pilzinsel64 251fcc26b0 Ultra Dense ME Conduits (#105)
* basic MEConduit DenseUltra implementation

* add assets for ME Conduit Dense Ultra

* fix icon array count

* fix previous commit

* finalize ultra dense me conduits

* add configu for Ultra Dense ME Conduits

* edit texture a little bit more

* adjust meConduitCoreDenseUltra.png

* fix enableMEUltraDenseConduits

* spottlessApply

* fix texture

* improve canConnectToExternal()
2023-03-19 10:35:42 +01:00
Pilzinsel64 b22915cc9c More German Translation (#110)
* more german translation

* fix crystalline pink slime missmatch
2023-03-12 11:19:10 +01:00
Pilzinsel64 0bf8d3f568 Revert "fix ME Conduits onChunkUnload (#107)" (#109)
This reverts commit 73cb43a761.
2023-03-05 18:05:17 +01:00
Pilzinsel64andglowredman 35e6667da5 Some more German translation (#108)
* some more German translation

* Update src/main/resources/assets/enderio/lang/de_DE.lang

Co-authored-by: glowredman <[email protected]>

* Update src/main/resources/assets/enderio/lang/de_DE.lang

Co-authored-by: glowredman <[email protected]>

* Update src/main/resources/assets/enderio/lang/de_DE.lang

Co-authored-by: glowredman <[email protected]>

* Update src/main/resources/assets/enderio/lang/de_DE.lang

Co-authored-by: glowredman <[email protected]>

* Update src/main/resources/assets/enderio/lang/de_DE.lang

Co-authored-by: glowredman <[email protected]>

* Update src/main/resources/assets/enderio/lang/de_DE.lang

Co-authored-by: glowredman <[email protected]>

---------

Co-authored-by: glowredman <[email protected]>
2023-03-05 13:31:55 +01:00
Pilzinsel64 73cb43a761 fix ME Conduits onChunkUnload (#107) 2023-03-05 11:10:11 +01:00
miozune d32a8e88a3 Fix mouse wheel with lwjgl3 (#106)
* Fix mouse wheel with lwjgl3

* updateBuildScript, revert dependency change
2023-03-04 16:15:11 +01:00
Glease 447450d541 fix item conduit settings not sent to server (#103) 2023-03-02 12:08:53 +01:00
7f6a0a6a4c Fix existing item filter (#101)
* Update buildscript and dependencies

* Remove the extra conduit packet update that overrides some of the previous change packets

* spotlessApply (#102)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-03-01 06:32:43 +00:00
D-Cysteine 28df6fa938 Sync teleport staff config (#100) 2023-02-27 20:48:44 +01:00
Pilzinsel64 1728809a8a fix single solar cell max capacity (#99) 2023-02-17 22:00:12 +01:00
miozune 0edabd4a9d Fix energy stored in Slice'N'Splice with Melodic Capacitor (#98) 2023-02-16 16:53:10 +01:00
Pilzinsel64 b5752a8338 Fix NullReferenceException at getCapacity->getBlockMetadata (#97)
* fix NullReferenceException on getBlockMetadata

* oh no-no, please be static, it's your present! :)
2023-02-10 22:23:59 +01:00
Pilzinsel64 29b0d711f7 Solar Panels: Use config for capacity RF (#94)
* make Solar Energy configurable

* spotlessApply

* calc capacity also for single solar panels

* getCapacity(,) sanity check 'panel' against null
2023-02-08 21:01:19 +01:00
Pilzinsel64 e41827fb69 fix Waila tooltip for Endergy Energy Conduits (#95) 2023-02-08 21:01:10 +01:00
D-Cysteine 628af062ba Fix for getTravelItemTravelSource (#96)
This bug does not currently have any gameplay effect, because the return value of this method is not used to determine teleport range. But we should fix it anyway.
2023-02-08 11:42:03 +01:00
Pilzinsel64 09661218a3 Parse config val maxPhotovoltaicVibrantOutputRF (#93) 2023-02-03 20:16:34 +01:00
Raven Szewczyk e9f9412cab [ci skip] upgraded build system 2023-01-31 09:52:29 +00:00
D-Cysteine 378b32726b Add dimension check for long-distance travel anchor teleport (#92)
* Add dimension check for long-distance travel anchor teleport

* Update comment

* Key on dimension ID instead of World object
2023-01-29 10:56:18 +01:00
Jason Mitchell 4fdfc808ad [ci skip] Add git-blame-ignore-revs for spotlessApply 2023-01-28 18:30:35 -08:00
Jason Mitchell 275d137ba8 [ci skip] spotlessApply with the new settings 2023-01-28 18:30:34 -08:00
Jason Mitchell 8d02293e71 [ci skip] Update buildscript to RetroFuturaGradle 2023-01-28 18:30:20 -08:00
D-Cysteine 8612980782 Add distance limit for out-of-range message (#91)
Also fix the check so that we only display the message for travel anchors within the angle limit.
2023-01-28 18:50:06 +01:00
D-Cysteine 0902a8956b Add staff of teleportation (#89)
* Add teleport staff

* Add support for long-range travel anchor teleportation

* Update buildscript + apply spotless

* Replace creative staff of travelling

* Add missing mapping handler and fix extract energy
2023-01-27 20:22:06 +01:00
Alexdoru d9b99f6888 unbind keys by default (#90)
* unbind all keys by default

* show "EnderIO - Tools" instead of "Tools" in the controls menu

* check if keybind is pressed first
2023-01-27 20:21:27 +01:00
miozune e03011cd40 Fix behavior on Enchanter NEI while holding shift (#88) 2022-12-20 07:51:17 +01:00
miozune 864e5c03b3 Add Fertilized Dirt from RandomThings to recognized farmland list for CustomSeedFarmer (#87)
* Update buildscript & NEI version

* Add Fertilized Dirt from RandomThings to recognized farmland list for CustomSeedFarmer
2022-10-13 09:57:40 +02:00
Raven Szewczyk 727aed1335 Guard against ClassCastExceptions in BlockConduitBundle (#86)
Remove null checks that are already covered by instanceof

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11474>
2022-09-30 08:54:16 +02:00
Raven Szewczyk b607aeb760 Remove per-recipe logging: -170kiB of logs in GTNH (#85) 2022-09-26 20:07:19 +02:00
Kiwi 380518b796 Update zh_CN.lang (#84) 2022-09-24 12:38:31 +02:00
boubou19 fd85b9aee9 Infinite staff (#83)
* fix readme

* added a creative staff of travelling

* spotless

* add back tooltip

* adress reviews
2022-09-20 16:53:04 +02:00
Glease 52b0cabc0b collapse continuous glPushAttrib into one call (#82) 2022-08-18 10:38:02 +02:00
Vladislav Laetansky 2dce4873b7 Fix any travel teleport cause player disconnect on dedicated server (#81) 2022-08-05 17:02:45 +07:00
miozune eb4401f755 Fix crash when Waila is loaded and Chisel is not loaded (#80) 2022-07-29 18:43:27 +07:00
Vladislav Laetansky 37bc1d700c Fix anchor distance config option not working (#79) 2022-07-22 18:58:43 +01:00
Raven Szewczyk cf41b89ae4 Update buildscript & spotlessApply (#78)
* Update buildscript & spotlessApply

* Add mapping version
2022-07-21 18:26:15 +07:00
Vladislav f272840987 Fix weather obelisk not working anywhere but overworld (#77)
* Fix weather obelisk not working anywhere but overworld

* Additional NPE and out of bound checks
2022-07-21 17:55:09 +07:00
Jason Mitchell 1eeef116c9 [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:47:57 -07:00
Raven Szewczyk 3358691fef Conduit gui fixes (#76)
* Fix swapped insert/extract filter locations in the guis

* Fix filters sometimes causing dropping items and left clicking to clear ender fluid filters
2022-07-02 10:47:41 +02:00
Yang Xizhi 3ed88d87a6 make ender io conduit can drain from multi fluid tank (#75) 2022-06-29 23:03:00 +02:00
Raven Szewczyk fab7b9b354 Conduit gui 1.12.2 backport (#74)
* Update EnderCore

* Backport BaseSettingsPanel

* Add the 1.12.2 gui textures

* First pass ItemSettings GUI

* Item conduit&filter gui

* Fix broken texture height on other panels

* Improved fluid conduit gui

* Make sure inventory slots are hidden by default on conduit guis

* Clear ghost slots on tab changes

* Update EnderCore version
2022-06-26 09:56:10 +02:00
miozune f8e96eaa59 Fix log spam with DImensional Transceiver (#73) 2022-06-22 11:30:09 +02:00
TataTawa 1eeddad48f Patch 1 (#72)
* Update TileConduitBundle.java

* Update TileConduitBundle.java

* Update TileConduitBundle.java
2022-06-20 20:05:49 +02:00
Raven Szewczyk 7e625f2bff Save ServerChannelRegister together with every world save, and avoid saving it on server crashes. (#70) 2022-06-10 16:50:16 +02:00
MuXiu1997andKiwi 47bd7efd19 Update en_US.lang (#69)
Co-authored-by: Kiwi <[email protected]>

Co-authored-by: Kiwi <[email protected]>
2022-05-30 09:06:46 +02:00
DianeXD 4f8336dc5b Fix powered spawner wrong behavior (#67)
* Fix powered spawner wrong behavior

* Fix powered spawner wrong behavior
2022-05-27 12:46:35 +02:00
miozune b19a4c98b8 Add Garden Soil from Ztones to recognized farmland list for CustomSeedFarmer (#68) 2022-05-26 09:49:33 +02:00
Martin Robertz 5f4a9794b0 update mekanism link 2022-05-17 18:14:44 +02:00
MuXiu1997 6a00ab5d88 Fix TravelUpgrade (#66) 2022-05-02 20:06:16 +02:00
miozune da6e0c5ba0 Allow blinking onto the roof (#65)
* Allow blinking onto the roof

* swap
2022-04-25 15:32:07 +02:00
miozune edc8786d79 Fix overflow with XP container machines (#64) 2022-04-20 11:49:19 +02:00
miozune 88d7baef0a Fix chat spam when try to blink but staff does not have enough power (#63) 2022-04-19 11:18:50 +02:00
miozune efc8eba67b Travel Anchor improvements (#62)
* No penalty for failed teleportation

* Allow Travel Anchors to be hidden

* Fix protected mode not working

* Fix visibility not written to disk
2022-04-08 18:58:04 +02:00
TheyuGin f4f2b857b7 fix: moving around buttons in Big Advanced Item Filter (#61)
* fix: moving around buttons in Big Advanced Item Filter

* fix: moved sticky button to not split other buttons in extract
2022-04-05 07:09:35 +02:00
boubou19 958da172e4 fix farming station range (#60) 2022-03-30 20:03:22 +02:00
miozune 3669b5a690 Fix tooltip for coolant (#59)
* Fix tooltip for coolant

* Update OC
2022-03-19 15:49:39 +01:00
Pnc6lx d46289b0e1 EIO capacitor fix (#58)
* EIO capacitor fix

fix new capacitor behave in some machine

* Update TilePoweredSpawner.java

* Update TilePoweredSpawner.java
2022-03-04 16:10:13 +01:00
repo-alt 07152aaee0 fix AE2 version check in crash callback (#57) 2022-02-26 14:32:09 +01:00
bombcar 86da15ac65 Update .github scripts and buildscript (#56)
* additional dep cleanup

* build and test

* remove library
2022-02-12 22:16:35 +01:00
glowredman 979957a4c0 Make Forestry a soft-dependency (#55)
* Update Buildscript

* Only load Forestry Farmer if Forestry is installed
2022-02-12 07:38:56 -06:00
Zereff06 13634ef7c8 small correction "==" - "=" (#54) 2022-02-08 21:15:38 +01:00
bombcar def6497c99 update buildcraft (#53) 2022-02-07 00:34:31 +01:00
bombcar 1448342910 update dependencies, including buildscript and buildcraft (#52) 2022-02-06 21:24:43 +01:00
bombcar 35c2828696 nei 2022-01-27 21:21:38 -08:00
bombcar a661799beb update buildscript and readme 2022-01-27 21:21:38 -08:00
bombcar 018ee58dcc LGPL-3.0 2022-01-27 21:21:38 -08:00
Jason Mitchell 36d17585a3 add CCC dep 2022-01-18 00:13:04 -08:00
Jason Mitchell 0f8b438443 add more (formerly) transitive deps 2022-01-18 00:09:26 -08:00
Jason Mitchell 2db8a4e926 add nei explicit dep 2022-01-18 00:03:50 -08:00
Jason Mitchell 32edaf1acb update to explicit dependencies 2022-01-17 23:53:37 -08:00
Jason Mitchell 56fedda2d8 maven publish buildscript update 2022-01-17 23:53:37 -08:00
1666 changed files with 94863 additions and 90308 deletions

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
# This is the universal Text Editor Configuration
# for all GTNewHorizons projects
# See: https://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{bat,ini}]
end_of_line = crlf
[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
indent_size = 2
[*.lang]
trim_trailing_whitespace = false
+2
View File
@@ -0,0 +1,2 @@
# Ignore spotlessApply reformat
275d137ba8573454518c21bdcf4372362302ee82
+44
View File
@@ -0,0 +1,44 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
-9
View File
@@ -1,9 +0,0 @@
directory="run/crash-reports"
if [ -d $directory ]; then
echo "Crash reports detected:"
cat $directory/*
exit 1
else
echo "No crash reports detected"
exit 0
fi
+4 -36
View File
@@ -1,45 +1,13 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test
on:
pull_request:
branches: [ master, main ]
branches: [ master, main, release/** ]
push:
branches: [ master, main ]
branches: [ master, main, release/** ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupDecompWorkspace
- name: Build the mod
run: ./gradlew build
- name: Run server for 1 minute
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 60 ./gradlew runServer || true
- name: Test no crashes happend
run: |
chmod +x .github/scripts/test-no-crash-reports.sh
.github/scripts/test-no-crash-reports.sh
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
+17
View File
@@ -0,0 +1,17 @@
name: Optimize images
on:
pull_request:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
push:
branches: [ master, main, release/** ]
paths:
- "**/*.png"
jobs:
optimize-images:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
secrets: inherit
+7 -38
View File
@@ -1,45 +1,14 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Release tagged build
on:
push:
tags:
- '*'
tags: [ '*' ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
+2
View File
@@ -27,3 +27,5 @@ whitelist.json
*.iws
src/main/resources/mixins.*.json
*.bat
layout.json
.DS_Store
+3
View File
@@ -0,0 +1,3 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
-674
View File
@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.1996
-165
View File
@@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
-30
View File
@@ -1,30 +0,0 @@
#### Issue Description:
Note: If this bug occurs in a modpack, please report this to the modpack author. Otherwise, delete this line and add your description here. If you are using an unreleased version of Ender IO (e.g. for 1.8.9), please don't open an issue for features that have not been announced as "finished" or "working".
#### What happens:
#### What you expected to happen:
#### Steps to reproduce:
1.
2.
3.
...
____
#### Affected Versions (Do *not* use "latest"):
- EnderIO:
- EnderCore:
- Minecraft: 1.7.10
- Forge:
#### Your most recent log file where the issue was present:
[pastebin/gist/etc link here]
View File
File renamed without changes.
+6 -3
View File
@@ -3,12 +3,16 @@ EnderIO-Unofficial
[![Build Status](http://jenkins.usrv.eu:8080/buildStatus/icon?job=Ender-IO)](http://jenkins.usrv.eu:8080/job/Ender-IO/)
This is a unofficial version of EndeIO for 1.7.10, in case of any bugs or problems please do not contact the original developers of EnderIO!
All code (excluding the bundled APIs from other mods, which are covered by their respective licenses) are released without restriction into the public domain under the CC0 1.0 license (http://creativecommons.org/publicdomain/zero/1.0/legalcode) FAQ (https://wiki.creativecommons.org/CC0_FAQ).
Issues can be reported to the [GTNH tracker](https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues).
All code (excluding the bundled APIs from other mods, which are covered by their respective licenses) were released without restriction into the public domain under the CC0 1.0 license (http://creativecommons.org/publicdomain/zero/1.0/legalcode) FAQ (https://wiki.creativecommons.org/CC0_FAQ).
Do what you want with it, as long as you smile while doing so.
### GTNH Modifications:
LGPL v3.0 or later. Feel free to use our changes, just give back any changes you make to the community as well!
###Sound Credits
### Sound Credits
Most sound attributed under Creative Commons Attribution 3.0 Unported (CC BY 3.0)
@@ -18,4 +22,3 @@ Credits:
- http://freesound.org/people/Anton/
- http://freesound.org/people/pj1s/
- http://freesound.org/people/Syna-Max/
+2 -514
View File
@@ -1,517 +1,5 @@
//version: ffe7b130f98fdfa1ac7c6ba4bd34722a55ab28d4
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.util.concurrent.TimeUnit
buildscript {
repositories {
maven {
name = "forge"
url = "https://maven.minecraftforge.net"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "Scala CI dependencies"
url = "https://repo1.maven.org/maven2/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
}
}
//version: 1707058017
plugins {
id 'idea'
id 'scala'
id("org.ajoberstar.grgit") version("3.1.1")
id("com.github.johnrengelman.shadow") version("4.0.4")
id("com.palantir.git-version") version("0.12.3")
}
apply plugin: 'forge'
def projectJavaVersion = JavaLanguageVersion.of(8)
java {
toolchain {
languageVersion.set(projectJavaVersion)
}
}
idea {
module {
inheritOutputDirs = true
downloadJavadoc = true
downloadSources = true
}
}
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
checkPropertyExists("modName")
checkPropertyExists("modId")
checkPropertyExists("modGroup")
checkPropertyExists("autoUpdateBuildScript")
checkPropertyExists("minecraftVersion")
checkPropertyExists("forgeVersion")
checkPropertyExists("replaceGradleTokenInFile")
checkPropertyExists("gradleTokenModId")
checkPropertyExists("gradleTokenModName")
checkPropertyExists("gradleTokenVersion")
checkPropertyExists("gradleTokenGroupName")
checkPropertyExists("apiPackage")
checkPropertyExists("accessTransformersFile")
checkPropertyExists("usesMixins")
checkPropertyExists("mixinPlugin")
checkPropertyExists("mixinsPackage")
checkPropertyExists("coreModClass")
checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
def checkPropertyExists(String propertyName) {
if (project.hasProperty(propertyName) == false) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties")
}
}
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) {
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
}
if(apiPackage) {
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
}
}
if(accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
if(new File(targetFile).exists() == false) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
}
if(usesMixins.toBoolean()) {
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
}
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
if((new File(targetPackageJava).exists() || new File(targetPackageScala).exists()) == false) {
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
}
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
if((new File(targetFileJava).exists() || new File(targetFileScala).exists() || new File(targetFileScalaJava).exists()) == false) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
}
}
if(coreModClass) {
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
if((new File(targetFileJava).exists() || new File(targetFileScala).exists() || new File(targetFileScalaJava).exists()) == false) {
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
// Make sure GregTech build won't time out
System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String)
System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String)
}
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
'git config core.fileMode false'.execute()
// Pulls version from git tag
try {
version = minecraftVersion + "-" + gitVersion()
}
catch (Exception e) {
throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!");
}
group = modGroup
archivesBaseName = modId
minecraft {
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
runDir = "run"
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
if(gradleTokenModId) {
replace gradleTokenModId, modId
}
if(gradleTokenModName) {
replace gradleTokenModName, modName
}
if(gradleTokenVersion) {
replace gradleTokenVersion, versionDetails().lastTag
}
if(gradleTokenGroupName) {
replace gradleTokenGroupName, modGroup
}
}
}
if(file("addon.gradle").exists()) {
apply from: "addon.gradle"
}
apply from: 'repositories.gradle'
configurations {
implementation.extendsFrom(shadowImplementation)
}
repositories {
maven {
name = "Overmind forge repo mirror"
url = "https://gregtech.overminddl1.com/"
}
if(usesMixins.toBoolean()) {
maven {
name = "sponge"
url = "https://repo.spongepowered.org/repository/maven-public"
}
maven {
url = "https://jitpack.io"
}
}
}
dependencies {
if(usesMixins.toBoolean()) {
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
annotationProcessor("com.google.guava:guava:24.1.1-jre")
annotationProcessor("com.google.code.gson:gson:2.8.6")
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
// using 0.8 to workaround a issue in 0.7 which fails mixin application
compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: "launchwrapper"
exclude module: "guava"
exclude module: "gson"
exclude module: "commons-io"
exclude module: "log4j-core"
}
compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
}
}
apply from: 'dependencies.gradle'
def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if(usesMixins.toBoolean()) {
new File(projectDir.toString() + "/src/main/resources/", "mixins." + modId + ".json").text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}
"""
}
}
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
}
shadowJar {
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
dependsOn(relocateShadowJar)
}
jar {
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(shadowJar)
enabled = false
}
}
reobf {
if(usesMixins.toBoolean()) {
addExtraSrgFile mixinSrg
}
}
afterEvaluate {
if(usesMixins.toBoolean()) {
tasks.compileJava {
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobf.srg}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
"-XDenableSunApiLintControl",
"-XDignore.symbol.file"
]
}
}
}
runClient {
def arguments = []
if(usesMixins.toBoolean()) {
arguments += [
"--mods=../build/libs/$modId-${version}.jar",
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
}
if(developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
]
}
args(arguments)
}
runServer {
def arguments = []
if (usesMixins.toBoolean()) {
arguments += [
"--mods=../build/libs/$modId-${version}.jar",
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
}
args(arguments)
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion = projectJavaVersion
}
)
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}
if(usesMixins.toBoolean()) {
from refMap
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
def getManifestAttributes() {
def manifestAttributes = [:]
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
if(accessTransformersFile) {
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
}
if(coreModClass) {
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
}
if(usesMixins.toBoolean()) {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
from (sourceSets.main.allJava)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
task shadowDevJar(type: ShadowJar) {
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
}
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
target = tasks.shadowDevJar
prefix = modGroup + ".shadow"
}
task circularResolverJar(type: Jar) {
dependsOn(relocateShadowDevJar)
dependsOn(shadowDevJar)
enabled = false
}
task devJar(type: Jar) {
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(circularResolverJar)
enabled = false
}
}
task apiJar(type: Jar) {
from (sourceSets.main.allJava) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString() + '/**'
}
from (sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString() + '/**'
}
from (sourceSets.main.resources.srcDirs) {
include("LICENSE")
}
getArchiveClassifier().set('api')
}
artifacts {
archives sourcesJar
archives devJar
if(apiPackage) {
archives apiJar
}
}
// Updating
task updateBuildScript {
doLast {
if (updateBuildScript()) return
print("Build script already up-to-date!")
}
}
if (isNewBuildScriptVersionAvailable()) {
if (autoUpdateBuildScript.toBoolean()) {
updateBuildScript()
} else {
println("Build script update available! Run 'gradle updateBuildScript'")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle")
}
static boolean updateBuildScript() {
if (isNewBuildScriptVersionAvailable()) {
def buildscriptFile = new File("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}
static boolean isNewBuildScriptVersionAvailable() {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
String currentBuildScript = new File("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
return versionLine.split(": ").last()
}
return ""
}
configure(updateBuildScript) {
group = 'forgegradle'
description = 'Updates the build script to the latest version'
id 'com.gtnewhorizons.gtnhconvention'
}
+30 -43
View File
@@ -1,48 +1,35 @@
// Add your dependencies here
dependencies {
compile("com.github.GTNewHorizons:EnderCore:master-SNAPSHOT:dev")
compile("com.github.GTNewHorizons:ForestryMC:master-SNAPSHOT:dev")
api('com.github.GTNewHorizons:EnderCore:0.5.15:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.37:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.8.130-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.11.45:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.63:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
api("com.github.GTNewHorizons:TinkersConstruct:1.14.107-GTNH:dev")
compile("curse.maven:cofh-lib-220333:2388748")
shadowImplementation("cglib:cglib-nodep:3.3.0")
compileOnly("com.github.GTNewHorizons:waila:master-SNAPSHOT:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:master-SNAPSHOT:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Baubles:master-SNAPSHOT:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Railcraft:master-SNAPSHOT:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:StorageDrawers:master-SNAPSHOT:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Chisel:master-SNAPSHOT:dev") {
transitive = false
}
compileOnly("curse.maven:minefactory-reloaded-66672:2366150") {
transitive = false
}
compileOnly("curse.maven:computercraft-67504:2269339") { // https://www.curseforge.com/minecraft/mc-mods/computercraft/files/2269339
transitive = false
}
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {
transitive = false
}
compileOnly("li.cil.oc:OpenComputers:MC1.7.10-1.7.5.1356:api") {
transitive = false
}
compileOnly("curse.maven:mekanism-268560:2475797") { // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797
transitive = false
}
compileOnly("curse.maven:ee3-65509:2305023") { // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
transitive = false
}
compileOnly files("dependencies/immibis-microblocks-59.1.2.jar")
devOnlyNonPublishable('com.github.GTNewHorizons:waila:1.19.34:dev') {transitive = false}
compileOnly('ganymedes01.etfuturum:Et-Futurum-Requiem:2.6.48-GTNH:dev') {transitive = false}
runtimeOnlyNonPublishable('com.github.GTNewHorizons:WAILAPlugins:0.7.2:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:Backhand:1.8.14:dev") { transitive = false }
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-999-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.22-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.54.129:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.3.88-1.7.10:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.17.31:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.2.29-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.17.32-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.61-GTNH:api') {transitive = false}
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('curse.maven:ee3-65509:2305023') // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
compileOnly(rfg.deobf('curse.maven:computercraft-67504:2269339')) // https://www.curseforge.com/minecraft/mc-mods/computercraft/files/2269339
compileOnly(rfg.deobf('curse.maven:mekanism-268560:2475797')) // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797
compileOnly(rfg.deobf('maven.modrinth:immibis-microblocks:59.1.2')) // https://modrinth.com/mod/immibis-microblocks/version/59.1.2
compileOnly('com.github.GTNewHorizons:BetterBuildersWands:0.13.12-GTNH:dev@jar')
compileOnlyApi('com.github.GTNewHorizons:Angelica:2.2.10:api') {transitive = false}
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.196:dev")
compileOnly('curse.maven:automagy-222153:2285272')
}
Binary file not shown.
+205 -27
View File
@@ -1,60 +1,238 @@
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = Ender IO
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = EnderIO
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = crazypants.enderio
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Whether to use modGroup as the maven publishing group.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Will update your build.gradle automatically whenever an update is available
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = "Developer"
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = EnderIO.java
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Enables modern Java syntax support. Valid values:
# - false: No modern syntax, Java 8 only
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
# - modern: Native modern Java bytecode, no downgrading
enableModernJavaSyntax = jabel
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
# and should *not* be used in most situations. -1 disables this.
# forceToolchainVersion = -1
# Target JVM version for JVM Downgrader bytecode downgrading.
# Only used when enableModernJavaSyntax = jvmDowngrader
# downgradeTargetVersion = 8
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
# Classes will be available in META-INF/versions/N/ for each version N in this list.
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
# jvmDowngraderMultiReleaseVersions = 21,25
# Specifies how JVM Downgrader API stubs are provided. Options:
# - shade: Shade minimized stubs into the jar
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
# - external: Another dependency provides stubs (no constraint, no warning)
# - (empty): Warning reminding you to configure stubs
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
# jvmDowngraderStubsProvider =
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = true
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass = crazypants.enderio.Tags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =
gradleTokenVersion = GRADLETOKEN_VERSION
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
apiPackage = api
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
accessTransformersFile =
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile = enderio_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatability only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
# This parameter is for legacy compatibility only
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = true
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
# Non-GTNH properties
org.gradle.configuration-cache = true
org.gradle.parallel = true
+12
View File
@@ -0,0 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9064f22734b42ac03e85df04b632e167/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/4d0277c49991306ac78048580fe34bcf/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/a9fa3b809e484a1e1ac4308a5dda661a/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/aa99913fa6d767d899ffc96082da01ca/redirect
toolchainVersion=25
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+178 -118
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,80 +15,114 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,92 +131,118 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+27 -34
View File
@@ -13,8 +13,10 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,10 +27,14 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -37,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -51,48 +57,35 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
-22
View File
@@ -1,26 +1,4 @@
// Add any additional repositories for your dependencies here
repositories {
maven {
name = "ic2"
url = "http://maven.ic2.player.to/"
metadataSources {
mavenPom()
artifact()
}
}
maven {
name "OpenComputers Repo"
url = "http://maven.cil.li/"
metadataSources {
mavenPom()
artifact()
}
}
maven {
url "https://cursemaven.com"
}
maven {
url = "https://jitpack.io"
}
}
+23
View File
@@ -0,0 +1,23 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.29'
}
+29 -26
View File
@@ -14,33 +14,36 @@ import crazypants.enderio.tool.ToolUtil;
public abstract class BlockEio extends BlockEnder {
protected BlockEio(String name, Class<? extends TileEntityEio> teClass) {
super(name, teClass);
setCreativeTab(EnderIOTab.tabEnderIO);
}
protected BlockEio(String name, Class<? extends TileEntityEio> teClass, Material mat) {
super(name, teClass, mat);
setCreativeTab(EnderIOTab.tabEnderIO);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9) {
if(shouldWrench(world, x, y, z, entityPlayer, side) && ToolUtil.breakBlockWithTool(this, world, x, y, z, entityPlayer)) {
return true;
protected BlockEio(String name, Class<? extends TileEntityEio> teClass) {
super(name, teClass);
setCreativeTab(EnderIOTab.tabEnderIO);
}
TileEntity te = world.getTileEntity(x, y, z);
ITool tool = ToolUtil.getEquippedTool(entityPlayer);
if(tool != null && !entityPlayer.isSneaking() && tool.canUse(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z)) {
if(te instanceof AbstractMachineEntity) {
((AbstractMachineEntity) te).toggleIoModeForFace(ForgeDirection.getOrientation(side));
world.markBlockForUpdate(x, y, z);
return true;
}
protected BlockEio(String name, Class<? extends TileEntityEio> teClass, Material mat) {
super(name, teClass, mat);
setCreativeTab(EnderIOTab.tabEnderIO);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7,
float par8, float par9) {
if (shouldWrench(world, x, y, z, entityPlayer, side)
&& ToolUtil.breakBlockWithTool(this, world, x, y, z, entityPlayer)) {
return true;
}
TileEntity te = world.getTileEntity(x, y, z);
ITool tool = ToolUtil.getEquippedTool(entityPlayer);
if (tool != null && !entityPlayer.isSneaking()
&& tool.canUse(entityPlayer.getCurrentEquippedItem(), entityPlayer, x, y, z)) {
if (te instanceof AbstractMachineEntity) {
((AbstractMachineEntity) te).toggleIoModeForFace(ForgeDirection.getOrientation(side));
world.markBlockForUpdate(x, y, z);
return true;
}
}
return super.onBlockActivated(world, x, y, z, entityPlayer, side, par7, par8, par9);
}
return super.onBlockActivated(world, x, y, z, entityPlayer, side, par7, par8, par9);
}
}
+306 -341
View File
@@ -1,8 +1,5 @@
package crazypants.enderio;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@@ -30,39 +27,29 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.conduit.BlockConduitBundle;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.TileConduitBundle;
import crazypants.enderio.conduit.facade.FacadeRenderer;
import crazypants.enderio.conduit.gas.GasConduit;
import crazypants.enderio.conduit.gas.GasConduitRenderer;
import crazypants.enderio.conduit.gas.GasUtil;
import crazypants.enderio.conduit.item.ItemConduit;
import crazypants.enderio.conduit.liquid.AbstractEnderLiquidConduit;
import crazypants.enderio.conduit.liquid.AdvancedLiquidConduit;
import crazypants.enderio.conduit.liquid.AdvancedLiquidConduitRenderer;
import crazypants.enderio.conduit.liquid.CrystallineEnderLiquidConduit;
import crazypants.enderio.conduit.liquid.CrystallinePinkSlimeEnderLiquidConduit;
import crazypants.enderio.conduit.liquid.EnderLiquidConduit;
import crazypants.enderio.conduit.liquid.EnderLiquidConduitRenderer;
import crazypants.enderio.conduit.liquid.LiquidConduit;
import crazypants.enderio.conduit.liquid.LiquidConduitRenderer;
import crazypants.enderio.conduit.liquid.MelodicEnderLiquidConduit;
import crazypants.enderio.conduit.liquid.StellarEnderLiquidConduit;
import crazypants.enderio.conduit.me.MEConduit;
import crazypants.enderio.conduit.me.MEUtil;
import crazypants.enderio.conduit.oc.OCConduit;
import crazypants.enderio.conduit.oc.OCConduitRenderer;
import crazypants.enderio.conduit.oc.OCUtil;
import crazypants.enderio.conduit.power.PowerConduit;
import crazypants.enderio.conduit.power.PowerConduitRenderer;
import crazypants.enderio.conduit.power.endergy.PowerConduitEndergy;
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduitRenderer;
import crazypants.enderio.conduit.redstone.RedstoneConduit;
import crazypants.enderio.conduit.redstone.RedstoneSwitch;
import crazypants.enderio.conduit.redstone.RedstoneSwitchRenderer;
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
import crazypants.enderio.conduit.render.ConduitRenderer;
import crazypants.enderio.conduit.render.DefaultConduitRenderer;
import crazypants.enderio.conduit.render.ItemConduitRenderer;
import crazypants.enderio.config.Config;
import crazypants.enderio.enderface.EnderIoRenderer;
@@ -116,11 +103,8 @@ import crazypants.enderio.machine.painter.BlockPaintedFenceGateRenderer;
import crazypants.enderio.machine.painter.BlockPaintedGlowstone;
import crazypants.enderio.machine.painter.PaintedBlockRenderer;
import crazypants.enderio.machine.painter.PaintedItemRenderer;
import crazypants.enderio.machine.power.BlockCapacitorBank;
import crazypants.enderio.machine.power.CapBankRenderer2;
import crazypants.enderio.machine.power.CapacitorBankRenderer;
import crazypants.enderio.machine.ranged.RangeEntity;
import crazypants.enderio.machine.ranged.RangeRenerer;
import crazypants.enderio.machine.ranged.RangeRenderer;
import crazypants.enderio.machine.reservoir.ReservoirRenderer;
import crazypants.enderio.machine.reservoir.TileReservoir;
import crazypants.enderio.machine.solar.BlockSolarPanel;
@@ -155,355 +139,336 @@ import crazypants.enderio.teleport.telepad.TileTelePad;
@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy {
// @formatter:off
public static int[][] sideAndFacingToSpriteOffset = new int[][] {
{ 3, 2, 0, 0, 0, 0 },
{ 2, 3, 1, 1, 1, 1 },
{ 1, 1, 3, 2, 5, 4 },
{ 0, 0, 2, 3, 4, 5 },
{ 4, 5, 4, 5, 3, 2 },
{ 5, 4, 5, 4, 2, 3 }
};
// @formatter:on
// @formatter:off
public static int[][] sideAndFacingToSpriteOffset = new int[][] {
{3, 2, 0, 0, 0, 0},
{2, 3, 1, 1, 1, 1},
{1, 1, 3, 2, 5, 4},
{0, 0, 2, 3, 4, 5},
{4, 5, 4, 5, 3, 2},
{5, 4, 5, 4, 2, 3}
};
// @formatter:on
private final List<ConduitRenderer> conduitRenderers = new ArrayList<ConduitRenderer>();
private ConduitBundleRenderer cbr;
private final DefaultConduitRenderer dcr = new DefaultConduitRenderer();
private boolean checkedNei = false;
private boolean neiInstalled = false;
private ConduitBundleRenderer cbr;
private boolean checkedNei = false;
private boolean neiInstalled = false;
@Override
public World getClientWorld() {
return FMLClientHandler.instance().getClient().theWorld;
}
@Override
public boolean isNeiInstalled() {
if(checkedNei) {
return neiInstalled;
}
try {
Class.forName("crazypants.enderio.nei.EnchanterRecipeHandler");
neiInstalled = true;
} catch (Exception e) {
neiInstalled = false;
}
checkedNei = true;
return false;
}
@Override
public EntityPlayer getClientPlayer() {
return Minecraft.getMinecraft().thePlayer;
}
public ConduitBundleRenderer getConduitBundleRenderer() {
return cbr;
}
public void setCbr(ConduitBundleRenderer cbr) {
this.cbr = cbr;
}
@Override
public void loadIcons() {
RedstoneConduit.initIcons();
InsulatedRedstoneConduit.initIcons();
RedstoneSwitch.initIcons();
PowerConduit.initIcons();
PowerConduitEndergy.initIcons();
LiquidConduit.initIcons();
AdvancedLiquidConduit.initIcons();
AbstractEnderLiquidConduit.initIcons();
EnderLiquidConduit.initIcons();
CrystallineEnderLiquidConduit.initIcons();
CrystallinePinkSlimeEnderLiquidConduit.initIcons();
MelodicEnderLiquidConduit.initIcons();
StellarEnderLiquidConduit.initIcons();
ItemConduit.initIcons();
if(GasUtil.isGasConduitEnabled()) {
GasConduit.initIcons();
}
if(MEUtil.isMEEnabled()) {
MEConduit.initIcons();
}
if (OCUtil.isOCEnabled()) {
OCConduit.initIcons();
}
}
@Override
public void load() {
super.load();
SpecialTooltipHandler tt = SpecialTooltipHandler.INSTANCE;
tt.addCallback(new TooltipHandlerGrinding());
tt.addCallback(new TooltipHandlerBurnTime());
if (Config.addFuelTooltipsToAllFluidContainers) {
tt.addCallback(new TooltipHandlerFluid());
@Override
public World getClientWorld() {
return FMLClientHandler.instance().getClient().theWorld;
}
// Renderers
AbstractMachineBlock.renderId = RenderingRegistry.getNextAvailableRenderId();
AbstractMachineRenderer machRen = new AbstractMachineRenderer();
RenderingRegistry.registerBlockHandler(machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockStirlingGenerator), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCrusher), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockAlloySmelter), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPowerMonitor), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPainter), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCrafter), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockBuffer), machRen);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemBrokenSpawner, new BrokenSpawnerRenderer());
BlockSolarPanel.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new SolarPanelRenderer());
EnchanterModelRenderer emr = new EnchanterModelRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, emr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnchanter), emr);
BlockFusedQuartz.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new FusedQuartzRenderer());
BlockFarmStation.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new FarmingStationRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileFarmStation.class, new FarmingStationSpecialRenderer());
BlockSoulBinder.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new SoulBinderRenderer());
ObeliskRenderer defaultObeliskRenderer = new ObeliskRenderer();
BlockObeliskAbstract.defaultObeliskRenderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(defaultObeliskRenderer);
ObeliskSpecialRenderer<TileAttractor> attRen = new ObeliskSpecialRenderer<TileAttractor>(new ItemStack(EnderIO.itemMaterial, 1,
Material.ATTRACTOR_CRYSTAL.ordinal()), defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileAttractor.class, attRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockAttractor), attRen);
AversionObeliskRenderer sgr = new AversionObeliskRenderer(defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileAversionObelisk.class, sgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockSpawnGuard), sgr);
ObeliskSpecialRenderer<TileExperienceObelisk> eor = new ObeliskSpecialRenderer<TileExperienceObelisk>(new ItemStack(EnderIO.itemXpTransfer),
defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileExperienceObelisk.class, eor);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockExperianceOblisk), eor);
ObeliskSpecialRenderer<TileWeatherObelisk> twr = new WeatherObeliskSpecialRenderer(new ItemStack(Items.fireworks), defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileWeatherObelisk.class, twr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockWeatherObelisk), twr);
BlockCombustionGenerator.renderId = RenderingRegistry.getNextAvailableRenderId();
TechneMachineRenderer<TileCombustionGenerator> cr = new TechneMachineRenderer<TileCombustionGenerator>(EnderIO.blockCombustionGenerator, "models/combustionGen");
RenderingRegistry.registerBlockHandler(cr);
ZombieGeneratorRenderer zgr = new ZombieGeneratorRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileZombieGenerator.class, zgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockZombieGenerator), zgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockFrankenZombieGenerator), zgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnderGenerator), zgr);
KillerJoeRenderer kjr = new KillerJoeRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileKillerJoe.class, kjr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockKillerJoe), kjr);
BlockVat.renderId = RenderingRegistry.getNextAvailableRenderId();
TechneMachineRenderer<TileVat> vr = new TechneMachineRenderer<TileVat>(EnderIO.blockVat, "models/vat");
RenderingRegistry.registerBlockHandler(vr);
FusedQuartzFrameRenderer fqfr = new FusedQuartzFrameRenderer();
MinecraftForgeClient.registerItemRenderer(EnderIO.itemFusedQuartzFrame, fqfr);
BlockElectricLight.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new ElectricLightRenderer());
if(EnderIO.blockCapBank != null) {
BlockCapBank.renderId = RenderingRegistry.getNextAvailableRenderId();
CapBankRenderer newCbr = new CapBankRenderer();
RenderingRegistry.registerBlockHandler(newCbr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCapBank), newCbr);
ClientRegistry.bindTileEntitySpecialRenderer(TileCapBank.class, newCbr);
@Override
public boolean isNeiInstalled() {
if (checkedNei) {
return neiInstalled;
}
try {
Class.forName("crazypants.enderio.nei.EnchanterRecipeHandler");
neiInstalled = true;
} catch (Exception e) {
neiInstalled = false;
}
checkedNei = true;
return false;
}
CapacitorBankRenderer capr = new CapacitorBankRenderer();
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCapacitorBank), capr);
BlockCapacitorBank.renderId = RenderingRegistry.getNextAvailableRenderId();
CapBankRenderer2 cbr2 = new CapBankRenderer2();
RenderingRegistry.registerBlockHandler(cbr2);
BlockVacuumChest.renderId = RenderingRegistry.getNextAvailableRenderId();
VacuumChestRenderer vcr = new VacuumChestRenderer();
RenderingRegistry.registerBlockHandler(vcr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockVacuumChest), vcr);
ItemConduitRenderer itemConRenderer = new ItemConduitRenderer();
MinecraftForgeClient.registerItemRenderer(EnderIO.itemLiquidConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduitEndergy, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemRedstoneConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemItemConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemGasConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemMEConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemOCConduit, itemConRenderer);
BlockPaintedFenceGateRenderer bcfgr = new BlockPaintedFenceGateRenderer();
BlockPaintedFenceGate.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(bcfgr);
PaintedItemRenderer pir = new PaintedItemRenderer();
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedFence), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedFenceGate), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedWall), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedStair), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedSlab), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedGlowstone), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedCarpet), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockDarkSteelPressurePlate), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTravelPlatform), pir);
BlockPaintedGlowstone.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new PaintedBlockRenderer(BlockPaintedGlowstone.renderId, Blocks.glowstone));
BlockTravelAnchor.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new PaintedBlockRenderer(BlockTravelAnchor.renderId, EnderIO.blockTravelPlatform));
BlockTelePad.renderId = RenderingRegistry.getNextAvailableRenderId();
TelePadRenderer telePadRenderer = new TelePadRenderer();
RenderingRegistry.registerBlockHandler(telePadRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileTelePad.class, new TelePadSpecialRenderer(telePadRenderer));
MinecraftForgeClient.registerItemRenderer(EnderIO.itemMachinePart, new MachinePartRenderer());
MinecraftForgeClient.registerItemRenderer(EnderIO.itemConduitFacade, new FacadeRenderer());
cbr = new ConduitBundleRenderer((float) Config.conduitScale);
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(cbr);
ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);
ClientRegistry.bindTileEntitySpecialRenderer(TileTravelAnchor.class, new TravelEntitySpecialRenderer());
BlockEndermanSkull.renderId = RenderingRegistry.getNextAvailableRenderId();
EndermanSkullRenderer esk = new EndermanSkullRenderer();
RenderingRegistry.registerBlockHandler(esk);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEndermanSkull), esk);
conduitRenderers.add(RedstoneSwitchRenderer.getInstance());
conduitRenderers.add(new AdvancedLiquidConduitRenderer());
conduitRenderers.add(LiquidConduitRenderer.create());
conduitRenderers.add(new PowerConduitRenderer());
conduitRenderers.add(new InsulatedRedstoneConduitRenderer());
conduitRenderers.add(new EnderLiquidConduitRenderer());
conduitRenderers.add(new crazypants.enderio.conduit.item.ItemConduitRenderer());
if(GasUtil.isGasConduitEnabled()) {
conduitRenderers.add(new GasConduitRenderer());
}
if (OCUtil.isOCEnabled()) {
conduitRenderers.add(new OCConduitRenderer());
@Override
public EntityPlayer getClientPlayer() {
return Minecraft.getMinecraft().thePlayer;
}
EnderIoRenderer eior = new EnderIoRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileEnderIO.class, eior);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnderIo), eior);
ClientRegistry.bindTileEntitySpecialRenderer(TileReservoir.class, new ReservoirRenderer(EnderIO.blockReservoir));
ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new TankFluidRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTank), new TankItemRenderer());
HyperCubeRenderer hcr = new HyperCubeRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileHyperCube.class, hcr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockHyperCube), hcr);
if(Config.transceiverEnabled) {
TransceiverRenderer tr = new TransceiverRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileTransceiver.class, tr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTransceiver), tr);
public ConduitBundleRenderer getConduitBundleRenderer() {
return cbr;
}
new YetaWrenchOverlayRenderer();
new ConduitProbeOverlayRenderer();
if(Config.useSneakMouseWheelYetaWrench) {
ToolTickHandler th = new ToolTickHandler();
MinecraftForge.EVENT_BUS.register(th);
FMLCommonHandler.instance().bus().register(th);
public void setCbr(ConduitBundleRenderer cbr) {
this.cbr = cbr;
}
MinecraftForge.EVENT_BUS.register(TravelController.instance);
FMLCommonHandler.instance().bus().register(TravelController.instance);
DarkSteelItems.registerItemRenderer();
@Override
public void loadIcons() {
RedstoneConduit.initIcons();
InsulatedRedstoneConduit.initIcons();
RedstoneSwitch.initIcons();
PowerConduit.initIcons();
PowerConduitEndergy.initIcons();
LiquidConduit.initIcons();
AdvancedLiquidConduit.initIcons();
AbstractEnderLiquidConduit.initIcons();
EnderLiquidConduit.initIcons();
CrystallineEnderLiquidConduit.initIcons();
CrystallinePinkSlimeEnderLiquidConduit.initIcons();
MelodicEnderLiquidConduit.initIcons();
StellarEnderLiquidConduit.initIcons();
ItemConduit.initIcons();
if (GasUtil.isGasConduitEnabled()) {
GasConduit.initIcons();
}
if (MEUtil.isMEEnabled()) {
MEConduit.initIcons();
}
if (OCUtil.isOCEnabled()) {
OCConduit.initIcons();
}
}
FMLCommonHandler.instance().bus().register(KeyTracker.instance);
@Override
public void load() {
super.load();
RenderingRegistry.registerEntityRenderingHandler(SoundEntity.class, new SoundRenderer());
RenderingRegistry.registerEntityRenderingHandler(RangeEntity.class, new RangeRenerer());
MinecraftForge.EVENT_BUS.register(SoundDetector.instance);
FMLCommonHandler.instance().bus().register(SoundDetector.instance);
if(!Loader.isModLoaded("OpenBlocks")) {
//We have registered liquid XP so we need to give it textures
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
@Override
public void registerIcons(IIconRegister register) {
//NB: textures re-used with permission from OpenBlocks to maintain look
IIcon flowing = register.registerIcon("enderio:xpjuiceflowing");
IIcon still = register.registerIcon("enderio:xpjuicestill");
EnderIO.fluidXpJuice.setIcons(still, flowing);
SpecialTooltipHandler tt = SpecialTooltipHandler.INSTANCE;
tt.addCallback(new TooltipHandlerGrinding());
tt.addCallback(new TooltipHandlerBurnTime());
if (Config.addFuelTooltipsToAllFluidContainers) {
tt.addCallback(new TooltipHandlerFluid());
}
@Override
public int getTextureType() {
return 0;
// Renderers
AbstractMachineBlock.renderId = RenderingRegistry.getNextAvailableRenderId();
AbstractMachineRenderer machRen = new AbstractMachineRenderer();
RenderingRegistry.registerBlockHandler(machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockStirlingGenerator), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCrusher), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockAlloySmelter), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPowerMonitor), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPainter), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCrafter), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockBuffer), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPoweredSpawner), machRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockSliceAndSplice), machRen);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemBrokenSpawner, new BrokenSpawnerRenderer());
BlockSolarPanel.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new SolarPanelRenderer());
EnchanterModelRenderer emr = new EnchanterModelRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, emr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnchanter), emr);
BlockFusedQuartz.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new FusedQuartzRenderer());
BlockFarmStation.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new FarmingStationRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileFarmStation.class, new FarmingStationSpecialRenderer());
BlockSoulBinder.renderId = RenderingRegistry.getNextAvailableRenderId();
SoulBinderRenderer soulBinderRenderer = new SoulBinderRenderer();
RenderingRegistry.registerBlockHandler(soulBinderRenderer);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockSoulFuser), soulBinderRenderer);
ObeliskRenderer defaultObeliskRenderer = new ObeliskRenderer();
BlockObeliskAbstract.defaultObeliskRenderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(defaultObeliskRenderer);
ObeliskSpecialRenderer<TileAttractor> attRen = new ObeliskSpecialRenderer<>(
new ItemStack(EnderIO.itemMaterial, 1, Material.ATTRACTOR_CRYSTAL.ordinal()),
defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileAttractor.class, attRen);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockAttractor), attRen);
AversionObeliskRenderer sgr = new AversionObeliskRenderer(defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileAversionObelisk.class, sgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockSpawnGuard), sgr);
ObeliskSpecialRenderer<TileExperienceObelisk> eor = new ObeliskSpecialRenderer<>(
new ItemStack(EnderIO.itemXpTransfer),
defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileExperienceObelisk.class, eor);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockExperianceOblisk), eor);
ObeliskSpecialRenderer<TileWeatherObelisk> twr = new WeatherObeliskSpecialRenderer(
new ItemStack(Items.fireworks),
defaultObeliskRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileWeatherObelisk.class, twr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockWeatherObelisk), twr);
BlockCombustionGenerator.renderId = RenderingRegistry.getNextAvailableRenderId();
TechneMachineRenderer<TileCombustionGenerator> cr = new TechneMachineRenderer<>(
EnderIO.blockCombustionGenerator,
"models/combustionGen");
RenderingRegistry.registerBlockHandler(cr);
ZombieGeneratorRenderer zgr = new ZombieGeneratorRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileZombieGenerator.class, zgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockZombieGenerator), zgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockFrankenZombieGenerator), zgr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnderGenerator), zgr);
KillerJoeRenderer kjr = new KillerJoeRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileKillerJoe.class, kjr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockKillerJoe), kjr);
BlockVat.renderId = RenderingRegistry.getNextAvailableRenderId();
TechneMachineRenderer<TileVat> vr = new TechneMachineRenderer<>(EnderIO.blockVat, "models/vat");
RenderingRegistry.registerBlockHandler(vr);
FusedQuartzFrameRenderer fqfr = new FusedQuartzFrameRenderer();
MinecraftForgeClient.registerItemRenderer(EnderIO.itemFusedQuartzFrame, fqfr);
BlockElectricLight.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new ElectricLightRenderer());
if (EnderIO.blockCapBank != null) {
BlockCapBank.renderId = RenderingRegistry.getNextAvailableRenderId();
CapBankRenderer newCbr = new CapBankRenderer();
RenderingRegistry.registerBlockHandler(newCbr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockCapBank), newCbr);
ClientRegistry.bindTileEntitySpecialRenderer(TileCapBank.class, newCbr);
}
});
BlockVacuumChest.renderId = RenderingRegistry.getNextAvailableRenderId();
VacuumChestRenderer vcr = new VacuumChestRenderer();
RenderingRegistry.registerBlockHandler(vcr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockVacuumChest), vcr);
ItemConduitRenderer itemConRenderer = new ItemConduitRenderer();
MinecraftForgeClient.registerItemRenderer(EnderIO.itemLiquidConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemPowerConduitEndergy, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemRedstoneConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemItemConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemGasConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemMEConduit, itemConRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemOCConduit, itemConRenderer);
BlockPaintedFenceGateRenderer bcfgr = new BlockPaintedFenceGateRenderer();
BlockPaintedFenceGate.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(bcfgr);
PaintedItemRenderer pir = new PaintedItemRenderer();
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedFence), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedFenceGate), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedWall), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedStair), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedSlab), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedGlowstone), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockPaintedCarpet), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockDarkSteelPressurePlate), pir);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTravelPlatform), pir);
BlockPaintedGlowstone.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry
.registerBlockHandler(new PaintedBlockRenderer(BlockPaintedGlowstone.renderId, Blocks.glowstone));
BlockTravelAnchor.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(
new PaintedBlockRenderer(BlockTravelAnchor.renderId, EnderIO.blockTravelPlatform));
BlockTelePad.renderId = RenderingRegistry.getNextAvailableRenderId();
TelePadRenderer telePadRenderer = new TelePadRenderer();
RenderingRegistry.registerBlockHandler(telePadRenderer);
ClientRegistry.bindTileEntitySpecialRenderer(TileTelePad.class, new TelePadSpecialRenderer(telePadRenderer));
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTelePad), telePadRenderer);
MinecraftForgeClient.registerItemRenderer(EnderIO.itemMachinePart, new MachinePartRenderer());
MinecraftForgeClient.registerItemRenderer(EnderIO.itemConduitFacade, new FacadeRenderer());
cbr = new ConduitBundleRenderer((float) Config.conduitScale);
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(cbr);
ClientRegistry.bindTileEntitySpecialRenderer(TileTravelAnchor.class, new TravelEntitySpecialRenderer());
BlockEndermanSkull.renderId = RenderingRegistry.getNextAvailableRenderId();
EndermanSkullRenderer esk = new EndermanSkullRenderer();
RenderingRegistry.registerBlockHandler(esk);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEndermanSkull), esk);
EnderIoRenderer eior = new EnderIoRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileEnderIO.class, eior);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnderIo), eior);
ClientRegistry
.bindTileEntitySpecialRenderer(TileReservoir.class, new ReservoirRenderer(EnderIO.blockReservoir));
ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new TankFluidRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTank), new TankItemRenderer());
HyperCubeRenderer hcr = new HyperCubeRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileHyperCube.class, hcr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockHyperCube), hcr);
if (Config.transceiverEnabled) {
TransceiverRenderer tr = new TransceiverRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileTransceiver.class, tr);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTransceiver), tr);
}
new YetaWrenchOverlayRenderer();
new ConduitProbeOverlayRenderer();
if (Config.useSneakMouseWheelYetaWrench) {
ToolTickHandler th = new ToolTickHandler();
MinecraftForge.EVENT_BUS.register(th);
FMLCommonHandler.instance().bus().register(th);
}
MinecraftForge.EVENT_BUS.register(TravelController.instance);
FMLCommonHandler.instance().bus().register(TravelController.instance);
DarkSteelItems.registerItemRenderer();
FMLCommonHandler.instance().bus().register(KeyTracker.instance);
RenderingRegistry.registerEntityRenderingHandler(SoundEntity.class, new SoundRenderer());
RenderingRegistry.registerEntityRenderingHandler(RangeEntity.class, new RangeRenderer());
MinecraftForge.EVENT_BUS.register(SoundDetector.instance);
FMLCommonHandler.instance().bus().register(SoundDetector.instance);
if (!Loader.isModLoaded("OpenBlocks")) {
// We have registered liquid XP so we need to give it textures
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
@Override
public void registerIcons(IIconRegister register) {
// NB: textures re-used with permission from OpenBlocks to maintain look
IIcon flowing = register.registerIcon("enderio:xpjuiceflowing");
IIcon still = register.registerIcon("enderio:xpjuicestill");
EnderIO.fluidXpJuice.setIcons(still, flowing);
}
@Override
public int getTextureType() {
return 0;
}
});
}
MinecraftForge.EVENT_BUS.register(new TeleportEntityRenderHandler());
}
MinecraftForge.EVENT_BUS.register(new TeleportEntityRenderHandler());
}
@Override
public ConduitRenderer getRendererForConduit(IConduit conduit) {
for (ConduitRenderer renderer : conduitRenderers) {
if(renderer.isRendererForConduit(conduit)) {
return renderer;
}
@Override
public ConduitRenderer getRendererForConduit(IConduit conduit) {
return conduit.getRenderer();
}
return dcr;
}
@Override
public double getReachDistanceForPlayer(EntityPlayer entityPlayer) {
if(entityPlayer instanceof EntityPlayerMP) {
return ((EntityPlayerMP) entityPlayer).theItemInWorldManager.getBlockReachDistance();
@Override
public double getReachDistanceForPlayer(EntityPlayer entityPlayer) {
if (entityPlayer instanceof EntityPlayerMP) {
return ((EntityPlayerMP) entityPlayer).theItemInWorldManager.getBlockReachDistance();
}
return super.getReachDistanceForPlayer(entityPlayer);
}
return super.getReachDistanceForPlayer(entityPlayer);
}
@Override
public void setInstantConfusionOnPlayer(EntityPlayer ent, int duration) {
ent.addPotionEffect(new PotionEffect(Potion.confusion.getId(), duration, 1, true));
Minecraft.getMinecraft().thePlayer.timeInPortal = 1;
}
@Override
public long getTickCount() {
return clientTickCount;
}
@Override
protected void onClientTick() {
if(!Minecraft.getMinecraft().isGamePaused() && Minecraft.getMinecraft().theWorld != null) {
++clientTickCount;
@Override
public void setInstantConfusionOnPlayer(EntityPlayer ent, int duration) {
ent.addPotionEffect(new PotionEffect(Potion.confusion.getId(), duration, 1, true));
Minecraft.getMinecraft().thePlayer.timeInPortal = 1;
}
}
@Override
public long getTickCount() {
return clientTickCount;
}
@Override
protected void onClientTick() {
if (!Minecraft.getMinecraft().isGamePaused() && Minecraft.getMinecraft().theWorld != null) {
++clientTickCount;
}
}
}
@@ -1,87 +1,120 @@
package crazypants.enderio;
import java.text.DecimalFormat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.render.ConduitRenderer;
import crazypants.enderio.machine.hypercube.HyperCubeRegister;
import crazypants.enderio.machine.transceiver.ServerChannelRegister;
import crazypants.enderio.machine.wireless.WirelessChargerController;
public class CommonProxy {
private static final DecimalFormat FORMAT = new DecimalFormat("########0.000");
protected long serverTickCount = 0;
protected long clientTickCount = 0;
protected final TickTimer tickTimer = new TickTimer();
public ConduitNetworkTickHandler conduitNetworkTickHandler = null;
public WirelessChargerController wirelessChargerController = null;
protected long serverTickCount = 0;
protected long clientTickCount = 0;
protected final TickTimer tickTimer = new TickTimer();
public CommonProxy() {}
public CommonProxy() {
}
public World getClientWorld() {
return null;
}
public EntityPlayer getClientPlayer() {
return null;
}
public ConduitRenderer getRendererForConduit(IConduit conduit) {
return null;
}
public double getReachDistanceForPlayer(EntityPlayer entityPlayer) {
return 5;
}
public void loadIcons() {
;
}
public void load() {
FMLCommonHandler.instance().bus().register(tickTimer);
}
public long getTickCount() {
return serverTickCount;
}
public boolean isNeiInstalled() {
return false;
}
public void setInstantConfusionOnPlayer(EntityPlayer ent, int duration) {
ent.addPotionEffect(new PotionEffect(Potion.confusion.getId(), duration, 1, true));
}
protected void onServerTick() {
++serverTickCount;
}
protected void onClientTick() {
}
public final class TickTimer {
@SubscribeEvent
public void onTick(ServerTickEvent evt) {
if(evt.phase == Phase.END) {
onServerTick();
}
public World getClientWorld() {
return null;
}
@SubscribeEvent
public void onTick(ClientTickEvent evt) {
if(evt.phase == Phase.END) {
onClientTick();
}
public EntityPlayer getClientPlayer() {
return null;
}
@Deprecated
public ConduitRenderer getRendererForConduit(IConduit conduit) {
return null;
}
public double getReachDistanceForPlayer(EntityPlayer entityPlayer) {
return 5;
}
public void loadIcons() {
}
public void load() {
FMLCommonHandler.instance().bus().register(tickTimer);
}
public long getTickCount() {
return serverTickCount;
}
public boolean isNeiInstalled() {
return false;
}
public void setInstantConfusionOnPlayer(EntityPlayer ent, int duration) {
ent.addPotionEffect(new PotionEffect(Potion.confusion.getId(), duration, 1, true));
}
protected void onServerTick() {
++serverTickCount;
}
protected void onClientTick() {}
private static final String TEXTURE_PATH = ":textures/gui/23/";
private static final String TEXTURE_EXT = ".png";
public ResourceLocation getGuiTexture(String name) {
return new ResourceLocation(EnderIO.DOMAIN + TEXTURE_PATH + name + TEXTURE_EXT);
}
public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
conduitNetworkTickHandler = new ConduitNetworkTickHandler();
FMLCommonHandler.instance().bus().register(conduitNetworkTickHandler);
wirelessChargerController = new WirelessChargerController();
FMLCommonHandler.instance().bus().register(wirelessChargerController);
}
public void onServerStarted(FMLServerStartedEvent event) {
HyperCubeRegister.load();
ServerChannelRegister.load();
}
public void onServerStopped(FMLServerStoppedEvent event) {
HyperCubeRegister.unload();
FMLCommonHandler.instance().bus().unregister(conduitNetworkTickHandler);
conduitNetworkTickHandler = null;
FMLCommonHandler.instance().bus().unregister(wirelessChargerController);
wirelessChargerController = null;
}
public final class TickTimer {
@SubscribeEvent
public void onTick(ServerTickEvent evt) {
if (evt.phase == Phase.END) {
onServerTick();
}
}
@SubscribeEvent
public void onTick(ClientTickEvent evt) {
if (evt.phase == Phase.END) {
onClientTick();
}
}
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,36 +1,36 @@
package crazypants.enderio;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import static crazypants.enderio.EnderIO.MODID;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EnderIOTab extends CreativeTabs {
public static final CreativeTabs tabEnderIO = new EnderIOTab();
public static final CreativeTabs tabEnderIO = new EnderIOTab();
public EnderIOTab() {
super(MODID);
}
public EnderIOTab() {
super(MODID);
}
@Override
@SideOnly(Side.CLIENT)
public String getTabLabel() {
return MODID;
}
@Override
@SideOnly(Side.CLIENT)
public String getTabLabel() {
return MODID;
}
@Override
@SideOnly(Side.CLIENT)
public String getTranslatedTabLabel() {
return MODID;
}
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return EnderIO.itemEnderface;
}
@Override
@SideOnly(Side.CLIENT)
public String getTranslatedTabLabel() {
return MODID;
}
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return EnderIO.itemEnderface;
}
}
@@ -6,81 +6,81 @@ import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.network.IGuiHandler;
public class GuiHandler implements IGuiHandler {
public static final int GUI_ID_ENDERFACE = 1;
public static final int GUI_ID_PAINTER = 2;
public static final int GUI_ID_STIRLING_GEN = 3;
public static final int GUI_ID_ALLOY_SMELTER = 4;
public static final int GUI_ID_CAPACITOR_BANK = 5;
public static final int GUI_ID_CRUSHER = 6;
public static final int GUI_ID_HYPER_CUBE = 7;
public static final int GUI_ID_POWER_MONITOR = 8;
public static final int GUI_ID_ENDERFACE = 1;
public static final int GUI_ID_PAINTER = 2;
public static final int GUI_ID_STIRLING_GEN = 3;
public static final int GUI_ID_ALLOY_SMELTER = 4;
public static final int GUI_ID_CAPACITOR_BANK = 5;
public static final int GUI_ID_CRUSHER = 6;
public static final int GUI_ID_HYPER_CUBE = 7;
public static final int GUI_ID_POWER_MONITOR = 8;
public static final int GUI_ID_EXTERNAL_CONNECTION_BASE = 9;
public static final int GUI_ID_EXTERNAL_CONNECTION_UP = 9 + ForgeDirection.UP.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_DOWN = 9 + ForgeDirection.DOWN.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_NORTH = 9 + ForgeDirection.NORTH.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_SOUTH = 9 + ForgeDirection.SOUTH.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_EAST = 9 + ForgeDirection.EAST.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_WEST = 9 + ForgeDirection.WEST.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_SELECTOR = 16;
public static final int GUI_ID_EXTERNAL_CONNECTION_BASE = 9;
public static final int GUI_ID_EXTERNAL_CONNECTION_UP = 9 + ForgeDirection.UP.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_DOWN = 9 + ForgeDirection.DOWN.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_NORTH = 9 + ForgeDirection.NORTH.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_SOUTH = 9 + ForgeDirection.SOUTH.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_EAST = 9 + ForgeDirection.EAST.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_WEST = 9 + ForgeDirection.WEST.ordinal();
public static final int GUI_ID_EXTERNAL_CONNECTION_SELECTOR = 16;
public static final int GUI_ID_ME_ACCESS_TERMINAL = 17;
public static final int GUI_ID_ME_ACCESS_TERMINAL = 17;
public static final int GUI_ID_TRAVEL_ACCESSABLE = 18;
public static final int GUI_ID_TRAVEL_AUTH = 19;
public static final int GUI_ID_STILL = 20;
public static final int GUI_ID_COMBUSTION_GEN = 21;
public static final int GUI_ID_FARM_STATATION = 22;
public static final int GUI_ID_TANK = 86;
public static final int GUI_ID_CRAFTER = 87;
public static final int GUI_ID_ZOMBIE_GEN = 71;
public static final int GUI_ID_POWERED_SPAWNER = 88;
public static final int GUI_ID_VACUUM_CHEST = 89;
public static final int GUI_ID_WIRELESS_CHARGER = 90;
public static final int GUI_ID_ENCHANTER = 91;
public static final int GUI_ID_KILLER_JOE = 92;
public static final int GUI_ID_SOUL_BINDER = 93;
public static final int GUI_ID_SLICE_N_SPLICE = 94;
public static final int GUI_ID_ATTRACTOR = 95;
public static final int GUI_ID_SPAWN_GUARD = 96;
public static final int GUI_ID_TRANSCEIVER = 97;
public static final int GUI_ID_XP_OBELISK = 98;
public static final int GUI_ID_ANVIL = 99;
public static final int GUI_ID_BUFFER = 100;
public static final int GUI_ID_WEATHER_OBELISK = 101;
public static final int GUI_ID_TELEPAD = 102;
public static final int GUI_ID_TELEPAD_TRAVEL = 103;
public static final int GUI_ID_INHIBITOR = 104;
public static final int GUI_ID_INVENTORY_PANEL = 105;
public static final int GUI_ID_TRAVEL_ACCESSABLE = 18;
public static final int GUI_ID_TRAVEL_AUTH = 19;
public static final int GUI_ID_STILL = 20;
public static final int GUI_ID_COMBUSTION_GEN = 21;
public static final int GUI_ID_FARM_STATATION = 22;
public static final int GUI_ID_TANK = 86;
public static final int GUI_ID_CRAFTER = 87;
public static final int GUI_ID_ZOMBIE_GEN = 71;
public static final int GUI_ID_POWERED_SPAWNER = 88;
public static final int GUI_ID_VACUUM_CHEST = 89;
public static final int GUI_ID_WIRELESS_CHARGER = 90;
public static final int GUI_ID_ENCHANTER = 91;
public static final int GUI_ID_KILLER_JOE = 92;
public static final int GUI_ID_SOUL_BINDER = 93;
public static final int GUI_ID_SLICE_N_SPLICE = 94;
public static final int GUI_ID_ATTRACTOR = 95;
public static final int GUI_ID_SPAWN_GUARD = 96;
public static final int GUI_ID_TRANSCEIVER = 97;
public static final int GUI_ID_XP_OBELISK = 98;
public static final int GUI_ID_ANVIL = 99;
public static final int GUI_ID_BUFFER = 100;
public static final int GUI_ID_WEATHER_OBELISK = 101;
public static final int GUI_ID_TELEPAD = 102;
public static final int GUI_ID_TELEPAD_TRAVEL = 103;
public static final int GUI_ID_INHIBITOR = 104;
public static final int GUI_ID_INVENTORY_PANEL = 105;
public static final int GUI_ID_CAP_BANK = 142; // leave room for more machines
public static final int GUI_ID_CAP_BANK = 142; // leave room for more machines
protected final Map<Integer, IGuiHandler> guiHandlers = new HashMap<Integer, IGuiHandler>();
protected final Map<Integer, IGuiHandler> guiHandlers = new HashMap<>();
public void registerGuiHandler(int id, IGuiHandler handler) {
guiHandlers.put(id, handler);
}
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
IGuiHandler handler = guiHandlers.get(id);
if(handler != null) {
return handler.getServerGuiElement(id, player, world, x, y, z);
public void registerGuiHandler(int id, IGuiHandler handler) {
guiHandlers.put(id, handler);
}
return null;
}
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
IGuiHandler handler = guiHandlers.get(id);
if(handler != null) {
return handler.getClientGuiElement(id, player, world, x, y, z);
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
IGuiHandler handler = guiHandlers.get(id);
if (handler != null) {
return handler.getServerGuiElement(id, player, world, x, y, z);
}
return null;
}
return null;
}
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
IGuiHandler handler = guiHandlers.get(id);
if (handler != null) {
return handler.getClientGuiElement(id, player, world, x, y, z);
}
return null;
}
}
+17 -17
View File
@@ -2,29 +2,29 @@ package crazypants.enderio;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
public final class Log {
public static final Logger LOGGER = LogManager.getLogger(EnderIO.MODID);
public static final Logger LOGGER = LogManager.getLogger(EnderIO.MODID);
public static final Marker securityMarker = MarkerManager.getMarker("SuspiciousPackets");
public static void warn(String msg) {
LOGGER.warn(msg);
}
public static void warn(String msg) {
LOGGER.warn(msg);
}
public static void error(String msg) {
LOGGER.error(msg);
}
public static void error(String msg) {
LOGGER.error(msg);
}
public static void info(String msg) {
LOGGER.info(msg);
}
public static void info(String msg) {
LOGGER.info(msg);
}
public static void debug(String msg) {
LOGGER.debug(msg);
}
private Log() {
}
public static void debug(String msg) {
LOGGER.debug(msg);
}
private Log() {}
}
+112 -110
View File
@@ -1,131 +1,133 @@
package crazypants.enderio;
public enum ModObject {
// Enderface
blockEnderIo,
itemEnderface,
// Conduits
blockConduitBundle,
blockConduitFacade,
itemConduitFacade,
itemRedstoneConduit,
itemItemConduit,
itemGasConduit,
itemMEConduit,
itemOCConduit,
itemBasicFilterUpgrade,
itemBigFilterUpgrade,
itemExistingItemFilter,
itemModItemFilter,
itemPowerItemFilter,
itemExtractSpeedUpgrade,
itemFunctionUpgrade,
// Enderface
blockEnderIo,
itemEnderface,
// Power
itemPowerConduit,
itemPowerConduitEndergy,
// Conduits
blockConduitBundle,
blockConduitFacade,
itemConduitFacade,
itemRedstoneConduit,
itemItemConduit,
itemGasConduit,
itemMEConduit,
itemOCConduit,
itemBasicFilterUpgrade,
itemBigFilterUpgrade,
itemExistingItemFilter,
itemLimitedItemFilter,
itemModItemFilter,
itemPowerItemFilter,
itemExtractSpeedUpgrade,
itemFunctionUpgrade,
// Liquid
itemLiquidConduit,
// Power
itemPowerConduit,
itemPowerConduitEndergy,
// Materials
itemBasicCapacitor,
itemAlloy,
itemAlloyEndergy,
itemGrindingBall,
itemGrindingBallEndergy,
itemMaterial,
itemMachinePart,
itemPowderIngot,
blockFusedQuartz,
itemFusedQuartzFrame,
blockDarkIronBars,
blockSoulariumBars,
blockEndSteelBars,
// Liquid
itemLiquidConduit,
// Machines
blockStirlingGenerator,
blockCombustionGenerator,
blockZombieGenerator,
blockFrankenzombieGenerator,
blockEnderGenerator,
blockReservoir,
blockAlloySmelter,
blockSolarPanel,
blockCapacitorBank,
blockCapBank,
blockSagMill,
blockHyperCube,
blockPowerMonitor,
blockVat,
blockFarmStation,
blockTank,
blockCrafter,
blockVacuumChest,
blockWirelessCharger,
blockEnchanter,
blockSoulBinder,
blockSliceAndSplice,
blockAttractor,
blockSpawnGuard,
blockExperienceObelisk,
blockWeatherObelisk,
blockInhibitorObelisk,
blockTransceiver,
blockBuffer,
blockInventoryPanel,
// Materials
itemBasicCapacitor,
itemAlloy,
itemAlloyEndergy,
itemGrindingBall,
itemGrindingBallEndergy,
itemMaterial,
itemMachinePart,
itemPowderIngot,
blockFusedQuartz,
itemFusedQuartzFrame,
blockDarkIronBars,
blockSoulariumBars,
blockEndSteelBars,
blockPoweredSpawner,
itemBrokenSpawner,
// Machines
blockStirlingGenerator,
blockCombustionGenerator,
blockZombieGenerator,
blockFrankenzombieGenerator,
blockEnderGenerator,
blockReservoir,
blockAlloySmelter,
blockSolarPanel,
blockCapBank,
blockSagMill,
blockHyperCube,
blockPowerMonitor,
blockVat,
blockFarmStation,
blockTank,
blockCrafter,
blockVacuumChest,
blockWirelessCharger,
blockEnchanter,
blockSoulBinder,
blockSliceAndSplice,
blockAttractor,
blockSpawnGuard,
blockExperienceObelisk,
blockWeatherObelisk,
blockInhibitorObelisk,
blockTransceiver,
blockBuffer,
blockInventoryPanel,
blockKillerJoe,
blockPoweredSpawner,
itemBrokenSpawner,
blockElectricLight,
blockLightNode,
blockLight,
blockKillerJoe,
//Blocks
blockDarkSteelPressurePlate,
blockDarkSteelAnvil,
blockDarkSteelLadder,
blockReinforcedObsidian,
blockIngotStorage,
blockIngotStorageEndergy,
blockElectricLight,
blockLightNode,
blockLight,
// Painter
blockPainter,
blockPaintedFence,
blockPaintedFenceGate,
blockPaintedWall,
blockPaintedStair,
blockPaintedSlab,
blockPaintedDoubleSlab,
blockPaintedGlowstone,
blockPaintedCarpet,
// Blocks
blockDarkSteelPressurePlate,
blockDarkSteelAnvil,
blockDarkSteelLadder,
blockReinforcedObsidian,
blockIngotStorage,
blockIngotStorageEndergy,
itemConduitProbe,
itemYetaWrench,
itemXpTransfer,
// Painter
blockPainter,
blockPaintedFence,
blockPaintedFenceGate,
blockPaintedWall,
blockPaintedStair,
blockPaintedSlab,
blockPaintedDoubleSlab,
blockPaintedGlowstone,
blockPaintedCarpet,
blockTravelAnchor,
blockTelePad,
itemCoordSelector,
itemTravelStaff,
itemMagnet,
itemGliderWing,
blockEndermanSkull,
itemSoulVessel,
itemFrankenSkull,
itemConduitProbe,
itemYetaWrench,
itemXpTransfer,
blockEnderRail,
blockTravelAnchor,
blockTelePad,
itemCoordSelector,
itemTravelStaff,
itemMagnet,
itemGliderWing,
blockEndermanSkull,
itemSoulVessel,
itemFrankenSkull,
itemEnderFood;
blockEnderRail,
public final String unlocalisedName;
itemEnderFood,
private ModObject() {
unlocalisedName = name();
}
itemTeleportStaff;
public final String unlocalisedName;
private ModObject() {
unlocalisedName = name();
}
}
@@ -3,5 +3,5 @@ package crazypants.enderio;
import com.enderio.core.common.TileEntityEnder;
public abstract class TileEntityEio extends TileEntityEnder {
// Nothing yet ;D
// Nothing yet ;D
}
@@ -1,9 +1,8 @@
package crazypants.enderio.api;
public final class EnderIOAPIProps {
private EnderIOAPIProps() {}
public static final String VERSION = "0.0.2";
private EnderIOAPIProps() {}
public static final String VERSION = "0.0.2";
}
+83 -102
View File
@@ -14,124 +14,105 @@ import crazypants.enderio.machine.vat.VatRecipeManager;
import crazypants.enderio.teleport.TravelController;
/**
* This class provides the keys for the IMC messages supported by EIO and links
* the the details of how the messages are processed. It is preferable not to
* refer to these constants directly to avoid a dependence on this class.
* This class provides the keys for the IMC messages supported by EIO and links the the details of how the messages are
* processed. It is preferable not to refer to these constants directly to avoid a dependence on this class.
*/
public final class IMC {
/**
* Key for a string message to add Vat recipes. Calls
* {@link VatRecipeManager#addCustomRecipes(String)} with the string value of
* the message.
*/
public static final String VAT_RECIPE = "recipe:vat";
/**
* Key for a string message to add Vat recipes. Calls {@link VatRecipeManager#addCustomRecipes(String)} with the
* string value of the message.
*/
public static final String VAT_RECIPE = "recipe:vat";
/**
* Key for a string message to add SAGMill recipes. Calls
* {@link CrusherRecipeManager#addCustomRecipes(String)} with the string value
* of the message.
*/
public static final String SAG_RECIPE = "recipe:sagmill";
/**
* Key for a string message to add SAGMill recipes. Calls {@link CrusherRecipeManager#addCustomRecipes(String)} with
* the string value of the message.
*/
public static final String SAG_RECIPE = "recipe:sagmill";
/**
* Key for a string message to add Alloy Smelter recipes. Calls
* {@link AlloyRecipeManager#addCustomRecipes(String)} with the string value
* of the message.
*/
public static final String ALLOY_RECIPE = "recipe:alloysmelter";
/**
* Key for a string message to add Alloy Smelter recipes. Calls {@link AlloyRecipeManager#addCustomRecipes(String)}
* with the string value of the message.
*/
public static final String ALLOY_RECIPE = "recipe:alloysmelter";
/**
* Key for a string message to add Enchanter recipes. Calls
* {@link EnchanterRecipeManager#addCustomRecipes(String)} with the string
* value of the message. The supplied xml is treated as if it was loaded from
* EnchanterRecipes_User.xm.
*/
public static final String ENCHANTER_RECIPE = "recipe:enchanter";
/**
* Key for a string message to add Enchanter recipes. Calls {@link EnchanterRecipeManager#addCustomRecipes(String)}
* with the string value of the message. The supplied xml is treated as if it was loaded from
* EnchanterRecipes_User.xm.
*/
public static final String ENCHANTER_RECIPE = "recipe:enchanter";
/**
* Key for a string message to add Slice'N'Splice recipes. Calls
* {@link SliceAndSpliceRecipeManager#addCustomRecipes(String)} with the
* string value of the message.
*/
public static final String SLINE_N_SPLICE_RECIPE = "recipe:slicensplice";
/**
* Key for a string message to add Slice'N'Splice recipes. Calls
* {@link SliceAndSpliceRecipeManager#addCustomRecipes(String)} with the string value of the message.
*/
public static final String SLINE_N_SPLICE_RECIPE = "recipe:slicensplice";
/**
* Key for an NBT message to add Soul Binder recipes. Calls
* {@link SoulBinderRecipeManager#addRecipeFromNBT(net.minecraft.nbt.NBTTagCompound)}
* with the NBT value of the message.
*/
public static final String SOUL_BINDER_RECIPE = "recipe:soulbinder";
/**
* Key for an NBT message to add Soul Binder recipes. Calls
* {@link SoulBinderRecipeManager#addRecipeFromNBT(net.minecraft.nbt.NBTTagCompound)} with the NBT value of the
* message.
*/
public static final String SOUL_BINDER_RECIPE = "recipe:soulbinder";
/**
* Key for an ItemStack message to add an item to the Painters paint source
* whitelist. Calls
* {@link PaintSourceValidator#addToWhitelist(net.minecraft.item.ItemStack)}
*/
public static final String PAINTER_WHITELIST_ADD = "painter:whitelist:add";
/**
* Key for an ItemStack message to add an item to the Painters paint source whitelist. Calls
* {@link PaintSourceValidator#addToWhitelist(net.minecraft.item.ItemStack)}
*/
public static final String PAINTER_WHITELIST_ADD = "painter:whitelist:add";
/**
* Key for an ItemStack message to add an item to the Painters paint source
* blacklist. Calls
* {@link PaintSourceValidator#addToBlacklist(net.minecraft.item.ItemStack)}
*/
public static final String PAINTER_BLACKLIST_ADD = "painter:blacklist:add";
/**
* Key for an ItemStack message to add an item to the Painters paint source blacklist. Calls
* {@link PaintSourceValidator#addToBlacklist(net.minecraft.item.ItemStack)}
*/
public static final String PAINTER_BLACKLIST_ADD = "painter:blacklist:add";
/**
* Key for a string message to add an entity to the Powered Spawner blacklist.
* Calls {@link PoweredSpawnerConfig#addToBlacklist(String)} with the string
* value of the message.
*/
public static final String POWERED_SPAWNER_BLACKLIST_ADD = "poweredSpawner:blacklist:add";
/**
* Key for a string message to add an entity to the Powered Spawner blacklist. Calls
* {@link PoweredSpawnerConfig#addToBlacklist(String)} with the string value of the message.
*/
public static final String POWERED_SPAWNER_BLACKLIST_ADD = "poweredSpawner:blacklist:add";
/**
* Key for an NBT message to specify a cost multiplier for spawning an entity
* in the Powered Spawner. Calls
* {@link PoweredSpawnerConfig#addEntityCostFromNBT(net.minecraft.nbt.NBTTagCompound)}
* with the NBT value of the message.
*/
public static final String POWERED_SPAWNER_COST_MULTIPLIER = "poweredSpawner:costMultiplier";
/**
* Key for an NBT message to specify a cost multiplier for spawning an entity in the Powered Spawner. Calls
* {@link PoweredSpawnerConfig#addEntityCostFromNBT(net.minecraft.nbt.NBTTagCompound)} with the NBT value of the
* message.
*/
public static final String POWERED_SPAWNER_COST_MULTIPLIER = "poweredSpawner:costMultiplier";
/**
* Key for a string message to add an entity to the Soul Vial blacklist. Calls
* {@link ItemSoulVessel#addEntityToBlackList(String)} with the string value
* of the message.
*/
public static final String SOUL_VIAL_BLACKLIST = "soulVial:blacklist:add";
/**
* Key for a string message to add an entity to the Soul Vial blacklist. Calls
* {@link ItemSoulVessel#addEntityToBlackList(String)} with the string value of the message.
*/
public static final String SOUL_VIAL_BLACKLIST = "soulVial:blacklist:add";
/**
* Key for an NBT message to register a fluid fuel. Calls
* {@link FluidFuelRegister#addFuel(net.minecraft.nbt.NBTTagCompound)} with
* the NBT value of the message.
*/
public static final String FLUID_FUEL_ADD = "fluidFuel:add";
/**
* Key for an NBT message to register a fluid fuel. Calls
* {@link FluidFuelRegister#addFuel(net.minecraft.nbt.NBTTagCompound)} with the NBT value of the message.
*/
public static final String FLUID_FUEL_ADD = "fluidFuel:add";
/**
* Key for an NBT message to register a fluid coolant. Calls
* {@link FluidFuelRegister#addCoolant(net.minecraft.nbt.NBTTagCompound)} with
* the NBT value of the message.
*/
public static final String FLUID_COOLANT_ADD = "fluidCoolant:add";
/**
* Key for an NBT message to register a fluid coolant. Calls
* {@link FluidFuelRegister#addCoolant(net.minecraft.nbt.NBTTagCompound)} with the NBT value of the message.
*/
public static final String FLUID_COOLANT_ADD = "fluidCoolant:add";
/**
* Key for a string message to add a block to the list of blocks that cannot
* be teleported through using the Staff of Travel or Dark Steel Travel
* Upgrade. Value must be in the form: 'modid:blockName' Calls
* {@link TravelController#addBlockToBlinkBlackList(String)} with the string
* value of the message.
*/
public static final String TELEPORT_BLACKLIST_ADD = "teleport:blacklist:add";
/**
* Key for a string message to add a block to the list of blocks that cannot be teleported through using the Staff
* of Travel or Dark Steel Travel Upgrade. Value must be in the form: 'modid:blockName' Calls
* {@link TravelController#addBlockToBlinkBlackList(String)} with the string value of the message.
*/
public static final String TELEPORT_BLACKLIST_ADD = "teleport:blacklist:add";
/**
* Key for an NBT message to register a block or tile entity as connectable to
* insulated redstone conduits. Calls
* {@link InsulatedRedstoneConduit#addConnectableBlock(net.minecraft.nbt.NBTTagCompound)}
* with the NBT value of the message.
*/
public static final String REDSTONE_CONNECTABLE_ADD = "redstone:connectable:add";
private IMC() {
}
/**
* Key for an NBT message to register a block or tile entity as connectable to insulated redstone conduits. Calls
* {@link InsulatedRedstoneConduit#addConnectableBlock(net.minecraft.nbt.NBTTagCompound)} with the NBT value of the
* message.
*/
public static final String REDSTONE_CONNECTABLE_ADD = "redstone:connectable:add";
private IMC() {}
}
@@ -2,4 +2,3 @@
package crazypants.enderio.api;
import cpw.mods.fml.common.API;
@@ -4,13 +4,12 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this on your Block or TileEntity to control whether insulated
* restone conduits will automatically connect to your block.
* Implement this on your Block or TileEntity to control whether insulated restone conduits will automatically connect
* to your block.
* <p>
* Implementing on both is not recommended and will likely not work as expected.
*/
public interface IRedstoneConnectable {
boolean shouldRedstoneConduitConnect(World world, int x, int y, int z, ForgeDirection from);
boolean shouldRedstoneConduitConnect(World world, int x, int y, int z, ForgeDirection from);
}
@@ -3,4 +3,3 @@ package crazypants.enderio.api.redstone;
import cpw.mods.fml.common.API;
import crazypants.enderio.api.EnderIOAPIProps;
@@ -2,12 +2,22 @@ package crazypants.enderio.api.teleport;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import cofh.api.energy.IEnergyContainerItem;
import crazypants.enderio.config.Config;
public interface IItemOfTravel extends IEnergyContainerItem {
boolean isActive(EntityPlayer ep, ItemStack equipped);
boolean isActive(EntityPlayer ep, ItemStack equipped);
void extractInternal(ItemStack equipped, int power);
void extractInternal(ItemStack equipped, int power);
/**
* @param equipped player who is currently holding this item. caller will ensure the item held has your Item as item
* type
* @return -1 if method not supported, or max(can extract, power), e.g. 0 if item is empty.
*/
default int canExtractInternal(ItemStack equipped, int power) {
return Config.strictTPItemChecking ? 0 : -1;
}
}
@@ -3,134 +3,117 @@ package crazypants.enderio.api.teleport;
import javax.annotation.Nullable;
import net.minecraft.entity.Entity;
import com.enderio.core.common.util.BlockCoord;
public interface ITelePad extends ITravelAccessable {
/**
* If this piece of the telepad is the master, meaning it is connected on all
* 4 sides. This does <i>not</i> guarantee that it is in a connected state.
*
* @return True if this TE is the master TE, false otherwise.
*/
boolean isMaster();
/**
* If this piece of the telepad is the master, meaning it is connected on all 4 sides. This does <i>not</i>
* guarantee that it is in a connected state.
*
* @return True if this TE is the master TE, false otherwise.
*/
boolean isMaster();
/**
* Gets the master telepad that this one is connected to.
*
* @return The master telepad TE. {@code null} if not in a network. Itself if
* it is the master.
*/
@Nullable
ITelePad getMaster();
/**
* Gets the master telepad that this one is connected to.
*
* @return The master telepad TE. {@code null} if not in a network. Itself if it is the master.
*/
@Nullable
ITelePad getMaster();
/**
* If this telepad piece is in a network, meaning it is connected and in a
* valid configuration.
*
* @return True if this TE is in a network, false otherwise.
*/
boolean inNetwork();
/**
* If this telepad piece is in a network, meaning it is connected and in a valid configuration.
*
* @return True if this TE is in a network, false otherwise.
*/
boolean inNetwork();
/**
* The X coordinate stored in this telepad network. Always 0 if this is
* {@link #inNetwork()} returns false.
*
* @return The target X coordinate.
*/
int getX();
/**
* The X coordinate stored in this telepad network. Always 0 if this is {@link #inNetwork()} returns false.
*
* @return The target X coordinate.
*/
int getX();
/**
* The Y coordinate stored in this telepad network. Always 0 if this is
* {@link #inNetwork()} returns false.
*
* @return The target Y coordinate.
*/
int getY();
/**
* The Y coordinate stored in this telepad network. Always 0 if this is {@link #inNetwork()} returns false.
*
* @return The target Y coordinate.
*/
int getY();
/**
* The Z coordinate stored in this telepad network. Always 0 if this is
* {@link #inNetwork()} returns false.
*
* @return The target Z coordinate.
*/
int getZ();
/**
* The Z coordinate stored in this telepad network. Always 0 if this is {@link #inNetwork()} returns false.
*
* @return The target Z coordinate.
*/
int getZ();
/**
* The target dimension ID for the telepad. Defaults to the dimension the
* block is placed in.
*
* @return An int dimension ID.
*/
int getTargetDim();
/**
* The target dimension ID for the telepad. Defaults to the dimension the block is placed in.
*
* @return An int dimension ID.
*/
int getTargetDim();
/**
* Sets the target X coordinate of the network. Has no effect if
* {@link #inNetwork()} returns false.
*
* @param x
* The X coord.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setX(int x);
/**
* Sets the target X coordinate of the network. Has no effect if {@link #inNetwork()} returns false.
*
* @param x The X coord.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setX(int x);
/**
* Sets the target Y coordinate of the network. Has no effect if
* {@link #inNetwork()} returns false.
*
* @param y
* The Y coord.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setY(int y);
/**
* Sets the target Y coordinate of the network. Has no effect if {@link #inNetwork()} returns false.
*
* @param y The Y coord.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setY(int y);
/**
* Sets the target Z coordinate of the network. Has no effect if
* {@link #inNetwork()} returns false.
*
* @param z
* The Z coord.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setZ(int z);
/**
* Sets the target Z coordinate of the network. Has no effect if {@link #inNetwork()} returns false.
*
* @param z The Z coord.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setZ(int z);
/**
* Sets the target dimension of the network. Has no effect if
* {@link #inNetwork()} returns false.
*
* @param dimID
* The dimension ID.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setTargetDim(int dimID);
/**
* Sets the target dimension of the network. Has no effect if {@link #inNetwork()} returns false.
*
* @param dimID The dimension ID.
* @return The master telepad TE. DOES NOT ALWAYS return itself.
*/
ITelePad setTargetDim(int dimID);
/**
* Util method to set all coords using a {@link BlockCoord} object.
*
* @see #setX(int)
* @see #setY(int)
* @see #setZ(int)
*
* @param coords
* The coords to set this telepad to.
*/
void setCoords(BlockCoord coords);
/**
* Util method to set all coords using a {@link BlockCoord} object.
*
* @param coords The coords to set this telepad to.
* @see #setX(int)
* @see #setY(int)
* @see #setZ(int)
*/
void setCoords(BlockCoord coords);
/**
* Teleports a specific entity to the destination if:
* <ul>
* <li>The entity is in range (standing on top)</li>
* <li>There is sufficient power to perform the operation</li>
* </ul>
*
* @param entity
* The entity to teleport
*/
void teleportSpecific(Entity entity);
/**
* Teleports a specific entity to the destination if:
* <ul>
* <li>The entity is in range (standing on top)</li>
* <li>There is sufficient power to perform the operation</li>
* </ul>
*
* @param entity The entity to teleport
*/
void teleportSpecific(Entity entity);
/**
* Teleports all entities in range (in no particular order) until either there
* are none left or the power runs out.
*/
void teleportAll();
/**
* Teleports all entities in range (in no particular order) until either there are none left or the power runs out.
*/
void teleportAll();
}
@@ -13,48 +13,60 @@ import crazypants.util.UserIdent;
public interface ITravelAccessable {
public enum AccessMode {
PUBLIC,
PRIVATE,
PROTECTED
}
enum AccessMode {
PUBLIC,
PRIVATE,
PROTECTED
}
boolean canBlockBeAccessed(EntityPlayer playerName);
boolean canBlockBeAccessed(EntityPlayer playerName);
boolean canSeeBlock(EntityPlayer playerName);
boolean canSeeBlock(EntityPlayer playerName);
boolean canUiBeAccessed(EntityPlayer username);
boolean canUiBeAccessed(EntityPlayer username);
boolean getRequiresPassword(EntityPlayer username);
boolean getRequiresPassword(EntityPlayer username);
boolean authoriseUser(EntityPlayer username, ItemStack[] password);
boolean authoriseUser(EntityPlayer username, ItemStack[] password);
AccessMode getAccessMode();
AccessMode getAccessMode();
void setAccessMode(AccessMode accessMode);
void setAccessMode(AccessMode accessMode);
ItemStack[] getPassword();
ItemStack[] getPassword();
void setPassword(ItemStack[] password);
ItemStack getItemLabel();
void setItemLabel(ItemStack lableIcon);
String getLabel();
void setLabel(String label);
void setPassword(ItemStack[] password);
@Deprecated
UUID getPlacedBy();
ItemStack getItemLabel();
@Nonnull
UserIdent getOwner();
void setItemLabel(ItemStack lableIcon);
void setPlacedBy(EntityPlayer player);
String getLabel();
public void clearAuthorisedUsers();
void setLabel(String label);
public BlockCoord getLocation();
@Deprecated
UUID getPlacedBy();
@Nonnull
UserIdent getOwner();
void setPlacedBy(EntityPlayer player);
void clearAuthorisedUsers();
BlockCoord getLocation();
/**
* Is this block a travel target for the staff or a travel anchor?
*/
default boolean isTravelSource() {
return true;
}
default boolean isVisible() {
return true;
}
default void setVisible(boolean visible) {}
}
@@ -2,6 +2,7 @@ package crazypants.enderio.api.teleport;
import net.minecraft.entity.Entity;
import net.minecraftforge.event.entity.EntityEvent;
import cpw.mods.fml.common.eventhandler.Cancelable;
/**
@@ -13,38 +14,32 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
* <li>Staff of travelling</li>
* <li>Telepad</li>
* </ul>
*
* As well as any externally added teleports, assuming they fire this event
* manually.
*
* <p>
* As well as any externally added teleports, assuming they fire this event manually.
*/
@Cancelable
public class TeleportEntityEvent extends EntityEvent {
/**
* The target coords. These can be edited by event handlers.
*/
public int targetX, targetY, targetZ;
/**
* The target coords. These can be edited by event handlers.
*/
public int targetX, targetY, targetZ;
public final TravelSource source;
public final TravelSource source;
/**
* Fired before an entity teleports to the given location.
*
* @param entity
* The entity teleporting
* @param x
* The target X coord
* @param y
* The target Y coord
* @param z
* The target Z coord
*/
public TeleportEntityEvent(Entity entity, TravelSource source, int x, int y, int z) {
super(entity);
this.targetX = x;
this.targetY = y;
this.targetZ = z;
this.source = source;
}
/**
* Fired before an entity teleports to the given location.
*
* @param entity The entity teleporting
* @param x The target X coord
* @param y The target Y coord
* @param z The target Z coord
*/
public TeleportEntityEvent(Entity entity, TravelSource source, int x, int y, int z) {
super(entity);
this.targetX = x;
this.targetY = y;
this.targetZ = z;
this.source = source;
}
}
@@ -1,72 +1,117 @@
package crazypants.enderio.api.teleport;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.config.Config;
import crazypants.enderio.teleport.TravelController;
public enum TravelSource {
BLOCK() {
@Override
public int getMaxDistanceTravelled() {
return Config.travelAnchorMaxDistance;
}
},
STAFF() {
@Override
public int getMaxDistanceTravelled() {
return Config.travelStaffMaxDistance;
BLOCK() {
@Override
public int getMaxDistanceTravelled() {
return Config.travelAnchorMaxDistance;
}
},
STAFF() {
@Override
public int getMaxDistanceTravelled() {
return Config.travelStaffMaxDistance;
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return Config.travelStaffPowerPerBlockRF;
}
},
STAFF_BLINK() {
@Override
public int getMaxDistanceTravelled() {
return Config.travelStaffMaxBlinkDistance;
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return Config.travelStaffPowerPerBlockRF;
}
},
TELEPORT_STAFF() {
@Override
public int getMaxDistanceTravelled() {
return Config.teleportStaffMaxDistance;
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return 0f;
}
},
TELEPORT_STAFF_BLINK() {
@Override
public int getMaxDistanceTravelled() {
return Config.teleportStaffMaxBlinkDistance;
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return 0f;
}
},
TELEPAD(EnderIO.DOMAIN + ":telepad.teleport");
public static int getMaxDistance() {
return STAFF.getMaxDistanceTravelledSq();
}
@SideOnly(Side.CLIENT)
public static int getMaxDistanceSq() {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player == null) {
return 0;
}
TravelSource source = TravelController.instance.getTravelItemTravelSource(player, false);
if (source == null) {
return TravelSource.BLOCK.getMaxDistanceTravelledSq();
} else {
return source.getMaxDistanceTravelledSq();
}
}
public final String sound;
private TravelSource() {
this("mob.endermen.portal");
}
private TravelSource(String sound) {
this.sound = sound;
}
public boolean getConserveMomentum() {
return this == STAFF_BLINK;
}
public int getMaxDistanceTravelled() {
return 0;
}
public int getMaxDistanceTravelledSq() {
return getMaxDistanceTravelled() * getMaxDistanceTravelled();
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return Config.travelStaffPowerPerBlockRF;
return 0;
}
},
STAFF_BLINK() {
@Override
public int getMaxDistanceTravelled() {
return Config.travelStaffMaxBlinkDistance;
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return Config.travelStaffPowerPerBlockRF;
}
},
TELEPAD(EnderIO.DOMAIN + ":telepad.teleport");
public static int getMaxDistance() {
return STAFF.getMaxDistanceTravelledSq();
}
public static int getMaxDistanceSq() {
return STAFF.getMaxDistanceTravelledSq();
}
public final String sound;
private TravelSource() {
this("mob.endermen.portal");
}
private TravelSource(String sound) {
this.sound = sound;
}
public boolean getConserveMomentum() {
return this == STAFF_BLINK;
}
public int getMaxDistanceTravelled() {
return 0;
}
public int getMaxDistanceTravelledSq() {
return getMaxDistanceTravelled() * getMaxDistanceTravelled();
}
public float getPowerCostPerBlockTraveledRF() {
return 0;
}
}
}
@@ -3,4 +3,3 @@ package crazypants.enderio.api.teleport;
import cpw.mods.fml.common.API;
import crazypants.enderio.api.EnderIOAPIProps;
@@ -8,16 +8,12 @@ import net.minecraft.item.ItemStack;
*/
public interface IConduitControl extends IHideFacades {
/**
* Controls whether the overlay is shown and the player can change the display
* mode.
*
* @param stack
* The itemstack
* @param player
* The player holding the itemstack
* @return True if the overlay should be rendered and the player should be
* able to change modes. False otherwise.
*/
boolean showOverlay(ItemStack stack, EntityPlayer player);
/**
* Controls whether the overlay is shown and the player can change the display mode.
*
* @param stack The itemstack
* @param player The player holding the itemstack
* @return True if the overlay should be rendered and the player should be able to change modes. False otherwise.
*/
boolean showOverlay(ItemStack stack, EntityPlayer player);
}
@@ -4,7 +4,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IHideFacades {
boolean shouldHideFacades(ItemStack stack, EntityPlayer player);
boolean shouldHideFacades(ItemStack stack, EntityPlayer player);
}
@@ -3,11 +3,9 @@ package crazypants.enderio.api.tool;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface ITool extends IHideFacades {
boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z);
void used(ItemStack stack, EntityPlayer player, int x, int y, int z);
boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z);
void used(ItemStack stack, EntityPlayer player, int x, int y, int z);
}
@@ -3,4 +3,3 @@ package crazypants.enderio.api.tool;
import cpw.mods.fml.common.API;
import crazypants.enderio.api.EnderIOAPIProps;
@@ -0,0 +1,101 @@
package crazypants.enderio.betterbuilderswands;
import java.util.function.BiFunction;
import java.util.function.IntFunction;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import com.github.bsideup.jabel.Desugar;
import crazypants.enderio.EnderIO;
import crazypants.enderio.machine.painter.BlockPaintedCarpet;
import crazypants.enderio.machine.painter.BlockPaintedFence;
import crazypants.enderio.machine.painter.BlockPaintedFenceGate;
import crazypants.enderio.machine.painter.BlockPaintedGlowstone;
import crazypants.enderio.machine.painter.BlockPaintedSlab;
import crazypants.enderio.machine.painter.BlockPaintedStair;
import crazypants.enderio.machine.painter.BlockPaintedWall;
import crazypants.enderio.machine.painter.TileEntityPaintedBlock;
import portablejim.bbw.BetterBuildersWandsMod;
import portablejim.bbw.basics.Point3d;
import portablejim.bbw.core.conversion.ICustomMapping;
import portablejim.bbw.shims.IPlayerShim;
import portablejim.bbw.shims.IWorldShim;
@Desugar
public record PaintedCustomMapping(Block lookBlock, BiFunction<Block, Integer, ItemStack> itemStackGetter, int meta)
implements ICustomMapping {
@Override
public Block getLookBlock() {
return lookBlock;
}
@Override
public int getMeta() {
return meta;
}
@Override
public ItemStack getItems(IWorldShim world, IPlayerShim player, Point3d point) {
if (world.getTile(point) instanceof TileEntityPaintedBlock painted) {
return itemStackGetter.apply(painted.getSourceBlock(), painted.getSourceBlockMetadata());
}
return null;
}
@Override
public boolean shouldCopyTileNBT() {
return true;
}
public static void registerMappings() {
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedGlowstone,
BlockPaintedGlowstone::createItemStackForSourceBlock,
i));
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedStair,
BlockPaintedStair::createItemStackForSourceBlock,
i));
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedFence,
BlockPaintedFence::createItemStackForSourceBlock,
i));
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedFenceGate,
BlockPaintedFenceGate::createItemStackForSourceBlock,
i));
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedCarpet,
BlockPaintedCarpet::createItemStackForSourceBlock,
i));
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedSlab,
BlockPaintedSlab::createItemStackForSourceBlock,
i));
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedWall,
BlockPaintedWall::createItemStackForSourceBlock,
i));
register(
i -> new PaintedCustomMapping(
EnderIO.blockPaintedDoubleSlab,
BlockPaintedSlab::createItemStackForSourceBlock,
i));
}
private static void register(IntFunction<ICustomMapping> mapping) {
for (int i = 0; i < 16; i++) {
BetterBuildersWandsMod.instance.mappingManager.setMapping(mapping.apply(i));
}
}
}
@@ -1,7 +1,5 @@
package crazypants.enderio.block;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import net.minecraft.block.BlockAnvil;
import net.minecraft.client.gui.GuiRepair;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -11,6 +9,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -22,83 +23,78 @@ import crazypants.enderio.ModObject;
public class BlockDarkSteelAnvil extends BlockAnvil implements IResourceTooltipProvider {
private static final String[] anvilIconNames = new String[] { "anvil_0", "anvil_1", "anvil_2" };
private static final String[] anvilIconNames = new String[] { "anvil_0", "anvil_1", "anvil_2" };
@SideOnly(Side.CLIENT)
private IIcon[] anvilIcons;
@SideOnly(Side.CLIENT)
private IIcon[] anvilIcons;
public static BlockDarkSteelAnvil create() {
BlockDarkSteelAnvil res = new BlockDarkSteelAnvil();
res.init();
return res;
}
private BlockDarkSteelAnvil() {
super();
setHardness(5.0F);
setStepSound(soundTypeAnvil);
setResistance(2000.0F);
setBlockName(ModObject.blockDarkSteelAnvil.unlocalisedName);
setCreativeTab(EnderIOTab.tabEnderIO);
}
protected void init() {
GameRegistry.registerBlock(this, ItemAnvilBlock.class, ModObject.blockDarkSteelAnvil.unlocalisedName);
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_ANVIL, new IGuiHandler() {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerDarkSteelAnvil(player.inventory, world, x, y, z, player);
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GuiRepair(player.inventory, world, x, y, z);
}
});
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return this.getUnlocalizedName();
}
@Override
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ) {
p.openGui(EnderIO.instance, GuiHandler.GUI_ID_ANVIL, w, x, y, z);
return true;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
{
if(this.anvilRenderSide == 3 && p_149691_1_ == 1)
{
int k = (p_149691_2_ >> 2) % this.anvilIcons.length;
return this.anvilIcons[k];
public static BlockDarkSteelAnvil create() {
BlockDarkSteelAnvil res = new BlockDarkSteelAnvil();
res.init();
return res;
}
else
{
return this.blockIcon;
private BlockDarkSteelAnvil() {
super();
setHardness(5.0F);
setStepSound(soundTypeAnvil);
setResistance(2000.0F);
setBlockName(ModObject.blockDarkSteelAnvil.unlocalisedName);
setCreativeTab(EnderIOTab.tabEnderIO);
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register)
{
this.blockIcon = register.registerIcon(EnderIO.DOMAIN + ":anvil_base");
this.anvilIcons = new IIcon[anvilIconNames.length];
protected void init() {
GameRegistry.registerBlock(this, ItemAnvilBlock.class, ModObject.blockDarkSteelAnvil.unlocalisedName);
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_ANVIL, new IGuiHandler() {
for (int i = 0; i < this.anvilIcons.length; ++i)
{
this.anvilIcons[i] = register.registerIcon(EnderIO.DOMAIN + ":" + anvilIconNames[i]);
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerDarkSteelAnvil(player.inventory, world, x, y, z, player);
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GuiRepair(player.inventory, world, x, y, z);
}
});
}
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z) >> 2);
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return this.getUnlocalizedName();
}
@Override
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY,
float hitZ) {
p.openGui(EnderIO.instance, GuiHandler.GUI_ID_ANVIL, w, x, y, z);
return true;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
if (this.anvilRenderSide == 3 && p_149691_1_ == 1) {
int k = (p_149691_2_ >> 2) % this.anvilIcons.length;
return this.anvilIcons[k];
} else {
return this.blockIcon;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
this.blockIcon = register.registerIcon(EnderIO.DOMAIN + ":anvil_base");
this.anvilIcons = new IIcon[anvilIconNames.length];
for (int i = 0; i < this.anvilIcons.length; ++i) {
this.anvilIcons[i] = register.registerIcon(EnderIO.DOMAIN + ":" + anvilIconNames[i]);
}
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z) >> 2);
}
}
@@ -1,7 +1,5 @@
package crazypants.enderio.block;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLadder;
import net.minecraft.block.material.Material;
@@ -9,6 +7,9 @@ import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import cpw.mods.fml.common.registry.GameRegistry;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
@@ -16,50 +17,53 @@ import crazypants.enderio.ModObject;
import crazypants.enderio.config.Config;
public class BlockDarkSteelLadder extends BlockLadder implements IResourceTooltipProvider {
public static BlockDarkSteelLadder create() {
BlockDarkSteelLadder res = new BlockDarkSteelLadder();
res.init();
return res;
}
protected BlockDarkSteelLadder() {
super();
setBlockName(ModObject.blockDarkSteelLadder.unlocalisedName);
setBlockTextureName(EnderIO.DOMAIN + ":" + ModObject.blockDarkSteelLadder.unlocalisedName);
setStepSound(Block.soundTypeMetal);
setCreativeTab(EnderIOTab.tabEnderIO);
setHardness(0.4F);
}
protected void init() {
GameRegistry.registerBlock(this, ModObject.blockDarkSteelLadder.unlocalisedName);
}
@Override
public Material getMaterial() {
return Material.iron;
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (entity.onGround || entity.isCollidedVertically) {
return;
public static BlockDarkSteelLadder create() {
BlockDarkSteelLadder res = new BlockDarkSteelLadder();
res.init();
return res;
}
if(entity.motionY >= 0.1) {
entity.setPosition(entity.posX, entity.posY + Config.darkSteelLadderSpeedBoost, entity.posZ);
} else if(entity.motionY <= -0.1) {
Block blockUnder = entity.worldObj.getBlock(MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY) - 3, MathHelper.floor_double(entity.posZ));
if (blockUnder == null || blockUnder == this) { // prevent clipping into block
entity.setPosition(entity.posX, entity.posY - Config.darkSteelLadderSpeedBoost, entity.posZ);
}
}
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName();
}
protected BlockDarkSteelLadder() {
super();
setBlockName(ModObject.blockDarkSteelLadder.unlocalisedName);
setBlockTextureName(EnderIO.DOMAIN + ":" + ModObject.blockDarkSteelLadder.unlocalisedName);
setStepSound(Block.soundTypeMetal);
setCreativeTab(EnderIOTab.tabEnderIO);
setHardness(0.4F);
}
protected void init() {
GameRegistry.registerBlock(this, ModObject.blockDarkSteelLadder.unlocalisedName);
}
@Override
public Material getMaterial() {
return Material.iron;
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (entity.onGround || entity.isCollidedVertically) {
return;
}
if (entity.motionY >= 0.1) {
entity.setPosition(entity.posX, entity.posY + Config.darkSteelLadderSpeedBoost, entity.posZ);
} else if (entity.motionY <= -0.1) {
Block blockUnder = entity.worldObj.getBlock(
MathHelper.floor_double(entity.posX),
MathHelper.floor_double(entity.posY) - 3,
MathHelper.floor_double(entity.posZ));
if (blockUnder == null || blockUnder == this) { // prevent clipping into block
entity.setPosition(entity.posX, entity.posY - Config.darkSteelLadderSpeedBoost, entity.posZ);
}
}
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName();
}
}
@@ -18,6 +18,8 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import com.enderio.core.common.util.Util;
import com.google.common.collect.Lists;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -34,190 +36,194 @@ import crazypants.enderio.machine.painter.PaintSourceValidator;
import crazypants.enderio.machine.painter.PainterUtil;
import crazypants.enderio.machine.painter.TileEntityPaintedBlock;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import com.enderio.core.common.util.Util;
public class BlockDarkSteelPressurePlate extends BlockPressurePlate
implements IResourceTooltipProvider, ITileEntityProvider, IPaintedBlock {
public class BlockDarkSteelPressurePlate extends BlockPressurePlate implements IResourceTooltipProvider, ITileEntityProvider, IPaintedBlock {
public static BlockDarkSteelPressurePlate create() {
BlockDarkSteelPressurePlate res = new BlockDarkSteelPressurePlate();
res.init();
return res;
}
public BlockDarkSteelPressurePlate() {
super(ModObject.blockDarkSteelPressurePlate.unlocalisedName, Material.iron, Sensitivity.players);
setBlockName(ModObject.blockDarkSteelPressurePlate.unlocalisedName);
setStepSound(Block.soundTypeMetal);
setCreativeTab(EnderIOTab.tabEnderIO);
setHardness(2.0f);
}
protected void init() {
GameRegistry.registerBlock(this, BlockItemDarkSteelPressurePlate.class, ModObject.blockDarkSteelPressurePlate.unlocalisedName);
GameRegistry.registerTileEntity(TileEntityDarkSteelPressurePlate.class, ModObject.blockDarkSteelPressurePlate.unlocalisedName + "TileEntity");
MachineRecipeRegistry.instance.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate(this));
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
blockIcon = iIconRegister.registerIcon("enderio:" + ModObject.blockDarkSteelPressurePlate.unlocalisedName);
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
if(itemStack != null && itemStack.getItemDamage() == 1) {
return getUnlocalizedName() + ".silent";
}
return getUnlocalizedName();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
TileEntityPaintedBlock tef = (TileEntityPaintedBlock) te;
if(tef.getSourceBlock() != null) {
return tef.getSourceBlock().getIcon(blockSide, tef.getSourceBlockMetadata());
}
}
return super.getIcon(world, x, y, z, blockSide);
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if(willHarvest) {
return true;
}
return super.removedByPlayer(world, player, x, y, z, willHarvest);
}
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
super.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
}
@Override
public final ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
TileEntityDarkSteelPressurePlate tepb = (TileEntityDarkSteelPressurePlate) world.getTileEntity(x, y, z);
ItemStack stack = new ItemStack(this, 1, tepb.isSilent() ? 1 : 0);
if(tepb.getSourceBlock() != null) {
PainterUtil.setSourceBlock(stack, tepb.getSourceBlock(), tepb.getSourceBlockMetadata());
}
return Lists.newArrayList(stack);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
Block b = PainterUtil.getSourceBlock(stack);
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityDarkSteelPressurePlate) {
TileEntityDarkSteelPressurePlate tef = (TileEntityDarkSteelPressurePlate) te;
tef.setSourceBlock(b);
tef.setSourceBlockMetadata(PainterUtil.getSourceBlockMetadata(stack));
tef.setSilent(stack.getItemDamage() == 1);
}
world.markBlockForUpdate(x, y, z);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityDarkSteelPressurePlate();
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityPaintedBlock) {
TileEntityPaintedBlock tef = (TileEntityPaintedBlock) te;
if(tef.getSourceBlock() != null) {
return tef.getSourceBlock().colorMultiplier(world, x, y, z);
}
}
return super.colorMultiplier(world, x, y, z);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item arg0, CreativeTabs arg1, List items) {
items.add(new ItemStack(this, 1, 0));
items.add(new ItemStack(this, 1, 1));
}
@Override
protected void func_150062_a(World world, int x, int y, int z, int p_150062_5_) {
int i1 = func_150065_e(world, x, y, z);
boolean flag = p_150062_5_ > 0;
boolean flag1 = i1 > 0;
if(p_150062_5_ != i1) {
world.setBlockMetadataWithNotify(x, y, z, func_150066_d(i1), 2);
func_150064_a_(world, x, y, z);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
public static BlockDarkSteelPressurePlate create() {
BlockDarkSteelPressurePlate res = new BlockDarkSteelPressurePlate();
res.init();
return res;
}
boolean playSound = true;
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityDarkSteelPressurePlate && ((TileEntityDarkSteelPressurePlate)te).isSilent()) {
playSound = false;
}
if(playSound) {
if(!flag1 && flag) {
world.playSoundEffect(x + 0.5D, y + 0.1D, z + 0.5D, "random.click", 0.3F, 0.5F);
} else if(flag1 && !flag) {
world.playSoundEffect(x + 0.5D, y + 0.1D, z + 0.5D, "random.click", 0.3F, 0.6F);
}
public BlockDarkSteelPressurePlate() {
super(ModObject.blockDarkSteelPressurePlate.unlocalisedName, Material.iron, Sensitivity.players);
setBlockName(ModObject.blockDarkSteelPressurePlate.unlocalisedName);
setStepSound(Block.soundTypeMetal);
setCreativeTab(EnderIOTab.tabEnderIO);
setHardness(2.0f);
}
if(flag1) {
world.scheduleBlockUpdate(x, y, z, this, tickRate(world));
}
}
public static final class PainterTemplate extends BasicPainterTemplate {
public PainterTemplate(Block dspp) {
super(dspp);
protected void init() {
GameRegistry.registerBlock(
this,
BlockItemDarkSteelPressurePlate.class,
ModObject.blockDarkSteelPressurePlate.unlocalisedName);
GameRegistry.registerTileEntity(
TileEntityDarkSteelPressurePlate.class,
ModObject.blockDarkSteelPressurePlate.unlocalisedName + "TileEntity");
MachineRecipeRegistry.instance
.registerRecipe(ModObject.blockPainter.unlocalisedName, new PainterTemplate(this));
}
@Override
public boolean isValidPaintSource(ItemStack paintSource) {
if(PaintSourceValidator.instance.isValidSourceDefault(paintSource)) {
return true;
}
if(paintSource == null) {
return false;
}
Block block = Util.getBlockFromItemId(paintSource);
if(block == null) {
return false;
}
return Block.getBlockFromItem(paintSource.getItem()) == EnderIO.blockFusedQuartz;
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iIconRegister) {
blockIcon = iIconRegister.registerIcon("enderio:" + ModObject.blockDarkSteelPressurePlate.unlocalisedName);
}
@Override
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
if(paintSource == null) {
return new ResultStack[0];
}
ItemStack target = MachineRecipeInput.getInputForSlot(0, inputs);
ItemStack resultStack = createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage());
resultStack.setItemDamage(target.getItemDamage());
return new ResultStack[] { new ResultStack(resultStack) };
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
if (itemStack != null && itemStack.getItemDamage() == 1) {
return getUnlocalizedName() + ".silent";
}
return getUnlocalizedName();
}
public static ItemStack createItemStackForSourceBlock(Block block, int damage) {
ItemStack result = new ItemStack(EnderIO.blockDarkSteelPressurePlate, 1, damage);
PainterUtil.setSourceBlock(result, block, damage);
return result;
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityPaintedBlock) {
TileEntityPaintedBlock tef = (TileEntityPaintedBlock) te;
if (tef.getSourceBlock() != null) {
return tef.getSourceBlock().getIcon(blockSide, tef.getSourceBlockMetadata());
}
}
return super.getIcon(world, x, y, z, blockSide);
}
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if (willHarvest) {
return true;
}
return super.removedByPlayer(world, player, x, y, z, willHarvest);
}
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
super.harvestBlock(world, player, x, y, z, meta);
world.setBlockToAir(x, y, z);
}
@Override
public final ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
TileEntityDarkSteelPressurePlate tepb = (TileEntityDarkSteelPressurePlate) world.getTileEntity(x, y, z);
ItemStack stack = new ItemStack(this, 1, tepb.isSilent() ? 1 : 0);
if (tepb.getSourceBlock() != null) {
PainterUtil.setSourceBlock(stack, tepb.getSourceBlock(), tepb.getSourceBlockMetadata());
}
return Lists.newArrayList(stack);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
Block b = PainterUtil.getSourceBlock(stack);
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityDarkSteelPressurePlate) {
TileEntityDarkSteelPressurePlate tef = (TileEntityDarkSteelPressurePlate) te;
tef.setSourceBlock(b);
tef.setSourceBlockMetadata(PainterUtil.getSourceBlockMetadata(stack));
tef.setSilent(stack.getItemDamage() == 1);
}
world.markBlockForUpdate(x, y, z);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityDarkSteelPressurePlate();
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityPaintedBlock) {
TileEntityPaintedBlock tef = (TileEntityPaintedBlock) te;
if (tef.getSourceBlock() != null) {
return tef.getSourceBlock().colorMultiplier(world, x, y, z);
}
}
return super.colorMultiplier(world, x, y, z);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item arg0, CreativeTabs arg1, List<ItemStack> items) {
items.add(new ItemStack(this, 1, 0));
items.add(new ItemStack(this, 1, 1));
}
@Override
protected void func_150062_a(World world, int x, int y, int z, int p_150062_5_) {
int i1 = func_150065_e(world, x, y, z);
boolean flag = p_150062_5_ > 0;
boolean flag1 = i1 > 0;
if (p_150062_5_ != i1) {
world.setBlockMetadataWithNotify(x, y, z, func_150066_d(i1), 2);
func_150064_a_(world, x, y, z);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
}
boolean playSound = true;
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityDarkSteelPressurePlate && ((TileEntityDarkSteelPressurePlate) te).isSilent()) {
playSound = false;
}
if (playSound) {
if (!flag1 && flag) {
world.playSoundEffect(x + 0.5D, y + 0.1D, z + 0.5D, "random.click", 0.3F, 0.5F);
} else if (flag1 && !flag) {
world.playSoundEffect(x + 0.5D, y + 0.1D, z + 0.5D, "random.click", 0.3F, 0.6F);
}
}
if (flag1) {
world.scheduleBlockUpdate(x, y, z, this, tickRate(world));
}
}
public static final class PainterTemplate extends BasicPainterTemplate {
public PainterTemplate(Block dspp) {
super(dspp);
}
@Override
public boolean isValidPaintSource(ItemStack paintSource) {
if (PaintSourceValidator.instance.isValidSourceDefault(paintSource)) {
return true;
}
if (paintSource == null) {
return false;
}
Block block = Util.getBlockFromItemId(paintSource);
if (block == null) {
return false;
}
return Block.getBlockFromItem(paintSource.getItem()) == EnderIO.blockFusedQuartz;
}
@Override
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs);
if (paintSource == null) {
return new ResultStack[0];
}
ItemStack target = MachineRecipeInput.getInputForSlot(0, inputs);
ItemStack resultStack = createItemStackForSourceBlock(
Block.getBlockFromItem(paintSource.getItem()),
paintSource.getItemDamage());
resultStack.setItemDamage(target.getItemDamage());
return new ResultStack[] { new ResultStack(resultStack) };
}
public static ItemStack createItemStackForSourceBlock(Block block, int damage) {
ItemStack result = new ItemStack(EnderIO.blockDarkSteelPressurePlate, 1, damage);
PainterUtil.setSourceBlock(result, block, damage);
return result;
}
}
}
@@ -5,13 +5,12 @@ import net.minecraft.item.ItemBlockWithMetadata;
public class BlockItemDarkSteelPressurePlate extends ItemBlockWithMetadata {
public BlockItemDarkSteelPressurePlate(Block block) {
super(block, block);
}
@Override
public int getMetadata(int p_77647_1_) {
return 0;
}
public BlockItemDarkSteelPressurePlate(Block block) {
super(block, block);
}
@Override
public int getMetadata(int p_77647_1_) {
return 0;
}
}
@@ -2,8 +2,6 @@ package crazypants.enderio.block;
import java.util.List;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
@@ -12,6 +10,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import crazypants.enderio.BlockEio;
import crazypants.enderio.ModObject;
import crazypants.enderio.config.Config;
@@ -19,56 +20,56 @@ import crazypants.enderio.waila.IWailaInfoProvider;
public class BlockReinforcedObsidian extends BlockEio implements IResourceTooltipProvider, IWailaInfoProvider {
public static BlockReinforcedObsidian create() {
BlockReinforcedObsidian result = new BlockReinforcedObsidian();
result.init();
return result;
}
private BlockReinforcedObsidian() {
super(ModObject.blockReinforcedObsidian.unlocalisedName, null, Material.rock);
setHardness(50.0F);
setResistance(2000.0F);
setStepSound(soundTypePiston);
if(!Config.reinforcedObsidianEnabled) {
setCreativeTab(null);
public static BlockReinforcedObsidian create() {
BlockReinforcedObsidian result = new BlockReinforcedObsidian();
result.init();
return result;
}
}
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
return false;
}
@Override
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
;
}
@Override
public boolean canDropFromExplosion(Explosion p_149659_1_) {
return false;
}
public MapColor getMapColor(int p_149728_1_) {
return MapColor.obsidianColor;
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName();
}
@Override
protected boolean shouldWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side) {
return false;
}
private BlockReinforcedObsidian() {
super(ModObject.blockReinforcedObsidian.unlocalisedName, null, Material.rock);
setHardness(50.0F);
setResistance(2000.0F);
setStepSound(soundTypePiston);
@Override
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {}
if (!Config.reinforcedObsidianEnabled) {
setCreativeTab(null);
}
}
@Override
public int getDefaultDisplayMask(World world, int x, int y, int z) {
return IWailaInfoProvider.BIT_BASIC;
}
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
return false;
}
@Override
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
;
}
@Override
public boolean canDropFromExplosion(Explosion p_149659_1_) {
return false;
}
public MapColor getMapColor(int p_149728_1_) {
return MapColor.obsidianColor;
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName();
}
@Override
protected boolean shouldWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side) {
return false;
}
@Override
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {}
@Override
public int getDefaultDisplayMask(World world, int x, int y, int z) {
return IWailaInfoProvider.BIT_BASIC;
}
}
@@ -9,93 +9,99 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.ReflectionHelper;
import crazypants.enderio.EnderIO;
import crazypants.enderio.config.Config;
public class ContainerDarkSteelAnvil extends ContainerRepair {
private int x, y, z;
private final int x;
private final int y;
private final int z;
private final Field _outputSlot = ReflectionHelper.findField(ContainerRepair.class, "outputSlot", "field_82852_f");
private final Field _inputSlots = ReflectionHelper.findField(ContainerRepair.class, "inputSlots", "field_82853_g");
private final Field _materialCost = ReflectionHelper.findField(ContainerRepair.class, "materialCost", "stackSizeToBeUsedInRepair", "field_82856_l");
public ContainerDarkSteelAnvil(InventoryPlayer playerInv, final World world, final int x, final int y, final int z,
EntityPlayer player) {
super(playerInv, world, x, y, z, player);
@SuppressWarnings("unchecked")
public ContainerDarkSteelAnvil(InventoryPlayer playerInv, final World world, final int x, final int y, final int z, EntityPlayer player) {
super(playerInv, world, x, y, z, player);
final IInventory outputSlot, inputSlots;
final int materialCost;
final IInventory outputSlot, inputSlots;
final int materialCost;
try {
Field _outputSlot = ReflectionHelper.findField(ContainerRepair.class, "outputSlot", "field_82852_f");
outputSlot = (IInventory) _outputSlot.get(this);
Field _inputSlots = ReflectionHelper.findField(ContainerRepair.class, "inputSlots", "field_82853_g");
inputSlots = (IInventory) _inputSlots.get(this);
Field _materialCost = ReflectionHelper
.findField(ContainerRepair.class, "materialCost", "stackSizeToBeUsedInRepair", "field_82856_l");
materialCost = _materialCost.getInt(this);
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
outputSlot = (IInventory) _outputSlot.get(this);
inputSlots = (IInventory) _inputSlots.get(this);
materialCost = _materialCost.getInt(this);
} catch (Exception e) {
throw new RuntimeException(e);
this.x = x;
this.y = y;
this.z = z;
this.inventorySlots.set(2, new Slot(outputSlot, 2, 134, 47) {
public boolean isItemValid(ItemStack stack) {
return false;
}
public boolean canTakeStack(EntityPlayer stack) {
return (stack.capabilities.isCreativeMode
|| stack.experienceLevel >= ContainerDarkSteelAnvil.this.maximumCost)
&& ContainerDarkSteelAnvil.this.maximumCost > 0
&& this.getHasStack();
}
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
if (!player.capabilities.isCreativeMode) {
player.addExperienceLevel(-ContainerDarkSteelAnvil.this.maximumCost);
}
inputSlots.setInventorySlotContents(0, (ItemStack) null);
if (materialCost > 0) {
ItemStack itemstack1 = inputSlots.getStackInSlot(1);
if (itemstack1 != null && itemstack1.stackSize > materialCost) {
itemstack1.stackSize -= materialCost;
inputSlots.setInventorySlotContents(1, itemstack1);
} else {
inputSlots.setInventorySlotContents(1, (ItemStack) null);
}
} else {
inputSlots.setInventorySlotContents(1, (ItemStack) null);
}
ContainerDarkSteelAnvil.this.maximumCost = 0;
if (!player.capabilities.isCreativeMode && !world.isRemote
&& world.getBlock(x, y, z) == EnderIO.blockDarkSteelAnvil
&& player.getRNG().nextFloat() < Config.darkSteelAnvilDamageChance) {
int i1 = world.getBlockMetadata(x, y, z);
int k = i1 & 3;
int l = i1 >> 2;
++l;
if (l > 2) {
world.setBlockToAir(x, y, z);
world.playAuxSFX(1020, x, y, z, 0);
} else {
world.setBlockMetadataWithNotify(x, y, z, k | l << 2, 2);
world.playAuxSFX(1021, x, y, z, 0);
}
} else if (!world.isRemote) {
world.playAuxSFX(1021, x, y, z, 0);
}
}
});
}
this.x = x;
this.y = y;
this.z = z;
this.inventorySlots.set(2, new Slot(outputSlot, 2, 134, 47) {
public boolean isItemValid(ItemStack stack) {
return false;
}
public boolean canTakeStack(EntityPlayer stack) {
return (stack.capabilities.isCreativeMode || stack.experienceLevel >= ContainerDarkSteelAnvil.this.maximumCost)
&& ContainerDarkSteelAnvil.this.maximumCost > 0 && this.getHasStack();
}
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
if(!player.capabilities.isCreativeMode) {
player.addExperienceLevel(-ContainerDarkSteelAnvil.this.maximumCost);
}
inputSlots.setInventorySlotContents(0, (ItemStack) null);
if(materialCost > 0) {
ItemStack itemstack1 = inputSlots.getStackInSlot(1);
if(itemstack1 != null && itemstack1.stackSize > materialCost) {
itemstack1.stackSize -= materialCost;
inputSlots.setInventorySlotContents(1, itemstack1);
} else {
inputSlots.setInventorySlotContents(1, (ItemStack) null);
}
} else {
inputSlots.setInventorySlotContents(1, (ItemStack) null);
}
ContainerDarkSteelAnvil.this.maximumCost = 0;
if(!player.capabilities.isCreativeMode && !world.isRemote && world.getBlock(x, y, z) == EnderIO.blockDarkSteelAnvil
&& player.getRNG().nextFloat() < Config.darkSteelAnvilDamageChance) {
int i1 = world.getBlockMetadata(x, y, z);
int k = i1 & 3;
int l = i1 >> 2;
++l;
if(l > 2) {
world.setBlockToAir(x, y, z);
world.playAuxSFX(1020, x, y, z, 0);
} else {
world.setBlockMetadataWithNotify(x, y, z, k | l << 2, 2);
world.playAuxSFX(1021, x, y, z, 0);
}
} else if(!world.isRemote) {
world.playAuxSFX(1021, x, y, z, 0);
}
}
});
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return player.worldObj.getBlock(this.x, this.y, this.z) == EnderIO.blockDarkSteelAnvil;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return player.worldObj.getBlock(this.x, this.y, this.z) == EnderIO.blockDarkSteelAnvil;
}
}
@@ -1,32 +1,30 @@
package crazypants.enderio.block;
import net.minecraft.nbt.NBTTagCompound;
import crazypants.enderio.machine.painter.TileEntityPaintedBlock;
public class TileEntityDarkSteelPressurePlate extends TileEntityPaintedBlock {
private boolean silent;
private boolean silent;
public boolean isSilent() {
return silent;
}
public boolean isSilent() {
return silent;
}
public void setSilent(boolean silent) {
this.silent = silent;
}
public void setSilent(boolean silent) {
this.silent = silent;
}
@Override
public void readCustomNBT(NBTTagCompound nbtRoot) {
super.readCustomNBT(nbtRoot);
silent = nbtRoot.getBoolean("silent");
}
@Override
public void readCustomNBT(NBTTagCompound nbtRoot) {
super.readCustomNBT(nbtRoot);
silent = nbtRoot.getBoolean("silent");
}
@Override
public void writeCustomNBT(NBTTagCompound nbtRoot) {
super.writeCustomNBT(nbtRoot);
nbtRoot.setBoolean("silent", silent);
}
@Override
public void writeCustomNBT(NBTTagCompound nbtRoot) {
super.writeCustomNBT(nbtRoot);
nbtRoot.setBoolean("silent", silent);
}
}
File diff suppressed because it is too large. Load diff
@@ -7,97 +7,99 @@ import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
//I=base type, I is the base class of the implementations accepted by the network
import crazypants.enderio.EnderIO;
// I=base type, I is the base class of the implementations accepted by the network
public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
protected final List<I> conduits = new ArrayList<I>();
protected final List<I> conduits = new ArrayList<>();
protected final Class<I> implClass;
protected final Class<T> baseConduitClass;
protected final Class<I> implClass;
protected final Class<T> baseConduitClass;
protected AbstractConduitNetwork(Class<I> implClass, Class<T> baseConduitClass) {
this.implClass = implClass;
this.baseConduitClass = baseConduitClass;
}
public void init(IConduitBundle tile, Collection<I> connections, World world) {
if(world.isRemote) {
throw new UnsupportedOperationException();
protected AbstractConduitNetwork(Class<I> implClass, Class<T> baseConduitClass) {
this.implClass = implClass;
this.baseConduitClass = baseConduitClass;
}
// Destroy all existing redstone networks around this block
for (I con : connections) {
AbstractConduitNetwork<?, ?> network = con.getNetwork();
if(network != null) {
network.destroyNetwork();
}
}
setNetwork(world, tile);
notifyNetworkOfUpdate();
}
public void init(IConduitBundle tile, Collection<I> connections, World world) {
public final Class<T> getBaseConduitType() {
return baseConduitClass;
}
protected void setNetwork(World world, IConduitBundle tile) {
T conduit = tile.getConduit(getBaseConduitType());
if(conduit != null && implClass.isAssignableFrom(conduit.getClass()) && conduit.setNetwork(this)) {
addConduit(implClass.cast(conduit));
TileEntity te = tile.getEntity();
Collection<T> connections = ConduitUtil.getConnectedConduits(world, te.xCoord, te.yCoord, te.zCoord, getBaseConduitType());
for (T con : connections) {
if(con.getNetwork() == null) {
setNetwork(world, con.getBundle());
} else if(con.getNetwork() != this) {
con.getNetwork().destroyNetwork();
setNetwork(world, con.getBundle());
if (world.isRemote) {
throw new UnsupportedOperationException();
}
}
// Destroy all existing redstone networks around this block
for (I con : connections) {
AbstractConduitNetwork<?, ?> network = con.getNetwork();
if (network != null) {
network.destroyNetwork();
}
}
setNetwork(world, tile);
notifyNetworkOfUpdate();
}
}
public void addConduit(I con) {
if(!conduits.contains(con)) {
if(conduits.isEmpty()) {
ConduitNetworkTickHandler.instance.registerNetwork(this);
}
conduits.add(con);
public final Class<T> getBaseConduitType() {
return baseConduitClass;
}
}
public void destroyNetwork() {
for (I con : conduits) {
con.setNetwork(null);
protected void setNetwork(World world, IConduitBundle tile) {
T conduit = tile.getConduit(getBaseConduitType());
if (conduit != null && implClass.isAssignableFrom(conduit.getClass()) && conduit.setNetwork(this)) {
addConduit(implClass.cast(conduit));
TileEntity te = tile.getEntity();
Collection<T> connections = ConduitUtil
.getConnectedConduits(world, te.xCoord, te.yCoord, te.zCoord, getBaseConduitType());
for (T con : connections) {
if (con.getNetwork() == null) {
setNetwork(world, con.getBundle());
} else if (con.getNetwork() != this) {
con.getNetwork().destroyNetwork();
setNetwork(world, con.getBundle());
}
}
}
}
conduits.clear();
ConduitNetworkTickHandler.instance.unregisterNetwork(this);
}
public List<I> getConduits() {
return conduits;
}
public void notifyNetworkOfUpdate() {
for (I con : conduits) {
TileEntity te = con.getBundle().getEntity();
te.getWorldObj().markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
public void addConduit(I con) {
if (!conduits.contains(con)) {
if (conduits.isEmpty()) {
EnderIO.proxy.conduitNetworkTickHandler.registerNetwork(this);
}
conduits.add(con);
}
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (IConduit con : conduits) {
sb.append(con.getLocation());
sb.append(", ");
public void destroyNetwork() {
for (I con : conduits) {
con.setNetwork(null);
}
conduits.clear();
EnderIO.proxy.conduitNetworkTickHandler.unregisterNetwork(this);
}
return "AbstractConduitNetwork [conduits=" + sb.toString() + "]";
}
public void doNetworkTick() {
}
public List<I> getConduits() {
return conduits;
}
public void notifyNetworkOfUpdate() {
for (I con : conduits) {
TileEntity te = con.getBundle().getEntity();
te.getWorldObj().markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (IConduit con : conduits) {
sb.append(con.getLocation());
sb.append(", ");
}
return "AbstractConduitNetwork [conduits=" + sb.toString() + "]";
}
public void doNetworkTick() {}
}
@@ -2,10 +2,6 @@ package crazypants.enderio.conduit;
import java.util.List;
import mods.immibis.microblocks.api.IMicroblockCoverSystem;
import mods.immibis.microblocks.api.IMicroblockSupporterTile;
import mods.immibis.microblocks.api.MicroblockAPIUtils;
import mods.immibis.microblocks.api.Part;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -28,176 +24,177 @@ import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.util.ForgeDirections;
import mods.immibis.microblocks.api.IMicroblockCoverSystem;
import mods.immibis.microblocks.api.IMicroblockSupporterTile;
import mods.immibis.microblocks.api.MicroblockAPIUtils;
import mods.immibis.microblocks.api.Part;
public abstract class AbstractItemConduit extends Item implements IConduitItem {
protected ModObject modObj;
protected ModObject modObj;
protected ItemConduitSubtype[] subtypes;
protected ItemConduitSubtype[] subtypes;
protected IIcon[] icons;
protected IIcon[] icons;
protected AbstractItemConduit(ModObject modObj, ItemConduitSubtype... subtypes) {
this.modObj = modObj;
this.subtypes = subtypes;
setCreativeTab(EnderIOTab.tabEnderIO);
setUnlocalizedName(modObj.unlocalisedName);
setMaxStackSize(64);
setHasSubtypes(true);
}
protected void init() {
GameRegistry.registerItem(this, modObj.unlocalisedName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
icons = new IIcon[subtypes.length];
int index = 0;
for (ItemConduitSubtype subtype : subtypes) {
icons[index] = IIconRegister.registerIcon(subtype.iconKey);
index++;
protected AbstractItemConduit(ModObject modObj, ItemConduitSubtype... subtypes) {
this.modObj = modObj;
this.subtypes = subtypes;
setCreativeTab(EnderIOTab.tabEnderIO);
setUnlocalizedName(modObj.unlocalisedName);
setMaxStackSize(64);
setHasSubtypes(true);
}
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (MicroblocksUtil.supportMicroblocks() && tryAddToMicroblocks(stack, player, world, x, y, z, side)) {
return true;
protected void init() {
GameRegistry.registerItem(this, modObj.unlocalisedName);
}
BlockCoord placeAt = Util.canPlaceItem(stack, EnderIO.blockConduitBundle, player, world, x, y, z, side);
if(placeAt != null) {
if(!world.isRemote) {
if(world.setBlock(placeAt.x, placeAt.y, placeAt.z, EnderIO.blockConduitBundle, 0, 1)) {
TileEntity te = world.getTileEntity(placeAt.x, placeAt.y, placeAt.z);
if(te instanceof IConduitBundle) {
IConduitBundle bundle = (IConduitBundle) te;
bundle.addConduit(createConduit(stack, player));
ConduitUtil.playBreakSound(Block.soundTypeMetal, world, placeAt.x, placeAt.y, placeAt.z);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
icons = new IIcon[subtypes.length];
int index = 0;
for (ItemConduitSubtype subtype : subtypes) {
icons[index] = IIconRegister.registerIcon(subtype.iconKey);
index++;
}
}
if(!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
return true;
}
} else {
ForgeDirection dir = ForgeDirection.values()[side];
int placeX = x + dir.offsetX;
int placeY = y + dir.offsetY;
int placeZ = z + dir.offsetZ;
if(world.getBlock(placeX, placeY, placeZ) == EnderIO.blockConduitBundle) {
IConduitBundle bundle = (TileConduitBundle) world.getTileEntity(placeX, placeY, placeZ);
if(bundle == null) {
System.out.println("AbstractItemConduit.onItemUse: Bundle null");
return false;
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ) {
if (MicroblocksUtil.supportMicroblocks() && tryAddToMicroblocks(stack, player, world, x, y, z, side)) {
return true;
}
if(!bundle.hasType(getBaseConduitType())) {
if(!world.isRemote) {
IConduit con = createConduit(stack, player);
if(con == null) {
System.out.println("AbstractItemConduit.onItemUse: Conduit null.");
return false;
BlockCoord placeAt = Util.canPlaceItem(stack, EnderIO.blockConduitBundle, player, world, x, y, z, side);
if (placeAt != null) {
if (!world.isRemote) {
if (world.setBlock(placeAt.x, placeAt.y, placeAt.z, EnderIO.blockConduitBundle, 0, 1)) {
TileEntity te = world.getTileEntity(placeAt.x, placeAt.y, placeAt.z);
if (te instanceof IConduitBundle) {
IConduitBundle bundle = (IConduitBundle) te;
bundle.addConduit(createConduit(stack, player));
ConduitUtil.playBreakSound(Block.soundTypeMetal, world, placeAt.x, placeAt.y, placeAt.z);
}
}
}
bundle.addConduit(con);
ConduitUtil.playBreakSound(Block.soundTypeMetal, world, placeX, placeY, placeZ);
if(!player.capabilities.isCreativeMode) {
stack.stackSize--;
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
}
return true;
}
}
}
return true;
} else {
ForgeDirection dir = ForgeDirections.DIRECTIONS[side];
int placeX = x + dir.offsetX;
int placeY = y + dir.offsetY;
int placeZ = z + dir.offsetZ;
return false;
}
if (world.getBlock(placeX, placeY, placeZ) == EnderIO.blockConduitBundle) {
private boolean tryAddToMicroblocks(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te.getClass().getName().equals("mods.immibis.microblocks.TileMicroblockContainer")) {
IMicroblockCoverSystem covers = ((IMicroblockSupporterTile) te).getCoverSystem();
world.setBlock(x, y, z, EnderIO.blockConduitBundle);
EnderIO.blockConduitBundle.onBlockActivated(world, x, y, z, player, side, 0, 0, 0);
IMicroblockCoverSystem newCovers = MicroblockAPIUtils.createMicroblockCoverSystem((IMicroblockSupporterTile) world.getTileEntity(x, y, z));
for (Part p : covers.getAllParts()) {
newCovers.addPart(p);
}
((TileConduitBundle)world.getTileEntity(x, y, z)).covers = newCovers;
return true;
}
return false;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
// Conduit replacement
if (player.isSneaking()) {
return false;
}
TileEntity te = world.getTileEntity(x, y, z);
if (te == null || !(te instanceof IConduitBundle)) {
return false;
}
IConduitBundle bundle = (IConduitBundle) te;
IConduit existingConduit = bundle.getConduit(getBaseConduitType());
if (existingConduit == null) {
return false;
}
ItemStack existingConduitAsItemStack = existingConduit.createItem();
if (!ItemUtil.areStacksEqual(existingConduitAsItemStack, stack)) {
if (!world.isRemote) {
IConduit newConduit = createConduit(stack, player);
if (newConduit == null) {
System.out.println("AbstractItemConduit.onItemUse: Conduit null.");
return false;
}
bundle.removeConduit(existingConduit);
bundle.addConduit(newConduit);
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
for (ItemStack drop : existingConduit.getDrops()) {
if (!player.inventory.addItemStackToInventory(drop)) {
ItemUtil.spawnItemInWorldWithRandomMotion(world, drop, x, y, z);
IConduitBundle bundle = (TileConduitBundle) world.getTileEntity(placeX, placeY, placeZ);
if (bundle == null) {
System.out.println("AbstractItemConduit.onItemUse: Bundle null");
return false;
}
if (!bundle.hasType(getBaseConduitType())) {
if (!world.isRemote) {
IConduit con = createConduit(stack, player);
if (con == null) {
System.out.println("AbstractItemConduit.onItemUse: Conduit null.");
return false;
}
bundle.addConduit(con);
ConduitUtil.playBreakSound(Block.soundTypeMetal, world, placeX, placeY, placeZ);
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
}
}
return true;
}
}
}
player.inventoryContainer.detectAndSendChanges();
}
return true;
} else {
player.swingItem();
}
return false;
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
damage = MathHelper.clamp_int(damage, 0, subtypes.length - 1);
return icons[damage];
}
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, subtypes.length - 1);
return subtypes[i].unlocalisedName;
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (int j = 0; j < subtypes.length; ++j) {
par3List.add(new ItemStack(this, 1, j));
private boolean tryAddToMicroblocks(ItemStack stack, EntityPlayer player, World world, int x, int y, int z,
int side) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te.getClass().getName().equals("mods.immibis.microblocks.TileMicroblockContainer")) {
IMicroblockCoverSystem covers = ((IMicroblockSupporterTile) te).getCoverSystem();
world.setBlock(x, y, z, EnderIO.blockConduitBundle);
EnderIO.blockConduitBundle.onBlockActivated(world, x, y, z, player, side, 0, 0, 0);
IMicroblockCoverSystem newCovers = MicroblockAPIUtils
.createMicroblockCoverSystem((IMicroblockSupporterTile) world.getTileEntity(x, y, z));
for (Part p : covers.getAllParts()) {
newCovers.addPart(p);
}
((TileConduitBundle) world.getTileEntity(x, y, z)).covers = newCovers;
return true;
}
return false;
}
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ) {
// Conduit replacement
if (player.isSneaking()) {
return false;
}
TileEntity te = world.getTileEntity(x, y, z);
if (te == null || !(te instanceof IConduitBundle)) {
return false;
}
IConduitBundle bundle = (IConduitBundle) te;
IConduit existingConduit = bundle.getConduit(getBaseConduitType());
if (existingConduit == null) {
return false;
}
ItemStack existingConduitAsItemStack = existingConduit.createItem();
if (!ItemUtil.areStacksEqual(existingConduitAsItemStack, stack)) {
if (!world.isRemote) {
IConduit newConduit = createConduit(stack, player);
if (newConduit == null) {
System.out.println("AbstractItemConduit.onItemUse: Conduit null.");
return false;
}
bundle.replaceConduit(existingConduit, newConduit);
if (!player.capabilities.isCreativeMode) {
stack.stackSize--;
for (ItemStack drop : existingConduit.getDrops()) {
if (!player.inventory.addItemStackToInventory(drop)) {
ItemUtil.spawnItemInWorldWithRandomMotion(world, drop, x, y, z);
}
}
player.inventoryContainer.detectAndSendChanges();
}
return true;
} else {
player.swingItem();
}
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
damage = MathHelper.clamp_int(damage, 0, subtypes.length - 1);
return icons[damage];
}
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, subtypes.length - 1);
return subtypes[i].unlocalisedName;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List<ItemStack> par3List) {
for (int j = 0; j < subtypes.length; ++j) {
par3List.add(new ItemStack(this, 1, j));
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,5 +1,16 @@
package crazypants.enderio.conduit;
import static crazypants.enderio.gui.IconEIO.CROSS;
import static crazypants.enderio.gui.IconEIO.TICK;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_FLUID;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_FLUID_OFF;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_ITEM;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_ITEM_OFF;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_POWER;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_POWER_OFF;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_REDSTONE;
import static crazypants.enderio.gui.IconEIO.WRENCH_OVERLAY_REDSTONE_OFF;
import java.util.List;
import javax.annotation.Nonnull;
@@ -18,226 +29,208 @@ import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.liquid.ILiquidConduit;
import crazypants.enderio.conduit.power.IPowerConduit;
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
import static crazypants.enderio.gui.IconEIO.*;
public class ConduitDisplayMode {
public static final ConduitDisplayMode ALL = new ConduitDisplayMode("all", TICK, TICK);
public static final ConduitDisplayMode NONE = new ConduitDisplayMode("none", CROSS, CROSS);
private static final List<ConduitDisplayMode> registrar;
public static final ConduitDisplayMode ALL = new ConduitDisplayMode("all", TICK, TICK);
public static final ConduitDisplayMode NONE = new ConduitDisplayMode("none", CROSS, CROSS);
// @formatter:off
static {
registrar = Lists.newArrayList(
NONE,
ALL,
new ConduitDisplayMode(IItemConduit.class, WRENCH_OVERLAY_ITEM, WRENCH_OVERLAY_ITEM_OFF),
new ConduitDisplayMode(ILiquidConduit.class, WRENCH_OVERLAY_FLUID, WRENCH_OVERLAY_FLUID_OFF),
new ConduitDisplayMode(IPowerConduit.class, WRENCH_OVERLAY_POWER, WRENCH_OVERLAY_POWER_OFF),
new ConduitDisplayMode(IRedstoneConduit.class, WRENCH_OVERLAY_REDSTONE, WRENCH_OVERLAY_REDSTONE_OFF)
);
}
// @formatter:on
private static final List<ConduitDisplayMode> registrar;
public static void registerDisplayMode(ConduitDisplayMode mode) {
if (!registrar.contains(mode)) {
registrar.add(mode);
// @formatter:off
static {
registrar = Lists.newArrayList(
NONE,
ALL,
new ConduitDisplayMode(IItemConduit.class, WRENCH_OVERLAY_ITEM, WRENCH_OVERLAY_ITEM_OFF),
new ConduitDisplayMode(ILiquidConduit.class, WRENCH_OVERLAY_FLUID, WRENCH_OVERLAY_FLUID_OFF),
new ConduitDisplayMode(IPowerConduit.class, WRENCH_OVERLAY_POWER, WRENCH_OVERLAY_POWER_OFF),
new ConduitDisplayMode(IRedstoneConduit.class, WRENCH_OVERLAY_REDSTONE, WRENCH_OVERLAY_REDSTONE_OFF));
}
}
// @formatter:on
private final Class<? extends IConduit> conduitType;
private final IWidgetIcon widgetSelected, widgetUnselected;
private String overrideName = null;
/**
* Use this constructor if you have custom display logic, it will use
* {@code IConduit.class} as the conduitType, and the passed name as the
* override name.
*
* @see #ConduitDisplayMode(Class, IWidgetIcon, IWidgetIcon)
*
* @param name
* The override name.
* @param widgetSelected
* The widget to render when this type is selected.
* @param widgetUnselected
* The widget to render when this type is unselected.
*/
public ConduitDisplayMode(String name, IWidgetIcon widgetSelected, IWidgetIcon widgetUnselected) {
this(IConduit.class, widgetSelected, widgetUnselected);
setName(name);
}
/**
* Creates a new display mode for any {@link IConduitControl} wrench. Contains
* data about which conduit type this is for, and the icons to render while
* holding the wrench. wrench.
*
* @param conduitType
* The base class for your conduit type, typically an interface (e.g.
* {@code IPowerConduit}).
* @param widgetSelected
* The widget to render when this type is selected.
* @param widgetUnselected
* The widget to render when this type is unselected.
*/
public ConduitDisplayMode(@Nonnull Class<? extends IConduit> conduitType, IWidgetIcon widgetSelected, IWidgetIcon widgetUnselected) {
this.conduitType = conduitType;
this.widgetSelected = widgetSelected;
this.widgetUnselected = widgetUnselected;
}
@Nullable
public Class<? extends IConduit> getConduitType() {
return conduitType;
}
public boolean renderConduit(Class<? extends IConduit> conduitType) {
if (this == ALL) {
return true;
} else if (this == NONE) {
return false;
} else {
return this.conduitType.isAssignableFrom(conduitType);
public static void registerDisplayMode(ConduitDisplayMode mode) {
if (!registrar.contains(mode)) {
registrar.add(mode);
}
}
}
@Nonnull
public String getName() {
return overrideName == null ? conduitType.getSimpleName() : overrideName;
}
private final Class<? extends IConduit> conduitType;
private final IWidgetIcon widgetSelected, widgetUnselected;
/**
* The name is null by default, and will use the simple class name of the
* conduit type.
*
* @param name
* The override name to set.
*/
public void setName(@Nullable String name) {
this.overrideName = name;
}
private String overrideName = null;
public IWidgetIcon getWidgetSelected() {
return widgetSelected;
}
public IWidgetIcon getWidgetUnselected() {
return widgetUnselected;
}
public static ConduitDisplayMode next(ConduitDisplayMode mode) {
int index = registrar.indexOf(mode) + 1;
if (index >= registrar.size()) {
index = 0;
/**
* Use this constructor if you have custom display logic, it will use {@code IConduit.class} as the conduitType, and
* the passed name as the override name.
*
* @param name The override name.
* @param widgetSelected The widget to render when this type is selected.
* @param widgetUnselected The widget to render when this type is unselected.
* @see #ConduitDisplayMode(Class, IWidgetIcon, IWidgetIcon)
*/
public ConduitDisplayMode(String name, IWidgetIcon widgetSelected, IWidgetIcon widgetUnselected) {
this(IConduit.class, widgetSelected, widgetUnselected);
setName(name);
}
return registrar.get(index);
}
public static ConduitDisplayMode previous(ConduitDisplayMode mode) {
int index = registrar.indexOf(mode) - 1;
if (index < 0) {
index = registrar.size() - 1;
/**
* Creates a new display mode for any {@link IConduitControl} wrench. Contains data about which conduit type this is
* for, and the icons to render while holding the wrench. wrench.
*
* @param conduitType The base class for your conduit type, typically an interface (e.g.
* {@code IPowerConduit}).
* @param widgetSelected The widget to render when this type is selected.
* @param widgetUnselected The widget to render when this type is unselected.
*/
public ConduitDisplayMode(@Nonnull Class<? extends IConduit> conduitType, IWidgetIcon widgetSelected,
IWidgetIcon widgetUnselected) {
this.conduitType = conduitType;
this.widgetSelected = widgetSelected;
this.widgetUnselected = widgetUnselected;
}
return registrar.get(index);
}
public static ConduitDisplayMode fromName(String name) {
for (ConduitDisplayMode mode : registrar) {
if (mode.getName().equals(name)) {
@Nullable
public Class<? extends IConduit> getConduitType() {
return conduitType;
}
public boolean renderConduit(Class<? extends IConduit> conduitType) {
if (this == ALL) {
return true;
} else if (this == NONE) {
return false;
} else {
return this.conduitType.isAssignableFrom(conduitType);
}
}
@Nonnull
public String getName() {
return overrideName == null ? conduitType.getSimpleName() : overrideName;
}
/**
* The name is null by default, and will use the simple class name of the conduit type.
*
* @param name The override name to set.
*/
public void setName(@Nullable String name) {
this.overrideName = name;
}
public IWidgetIcon getWidgetSelected() {
return widgetSelected;
}
public IWidgetIcon getWidgetUnselected() {
return widgetUnselected;
}
public static ConduitDisplayMode next(ConduitDisplayMode mode) {
int index = registrar.indexOf(mode) + 1;
if (index >= registrar.size()) {
index = 0;
}
return registrar.get(index);
}
public static ConduitDisplayMode previous(ConduitDisplayMode mode) {
int index = registrar.indexOf(mode) - 1;
if (index < 0) {
index = registrar.size() - 1;
}
return registrar.get(index);
}
public static ConduitDisplayMode fromName(String name) {
for (ConduitDisplayMode mode : registrar) {
if (mode.getName().equals(name)) {
return mode;
}
}
return null;
}
private static final String NBT_KEY = "enderio.displaymode";
public static ConduitDisplayMode getDisplayMode(ItemStack equipped) {
if (equipped == null || !(equipped.getItem() instanceof IConduitControl)) {
return ALL;
}
initDisplayModeTag(equipped);
String name = equipped.stackTagCompound.getString(NBT_KEY);
ConduitDisplayMode mode = fromName(name);
if (mode == null) { // backwards compat
setDisplayMode(equipped, ALL);
return ALL;
}
return mode;
}
}
return null;
}
private static final String NBT_KEY = "enderio.displaymode";
public static ConduitDisplayMode getDisplayMode(ItemStack equipped) {
if (equipped == null || !(equipped.getItem() instanceof IConduitControl)) {
return ALL;
public static void setDisplayMode(ItemStack equipped, ConduitDisplayMode mode) {
if (mode == null || equipped == null || !(equipped.getItem() instanceof IConduitControl)) {
return;
}
initDisplayModeTag(equipped);
equipped.stackTagCompound.setString(NBT_KEY, mode.getName());
}
initDisplayModeTag(equipped);
String name = equipped.stackTagCompound.getString(NBT_KEY);
ConduitDisplayMode mode = fromName(name);
if (mode == null) { // backwards compat
setDisplayMode(equipped, ALL);
return ALL;
private static void initDisplayModeTag(ItemStack stack) {
if (stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setString(NBT_KEY, ConduitDisplayMode.ALL.getName());
}
}
return mode;
}
public static void setDisplayMode(ItemStack equipped, ConduitDisplayMode mode) {
if (mode == null || equipped == null || !(equipped.getItem() instanceof IConduitControl)) {
return;
public ConduitDisplayMode next() {
return next(this);
}
initDisplayModeTag(equipped);
equipped.stackTagCompound.setString(NBT_KEY, mode.getName());
}
private static void initDisplayModeTag(ItemStack stack) {
if (stack.stackTagCompound == null) {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setString(NBT_KEY, ConduitDisplayMode.ALL.getName());
public ConduitDisplayMode previous() {
return previous(this);
}
}
public ConduitDisplayMode next() {
return next(this);
}
public static int registrySize() {
return registrar.size() - 2;
}
public ConduitDisplayMode previous() {
return previous(this);
}
public static Iterable<ConduitDisplayMode> getRenderableModes() {
return FluentIterable.from(registrar).filter(new Predicate<>() {
public static int registrySize() {
return registrar.size() - 2;
}
@Override
public boolean apply(ConduitDisplayMode input) {
return input != ALL && input != NONE;
}
});
}
public static Iterable<ConduitDisplayMode> getRenderableModes() {
return FluentIterable.from(registrar).filter(new Predicate<ConduitDisplayMode>() {
@Override
public boolean apply(ConduitDisplayMode input) {
return input != ALL && input != NONE;
}
});
}
@Override
public String toString() {
return getName();
}
@Override
public String toString() {
return getName();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((conduitType == null) ? 0 : conduitType.hashCode());
result = prime * result + ((overrideName == null) ? 0 : overrideName.hashCode());
return result;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((conduitType == null) ? 0 : conduitType.hashCode());
result = prime * result + ((overrideName == null) ? 0 : overrideName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ConduitDisplayMode other = (ConduitDisplayMode) obj;
if (conduitType == null) {
if (other.conduitType != null)
return false;
} else if (!conduitType.equals(other.conduitType))
return false;
if (overrideName == null) {
if (other.overrideName != null)
return false;
} else if (!overrideName.equals(other.overrideName))
return false;
return true;
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
ConduitDisplayMode other = (ConduitDisplayMode) obj;
if (conduitType == null) {
if (other.conduitType != null) return false;
} else if (!conduitType.equals(other.conduitType)) return false;
if (overrideName == null) {
if (other.overrideName != null) return false;
} else if (!overrideName.equals(other.overrideName)) return false;
return true;
}
}
@@ -10,58 +10,54 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
public class ConduitNetworkTickHandler {
public static final ConduitNetworkTickHandler instance = new ConduitNetworkTickHandler();
public interface TickListener {
public static interface TickListener {
public void tickStart(TickEvent.ServerTickEvent evt);
void tickStart(TickEvent.ServerTickEvent evt);
public void tickEnd(TickEvent.ServerTickEvent evt);
}
private final List<TickListener> listeners = new ArrayList<TickListener>();
private final IdentityHashMap<AbstractConduitNetwork<?,?>, Boolean> networks =
new IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean>();
public void addListener(TickListener listener) {
listeners.add(listener);
}
public void removeListener(TickListener listener) {
listeners.remove(listener);
}
public void registerNetwork(AbstractConduitNetwork<?,?> cn) {
networks.put(cn, Boolean.TRUE);
}
public void unregisterNetwork(AbstractConduitNetwork<?,?> cn) {
networks.remove(cn);
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if(event.phase == Phase.START) {
tickStart(event);
} else {
tickEnd(event);
void tickEnd(TickEvent.ServerTickEvent evt);
}
}
public void tickStart(TickEvent.ServerTickEvent event) {
for (TickListener h : listeners) {
h.tickStart(event);
}
}
private final List<TickListener> listeners = new ArrayList<>();
private final IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean> networks = new IdentityHashMap<>();
public void tickEnd(TickEvent.ServerTickEvent event) {
for (TickListener h : listeners) {
h.tickEnd(event);
public void addListener(TickListener listener) {
listeners.add(listener);
}
listeners.clear();
for(AbstractConduitNetwork<?,?> cn : networks.keySet()) {
cn.doNetworkTick();
}
}
public void removeListener(TickListener listener) {
listeners.remove(listener);
}
public void registerNetwork(AbstractConduitNetwork<?, ?> cn) {
networks.put(cn, Boolean.TRUE);
}
public void unregisterNetwork(AbstractConduitNetwork<?, ?> cn) {
networks.remove(cn);
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == Phase.START) {
tickStart(event);
} else {
tickEnd(event);
}
}
public void tickStart(TickEvent.ServerTickEvent event) {
for (TickListener h : listeners) {
h.tickStart(event);
}
}
public void tickEnd(TickEvent.ServerTickEvent event) {
for (TickListener h : listeners) {
h.tickEnd(event);
}
listeners.clear();
for (AbstractConduitNetwork<?, ?> cn : networks.keySet()) {
cn.doNetworkTick();
}
}
}
@@ -1,11 +1,29 @@
package crazypants.enderio.conduit;
import static crazypants.enderio.ModObject.blockPainter;
import static crazypants.enderio.material.Alloy.CONDUCTIVE_IRON;
import static crazypants.enderio.material.Alloy.ELECTRICAL_STEEL;
import static crazypants.enderio.material.Alloy.END_STEEL;
import static crazypants.enderio.material.Alloy.ENERGETIC_ALLOY;
import static crazypants.enderio.material.Alloy.PHASED_GOLD;
import static crazypants.enderio.material.Alloy.REDSTONE_ALLOY;
import static crazypants.enderio.material.Material.CONDUIT_BINDER;
import static crazypants.enderio.material.Material.PHASED_IRON_NUGGET;
import static crazypants.enderio.material.endergy.AlloyEndergy.CRUDE_STEEL;
import static crazypants.enderio.material.endergy.AlloyEndergy.CRYSTALLINE_ALLOY;
import static crazypants.enderio.material.endergy.AlloyEndergy.CRYSTALLINE_PINK_SLIME;
import static crazypants.enderio.material.endergy.AlloyEndergy.ENERGETIC_SILVER;
import static crazypants.enderio.material.endergy.AlloyEndergy.MELODIC_ALLOY;
import static crazypants.enderio.material.endergy.AlloyEndergy.STELLAR_ALLOY;
import static crazypants.util.RecipeUtil.addShaped;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import appeng.api.AEApi;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -27,215 +45,658 @@ import crazypants.enderio.material.BlockFusedQuartz;
import crazypants.enderio.material.FrankenSkull;
import crazypants.enderio.material.Material;
import static crazypants.enderio.ModObject.blockPainter;
import static crazypants.enderio.material.Alloy.*;
import static crazypants.enderio.material.endergy.AlloyEndergy.*;
import static crazypants.enderio.material.Material.*;
import static crazypants.util.RecipeUtil.addShaped;
public class ConduitRecipes {
public static void addRecipes() {
public static void addRecipes() {
//Crafting Components
ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 0);
// Crafting Components
ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 0);
ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0);
ItemStack fusedGlass = new ItemStack(EnderIO.blockFusedQuartz, 1, BlockFusedQuartz.Type.GLASS.ordinal());
ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0);
ItemStack fusedGlass = new ItemStack(EnderIO.blockFusedQuartz, 1, BlockFusedQuartz.Type.GLASS.ordinal());
String crudeSteel = CRUDE_STEEL.getOreIngot();
String energeticSilver = ENERGETIC_SILVER.getOreIngot();
String crystallineAlloy = CRYSTALLINE_ALLOY.getOreIngot();
String crystallinePinkSlime = CRYSTALLINE_PINK_SLIME.getOreIngot();
String melodicAlloy = MELODIC_ALLOY.getOreIngot();
String stellarAlloy = STELLAR_ALLOY.getOreIngot();
String crudeSteel = CRUDE_STEEL.getOreIngot();
String energeticSilver = ENERGETIC_SILVER.getOreIngot();
String crystallineAlloy = CRYSTALLINE_ALLOY.getOreIngot();
String crystallinePinkSlime = CRYSTALLINE_PINK_SLIME.getOreIngot();
String melodicAlloy = MELODIC_ALLOY.getOreIngot();
String stellarAlloy = STELLAR_ALLOY.getOreIngot();
String electricalSteel = ELECTRICAL_STEEL.getOreIngot();
String phasedGold = PHASED_GOLD.getOreIngot();
String conductiveIron = CONDUCTIVE_IRON.getOreIngot();
String energeticGold = ENERGETIC_ALLOY.getOreIngot();
String phasedIronNugget = PHASED_IRON_NUGGET.oreDict;
String redstoneAlloy = REDSTONE_ALLOY.getOreIngot();
String electricalSteel = ELECTRICAL_STEEL.getOreIngot();
String phasedGold = PHASED_GOLD.getOreIngot();
String conductiveIron = CONDUCTIVE_IRON.getOreIngot();
String energeticGold = ENERGETIC_ALLOY.getOreIngot();
String phasedIronNugget = PHASED_IRON_NUGGET.oreDict;
String redstoneAlloy = REDSTONE_ALLOY.getOreIngot();
String binder = CONDUIT_BINDER.oreDict;
String binder = CONDUIT_BINDER.oreDict;
ItemStack zombieController = new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.ZOMBIE_CONTROLLER.ordinal());
ItemStack skeletalContractor = new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.SKELETAL_CONTRACTOR.ordinal());
ItemStack zombieController = new ItemStack(
EnderIO.itemFrankenSkull,
1,
FrankenSkull.ZOMBIE_CONTROLLER.ordinal());
ItemStack skeletalContractor = new ItemStack(
EnderIO.itemFrankenSkull,
1,
FrankenSkull.SKELETAL_CONTRACTOR.ordinal());
//Recipes
addShaped(new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.BASIC.ordinal()), "bbb", "b b", "bbb", 'b', binder);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.HARDENED.ordinal()), " o ", "oFo", " o ", 'F',
EnderIO.itemConduitFacade, 'o', "dustObsidian"));
// Recipes
addShaped(
new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.BASIC.ordinal()),
"bbb",
"b b",
"bbb",
'b',
binder);
GameRegistry.addRecipe(
new ShapedOreRecipe(
new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.HARDENED.ordinal()),
" o ",
"oFo",
" o ",
'F',
EnderIO.itemConduitFacade,
'o',
"dustObsidian"));
int numConduits = Config.numConduitsPerRecipe;
addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 0), "bbb", "###", "bbb", 'b', binder, '#', fusedGlass);
addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 1), "bbb", "###", "bbb", 'b', binder, '#', fusedQuartz);
addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, EnderLiquidConduit.METADATA), "bbb", "#p#", "bbb", 'b', binder, '#', fusedQuartz, 'p', phasedGold);
addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, CrystallineEnderLiquidConduit.METADATA), "bbb", "#p#", "bbb", 'b', binder, '#', fusedQuartz, 'p', crystallineAlloy);
addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, CrystallinePinkSlimeEnderLiquidConduit.METADATA), "bbb", "#p#", "bbb", 'b', binder, '#', fusedQuartz, 'p', crystallinePinkSlime);
addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, MelodicEnderLiquidConduit.METADATA), "bbb", "#p#", "bbb", 'b', binder, '#', fusedQuartz, 'p', melodicAlloy);
addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, StellarEnderLiquidConduit.METADATA), "bbb", "#p#", "bbb", 'b', binder, '#', fusedQuartz, 'p', stellarAlloy);
addShaped(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 0), "###", '#', redstoneAlloy);
addShaped(new ItemStack(EnderIO.itemRedstoneConduit, 1, 1), "lbl", "bcb", "lbl", 'b', binder, 'c', redstoneConduit, 'l', Blocks.lever);
addShaped(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 2), "bbb", "###", "bbb", 'b', binder, '#', redstoneAlloy);
int numConduits = Config.numConduitsPerRecipe;
addShaped(
new ItemStack(EnderIO.itemLiquidConduit, numConduits, 0),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
fusedGlass);
addShaped(
new ItemStack(EnderIO.itemLiquidConduit, numConduits, 1),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
fusedQuartz);
addShaped(
new ItemStack(EnderIO.itemLiquidConduit, numConduits, EnderLiquidConduit.METADATA),
"bbb",
"#p#",
"bbb",
'b',
binder,
'#',
fusedQuartz,
'p',
phasedGold);
addShaped(
new ItemStack(EnderIO.itemLiquidConduit, numConduits, CrystallineEnderLiquidConduit.METADATA),
"bbb",
"#p#",
"bbb",
'b',
binder,
'#',
fusedQuartz,
'p',
crystallineAlloy);
addShaped(
new ItemStack(EnderIO.itemLiquidConduit, numConduits, CrystallinePinkSlimeEnderLiquidConduit.METADATA),
"bbb",
"#p#",
"bbb",
'b',
binder,
'#',
fusedQuartz,
'p',
crystallinePinkSlime);
addShaped(
new ItemStack(EnderIO.itemLiquidConduit, numConduits, MelodicEnderLiquidConduit.METADATA),
"bbb",
"#p#",
"bbb",
'b',
binder,
'#',
fusedQuartz,
'p',
melodicAlloy);
addShaped(
new ItemStack(EnderIO.itemLiquidConduit, numConduits, StellarEnderLiquidConduit.METADATA),
"bbb",
"#p#",
"bbb",
'b',
binder,
'#',
fusedQuartz,
'p',
stellarAlloy);
addShaped(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 0), "###", '#', redstoneAlloy);
addShaped(
new ItemStack(EnderIO.itemRedstoneConduit, 1, 1),
"lbl",
"bcb",
"lbl",
'b',
binder,
'c',
redstoneConduit,
'l',
Blocks.lever);
addShaped(
new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 2),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
redstoneAlloy);
if(Config.useHardRecipes) {
if (Config.useHardRecipes) {
ItemStack lastTier;
ItemStack lastTier;
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 0), "bbb", "###", "bbb", 'b', binder, '#', crudeSteel);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 0);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 0),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
crudeSteel);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 0);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 1), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', "ingotIron");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 1);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 1),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
"ingotIron");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 1);
if(OreDictionary.doesOreNameExist("ingotAluminum")||OreDictionary.doesOreNameExist("ingotAluminium")) {
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 2), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', "ingotAluminum");
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 2), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', "ingotAluminium");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 2);
if (OreDictionary.doesOreNameExist("ingotAluminum") || OreDictionary.doesOreNameExist("ingotAluminium")) {
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 2),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
"ingotAluminum");
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 2),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
"ingotAluminium");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 2);
}
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 3),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
"ingotGold");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 3);
if (OreDictionary.doesOreNameExist("ingotCopper") && OreDictionary.getOres("ingotCopper").size() > 0) {
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 4),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
"ingotCopper");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 4);
}
addShaped(
new ItemStack(EnderIO.itemPowerConduit, numConduits, 0),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
conductiveIron);
lastTier = new ItemStack(EnderIO.itemPowerConduit, 1, 0);
if (OreDictionary.doesOreNameExist("ingotSilver")) {
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 5),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
"ingotSilver");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 5);
}
if (OreDictionary.doesOreNameExist("ingotElectrum")) {
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 6),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
"ingotElectrum");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 6);
}
addShaped(
new ItemStack(EnderIO.itemPowerConduit, numConduits, 1),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
energeticGold);
lastTier = new ItemStack(EnderIO.itemPowerConduit, 1, 1);
if (OreDictionary.doesOreNameExist("ingotSilver")) {
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 7),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
energeticSilver);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 7);
}
addShaped(
new ItemStack(EnderIO.itemPowerConduit, numConduits, 2),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
phasedGold);
lastTier = new ItemStack(EnderIO.itemPowerConduit, 1, 2);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 8),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
crystallineAlloy);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 8);
if (OreDictionary.doesOreNameExist("slimeballPink")) {
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 9),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
crystallinePinkSlime);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 9);
}
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 10),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
melodicAlloy);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 10);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 11),
"b#b",
"ccc",
"b#b",
'c',
lastTier,
'b',
binder,
'#',
stellarAlloy);
} else {
addShaped(
new ItemStack(EnderIO.itemPowerConduit, numConduits, 0),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
conductiveIron);
addShaped(
new ItemStack(EnderIO.itemPowerConduit, numConduits, 1),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
energeticGold);
addShaped(
new ItemStack(EnderIO.itemPowerConduit, numConduits, 2),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
phasedGold);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 0),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
crudeSteel);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 1),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
"ingotIron");
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 2),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
"ingotAluminum");
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 3),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
"ingotGold");
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 4),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
"ingotCopper");
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 5),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
"ingotSilver");
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 6),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
"ingotElectrum");
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 7),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
energeticSilver);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 8),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
crystallineAlloy);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 9),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
crystallinePinkSlime);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 10),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
melodicAlloy);
addShaped(
new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 11),
"bbb",
"###",
"bbb",
'b',
binder,
'#',
stellarAlloy);
}
if (GasUtil.isGasConduitEnabled()) {
addShaped(
new ItemStack(EnderIO.itemGasConduit, numConduits, 0),
"bbb",
"#g#",
"bbb",
'b',
binder,
'#',
electricalSteel,
'g',
fusedGlass);
}
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 3), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', "ingotGold");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 3);
ItemStack itemConduit = new ItemStack(EnderIO.itemItemConduit, numConduits, 0);
addShaped(itemConduit, "bbb", "###", "bbb", 'b', binder, '#', phasedIronNugget);
if(OreDictionary.doesOreNameExist("ingotCopper") && OreDictionary.getOres("ingotCopper").size()>0) {
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 4), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', "ingotCopper");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 4);
}
MachineRecipeRegistry.instance
.registerRecipe(blockPainter.unlocalisedName, EnderIO.itemConduitFacade.new FacadePainterRecipe());
addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 0), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', conductiveIron);
lastTier = new ItemStack(EnderIO.itemPowerConduit, 1, 0);
// Filter Recipes
ItemStack basicFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 0);
addShaped(basicFilter, " p ", "php", " p ", 'p', Items.paper, 'h', Blocks.hopper);
if(OreDictionary.doesOreNameExist("ingotSilver")) {
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 5), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', "ingotSilver");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 5);
}
ItemStack advFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 1);
addShaped(advFilter, "rpr", "pzp", "rpr", 'p', Items.paper, 'z', zombieController, 'r', "dustRedstone");
if(OreDictionary.doesOreNameExist("ingotElectrum")) {
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 6), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', "ingotElectrum");
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 6);
}
ItemStack bigFilter = new ItemStack(EnderIO.itemBigFilterUpgrade, 1, 0);
addShaped(bigFilter, "opo", "psp", "opo", 'p', Items.paper, 's', skeletalContractor, 'o', "dustObsidian");
addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 1), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', energeticGold);
lastTier = new ItemStack(EnderIO.itemPowerConduit, 1, 1);
ItemStack bigAdvFilter = new ItemStack(EnderIO.itemBigFilterUpgrade, 1, 1);
addShaped(bigAdvFilter, "eme", "mfm", "eme", 'm', melodicAlloy, 'f', bigFilter, 'e', END_STEEL.getOreIngot());
if(OreDictionary.doesOreNameExist("ingotSilver")) {
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 7), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', energeticSilver);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 7);
}
ItemStack modFilter = new ItemStack(EnderIO.itemModItemFilter, 1, 0);
addShaped(modFilter, " p ", "pwp", " p ", 'p', Items.paper, 'w', EnderIO.itemYetaWench);
addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 2), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', phasedGold);
lastTier = new ItemStack(EnderIO.itemPowerConduit, 1, 2);
ItemStack exFilt = new ItemStack(EnderIO.itemExistingItemFilter);
addShaped(
exFilt,
" r ",
"rfr",
" c ",
'c',
new ItemStack(Items.comparator, 1, 0),
'r',
"dustRedstone",
'f',
advFilter);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 8), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', crystallineAlloy);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 8);
ItemStack limitedFilter = new ItemStack(EnderIO.itemLimitedItemFilter, 1, 0);
addShaped(limitedFilter, " ", "cfc", " ", 'c', new ItemStack(Items.comparator, 1, 0), 'f', advFilter);
if(OreDictionary.doesOreNameExist("slimeballPink")) {
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 9), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', crystallinePinkSlime);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 9);
}
ItemStack powerFilt = new ItemStack(EnderIO.itemPowerItemFilter);
addShaped(powerFilt, " p ", "pcp", " p ", 'p', Items.paper, 'c', EnderIO.itemConduitProbe);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 10), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', melodicAlloy);
lastTier = new ItemStack(EnderIO.itemPowerConduitEndergy, 1, 10);
ClearFilterRecipe clearRec = new ClearFilterRecipe();
MinecraftForge.EVENT_BUS.register(clearRec);
GameRegistry.addRecipe(clearRec);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 11), "b#b", "ccc", "b#b", 'c', lastTier, 'b', binder, '#', stellarAlloy);
CopyFilterRecipe copyRec = new CopyFilterRecipe();
GameRegistry.addRecipe(copyRec);
ItemStack speedUpgrade = new ItemStack(EnderIO.itemExtractSpeedUpgrade, 1, 0);
addShaped(
speedUpgrade,
"iii",
"epe",
"ere",
'p',
Blocks.piston,
'e',
electricalSteel,
'r',
Blocks.redstone_torch,
'i',
"ingotIron");
ItemStack speedDowngrade = new ItemStack(EnderIO.itemExtractSpeedUpgrade, 1, 1);
addShaped(
speedDowngrade,
"iii",
"ese",
"ete",
's',
"slimeball",
'e',
electricalSteel,
't',
"stickWood",
'i',
"ingotIron");
addShaped(
speedDowngrade,
"iii",
"ese",
"ete",
's',
"slimeball",
'e',
electricalSteel,
't',
"woodStick",
'i',
"ingotIron");
if (MEUtil.isMEEnabled()) {
addAeRecipes();
}
if (OCUtil.isOCEnabled()) {
addOCRecipes();
}
}
else {
addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 0), "bbb", "###", "bbb", 'b', binder, '#', conductiveIron);
addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 1), "bbb", "###", "bbb", 'b', binder, '#', energeticGold);
addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 2), "bbb", "###", "bbb", 'b', binder, '#', phasedGold);
private static void addOCRecipes() {
int numConduits = Config.numConduitsPerRecipe;
String redstoneAlloy = REDSTONE_ALLOY.getOreIngot();
String binder = CONDUIT_BINDER.oreDict;
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 0), "bbb", "###", "bbb", 'b', binder, '#', crudeSteel);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 1), "bbb", "###", "bbb", 'b', binder, '#', "ingotIron");
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 2), "bbb", "###", "bbb", 'b', binder, '#', "ingotAluminum");
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 3), "bbb", "###", "bbb", 'b', binder, '#', "ingotGold");
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 4), "bbb", "###", "bbb", 'b', binder, '#', "ingotCopper");
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 5), "bbb", "###", "bbb", 'b', binder, '#', "ingotSilver");
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 6), "bbb", "###", "bbb", 'b', binder, '#', "ingotElectrum");
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 7), "bbb", "###", "bbb", 'b', binder, '#', energeticSilver);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 8), "bbb", "###", "bbb", 'b', binder, '#', crystallineAlloy);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 9), "bbb", "###", "bbb", 'b', binder, '#', crystallinePinkSlime);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 10), "bbb", "###", "bbb", 'b', binder, '#', melodicAlloy);
addShaped(new ItemStack(EnderIO.itemPowerConduitEndergy, numConduits, 11), "bbb", "###", "bbb", 'b', binder, '#', stellarAlloy);
}
if (GasUtil.isGasConduitEnabled()) {
addShaped(new ItemStack(EnderIO.itemGasConduit, numConduits, 0), "bbb", "#g#", "bbb", 'b', binder, '#', electricalSteel, 'g', fusedGlass);
addShaped(
new ItemStack(EnderIO.itemOCConduit, numConduits, 0),
"bbb",
"rir",
"bbb",
'b',
binder,
'r',
redstoneAlloy,
'i',
"ingotIron");
}
ItemStack itemConduit = new ItemStack(EnderIO.itemItemConduit, numConduits, 0);
addShaped(itemConduit, "bbb", "###", "bbb", 'b', binder, '#', phasedIronNugget);
@Method(modid = "appliedenergistics2")
private static void addAeRecipes() {
String fluix = "crystalFluix";
String pureFluix = "crystalPureFluix";
MachineRecipeRegistry.instance.registerRecipe(blockPainter.unlocalisedName, EnderIO.itemConduitFacade.new FacadePainterRecipe());
ItemStack quartzFiber = AEApi.instance().definitions().parts().quartzFiber().maybeStack(1).get().copy();
ItemStack conduitBinder = new ItemStack(EnderIO.itemMaterial, 1, Material.CONDUIT_BINDER.ordinal());
ItemStack res = new ItemStack(EnderIO.itemMEConduit, Config.numConduitsPerRecipe / 2);
//Filter Recipes
ItemStack basicFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 0);
addShaped(basicFilter, " p ", "php", " p ", 'p', Items.paper, 'h', Blocks.hopper);
addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', fluix, 'q', quartzFiber);
addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', pureFluix, 'q', quartzFiber);
ItemStack advFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 1);
addShaped(advFilter, "rpr", "pzp", "rpr", 'p', Items.paper, 'z', zombieController, 'r', "dustRedstone");
ItemStack bigFilter = new ItemStack(EnderIO.itemBigFilterUpgrade, 1, 0);
addShaped(bigFilter, "opo", "psp", "opo", 'p', Items.paper, 's', skeletalContractor, 'o', "dustObsidian");
ItemStack bigAdvFilter = new ItemStack(EnderIO.itemBigFilterUpgrade, 1, 1);
addShaped(bigAdvFilter, "eme", "mfm", "eme", 'm', melodicAlloy, 'f', bigFilter, 'e', END_STEEL.getOreIngot());
ItemStack modFilter = new ItemStack(EnderIO.itemModItemFilter, 1, 0);
addShaped(modFilter, " p ", "pwp", " p ", 'p', Items.paper, 'w', EnderIO.itemYetaWench);
ItemStack exFilt = new ItemStack(EnderIO.itemExistingItemFilter);
addShaped(exFilt, " r ", "rfr", " c ", 'c', new ItemStack(Items.comparator, 1, 0), 'r', "dustRedstone", 'f', advFilter);
ItemStack powerFilt = new ItemStack(EnderIO.itemPowerItemFilter);
addShaped(powerFilt, " p ", "pcp", " p ", 'p', Items.paper, 'c', EnderIO.itemConduitProbe);
ClearFilterRecipe clearRec = new ClearFilterRecipe();
MinecraftForge.EVENT_BUS.register(clearRec);
GameRegistry.addRecipe(clearRec);
CopyFilterRecipe copyRec = new CopyFilterRecipe();
GameRegistry.addRecipe(copyRec);
ItemStack speedUpgrade = new ItemStack(EnderIO.itemExtractSpeedUpgrade, 1, 0);
addShaped(speedUpgrade, "iii", "epe", "ere", 'p', Blocks.piston, 'e', electricalSteel, 'r', Blocks.redstone_torch, 'i', "ingotIron");
ItemStack speedDowngrade = new ItemStack(EnderIO.itemExtractSpeedUpgrade, 1, 1);
addShaped(speedDowngrade, "iii", "ese", "ete", 's', "slimeball", 'e', electricalSteel, 't', "stickWood", 'i', "ingotIron");
addShaped(speedDowngrade, "iii", "ese", "ete", 's', "slimeball", 'e', electricalSteel, 't', "woodStick", 'i', "ingotIron");
if (MEUtil.isMEEnabled()) {
addAeRecipes();
res.stackSize = 1;
ItemStack resDense = new ItemStack(EnderIO.itemMEConduit, 1, 1);
addShaped(resDense, "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', res);
}
if (OCUtil.isOCEnabled()) {
addOCRecipes();
}
}
private static void addOCRecipes() {
int numConduits = Config.numConduitsPerRecipe;
String redstoneAlloy = REDSTONE_ALLOY.getOreIngot();
String binder = CONDUIT_BINDER.oreDict;
addShaped(new ItemStack(EnderIO.itemOCConduit, numConduits, 0), "bbb", "rir", "bbb", 'b', binder, 'r', redstoneAlloy, 'i',
"ingotIron");
}
@Method(modid = "appliedenergistics2")
private static void addAeRecipes() {
String fluix = "crystalFluix";
String pureFluix = "crystalPureFluix";
ItemStack quartzFiber = AEApi.instance().parts().partQuartzFiber.stack(1).copy();
ItemStack conduitBinder = new ItemStack(EnderIO.itemMaterial, 1, Material.CONDUIT_BINDER.ordinal());
ItemStack res = new ItemStack(EnderIO.itemMEConduit, Config.numConduitsPerRecipe / 2);
addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', fluix, 'q', quartzFiber);
addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', pureFluix, 'q', quartzFiber);
res.stackSize = 1;
addShaped(new ItemStack(EnderIO.itemMEConduit, 1, 1), "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', res);
}
}
@@ -41,380 +41,425 @@ import crazypants.enderio.tool.ToolUtil;
public class ConduitUtil {
public static final Random RANDOM = new Random();
public static final Random RANDOM = new Random();
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void ensureValidNetwork(IConduit conduit) {
TileEntity te = conduit.getBundle().getEntity();
World world = te.getWorldObj();
Collection<? extends IConduit> connections = ConduitUtil.getConnectedConduits(world, te.xCoord, te.yCoord, te.zCoord, conduit.getBaseConduitType());
@SuppressWarnings("unchecked")
public static void ensureValidNetwork(IConduit conduit) {
TileEntity te = conduit.getBundle().getEntity();
World world = te.getWorldObj();
Collection<? extends IConduit> connections = ConduitUtil
.getConnectedConduits(world, te.xCoord, te.yCoord, te.zCoord, conduit.getBaseConduitType());
if(reuseNetwork(conduit, connections, world)) {
return;
if (reuseNetwork(conduit, connections, world)) {
return;
}
@SuppressWarnings("rawtypes")
AbstractConduitNetwork res = conduit.createNetworkForType();
res.init(conduit.getBundle(), connections, world);
return;
}
AbstractConduitNetwork res = conduit.createNetworkForType();
res.init(conduit.getBundle(), connections, world);
return;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private static boolean reuseNetwork(IConduit con, Collection<? extends IConduit> connections, World world) {
AbstractConduitNetwork network = null;
for (IConduit conduit : connections) {
if(network == null) {
network = conduit.getNetwork();
} else if(network != conduit.getNetwork()) {
@SuppressWarnings("unchecked")
private static boolean reuseNetwork(IConduit con, Collection<? extends IConduit> connections, World world) {
@SuppressWarnings("rawtypes")
AbstractConduitNetwork network = null;
for (IConduit conduit : connections) {
if (network == null) {
network = conduit.getNetwork();
} else if (network != conduit.getNetwork()) {
return false;
}
}
if (network == null) {
return false;
}
if (con.setNetwork(network)) {
network.addConduit(con);
network.notifyNetworkOfUpdate();
return true;
}
return false;
}
}
if(network == null) {
return false;
}
if(con.setNetwork(network)) {
network.addConduit(con);
network.notifyNetworkOfUpdate();
return true;
}
return false;
}
public static <T extends IConduit> void disconectConduits(T con, ForgeDirection connDir) {
con.conduitConnectionRemoved(connDir);
BlockCoord loc = con.getLocation().getLocation(connDir);
IConduit neighbour = ConduitUtil.getConduit(con.getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, con.getBaseConduitType());
if(neighbour != null) {
neighbour.conduitConnectionRemoved(connDir.getOpposite());
if(neighbour.getNetwork() != null) {
neighbour.getNetwork().destroyNetwork();
}
}
if(con.getNetwork() != null) { //this should have been destroyed when destroying the neighbours network but lets just make sure
con.getNetwork().destroyNetwork();
}
con.connectionsChanged();
if(neighbour != null) {
neighbour.connectionsChanged();
}
}
public static <T extends IConduit> boolean joinConduits(T con, ForgeDirection faceHit) {
BlockCoord loc = con.getLocation().getLocation(faceHit);
IConduit neighbour = ConduitUtil.getConduit(con.getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, con.getBaseConduitType());
if(neighbour != null && con.canConnectToConduit(faceHit, neighbour) && neighbour.canConnectToConduit(faceHit.getOpposite(), con)) {
con.conduitConnectionAdded(faceHit);
neighbour.conduitConnectionAdded(faceHit.getOpposite());
if(con.getNetwork() != null) {
con.getNetwork().destroyNetwork();
}
if(neighbour.getNetwork() != null) {
neighbour.getNetwork().destroyNetwork();
}
con.connectionsChanged();
neighbour.connectionsChanged();
return true;
}
return false;
}
public static boolean forceSkylightRecalculation(World worldObj, int xCoord, int yCoord, int zCoord) {
int height = worldObj.getHeightValue(xCoord, zCoord);
if(height <= yCoord) {
for (int i = 1; i < 12; i++) {
if(worldObj.isAirBlock(xCoord, yCoord + i, zCoord)) {
//We need to force the re-lighting of the column due to a change
//in the light reaching bellow the block from the sky. To avoid
//modifying core classes to expose this functionality I am just placing then breaking
//a block above this one to force the check
worldObj.setBlock(xCoord, yCoord + i, zCoord, Blocks.stone, 0, 3);
worldObj.setBlockToAir(xCoord, yCoord + i, zCoord);
return true;
public static <T extends IConduit> void disconectConduits(T con, ForgeDirection connDir) {
con.conduitConnectionRemoved(connDir);
BlockCoord loc = con.getLocation().getLocation(connDir);
IConduit neighbour = ConduitUtil
.getConduit(con.getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, con.getBaseConduitType());
if (neighbour != null) {
neighbour.conduitConnectionRemoved(connDir.getOpposite());
if (neighbour.getNetwork() != null) {
neighbour.getNetwork().destroyNetwork();
}
}
if (con.getNetwork() != null) { // this should have been destroyed when destroying the neighbours network but
// lets just make
// sure
con.getNetwork().destroyNetwork();
}
con.connectionsChanged();
if (neighbour != null) {
neighbour.connectionsChanged();
}
}
}
return false;
}
@SideOnly(Side.CLIENT)
public static FacadeRenderState getRequiredFacadeRenderState(IConduitBundle bundle, EntityPlayer player) {
if(!bundle.hasFacade()) {
return FacadeRenderState.NONE;
}
if(isFacadeHidden(bundle, player)) {
return FacadeRenderState.WIRE_FRAME;
}
return FacadeRenderState.FULL;
}
public static boolean isSolidFacadeRendered(IConduitBundle bundle, EntityPlayer player) {
return bundle.getFacadeId() != null && !isFacadeHidden(bundle, player);
}
public static boolean isFacadeHidden(IConduitBundle bundle, EntityPlayer player) {
return bundle.getFacadeId() != null && shouldHeldItemHideFacades(player);
}
public static ConduitDisplayMode getDisplayMode(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if(player == null) {
return ConduitDisplayMode.ALL;
}
ItemStack equipped = player.getCurrentEquippedItem();
if(equipped == null) {
return ConduitDisplayMode.ALL;
}
ConduitDisplayMode result = ConduitDisplayMode.getDisplayMode(equipped);
if(result == null) {
return ConduitDisplayMode.ALL;
public static <T extends IConduit> boolean joinConduits(T con, ForgeDirection faceHit) {
BlockCoord loc = con.getLocation().getLocation(faceHit);
IConduit neighbour = ConduitUtil
.getConduit(con.getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, con.getBaseConduitType());
if (neighbour != null && con.canConnectToConduit(faceHit, neighbour)
&& neighbour.canConnectToConduit(faceHit.getOpposite(), con)) {
con.conduitConnectionAdded(faceHit);
neighbour.conduitConnectionAdded(faceHit.getOpposite());
if (con.getNetwork() != null) {
con.getNetwork().destroyNetwork();
}
if (neighbour.getNetwork() != null) {
neighbour.getNetwork().destroyNetwork();
}
con.connectionsChanged();
neighbour.connectionsChanged();
return true;
}
return false;
}
return result;
}
public static boolean renderConduit(EntityPlayer player, IConduit con) {
if(player == null || con == null) {
return true;
}
return renderConduit(player, con.getBaseConduitType());
}
public static boolean forceSkylightRecalculation(World worldObj, int xCoord, int yCoord, int zCoord) {
int height = worldObj.getHeightValue(xCoord, zCoord);
if (height <= yCoord) {
for (int i = 1; i < 12; i++) {
if (worldObj.isAirBlock(xCoord, yCoord + i, zCoord)) {
// We need to force the re-lighting of the column due to a change
// in the light reaching bellow the block from the sky. To avoid
// modifying core classes to expose this functionality I am just placing then breaking
// a block above this one to force the check
worldObj.setBlock(xCoord, yCoord + i, zCoord, Blocks.stone, 0, 3);
worldObj.setBlockToAir(xCoord, yCoord + i, zCoord);
public static boolean renderConduit(EntityPlayer player, Class<? extends IConduit> conduitType) {
if(player == null || conduitType == null) {
return true;
return true;
}
}
}
return false;
}
ConduitDisplayMode mode = getDisplayMode(player);
return mode.renderConduit(conduitType);
}
public static boolean shouldHeldItemHideFacades(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if(player == null) {
return false;
@SideOnly(Side.CLIENT)
public static FacadeRenderState getRequiredFacadeRenderState(IConduitBundle bundle, EntityPlayer player) {
if (!bundle.hasFacade()) {
return FacadeRenderState.NONE;
}
if (isFacadeHidden(bundle, player)) {
return FacadeRenderState.WIRE_FRAME;
}
return FacadeRenderState.FULL;
}
ItemStack held = player.getCurrentEquippedItem();
if(held != null && held.getItem() instanceof IHideFacades) {
return ((IHideFacades) held.getItem()).shouldHideFacades(held, player);
}
return ToolUtil.isToolEquipped(player);
}
public static boolean isConduitEquipped(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if(player == null) {
return false;
public static boolean isSolidFacadeRendered(IConduitBundle bundle, EntityPlayer player) {
return bundle.getFacadeId() != null && !isFacadeHidden(bundle, player);
}
ItemStack equipped = player.getCurrentEquippedItem();
if(equipped == null) {
return false;
}
return equipped.getItem() instanceof IConduitItem;
}
public static boolean isProbeEquipped(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if(player == null) {
return false;
public static boolean isFacadeHidden(IConduitBundle bundle, EntityPlayer player) {
return bundle != null && bundle.getFacadeId() != null && shouldHeldItemHideFacades(player);
}
ItemStack equipped = player.getCurrentEquippedItem();
if(equipped == null) {
return false;
}
return equipped.getItem() == EnderIO.itemConduitProbe;
}
public static <T extends IConduit> T getConduit(World world, int x, int y, int z, Class<T> type) {
if(world == null || !world.blockExists(x, y, z)) {
return null;
}
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof IConduitBundle) {
IConduitBundle con = (IConduitBundle) te;
return con.getConduit(type);
}
return null;
}
public static <T extends IConduit> T getConduit(World world, TileEntity te, ForgeDirection dir, Class<T> type) {
return ConduitUtil.getConduit(world, te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, type);
}
public static <T extends IConduit> Collection<T> getConnectedConduits(World world, int x, int y, int z, Class<T> type) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof IConduitBundle)) {
return Collections.emptyList();
}
List<T> result = new ArrayList<T>();
IConduitBundle root = (IConduitBundle) te;
T con = root.getConduit(type);
if(con != null) {
for (ForgeDirection dir : con.getConduitConnections()) {
T connected = getConduit(world, root.getEntity(), dir, type);
if(connected != null) {
result.add(connected);
public static ConduitDisplayMode getDisplayMode(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if (player == null) {
return ConduitDisplayMode.ALL;
}
ItemStack equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return ConduitDisplayMode.ALL;
}
}
}
return result;
}
public static void writeToNBT(IConduit conduit, NBTTagCompound conduitRoot) {
if(conduit == null) {
return;
}
NBTTagCompound conduitBody = new NBTTagCompound();
conduit.writeToNBT(conduitBody);
conduitRoot.setString("conduitType", conduit.getClass().getCanonicalName());
conduitRoot.setTag("conduit", conduitBody);
}
public static IConduit readConduitFromNBT(NBTTagCompound conduitRoot, short nbtVersion) {
String typeName = conduitRoot.getString("conduitType");
NBTTagCompound conduitBody = conduitRoot.getCompoundTag("conduit");
if(typeName == null || conduitBody == null) {
return null;
}
if ((typeName.contains("conduit.oc") && !OCUtil.isOCEnabled()) || (typeName.contains("conduit.me") && !MEUtil.isMEEnabled())
|| (typeName.contains("conduit.gas") && !GasUtil.isGasConduitEnabled())) {
return null;
}
if (nbtVersion == 0 && "crazypants.enderio.conduit.liquid.LiquidConduit".equals(typeName)) {
Log.debug("ConduitUtil.readConduitFromNBT: Converted pre 0.7.3 fluid conduit to advanced fluid conduit.");
typeName = "crazypants.enderio.conduit.liquid.AdvancedLiquidConduit";
} else if ("crazypants.enderio.conduit.liquid.AdvancedEnderLiquidConduit".equals(typeName)) {
Log.debug("ConduitUtil.readConduitFromNBT: Converted advanced ender fluid conduit to crystalline ender fluid conduit.");
typeName = "crazypants.enderio.conduit.liquid.CrystallineEnderLiquidConduit";
}
IConduit result;
try {
result = (IConduit) Class.forName(typeName).newInstance();
} catch (Exception e) {
throw new RuntimeException("Could not create an instance of the conduit with name: " + typeName, e);
}
result.readFromNBT(conduitBody, nbtVersion);
return result;
}
public static boolean isRedstoneControlModeMet(IConduitBundle bundle, RedstoneControlMode mode, DyeColor col) {
if(mode == RedstoneControlMode.IGNORE) {
return true;
} else if(mode == RedstoneControlMode.NEVER) {
return false;
} else if(mode == null) {
return false;
}
int signalStrength = getInternalSignalForColor(bundle, col);
if(signalStrength < 15 && DyeColor.RED == col && bundle != null && bundle.getEntity() != null) {
TileEntity te = bundle.getEntity();
signalStrength = Math.max(signalStrength, te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord));
}
return RedstoneControlMode.isConditionMet(mode, signalStrength);
}
public static int getInternalSignalForColor(IConduitBundle bundle, DyeColor col) {
int signalStrength = 0;
if(bundle == null) {
return 0;
}
IRedstoneConduit rsCon = bundle.getConduit(IRedstoneConduit.class);
if(rsCon != null) {
Set<Signal> signals = rsCon.getNetworkOutputs(ForgeDirection.UNKNOWN);
for (Signal sig : signals) {
if(sig.color == col) {
if(sig.strength > signalStrength) {
signalStrength = sig.strength;
}
ConduitDisplayMode result = ConduitDisplayMode.getDisplayMode(equipped);
if (result == null) {
return ConduitDisplayMode.ALL;
}
}
return result;
}
return signalStrength;
}
public static boolean isFluidValid(FluidStack fluidStack) {
if(fluidStack != null) {
String name = FluidRegistry.getFluidName(fluidStack);
if(name != null && !name.trim().isEmpty()) {
return true;
}
public static boolean renderConduit(EntityPlayer player, IConduit con) {
if (player == null || con == null) {
return true;
}
return renderConduit(player, con.getBaseConduitType());
}
return false;
}
public static void openConduitGui(World world, int x, int y, int z, EntityPlayer player) {
TileEntity te = world.getTileEntity(x, y, z);
if(! (te instanceof TileConduitBundle) ) {
return;
}
IConduitBundle cb = (IConduitBundle) te;
Set<ForgeDirection> cons = new HashSet<ForgeDirection>();
boolean hasInsulated = false;
for (IConduit con : cb.getConduits()) {
cons.addAll(con.getExternalConnections());
if(con instanceof IInsulatedRedstoneConduit) {
hasInsulated = true;
}
}
if(cons.isEmpty() && !hasInsulated) {
return;
}
if(cons.size() == 1) {
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + cons.iterator().next().ordinal(), world, x, y, z);
return;
}
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_SELECTOR, world, x, y, z);
}
public static void playBreakSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, snd.getBreakSound(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
} else {
playClientBreakSound(snd);
public static boolean renderConduit(EntityPlayer player, Class<? extends IConduit> conduitType) {
if (player == null || conduitType == null) {
return true;
}
ConduitDisplayMode mode = getDisplayMode(player);
return mode.renderConduit(conduitType);
}
}
private static void playClientBreakSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity().playSound(snd.getBreakSound(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
}
public static void playHitSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
} else {
playClientHitSound(snd);
public static boolean shouldHeldItemHideFacades(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if (player == null) {
return false;
}
ItemStack held = player.getCurrentEquippedItem();
if (held != null && held.getItem() instanceof IHideFacades) {
return ((IHideFacades) held.getItem()).shouldHideFacades(held, player);
}
return ToolUtil.isToolEquipped(player);
}
}
private static void playClientHitSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity().playSound(snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch() * 0.5F);
}
public static void playStepSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
} else {
playClientStepSound(snd);
public static boolean isConduitEquipped(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if (player == null) {
return false;
}
ItemStack equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return false;
}
return equipped.getItem() instanceof IConduitItem;
}
}
private static void playClientStepSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity().playSound(snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch());
}
public static void playPlaceSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, snd.func_150496_b(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
} else {
playClientPlaceSound(snd);
public static boolean isProbeEquipped(EntityPlayer player) {
player = player == null ? EnderIO.proxy.getClientPlayer() : player;
if (player == null) {
return false;
}
ItemStack equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return false;
}
return equipped.getItem() == EnderIO.itemConduitProbe;
}
}
private static void playClientPlaceSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity().playSound(snd.func_150496_b(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch());
}
public static <T extends IConduit> T getConduit(World world, int x, int y, int z, Class<T> type) {
if (world == null || !world.blockExists(x, y, z)) {
return null;
}
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof IConduitBundle) {
IConduitBundle con = (IConduitBundle) te;
return con.getConduit(type);
}
return null;
}
public static <T extends IConduit> T getConduit(World world, TileEntity te, ForgeDirection dir, Class<T> type) {
return ConduitUtil
.getConduit(world, te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, type);
}
public static <T extends IConduit> Collection<T> getConnectedConduits(World world, int x, int y, int z,
Class<T> type) {
TileEntity te = world.blockExists(x, y, z) ? world.getTileEntity(x, y, z) : null;
if (!(te instanceof IConduitBundle)) {
return Collections.emptyList();
}
List<T> result = new ArrayList<>();
IConduitBundle root = (IConduitBundle) te;
T con = root.getConduit(type);
if (con != null) {
for (ForgeDirection dir : con.getConduitConnections()) {
T connected = getConduit(world, root.getEntity(), dir, type);
if (connected != null) {
result.add(connected);
}
}
}
return result;
}
public static void writeToNBT(IConduit conduit, NBTTagCompound conduitRoot) {
if (conduit == null) {
return;
}
NBTTagCompound conduitBody = new NBTTagCompound();
conduit.writeToNBT(conduitBody);
conduitRoot.setString("conduitType", conduit.getClass().getCanonicalName());
conduitRoot.setTag("conduit", conduitBody);
}
public static IConduit readConduitFromNBT(NBTTagCompound conduitRoot, short nbtVersion) {
String typeName = conduitRoot.getString("conduitType");
NBTTagCompound conduitBody = conduitRoot.getCompoundTag("conduit");
if (typeName == null || conduitBody == null) {
return null;
}
if ((typeName.contains("conduit.oc") && !OCUtil.isOCEnabled())
|| (typeName.contains("conduit.me") && !MEUtil.isMEEnabled())
|| (typeName.contains("conduit.gas") && !GasUtil.isGasConduitEnabled())) {
return null;
}
if (nbtVersion == 0 && "crazypants.enderio.conduit.liquid.LiquidConduit".equals(typeName)) {
Log.debug("ConduitUtil.readConduitFromNBT: Converted pre 0.7.3 fluid conduit to advanced fluid conduit.");
typeName = "crazypants.enderio.conduit.liquid.AdvancedLiquidConduit";
} else if ("crazypants.enderio.conduit.liquid.AdvancedEnderLiquidConduit".equals(typeName)) {
Log.debug(
"ConduitUtil.readConduitFromNBT: Converted advanced ender fluid conduit to crystalline ender fluid conduit.");
typeName = "crazypants.enderio.conduit.liquid.CrystallineEnderLiquidConduit";
}
IConduit result;
try {
result = (IConduit) Class.forName(typeName).newInstance();
} catch (Exception e) {
throw new RuntimeException("Could not create an instance of the conduit with name: " + typeName, e);
}
result.readFromNBT(conduitBody, nbtVersion);
return result;
}
public static boolean isRedstoneControlModeMet(IConduitBundle bundle, RedstoneControlMode mode, DyeColor col) {
if (mode == RedstoneControlMode.IGNORE) {
return true;
} else if (mode == RedstoneControlMode.NEVER) {
return false;
} else if (mode == null) {
return false;
}
int signalStrength = getInternalSignalForColor(bundle, col);
if (signalStrength < 15 && bundle != null && bundle.getEntity() != null) {
TileEntity te = bundle.getEntity();
signalStrength = Math
.max(signalStrength, te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord));
}
return RedstoneControlMode.isConditionMet(mode, signalStrength);
}
public static int getInternalSignalForColor(IConduitBundle bundle, DyeColor col) {
int signalStrength = 0;
if (bundle == null) {
return 0;
}
IRedstoneConduit rsCon = bundle.getConduit(IRedstoneConduit.class);
if (rsCon != null) {
Set<Signal> signals = rsCon.getNetworkOutputs(ForgeDirection.UNKNOWN);
for (Signal sig : signals) {
if (sig.color == col) {
if (sig.strength > signalStrength) {
signalStrength = sig.strength;
}
}
}
}
return signalStrength;
}
public static boolean isFluidValid(FluidStack fluidStack) {
if (fluidStack != null) {
String name = FluidRegistry.getFluidName(fluidStack);
if (name != null && !name.trim().isEmpty()) {
return true;
}
}
return false;
}
public static void openConduitGui(World world, int x, int y, int z, EntityPlayer player) {
TileEntity te = world.getTileEntity(x, y, z);
if (!(te instanceof TileConduitBundle)) {
return;
}
IConduitBundle cb = (IConduitBundle) te;
Set<ForgeDirection> cons = new HashSet<>();
boolean hasInsulated = false;
for (IConduit con : cb.getConduits()) {
cons.addAll(con.getExternalConnections());
if (con instanceof IInsulatedRedstoneConduit) {
hasInsulated = true;
}
}
if (cons.isEmpty() && !hasInsulated) {
return;
}
if (cons.size() == 1) {
player.openGui(
EnderIO.instance,
GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + cons.iterator().next().ordinal(),
world,
x,
y,
z);
return;
}
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_SELECTOR, world, x, y, z);
}
public static void playBreakSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(
x + 0.5,
y + 0.5,
z + 0.5,
snd.getBreakSound(),
(snd.getVolume() + 1.0F) / 2.0F,
snd.getPitch() * 0.8F);
} else {
playClientBreakSound(snd);
}
}
private static void playClientBreakSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity()
.playSound(snd.getBreakSound(), (snd.getVolume() + 1.0F) / 2.0F, snd.getPitch() * 0.8F);
}
public static void playHitSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(
x + 0.5,
y + 0.5,
z + 0.5,
snd.getStepResourcePath(),
(snd.getVolume() + 1.0F) / 2.0F,
snd.getPitch() * 0.8F);
} else {
playClientHitSound(snd);
}
}
private static void playClientHitSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity()
.playSound(snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch() * 0.5F);
}
public static void playStepSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(
x + 0.5,
y + 0.5,
z + 0.5,
snd.getStepResourcePath(),
(snd.getVolume() + 1.0F) / 2.0F,
snd.getPitch() * 0.8F);
} else {
playClientStepSound(snd);
}
}
private static void playClientStepSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity()
.playSound(snd.getStepResourcePath(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch());
}
public static void playPlaceSound(SoundType snd, World world, int x, int y, int z) {
if (!world.isRemote) {
world.playSoundEffect(
x + 0.5,
y + 0.5,
z + 0.5,
snd.func_150496_b(),
(snd.getVolume() + 1.0F) / 2.0F,
snd.getPitch() * 0.8F);
} else {
playClientPlaceSound(snd);
}
}
private static void playClientPlaceSound(SoundType snd) {
FMLClientHandler.instance().getClientPlayerEntity()
.playSound(snd.func_150496_b(), (snd.getVolume() + 1.0F) / 8.0F, snd.getPitch());
}
}
@@ -2,51 +2,54 @@ package crazypants.enderio.conduit;
import crazypants.enderio.EnderIO;
public enum ConnectionMode {
IN_OUT("gui.conduit.ioMode.inOut"),
INPUT("gui.conduit.ioMode.input"),
OUTPUT("gui.conduit.ioMode.output"),
DISABLED("gui.conduit.ioMode.disabled"),
NOT_SET("gui.conduit.ioMode.notSet");
IN_OUT("gui.conduit.ioMode.inOut"),
INPUT("gui.conduit.ioMode.input"),
OUTPUT("gui.conduit.ioMode.output"),
DISABLED("gui.conduit.ioMode.disabled"),
NOT_SET("gui.conduit.ioMode.notSet");
private final String unlocalisedName;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final ConnectionMode[] VALUES = values();
private final String unlocalisedName;
ConnectionMode(String unlocalisedName) {
this.unlocalisedName = unlocalisedName;
}
public String getUnlocalisedName() {
return unlocalisedName;
}
public static ConnectionMode getNext(ConnectionMode mode) {
int ord = mode.ordinal() + 1;
if(ord >= ConnectionMode.values().length) {
ord = 0;
ConnectionMode(String unlocalisedName) {
this.unlocalisedName = unlocalisedName;
}
return ConnectionMode.values()[ord];
}
public static ConnectionMode getPrevious(ConnectionMode mode) {
int ord = mode.ordinal() - 1;
if(ord < 0) {
ord = ConnectionMode.values().length - 1;
public String getUnlocalisedName() {
return unlocalisedName;
}
return ConnectionMode.values()[ord];
}
public boolean acceptsInput() {
return this == IN_OUT || this == INPUT;
}
public static ConnectionMode getNext(ConnectionMode mode) {
int ord = mode.ordinal() + 1;
if (ord >= ConnectionMode.VALUES.length) {
ord = 0;
}
return ConnectionMode.VALUES[ord];
}
public boolean acceptsOutput() {
return this == IN_OUT || this == OUTPUT;
}
public static ConnectionMode getPrevious(ConnectionMode mode) {
public String getLocalisedName() {
return EnderIO.lang.localize(unlocalisedName);
}
int ord = mode.ordinal() - 1;
if (ord < 0) {
ord = ConnectionMode.VALUES.length - 1;
}
return ConnectionMode.VALUES[ord];
}
public boolean acceptsInput() {
return this == IN_OUT || this == INPUT;
}
public boolean acceptsOutput() {
return this == IN_OUT || this == OUTPUT;
}
public String getLocalisedName() {
return EnderIO.lang.localize(unlocalisedName);
}
}
@@ -17,130 +17,131 @@ import com.enderio.core.common.util.BlockCoord;
import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
import crazypants.enderio.conduit.geom.CollidableComponent;
import crazypants.enderio.conduit.render.ConduitRenderer;
public interface IConduit {
// Base functionality
Class<? extends IConduit> getBaseConduitType();
// Base functionality
Class<? extends IConduit> getBaseConduitType();
ItemStack createItem();
List<ItemStack> getDrops();
ItemStack createItem();
int getLightValue();
List<ItemStack> getDrops();
boolean isActive();
int getLightValue();
void setActive(boolean active);
boolean isActive();
void writeToNBT(NBTTagCompound conduitBody);
void setActive(boolean active);
void readFromNBT(NBTTagCompound conduitBody, short nbtVersion);
void writeToNBT(NBTTagCompound conduitBody);
// Container
void readFromNBT(NBTTagCompound conduitBody, short nbtVersion);
void setBundle(IConduitBundle tileConduitBundle);
// Container
IConduitBundle getBundle();
void setBundle(IConduitBundle tileConduitBundle);
void onAddedToBundle();
IConduitBundle getBundle();
void onRemovedFromBundle();
void onAddedToBundle();
BlockCoord getLocation();
void onRemovedFromBundle();
// Conections
boolean hasConnections();
BlockCoord getLocation();
boolean hasExternalConnections();
// Conections
boolean hasConnections();
boolean hasConduitConnections();
boolean hasExternalConnections();
// Conduit Connections
boolean hasConduitConnections();
boolean canConnectToConduit(ForgeDirection direction, IConduit conduit);
// Conduit Connections
Set<ForgeDirection> getConduitConnections();
boolean canConnectToConduit(ForgeDirection direction, IConduit conduit);
boolean containsConduitConnection(ForgeDirection dir);
Set<ForgeDirection> getConduitConnections();
void conduitConnectionAdded(ForgeDirection fromDirection);
boolean containsConduitConnection(ForgeDirection dir);
void conduitConnectionRemoved(ForgeDirection fromDirection);
void conduitConnectionAdded(ForgeDirection fromDirection);
void connectionsChanged();
void conduitConnectionRemoved(ForgeDirection fromDirection);
AbstractConduitNetwork<?, ?> getNetwork();
void connectionsChanged();
boolean setNetwork(AbstractConduitNetwork<?, ?> network);
AbstractConduitNetwork<?, ?> getNetwork();
// External Connections
boolean setNetwork(AbstractConduitNetwork<?, ?> network);
boolean canConnectToExternal(ForgeDirection direction, boolean ignoreConnectionMode);
// External Connections
Set<ForgeDirection> getExternalConnections();
boolean canConnectToExternal(ForgeDirection direction, boolean ignoreConnectionMode);
boolean containsExternalConnection(ForgeDirection dir);
Set<ForgeDirection> getExternalConnections();
void externalConnectionAdded(ForgeDirection fromDirection);
boolean containsExternalConnection(ForgeDirection dir);
void externalConnectionRemoved(ForgeDirection fromDirection);
void externalConnectionAdded(ForgeDirection fromDirection);
boolean isConnectedTo(ForgeDirection dir);
void externalConnectionRemoved(ForgeDirection fromDirection);
ConnectionMode getConnectionMode(ForgeDirection dir);
boolean isConnectedTo(ForgeDirection dir);
void setConnectionMode(ForgeDirection dir, ConnectionMode mode);
ConnectionMode getConnectionMode(ForgeDirection dir);
boolean hasConnectionMode(ConnectionMode mode);
void setConnectionMode(ForgeDirection dir, ConnectionMode mode);
ConnectionMode getNextConnectionMode(ForgeDirection dir);
boolean hasConnectionMode(ConnectionMode mode);
ConnectionMode getPreviousConnectionMode(ForgeDirection dir);
ConnectionMode getNextConnectionMode(ForgeDirection dir);
// rendering, only needed us default rendering is used
ConnectionMode getPreviousConnectionMode(ForgeDirection dir);
IIcon getTextureForState(CollidableComponent component);
// rendering, only needed us default rendering is used
IIcon getTransmitionTextureForState(CollidableComponent component);
IIcon getTextureForState(CollidableComponent component);
float getTransmitionGeometryScale();
IIcon getTransmitionTextureForState(CollidableComponent component);
float getSelfIlluminationForState(CollidableComponent component);
float getTransmitionGeometryScale();
// geometry
float getSelfIlluminationForState(CollidableComponent component);
boolean haveCollidablesChangedSinceLastCall();
// geometry
Collection<CollidableComponent> getCollidableComponents();
boolean haveCollidablesChangedSinceLastCall();
Collection<CollidableComponent> createCollidables(CacheKey key);
Collection<CollidableComponent> getCollidableComponents();
Class<? extends IConduit> getCollidableType();
Collection<CollidableComponent> createCollidables(CacheKey key);
// Actions
Class<? extends IConduit> getCollidableType();
boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all);
// Actions
void onChunkUnload(World worldObj);
boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all);
void updateEntity(World worldObj);
void onChunkUnload(World worldObj);
boolean onNeighborBlockChange(Block blockId);
boolean onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ);
void updateEntity(World worldObj);
//For Copy/Paste of connection settings
boolean writeConnectionSettingsToNBT(ForgeDirection dir, NBTTagCompound nbt);
boolean onNeighborBlockChange(Block blockId);
boolean readConduitSettingsFromNBT(ForgeDirection dir, NBTTagCompound nbt);
public AbstractConduitNetwork<?, ?> createNetworkForType();
boolean onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ);
/**
* Should the texture of the conduit connectors be mirrored around the conduit
* node?
*/
boolean shouldMirrorTexture();
// For Copy/Paste of connection settings
boolean writeConnectionSettingsToNBT(ForgeDirection dir, NBTTagCompound nbt);
boolean readConduitSettingsFromNBT(ForgeDirection dir, NBTTagCompound nbt);
public AbstractConduitNetwork<?, ?> createNetworkForType();
/**
* Should the texture of the conduit connectors be mirrored around the conduit node?
*/
boolean shouldMirrorTexture();
ConduitRenderer getRenderer();
}
@@ -4,22 +4,17 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import li.cil.oc.api.network.Environment;
import li.cil.oc.api.network.SidedEnvironment;
import li.cil.oc.api.network.Node;
import mekanism.api.gas.IGasHandler;
import mods.immibis.microblocks.api.IMicroblockSupporterTile;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import appeng.api.networking.IGridHost;
import cofh.api.transport.IItemDuct;
import com.enderio.core.common.util.BlockCoord;
import appeng.api.networking.IGridHost;
import cofh.api.transport.IItemDuct;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.relauncher.Side;
@@ -28,97 +23,101 @@ import crazypants.enderio.conduit.facade.ItemConduitFacade.FacadeType;
import crazypants.enderio.conduit.geom.CollidableComponent;
import crazypants.enderio.conduit.geom.Offset;
import crazypants.enderio.power.IInternalPowerHandler;
import li.cil.oc.api.network.Environment;
import li.cil.oc.api.network.SidedEnvironment;
import mekanism.api.gas.IGasHandler;
import mods.immibis.microblocks.api.IMicroblockSupporterTile;
@InterfaceList({
@Interface(iface = "appeng.api.networking.IGridHost", modid = "appliedenergistics2"),
@Interface(iface = "mekanism.api.gas.IGasHandler", modid = "MekanismAPI|gas"),
@Interface(iface = "mods.immibis.microblocks.api.IMicroblockSupporterTile", modid = "ImmibisMicroblocks"),
@Interface(iface = "li.cil.oc.api.network.Environment", modid = "OpenComputersAPI|Network"),
@Interface(iface = "li.cil.oc.api.network.SidedEnvironment", modid = "OpenComputersAPI|Network")
})
@InterfaceList({ @Interface(iface = "appeng.api.networking.IGridHost", modid = "appliedenergistics2"),
@Interface(iface = "mekanism.api.gas.IGasHandler", modid = "MekanismAPI|gas"),
@Interface(iface = "mods.immibis.microblocks.api.IMicroblockSupporterTile", modid = "ImmibisMicroblocks"),
@Interface(iface = "li.cil.oc.api.network.Environment", modid = "OpenComputersAPI|Network"),
@Interface(iface = "li.cil.oc.api.network.SidedEnvironment", modid = "OpenComputersAPI|Network") })
public interface IConduitBundle extends IInternalPowerHandler, IFluidHandler, IItemDuct, IGasHandler, IGridHost,
IMicroblockSupporterTile, Environment, SidedEnvironment {
IMicroblockSupporterTile, Environment, SidedEnvironment {
TileEntity getEntity();
TileEntity getEntity();
@Override
BlockCoord getLocation();
@Override
BlockCoord getLocation();
// conduits
// conduits
boolean hasType(Class<? extends IConduit> type);
boolean hasType(Class<? extends IConduit> type);
<T extends IConduit> T getConduit(Class<T> type);
<T extends IConduit> T getConduit(Class<T> type);
void addConduit(IConduit conduit);
void addConduit(IConduit conduit);
void removeConduit(IConduit conduit);
void replaceConduit(IConduit original, IConduit replacement);
Collection<IConduit> getConduits();
void removeConduit(IConduit conduit);
Offset getOffset(Class<? extends IConduit> type, ForgeDirection dir);
Collection<IConduit> getConduits();
// connections
Offset getOffset(Class<? extends IConduit> type, ForgeDirection dir);
Set<ForgeDirection> getConnections(Class<? extends IConduit> type);
// connections
boolean containsConnection(Class<? extends IConduit> type, ForgeDirection west);
Set<ForgeDirection> getConnections(Class<? extends IConduit> type);
Set<ForgeDirection> getAllConnections();
boolean containsConnection(Class<? extends IConduit> type, ForgeDirection west);
boolean containsConnection(ForgeDirection dir);
Set<ForgeDirection> getAllConnections();
//geometry
boolean containsConnection(ForgeDirection dir);
List<CollidableComponent> getCollidableComponents();
// geometry
List<CollidableComponent> getConnectors();
List<CollidableComponent> getCollidableComponents();
// events
List<CollidableComponent> getConnectors();
void onNeighborBlockChange(Block blockId);
void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ);
// events
void onBlockRemoved();
void onNeighborBlockChange(Block blockId);
void dirty();
void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ);
// Facade
void onBlockRemoved();
enum FacadeRenderState {
NONE,
FULL,
WIRE_FRAME
}
void dirty();
@SideOnly(Side.CLIENT)
FacadeRenderState getFacadeRenderedAs();
// Facade
@SideOnly(Side.CLIENT)
void setFacadeRenderAs(FacadeRenderState state);
enum FacadeRenderState {
NONE,
FULL,
WIRE_FRAME
}
int getLightOpacity();
@SideOnly(Side.CLIENT)
FacadeRenderState getFacadeRenderedAs();
void setLightOpacity(int opacity);
@SideOnly(Side.CLIENT)
void setFacadeRenderAs(FacadeRenderState state);
boolean hasFacade();
int getLightOpacity();
void setFacadeId(Block block);
void setLightOpacity(int opacity);
void setFacadeId(Block block, boolean triggerUpdate);
boolean hasFacade();
void setFacadeMetadata(int meta);
void setFacadeId(Block block);
void setFacadeType(FacadeType type);
void setFacadeId(Block block, boolean triggerUpdate);
Block getFacadeId();
void setFacadeMetadata(int meta);
int getFacadeMetadata();
void setFacadeType(FacadeType type);
FacadeType getFacadeType();
Block getFacadeId();
World getWorld();
int getFacadeMetadata();
void setGridNode(Object node);
FacadeType getFacadeType();
World getWorld();
void setGridNode(Object node);
}
@@ -2,12 +2,12 @@ package crazypants.enderio.conduit;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import crazypants.enderio.api.tool.IHideFacades;
public interface IConduitItem extends IHideFacades {
Class<? extends IConduit> getBaseConduitType();
IConduit createConduit(ItemStack item, EntityPlayer player);
Class<? extends IConduit> getBaseConduitType();
IConduit createConduit(ItemStack item, EntityPlayer player);
}
@@ -8,12 +8,11 @@ import crazypants.enderio.machine.RedstoneControlMode;
public interface IExtractor extends IConduit {
void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir);
void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir);
RedstoneControlMode getExtractionRedstoneMode(ForgeDirection dir);
RedstoneControlMode getExtractionRedstoneMode(ForgeDirection dir);
void setExtractionSignalColor(ForgeDirection dir, DyeColor col);
DyeColor getExtractionSignalColor(ForgeDirection dir);
void setExtractionSignalColor(ForgeDirection dir, DyeColor col);
DyeColor getExtractionSignalColor(ForgeDirection dir);
}
@@ -2,13 +2,12 @@ package crazypants.enderio.conduit;
public class ItemConduitSubtype {
public final String unlocalisedName;
public final String unlocalisedName;
public final String iconKey;
public ItemConduitSubtype(String unlocalisedName, String iconKey) {
this.unlocalisedName = "enderio." + unlocalisedName;
this.iconKey = iconKey;
}
public final String iconKey;
public ItemConduitSubtype(String unlocalisedName, String iconKey) {
this.unlocalisedName = "enderio." + unlocalisedName;
this.iconKey = iconKey;
}
}
@@ -1,40 +1,41 @@
package crazypants.enderio.conduit;
import mods.immibis.microblocks.api.EnumPosition;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional.Method;
import mods.immibis.microblocks.api.EnumPosition;
public class MicroblocksUtil {
private static boolean useCheckPerformed = false;
private static boolean supportMicroblocks = false;
private static boolean useCheckPerformed = false;
private static boolean supportMicroblocks = false;
public static boolean supportMicroblocks() {
if (!useCheckPerformed) {
supportMicroblocks = Loader.isModLoaded("ImmibisMicroblocks");
useCheckPerformed = true;
public static boolean supportMicroblocks() {
if (!useCheckPerformed) {
supportMicroblocks = Loader.isModLoaded("ImmibisMicroblocks");
useCheckPerformed = true;
}
return supportMicroblocks;
}
return supportMicroblocks;
}
@Method(modid = "ImmibisMicroblocks")
public static ForgeDirection posToDir(EnumPosition pos) {
switch(pos) {
case FaceNX:
return ForgeDirection.WEST;
case FaceNY:
return ForgeDirection.DOWN;
case FaceNZ:
return ForgeDirection.NORTH;
case FacePX:
return ForgeDirection.EAST;
case FacePY:
return ForgeDirection.UP;
case FacePZ:
return ForgeDirection.SOUTH;
default:
return null;
@Method(modid = "ImmibisMicroblocks")
public static ForgeDirection posToDir(EnumPosition pos) {
switch (pos) {
case FaceNX:
return ForgeDirection.WEST;
case FaceNY:
return ForgeDirection.DOWN;
case FaceNZ:
return ForgeDirection.NORTH;
case FacePX:
return ForgeDirection.EAST;
case FacePY:
return ForgeDirection.UP;
case FacePZ:
return ForgeDirection.SOUTH;
default:
return null;
}
}
}
}
@@ -7,52 +7,53 @@ import java.util.List;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import crazypants.enderio.conduit.geom.CollidableComponent;
public class RaytraceResult {
public static RaytraceResult getClosestHit(Vec3 origin, Collection<RaytraceResult> candidates) {
double minLengthSquared = Double.POSITIVE_INFINITY;
RaytraceResult closest = null;
public static RaytraceResult getClosestHit(Vec3 origin, Collection<RaytraceResult> candidates) {
double minLengthSquared = Double.POSITIVE_INFINITY;
RaytraceResult closest = null;
for (RaytraceResult candidate : candidates) {
MovingObjectPosition hit = candidate.movingObjectPosition;
if(hit != null) {
double lengthSquared = hit.hitVec.squareDistanceTo(origin);
if(lengthSquared < minLengthSquared) {
minLengthSquared = lengthSquared;
closest = candidate;
for (RaytraceResult candidate : candidates) {
MovingObjectPosition hit = candidate.movingObjectPosition;
if (hit != null) {
double lengthSquared = hit.hitVec.squareDistanceTo(origin);
if (lengthSquared < minLengthSquared) {
minLengthSquared = lengthSquared;
closest = candidate;
}
}
}
}
return closest;
}
return closest;
}
public static void sort(final Vec3 origin, List<RaytraceResult> toSort) {
if(origin == null || toSort == null) {
return;
public static void sort(final Vec3 origin, List<RaytraceResult> toSort) {
if (origin == null || toSort == null) {
return;
}
Collections.sort(toSort, new Comparator<>() {
@Override
public int compare(RaytraceResult o1, RaytraceResult o2) {
return Double.compare(o1.getDistanceTo(origin), o2.getDistanceTo(origin));
}
});
}
Collections.sort(toSort, new Comparator<RaytraceResult>() {
@Override
public int compare(RaytraceResult o1, RaytraceResult o2) {
return Double.compare(o1.getDistanceTo(origin), o2.getDistanceTo(origin));
}
});
}
public final CollidableComponent component;
public final MovingObjectPosition movingObjectPosition;
public final CollidableComponent component;
public final MovingObjectPosition movingObjectPosition;
public RaytraceResult(CollidableComponent component, MovingObjectPosition movingObjectPosition) {
this.component = component;
this.movingObjectPosition = movingObjectPosition;
}
public double getDistanceTo(Vec3 origin) {
if(movingObjectPosition == null || origin == null) {
return Double.MAX_VALUE;
public RaytraceResult(CollidableComponent component, MovingObjectPosition movingObjectPosition) {
this.component = component;
this.movingObjectPosition = movingObjectPosition;
}
return movingObjectPosition.hitVec.squareDistanceTo(origin);
}
public double getDistanceTo(Vec3 origin) {
if (movingObjectPosition == null || origin == null) {
return Double.MAX_VALUE;
}
return movingObjectPosition.hitVec.squareDistanceTo(origin);
}
}
File diff suppressed because it is too large. Load diff
@@ -8,6 +8,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.BlockEio;
@@ -15,138 +16,138 @@ import crazypants.enderio.ModObject;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.machine.painter.IPaintedBlock;
public class BlockConduitFacade extends BlockEio implements IPaintedBlock {
public class BlockConduitFacade extends BlockEio implements IPaintedBlock, Cloneable {
public static BlockConduitFacade create() {
BlockConduitFacade result = new BlockConduitFacade();
result.init();
return result;
}
private Block blockOverride;
private BlockConduitFacade() {
super(ModObject.blockConduitFacade.unlocalisedName, null, new Material(MapColor.stoneColor));
setStepSound(Block.soundTypeStone);
setCreativeTab(null);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister IIconRegister) {
blockIcon = IIconRegister.registerIcon("enderio:conduitFacade");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess ba, int x, int y, int z, int side) {
TileEntity te = ba.getTileEntity(x, y, z);
if(!(te instanceof IConduitBundle)) {
return blockIcon;
}
IConduitBundle cb = (IConduitBundle) te;
Block block = cb.getFacadeId();
if(block != null) {
int meta = cb.getFacadeMetadata();
return block.getIcon(side, meta);
}
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int par1, int par2) {
if(blockOverride != null) {
return blockOverride.getIcon(par1, par2);
}
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public int getBlockColor() {
if(blockOverride != null) {
return blockOverride.getBlockColor();
} else {
return super.getBlockColor();
}
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
if(blockOverride != null) {
try { //work around for Issue #589
return blockOverride.colorMultiplier(par1IBlockAccess, par2, par3, par4);
} catch (Exception e) {
}
}
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
}
public Block getIconOverrideBlock() {
return blockOverride;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int par1) {
if(blockOverride != null) {
return blockOverride.getRenderColor(par1);
} else {
return super.getRenderColor(par1);
}
}
public void setBlockOverride(IConduitBundle cb) {
if(cb == null) {
blockOverride = null;
return;
public static BlockConduitFacade create() {
BlockConduitFacade result = new BlockConduitFacade();
result.init();
return result;
}
Block block = cb.getFacadeId();
int meta = cb.getFacadeMetadata();
if(block == null || block == this) {
return;
}
blockOverride = block;
}
@Override
public int getDamageValue(World par1World, int x, int y, int z) {
Mimic m = getMimic(par1World, x, y, z);
if(m != null) {
return m.meta;
}
return 0;
}
private Mimic getMimic(IBlockAccess ba, int x, int y, int z) {
TileEntity te = ba.getTileEntity(x, y, z);
if(!(te instanceof IConduitBundle)) {
return null;
}
IConduitBundle cb = (IConduitBundle) te;
Block id = cb.getFacadeId();
int meta = cb.getFacadeMetadata();
if(id == null) {
return null;
public BlockConduitFacade clone() throws CloneNotSupportedException {
return (BlockConduitFacade) super.clone();
}
return new Mimic(id, meta);
}
private Block blockOverride;
class Mimic {
int meta;
Block block;
private Mimic(Block block, int meta) {
this.block = block;
this.meta = meta;
private BlockConduitFacade() {
super(ModObject.blockConduitFacade.unlocalisedName, null, new Material(MapColor.stoneColor));
setStepSound(Block.soundTypeStone);
setCreativeTab(null);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister IIconRegister) {
blockIcon = IIconRegister.registerIcon("enderio:conduitFacade");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess ba, int x, int y, int z, int side) {
TileEntity te = ba.getTileEntity(x, y, z);
if (!(te instanceof IConduitBundle)) {
return blockIcon;
}
IConduitBundle cb = (IConduitBundle) te;
Block block = cb.getFacadeId();
if (block != null) {
int meta = cb.getFacadeMetadata();
return block.getIcon(side, meta);
}
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int par1, int par2) {
if (blockOverride != null) {
return blockOverride.getIcon(par1, par2);
}
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public int getBlockColor() {
if (blockOverride != null) {
return blockOverride.getBlockColor();
} else {
return super.getBlockColor();
}
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
if (blockOverride != null) {
try { // work around for Issue #589
return blockOverride.colorMultiplier(par1IBlockAccess, par2, par3, par4);
} catch (Exception e) {}
}
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
}
public Block getIconOverrideBlock() {
return blockOverride;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int par1) {
if (blockOverride != null) {
return blockOverride.getRenderColor(par1);
} else {
return super.getRenderColor(par1);
}
}
public void setBlockOverride(IConduitBundle cb) {
if (cb == null) {
blockOverride = null;
return;
}
Block block = cb.getFacadeId();
if (block == null || block == this) {
return;
}
blockOverride = block;
}
@Override
public int getDamageValue(World par1World, int x, int y, int z) {
Mimic m = getMimic(par1World, x, y, z);
if (m != null) {
return m.meta;
}
return 0;
}
private Mimic getMimic(IBlockAccess ba, int x, int y, int z) {
TileEntity te = ba.getTileEntity(x, y, z);
if (!(te instanceof IConduitBundle)) {
return null;
}
IConduitBundle cb = (IConduitBundle) te;
Block id = cb.getFacadeId();
int meta = cb.getFacadeMetadata();
if (id == null) {
return null;
}
return new Mimic(id, meta);
}
static class Mimic {
int meta;
Block block;
private Mimic(Block block, int meta) {
this.block = block;
this.meta = meta;
}
}
}
@@ -15,89 +15,89 @@ import crazypants.enderio.machine.painter.PainterUtil;
public class FacadeRenderer implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.ENTITY || type == ItemRenderType.EQUIPPED || type == ItemRenderType.INVENTORY || type == ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if(type == ItemRenderType.INVENTORY) {
RenderBlocks renderBlocks = (RenderBlocks) data[0];
renderToInventory(item, renderBlocks);
} else if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
renderEquipped(item, (RenderBlocks) data[0]);
} else if(type == ItemRenderType.ENTITY) {
renderEntity(item, (RenderBlocks) data[0]);
} else {
System.out.println("FacadeRenderer.renderItem: Unsupported render type");
}
}
private void renderEntity(ItemStack item, RenderBlocks renderBlocks) {
GL11.glPushMatrix();
GL11.glScalef(0.5f, 0.5f, 0.5f);
renderToInventory(item, renderBlocks);
GL11.glPopMatrix();
}
private void renderEquipped(ItemStack item, RenderBlocks renderBlocks) {
renderToInventory(item, renderBlocks);
}
private void renderToInventory(ItemStack item, RenderBlocks renderBlocks) {
Block block = PainterUtil.getSourceBlock(item);
if(block != null) {
// Render the facade block
RenderUtil.bindBlockTexture();
if(!block.isOpaqueCube()) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
if("appeng.block.solids.BlockSkyStone".equals(block.getClass().getName())) {
//Yes, this is a horrible hack, but stumped as to why it is rendered invisible if this isn't done.
renderBlocks.setOverrideBlockTexture(block.getIcon(0, PainterUtil.getSourceBlockMetadata(item)));
renderBlocks.renderBlockAsItem(Blocks.stone, 0, 1.0F);
} else {
renderBlocks.renderBlockAsItem(block, PainterUtil.getSourceBlockMetadata(item), 1.0F);
}
// then the 'overlay' that marks it as a facade
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPolygonOffset(-1.0f, -1.0f);
RenderUtil.bindItemTexture();
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getOverlayIcon());
renderBlocks.renderBlockAsItem(Blocks.stone, item.getItemDamage(), 1.0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
renderBlocks.clearOverrideBlockTexture();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
} else {
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getIconFromDamage(item.getItemDamage()));
renderBlocks.renderBlockAsItem(Blocks.stone, 0, 1.0F);
renderBlocks.clearOverrideBlockTexture();
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.ENTITY || type == ItemRenderType.EQUIPPED
|| type == ItemRenderType.INVENTORY
|| type == ItemRenderType.EQUIPPED_FIRST_PERSON;
}
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (type == ItemRenderType.INVENTORY) {
RenderBlocks renderBlocks = (RenderBlocks) data[0];
renderToInventory(item, renderBlocks);
} else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
renderEquipped(item, (RenderBlocks) data[0]);
} else if (type == ItemRenderType.ENTITY) {
renderEntity(item, (RenderBlocks) data[0]);
} else {
System.out.println("FacadeRenderer.renderItem: Unsupported render type");
}
}
private void renderEntity(ItemStack item, RenderBlocks renderBlocks) {
GL11.glPushMatrix();
GL11.glScalef(0.5f, 0.5f, 0.5f);
renderToInventory(item, renderBlocks);
GL11.glPopMatrix();
}
private void renderEquipped(ItemStack item, RenderBlocks renderBlocks) {
renderToInventory(item, renderBlocks);
}
private void renderToInventory(ItemStack item, RenderBlocks renderBlocks) {
Block block = PainterUtil.getSourceBlock(item);
if (block != null) {
// Render the facade block
RenderUtil.bindBlockTexture();
if (!block.isOpaqueCube()) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
if ("appeng.block.solids.BlockSkyStone".equals(block.getClass().getName())) {
// Yes, this is a horrible hack, but stumped as to why it is rendered invisible if this isn't done.
renderBlocks.setOverrideBlockTexture(block.getIcon(0, PainterUtil.getSourceBlockMetadata(item)));
renderBlocks.renderBlockAsItem(Blocks.stone, 0, 1.0F);
} else {
renderBlocks.renderBlockAsItem(block, PainterUtil.getSourceBlockMetadata(item), 1.0F);
}
// then the 'overlay' that marks it as a facade
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
GL11.glPolygonOffset(-1.0f, -1.0f);
RenderUtil.bindItemTexture();
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getOverlayIcon());
renderBlocks.renderBlockAsItem(Blocks.stone, item.getItemDamage(), 1.0F);
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
renderBlocks.clearOverrideBlockTexture();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
} else {
renderBlocks.setOverrideBlockTexture(EnderIO.itemConduitFacade.getIconFromDamage(item.getItemDamage()));
renderBlocks.renderBlockAsItem(Blocks.stone, 0, 1.0F);
renderBlocks.clearOverrideBlockTexture();
}
}
}
@@ -32,216 +32,220 @@ import crazypants.enderio.machine.painter.BasicPainterTemplate;
import crazypants.enderio.machine.painter.IPaintedBlock;
import crazypants.enderio.machine.painter.PaintSourceValidator;
import crazypants.enderio.machine.painter.PainterUtil;
import crazypants.util.ForgeDirections;
public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider, IResourceTooltipProvider {
public static enum FacadeType {
BASIC,
HARDENED;
public enum FacadeType {
public String getUnlocName(Item me) {
return this == BASIC ? me.getUnlocalizedName() : me.getUnlocalizedName() + ".hardened";
}
}
BASIC,
HARDENED;
private IIcon[] icons;
public static final FacadeType[] VALUES = values();
public static ItemConduitFacade create() {
ItemConduitFacade result = new ItemConduitFacade();
result.init();
return result;
}
protected IIcon overlayIcon;
protected ItemConduitFacade() {
setCreativeTab(EnderIOTab.tabEnderIO);
setMaxStackSize(64);
setHasSubtypes(true);
}
protected void init() {
GameRegistry.registerItem(this, ModObject.itemConduitFacade.unlocalisedName);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs p_150895_2_, List list) {
for (FacadeType t : FacadeType.values()) {
list.add(new ItemStack(item, 1, t.ordinal()));
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return FacadeType.values()[stack.getItemDamage()].getUnlocName(this);
}
@Override
public String getUnlocalizedName() {
return "item.enderio." + ModObject.itemConduitFacade.name();
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
icons = new IIcon[FacadeType.values().length];
icons[0] = itemIcon = IIconRegister.registerIcon("enderio:conduitFacade");
icons[1] = IIconRegister.registerIcon("enderio:conduitFacadeHardened");
overlayIcon = IIconRegister.registerIcon("enderio:conduitFacadeOverlay");
}
public IIcon getOverlayIcon() {
return overlayIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
return icons[damage % icons.length];
}
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
return getIconFromDamage(stack.getItemDamage());
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8,
float par9, float par10) {
if(world.isRemote) {
return true;
}
ForgeDirection dir = ForgeDirection.values()[side];
int placeX = x + dir.offsetX;
int placeY = y + dir.offsetY;
int placeZ = z + dir.offsetZ;
if (player.canPlayerEdit(placeX, placeY, placeZ, side, itemStack) && PainterUtil.getSourceBlock(itemStack) != null) {
if (world.isAirBlock(placeX, placeY, placeZ)) {
world.setBlock(placeX, placeY, placeZ, EnderIO.blockConduitBundle);
IConduitBundle bundle = (IConduitBundle) world.getTileEntity(placeX, placeY, placeZ);
Block facadeID = PainterUtil.getSourceBlock(itemStack);
int facadeMeta = PainterUtil.getSourceBlockMetadata(itemStack);
facadeMeta = PainterUtil.adjustFacadeMetadata(facadeID, facadeMeta, side);
bundle.setFacadeId(facadeID);
bundle.setFacadeMetadata(facadeMeta);
bundle.setFacadeType(FacadeType.values()[itemStack.getItemDamage()]);
ConduitUtil.playPlaceSound(facadeID.stepSound, world, x, y, z);
if (!player.capabilities.isCreativeMode) {
itemStack.stackSize--;
public String getUnlocName(Item me) {
return this == BASIC ? me.getUnlocalizedName() : me.getUnlocalizedName() + ".hardened";
}
return true;
} else {
Block block = world.getBlock(placeX, placeY, placeZ);
if (block == EnderIO.blockConduitBundle) {
((BlockConduitBundle) block).handleFacadeClick(world, placeX, placeY, placeZ, player, dir.getOpposite().ordinal(),
(IConduitBundle) world.getTileEntity(placeX, placeY, placeZ), itemStack);
}
private IIcon[] icons;
public static ItemConduitFacade create() {
ItemConduitFacade result = new ItemConduitFacade();
result.init();
return result;
}
protected IIcon overlayIcon;
protected ItemConduitFacade() {
setCreativeTab(EnderIOTab.tabEnderIO);
setMaxStackSize(64);
setHasSubtypes(true);
}
protected void init() {
GameRegistry.registerItem(this, ModObject.itemConduitFacade.unlocalisedName);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs p_150895_2_, List<ItemStack> list) {
for (FacadeType t : FacadeType.VALUES) {
list.add(new ItemStack(item, 1, t.ordinal()));
}
}
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
public ItemStack createItemStackForSourceBlock(Block id, int itemDamage) {
if(id == null) {
id = EnderIO.blockConduitFacade;
}
ItemStack result = new ItemStack(id, 1, 0);
PainterUtil.setSourceBlock(result, id, itemDamage);
return result;
}
@SuppressWarnings("rawtypes")
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, EntityPlayer par2EntityPlayer, List list, boolean par4) {
super.addInformation(item, par2EntityPlayer, list, par4);
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName();
}
@SuppressWarnings("rawtypes")
@Override
@SideOnly(Side.CLIENT)
public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
if(PainterUtil.getSourceBlock(itemstack) == null) {
list.add(EnderIO.lang.localize("item.itemConduitFacade.tooltip.notpainted"));
} else {
list.add(PainterUtil.getTooltTipText(itemstack));
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
SpecialTooltipHandler.addDetailedTooltipFromResources(list, itemstack);
if(itemstack.getItemDamage() == FacadeType.HARDENED.ordinal()) {
list.add("");
list.add(EnderIO.lang.localizeExact(getUnlocalizedName(itemstack) + ".tooltip"));
}
}
public final class FacadePainterRecipe extends BasicPainterTemplate {
@Override
public boolean isValidPaintSource(ItemStack paintSource) {
if(paintSource == null) {
return false;
}
if (paintSource.getItem() == ItemConduitFacade.this) {
return true;
}
Block block = Util.getBlockFromItemId(paintSource);
if(block == null || block instanceof IPaintedBlock) {
return false;
}
if(PaintSourceValidator.instance.isBlacklisted(paintSource)) {
return false;
}
if(PaintSourceValidator.instance.isWhitelisted(paintSource)) {
return true;
}
if (!Config.allowTileEntitiesAsPaintSource && block.hasTileEntity(paintSource.getItemDamage())) {
return false;
}
if(block == EnderIO.blockFusedQuartz && paintSource.getItemDamage() < 2) {
return true;
}
return block.getRenderType() == 0 || block.isOpaqueCube() || block.isNormalCube();
}
@Override
public boolean isValidTarget(ItemStack target) {
return target != null && target.getItem() == ItemConduitFacade.this;
public String getUnlocalizedName(ItemStack stack) {
return FacadeType.VALUES[stack.getItemDamage()].getUnlocName(this);
}
@Override
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
ResultStack[] res = super.getCompletedResult(chance, inputs);
return res;
public String getUnlocalizedName() {
return "item.enderio." + ModObject.itemConduitFacade.name();
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
icons = new IIcon[FacadeType.VALUES.length];
icons[0] = itemIcon = IIconRegister.registerIcon("enderio:conduitFacade");
icons[1] = IIconRegister.registerIcon("enderio:conduitFacadeHardened");
overlayIcon = IIconRegister.registerIcon("enderio:conduitFacadeOverlay");
}
public IIcon getOverlayIcon() {
return overlayIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
return icons[damage % icons.length];
}
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {
return getIconFromDamage(stack.getItemDamage());
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side,
float par8, float par9, float par10) {
if (world.isRemote) {
return true;
}
ForgeDirection dir = ForgeDirections.DIRECTIONS[side];
int placeX = x + dir.offsetX;
int placeY = y + dir.offsetY;
int placeZ = z + dir.offsetZ;
if (player.canPlayerEdit(placeX, placeY, placeZ, side, itemStack)
&& PainterUtil.getSourceBlock(itemStack) != null) {
if (world.isAirBlock(placeX, placeY, placeZ)) {
world.setBlock(placeX, placeY, placeZ, EnderIO.blockConduitBundle);
IConduitBundle bundle = (IConduitBundle) world.getTileEntity(placeX, placeY, placeZ);
Block facadeID = PainterUtil.getSourceBlock(itemStack);
int facadeMeta = PainterUtil.getSourceBlockMetadata(itemStack);
facadeMeta = PainterUtil.adjustFacadeMetadata(facadeID, facadeMeta, side);
bundle.setFacadeId(facadeID);
bundle.setFacadeMetadata(facadeMeta);
bundle.setFacadeType(FacadeType.VALUES[itemStack.getItemDamage()]);
ConduitUtil.playPlaceSound(facadeID.stepSound, world, x, y, z);
if (!player.capabilities.isCreativeMode) {
itemStack.stackSize--;
}
return true;
} else {
Block block = world.getBlock(placeX, placeY, placeZ);
if (block == EnderIO.blockConduitBundle) {
((BlockConduitBundle) block).handleFacadeClick(
world,
placeX,
placeY,
placeZ,
player,
dir.getOpposite().ordinal(),
(IConduitBundle) world.getTileEntity(placeX, placeY, placeZ),
itemStack);
}
}
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
public ItemStack createItemStackForSourceBlock(Block id, int itemDamage) {
if (id == null) {
id = EnderIO.blockConduitFacade;
}
ItemStack result = new ItemStack(id, 1, 0);
PainterUtil.setSourceBlock(result, id, itemDamage);
return result;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, EntityPlayer par2EntityPlayer, List<String> list, boolean par4) {
super.addInformation(item, par2EntityPlayer, list, par4);
}
@Override
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
return getUnlocalizedName();
}
@Override
@SideOnly(Side.CLIENT)
public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {}
@Override
@SideOnly(Side.CLIENT)
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {
if (PainterUtil.getSourceBlock(itemstack) == null) {
list.add(EnderIO.lang.localize("item.itemConduitFacade.tooltip.notpainted"));
} else {
list.add(PainterUtil.getTooltTipText(itemstack));
}
}
@Override
@SideOnly(Side.CLIENT)
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {
SpecialTooltipHandler.addDetailedTooltipFromResources(list, itemstack);
if (itemstack.getItemDamage() == FacadeType.HARDENED.ordinal()) {
list.add("");
list.add(EnderIO.lang.localizeExact(getUnlocalizedName(itemstack) + ".tooltip"));
}
}
public final class FacadePainterRecipe extends BasicPainterTemplate {
@Override
public boolean isValidPaintSource(ItemStack paintSource) {
if (paintSource == null) {
return false;
}
if (paintSource.getItem() == ItemConduitFacade.this) {
return true;
}
Block block = Util.getBlockFromItemId(paintSource);
if (block == null || block instanceof IPaintedBlock) {
return false;
}
if (PaintSourceValidator.instance.isBlacklisted(paintSource)) {
return false;
}
if (PaintSourceValidator.instance.isWhitelisted(paintSource)) {
return true;
}
if (!Config.allowTileEntitiesAsPaintSource && block.hasTileEntity(paintSource.getItemDamage())) {
return false;
}
if (block == EnderIO.blockFusedQuartz && paintSource.getItemDamage() < 2) {
return true;
}
return block.getRenderType() == 0 || block.isOpaqueCube() || block.isNormalCube();
}
@Override
public boolean isValidTarget(ItemStack target) {
return target != null && target.getItem() == ItemConduitFacade.this;
}
@Override
public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
ResultStack[] res = super.getCompletedResult(chance, inputs);
return res;
}
}
}
@@ -5,7 +5,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.gas.IGasHandler;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -22,181 +21,180 @@ import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.machine.RedstoneControlMode;
import crazypants.enderio.machine.reservoir.TileReservoir;
import mekanism.api.gas.IGasHandler;
public abstract class AbstractGasConduit extends AbstractConduit implements IGasConduit {
protected final EnumMap<ForgeDirection, RedstoneControlMode> extractionModes = new EnumMap<ForgeDirection, RedstoneControlMode>(ForgeDirection.class);
protected final EnumMap<ForgeDirection, DyeColor> extractionColors = new EnumMap<ForgeDirection, DyeColor>(ForgeDirection.class);
protected final EnumMap<ForgeDirection, RedstoneControlMode> extractionModes = new EnumMap<>(ForgeDirection.class);
protected final EnumMap<ForgeDirection, DyeColor> extractionColors = new EnumMap<>(ForgeDirection.class);
protected final Map<ForgeDirection, Integer> externalRedstoneSignals = new HashMap<ForgeDirection, Integer>();
protected boolean redstoneStateDirty = true;
protected final Map<ForgeDirection, Integer> externalRedstoneSignals = new HashMap<>();
protected boolean redstoneStateDirty = true;
@Method(modid = GasUtil.API_NAME)
public IGasHandler getExternalHandler(ForgeDirection direction) {
IGasHandler con = GasUtil.getExternalGasHandler(getBundle().getWorld(), getLocation().getLocation(direction));
return (con != null && !(con instanceof IConduitBundle)) ? con : null;
}
@Method(modid = GasUtil.API_NAME)
public IGasHandler getTankContainer(BlockCoord bc) {
return GasUtil.getGasHandler(getBundle().getWorld(), bc);
}
@Override
public boolean canConnectToExternal(ForgeDirection direction, boolean ignoreDisabled) {
IGasHandler h = getExternalHandler(direction);
if(h == null) {
return false;
}
return true;
}
@Override
public Class<? extends IConduit> getBaseConduitType() {
return IGasConduit.class;
}
@Override
public boolean onNeighborBlockChange(Block blockId) {
redstoneStateDirty = true;
return super.onNeighborBlockChange(blockId);
}
@Override
public void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir) {
extractionModes.put(dir, mode);
redstoneStateDirty = true;
}
@Override
public RedstoneControlMode getExtractionRedstoneMode(ForgeDirection dir) {
RedstoneControlMode res = extractionModes.get(dir);
if(res == null) {
res = RedstoneControlMode.ON;
}
return res;
}
@Override
public void setExtractionSignalColor(ForgeDirection dir, DyeColor col) {
extractionColors.put(dir, col);
}
@Override
public DyeColor getExtractionSignalColor(ForgeDirection dir) {
DyeColor result = extractionColors.get(dir);
if(result == null) {
return DyeColor.RED;
}
return result;
}
@Override
public boolean canOutputToDir(ForgeDirection dir) {
if(isExtractingFromDir(dir) || getConnectionMode(dir) == ConnectionMode.DISABLED) {
return false;
}
if(conduitConnections.contains(dir)) {
return true;
}
if(!externalConnections.contains(dir)) {
return false;
}
IGasHandler ext = getExternalHandler(dir);
if(ext instanceof TileReservoir) { // dont push to an auto ejecting
// resevoir or we loop
TileReservoir tr = (TileReservoir) ext;
return !tr.isMultiblock() || !tr.isAutoEject();
}
return true;
}
protected boolean autoExtractForDir(ForgeDirection dir) {
if(!isExtractingFromDir(dir)) {
return false;
}
RedstoneControlMode mode = getExtractionRedstoneMode(dir);
if(mode == RedstoneControlMode.IGNORE) {
return true;
}
if(mode == RedstoneControlMode.NEVER) {
return false;
}
if(redstoneStateDirty) {
externalRedstoneSignals.clear();
redstoneStateDirty = false;
@Method(modid = GasUtil.API_NAME)
public IGasHandler getExternalHandler(ForgeDirection direction) {
IGasHandler con = GasUtil.getExternalGasHandler(getBundle().getWorld(), getLocation().getLocation(direction));
return (con != null && !(con instanceof IConduitBundle)) ? con : null;
}
DyeColor col = getExtractionSignalColor(dir);
int signal = ConduitUtil.getInternalSignalForColor(getBundle(), col);
if(RedstoneControlMode.isConditionMet(mode, signal) && mode != RedstoneControlMode.OFF) {
return true;
@Method(modid = GasUtil.API_NAME)
public IGasHandler getTankContainer(BlockCoord bc) {
return GasUtil.getGasHandler(getBundle().getWorld(), bc);
}
return isConditionMetByExternalSignal(dir, mode, col);
}
private boolean isConditionMetByExternalSignal(ForgeDirection dir, RedstoneControlMode mode, DyeColor col) {
int externalSignal = 0;
if(col == DyeColor.RED) {
Integer val = externalRedstoneSignals.get(dir);
if(val == null) {
TileEntity te = getBundle().getEntity();
externalSignal = te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord);
externalRedstoneSignals.put(dir, externalSignal);
} else {
externalSignal = val;
}
}
return RedstoneControlMode.isConditionMet(mode, externalSignal);
}
@Override
public boolean isExtractingFromDir(ForgeDirection dir) {
return getConnectionMode(dir) == ConnectionMode.INPUT;
}
@Override
public void writeToNBT(NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
for (Entry<ForgeDirection, RedstoneControlMode> entry : extractionModes.entrySet()) {
if(entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extRM." + entry.getKey().name(), ord);
}
}
for (Entry<ForgeDirection, DyeColor> entry : extractionColors.entrySet()) {
if(entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extSC." + entry.getKey().name(), ord);
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) {
super.readFromNBT(nbtRoot, nbtVersion);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
String key = "extRM." + dir.name();
if(nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if(ord >= 0 && ord < RedstoneControlMode.values().length) {
extractionModes.put(dir, RedstoneControlMode.values()[ord]);
@Override
public boolean canConnectToExternal(ForgeDirection direction, boolean ignoreDisabled) {
IGasHandler h = getExternalHandler(direction);
if (h == null) {
return false;
}
}
key = "extSC." + dir.name();
if(nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if(ord >= 0 && ord < DyeColor.values().length) {
extractionColors.put(dir, DyeColor.values()[ord]);
}
}
return true;
}
}
@Override
public Class<? extends IConduit> getBaseConduitType() {
return IGasConduit.class;
}
@Override
public boolean onNeighborBlockChange(Block blockId) {
redstoneStateDirty = true;
return super.onNeighborBlockChange(blockId);
}
@Override
public void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir) {
extractionModes.put(dir, mode);
redstoneStateDirty = true;
}
@Override
public RedstoneControlMode getExtractionRedstoneMode(ForgeDirection dir) {
RedstoneControlMode res = extractionModes.get(dir);
if (res == null) {
res = RedstoneControlMode.ON;
}
return res;
}
@Override
public void setExtractionSignalColor(ForgeDirection dir, DyeColor col) {
extractionColors.put(dir, col);
}
@Override
public DyeColor getExtractionSignalColor(ForgeDirection dir) {
DyeColor result = extractionColors.get(dir);
if (result == null) {
return DyeColor.RED;
}
return result;
}
@Override
public boolean canOutputToDir(ForgeDirection dir) {
if (isExtractingFromDir(dir) || getConnectionMode(dir) == ConnectionMode.DISABLED) {
return false;
}
if (conduitConnections.contains(dir)) {
return true;
}
if (!externalConnections.contains(dir)) {
return false;
}
IGasHandler ext = getExternalHandler(dir);
if (ext instanceof TileReservoir) { // dont push to an auto ejecting
// resevoir or we loop
TileReservoir tr = (TileReservoir) ext;
return !tr.isMultiblock() || !tr.isAutoEject();
}
return true;
}
protected boolean autoExtractForDir(ForgeDirection dir) {
if (!isExtractingFromDir(dir)) {
return false;
}
RedstoneControlMode mode = getExtractionRedstoneMode(dir);
if (mode == RedstoneControlMode.IGNORE) {
return true;
}
if (mode == RedstoneControlMode.NEVER) {
return false;
}
if (redstoneStateDirty) {
externalRedstoneSignals.clear();
redstoneStateDirty = false;
}
DyeColor col = getExtractionSignalColor(dir);
int signal = ConduitUtil.getInternalSignalForColor(getBundle(), col);
if (RedstoneControlMode.isConditionMet(mode, signal) && mode != RedstoneControlMode.OFF) {
return true;
}
return isConditionMetByExternalSignal(dir, mode, col);
}
private boolean isConditionMetByExternalSignal(ForgeDirection dir, RedstoneControlMode mode, DyeColor col) {
int externalSignal = 0;
if (col == DyeColor.RED) {
Integer val = externalRedstoneSignals.get(dir);
if (val == null) {
TileEntity te = getBundle().getEntity();
externalSignal = te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord);
externalRedstoneSignals.put(dir, externalSignal);
} else {
externalSignal = val;
}
}
return RedstoneControlMode.isConditionMet(mode, externalSignal);
}
@Override
public boolean isExtractingFromDir(ForgeDirection dir) {
return getConnectionMode(dir) == ConnectionMode.INPUT;
}
@Override
public void writeToNBT(NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
for (Entry<ForgeDirection, RedstoneControlMode> entry : extractionModes.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extRM." + entry.getKey().name(), ord);
}
}
for (Entry<ForgeDirection, DyeColor> entry : extractionColors.entrySet()) {
if (entry.getValue() != null) {
short ord = (short) entry.getValue().ordinal();
nbtRoot.setShort("extSC." + entry.getKey().name(), ord);
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) {
super.readFromNBT(nbtRoot, nbtVersion);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
String key = "extRM." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < RedstoneControlMode.VALUES.length) {
extractionModes.put(dir, RedstoneControlMode.VALUES[ord]);
}
}
key = "extSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
extractionColors.put(dir, DyeColor.VALUES[ord]);
}
}
}
}
}
@@ -2,8 +2,6 @@ package crazypants.enderio.conduit.gas;
import java.util.List;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
@@ -16,151 +14,154 @@ import crazypants.enderio.conduit.ConduitUtil;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.RaytraceResult;
import crazypants.enderio.tool.ToolUtil;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
public abstract class AbstractGasTankConduit extends AbstractGasConduit {
protected ConduitGasTank tank = new ConduitGasTank(0);
protected boolean stateDirty = false;
protected long lastEmptyTick = 0;
protected int numEmptyEvents = 0;
protected ConduitGasTank tank = new ConduitGasTank(0);
protected boolean stateDirty = false;
protected long lastEmptyTick = 0;
protected int numEmptyEvents = 0;
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
if(player.getCurrentEquippedItem() == null) {
return false;
}
if(ToolUtil.isToolEquipped(player)) {
if(!getBundle().getEntity().getWorldObj().isRemote) {
if(res != null && res.component != null) {
ForgeDirection connDir = res.component.dir;
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
if(getConnectionMode(faceHit) == ConnectionMode.DISABLED) {
setConnectionMode(faceHit, getNextConnectionMode(faceHit));
return true;
}
BlockCoord loc = getLocation().getLocation(faceHit);
IGasConduit n = ConduitUtil.getConduit(getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, IGasConduit.class);
if(n == null) {
return false;
}
if(!canJoinNeighbour(n)) {
return false;
}
if(!(n instanceof AbstractGasTankConduit)) {
return false;
}
AbstractGasTankConduit neighbour = (AbstractGasTankConduit) n;
if(neighbour.getGasType() == null || getGasType() == null) {
GasStack type = getGasType();
type = type != null ? type : neighbour.getGasType();
neighbour.setGasTypeOnNetwork(neighbour, type);
setGasTypeOnNetwork(this, type);
}
return ConduitUtil.joinConduits(this, faceHit);
} else if(containsExternalConnection(connDir)) {
// Toggle extraction mode
setConnectionMode(connDir, getNextConnectionMode(connDir));
} else if(containsConduitConnection(connDir)) {
GasStack curGasType = null;
if(getTankNetwork() != null) {
curGasType = getTankNetwork().getGasType();
}
ConduitUtil.disconectConduits(this, connDir);
setGasType(curGasType);
}
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
if (player.getCurrentEquippedItem() == null) {
return false;
}
}
return true;
if (ToolUtil.isToolEquipped(player)) {
if (!getBundle().getEntity().getWorldObj().isRemote) {
if (res != null && res.component != null) {
ForgeDirection connDir = res.component.dir;
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
if (connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
if (getConnectionMode(faceHit) == ConnectionMode.DISABLED) {
setConnectionMode(faceHit, getNextConnectionMode(faceHit));
return true;
}
BlockCoord loc = getLocation().getLocation(faceHit);
IGasConduit n = ConduitUtil.getConduit(
getBundle().getEntity().getWorldObj(),
loc.x,
loc.y,
loc.z,
IGasConduit.class);
if (n == null) {
return false;
}
if (!canJoinNeighbour(n)) {
return false;
}
if (!(n instanceof AbstractGasTankConduit)) {
return false;
}
AbstractGasTankConduit neighbour = (AbstractGasTankConduit) n;
if (neighbour.getGasType() == null || getGasType() == null) {
GasStack type = getGasType();
type = type != null ? type : neighbour.getGasType();
neighbour.setGasTypeOnNetwork(neighbour, type);
setGasTypeOnNetwork(this, type);
}
return ConduitUtil.joinConduits(this, faceHit);
} else if (containsExternalConnection(connDir)) {
// Toggle extraction mode
setConnectionMode(connDir, getNextConnectionMode(connDir));
} else if (containsConduitConnection(connDir)) {
GasStack curGasType = null;
if (getTankNetwork() != null) {
curGasType = getTankNetwork().getGasType();
}
ConduitUtil.disconectConduits(this, connDir);
setGasType(curGasType);
}
}
}
return true;
}
return false;
}
return false;
}
private void setGasTypeOnNetwork(AbstractGasTankConduit con, GasStack type) {
AbstractConduitNetwork<?, ?> n = con.getNetwork();
if(n != null) {
AbstractGasTankConduitNetwork<?> network = (AbstractGasTankConduitNetwork<?>) n;
network.setGasType(type);
private void setGasTypeOnNetwork(AbstractGasTankConduit con, GasStack type) {
AbstractConduitNetwork<?, ?> n = con.getNetwork();
if (n != null) {
AbstractGasTankConduitNetwork<?> network = (AbstractGasTankConduitNetwork<?>) n;
network.setGasType(type);
}
}
}
protected abstract boolean canJoinNeighbour(IGasConduit n);
protected abstract boolean canJoinNeighbour(IGasConduit n);
public abstract AbstractGasTankConduitNetwork<? extends AbstractGasTankConduit> getTankNetwork();
public abstract AbstractGasTankConduitNetwork<? extends AbstractGasTankConduit> getTankNetwork();
@Method(modid = GasUtil.API_NAME)
public void setGasType(GasStack gasType) {
if(tank.getGas() != null && tank.getGas().isGasEqual(gasType)) {
return;
@Method(modid = GasUtil.API_NAME)
public void setGasType(GasStack gasType) {
if (tank.getGas() != null && tank.getGas().isGasEqual(gasType)) {
return;
}
if (gasType != null) {
gasType = gasType.copy();
} else if (tank.getGas() == null) {
return;
}
tank.setGas(gasType);
stateDirty = true;
}
if(gasType != null) {
gasType = gasType.copy();
} else if(tank.getGas() == null) {
return;
}
tank.setGas(gasType);
stateDirty = true;
}
public ConduitGasTank getTank() {
return tank;
}
@Method(modid = GasUtil.API_NAME)
public GasStack getGasType() {
GasStack result = null;
if(getTankNetwork() != null) {
result = getTankNetwork().getGasType();
public ConduitGasTank getTank() {
return tank;
}
if(result == null) {
result = tank.getGas();
}
return result;
}
@Override
public boolean canOutputToDir(ForgeDirection dir) {
if (super.canOutputToDir(dir)) {
IGasHandler ext = getExternalHandler(dir);
return ext != null && ext.canReceiveGas(dir.getOpposite(), tank.getGasType());
}
return false;
}
protected abstract void updateTank();
@Override
public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) {
super.readFromNBT(nbtRoot, nbtVersion);
updateTank();
if(nbtRoot.hasKey("tank")) {
GasStack gas = GasStack.readFromNBT(nbtRoot.getCompoundTag("tank"));
tank.setGas(gas);
} else {
tank.setGas(null);
@Method(modid = GasUtil.API_NAME)
public GasStack getGasType() {
GasStack result = null;
if (getTankNetwork() != null) {
result = getTankNetwork().getGasType();
}
if (result == null) {
result = tank.getGas();
}
return result;
}
}
@Override
public void writeToNBT(NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
GasStack gt = getGasType();
if(GasUtil.isGasValid(gt)) {
updateTank();
gt = gt.copy();
gt.amount = tank.getStored();
nbtRoot.setTag("tank", gt.write(new NBTTagCompound()));
@Override
public boolean canOutputToDir(ForgeDirection dir) {
if (super.canOutputToDir(dir)) {
IGasHandler ext = getExternalHandler(dir);
return ext != null && ext.canReceiveGas(dir.getOpposite(), tank.getGasType());
}
return false;
}
}
protected abstract void updateTank();
@Override
public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) {
super.readFromNBT(nbtRoot, nbtVersion);
updateTank();
if (nbtRoot.hasKey("tank")) {
GasStack gas = GasStack.readFromNBT(nbtRoot.getCompoundTag("tank"));
tank.setGas(gas);
} else {
tank.setGas(null);
}
}
@Override
public void writeToNBT(NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
GasStack gt = getGasType();
if (GasUtil.isGasValid(gt)) {
updateTank();
gt = gt.copy();
gt.amount = tank.getStored();
nbtRoot.setTag("tank", gt.write(new NBTTagCompound()));
}
}
}
@@ -1,59 +1,59 @@
package crazypants.enderio.conduit.gas;
import mekanism.api.gas.GasStack;
import crazypants.enderio.conduit.AbstractConduitNetwork;
import mekanism.api.gas.GasStack;
public class AbstractGasTankConduitNetwork<T extends AbstractGasTankConduit> extends AbstractConduitNetwork<IGasConduit, T> {
public class AbstractGasTankConduitNetwork<T extends AbstractGasTankConduit>
extends AbstractConduitNetwork<IGasConduit, T> {
protected GasStack gasType;
protected GasStack gasType;
protected AbstractGasTankConduitNetwork(Class<T> cl) {
super(cl, IGasConduit.class);
}
public GasStack getGasType() {
return gasType;
}
@Override
public void addConduit(T con) {
super.addConduit(con);
con.setGasType(gasType);
}
public boolean setGasType(GasStack newType) {
if(gasType != null && gasType.isGasEqual(newType)) {
return false;
protected AbstractGasTankConduitNetwork(Class<T> cl) {
super(cl, IGasConduit.class);
}
if(newType != null) {
gasType = newType.copy();
gasType.amount = 0;
} else {
gasType = null;
}
for (AbstractGasTankConduit conduit : conduits) {
conduit.setGasType(gasType);
}
return true;
}
public boolean canAcceptGas(GasStack acceptable) {
return areGassCompatable(gasType, acceptable);
}
public static boolean areGassCompatable(GasStack a, GasStack b) {
if(a == null || b == null) {
return true;
public GasStack getGasType() {
return gasType;
}
return a.isGasEqual(b);
}
public int getTotalVolume() {
int totalVolume = 0;
for (T con : conduits) {
totalVolume += con.getTank().getStored();
@Override
public void addConduit(T con) {
super.addConduit(con);
con.setGasType(gasType);
}
return totalVolume;
}
public boolean setGasType(GasStack newType) {
if (gasType != null && gasType.isGasEqual(newType)) {
return false;
}
if (newType != null) {
gasType = newType.copy();
gasType.amount = 0;
} else {
gasType = null;
}
for (AbstractGasTankConduit conduit : conduits) {
conduit.setGasType(gasType);
}
return true;
}
public boolean canAcceptGas(GasStack acceptable) {
return areGassCompatable(gasType, acceptable);
}
public static boolean areGassCompatable(GasStack a, GasStack b) {
if (a == null || b == null) {
return true;
}
return a.isGasEqual(b);
}
public int getTotalVolume() {
int totalVolume = 0;
for (T con : conduits) {
totalVolume += con.getTank().getStored();
}
return totalVolume;
}
}
@@ -1,156 +1,155 @@
package crazypants.enderio.conduit.gas;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional.Method;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional.Method;
public class ConduitGasTank extends GasTank {
private int capacity;
private int capacity;
ConduitGasTank(int capacity) {
super(capacity);
this.capacity = capacity;
}
public float getFilledRatio() {
if(getStored() <= 0) {
return 0;
}
if(getMaxGas() <= 0) {
return -1;
}
float res = (float) getStored() / getMaxGas();
return res;
}
public boolean isFull() {
return getStored() >= getMaxGas();
}
public void setAmount(int amount) {
if(stored != null) {
stored.amount = amount;
}
}
public int getAvailableSpace() {
return getMaxGas() - getStored();
}
public void addAmount(int amount) {
setAmount(getStored() + amount);
}
@Override
public int getMaxGas() {
return this.capacity;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
if(getStored() > capacity) {
setAmount(capacity);
}
}
@Override
@Method(modid = GasUtil.API_NAME)
public int receive(GasStack resource, boolean doReceive) {
if(resource == null || resource.getGas().getID() < 0) {
return 0;
ConduitGasTank(int capacity) {
super(capacity);
this.capacity = capacity;
}
if(stored == null || stored.getGas().getID() < 0) {
if(resource.amount <= capacity) {
if(doReceive) {
setGas(resource.copy());
public float getFilledRatio() {
if (getStored() <= 0) {
return 0;
}
return resource.amount;
} else {
if(doReceive) {
stored = resource.copy();
stored.amount = capacity;
if (getMaxGas() <= 0) {
return -1;
}
return capacity;
}
float res = (float) getStored() / getMaxGas();
return res;
}
if(!stored.isGasEqual(resource)) {
return 0;
public boolean isFull() {
return getStored() >= getMaxGas();
}
int space = capacity - stored.amount;
if(resource.amount <= space) {
if(doReceive) {
addAmount(resource.amount);
}
return resource.amount;
} else {
if(doReceive) {
stored.amount = capacity;
}
return space;
public void setAmount(int amount) {
if (stored != null) {
stored.amount = amount;
}
}
}
@Override
@Method(modid = GasUtil.API_NAME)
public GasStack draw(int maxDrain, boolean doDraw) {
if(stored == null || stored.getGas().getID() < 0) {
return null;
}
if(stored.amount <= 0) {
return null;
public int getAvailableSpace() {
return getMaxGas() - getStored();
}
int used = maxDrain;
if(stored.amount < used) {
used = stored.amount;
public void addAmount(int amount) {
setAmount(getStored() + amount);
}
if(doDraw) {
addAmount(-used);
@Override
public int getMaxGas() {
return this.capacity;
}
GasStack drained = new GasStack(stored.getGas().getID(), used);
if(stored.amount < 0) {
stored.amount = 0;
public void setCapacity(int capacity) {
this.capacity = capacity;
if (getStored() > capacity) {
setAmount(capacity);
}
}
return drained;
}
public String getGasName() {
return stored != null ? stored.getGas().getLocalizedName() : null;
}
@Override
@Method(modid = GasUtil.API_NAME)
public int receive(GasStack resource, boolean doReceive) {
if (resource == null || resource.getGas().getID() < 0) {
return 0;
}
public boolean containsValidGas() {
return GasUtil.isGasValid(stored);
}
if (stored == null || stored.getGas().getID() < 0) {
if (resource.amount <= capacity) {
if (doReceive) {
setGas(resource.copy());
}
return resource.amount;
} else {
if (doReceive) {
stored = resource.copy();
stored.amount = capacity;
}
return capacity;
}
}
public NBTTagCompound write(NBTTagCompound nbt) {
if(containsValidGas()) {
stored.write(nbt);
} else {
nbt.setBoolean("emptyGasTank", true);
if (!stored.isGasEqual(resource)) {
return 0;
}
int space = capacity - stored.amount;
if (resource.amount <= space) {
if (doReceive) {
addAmount(resource.amount);
}
return resource.amount;
} else {
if (doReceive) {
stored.amount = capacity;
}
return space;
}
}
return nbt;
}
public void read(NBTTagCompound nbt) {
if(!nbt.hasKey("emptyGasTank")) {
GasStack gas = GasStack.readFromNBT(nbt);
if(gas != null) {
setGas(gas);
}
@Override
@Method(modid = GasUtil.API_NAME)
public GasStack draw(int maxDrain, boolean doDraw) {
if (stored == null || stored.getGas().getID() < 0) {
return null;
}
if (stored.amount <= 0) {
return null;
}
int used = maxDrain;
if (stored.amount < used) {
used = stored.amount;
}
if (doDraw) {
addAmount(-used);
}
GasStack drained = new GasStack(stored.getGas().getID(), used);
if (stored.amount < 0) {
stored.amount = 0;
}
return drained;
}
}
public boolean isEmpty() {
return stored == null || stored.amount == 0;
}
public String getGasName() {
return stored != null ? stored.getGas().getLocalizedName() : null;
}
public boolean containsValidGas() {
return GasUtil.isGasValid(stored);
}
public NBTTagCompound write(NBTTagCompound nbt) {
if (containsValidGas()) {
stored.write(nbt);
} else {
nbt.setBoolean("emptyGasTank", true);
}
return nbt;
}
public void read(NBTTagCompound nbt) {
if (!nbt.hasKey("emptyGasTank")) {
GasStack gas = GasStack.readFromNBT(nbt);
if (gas != null) {
setGas(gas);
}
}
}
public boolean isEmpty() {
return stored == null || stored.amount == 0;
}
}
@@ -3,8 +3,6 @@ package crazypants.enderio.conduit.gas;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
@@ -12,7 +10,6 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.enderio.core.client.render.IconUtil;
import com.enderio.core.common.util.BlockCoord;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
@@ -22,264 +19,269 @@ import crazypants.enderio.conduit.AbstractConduitNetwork;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.geom.CollidableComponent;
import crazypants.enderio.conduit.render.ConduitRenderer;
import crazypants.enderio.config.Config;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
public class GasConduit extends AbstractGasTankConduit {
public static final int CONDUIT_VOLUME = 1000;
public static final int CONDUIT_VOLUME = 1000;
public static final String ICON_KEY = "enderio:gasConduit";
public static final String ICON_CORE_KEY = "enderio:gasConduitCore";
public static final String ICON_EXTRACT_KEY = "enderio:gasConduitInput";
public static final String ICON_INSERT_KEY = "enderio:gasConduitOutput";
public static final String ICON_EMPTY_EDGE = "enderio:gasConduitEdge";
public static final String ICON_KEY = "enderio:gasConduit";
public static final String ICON_CORE_KEY = "enderio:gasConduitCore";
public static final String ICON_EXTRACT_KEY = "enderio:gasConduitInput";
public static final String ICON_INSERT_KEY = "enderio:gasConduitOutput";
public static final String ICON_EMPTY_EDGE = "enderio:gasConduitEdge";
static final Map<String, IIcon> ICONS = new HashMap<String, IIcon>();
static final Map<String, IIcon> ICONS = new HashMap<>();
@SideOnly(Side.CLIENT)
public static void initIcons() {
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
@Override
public void registerIcons(IIconRegister register) {
ICONS.put(ICON_KEY, register.registerIcon(ICON_KEY));
ICONS.put(ICON_CORE_KEY, register.registerIcon(ICON_CORE_KEY));
ICONS.put(ICON_EXTRACT_KEY, register.registerIcon(ICON_EXTRACT_KEY));
ICONS.put(ICON_INSERT_KEY, register.registerIcon(ICON_INSERT_KEY));
ICONS.put(ICON_EMPTY_EDGE, register.registerIcon(ICON_EMPTY_EDGE));
}
@Override
public int getTextureType() {
return 0;
}
});
}
private GasConduitNetwork network;
private long ticksSinceFailedExtract = 0;
public static final int MAX_EXTRACT_PER_TICK = Config.gasConduitExtractRate;
public static final int MAX_IO_PER_TICK = Config.gasConduitMaxIoRate;
public GasConduit() {
updateTank();
}
@Override
public void updateEntity(World world) {
super.updateEntity(world);
if(world.isRemote) {
return;
}
doExtract();
if(stateDirty) {
getBundle().dirty();
stateDirty = false;
}
}
private void doExtract() {
BlockCoord loc = getLocation();
if(!hasConnectionMode(ConnectionMode.INPUT)) {
return;
}
if(network == null) {
return;
@Override
public ConduitRenderer getRenderer() {
return GasConduitRenderer.instance.get();
}
// assume failure, reset to 0 if we do extract
ticksSinceFailedExtract++;
if(ticksSinceFailedExtract > 25 && ticksSinceFailedExtract % 10 != 0) {
// after 25 ticks of failing, only check every 10 ticks
return;
@SideOnly(Side.CLIENT)
public static void initIcons() {
IconUtil.addIconProvider(new IconUtil.IIconProvider() {
@Override
public void registerIcons(IIconRegister register) {
ICONS.put(ICON_KEY, register.registerIcon(ICON_KEY));
ICONS.put(ICON_CORE_KEY, register.registerIcon(ICON_CORE_KEY));
ICONS.put(ICON_EXTRACT_KEY, register.registerIcon(ICON_EXTRACT_KEY));
ICONS.put(ICON_INSERT_KEY, register.registerIcon(ICON_INSERT_KEY));
ICONS.put(ICON_EMPTY_EDGE, register.registerIcon(ICON_EMPTY_EDGE));
}
@Override
public int getTextureType() {
return 0;
}
});
}
Gas f = tank.getGas() == null ? null : tank.getGas().getGas();
for (ForgeDirection dir : externalConnections) {
if(autoExtractForDir(dir)) {
if(network.extractFrom(this, dir, MAX_EXTRACT_PER_TICK)) {
ticksSinceFailedExtract = 0;
private GasConduitNetwork network;
private long ticksSinceFailedExtract = 0;
public static final int MAX_EXTRACT_PER_TICK = Config.gasConduitExtractRate;
public static final int MAX_IO_PER_TICK = Config.gasConduitMaxIoRate;
public GasConduit() {
updateTank();
}
@Override
public void updateEntity(World world) {
super.updateEntity(world);
if (world.isRemote) {
return;
}
doExtract();
if (stateDirty) {
getBundle().dirty();
stateDirty = false;
}
}
}
}
private void doExtract() {
if (!hasConnectionMode(ConnectionMode.INPUT)) {
return;
}
if (network == null) {
return;
}
@Override
protected void updateTank() {
tank.setCapacity(CONDUIT_VOLUME);
if(network != null) {
network.updateConduitVolumes();
}
}
// assume failure, reset to 0 if we do extract
ticksSinceFailedExtract++;
if (ticksSinceFailedExtract > 25 && ticksSinceFailedExtract % 10 != 0) {
// after 25 ticks of failing, only check every 10 ticks
return;
}
@Override
public ItemStack createItem() {
return new ItemStack(EnderIO.itemGasConduit);
}
@Override
public AbstractConduitNetwork<?, ?> getNetwork() {
return network;
}
@Override
public boolean setNetwork(AbstractConduitNetwork<?, ?> network) {
if(network == null) {
this.network = null;
return true;
}
if(!(network instanceof GasConduitNetwork)) {
return false;
for (ForgeDirection dir : externalConnections) {
if (autoExtractForDir(dir)) {
if (network.extractFrom(this, dir, MAX_EXTRACT_PER_TICK)) {
ticksSinceFailedExtract = 0;
}
}
}
}
GasConduitNetwork n = (GasConduitNetwork) network;
if(tank.getGas() == null) {
tank.setGas(n.getGasType() == null ? null : n.getGasType().copy());
} else if(n.getGasType() == null) {
n.setGasType(tank.getGas());
} else if(!tank.getGas().isGasEqual(n.getGasType())) {
return false;
@Override
protected void updateTank() {
tank.setCapacity(CONDUIT_VOLUME);
if (network != null) {
network.updateConduitVolumes();
}
}
this.network = n;
return true;
}
@Override
public boolean canConnectToConduit(ForgeDirection direction, IConduit con) {
if(!super.canConnectToConduit(direction, con)) {
return false;
@Override
public ItemStack createItem() {
return new ItemStack(EnderIO.itemGasConduit);
}
if(!(con instanceof GasConduit)) {
return false;
@Override
public AbstractConduitNetwork<?, ?> getNetwork() {
return network;
}
if(getGasType() != null && ((GasConduit) con).getGasType() == null) {
return false;
@Override
public boolean setNetwork(AbstractConduitNetwork<?, ?> network) {
if (network == null) {
this.network = null;
return true;
}
if (!(network instanceof GasConduitNetwork)) {
return false;
}
GasConduitNetwork n = (GasConduitNetwork) network;
if (tank.getGas() == null) {
tank.setGas(n.getGasType() == null ? null : n.getGasType().copy());
} else if (n.getGasType() == null) {
n.setGasType(tank.getGas());
} else if (!tank.getGas().isGasEqual(n.getGasType())) {
return false;
}
this.network = n;
return true;
}
return GasConduitNetwork.areGassCompatable(getGasType(), ((GasConduit) con).getGasType());
}
@Override
public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) {
super.setConnectionMode(dir, mode);
refreshInputs(dir);
}
private void refreshInputs(ForgeDirection dir) {
if(network == null) {
return;
@Override
public boolean canConnectToConduit(ForgeDirection direction, IConduit con) {
if (!super.canConnectToConduit(direction, con)) {
return false;
}
if (!(con instanceof GasConduit)) {
return false;
}
if (getGasType() != null && ((GasConduit) con).getGasType() == null) {
return false;
}
return GasConduitNetwork.areGassCompatable(getGasType(), ((GasConduit) con).getGasType());
}
GasOutput lo = new GasOutput(getLocation().getLocation(dir), dir.getOpposite());
network.removeInput(lo);
if(getConnectionMode(dir).acceptsOutput() && containsExternalConnection(dir)) {
network.addInput(lo);
@Override
public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) {
super.setConnectionMode(dir, mode);
refreshInputs(dir);
}
}
@Override
public void externalConnectionAdded(ForgeDirection fromDirection) {
super.externalConnectionAdded(fromDirection);
refreshInputs(fromDirection);
}
@Override
public void externalConnectionRemoved(ForgeDirection fromDirection) {
super.externalConnectionRemoved(fromDirection);
refreshInputs(fromDirection);
}
@Override
public IIcon getTextureForState(CollidableComponent component) {
if(component.dir == ForgeDirection.UNKNOWN) {
return ICONS.get(ICON_CORE_KEY);
private void refreshInputs(ForgeDirection dir) {
if (network == null) {
return;
}
GasOutput lo = new GasOutput(getLocation().getLocation(dir), dir.getOpposite());
network.removeInput(lo);
if (getConnectionMode(dir).acceptsOutput() && containsExternalConnection(dir)) {
network.addInput(lo);
}
}
return ICONS.get(ICON_KEY);
}
public IIcon getTextureForInputMode() {
return ICONS.get(ICON_EXTRACT_KEY);
}
public IIcon getTextureForOutputMode() {
return ICONS.get(ICON_INSERT_KEY);
}
public IIcon getNotSetEdgeTexture() {
return ICONS.get(ICON_EMPTY_EDGE);
}
@Override
public IIcon getTransmitionTextureForState(CollidableComponent component) {
if(isActive() && tank.containsValidGas()) {
return tank.getGas().getGas().getIcon();
@Override
public void externalConnectionAdded(ForgeDirection fromDirection) {
super.externalConnectionAdded(fromDirection);
refreshInputs(fromDirection);
}
return null;
}
// ------------------------------------------- Gas API
@Override
@Deprecated
@Method(modid = GasUtil.API_NAME)
public int receiveGas(ForgeDirection side, GasStack stack) {
return receiveGas(side, stack, true);
}
@Override
@Method(modid = GasUtil.API_NAME)
public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) {
if(network == null || !getConnectionMode(side).acceptsInput()) {
return 0;
@Override
public void externalConnectionRemoved(ForgeDirection fromDirection) {
super.externalConnectionRemoved(fromDirection);
refreshInputs(fromDirection);
}
return network.fill(side, stack, doTransfer);
}
@Override
@Deprecated
@Method(modid = GasUtil.API_NAME)
public GasStack drawGas(ForgeDirection side, int amount) {
return drawGas(side, amount, true);
}
@Override
@Method(modid = GasUtil.API_NAME)
public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) {
if(network == null || !getConnectionMode(side).acceptsOutput()) {
return null;
@Override
public IIcon getTextureForState(CollidableComponent component) {
if (component.dir == ForgeDirection.UNKNOWN) {
return ICONS.get(ICON_CORE_KEY);
}
return ICONS.get(ICON_KEY);
}
return network.drain(side, amount, doTransfer);
}
@Override
@Method(modid = GasUtil.API_NAME)
public boolean canReceiveGas(ForgeDirection from, Gas gas) {
if(network == null) {
return false;
public IIcon getTextureForInputMode() {
return ICONS.get(ICON_EXTRACT_KEY);
}
return getConnectionMode(from).acceptsInput() && GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0));
}
@Override
@Method(modid = GasUtil.API_NAME)
public boolean canDrawGas(ForgeDirection from, Gas gas) {
if(network == null) {
return false;
public IIcon getTextureForOutputMode() {
return ICONS.get(ICON_INSERT_KEY);
}
return getConnectionMode(from).acceptsOutput() && GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0));
}
@Override
protected boolean canJoinNeighbour(IGasConduit n) {
return n instanceof GasConduit;
}
public IIcon getNotSetEdgeTexture() {
return ICONS.get(ICON_EMPTY_EDGE);
}
@Override
public AbstractGasTankConduitNetwork<? extends AbstractGasTankConduit> getTankNetwork() {
return network;
}
@Override
public IIcon getTransmitionTextureForState(CollidableComponent component) {
if (isActive() && tank.containsValidGas()) {
return tank.getGas().getGas().getIcon();
}
return null;
}
// ------------------------------------------- Gas API
@Override
@Deprecated
@Method(modid = GasUtil.API_NAME)
public int receiveGas(ForgeDirection side, GasStack stack) {
return receiveGas(side, stack, true);
}
@Override
@Method(modid = GasUtil.API_NAME)
public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) {
if (network == null || !getConnectionMode(side).acceptsInput()) {
return 0;
}
return network.fill(side, stack, doTransfer);
}
@Override
@Deprecated
@Method(modid = GasUtil.API_NAME)
public GasStack drawGas(ForgeDirection side, int amount) {
return drawGas(side, amount, true);
}
@Override
@Method(modid = GasUtil.API_NAME)
public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) {
if (network == null || !getConnectionMode(side).acceptsOutput()) {
return null;
}
return network.drain(side, amount, doTransfer);
}
@Override
@Method(modid = GasUtil.API_NAME)
public boolean canReceiveGas(ForgeDirection from, Gas gas) {
if (network == null) {
return false;
}
return getConnectionMode(from).acceptsInput()
&& GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0));
}
@Override
@Method(modid = GasUtil.API_NAME)
public boolean canDrawGas(ForgeDirection from, Gas gas) {
if (network == null) {
return false;
}
return getConnectionMode(from).acceptsOutput()
&& GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0));
}
@Override
protected boolean canJoinNeighbour(IGasConduit n) {
return n instanceof GasConduit;
}
@Override
public AbstractGasTankConduitNetwork<? extends AbstractGasTankConduit> getTankNetwork() {
return network;
}
}
@@ -4,8 +4,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -13,258 +11,259 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.enderio.core.common.util.BlockCoord;
import crazypants.enderio.conduit.IConduit;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
public class GasConduitNetwork extends AbstractGasTankConduitNetwork<GasConduit> {
private final ConduitGasTank tank = new ConduitGasTank(0);
private final ConduitGasTank tank = new ConduitGasTank(0);
private final Set<GasOutput> outputs = new HashSet<GasOutput>();
private final Set<GasOutput> outputs = new HashSet<>();
private Iterator<GasOutput> outputIterator;
private Iterator<GasOutput> outputIterator;
private int ticksActiveUnsynced;
private int ticksActiveUnsynced;
private boolean lastSyncedActive = false;
private boolean lastSyncedActive = false;
private int lastSyncedVolume = -1;
private int lastSyncedVolume = -1;
public GasConduitNetwork() {
super(GasConduit.class);
}
@Override
public void addConduit(GasConduit con) {
tank.setCapacity(tank.getMaxGas() + GasConduit.CONDUIT_VOLUME);
if(con.getTank().containsValidGas()) {
tank.addAmount(con.getTank().getStored());
public GasConduitNetwork() {
super(GasConduit.class);
}
for (ForgeDirection dir : con.getExternalConnections()) {
if(con.getConnectionMode(dir).acceptsOutput()) {
outputs.add(new GasOutput(con.getLocation().getLocation(dir), dir.getOpposite()));
}
}
outputIterator = null;
super.addConduit(con);
}
@Override
public boolean setGasType(GasStack newType) {
if(super.setGasType(newType)) {
GasStack ft = getGasType();
tank.setGas(ft == null ? null : ft.copy());
return true;
}
return false;
}
@Override
public void destroyNetwork() {
setConduitVolumes();
outputs.clear();
super.destroyNetwork();
}
private void setConduitVolumes() {
if(tank.containsValidGas() && !conduits.isEmpty()) {
GasStack gasPerConduit = tank.getGas().copy();
int numCons = conduits.size();
int leftOvers = gasPerConduit.amount % numCons;
gasPerConduit.amount = gasPerConduit.amount / numCons;
for (GasConduit con : conduits) {
GasStack f = gasPerConduit.copy();
if(leftOvers > 0) {
f.amount += 1;
leftOvers--;
@Override
public void addConduit(GasConduit con) {
tank.setCapacity(tank.getMaxGas() + GasConduit.CONDUIT_VOLUME);
if (con.getTank().containsValidGas()) {
tank.addAmount(con.getTank().getStored());
}
con.getTank().setGas(f);
BlockCoord bc = con.getLocation();
con.getBundle().getEntity().getWorldObj().markTileEntityChunkModified(bc.x, bc.y, bc.z, con.getBundle().getEntity());
}
}
}
@Override
public void doNetworkTick() {
if(gasType == null || outputs.isEmpty() || !tank.containsValidGas() || tank.isEmpty()) {
updateActiveState();
return;
}
if(outputIterator == null || !outputIterator.hasNext()) {
outputIterator = outputs.iterator();
}
updateActiveState();
int numVisited = 0;
while (!tank.isEmpty() && numVisited < outputs.size()) {
if(!outputIterator.hasNext()) {
outputIterator = outputs.iterator();
}
GasOutput output = outputIterator.next();
if(output != null) {
IGasHandler cont = getTankContainer(output.location);
if(cont != null) {
GasStack offer = tank.getGas().copy();
int filled = cont.receiveGas(output.dir, offer);
if(filled > 0) {
tank.addAmount(-filled);
}
for (ForgeDirection dir : con.getExternalConnections()) {
if (con.getConnectionMode(dir).acceptsOutput()) {
outputs.add(new GasOutput(con.getLocation().getLocation(dir), dir.getOpposite()));
}
}
}
numVisited++;
outputIterator = null;
super.addConduit(con);
}
}
@Override
public boolean setGasType(GasStack newType) {
if (super.setGasType(newType)) {
private void updateActiveState() {
boolean isActive = tank.containsValidGas() && !tank.isEmpty();
if(lastSyncedActive != isActive) {
ticksActiveUnsynced++;
} else {
ticksActiveUnsynced = 0;
}
if(ticksActiveUnsynced >= 10 || ticksActiveUnsynced > 0 && isActive) {
if(!isActive) {
setGasType(null);
}
for (IConduit con : conduits) {
con.setActive(isActive);
}
lastSyncedActive = isActive;
ticksActiveUnsynced = 0;
}
}
public int fill(ForgeDirection from, GasStack resource, boolean doFill) {
if(resource == null) {
return 0;
}
resource.amount = Math.min(resource.amount, GasConduit.MAX_IO_PER_TICK);
boolean gasWasValid = tank.containsValidGas();
int res = tank.receive(resource, doFill);
if(doFill && res > 0 && gasWasValid) {
int vol = tank.getStored();
setGasType(resource);
tank.setAmount(vol);
}
return res;
}
public GasStack drain(ForgeDirection from, GasStack resource, boolean doDrain) {
if(resource == null || tank.isEmpty() || !tank.containsValidGas() || !GasConduitNetwork.areGassCompatable(getGasType(), resource)) {
return null;
}
int amount = Math.min(resource.amount, tank.getStored());
amount = Math.min(amount, GasConduit.MAX_IO_PER_TICK);
GasStack result = resource.copy();
result.amount = amount;
if(doDrain) {
tank.addAmount(-amount);
}
return result;
}
public GasStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
if(tank.isEmpty() || !tank.containsValidGas()) {
return null;
}
int amount = Math.min(maxDrain, tank.getStored());
GasStack result = tank.getGas().copy();
result.amount = amount;
if(doDrain) {
tank.addAmount(-amount);
}
return result;
}
public boolean extractFrom(GasConduit advancedGasConduit, ForgeDirection dir, int maxExtractPerTick) {
if(tank.isFull()) {
return false;
}
IGasHandler extTank = getTankContainer(advancedGasConduit, dir);
if(extTank != null) {
int maxExtract = Math.min(maxExtractPerTick, tank.getAvailableSpace());
if(gasType == null || !tank.containsValidGas()) {
GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract);
if(drained == null || drained.amount <= 0) {
return false;
GasStack ft = getGasType();
tank.setGas(ft == null ? null : ft.copy());
return true;
}
setGasType(drained);
tank.setGas(drained.copy());
return true;
}
GasStack couldDrain = gasType.copy();
couldDrain.amount = maxExtract;
// GasStack drained = extTank.drain(dir.getOpposite(), couldDrain, true);
// if(drained == null || drained.amount <= 0) {
// return false;
// }
// tank.addAmount(drained.amount);
//Have to use this 'double handle' approach to work around an issue with TiC
GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract);
if(drained == null || drained.amount == 0) {
return false;
} else {
if(drained.isGasEqual(getGasType())) {
tank.addAmount(drained.amount);
}
@Override
public void destroyNetwork() {
setConduitVolumes();
outputs.clear();
super.destroyNetwork();
}
private void setConduitVolumes() {
if (tank.containsValidGas() && !conduits.isEmpty()) {
GasStack gasPerConduit = tank.getGas().copy();
int numCons = conduits.size();
int leftOvers = gasPerConduit.amount % numCons;
gasPerConduit.amount = gasPerConduit.amount / numCons;
for (GasConduit con : conduits) {
GasStack f = gasPerConduit.copy();
if (leftOvers > 0) {
f.amount += 1;
leftOvers--;
}
con.getTank().setGas(f);
BlockCoord bc = con.getLocation();
con.getBundle().getEntity().getWorldObj()
.markTileEntityChunkModified(bc.x, bc.y, bc.z, con.getBundle().getEntity());
}
}
}
return true;
}
return false;
}
public IGasHandler getTankContainer(BlockCoord bc) {
World w = getWorld();
if(w == null) {
return null;
@Override
public void doNetworkTick() {
if (gasType == null || outputs.isEmpty() || !tank.containsValidGas() || tank.isEmpty()) {
updateActiveState();
return;
}
if (outputIterator == null || !outputIterator.hasNext()) {
outputIterator = outputs.iterator();
}
updateActiveState();
int numVisited = 0;
while (!tank.isEmpty() && numVisited < outputs.size()) {
if (!outputIterator.hasNext()) {
outputIterator = outputs.iterator();
}
GasOutput output = outputIterator.next();
if (output != null) {
IGasHandler cont = getTankContainer(output.location);
if (cont != null) {
GasStack offer = tank.getGas().copy();
int filled = cont.receiveGas(output.dir, offer);
if (filled > 0) {
tank.addAmount(-filled);
}
}
}
numVisited++;
}
}
TileEntity te = w.getTileEntity(bc.x, bc.y, bc.z);
if(te instanceof IGasHandler) {
return (IGasHandler) te;
private void updateActiveState() {
boolean isActive = tank.containsValidGas() && !tank.isEmpty();
if (lastSyncedActive != isActive) {
ticksActiveUnsynced++;
} else {
ticksActiveUnsynced = 0;
}
if (ticksActiveUnsynced >= 10 || ticksActiveUnsynced > 0 && isActive) {
if (!isActive) {
setGasType(null);
}
for (IConduit con : conduits) {
con.setActive(isActive);
}
lastSyncedActive = isActive;
ticksActiveUnsynced = 0;
}
}
return null;
}
public IGasHandler getTankContainer(GasConduit con, ForgeDirection dir) {
BlockCoord bc = con.getLocation().getLocation(dir);
return getTankContainer(bc);
}
World getWorld() {
if(conduits.isEmpty()) {
return null;
public int fill(ForgeDirection from, GasStack resource, boolean doFill) {
if (resource == null) {
return 0;
}
resource.amount = Math.min(resource.amount, GasConduit.MAX_IO_PER_TICK);
boolean gasWasValid = tank.containsValidGas();
int res = tank.receive(resource, doFill);
if (doFill && res > 0 && gasWasValid) {
int vol = tank.getStored();
setGasType(resource);
tank.setAmount(vol);
}
return res;
}
return conduits.get(0).getBundle().getWorld();
}
public void removeInput(GasOutput lo) {
outputs.remove(lo);
outputIterator = null;
}
public void addInput(GasOutput lo) {
outputs.add(lo);
outputIterator = null;
}
public void updateConduitVolumes() {
if(tank.getStored() == lastSyncedVolume) {
return;
public GasStack drain(ForgeDirection from, GasStack resource, boolean doDrain) {
if (resource == null || tank.isEmpty()
|| !tank.containsValidGas()
|| !GasConduitNetwork.areGassCompatable(getGasType(), resource)) {
return null;
}
int amount = Math.min(resource.amount, tank.getStored());
amount = Math.min(amount, GasConduit.MAX_IO_PER_TICK);
GasStack result = resource.copy();
result.amount = amount;
if (doDrain) {
tank.addAmount(-amount);
}
return result;
}
setConduitVolumes();
lastSyncedVolume = tank.getStored();
}
public GasStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
if (tank.isEmpty() || !tank.containsValidGas()) {
return null;
}
int amount = Math.min(maxDrain, tank.getStored());
GasStack result = tank.getGas().copy();
result.amount = amount;
if (doDrain) {
tank.addAmount(-amount);
}
return result;
}
public boolean extractFrom(GasConduit advancedGasConduit, ForgeDirection dir, int maxExtractPerTick) {
if (tank.isFull()) {
return false;
}
IGasHandler extTank = getTankContainer(advancedGasConduit, dir);
if (extTank != null) {
int maxExtract = Math.min(maxExtractPerTick, tank.getAvailableSpace());
if (gasType == null || !tank.containsValidGas()) {
GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract);
if (drained == null || drained.amount <= 0) {
return false;
}
setGasType(drained);
tank.setGas(drained.copy());
return true;
}
GasStack couldDrain = gasType.copy();
couldDrain.amount = maxExtract;
// GasStack drained = extTank.drain(dir.getOpposite(), couldDrain, true);
// if(drained == null || drained.amount <= 0) {
// return false;
// }
// tank.addAmount(drained.amount);
// Have to use this 'double handle' approach to work around an issue with TiC
GasStack drained = extTank.drawGas(dir.getOpposite(), maxExtract);
if (drained == null || drained.amount == 0) {
return false;
} else {
if (drained.isGasEqual(getGasType())) {
tank.addAmount(drained.amount);
}
}
return true;
}
return false;
}
public IGasHandler getTankContainer(BlockCoord bc) {
World w = getWorld();
if (w == null) {
return null;
}
TileEntity te = w.getTileEntity(bc.x, bc.y, bc.z);
if (te instanceof IGasHandler) {
return (IGasHandler) te;
}
return null;
}
public IGasHandler getTankContainer(GasConduit con, ForgeDirection dir) {
BlockCoord bc = con.getLocation().getLocation(dir);
return getTankContainer(bc);
}
World getWorld() {
if (conduits.isEmpty()) {
return null;
}
return conduits.get(0).getBundle().getWorld();
}
public void removeInput(GasOutput lo) {
outputs.remove(lo);
outputIterator = null;
}
public void addInput(GasOutput lo) {
outputs.add(lo);
outputIterator = null;
}
public void updateConduitVolumes() {
if (tank.getStored() == lastSyncedVolume) {
return;
}
setConduitVolumes();
lastSyncedVolume = tank.getStored();
}
}
@@ -1,13 +1,13 @@
package crazypants.enderio.conduit.gas;
import java.util.List;
import mekanism.api.gas.GasStack;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import com.enderio.core.client.render.BoundingBox;
import com.enderio.core.client.render.CubeRenderer;
import com.enderio.core.client.render.RenderUtil;
import com.enderio.core.common.vecmath.Vector3d;
import com.enderio.core.common.vecmath.Vertex;
@@ -20,162 +20,166 @@ import crazypants.enderio.conduit.geom.CollidableComponent;
import crazypants.enderio.conduit.geom.ConnectionModeGeometry;
import crazypants.enderio.conduit.geom.Offset;
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
import crazypants.enderio.conduit.render.ConduitRenderer;
import crazypants.enderio.conduit.render.DefaultConduitRenderer;
import static com.enderio.core.client.render.CubeRenderer.addVecWithUV;
import mekanism.api.gas.GasStack;
public class GasConduitRenderer extends DefaultConduitRenderer {
@Override
public boolean isRendererForConduit(IConduit conduit) {
return conduit instanceof GasConduit;
}
public static final ThreadLocal<ConduitRenderer> instance = ThreadLocal.withInitial(GasConduitRenderer::new);
@Override
public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x, double y, double z, float partialTick,
float worldLight, RenderBlocks rb) {
super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight, rb);
if(!conduit.hasConnectionMode(ConnectionMode.INPUT) && !conduit.hasConnectionMode(ConnectionMode.OUTPUT)) {
return;
}
GasConduit pc = (GasConduit) conduit;
for (ForgeDirection dir : conduit.getExternalConnections()) {
IIcon tex = null;
if(conduit.getConnectionMode(dir) == ConnectionMode.INPUT) {
tex = pc.getTextureForInputMode();
} else if(conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) {
tex = pc.getTextureForOutputMode();
}
if(tex != null) {
Offset offset = te.getOffset(IGasConduit.class, dir);
ConnectionModeGeometry.renderModeConnector(dir, offset, tex, true);
}
}
}
@Override
protected void renderConduit(IIcon tex, IConduit conduit, CollidableComponent component, float brightness) {
super.renderConduit(tex, conduit, component, brightness);
if(isNSEWUD(component.dir)) {
GasConduit lc = (GasConduit) conduit;
GasStack gas = lc.getGasType();
IIcon texture = null;
if(gas != null) {
texture = gas.getGas().getIcon();
}
if(texture == null) {
texture = lc.getNotSetEdgeTexture();
}
float scaleFactor = 0.75f;
float xLen = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor;
float yLen = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor;
float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor;
BoundingBox cube = component.bound;
BoundingBox bb = cube.scale(xLen, yLen, zLen);
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if(d != component.dir && d != component.dir.getOpposite()) {
ForgeDirection vDir = RenderUtil.getVDirForFace(d);
if(component.dir == ForgeDirection.UP || component.dir == ForgeDirection.DOWN) {
vDir = RenderUtil.getUDirForFace(d);
} else if((component.dir == ForgeDirection.NORTH || component.dir == ForgeDirection.SOUTH) && d.offsetY != 0) {
vDir = RenderUtil.getUDirForFace(d);
}
float minU = texture.getMinU();
float maxU = texture.getMaxU();
float minV = texture.getMinV();
float maxV = texture.getMaxV();
float sideScale = Math.max(bb.sizeX(), bb.sizeY()) * 2 / 16f;
sideScale = Math.max(sideScale, bb.sizeZ() * 2 / 16f);
float width = Math.min(bb.sizeX(), bb.sizeY()) * 15f / 16f;
List<Vertex> corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV);
moveEdgeCorners(corners, vDir, width);
moveEdgeCorners(corners, component.dir.getOpposite(), sideScale);
for (Vertex c : corners) {
addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV);
moveEdgeCorners(corners, vDir.getOpposite(), width);
moveEdgeCorners(corners, component.dir.getOpposite(), sideScale);
for (Vertex c : corners) {
addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
@Override
public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit, double x,
double y, double z, float partialTick, float worldLight, RenderBlocks rb) {
super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight, rb);
if (!conduit.hasConnectionMode(ConnectionMode.INPUT) && !conduit.hasConnectionMode(ConnectionMode.OUTPUT)) {
return;
}
}
if(conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) {
tex = EnderIO.blockConduitBundle.getConnectorIcon(component.data);
List<Vertex> corners = component.bound.getCornersWithUvForFace(component.dir, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV());
Tessellator tessellator = Tessellator.instance;
for (Vertex c : corners) {
addVecWithUV(c.xyz, c.uv.x, c.uv.y);
GasConduit pc = (GasConduit) conduit;
for (ForgeDirection dir : conduit.getExternalConnections()) {
IIcon tex = null;
if (conduit.getConnectionMode(dir) == ConnectionMode.INPUT) {
tex = pc.getTextureForInputMode();
} else if (conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) {
tex = pc.getTextureForOutputMode();
}
if (tex != null) {
Offset offset = te.getOffset(IGasConduit.class, dir);
ConnectionModeGeometry.renderModeConnector(dir, offset, tex, true);
}
}
//back face
for (int i = corners.size() - 1; i >= 0; i--) {
Vertex c = corners.get(i);
addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
@Override
protected void renderConduit(IIcon tex, IConduit conduit, CollidableComponent component, float brightness) {
super.renderConduit(tex, conduit, component, brightness);
final CubeRenderer cr = CubeRenderer.get();
int i;
if (isNSEWUD(component.dir)) {
GasConduit lc = (GasConduit) conduit;
GasStack gas = lc.getGasType();
IIcon texture = null;
if (gas != null) {
texture = gas.getGas().getIcon();
}
if (texture == null) {
texture = lc.getNotSetEdgeTexture();
}
float scaleFactor = 0.75f;
float xLen = Math.abs(component.dir.offsetX) == 1 ? 1 : scaleFactor;
float yLen = Math.abs(component.dir.offsetY) == 1 ? 1 : scaleFactor;
float zLen = Math.abs(component.dir.offsetZ) == 1 ? 1 : scaleFactor;
BoundingBox cube = component.bound;
BoundingBox bb = cube.scale(xLen, yLen, zLen);
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (d != component.dir && d != component.dir.getOpposite()) {
ForgeDirection vDir = RenderUtil.getVDirForFace(d);
if (component.dir == ForgeDirection.UP || component.dir == ForgeDirection.DOWN) {
vDir = RenderUtil.getUDirForFace(d);
} else if ((component.dir == ForgeDirection.NORTH || component.dir == ForgeDirection.SOUTH)
&& d.offsetY != 0) {
vDir = RenderUtil.getUDirForFace(d);
}
float minU = texture.getMinU();
float maxU = texture.getMaxU();
float minV = texture.getMinV();
float maxV = texture.getMaxV();
float sideScale = Math.max(bb.sizeX(), bb.sizeY()) * 2 / 16f;
sideScale = Math.max(sideScale, bb.sizeZ() * 2 / 16f);
float width = Math.min(bb.sizeX(), bb.sizeY()) * 15f / 16f;
List<Vertex> corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV);
moveEdgeCorners(corners, vDir, width);
moveEdgeCorners(corners, component.dir.getOpposite(), sideScale);
for (i = 0; i < corners.size(); i++) {
final Vertex c = corners.get(i);
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV);
moveEdgeCorners(corners, vDir.getOpposite(), width);
moveEdgeCorners(corners, component.dir.getOpposite(), sideScale);
for (i = 0; i < corners.size(); i++) {
final Vertex c = corners.get(i);
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
}
}
if (conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) {
tex = EnderIO.blockConduitBundle.getConnectorIcon(component.data);
List<Vertex> corners = component.bound.getCornersWithUvForFace(
component.dir,
tex.getMinU(),
tex.getMaxU(),
tex.getMinV(),
tex.getMaxV());
for (i = 0; i < corners.size(); i++) {
final Vertex c = corners.get(i);
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
// back face
for (i = corners.size() - 1; i >= 0; i--) {
final Vertex c = corners.get(i);
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
}
}
}
}
}
}
@Override
protected void renderTransmission(IConduit conduit, IIcon tex, CollidableComponent component, float selfIllum) {
super.renderTransmission(conduit, tex, component, selfIllum);
}
@Override
protected void renderTransmission(IConduit conduit, IIcon tex, CollidableComponent component, float selfIllum) {
super.renderTransmission(conduit, tex, component, selfIllum);
}
private void moveEdgeCorners(List<Vertex> vertices, ForgeDirection edge, float scaleFactor) {
int[] indices = getClosest(edge, vertices);
vertices.get(indices[0]).xyz.x -= scaleFactor * edge.offsetX;
vertices.get(indices[1]).xyz.x -= scaleFactor * edge.offsetX;
vertices.get(indices[0]).xyz.y -= scaleFactor * edge.offsetY;
vertices.get(indices[1]).xyz.y -= scaleFactor * edge.offsetY;
vertices.get(indices[0]).xyz.z -= scaleFactor * edge.offsetZ;
vertices.get(indices[1]).xyz.z -= scaleFactor * edge.offsetZ;
}
private void moveEdgeCorners(List<Vertex> vertices, ForgeDirection edge, float scaleFactor) {
int[] indices = getClosest(edge, vertices);
vertices.get(indices[0]).xyz.x -= scaleFactor * edge.offsetX;
vertices.get(indices[1]).xyz.x -= scaleFactor * edge.offsetX;
vertices.get(indices[0]).xyz.y -= scaleFactor * edge.offsetY;
vertices.get(indices[1]).xyz.y -= scaleFactor * edge.offsetY;
vertices.get(indices[0]).xyz.z -= scaleFactor * edge.offsetZ;
vertices.get(indices[1]).xyz.z -= scaleFactor * edge.offsetZ;
}
private int[] getClosest(ForgeDirection edge, List<Vertex> vertices) {
int[] res = new int[] { -1, -1 };
boolean highest = edge.offsetX > 0 || edge.offsetY > 0 || edge.offsetZ > 0;
double minMax = highest ? -Double.MAX_VALUE : Double.MAX_VALUE;
int index = 0;
for (Vertex v : vertices) {
double val = get(v.xyz, edge);
if(highest ? val >= minMax : val <= minMax) {
if(val != minMax) {
res[0] = index;
} else {
res[1] = index;
private int[] getClosest(ForgeDirection edge, List<Vertex> vertices) {
int[] res = new int[] { -1, -1 };
boolean highest = edge.offsetX > 0 || edge.offsetY > 0 || edge.offsetZ > 0;
double minMax = highest ? -Double.MAX_VALUE : Double.MAX_VALUE;
int index = 0;
for (Vertex v : vertices) {
double val = get(v.xyz, edge);
if (highest ? val >= minMax : val <= minMax) {
if (val != minMax) {
res[0] = index;
} else {
res[1] = index;
}
minMax = val;
}
index++;
}
minMax = val;
}
index++;
return res;
}
return res;
}
private double get(Vector3d xyz, ForgeDirection edge) {
if(edge == ForgeDirection.EAST || edge == ForgeDirection.WEST) {
return xyz.x;
private double get(Vector3d xyz, ForgeDirection edge) {
if (edge == ForgeDirection.EAST || edge == ForgeDirection.WEST) {
return xyz.x;
}
if (edge == ForgeDirection.UP || edge == ForgeDirection.DOWN) {
return xyz.y;
}
return xyz.z;
}
if(edge == ForgeDirection.UP || edge == ForgeDirection.DOWN) {
return xyz.y;
}
return xyz.z;
}
}
@@ -6,45 +6,38 @@ import com.enderio.core.common.util.BlockCoord;
public class GasOutput {
final ForgeDirection dir;
final BlockCoord location;
final ForgeDirection dir;
final BlockCoord location;
public GasOutput(BlockCoord bc, ForgeDirection dir) {
this.dir = dir;
this.location = bc;
}
public GasOutput(BlockCoord bc, ForgeDirection dir) {
this.dir = dir;
this.location = bc;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
return result;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if(this == obj)
return true;
if(obj == null)
return false;
if(getClass() != obj.getClass())
return false;
GasOutput other = (GasOutput) obj;
if(location == null) {
if(other.location != null)
return false;
} else if(!location.equals(other.location))
return false;
if(dir != other.dir)
return false;
return true;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
GasOutput other = (GasOutput) obj;
if (location == null) {
if (other.location != null) return false;
} else if (!location.equals(other.location)) return false;
if (dir != other.dir) return false;
return true;
}
@Override
public String toString() {
return "GasOutput [dir=" + dir + ", location=" + location + "]";
}
}
@Override
public String toString() {
return "GasOutput [dir=" + dir + ", location=" + location + "]";
}
}
@@ -1,7 +1,5 @@
package crazypants.enderio.conduit.gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
@@ -11,62 +9,63 @@ import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.common.Optional.Method;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.config.Config;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.IGasHandler;
public final class GasUtil {
private static boolean useCheckPerformed = false;
private static boolean isGasConduitEnabled = false;
public static final String API_NAME = "MekanismAPI|gas";
private static boolean useCheckPerformed = false;
private static boolean isGasConduitEnabled = false;
public static boolean isGasConduitEnabled() {
if(!useCheckPerformed) {
if(Config.isGasConduitEnabled) {
isGasConduitEnabled = ModAPIManager.INSTANCE.hasAPI(API_NAME);
} else {
isGasConduitEnabled = false;
}
useCheckPerformed = true;
public static final String API_NAME = "MekanismAPI|gas";
public static boolean isGasConduitEnabled() {
if (!useCheckPerformed) {
if (Config.isGasConduitEnabled) {
isGasConduitEnabled = ModAPIManager.INSTANCE.hasAPI(API_NAME);
} else {
isGasConduitEnabled = false;
}
useCheckPerformed = true;
}
return isGasConduitEnabled;
}
return isGasConduitEnabled;
}
@Method(modid = API_NAME)
public static IGasHandler getExternalGasHandler(IBlockAccess world, BlockCoord bc) {
IGasHandler con = getGasHandler(world, bc);
return (con != null && !(con instanceof IConduitBundle)) ? con : null;
}
@Method(modid = API_NAME)
public static IGasHandler getGasHandler(IBlockAccess world, BlockCoord bc) {
return getGasHandler(world, bc.x, bc.y, bc.z);
}
@Method(modid = API_NAME)
public static IGasHandler getGasHandler(IBlockAccess world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
return getGasHandler(te);
}
@Method(modid = API_NAME)
public static IGasHandler getGasHandler(TileEntity te) {
if(te instanceof IGasHandler) {
return (IGasHandler) te;
@Method(modid = API_NAME)
public static IGasHandler getExternalGasHandler(IBlockAccess world, BlockCoord bc) {
IGasHandler con = getGasHandler(world, bc);
return (con != null && !(con instanceof IConduitBundle)) ? con : null;
}
return null;
}
@Method(modid = API_NAME)
public static boolean isGasValid(GasStack gas) {
if(gas != null) {
String name = gas.getGas().getLocalizedName();
if(name != null && !name.trim().isEmpty()) {
return true;
}
@Method(modid = API_NAME)
public static IGasHandler getGasHandler(IBlockAccess world, BlockCoord bc) {
return getGasHandler(world, bc.x, bc.y, bc.z);
}
return false;
}
private GasUtil() {
}
@Method(modid = API_NAME)
public static IGasHandler getGasHandler(IBlockAccess world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
return getGasHandler(te);
}
@Method(modid = API_NAME)
public static IGasHandler getGasHandler(TileEntity te) {
if (te instanceof IGasHandler) {
return (IGasHandler) te;
}
return null;
}
@Method(modid = API_NAME)
public static boolean isGasValid(GasStack gas) {
if (gas != null) {
String name = gas.getGas().getLocalizedName();
if (name != null && !name.trim().isEmpty()) {
return true;
}
}
return false;
}
private GasUtil() {}
}
@@ -1,16 +1,16 @@
package crazypants.enderio.conduit.gas;
import mekanism.api.gas.IGasHandler;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional.Interface;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IExtractor;
import mekanism.api.gas.IGasHandler;
@Interface(iface = "mekanism.api.gas.IGasHandler", modid = GasUtil.API_NAME)
public interface IGasConduit extends IConduit, IGasHandler, IExtractor {
boolean canOutputToDir(ForgeDirection dir);
boolean isExtractingFromDir(ForgeDirection dir);
boolean canOutputToDir(ForgeDirection dir);
boolean isExtractingFromDir(ForgeDirection dir);
}
@@ -21,61 +21,60 @@ import crazypants.enderio.gui.IconEIO;
public class ItemGasConduit extends AbstractItemConduit implements IAdvancedTooltipProvider {
private static ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
new ItemConduitSubtype(ModObject.itemGasConduit.name(), "enderio:itemGasConduit"),
};
private static final ItemConduitSubtype[] subtypes = new ItemConduitSubtype[] {
new ItemConduitSubtype(ModObject.itemGasConduit.name(), "enderio:itemGasConduit"), };
public static ItemGasConduit create() {
ItemGasConduit result = new ItemGasConduit();
if (GasUtil.isGasConduitEnabled()) {
result.init();
ConduitDisplayMode.registerDisplayMode(new ConduitDisplayMode(IGasConduit.class, IconEIO.WRENCH_OVERLAY_GAS, IconEIO.WRENCH_OVERLAY_GAS_OFF));
public static ItemGasConduit create() {
ItemGasConduit result = new ItemGasConduit();
if (GasUtil.isGasConduitEnabled()) {
result.init();
ConduitDisplayMode.registerDisplayMode(
new ConduitDisplayMode(
IGasConduit.class,
IconEIO.WRENCH_OVERLAY_GAS,
IconEIO.WRENCH_OVERLAY_GAS_OFF));
}
return result;
}
return result;
}
protected ItemGasConduit() {
super(ModObject.itemGasConduit, subtypes);
if(!GasUtil.isGasConduitEnabled()) {
setCreativeTab(null);
protected ItemGasConduit() {
super(ModObject.itemGasConduit, subtypes);
if (!GasUtil.isGasConduitEnabled()) {
setCreativeTab(null);
}
}
}
@Override
public Class<? extends IConduit> getBaseConduitType() {
return IGasConduit.class;
}
@Override
public Class<? extends IConduit> getBaseConduitType() {
return IGasConduit.class;
}
@Override
public IConduit createConduit(ItemStack stack, EntityPlayer player) {
return new GasConduit();
}
@Override
public IConduit createConduit(ItemStack stack, EntityPlayer player) {
return new GasConduit();
}
@Override
@SideOnly(Side.CLIENT)
public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
}
@Override
@SideOnly(Side.CLIENT)
public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {}
@Override
@SideOnly(Side.CLIENT)
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
@Override
@SideOnly(Side.CLIENT)
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {}
}
@Override
@SideOnly(Side.CLIENT)
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
String gpt = " " + EnderIO.lang.localize("gas.gasTick");
int extractRate = Config.gasConduitExtractRate;
int maxIo = Config.gasConduitMaxIoRate;
list.add(EnderIO.lang.localize("itemGasConduit.tooltip.maxExtract") + " " + extractRate + gpt);
list.add(EnderIO.lang.localize("itemGasConduit.tooltip.maxIo") + " " + maxIo + gpt);
SpecialTooltipHandler.addDetailedTooltipFromResources(list, "enderio.itemGasConduit");
}
@Override
public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {
String gpt = " " + EnderIO.lang.localize("gas.gasTick");
int extractRate = Config.gasConduitExtractRate;
int maxIo = Config.gasConduitMaxIoRate;
list.add(EnderIO.lang.localize("itemGasConduit.tooltip.maxExtract") + " " + extractRate + gpt);
list.add(EnderIO.lang.localize("itemGasConduit.tooltip.maxIo") + " " + maxIo + gpt);
SpecialTooltipHandler.addDetailedTooltipFromResources(list, "enderio.itemGasConduit");
}
@Override
public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) {
return true;
}
}
@@ -1,6 +1,5 @@
package crazypants.enderio.conduit.gas;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -11,35 +10,35 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.util.ClientUtil;
import io.netty.buffer.ByteBuf;
public class PacketGasLevel extends MessageTileEntity<TileEntity> implements IMessageHandler<PacketGasLevel, IMessage> {
public NBTTagCompound tc;
public NBTTagCompound tc;
public PacketGasLevel() {
}
public PacketGasLevel() {}
public PacketGasLevel(IGasConduit conduit) {
super(conduit.getBundle().getEntity());
tc = new NBTTagCompound();
conduit.writeToNBT(tc);
}
public PacketGasLevel(IGasConduit conduit) {
super(conduit.getBundle().getEntity());
tc = new NBTTagCompound();
conduit.writeToNBT(tc);
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
ByteBufUtils.writeTag(buf, tc);
}
@Override
public void toBytes(ByteBuf buf) {
super.toBytes(buf);
ByteBufUtils.writeTag(buf, tc);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
tc = ByteBufUtils.readTag(buf);
}
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
tc = ByteBufUtils.readTag(buf);
}
@Override
public IMessage onMessage(PacketGasLevel message, MessageContext ctx) {
ClientUtil.doGasLevelUpdate(message.x, message.y, message.z, message);
return null;
}
@Override
public IMessage onMessage(PacketGasLevel message, MessageContext ctx) {
ClientUtil.doGasLevelUpdate(message.x, message.y, message.z, message);
return null;
}
}
@@ -5,86 +5,85 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraftforge.common.util.ForgeDirection;
import crazypants.enderio.conduit.IConduit;
public class CollidableCache {
public static final CollidableCache instance = new CollidableCache();
public static final CollidableCache instance = new CollidableCache();
private final Map<CacheKey, Collection<CollidableComponent>> cache = new HashMap<CollidableCache.CacheKey, Collection<CollidableComponent>>();
private final Map<CacheKey, Collection<CollidableComponent>> cache = new HashMap<>();
public CacheKey createKey(Class<? extends IConduit> baseType, Offset offset, ForgeDirection dir, boolean isStub) {
return new CacheKey(baseType, offset, dir, isStub);
}
public Collection<CollidableComponent> getCollidables(CacheKey key, IConduit conduit) {
Collection<CollidableComponent> result = cache.get(key);
if(result == null) {
result = conduit.createCollidables(key);
cache.put(key, result);
}
return result;
}
public static class CacheKey {
public final Class<? extends IConduit> baseType;
public final String className; // used to generate reliable equals /
// hashcode
public final Offset offset;
public final ForgeDirection dir;
public final boolean isStub;
public CacheKey(Class<? extends IConduit> baseType, Offset offset, ForgeDirection dir, boolean isStub) {
this.baseType = baseType;
className = baseType.getCanonicalName();
this.offset = offset;
this.dir = dir;
this.isStub = isStub;
public CacheKey createKey(Class<? extends IConduit> baseType, Offset offset, ForgeDirection dir, boolean isStub) {
return new CacheKey(baseType, offset, dir, isStub);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
result = prime * result + (isStub ? 1231 : 1237);
result = prime * result + ((offset == null) ? 0 : offset.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if(this == obj) {
return true;
}
if(obj == null) {
return false;
}
if(getClass() != obj.getClass()) {
return false;
}
CacheKey other = (CacheKey) obj;
if(className == null) {
if(other.className != null) {
return false;
public Collection<CollidableComponent> getCollidables(CacheKey key, IConduit conduit) {
Collection<CollidableComponent> result = cache.get(key);
if (result == null) {
result = conduit.createCollidables(key);
cache.put(key, result);
}
} else if(!className.equals(other.className)) {
return false;
}
if(dir != other.dir) {
return false;
}
if(isStub != other.isStub) {
return false;
}
if(offset != other.offset) {
return false;
}
return true;
return result;
}
}
public static class CacheKey {
public final Class<? extends IConduit> baseType;
public final String className; // used to generate reliable equals /
// hashcode
public final Offset offset;
public final ForgeDirection dir;
public final boolean isStub;
public CacheKey(Class<? extends IConduit> baseType, Offset offset, ForgeDirection dir, boolean isStub) {
this.baseType = baseType;
className = baseType.getCanonicalName();
this.offset = offset;
this.dir = dir;
this.isStub = isStub;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
result = prime * result + (isStub ? 1231 : 1237);
result = prime * result + ((offset == null) ? 0 : offset.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
CacheKey other = (CacheKey) obj;
if (className == null) {
if (other.className != null) {
return false;
}
} else if (!className.equals(other.className)) {
return false;
}
if (dir != other.dir) {
return false;
}
if (isStub != other.isStub) {
return false;
}
if (offset != other.offset) {
return false;
}
return true;
}
}
}
@@ -8,39 +8,41 @@ import crazypants.enderio.conduit.IConduit;
public class CollidableComponent {
public final Class<? extends IConduit> conduitType;
public final BoundingBox bound;
public final ForgeDirection dir;
public final Object data;
public final Class<? extends IConduit> conduitType;
public final BoundingBox bound;
public final ForgeDirection dir;
public final Object data;
public CollidableComponent(Class<? extends IConduit> conduitType, BoundingBox bound, ForgeDirection id, Object data) {
this.conduitType = conduitType;
this.bound = bound;
this.dir = id;
this.data = data;
}
@Override
public String toString() {
return "CollidableComponent [conduitType=" + conduitType + ", bound=" + bound + ", id=" + dir + "]";
}
@Override
public boolean equals(Object obj) {
if(obj instanceof CollidableComponent) {
CollidableComponent other = (CollidableComponent) obj;
return conduitType == other.conduitType && bound.equals(((CollidableComponent) obj).bound) && dir == other.dir;
public CollidableComponent(Class<? extends IConduit> conduitType, BoundingBox bound, ForgeDirection id,
Object data) {
this.conduitType = conduitType;
this.bound = bound;
this.dir = id;
this.data = data;
}
return false;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((bound == null) ? 0 : bound.hashCode());
result = prime * result + ((conduitType == null) ? 0 : conduitType.getName().hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
return result;
}
@Override
public String toString() {
return "CollidableComponent [conduitType=" + conduitType + ", bound=" + bound + ", id=" + dir + "]";
}
@Override
public boolean equals(Object obj) {
if (obj instanceof CollidableComponent) {
CollidableComponent other = (CollidableComponent) obj;
return conduitType == other.conduitType && bound.equals(((CollidableComponent) obj).bound)
&& dir == other.dir;
}
return false;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((bound == null) ? 0 : bound.hashCode());
result = prime * result + ((conduitType == null) ? 0 : conduitType.getName().hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
return result;
}
}
@@ -1,8 +1,6 @@
package crazypants.enderio.conduit.geom;
public enum ConduitConnectorType {
INTERNAL,
EXTERNAL
INTERNAL,
EXTERNAL
}
@@ -15,194 +15,197 @@ import crazypants.enderio.conduit.IConduit;
public class ConduitGeometryUtil {
public static final ConduitGeometryUtil instance = new ConduitGeometryUtil();
public static final ConduitGeometryUtil instance = new ConduitGeometryUtil();
public static float STUB_WIDTH = 0.2f;
public static float STUB_HEIGHT = 0.2f;
public static float STUB_WIDTH = 0.2f;
public static float STUB_HEIGHT = 0.2f;
public static float WIDTH;
public static float HEIGHT;
public static float WIDTH;
public static float HEIGHT;
public static float HWIDTH;
public static float HHEIGHT;
public static float HWIDTH;
public static float HHEIGHT;
// All values are for a single conduit core
public static Vector3d CORE_MIN;
public static Vector3d CORE_MAX;
public static BoundingBox CORE_BOUNDS;
// All values are for a single conduit core
public static Vector3d CORE_MIN;
public static Vector3d CORE_MAX;
public static BoundingBox CORE_BOUNDS;
public static final float CONNECTOR_DEPTH = 0.05f;
public static final float CONNECTOR_DEPTH = 0.05f;
private static Map<ForgeDirection, BoundingBox[]> EXTERNAL_CONNECTOR_BOUNDS = new HashMap<ForgeDirection, BoundingBox[]>();
private static final Map<ForgeDirection, BoundingBox[]> EXTERNAL_CONNECTOR_BOUNDS = new HashMap<>();
static {
setupBounds(0.5f);
}
public static void setupBounds(float scale) {
float size = 0.075f + (0.175f * scale);
WIDTH = size;
HEIGHT = size;
HWIDTH = WIDTH / 2;
HHEIGHT = HEIGHT / 2;
CORE_MIN = new Vector3d(0.5f - HWIDTH, 0.5 - HHEIGHT, 0.5 - HWIDTH);
CORE_MAX = new Vector3d(CORE_MIN.x + WIDTH, CORE_MIN.y + HEIGHT, CORE_MIN.z + WIDTH);
CORE_BOUNDS = new BoundingBox(CORE_MIN, CORE_MAX);
float connectorWidth = 0.25f + (scale * 0.5f);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
EXTERNAL_CONNECTOR_BOUNDS.put(dir, createExternalConnector(dir, CONNECTOR_DEPTH, connectorWidth));
}
}
private static BoundingBox[] createExternalConnector(ForgeDirection dir, float connectorDepth, float connectorWidth) {
BoundingBox[] res = new BoundingBox[2];
float cMin = 0.5f - connectorWidth / 2;
float cMax = 0.5f + connectorWidth / 2;
float dMin = 1 - connectorDepth / 2;
float dMax = 1;
res[0] = createConnectorComponent(dir, cMin, cMax, dMin, dMax);
cMin = 0.5f - connectorWidth / 3;
cMax = 0.5f + connectorWidth / 3;
dMin = 1 - connectorDepth;
dMax = 1 - connectorDepth / 2;
res[1] = createConnectorComponent(dir, cMin, cMax, dMin, dMax);
return res;
}
private static BoundingBox createConnectorComponent(ForgeDirection dir, float cornerMin, float cornerMax, float depthMin, float depthMax) {
float minX = (1 - Math.abs(dir.offsetX)) * cornerMin + dir.offsetX * depthMin;
float minY = (1 - Math.abs(dir.offsetY)) * cornerMin + dir.offsetY * depthMin;
float minZ = (1 - Math.abs(dir.offsetZ)) * cornerMin + dir.offsetZ * depthMin;
float maxX = (1 - Math.abs(dir.offsetX)) * cornerMax + (dir.offsetX * depthMax);
float maxY = (1 - Math.abs(dir.offsetY)) * cornerMax + (dir.offsetY * depthMax);
float maxZ = (1 - Math.abs(dir.offsetZ)) * cornerMax + (dir.offsetZ * depthMax);
minX = fix(minX);
minY = fix(minY);
minZ = fix(minZ);
maxX = fix(maxX);
maxY = fix(maxY);
maxZ = fix(maxZ);
BoundingBox bb = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
bb = bb.fixMinMax();
return bb;
}
private static float fix(float val) {
return val < 0 ? 1 + val : val;
}
private Map<GeometryKey, BoundingBox> boundsCache = new HashMap<GeometryKey, BoundingBox>();
private EnumMap<ConduitConnectorType, BoundingBox> connectorBounds = new EnumMap<ConduitConnectorType, BoundingBox>(ConduitConnectorType.class);
private ConduitGeometryUtil() {
}
public BoundingBox getExternalConnectorBoundingBox(ForgeDirection dir) {
return getExternalConnectorBoundingBoxes(dir)[0];
}
public BoundingBox[] getExternalConnectorBoundingBoxes(ForgeDirection dir) {
return EXTERNAL_CONNECTOR_BOUNDS.get(dir);
}
public BoundingBox getBoundingBox(Class<? extends IConduit> type, ForgeDirection dir, boolean isStub, Offset offset) {
GeometryKey key = new GeometryKey(dir, isStub, offset, type);
BoundingBox result = boundsCache.get(key);
if(result == null) {
result = createConduitBounds(type, key);
boundsCache.put(key, result);
}
return result;
}
public Vector3d getTranslation(ForgeDirection dir, Offset offset) {
Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, offset.zOffset);
result.scale(WIDTH);
return result;
}
public BoundingBox createBoundsForConnectionController(ForgeDirection dir, Offset offset) {
Vector3d nonUniformScale = ForgeDirectionOffsets.forDirCopy(dir);
nonUniformScale.scale(0.5);
nonUniformScale.x = 0.8 * (1 - Math.abs(nonUniformScale.x));
nonUniformScale.y = 0.8 * (1 - Math.abs(nonUniformScale.y));
nonUniformScale.z = 0.8 * (1 - Math.abs(nonUniformScale.z));
BoundingBox bb = CORE_BOUNDS;
bb = bb.scale(nonUniformScale.x, nonUniformScale.y, nonUniformScale.z);
double offsetFromEnd = Math.min(bb.sizeX(), bb.sizeY());
offsetFromEnd = Math.min(offsetFromEnd, bb.sizeZ());
offsetFromEnd = Math.max(offsetFromEnd, 0.075);
double transMag = 0.5 - (offsetFromEnd * 1.2);
Vector3d trans = ForgeDirectionOffsets.forDirCopy(dir);
trans.scale(transMag);
bb = bb.translate(trans);
bb = bb.translate(getTranslation(dir, offset));
return bb;
}
private BoundingBox createConduitBounds(Class<? extends IConduit> type, GeometryKey key) {
return createConduitBounds(type, key.dir, key.isStub, key.offset);
}
private BoundingBox createConduitBounds(Class<? extends IConduit> type, ForgeDirection dir, boolean isStub, Offset offset) {
BoundingBox bb = CORE_BOUNDS;
Vector3d min = bb.getMin();
Vector3d max = bb.getMax();
switch (dir) {
case WEST:
min.x = isStub ? Math.max(0, bb.minX - STUB_WIDTH) : 0;
max.x = bb.minX;
break;
case EAST:
min.x = bb.maxX;
max.x = isStub ? Math.min(1, bb.maxX + STUB_WIDTH) : 1;
break;
case DOWN:
min.y = isStub ? Math.max(0, bb.minY - STUB_HEIGHT) : 0;
max.y = bb.minY;
break;
case UP:
max.y = isStub ? Math.min(1, bb.maxY + STUB_HEIGHT) : 1;
min.y = bb.maxY;
break;
case NORTH:
min.z = isStub ? Math.max(0.0F, bb.minZ - STUB_WIDTH) : 0;
max.z = bb.minZ;
break;
case SOUTH:
max.z = isStub ? Math.min(1F, bb.maxZ + STUB_WIDTH) : 1;
min.z = bb.maxZ;
break;
default:
break;
static {
setupBounds(0.5f);
}
Vector3d trans = getTranslation(dir, offset);
min.add(trans);
max.add(trans);
bb = new BoundingBox(VecmathUtil.clamp(min, 0, 1), VecmathUtil.clamp(max, 0, 1));
return bb;
}
public static void setupBounds(float scale) {
float size = 0.075f + (0.175f * scale);
WIDTH = size;
HEIGHT = size;
HWIDTH = WIDTH / 2;
HHEIGHT = HEIGHT / 2;
CORE_MIN = new Vector3d(0.5f - HWIDTH, 0.5 - HHEIGHT, 0.5 - HWIDTH);
CORE_MAX = new Vector3d(CORE_MIN.x + WIDTH, CORE_MIN.y + HEIGHT, CORE_MIN.z + WIDTH);
CORE_BOUNDS = new BoundingBox(CORE_MIN, CORE_MAX);
float connectorWidth = 0.25f + (scale * 0.5f);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
EXTERNAL_CONNECTOR_BOUNDS.put(dir, createExternalConnector(dir, CONNECTOR_DEPTH, connectorWidth));
}
}
private static BoundingBox[] createExternalConnector(ForgeDirection dir, float connectorDepth,
float connectorWidth) {
BoundingBox[] res = new BoundingBox[2];
float cMin = 0.5f - connectorWidth / 2;
float cMax = 0.5f + connectorWidth / 2;
float dMin = 1 - connectorDepth / 2;
float dMax = 1;
res[0] = createConnectorComponent(dir, cMin, cMax, dMin, dMax);
cMin = 0.5f - connectorWidth / 3;
cMax = 0.5f + connectorWidth / 3;
dMin = 1 - connectorDepth;
dMax = 1 - connectorDepth / 2;
res[1] = createConnectorComponent(dir, cMin, cMax, dMin, dMax);
return res;
}
private static BoundingBox createConnectorComponent(ForgeDirection dir, float cornerMin, float cornerMax,
float depthMin, float depthMax) {
float minX = (1 - Math.abs(dir.offsetX)) * cornerMin + dir.offsetX * depthMin;
float minY = (1 - Math.abs(dir.offsetY)) * cornerMin + dir.offsetY * depthMin;
float minZ = (1 - Math.abs(dir.offsetZ)) * cornerMin + dir.offsetZ * depthMin;
float maxX = (1 - Math.abs(dir.offsetX)) * cornerMax + (dir.offsetX * depthMax);
float maxY = (1 - Math.abs(dir.offsetY)) * cornerMax + (dir.offsetY * depthMax);
float maxZ = (1 - Math.abs(dir.offsetZ)) * cornerMax + (dir.offsetZ * depthMax);
minX = fix(minX);
minY = fix(minY);
minZ = fix(minZ);
maxX = fix(maxX);
maxY = fix(maxY);
maxZ = fix(maxZ);
BoundingBox bb = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
bb = bb.fixMinMax();
return bb;
}
private static float fix(float val) {
return val < 0 ? 1 + val : val;
}
private final Map<GeometryKey, BoundingBox> boundsCache = new HashMap<>();
private final EnumMap<ConduitConnectorType, BoundingBox> connectorBounds = new EnumMap<>(
ConduitConnectorType.class);
private ConduitGeometryUtil() {}
public BoundingBox getExternalConnectorBoundingBox(ForgeDirection dir) {
return getExternalConnectorBoundingBoxes(dir)[0];
}
public BoundingBox[] getExternalConnectorBoundingBoxes(ForgeDirection dir) {
return EXTERNAL_CONNECTOR_BOUNDS.get(dir);
}
public BoundingBox getBoundingBox(Class<? extends IConduit> type, ForgeDirection dir, boolean isStub,
Offset offset) {
GeometryKey key = new GeometryKey(dir, isStub, offset, type);
BoundingBox result = boundsCache.get(key);
if (result == null) {
result = createConduitBounds(type, key);
boundsCache.put(key, result);
}
return result;
}
public Vector3d getTranslation(ForgeDirection dir, Offset offset) {
Vector3d result = new Vector3d(offset.xOffset, offset.yOffset, offset.zOffset);
result.scale(WIDTH);
return result;
}
public BoundingBox createBoundsForConnectionController(ForgeDirection dir, Offset offset) {
Vector3d nonUniformScale = ForgeDirectionOffsets.forDirCopy(dir);
nonUniformScale.scale(0.5);
nonUniformScale.x = 0.8 * (1 - Math.abs(nonUniformScale.x));
nonUniformScale.y = 0.8 * (1 - Math.abs(nonUniformScale.y));
nonUniformScale.z = 0.8 * (1 - Math.abs(nonUniformScale.z));
BoundingBox bb = CORE_BOUNDS;
bb = bb.scale(nonUniformScale.x, nonUniformScale.y, nonUniformScale.z);
double offsetFromEnd = Math.min(bb.sizeX(), bb.sizeY());
offsetFromEnd = Math.min(offsetFromEnd, bb.sizeZ());
offsetFromEnd = Math.max(offsetFromEnd, 0.075);
double transMag = 0.5 - (offsetFromEnd * 1.2);
Vector3d trans = ForgeDirectionOffsets.forDirCopy(dir);
trans.scale(transMag);
bb = bb.translate(trans);
bb = bb.translate(getTranslation(dir, offset));
return bb;
}
private BoundingBox createConduitBounds(Class<? extends IConduit> type, GeometryKey key) {
return createConduitBounds(type, key.dir, key.isStub, key.offset);
}
private BoundingBox createConduitBounds(Class<? extends IConduit> type, ForgeDirection dir, boolean isStub,
Offset offset) {
BoundingBox bb = CORE_BOUNDS;
Vector3d min = bb.getMin();
Vector3d max = bb.getMax();
switch (dir) {
case WEST:
min.x = isStub ? Math.max(0, bb.minX - STUB_WIDTH) : 0;
max.x = bb.minX;
break;
case EAST:
min.x = bb.maxX;
max.x = isStub ? Math.min(1, bb.maxX + STUB_WIDTH) : 1;
break;
case DOWN:
min.y = isStub ? Math.max(0, bb.minY - STUB_HEIGHT) : 0;
max.y = bb.minY;
break;
case UP:
max.y = isStub ? Math.min(1, bb.maxY + STUB_HEIGHT) : 1;
min.y = bb.maxY;
break;
case NORTH:
min.z = isStub ? Math.max(0.0F, bb.minZ - STUB_WIDTH) : 0;
max.z = bb.minZ;
break;
case SOUTH:
max.z = isStub ? Math.min(1F, bb.maxZ + STUB_WIDTH) : 1;
min.z = bb.maxZ;
break;
default:
break;
}
Vector3d trans = getTranslation(dir, offset);
min.add(trans);
max.add(trans);
bb = new BoundingBox(VecmathUtil.clamp(min, 0, 1), VecmathUtil.clamp(max, 0, 1));
return bb;
}
}
@@ -1,5 +1,7 @@
package crazypants.enderio.conduit.geom;
import static com.enderio.core.common.util.ForgeDirectionOffsets.offsetScaled;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
@@ -17,123 +19,121 @@ import com.enderio.core.client.render.VertexTranslation;
import com.enderio.core.common.vecmath.Vector3d;
import com.enderio.core.common.vecmath.Vertex;
import static com.enderio.core.common.util.ForgeDirectionOffsets.offsetScaled;
public class ConnectionModeGeometry {
private static final EnumMap<ForgeDirection, List<Vertex>> VERTS = new EnumMap<ForgeDirection, List<Vertex>>(ForgeDirection.class);
private static final EnumMap<ForgeDirection, List<Vertex>> VERTS = new EnumMap<>(ForgeDirection.class);
static {
static {
float scale = 0.9f;
BoundingBox refBB = ConduitGeometryUtil.CORE_BOUNDS;
refBB = refBB.scale(scale, scale, scale);
refBB = refBB.scale(scale, 1, 1);
float scale = 0.9f;
BoundingBox refBB = ConduitGeometryUtil.CORE_BOUNDS;
refBB = refBB.scale(scale, scale, scale);
refBB = refBB.scale(scale, 1, 1);
double offset = (ConduitGeometryUtil.HWIDTH * scale * scale) + ConduitGeometryUtil.CONNECTOR_DEPTH;
double offset = (ConduitGeometryUtil.HWIDTH * scale * scale) + ConduitGeometryUtil.CONNECTOR_DEPTH;
ForgeDirection dir;
Vector3d trans;
ForgeDirection dir;
Vector3d trans;
VertexRotation vrot = new VertexRotation(Math.PI / 2, new Vector3d(0, 1, 0), new Vector3d(0.5, 0.5, 0.5));
VertexTranslation vtrans = new VertexTranslation(0, 0, 0);
VertexTransformComposite xform = new VertexTransformComposite(vrot, vtrans);
VertexRotation vrot = new VertexRotation(Math.PI / 2, new Vector3d(0, 1, 0), new Vector3d(0.5, 0.5, 0.5));
VertexTranslation vtrans = new VertexTranslation(0, 0, 0);
VertexTransformComposite xform = new VertexTransformComposite(vrot, vtrans);
dir = ForgeDirection.SOUTH;
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.SOUTH;
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.NORTH;
vrot.setAngle(Math.PI + Math.PI / 2);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.NORTH;
vrot.setAngle(Math.PI + Math.PI / 2);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.EAST;
vrot.setAngle(Math.PI);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.EAST;
vrot.setAngle(Math.PI);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.WEST;
vrot.setAngle(0);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.WEST;
vrot.setAngle(0);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
vrot.setAxis(new Vector3d(0, 0, 1));
vrot.setAxis(new Vector3d(0, 0, 1));
dir = ForgeDirection.UP;
vrot.setAngle(-Math.PI / 2);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.UP;
vrot.setAngle(-Math.PI / 2);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
dir = ForgeDirection.DOWN;
vrot.setAngle(Math.PI / 2);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
}
private static List<Vertex> createVerticesForDir(BoundingBox refBB, VertexTransform xform) {
List<Vertex> result = new ArrayList<Vertex>(24);
for (ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) {
result.addAll(refBB.getCornersWithUvForFace(face));
}
for (Vertex v : result) {
xform.apply(v.xyz);
xform.applyToNormal(v.normal);
}
return result;
}
public static void renderModeConnector(ForgeDirection dir, Offset offset, IIcon tex, boolean tintSides) {
List<Vertex> verts = VERTS.get(dir);
if (verts == null) {
return;
dir = ForgeDirection.DOWN;
vrot.setAngle(Math.PI / 2);
trans = offsetScaled(dir, 0.5);
trans.sub(offsetScaled(dir, offset));
vtrans.set(trans);
VERTS.put(dir, createVerticesForDir(refBB, xform));
}
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
float uWidth = tex.getMaxU() - tex.getMinU();
float uScale = uWidth * 0.64f;
float minU = tex.getMinU() + (uWidth - uScale);
float vScale = tex.getMaxV() - tex.getMinV();
Tessellator tes = Tessellator.instance;
for (Vertex v : verts) {
if (tintSides) {
float cm = 1;
if (v.ny() > 0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.UP);
} else if (v.ny() < -0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.DOWN);
} else if (v.nx() > 0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.EAST);
} else if (v.nx() < -0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.WEST);
} else if (v.nz() > 0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.SOUTH);
} else if (v.nz() < -0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.NORTH);
private static List<Vertex> createVerticesForDir(BoundingBox refBB, VertexTransform xform) {
List<Vertex> result = new ArrayList<>(24);
for (ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) {
result.addAll(refBB.getCornersWithUvForFace(face));
}
tes.setColorOpaque_F(cm, cm, cm);
}
tes.setNormal(v.nx(), v.ny(), v.nz());
tes.addVertexWithUV(v.x() + trans.x, v.y() + trans.y, v.z() + trans.z, minU + (v.u() * uScale), tex.getMinV() + (v.v() * vScale));
for (Vertex v : result) {
xform.apply(v.xyz);
xform.applyToNormal(v.normal);
}
return result;
}
}
public static void renderModeConnector(ForgeDirection dir, Offset offset, IIcon tex, boolean tintSides) {
List<Vertex> verts = VERTS.get(dir);
if (verts == null) {
return;
}
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
float uWidth = tex.getMaxU() - tex.getMinU();
float uScale = uWidth * 0.64f;
float minU = tex.getMinU() + (uWidth - uScale);
float vScale = tex.getMaxV() - tex.getMinV();
Tessellator tes = Tessellator.instance;
for (Vertex v : verts) {
if (tintSides) {
float cm = 1;
if (v.ny() > 0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.UP);
} else if (v.ny() < -0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.DOWN);
} else if (v.nx() > 0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.EAST);
} else if (v.nx() < -0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.WEST);
} else if (v.nz() > 0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.SOUTH);
} else if (v.nz() < -0.1) {
cm = RenderUtil.getColorMultiplierForFace(ForgeDirection.NORTH);
}
tes.setColorOpaque_F(cm, cm, cm);
}
tes.setNormal(v.nx(), v.ny(), v.nz());
tes.addVertexWithUV(
v.x() + trans.x,
v.y() + trans.y,
v.z() + trans.z,
minU + (v.u() * uScale),
tex.getMinV() + (v.v() * vScale));
}
}
}
@@ -1,54 +1,46 @@
package crazypants.enderio.conduit.geom;
import net.minecraftforge.common.util.ForgeDirection;
import crazypants.enderio.conduit.IConduit;
public final class GeometryKey {
public final ForgeDirection dir;
public final boolean isStub;
public final Offset offset;
public final String className;
public final ForgeDirection dir;
public final boolean isStub;
public final Offset offset;
public final String className;
public GeometryKey(ForgeDirection dir, boolean isStub, Offset offset, Class<? extends IConduit> type) {
this.dir = dir;
this.isStub = isStub;
this.offset = offset;
className = type != null ? type.getName() : null;
}
public GeometryKey(ForgeDirection dir, boolean isStub, Offset offset, Class<? extends IConduit> type) {
this.dir = dir;
this.isStub = isStub;
this.offset = offset;
className = type != null ? type.getName() : null;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
result = prime * result + (isStub ? 1231 : 1237);
result = prime * result + ((offset == null) ? 0 : offset.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if(this == obj)
return true;
if(obj == null)
return false;
if(getClass() != obj.getClass())
return false;
GeometryKey other = (GeometryKey) obj;
if(className == null) {
if(other.className != null)
return false;
} else if(!className.equals(other.className))
return false;
if(dir != other.dir)
return false;
if(isStub != other.isStub)
return false;
if(offset != other.offset)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + ((dir == null) ? 0 : dir.hashCode());
result = prime * result + (isStub ? 1231 : 1237);
result = prime * result + ((offset == null) ? 0 : offset.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
GeometryKey other = (GeometryKey) obj;
if (className == null) {
if (other.className != null) return false;
} else if (!className.equals(other.className)) return false;
if (dir != other.dir) return false;
if (isStub != other.isStub) return false;
if (offset != other.offset) return false;
return true;
}
}
@@ -4,51 +4,50 @@ import net.minecraftforge.common.util.ForgeDirection;
/**
* Offset vectors are based on Y up.
*
*
* @author brad
*/
public enum Offset {
NONE(0, 0, 0),
UP(ForgeDirection.UP),
DOWN(ForgeDirection.DOWN),
EAST(ForgeDirection.EAST),
WEST(ForgeDirection.WEST),
SOUTH(ForgeDirection.SOUTH),
NORTH(ForgeDirection.NORTH),
EAST_UP(ForgeDirection.EAST, ForgeDirection.UP),
WEST_UP(ForgeDirection.WEST, ForgeDirection.UP),
SOUTH_UP(ForgeDirection.SOUTH, ForgeDirection.UP),
NORTH_UP(ForgeDirection.NORTH, ForgeDirection.UP),
EAST_DOWN(ForgeDirection.EAST, ForgeDirection.DOWN),
WEST_DOWN(ForgeDirection.WEST, ForgeDirection.DOWN),
SOUTH_DOWN(ForgeDirection.SOUTH, ForgeDirection.DOWN),
NORTH_DOWN(ForgeDirection.NORTH, ForgeDirection.DOWN),
NORTH_EAST(ForgeDirection.NORTH, ForgeDirection.EAST),
NORTH_WEST(ForgeDirection.NORTH, ForgeDirection.WEST),
SOUTH_EAST(ForgeDirection.SOUTH, ForgeDirection.EAST),
SOUTH_WEST(ForgeDirection.SOUTH, ForgeDirection.WEST);
NONE(0, 0, 0),
UP(ForgeDirection.UP),
DOWN(ForgeDirection.DOWN),
EAST(ForgeDirection.EAST),
WEST(ForgeDirection.WEST),
SOUTH(ForgeDirection.SOUTH),
NORTH(ForgeDirection.NORTH),
EAST_UP(ForgeDirection.EAST, ForgeDirection.UP),
WEST_UP(ForgeDirection.WEST, ForgeDirection.UP),
SOUTH_UP(ForgeDirection.SOUTH, ForgeDirection.UP),
NORTH_UP(ForgeDirection.NORTH, ForgeDirection.UP),
EAST_DOWN(ForgeDirection.EAST, ForgeDirection.DOWN),
WEST_DOWN(ForgeDirection.WEST, ForgeDirection.DOWN),
SOUTH_DOWN(ForgeDirection.SOUTH, ForgeDirection.DOWN),
NORTH_DOWN(ForgeDirection.NORTH, ForgeDirection.DOWN),
NORTH_EAST(ForgeDirection.NORTH, ForgeDirection.EAST),
NORTH_WEST(ForgeDirection.NORTH, ForgeDirection.WEST),
SOUTH_EAST(ForgeDirection.SOUTH, ForgeDirection.EAST),
SOUTH_WEST(ForgeDirection.SOUTH, ForgeDirection.WEST);
public final int xOffset;
public final int yOffset;
public final int zOffset;
public final int xOffset;
public final int yOffset;
public final int zOffset;
private Offset(ForgeDirection dir) {
xOffset = dir.offsetX;
yOffset = dir.offsetY;
zOffset = dir.offsetZ;
}
private Offset(ForgeDirection dir) {
xOffset = dir.offsetX;
yOffset = dir.offsetY;
zOffset = dir.offsetZ;
}
private Offset(ForgeDirection dir, ForgeDirection yDir) {
xOffset = dir.offsetX + yDir.offsetX;
yOffset = dir.offsetY + yDir.offsetY;
zOffset = dir.offsetZ + yDir.offsetZ;
}
private Offset(int xOffset, int yOffset, int zOffset) {
this.xOffset = xOffset;
this.yOffset = yOffset;
this.zOffset = zOffset;
}
private Offset(ForgeDirection dir, ForgeDirection yDir) {
xOffset = dir.offsetX + yDir.offsetX;
yOffset = dir.offsetY + yDir.offsetY;
zOffset = dir.offsetZ + yDir.offsetZ;
}
private Offset(int xOffset, int yOffset, int zOffset) {
this.xOffset = xOffset;
this.yOffset = yOffset;
this.zOffset = zOffset;
}
}
@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraftforge.common.util.ForgeDirection;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.gas.IGasConduit;
import crazypants.enderio.conduit.item.IItemConduit;
@@ -15,135 +16,133 @@ import crazypants.enderio.conduit.redstone.IRedstoneConduit;
public class Offsets {
private static Map<OffsetKey, Offset> OFFSETS = new HashMap<OffsetKey, Offset>();
private static final Map<OffsetKey, Offset> OFFSETS = new HashMap<>();
static {
OFFSETS.put(key(IRedstoneConduit.class, Axis.NONE), Offset.UP);
OFFSETS.put(key(IRedstoneConduit.class, Axis.X), Offset.UP);
OFFSETS.put(key(IRedstoneConduit.class, Axis.Y), Offset.NORTH);
OFFSETS.put(key(IRedstoneConduit.class, Axis.Z), Offset.UP);
static {
OFFSETS.put(key(IRedstoneConduit.class, Axis.NONE), Offset.UP);
OFFSETS.put(key(IRedstoneConduit.class, Axis.X), Offset.UP);
OFFSETS.put(key(IRedstoneConduit.class, Axis.Y), Offset.NORTH);
OFFSETS.put(key(IRedstoneConduit.class, Axis.Z), Offset.UP);
OFFSETS.put(key(IPowerConduit.class, Axis.NONE), Offset.DOWN);
OFFSETS.put(key(IPowerConduit.class, Axis.X), Offset.DOWN);
OFFSETS.put(key(IPowerConduit.class, Axis.Y), Offset.SOUTH);
OFFSETS.put(key(IPowerConduit.class, Axis.Z), Offset.DOWN);
OFFSETS.put(key(IPowerConduit.class, Axis.NONE), Offset.DOWN);
OFFSETS.put(key(IPowerConduit.class, Axis.X), Offset.DOWN);
OFFSETS.put(key(IPowerConduit.class, Axis.Y), Offset.SOUTH);
OFFSETS.put(key(IPowerConduit.class, Axis.Z), Offset.DOWN);
OFFSETS.put(key(ILiquidConduit.class, Axis.NONE), Offset.WEST);
OFFSETS.put(key(ILiquidConduit.class, Axis.X), Offset.NORTH);
OFFSETS.put(key(ILiquidConduit.class, Axis.Y), Offset.WEST);
OFFSETS.put(key(ILiquidConduit.class, Axis.Z), Offset.WEST);
OFFSETS.put(key(ILiquidConduit.class, Axis.NONE), Offset.WEST);
OFFSETS.put(key(ILiquidConduit.class, Axis.X), Offset.NORTH);
OFFSETS.put(key(ILiquidConduit.class, Axis.Y), Offset.WEST);
OFFSETS.put(key(ILiquidConduit.class, Axis.Z), Offset.WEST);
OFFSETS.put(key(IItemConduit.class, Axis.NONE), Offset.EAST);
OFFSETS.put(key(IItemConduit.class, Axis.X), Offset.SOUTH);
OFFSETS.put(key(IItemConduit.class, Axis.Y), Offset.EAST);
OFFSETS.put(key(IItemConduit.class, Axis.Z), Offset.EAST);
OFFSETS.put(key(IItemConduit.class, Axis.NONE), Offset.EAST);
OFFSETS.put(key(IItemConduit.class, Axis.X), Offset.SOUTH);
OFFSETS.put(key(IItemConduit.class, Axis.Y), Offset.EAST);
OFFSETS.put(key(IItemConduit.class, Axis.Z), Offset.EAST);
OFFSETS.put(key(IGasConduit.class, Axis.NONE), Offset.NORTH_UP);
OFFSETS.put(key(IGasConduit.class, Axis.X), Offset.NORTH_UP);
OFFSETS.put(key(IGasConduit.class, Axis.Y), Offset.NORTH_WEST);
OFFSETS.put(key(IGasConduit.class, Axis.Z), Offset.WEST_UP);
OFFSETS.put(key(IMEConduit.class, Axis.NONE), Offset.SOUTH_UP);
OFFSETS.put(key(IMEConduit.class, Axis.X), Offset.SOUTH_UP);
OFFSETS.put(key(IMEConduit.class, Axis.Y), Offset.NORTH_EAST);
OFFSETS.put(key(IMEConduit.class, Axis.Z), Offset.EAST_UP);
OFFSETS.put(key(IGasConduit.class, Axis.NONE), Offset.NORTH_UP);
OFFSETS.put(key(IGasConduit.class, Axis.X), Offset.NORTH_UP);
OFFSETS.put(key(IGasConduit.class, Axis.Y), Offset.NORTH_WEST);
OFFSETS.put(key(IGasConduit.class, Axis.Z), Offset.WEST_UP);
OFFSETS.put(key(IOCConduit.class, Axis.NONE), Offset.NORTH_DOWN);
OFFSETS.put(key(IOCConduit.class, Axis.X), Offset.NORTH_DOWN);
OFFSETS.put(key(IOCConduit.class, Axis.Y), Offset.SOUTH_WEST);
OFFSETS.put(key(IOCConduit.class, Axis.Z), Offset.WEST_DOWN);
OFFSETS.put(key(IMEConduit.class, Axis.NONE), Offset.SOUTH_UP);
OFFSETS.put(key(IMEConduit.class, Axis.X), Offset.SOUTH_UP);
OFFSETS.put(key(IMEConduit.class, Axis.Y), Offset.NORTH_EAST);
OFFSETS.put(key(IMEConduit.class, Axis.Z), Offset.EAST_UP);
// OFFSETS.put(key(IxConduit.class, Axis.NONE), Offset.SOUTH_DOWN);
// OFFSETS.put(key(IxConduit.class, Axis.X), Offset.SOUTH_DOWN);
// OFFSETS.put(key(IxConduit.class, Axis.Y), Offset.SOUTH_EAST);
// OFFSETS.put(key(IxConduit.class, Axis.Z), Offset.EAST_DOWN);
OFFSETS.put(key(IOCConduit.class, Axis.NONE), Offset.NORTH_DOWN);
OFFSETS.put(key(IOCConduit.class, Axis.X), Offset.NORTH_DOWN);
OFFSETS.put(key(IOCConduit.class, Axis.Y), Offset.SOUTH_WEST);
OFFSETS.put(key(IOCConduit.class, Axis.Z), Offset.WEST_DOWN);
}
// OFFSETS.put(key(IxConduit.class, Axis.NONE), Offset.SOUTH_DOWN);
// OFFSETS.put(key(IxConduit.class, Axis.X), Offset.SOUTH_DOWN);
// OFFSETS.put(key(IxConduit.class, Axis.Y), Offset.SOUTH_EAST);
// OFFSETS.put(key(IxConduit.class, Axis.Z), Offset.EAST_DOWN);
public static Offset get(Class<? extends IConduit> type, ForgeDirection dir) {
Offset res = OFFSETS.get(key(type, getAxisForDir(dir)));
if(res == null) {
res = Offset.NONE;
}
return res;
}
public static OffsetKey key(Class<? extends IConduit> type, Axis axis) {
return new OffsetKey(type, axis);
}
public static Axis getAxisForDir(ForgeDirection dir) {
if(dir == ForgeDirection.UNKNOWN) {
return Axis.NONE;
}
if(dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
return Axis.X;
}
if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) {
return Axis.Y;
}
if(dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) {
return Axis.Z;
}
return Axis.NONE;
}
public static enum Axis {
NONE,
X,
Y,
Z
}
public static class OffsetKey {
String typeName;
Axis axis;
private OffsetKey(Class<? extends IConduit> type, Axis axis) {
this.typeName = type.getCanonicalName();
this.axis = axis;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((axis == null) ? 0 : axis.hashCode());
result = prime * result + ((typeName == null) ? 0 : typeName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if(this == obj) {
return true;
}
if(obj == null) {
return false;
}
if(getClass() != obj.getClass()) {
return false;
}
OffsetKey other = (OffsetKey) obj;
if(axis != other.axis) {
return false;
}
if(typeName == null) {
if(other.typeName != null) {
return false;
public static Offset get(Class<? extends IConduit> type, ForgeDirection dir) {
Offset res = OFFSETS.get(key(type, getAxisForDir(dir)));
if (res == null) {
res = Offset.NONE;
}
} else if(!typeName.equals(other.typeName)) {
return false;
}
return true;
return res;
}
@Override
public String toString() {
return "OffsetKey [typeName=" + typeName + ", axis=" + axis + "]";
public static OffsetKey key(Class<? extends IConduit> type, Axis axis) {
return new OffsetKey(type, axis);
}
}
public static Axis getAxisForDir(ForgeDirection dir) {
if (dir == ForgeDirection.UNKNOWN) {
return Axis.NONE;
}
if (dir == ForgeDirection.EAST || dir == ForgeDirection.WEST) {
return Axis.X;
}
if (dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) {
return Axis.Y;
}
if (dir == ForgeDirection.NORTH || dir == ForgeDirection.SOUTH) {
return Axis.Z;
}
return Axis.NONE;
}
public static enum Axis {
NONE,
X,
Y,
Z
}
public static class OffsetKey {
String typeName;
Axis axis;
private OffsetKey(Class<? extends IConduit> type, Axis axis) {
this.typeName = type.getCanonicalName();
this.axis = axis;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((axis == null) ? 0 : axis.hashCode());
result = prime * result + ((typeName == null) ? 0 : typeName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OffsetKey other = (OffsetKey) obj;
if (axis != other.axis) {
return false;
}
if (typeName == null) {
if (other.typeName != null) {
return false;
}
} else if (!typeName.equals(other.typeName)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OffsetKey [typeName=" + typeName + ", axis=" + axis + "]";
}
}
}
@@ -1,175 +1,342 @@
package crazypants.enderio.conduit.gui;
import java.awt.Color;
import java.awt.Rectangle;
import java.util.ArrayList;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
import net.minecraft.util.ResourceLocation;
import com.enderio.core.api.client.gui.ITabPanel;
import com.enderio.core.api.client.render.IWidgetIcon;
import com.enderio.core.client.gui.button.MultiIconButton;
import com.enderio.core.client.gui.button.CheckBox;
import com.enderio.core.client.gui.widget.GuiToolTip;
import com.enderio.core.client.handlers.SpecialTooltipHandler;
import com.enderio.core.client.render.ColorUtil;
import crazypants.enderio.EnderIO;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.item.FunctionUpgrade;
import crazypants.enderio.conduit.packet.PacketConnectionMode;
import crazypants.enderio.gui.IconEIO;
import crazypants.enderio.network.PacketHandler;
public class BaseSettingsPanel implements ITabPanel {
static final int PREV_MODE_B = 327;
static final int NEXT_MODE_B = 328;
static final int ID_INSERT_ENABLED = 327;
static final int ID_EXTRACT_ENABLED = 328;
protected static final int ID_INSERT_FILTER_OPTIONS = 329;
protected static final int ID_EXTRACT_FILTER_OPTIONS = 330;
protected static final int ID_ENABLED = 331;
protected final IconEIO icon;
protected final GuiExternalConnection gui;
protected final IConduit con;
protected final String typeName;
protected final @Nonnull IWidgetIcon icon;
protected final @Nonnull GuiExternalConnection gui;
protected @Nonnull IConduit con;
protected final @Nonnull String typeName;
protected final @Nonnull ResourceLocation texture;
protected MultiIconButton leftArrow;
protected MultiIconButton rightArrow;
protected String modeLabel;
protected ConnectionMode oldConnectionMode;
protected int left = 0;
protected int top = 0;
protected int width = 0;
protected int height = 0;
private final @Nonnull String inputHeading;
private final @Nonnull String outputHeading;
protected int gap = 5;
private boolean insertEnabled = false;
private boolean extractEnabled = false;
protected int customTop = 0;
private boolean enabled = false;
protected BaseSettingsPanel(IconEIO icon, String typeName, GuiExternalConnection gui, IConduit con) {
this.icon = icon;
this.typeName = typeName;
this.gui = gui;
this.con = con;
private final @Nonnull CheckBox extractEnabledB;
private final @Nonnull CheckBox insertEnabledB;
modeLabel = EnderIO.lang.localize("gui.conduit.ioMode");
private final @Nonnull CheckBox enabledB;
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
int x = gap * 3 + fr.getStringWidth(modeLabel);
int y = 8;// + fr.FONT_HEIGHT;
protected int left = 0;
protected int top = 0;
protected int width = 0;
protected int height = 0;
protected int rightColumn = 112;
protected int leftColumn = 22;
leftArrow = MultiIconButton.createLeftArrowButton(gui, PREV_MODE_B, x, y);
protected int gap = 5;
x += leftArrow.getWidth() + gap + getLongestModeStringWidth() + gap;
rightArrow = MultiIconButton.createRightArrowButton(gui, NEXT_MODE_B, x, y);
protected int customTop = 0;
customTop = top + gap * 5 + fr.FONT_HEIGHT * 2;
customTop -= 16;
//customTop = top;
protected int textureHeight = 166 + 29;
}
private final @Nonnull GuiToolTip speedUpgradeTooltip;
private final @Nonnull GuiToolTip functionUpgradeTooltip;
protected @Nonnull GuiToolTip filterExtractUpgradeTooltip;
protected @Nonnull GuiToolTip filterInsertUpgradeTooltip;
@Override
public void onGuiInit(int left, int top, int width, int height) {
this.left = left;
this.top = top;
this.width = width;
this.height = height;
leftArrow.onGuiInit();
rightArrow.onGuiInit();
connectionModeChanged(con.getConnectionMode(gui.getDir()));
initCustomOptions();
}
protected void initCustomOptions() {
}
@Override
public void deactivate() {
}
@Override
public void mouseClicked(int x, int y, int par3) {
}
@Override
public void keyTyped(char par1, int par2) {
}
@Override
public void updateScreen() {
}
@Override
public IWidgetIcon getIcon() {
return icon;
}
@Override
public void actionPerformed(GuiButton guiButton) {
if(guiButton.id == PREV_MODE_B) {
con.setConnectionMode(gui.getDir(), con.getPreviousConnectionMode(gui.getDir()));
PacketHandler.INSTANCE.sendToServer(new PacketConnectionMode(con, gui.getDir()));
connectionModeChanged(con.getConnectionMode(gui.getDir()));
} else if(guiButton.id == NEXT_MODE_B) {
con.setConnectionMode(gui.getDir(), con.getNextConnectionMode(gui.getDir()));
PacketHandler.INSTANCE.sendToServer(new PacketConnectionMode(con, gui.getDir()));
connectionModeChanged(con.getConnectionMode(gui.getDir()));
protected BaseSettingsPanel(@Nonnull IWidgetIcon icon, @Nonnull String typeName, @Nonnull GuiExternalConnection gui,
@Nonnull IConduit con) {
this(icon, typeName, gui, con, "externalConduitConnection");
}
}
protected void connectionModeChanged(ConnectionMode conectionMode) {
}
protected BaseSettingsPanel(@Nonnull IWidgetIcon icon, @Nonnull String typeName, @Nonnull GuiExternalConnection gui,
@Nonnull IConduit con, @Nonnull String texture) {
this.icon = icon;
this.typeName = typeName;
this.gui = gui;
this.con = con;
this.texture = EnderIO.proxy.getGuiTexture(texture);
@Override
public void render(float par1, int par2, int par3) {
FontRenderer fr = gui.getFontRenderer();
inputHeading = getInputHeading();
outputHeading = getOutputHeading();
int rgb = ColorUtil.getRGB(Color.darkGray);
int x = left + (width - fr.getStringWidth(getTypeName())) / 2;
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
//fr.drawString(getTypeName(), x, top, rgb);
customTop = top + gap * 5 + fr.FONT_HEIGHT * 2;
customTop -= 16;
x = left;
int y = gui.getGuiTop() + 13;//customTop + 8;//gap + fr.FONT_HEIGHT + gap;
gui.getFontRenderer().drawString(modeLabel, x, y, rgb);
int x = leftColumn;
int y = 6;
String modeString = con.getConnectionMode(gui.getDir()).getLocalisedName();
x += gap + leftArrow.getWidth() + fr.getStringWidth(modeLabel) + gap;
insertEnabledB = new CheckBox(gui, ID_INSERT_ENABLED, x, y);
GL11.glColor3f(1, 1, 1);
// TODO figure out what this should be
// IconEIO icon = new IconEIO(10, 48, 64, 16);
// icon.getMap().render(icon, x - gap, y - (fr.FONT_HEIGHT / 2) - 1, getLongestModeStringWidth() + gap * 2, leftArrow.getHeight(), 0, true);
enabledB = new CheckBox(gui, ID_ENABLED, x, y);
int move = (getLongestModeStringWidth() - fr.getStringWidth(modeString)) / 2;
x += move;
rgb = ColorUtil.getRGB(Color.white);
gui.getFontRenderer().drawString(modeString, x, y, rgb);
x = rightColumn;
renderCustomOptions(y + gap + fr.FONT_HEIGHT + gap, par1, par2, par3);
//renderCustomOptions(y + gap, par1, par2, par3);
}
extractEnabledB = new CheckBox(gui, ID_EXTRACT_ENABLED, x, y);
protected void renderCustomOptions(int top, float par1, int par2, int par3) {
x = leftColumn;
y = 92;
}
x = rightColumn;
private int getLongestModeStringWidth() {
int maxWidth = 0;
for (ConnectionMode mode : ConnectionMode.values()) {
int width = gui.getFontRenderer().getStringWidth(mode.getLocalisedName());
if(width > maxWidth) {
maxWidth = width;
}
x = rightColumn + 18 + 1;
filterExtractUpgradeTooltip = new GuiToolTip(
new Rectangle(rightColumn, 70, 18, 18),
EnderIO.lang.localize("gui.conduit.item.filterupgrade")) {
@Override
public boolean shouldDraw() {
return !gui.getContainer().hasFilterUpgrades(true) && super.shouldDraw();
}
};
filterInsertUpgradeTooltip = new GuiToolTip(
new Rectangle(leftColumn, 70, 18, 18),
EnderIO.lang.localize("gui.conduit.item.filterupgrade")) {
@Override
public boolean shouldDraw() {
return !gui.getContainer().hasFilterUpgrades(false) && super.shouldDraw();
}
};
speedUpgradeTooltip = new GuiToolTip(
new Rectangle(rightColumn + 18, customTop + 43, 18, 18),
EnderIO.lang.localize("gui.conduit.item.speedupgrade"),
EnderIO.lang.localize("gui.conduit.item.speedupgrade2")) {
@Override
public boolean shouldDraw() {
return !gui.getContainer().hasSpeedUpgrades() && super.shouldDraw();
}
};
ArrayList<String> funcUpgradeTips = new ArrayList<>();
SpecialTooltipHandler.addTooltipFromResources(funcUpgradeTips, "enderio.gui.conduit.item.functionupgrade.line");
for (FunctionUpgrade upgrade : FunctionUpgrade.values()) {
funcUpgradeTips.add(EnderIO.lang.localizeExact(upgrade.unlocName.concat(".name")));
}
functionUpgradeTooltip = new GuiToolTip(
new Rectangle(rightColumn + 36, customTop + 43, 18, 18),
funcUpgradeTips.toArray(new String[0])) {
@Override
public boolean shouldDraw() {
return !gui.getContainer().hasFunctionUpgrades() && super.shouldDraw();
}
};
gui.getContainer().setInoutSlotsVisible(false, false);
}
return maxWidth;
}
protected String getTypeName() {
return typeName;
}
@Override
public ResourceLocation getTexture() {
return texture;
}
public int getTextureHeight() {
return textureHeight;
}
protected void updateFilterButtons() {}
protected boolean hasFilterGui(boolean input) {
return true;
}
public boolean updateConduit(@Nonnull IConduit conduit) {
this.con = conduit;
if (oldConnectionMode != con.getConnectionMode(gui.getDir())) {
connectionModeChanged(con.getConnectionMode(gui.getDir()));
}
return true;
}
@Override
public void onGuiInit(int leftIn, int topIn, int widthIn, int heightIn) {
this.left = leftIn;
this.top = topIn;
this.width = widthIn;
this.height = heightIn;
updateConduit(con);
if (hasInOutModes()) {
insertEnabledB.onGuiInit();
extractEnabledB.onGuiInit();
insertEnabledB.setSelected(insertEnabled);
extractEnabledB.setSelected(extractEnabled);
} else {
enabledB.onGuiInit();
enabledB.setSelected(enabled);
}
if (hasFilters()) {
gui.addToolTip(filterExtractUpgradeTooltip);
gui.addToolTip(filterInsertUpgradeTooltip);
}
if (hasUpgrades()) {
gui.addToolTip(speedUpgradeTooltip);
gui.addToolTip(functionUpgradeTooltip);
}
initCustomOptions();
}
protected boolean hasUpgrades() {
return false;
}
protected void initCustomOptions() {}
@Override
public void deactivate() {
insertEnabledB.detach();
extractEnabledB.detach();
gui.removeToolTip(speedUpgradeTooltip);
gui.removeToolTip(functionUpgradeTooltip);
gui.removeToolTip(filterExtractUpgradeTooltip);
gui.removeToolTip(filterInsertUpgradeTooltip);
}
@Override
public void mouseClicked(int x, int y, int par3) {}
@Override
public void keyTyped(char par1, int par2) {}
@Override
public void updateScreen() {}
@Override
@Nonnull
public IWidgetIcon getIcon() {
return icon;
}
private void updateConnectionMode() {
ConnectionMode mode = ConnectionMode.DISABLED;
if (insertEnabled && extractEnabled || enabled) {
mode = ConnectionMode.IN_OUT;
} else if (insertEnabled) {
mode = ConnectionMode.OUTPUT;
} else if (extractEnabled) {
mode = ConnectionMode.INPUT;
}
con.setConnectionMode(gui.getDir(), mode);
PacketHandler.INSTANCE.sendToServer(new PacketConnectionMode(con, gui.getDir()));
}
@Override
public void actionPerformed(@Nonnull GuiButton guiButton) {
if (guiButton.id == ID_INSERT_ENABLED) {
insertEnabled = !insertEnabled;
updateConnectionMode();
} else if (guiButton.id == ID_EXTRACT_ENABLED) {
extractEnabled = !extractEnabled;
updateConnectionMode();
} else if (guiButton.id == ID_ENABLED) {
enabled = !enabled;
updateConnectionMode();
}
}
protected void connectionModeChanged(@Nonnull ConnectionMode mode) {
oldConnectionMode = mode;
if (hasInOutModes()) {
insertEnabled = mode.acceptsOutput();
extractEnabled = mode.acceptsInput();
} else {
enabled = mode == ConnectionMode.IN_OUT;
}
}
@Override
public void render(float par1, int par2, int par3) {
updateFilterButtons();
FontRenderer fr = gui.getFontRenderer();
int rgb = ColorUtil.getRGB(Color.darkGray);
int x = left + 32;
int y = gui.getGuiTop() + 10;
if (hasInOutModes()) {
fr.drawString(inputHeading, x, y, rgb);
x += 92;
fr.drawString(outputHeading, x, y, rgb);
} else {
String heading = enabled ? getEnabledHeading() : getDisabledHeading();
fr.drawString(heading, x, y, rgb);
}
renderCustomOptions(y + gap + fr.FONT_HEIGHT + gap, par1, par2, par3);
}
protected void renderCustomOptions(int topIn, float par1, int par2, int par3) {}
protected @Nonnull String getTypeName() {
return typeName;
}
protected boolean hasFilters() {
return false;
}
@Nonnull
protected String getInputHeading() {
// lang strings are nonintuitive for some reason
return EnderIO.lang.localize("gui.conduit.ioMode.output");
}
@Nonnull
protected String getOutputHeading() {
return EnderIO.lang.localize("gui.conduit.ioMode.input");
}
@Nonnull
protected String getEnabledHeading() {
return EnderIO.lang.localize("gui.enabled");
}
@Nonnull
protected String getDisabledHeading() {
return EnderIO.lang.localize("gui.disabled");
}
protected boolean hasInOutModes() {
return true;
}
}
@@ -2,6 +2,7 @@ package crazypants.enderio.conduit.gui;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -9,6 +10,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -22,264 +24,294 @@ import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.conduit.gui.item.InventoryUpgrades;
import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.item.SpeedUpgrade;
import crazypants.enderio.conduit.item.filter.IItemFilter;
import crazypants.enderio.machine.gui.IContainerWithTileEntity;
import crazypants.enderio.network.PacketHandler;
public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrades> {
public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrades> implements IContainerWithTileEntity {
private final IItemConduit itemConduit;
private final IItemConduit itemConduit;
private final ForgeDirection direction;
private final TileEntity te;
private int speedUpgradeSlotLimit = 15;
private int speedUpgradeSlotLimit = 15;
private static final int outputFilterUpgradeSlot = 36;
private static final int inputFilterUpgradeSlot = 37;
private static final int speedUpgradeSlot = 38;
private static final int functionUpgradeSlot = 39;
private static final int outputFilterUpgradeSlot = 36;
private static final int inputFilterUpgradeSlot = 37;
private static final int speedUpgradeSlot = 38;
private static final int functionUpgradeSlot = 39;
private Slot slotSpeedUpgrades;
private Slot slotFunctionUpgrades;
private Slot slotInputFilterUpgrades;
private Slot slotOutputFilterUpgrades;
private Slot slotSpeedUpgrades;
private Slot slotFunctionUpgrades;
private Slot slotInputFilterUpgrades;
private Slot slotOutputFilterUpgrades;
private final List<Point> slotLocations = new ArrayList<Point>();
private final List<Point> slotLocations = new ArrayList<>();
final List<FilterChangeListener> filterListeners = new ArrayList<FilterChangeListener>();
final List<GhostBackgroundItemSlot> bgSlots = new ArrayList<GhostBackgroundItemSlot>();
final List<FilterChangeListener> filterListeners = new ArrayList<>();
final List<GhostBackgroundItemSlot> bgSlots = new ArrayList<>();
public ExternalConnectionContainer(InventoryPlayer playerInv, IConduitBundle bundle, ForgeDirection dir) {
super(playerInv, new InventoryUpgrades(bundle.getConduit(IItemConduit.class), dir));
this.itemConduit = bundle.getConduit(IItemConduit.class);
slotLocations.addAll(playerSlotLocations.values());
public ExternalConnectionContainer(InventoryPlayer playerInv, IConduitBundle bundle, ForgeDirection dir) {
super(playerInv, new InventoryUpgrades(bundle.getConduit(IItemConduit.class), dir));
this.direction = dir;
this.itemConduit = bundle.getConduit(IItemConduit.class);
this.te = (TileEntity) bundle;
slotLocations.addAll(playerSlotLocations.values());
int x;
int y;
int x;
int y;
if (itemConduit != null) {
x = 10;
y = 47;
slotOutputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 3, x, y));
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemBasicFilterUpgrade, slotOutputFilterUpgrades));
if (itemConduit != null) {
x = 23;
y = 71;
slotOutputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 3, x, y));
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemBasicFilterUpgrade, slotOutputFilterUpgrades));
x = 10;
y = 47;
slotInputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 2, x, y));
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemBasicFilterUpgrade, slotInputFilterUpgrades));
x = 113;
y = 71;
slotInputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 2, x, y));
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemBasicFilterUpgrade, slotInputFilterUpgrades));
x = 10;
y = 83;
slotSpeedUpgrades = addSlotToContainer(new Slot(getInv(), 0, x, y) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return getInv().isItemValidForSlot(0, par1ItemStack);
x = 131;
y = 71;
slotSpeedUpgrades = addSlotToContainer(new Slot(getInv(), 0, x, y) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return getInv().isItemValidForSlot(0, par1ItemStack);
}
@Override
public int getSlotStackLimit() {
return speedUpgradeSlotLimit;
}
});
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemExtractSpeedUpgrade, slotSpeedUpgrades));
x = 149;
y = 71;
slotFunctionUpgrades = addSlotToContainer(new Slot(getInv(), 1, x, y) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return getInv().isItemValidForSlot(1, par1ItemStack);
}
@Override
public int getSlotStackLimit() {
return 1;
}
});
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemFunctionUpgrade, slotFunctionUpgrades));
}
setInventorySlotsVisible(false);
}
public void createGhostSlots(List<GhostSlot> slots) {
slots.addAll(bgSlots);
}
@Override
public Point getPlayerInventoryOffset() {
return new Point(23, 161);
}
public void addFilterListener(FilterChangeListener list) {
filterListeners.add(list);
}
protected void filterChanged() {
for (FilterChangeListener list : filterListeners) {
list.onFilterChanged();
}
}
public boolean hasSpeedUpgrades() {
return slotSpeedUpgrades != null && slotSpeedUpgrades.getHasStack();
}
public boolean hasFunctionUpgrades() {
return slotFunctionUpgrades != null && slotFunctionUpgrades.getHasStack();
}
public boolean hasFilterUpgrades(boolean input) {
Slot slot = input ? slotInputFilterUpgrades : slotOutputFilterUpgrades;
return slot != null && slot.getHasStack();
}
public ForgeDirection getDirection() {
return direction;
}
public IItemFilter getFilter(boolean input) {
if (itemConduit == null) {
return null;
}
return input ? itemConduit.getInputFilter(direction) : itemConduit.getOutputFilter(direction);
}
public void setInoutSlotsVisible(boolean inputVisible, boolean outputVisible) {
if (itemConduit == null) {
return;
}
setSlotsVisible(inputVisible, inputFilterUpgradeSlot, inputFilterUpgradeSlot + 1);
setSlotsVisible(inputVisible, speedUpgradeSlot, speedUpgradeSlot + 1);
setSlotsVisible(outputVisible, outputFilterUpgradeSlot, outputFilterUpgradeSlot + 1);
setSlotsVisible(inputVisible || outputVisible, functionUpgradeSlot, functionUpgradeSlot + 1);
World world = itemConduit.getBundle().getWorld();
if (world.isRemote) {
PacketHandler.INSTANCE.sendToServer(new PacketSlotVisibility(inputVisible, outputVisible));
}
}
public void setInventorySlotsVisible(boolean visible) {
setSlotsVisible(visible, 0, 36);
}
private void setSlotsVisible(boolean visible, int startIndex, int endIndex) {
for (int i = startIndex; i < endIndex; i++) {
Slot s = (Slot) inventorySlots.get(i);
if (visible) {
s.xDisplayPosition = slotLocations.get(i).x;
s.yDisplayPosition = slotLocations.get(i).y;
} else {
s.xDisplayPosition = -3000;
s.yDisplayPosition = -3000;
}
}
}
@Override
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
ItemStack st = par4EntityPlayer.inventory.getItemStack();
setSpeedUpgradeSlotLimit(st);
try {
return super.slotClick(par1, par2, par3, par4EntityPlayer);
} catch (Exception e) {
// Horrible work around for a bug when double clicking on a stack in inventory which matches a filter item
// This does does double clicking to fill a stack from working with this GUI open.
return null;
}
}
private void setSpeedUpgradeSlotLimit(ItemStack st) {
if (st != null && st.getItem() == EnderIO.itemExtractSpeedUpgrade) {
SpeedUpgrade speedUpgrade = EnderIO.itemExtractSpeedUpgrade.getSpeedUpgrade(st);
speedUpgradeSlotLimit = speedUpgrade.maxStackSize;
}
}
private boolean mergeItemStackSpecial(ItemStack origStack, Slot targetSlot) {
if (!targetSlot.isItemValid(origStack)) {
return false;
}
setSpeedUpgradeSlotLimit(origStack);
ItemStack curStack = targetSlot.getStack();
int maxStackSize = Math.min(origStack.getMaxStackSize(), targetSlot.getSlotStackLimit());
if (curStack == null) {
curStack = origStack.copy();
curStack.stackSize = Math.min(origStack.stackSize, maxStackSize);
origStack.stackSize -= curStack.stackSize;
targetSlot.putStack(curStack);
targetSlot.onSlotChanged();
return true;
} else if (ItemUtil.areStackMergable(curStack, origStack)) {
int mergedSize = curStack.stackSize + origStack.stackSize;
if (mergedSize <= maxStackSize) {
origStack.stackSize = 0;
curStack.stackSize = mergedSize;
targetSlot.onSlotChanged();
return true;
} else if (curStack.stackSize < maxStackSize) {
origStack.stackSize -= maxStackSize - curStack.stackSize;
curStack.stackSize = maxStackSize;
targetSlot.onSlotChanged();
return true;
}
}
return false;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
ItemStack copystack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack()) {
ItemStack origStack = slot.getStack();
copystack = origStack.copy();
boolean merged = false;
if (slotIndex < outputFilterUpgradeSlot) {
for (int targetSlotIdx = outputFilterUpgradeSlot; targetSlotIdx
<= functionUpgradeSlot; targetSlotIdx++) {
Slot targetSlot = (Slot) inventorySlots.get(targetSlotIdx);
if (targetSlot.xDisplayPosition >= 0 && mergeItemStackSpecial(origStack, targetSlot)) {
merged = true;
break;
}
}
} else {
merged = mergeItemStack(origStack, 0, outputFilterUpgradeSlot, false);
}
if (!merged) {
return null;
}
slot.onSlotChange(origStack, copystack);
if (origStack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (origStack.stackSize == copystack.stackSize) {
return null;
}
slot.onPickupFromSlot(entityPlayer, origStack);
}
return copystack;
}
@Override
public TileEntity getTileEntity() {
return te;
}
private class FilterSlot extends Slot {
public FilterSlot(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
@Override
public int getSlotStackLimit() {
return speedUpgradeSlotLimit;
return 1;
}
});
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemExtractSpeedUpgrade, slotSpeedUpgrades));
x = 10;
y = 65;
slotFunctionUpgrades = addSlotToContainer(new Slot(getInv(), 1, x, y) {
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return getInv().isItemValidForSlot(1, par1ItemStack);
public void onSlotChanged() {
filterChanged();
}
@Override
public int getSlotStackLimit() {
return 1;
public boolean isItemValid(ItemStack par1ItemStack) {
return inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
}
});
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemFunctionUpgrade, slotFunctionUpgrades));
}
}
public void createGhostSlots(List<GhostSlot> slots) {
slots.addAll(bgSlots);
}
@Override
public Point getPlayerInventoryOffset() {
return new Point(23, 113);
}
public void addFilterListener(FilterChangeListener list) {
filterListeners.add(list);
}
protected void filterChanged() {
for (FilterChangeListener list : filterListeners) {
list.onFilterChanged();
}
}
public boolean hasSpeedUpgrades() {
return slotSpeedUpgrades != null && slotSpeedUpgrades.getHasStack();
}
public boolean hasFunctionUpgrades() {
return slotFunctionUpgrades != null && slotFunctionUpgrades.getHasStack();
}
public boolean hasFilterUpgrades(boolean input) {
Slot slot = input ? slotInputFilterUpgrades : slotOutputFilterUpgrades;
return slot != null && slot.getHasStack();
}
public void setInoutSlotsVisible(boolean inputVisible, boolean outputVisible) {
if(itemConduit == null) {
return;
}
setSlotsVisible(inputVisible, inputFilterUpgradeSlot, inputFilterUpgradeSlot + 1);
setSlotsVisible(inputVisible, speedUpgradeSlot, speedUpgradeSlot + 1);
setSlotsVisible(outputVisible, outputFilterUpgradeSlot, outputFilterUpgradeSlot + 1);
setSlotsVisible(inputVisible || outputVisible, functionUpgradeSlot, functionUpgradeSlot + 1);
World world = itemConduit.getBundle().getWorld();
if(world.isRemote) {
PacketHandler.INSTANCE.sendToServer(new PacketSlotVisibility(inputVisible, outputVisible));
}
}
public void setInventorySlotsVisible(boolean visible) {
setSlotsVisible(visible, 0, 36);
}
private void setSlotsVisible(boolean visible, int startIndex, int endIndex) {
for (int i = startIndex; i < endIndex; i++) {
Slot s = (Slot) inventorySlots.get(i);
if(visible) {
s.xDisplayPosition = slotLocations.get(i).x;
s.yDisplayPosition = slotLocations.get(i).y;
} else {
s.xDisplayPosition = -3000;
s.yDisplayPosition = -3000;
}
}
}
@Override
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
ItemStack st = par4EntityPlayer.inventory.getItemStack();
setSpeedUpgradeSlotLimit(st);
try {
return super.slotClick(par1, par2, par3, par4EntityPlayer);
} catch (Exception e) {
//Horrible work around for a bug when double clicking on a stack in inventory which matches a filter item
//This does does double clicking to fill a stack from working with this GUI open.
return null;
}
}
private void setSpeedUpgradeSlotLimit(ItemStack st) {
if(st != null && st.getItem() == EnderIO.itemExtractSpeedUpgrade) {
SpeedUpgrade speedUpgrade = EnderIO.itemExtractSpeedUpgrade.getSpeedUpgrade(st);
speedUpgradeSlotLimit = speedUpgrade.maxStackSize;
}
}
private boolean mergeItemStackSpecial(ItemStack origStack, Slot targetSlot) {
if (!targetSlot.isItemValid(origStack)) {
return false;
}
setSpeedUpgradeSlotLimit(origStack);
ItemStack curStack = targetSlot.getStack();
int maxStackSize = Math.min(origStack.getMaxStackSize(), targetSlot.getSlotStackLimit());
if(curStack == null) {
curStack = origStack.copy();
curStack.stackSize = Math.min(origStack.stackSize, maxStackSize);
origStack.stackSize -= curStack.stackSize;
targetSlot.putStack(curStack);
targetSlot.onSlotChanged();
return true;
} else if(ItemUtil.areStackMergable(curStack, origStack)) {
int mergedSize = curStack.stackSize + origStack.stackSize;
if(mergedSize <= maxStackSize) {
origStack.stackSize = 0;
curStack.stackSize = mergedSize;
targetSlot.onSlotChanged();
return true;
} else if(curStack.stackSize < maxStackSize) {
origStack.stackSize -= maxStackSize - curStack.stackSize;
curStack.stackSize = maxStackSize;
targetSlot.onSlotChanged();
return true;
}
public List<String> getFunctionUpgradeToolTipText() {
return Collections.emptyList();
}
return false;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
ItemStack copystack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
if(slot != null && slot.getHasStack()) {
ItemStack origStack = slot.getStack();
copystack = origStack.copy();
boolean merged = false;
if (slotIndex < outputFilterUpgradeSlot) {
for (int targetSlotIdx = outputFilterUpgradeSlot; targetSlotIdx <= functionUpgradeSlot; targetSlotIdx++) {
Slot targetSlot = (Slot) inventorySlots.get(targetSlotIdx);
if(targetSlot.xDisplayPosition >= 0 && mergeItemStackSpecial(origStack, targetSlot)) {
merged = true;
break;
}
}
} else {
merged = mergeItemStack(origStack, 0, outputFilterUpgradeSlot, false);
}
if(!merged) {
return null;
}
slot.onSlotChange(origStack, copystack);
if(origStack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if(origStack.stackSize == copystack.stackSize) {
return null;
}
slot.onPickupFromSlot(entityPlayer, origStack);
}
return copystack;
}
private class FilterSlot extends Slot {
public FilterSlot(IInventory par1iInventory, int par2, int par3, int par4) {
super(par1iInventory, par2, par3, par4);
}
@Override
public int getSlotStackLimit() {
return 1;
}
@Override
public void onSlotChanged() {
filterChanged();
}
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
}
}
}
@@ -0,0 +1,78 @@
package crazypants.enderio.conduit.gui;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
import com.enderio.core.api.client.gui.IGuiScreen;
import com.enderio.core.api.client.render.IWidgetIcon;
import com.enderio.core.client.gui.button.TooltipButton;
public class FakeButton extends TooltipButton {
public static final int DEFAULT_WIDTH = 16;
public static final int DEFAULT_HEIGHT = 16;
protected @Nonnull IWidgetIcon icon;
private int marginY = 0;
private int marginX = 0;
public FakeButton(@Nonnull IGuiScreen gui, int x, int y, @Nonnull IWidgetIcon icon) {
super(gui, -1, x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT, "");
this.icon = icon;
}
@Override
public FakeButton setPosition(int x, int y) {
super.setPosition(x, y);
return this;
}
public FakeButton setIconMargin(int x, int y) {
marginX = x;
marginY = y;
return this;
}
public @Nonnull IWidgetIcon getIcon() {
return icon;
}
public void setIcon(@Nonnull IWidgetIcon icon) {
this.icon = icon;
}
public boolean mousePressedButton(@Nonnull Minecraft mc, int mouseX, int mouseY, int button) {
return false;
}
protected boolean checkMousePress(@Nonnull Minecraft mc, int mouseX, int mouseY) {
return false;
}
/**
* Draws this button to the screen.
*/
@Override
public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY) {
updateTooltip(mc, mouseX, mouseY);
if (isVisible()) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
icon.getMap().render(
icon,
xPosition + marginX,
yPosition + marginY,
width - 2 * marginX,
height - 2 * marginY,
0,
true);
GL11.glPopAttrib();
}
}
}
Loaded 100 of 1666 files, more files were not shown because too many files have changed in this diff. Show more