Compare commits

...
311 Commits
Author SHA1 Message Date
mezz 27b9b7bc57 Fix Carpenter output Dupe bug 2015-09-26 23:06:56 -07:00
Nirek-K 06b1f9fabf Allow Biogas Engine fuel tank to be drained externally.
(cherry picked from commit 81d2c1971c)
2015-09-26 19:51:33 -07:00
Nirek-K b00f92ab76 Fix #847 TradeStation not outputting items to automation (also fix insertion filtering)
(cherry picked from commit 9478ffb7c1)
2015-09-26 14:45:04 -07:00
mezz 83a41d41d3 Bump version to 3.6.8 2015-09-24 01:47:11 -07:00
Nirek-K a47fab4579 Make plantball value slightly less terrible (equal to 9 wheat, so 'slightly' better to combine wheat, still worse for things like saplings)
(cherry picked from commit 31bd1e82fd)
2015-09-24 01:46:48 -07:00
Nirek-K 07389fe1dc Fix #829 IC2 plantballs not working in fermenter
(cherry picked from commit b56a299f63)
2015-09-24 01:46:42 -07:00
mezz b276c5bb38 Fix #750 Worktable not working properly with GT Tools
(cherry picked from commit 37dd0efee2)
2015-09-24 01:09:19 -07:00
mezz b630540a26 Fix #834 Fix machine fluid handling for IFluidContainerItem
(cherry picked from commit f49bcfd020)
2015-09-22 23:20:04 -07:00
mezz 340ba2dc7c Fix #680 and Fix #750 worktable handling of tools and ItemCraftedEvent
Cleanup some derped refactoring

(cherry picked from commit 9f1b1cc474)
2015-09-12 16:59:59 -07:00
mezz 3e6c8407ff Bump version 2015-09-09 23:16:33 -07:00
mezz 87908d2a35 Merge pull request #818 from bdew/3.6-fixes
Fixes for 3.6.x - BeekeepingLogic overwriting queens with old data + OreDict use in Squeezer recipes
2015-09-09 23:13:21 -07:00
bdew a137cf8f12 Fixed BeekeepingLogic overwriting queen with old data 2015-09-09 13:38:26 +03:00
bdew 70f710231d Changed squeezer recipes to prioritize specific recipes over OD and fixed accepting items 2015-09-09 11:45:27 +03:00
mezz 7a68e04053 Fix #813 Found Chromosome with invalid Alleles 2015-09-08 13:45:16 -07:00
mezz 3c37a81617 Fix #816 Exception during loading Alveary Heater 2015-09-08 13:32:55 -07:00
mezz a9cc367623 Fix crash from missing Agrarian bee allele from older worlds 2015-07-13 20:51:45 -07:00
mezz 7757790b84 Bump version to 3.6.3 2015-06-30 20:51:04 -07:00
mezz bcdbec5b89 Fix #742 Hopper doesn't fill last spot of Carpenter inventory 2015-06-28 15:02:06 -07:00
mezz 3fcb927201 Fix issue with BeekeepingLogic cached canWork 2015-06-28 15:01:24 -07:00
mezz b374f0b23c Bump version to 3.6.2 2015-06-28 15:01:05 -07:00
mezz e9c4c416f5 Fix #739 Trade station crashes when loaded without name set 2015-06-27 21:16:48 -07:00
mezz 1b7d64a7b5 Fix #738 plain leaf blocks accept fertilizer and fruit pods do not grow 2015-06-26 22:31:37 -07:00
mezz 7b05cfd2f7 Bump version to 3.6.1 2015-06-26 22:31:37 -07:00
mezz 66fc9fbc9f Fix bees to pollinate vanilla trees again 2015-06-24 22:26:17 -07:00
mezz aa1ecd8c13 Fix #732 letter sizes 2015-06-24 21:18:36 -07:00
mezz c3453981c3 Fix #730 Crash with corrupted forestry leaves from MFR harvester 2015-06-20 20:38:19 -07:00
mezz 870eaf8725 Bump BC recipes compatible version range.
BuildcraftAPI|recipes got a breaking update in 7.0, but it only
breaks integration tables
2015-06-20 16:17:54 -07:00
mezz 2d07fea3ad Fix Analyzer block's display for trees and butterflies 2015-06-20 01:45:54 -07:00
mezz 95be941803 Fix #729 Leaves name doesn't show properly 2015-06-19 20:38:32 -07:00
mezz be16bf4491 Merge branch 'dev' into 3.6.0 2015-06-19 00:34:41 -07:00
mezz 699fb6fc37 minor tidying 2015-06-19 00:33:48 -07:00
mezz fde3b752e1 Fix progress bars on Carpenter and Centrifuge jumping to 100% at first 2015-06-19 00:33:36 -07:00
mezz f1b35a6746 Fix #692 Carpenter crafting preview is sometimes blank 2015-06-19 00:33:03 -07:00
mezz 4808c25e9f Remove use of OreDictionary method that is only in future Forge versions 2015-06-18 20:49:50 -07:00
mezz af3d007da4 Fix for missing meta value on ItemStack string 2015-06-17 01:21:32 -07:00
mezz 1a048c29ad Fix #694 Fix #672 Fix #578 Add better Backpack config and smart defaults 2015-06-17 01:01:29 -07:00
mezz 4cf7fd84b9 Fix recent issue with item inventories potentially losing items 2015-06-16 21:14:33 -07:00
mezz f6d8005e03 Fix #726 Letter's player/trader icon is glitched when side tabs are open 2015-06-14 20:35:51 -07:00
mezz ed563d98c2 Fix #547 wheat farm places farmland in invalid spaces 2015-06-14 19:24:41 -07:00
mezz 66da45f5bf Fix #725 Allow multifarm to break any type of soil again 2015-06-14 15:12:16 -07:00
mezz fb966143f9 Fix #721 Crash when reusing the Habitat Locator 2015-06-14 14:53:39 -07:00
mezz 763df470a1 Limit stack size of analyzed specimen in the escritoire 2015-06-14 14:36:41 -07:00
mezz 487a5bde45 Fix Alvearies animating after they are broken apart 2015-06-13 16:45:50 -07:00
mezz 19602bcd47 Fix #723 Alveary does not form using Oredictionary name slabWood 2015-06-13 16:45:50 -07:00
mezz c90ea75fde Minor code tidying in Escritoire 2015-06-13 16:43:44 -07:00
Nirek-K 4851a70893 Allow OreDictionary slabWood blocks to complete Alvearies 2015-06-13 18:27:40 -05:00
Nirek-K e7d297dbc6 Make AgriCraft particles slightly more melony. 2015-06-10 21:31:07 -05:00
mezz 50a0a5fa81 Fix #720 Spectacles don't show pollinated leaf blocks 2015-06-09 20:48:21 -07:00
mezz a4fc09c405 Fix #713 isHellish implementation for Alvearies 2015-06-09 00:33:20 -07:00
mezz fa092e2a1b Move PacketHelper methods into DataStreams 2015-06-09 00:23:36 -07:00
mezz ff97fd8067 Fix #716 Crash when looking up bee mutations in NEI 2015-06-08 23:39:18 -07:00
mezz d183abfd11 Fix GUI glitch with the Alveary (no progress bar) 2015-06-07 21:09:20 -07:00
mezz 2e4d9856b2 Fix #710 BeekeepingLogic crash 2015-06-07 01:29:24 -07:00
mezz ad1773a7f7 Close #703 Improve the probability system for centrifuge outputs 2015-06-07 01:21:30 -07:00
mezz a2944ce4e6 Fix Binnie's mods 2015-06-06 23:15:31 -07:00
mezz deb6afaf08 Bulletproof the BC pipe sealant recipe, make it shapeless 2015-06-06 23:15:31 -07:00
mezz fe84d52c38 Fix performance issue when player had no mailbox 2015-06-06 23:15:31 -07:00
mezz 1249ccf983 Fix #701 Improve BeekeepingLogic and network performance.
Improve rendering performance of saplings and butterflies too
2015-06-06 23:15:25 -07:00
mezz d61096e1a9 Fix #698 Worktable is uncraftable 2015-06-03 23:37:36 -07:00
mezz e458dcbb3f Fix #696 Ticon Autosmelt on Forestry Ores makes Apatite 2015-06-02 00:26:33 -07:00
mezz 31e4d93e33 Add API to query for plugin enabled/disabled status 2015-05-31 16:03:39 -07:00
mezz 3aad454237 Restrict Propolis Pipe to BC 6 (to be added in BC Compat for BC 7) 2015-05-31 15:30:07 -07:00
mezz cdae5a6a44 Fix #693 EnderIO Combustion Engine can't use Ethanol without BuildCraft 2015-05-31 14:56:18 -07:00
mezz 37fefff9f3 Add missing Copyright statement 2015-05-31 03:22:21 -07:00
mezz 04caed5baa Cleanup 2015-05-31 03:13:24 -07:00
mezz c6baca7116 #561 Fix bee particle effects networking 2015-05-31 03:13:23 -07:00
mezz 68315ee614 #561 Add "gui open" and "active" packet updates 2015-05-31 03:13:23 -07:00
mezz 0655ea235a Merge pull request #686 from ganymedes01/patch-1
Add fence recipes to match vanilla's style
2015-05-29 22:36:04 -07:00
mezz 25b33b8db9 Clean up Ledgers a bit 2015-05-29 22:31:38 -07:00
mezz 6dab61b0f9 Fix crash in BeekeepingLogic when removing a flower near bee hives
Fix Bee produceStacks logic
2015-05-29 22:31:38 -07:00
mezz 9fccfd1198 #561 refactor networking
Use more DataStreams and less NBT
Add packet for error states changing
Reduce network use by Clockwork Engine
2015-05-29 22:31:38 -07:00
ganymedes01 5294bfa44d Change fence recipes to match vanilla's style
I know forestry is not in 1.8 yet, but why not use it's recipe pattern for fences?

As seen here: http://minecraft.gamepedia.com/Fence
Fences in 1.8 are crafted with an specific type of wood and sticks in the middle, yielding 3 fences per recipe.
2015-05-27 11:08:18 -03:00
mezz ce00a33593 #641 Fix moistener inventory alignment 2015-05-25 23:32:13 -07:00
mezz 8f9c570dd0 replace Utils.getBiomeAt 2015-05-25 01:28:27 -07:00
mezz 4bff9e537e Use more precise biome temperature checking (use coordinates) 2015-05-25 01:24:57 -07:00
mezz c01c0b88e9 Remove ancient legacy tile entities 2015-05-25 00:58:11 -07:00
mezz 64f2cbae3c Fix #668 Add Localization grammar to crates 2015-05-21 23:21:00 -07:00
mezz e8e37eb010 Fix #675 Machine Gui Tabs should open based on time, not frame rate 2015-05-21 23:08:30 -07:00
mezz a3ccb226e5 Fix #679 dupe bug with EnderIO and worktable 2015-05-21 22:19:35 -07:00
mezz 1ed3851672 Remove ILegacyHandler (see #677) 2015-05-21 21:35:32 -07:00
mezz bb740e5c30 Fix #677 missing Maximum flowering allele 2015-05-21 21:27:49 -07:00
mezz 81f0018db3 Cleanup Refactored BeekeepingLogic.update() 2015-05-21 21:22:57 -07:00
mezz ce6aa27f44 Merge branch 'dev'
Conflicts:
	application.properties
	src/main/java/forestry/Forestry.java
	src/main/java/forestry/core/fluids/TankManager.java
	src/main/java/forestry/core/genetics/Allele.java
	src/main/java/forestry/factory/gadgets/MachineBottler.java
	src/main/java/forestry/factory/gadgets/MachineStill.java
	src/main/java/forestry/factory/gui/ContainerBottler.java
	src/main/java/forestry/plugins/PluginApiculture.java
	src/main/java/forestry/plugins/PluginCore.java
	src/main/java/forestry/plugins/PluginManager.java
	src/main/java/forestry/storage/items/ItemNaturalistBackpack.java
2015-05-21 00:48:20 -07:00
bdew 0e444d96d1 Refactored BeekeepingLogic.update() to separate check and work methods 2015-05-21 10:41:44 +03:00
mezz 93a6c77eba Fix #641 Item Inventory Dupe Bug. Refactor Inventories 2015-05-21 00:30:35 -07:00
mezz 6b824f47cd Add config option for gui tab speed 2015-05-17 18:31:07 -07:00
mezz e73e703f8c Tidy up item inventory code 2015-05-17 18:14:35 -07:00
mezz cd7d5f10e6 #666 Fix performance regression from checking for flowers constantly 2015-05-17 01:31:17 -07:00
mezz 43d8b18d2d #666 Display multiple errors for bees and housings that support it 2015-05-17 01:18:00 -07:00
mezz ff00017586 #666 Refactor error states, display multiple error states 2015-05-17 00:59:40 -07:00
mezz 5d9175a00d Tidy code in EngineTin 2015-05-16 00:44:05 -07:00
mezz 2bafc77c02 #657 Fix custom localization of maturation speed 2015-05-16 00:43:43 -07:00
mezz ea03a4c9fe #657 Add localization for gui.flyer.tooltip 2015-05-16 00:42:32 -07:00
mezz 1f2733a0f0 #657 Fix missing butterfly metabolism strings 2015-05-16 00:30:57 -07:00
mezz 6c90c812f0 #657 Custom localization for worker speed tooltips 2015-05-16 00:30:02 -07:00
mezz 6a16ac5133 Fix #665 Crash with addon mods from BeeMutation.getChance 2015-05-15 21:54:34 -07:00
mezz bf179c91d9 Bump patch version to 3.5.6 2015-05-09 17:55:08 -07:00
Nirek-K 5fc1b10298 Add meta checking to flower weight adjustment
(cherry picked from commit 49deb75278)
2015-05-09 17:54:44 -07:00
Nirek-K 23b8f8b892 #Fix 646 Move plantables registration to not be smashed by acceptable.
(cherry picked from commit c705486472)
2015-05-09 17:52:54 -07:00
Nirek-K 1598946632 Fix #650 Fix logic errors in bee planting
(cherry picked from commit d29f4c0b79)
2015-05-09 17:52:34 -07:00
mezz aad6dbaa3f Bump patch version to 3.5.5 2015-05-09 17:41:13 -07:00
mezz ca6cc89015 Fix #652 Bottler liquid dupe bug on server
(cherry picked from commit d5296fbc60)
2015-05-09 17:39:52 -07:00
mezz d5296fbc60 Fix #652 Bottler liquid dupe bug on server 2015-05-09 17:39:01 -07:00
mezz 7b476b39c2 Add AlleleFactory and localization support for forestry addons using it 2015-05-09 15:06:29 -07:00
mezz 53d3cc554f Add support for creating nocturnal bee species 2015-05-09 15:02:13 -07:00
Nirek-K 7a22f1d939 Fix #644 Make Clockwork engine recipe OreDictionary aware. 2015-05-09 00:15:28 -07:00
mezz ce6d92e5cc Begin to support Float product and specialty chances.
Full support will come when the deprecated Int versions are removed.
Until then, very small chances are rounded up to 1/100.
2015-05-07 23:59:43 -07:00
Nirek-K 49deb75278 Add meta checking to flower weight adjustment 2015-05-08 01:25:19 -05:00
mezz 9d32c6dfcb Fix server crash from allele refactor 2015-05-07 22:39:43 -07:00
mezz 7f4a13aa23 Revert "Revert "Add factories for creating bee species and mutations""
This reverts commit 0c12fdf730.
2015-05-07 22:27:19 -07:00
mezz 0c12fdf730 Revert "Add factories for creating bee species and mutations"
This reverts commit 6afee76bee.
2015-05-07 22:19:30 -07:00
mezz 6afee76bee Add factories for creating bee species and mutations
Remove strict bee biome check (it worked poorly with biome mods)
2015-05-07 22:14:52 -07:00
Nirek-K d29f4c0b79 Fix #650 Fix logic errors in bee planting 2015-05-07 20:33:44 -05:00
Nirek-K c705486472 #Fix 646 Move plantables registration to not be smashed by acceptable. 2015-05-02 17:00:58 -05:00
Nirek-K efc3795124 Fix #644 Make Clockwork engine recipe OreDictionary aware. 2015-04-30 21:40:08 -05:00
Nirek-K c3322de12a Add AgriCraft seeds to squeezer. 2015-04-26 18:48:47 -05:00
Nirek-K 1844546f03 Increase precision of secondPrincessChance to 2 decimals 2015-04-24 19:49:30 -05:00
Nirek-K ef658020d2 Fix #638 Allow Analyzer to accept and convert vanilla saplings. 2015-04-24 13:50:12 -05:00
mezz 4cdc612ed0 cleanup 2015-04-24 00:08:07 -07:00
mezz 8d9a0090ec Close #624 Make Forestry saplings IGrowable 2015-04-24 00:07:40 -07:00
mezz 821cfb4987 Fix #600 crash when removing a bee mod (even with clear.invalid.chromosomes) 2015-04-23 23:28:44 -07:00
mezz e5a4f8eb60 Cleanup for Bee Refactor 2015-04-22 23:28:51 -07:00
mezz d16c6a3b36 Cleanup for Bee Refactor 2015-04-22 23:14:42 -07:00
mezz dab7636c27 Update Lang 2015-04-22 22:57:21 -07:00
mezz f51d691002 Refactor Bee mutations, genomes, and species. 2015-04-22 22:51:56 -07:00
mezz a875a54b93 Remove old plugins 2015-04-22 21:58:26 -07:00
mezz 8418116b58 Clean up PluginApiculture hive drop registration 2015-04-22 21:58:26 -07:00
mezz 8dedba4f16 Remove old deprecated and legacy methods 2015-04-22 21:58:26 -07:00
Nirek-K cb6e4620fa Fix #633 End Flower (Dragon egg) doesn't work with HEE 2015-04-22 21:23:54 -05:00
mezz 4b8e651a89 Make TankManager gui handling match the old code properly 2015-04-18 16:17:26 -07:00
mezz 9275784a5a Fix #630 Can't use Ender Electron Tube 2015-04-18 14:06:13 -07:00
mezz feda84fbc6 bump patch version 2015-04-18 13:13:39 -07:00
mezz f7b36e11d1 Fix compatibility with Forge 10.13.3.x fluid changes 2015-04-18 13:08:25 -07:00
mezz 9f04307478 Allow compatibility with new Forge's Fluids change and old Forge too 2015-04-18 13:00:47 -07:00
Nirek-K ca050a7732 Fix #623
Also allow pollen to work on vanilla leaves.
2015-04-15 13:51:00 -05:00
mezz 240bdd3ad1 Merge pull request #615 from Nirek-K/MGCropsFix1
Fix MagicalCrops Plugin firing too early.
2015-04-13 22:05:49 -07:00
mezz f2c3495674 Merge pull request #614 from Nirek-K/F613
Fix #613 Buildcraft 6.4.x compatibility
2015-04-13 22:05:33 -07:00
mezz 1deb385cfe Merge pull request #616 from Nirek-K/VanillaFarm
Allow Orchard to pick up vanilla crops, address #498
2015-04-13 22:04:42 -07:00
Nirek-K d2fcbd8cde Allow Orchard to pick up vanilla crops, address #498 2015-04-13 16:43:11 -05:00
Nirek-K d7daceace7 Fix MagicalCrops Plugin firing too early. 2015-04-13 08:21:22 -05:00
Nirek-K 199158aeee Fix #613 2015-04-13 08:03:17 -05:00
mezz cca4710cb2 Fix #612. Update minimum required Forge version to 10.13.3.1370 2015-04-12 21:12:12 -07:00
mezz b8b7ea328f Update dependencies and fix Fluids for Forge 10.13.3.x 2015-04-11 18:39:46 -07:00
Joe Amenta 0462e5a930 Fix #602. Fixing the imprinter and infuser GUIs to work like the alyzers.
Imprinter and infuser would previously not run their output until the output
slot was clicked (likely, only in SSP). Treealyzer and Beealyzer comment out a
block of code (Flutterlyzer never had this in the first place) that was
uncommented in these... doing the same here made the issue go away.

Sign CLA
2015-04-10 19:26:33 -07:00
Nirek-K 4be4606854 Add AgriCraft cropstick plants to Orchard 2015-04-09 21:37:59 -07:00
Nirek-K f4d671ba2a Add Water Artichoke to orchard.
Add other crops to orchard.
2015-04-09 21:36:18 -07:00
Nirek-K 38ea1061d1 Add Spinach.
Add HC crops to the Orchard Tube, diverse crop fields can be built and the farm will maintain the design.
2015-04-09 21:35:17 -07:00
Nirek-K e26fde5cc0 Plant Mega Pack Stage 4
Add Forest and Plains plant types to bee plant/acceptable and Multifarm (Crop)
Slight Refactor and Cleanup
More minor Cleanup
2015-04-09 21:31:21 -07:00
mezz ae1ed86b50 #606 Allow Flutterlyzer to show mutations 2015-04-09 21:28:51 -07:00
mezz cfbab6b988 Fix #597 Crash from Butterfly Genome.getActiveAllele 2015-04-06 21:20:03 -07:00
mezz 784a47ba11 Fix #597 Crash from Butterfly Genome.getActiveAllele 2015-04-06 20:24:47 -07:00
mezz b5370254c4 Optimize compression of png assets 2015-04-06 00:58:17 -07:00
mezz 3978a068d1 Bump minor patch version 2015-04-05 21:15:14 -07:00
mezz 9d2d0af432 Fix #594 Crash in Natura plugin
(cherry picked from commit 689adab411)
2015-04-05 21:14:56 -07:00
mezz 689adab411 Fix #594 Crash in Natura plugin 2015-04-05 21:06:19 -07:00
mezz 1526b2cb3f Close #586 Disabled "Generated apatite vein around *coords*" messages 2015-04-05 20:55:37 -07:00
mezz d451309170 bump patch version to 3.5.1 2015-04-05 20:28:27 -07:00
mezz c82dd0fbfb Fix #592 Some Crates are missing a recipe 2015-04-05 20:22:21 -07:00
mezz 803911e10a Fix #588 crash on crate registry with disabled storage module and natura
(cherry picked from commit 536254af42)
2015-04-05 20:20:40 -07:00
Nirek-K 29eedf9011 Fix #588 Bulletproof null checks for Natura Plugin
(cherry picked from commit 3f6f12f7cc)
2015-04-05 20:15:05 -07:00
mezz 536254af42 Fix #588 crash on crate registry with disabled storage module and natura 2015-04-05 20:04:49 -07:00
mezz eee22d3e5c Rename loadPlugin to registerHandlers in PluginManager 2015-04-05 20:03:58 -07:00
mezz f7bc38c7e4 Fix #592 Some Crates are missing a recipe 2015-04-05 14:17:34 -07:00
Nirek-K 3f6f12f7cc Fix #588 Bulletproof null checks for Natura Plugin 2015-04-05 14:17:34 -07:00
mezz f8f949850b Bump unstable branch to version 3.6.0 2015-04-04 20:58:53 -07:00
mezz 882848a00f Revert "Close #441 Add Underground Biomes Constructs integration"
This reverts commit b3b1a6a415.

Conflicts:
	lang
	src/main/java/forestry/Forestry.java
	src/main/java/forestry/plugins/PluginManager.java

(cherry picked from commit 1ca041a29f)

Conflicts:
	src/main/java/forestry/plugins/PluginManager.java
2015-04-04 19:44:15 -07:00
mezz fd88173e6f Fix #584 Carpenter doesn't work 2015-04-04 19:41:16 -07:00
Nirek-K 70d6db8bf2 Plant Mega Pack Stage 3
Add most basic flowers to plantable and usable by bees. This should include almost all flowers that don't 'grow' like crops.
2015-03-30 22:07:18 -07:00
mezz 29dddc76ef Make escritoir inventory a private static class instead of anonymous 2015-03-30 22:07:17 -07:00
mezz e80a4e9dfa Organize modules 2015-03-30 22:04:30 -07:00
mezz 1ca041a29f Revert "Close #441 Add Underground Biomes Constructs integration"
This reverts commit b3b1a6a415.

Conflicts:
	lang
	src/main/java/forestry/Forestry.java
	src/main/java/forestry/plugins/PluginManager.java
2015-03-29 23:44:48 -07:00
mezz 4bfb2a3662 make worktable inventory adapter a private static class 2015-03-29 23:39:50 -07:00
mezz 59b90044b7 Clean up slot handling code 2015-03-29 22:00:00 -07:00
mezz 6a8b9af626 Fix #579 Centrifuge recipes do not work with wildcard metadata 2015-03-29 22:00:00 -07:00
mezz 9df39e48eb Move slot handling code out of ContainerForestry, in to SlotHelper 2015-03-29 22:00:00 -07:00
mezz 54fdeab46e Merge pull request #571 from Nirek-K/Witchery
Witchery Support #223
2015-03-28 23:13:46 -07:00
mezz 80cfe423aa Fix #574 clean up candle code 2015-03-28 23:03:52 -07:00
mezz 614ba3f6a9 Merge pull request #575 from Nirek-K/F573
Fix #573 Add Vanilla Acacia and Dark oak to fermenter
2015-03-28 17:16:02 -07:00
Nirek-K ac83f6107d Fix #573 Add Vanilla Acacia and Dark oak to fermenter 2015-03-28 18:25:35 -05:00
Nirek-K 51497c98f7 Witchery Support
BloodRose, Dandelion, Poppy, Shrub added to Flowers Acceptable (not spread)
Belladonna, Mandrake, Mindrake, Snowbell, Wolfsbane, Wormwood, Garlic added
to Crop Multifarm, seeds to squeezer.
Saplings added to multifarm, fermenter.
2015-03-28 02:01:16 -05:00
mezz ed7b200c56 Merge pull request #567 from Nirek-K/PlantMP2
Plant Mega Pack Stage 2
2015-03-27 22:27:51 -07:00
MysteriousAges 5d2d350a96 Merge pull request #568 from Nirek-K/dev
Remove old animation files no longer used (as per Hanfox)
2015-03-27 21:10:47 -07:00
Nirek-K 9ffe216f4a Remove old animation files no longer used. (as per Hanfox) 2015-03-27 18:20:04 -05:00
Nirek-K a3f23ea1cb Plant Mega Pack Stage 2
Cactus/Desert plants to crop multifarm, acceptable to Cacti bee flower allele
Land Crops to crop multifarm, seeds to seed oil, products to juice in Squeezer
2015-03-27 05:28:07 -05:00
mezz 4d253e1dd6 Merge branch 'dev' into release_3.5
Conflicts:
	src/main/java/forestry/apiculture/worldgen/HiveGenHelper.java
2015-03-26 23:02:38 -07:00
mezz f0c535f30a remove unused imports 2015-03-26 22:48:21 -07:00
mezz 1d162bf5ca Update formatting to ignore javadocs 2015-03-26 22:47:34 -07:00
Nirek-K af036b64e8 Plant Mega Pack Stage 1 Bamboo to Reed farm. Bamboo, Kelp to Fermenter 2015-03-26 22:47:20 -07:00
Nirek-K 06a86742bb Fix #542 Add Chisel Worldgen to Digger Backpack
Granite, Limestone, Marble, Andesite, Diorite
2015-03-26 22:40:14 -07:00
mezz e48fbe948e Fix #566 Habitat Locator icon is broken on 32x + texture packs 2015-03-26 22:22:00 -07:00
mezz d4cd2153ef #563 clear up error from missing Breeding Tracker constructor 2015-03-26 21:48:17 -07:00
mezz 4887926994 Fix #563 Player's Breeding Tracker is not sent on opening GUI 2015-03-25 22:11:19 -07:00
mezz 9989451c1c Cleanup 2015-03-25 00:51:48 -07:00
mezz ce3d891eaa #561 Use less network data for saplings 2015-03-24 23:02:48 -07:00
mezz e8c2223f01 #552 Fix leaf icons are missing in NEI recipes 2015-03-24 00:06:24 -07:00
mezz 714206d8c8 Fix #519 Analyzer block display does not update when bee changes 2015-03-23 23:35:06 -07:00
mezz 6593d75234 Move NOPOWER error check to TilePowered updateEntity 2015-03-23 23:35:05 -07:00
mezz 97a96b8f3f remove "all" from InvTools addStack. (used only by tryAddStack) 2015-03-23 23:35:05 -07:00
mezz 5bc0f0156e Remove unused methods 2015-03-23 23:35:05 -07:00
mezz b922c89bb1 Remove unused methods 2015-03-22 21:59:39 -07:00
mezz 8eb601b6cf Fix #548 Make butterfly "hurt" noise quieter 2015-03-22 20:39:05 -07:00
mezz f86031f884 Fix #520 Move recipe registration from postInit to Init 2015-03-22 19:33:57 -07:00
mezz d59072b771 Fix #556 Crash when disabling PluginFactory 2015-03-22 17:41:35 -07:00
mezz c780ec6aaf Remove redundant leaf speciesUID NBT 2015-03-22 17:10:56 -07:00
mezz 558d78bc63 #552 Fix display of non-default fruit types on trees 2015-03-22 16:48:37 -07:00
mezz 0f61cea75e #19 add config option to disable butterfly pollination 2015-03-22 15:37:56 -07:00
mezz 08a9badc54 Fix #559 Forestry fluid can be duplicated with buckets 2015-03-22 15:23:24 -07:00
mezz d71b0e5646 Fix #557 crash from Analyzer 2015-03-22 15:12:03 -07:00
mezz 8a870b9c76 Fix #552 Leaves use excess network bandwidth 2015-03-22 14:50:08 -07:00
mezz 59885f1916 Improve packet handling performance 2015-03-22 14:43:27 -07:00
mezz 7f54ddaa83 Rename ItemBackpack "info" to "definition" 2015-03-21 19:09:08 -07:00
mezz eb502ac0ca Stronger typing for alleles 2015-03-21 19:03:56 -07:00
mezz 2b2370be43 Remove minor backpack optimization that does not always work correctly. 2015-03-18 22:30:48 -07:00
mezz 0aec8b65e9 Fix #545 Client desync when breaking owned blocks 2015-03-05 22:05:32 -08:00
mezz 3de7766db6 Fix #532 Fix WAILA support. Use the deprecated getPickBlock 2015-03-04 22:48:07 -08:00
mezz 671752d1cf Fix #541 Thermionic Fabricator not giving output items 2015-03-04 22:21:36 -08:00
mezz b42837ef70 Fix #540 Dupe bug with Thermionic Fabricator 2015-03-04 21:08:18 -08:00
mezz f5407f9e88 Fix #537 Shift click goes to first slot instead of existing stack 2015-03-03 00:30:58 -08:00
mezz fc0ef3eef0 replace confusing for loops that have no body 2015-03-03 00:03:06 -08:00
mezz 76ceb7a46c Added clay, stained hardened clay, and packed ice to builder's backpack 2015-03-02 23:55:59 -08:00
mezz d169666f43 Cleanup GuiCatalogue 2015-03-02 23:55:58 -08:00
mezz 5802178bbd Fix #538 Internal error when changing Catalogue page with no trades 2015-03-02 23:55:58 -08:00
mezz d30b2482df Automatic cleanup of formatting 2015-03-02 23:55:58 -08:00
mezz f4e9c61e3a Strict and consistent typing for GUI's Container and Inventory 2015-03-02 23:55:52 -08:00
mezz 7362286ead Fix #531 Combine config item parsing for backpack and flowers 2015-03-01 01:04:07 -08:00
mezz 90b13eac1d Revert "Tidy Configuration.java"
This reverts commit ee114f82ec.
2015-03-01 00:58:45 -08:00
mezz f76af59569 Fix #527 Make Bee House, Apiary and Apiarist's Chest harvest with Axe 2015-03-01 00:05:31 -08:00
mezz 5d12fa7550 Fix #533 Backpack lag when inventory is full and standing on item 2015-02-28 23:41:27 -08:00
mezz 16922e6b99 Improve StackUtils isCraftingEquivalent when using OreDictionary 2015-02-28 23:39:36 -08:00
mezz 46b24745a4 Fix #526 Carpenter NPE when storage is disabled 2015-02-28 20:56:23 -08:00
mezz 4b355a6c4a Fix #528 crash from ItemStack with no item in Alveary 2015-02-28 20:42:06 -08:00
mezz 9efe1a940e Remove redundant method in GuiCarpenter 2015-02-28 20:24:19 -08:00
mezz ee114f82ec Tidy Configuration.java 2015-02-28 20:24:19 -08:00
mezz 12a81c5357 Merge pull request #530 from GenuineSounds/dev
Make backpack config more forgiving.
2015-02-28 20:22:08 -08:00
Brian Wiegand a149a29171 Add CLA Signature. 2015-02-26 17:09:20 -08:00
Brian Wiegand 82556c850e Trim each backpack part before processing.
Adds additional white-space forgiveness for the custom back config entries.
2015-02-26 17:05:30 -08:00
Brian Wiegand e265ffe09e Make backpack config much more forgiving.
Make backpack config much more forgiving of white-space characters in between definitions. Also it will skip entire sections that are empty.

Here are the split pattern results.
https://dl.dropboxusercontent.com/u/79514/Screenshots/Features/Screenshot%202015-02-26%2001.46.29.png
2015-02-26 01:49:49 -08:00
mezz b9b71cf015 Fix #518 Trade station crashes when new station is named after a restart 2015-02-21 00:02:31 -08:00
Nate Ingles 9536bf1b78 Changed baobab, mahogany, and wenge bark textures 2015-02-20 23:39:44 -08:00
mezz 298795690e Fix #517 NPE crash when disabling the storage module 2015-02-18 00:03:56 -08:00
mezz af59a2ad6a Fix #513 pollination issues with meta values and flowerpots 2015-02-17 23:44:20 -08:00
mezz 4d7988ee0f Merge branch 'dev' into release_3.4
Conflicts:
	application.properties
	src/main/java/forestry/apiculture/gadgets/TileSwarm.java
	src/main/java/forestry/apiculture/genetics/Bee.java
	src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java
	src/main/java/forestry/core/config/Config.java
	src/main/java/forestry/core/gui/widgets/ReservoirWidget.java
	src/main/java/forestry/core/utils/BlockUtil.java
	src/main/java/forestry/energy/EnergyManager.java
	src/main/java/forestry/factory/gadgets/MachineCarpenter.java
	src/main/java/forestry/mail/gui/GuiCatalogue.java
	src/main/java/forestry/plugins/PluginArboriculture.java
2015-02-16 15:00:16 -08:00
mezz ab0952ac2b Remove unused methods in EngineBronze 2015-02-15 17:58:34 -08:00
mezz 042b36a350 Fix #461 Disable powered machines on a direct redstone signal 2015-02-15 17:58:20 -08:00
mezz 1ac0cf5489 Fix #459 Enable automation of the Thermionic Fabricator 2015-02-15 17:34:22 -08:00
mezz 5f8661a17f #19 use a tick count like Railcraft 2015-02-15 16:40:06 -08:00
mezz 6a607e4551 Fix #510 Fix farmland layout 2015-02-15 16:12:48 -08:00
mezz 172a2c00ac #510, Fix #502. Fix farm error reporting and inventory blanking 2015-02-15 16:12:05 -08:00
mezz 7dff774368 Fix farm reporting wrong location for hasCultivated listeners 2015-02-15 15:05:40 -08:00
mezz 272152d48e Fix #510 Multifarm reports "No farmland" 2015-02-15 15:04:46 -08:00
mezz 2fce803456 #19 use a tick count like Railcraft 2015-02-15 15:04:00 -08:00
mezz a679d46c57 Remove unused methods in TileMachine 2015-02-15 13:41:14 -08:00
Nirek-K 2b4dfcdae3 Add config option to add a chance of additional princess spawn, for skyblock/limited land maps
Minor Cleanup
2015-02-15 13:26:27 -08:00
mezz 786dbd82c7 #19 Spread out tick updates for tile entities 2015-02-08 14:17:21 -08:00
mezz 0848cfb891 Fix #251 overlapping farming areas 2015-02-08 13:29:28 -08:00
mezz 7fc90fb76e #248 Cleanup TileControl 2015-02-08 11:31:03 -08:00
mezz 08741959b3 Use bee temp and humidity tolerance to place hives 2015-02-08 00:04:23 -08:00
mezz 93062955ba Change temperature and humidity tolerance of the basic bee lines 2015-02-08 00:03:33 -08:00
Nirek-K fd41fb9ff7 Add Support for Magical Crops Multifarm support (Wheat(Crop) tube) Fermenter/Squeezer support 2015-02-07 10:35:27 -08:00
mezz a9b90f4fef Fix #499 broken pollination with non-Forestry bees 2015-02-05 20:12:37 -08:00
mezz f5245e766b Fix #499 broken pollination with non-Forestry bees 2015-02-05 20:09:46 -08:00
mezz 4d43e918f1 #19 apply butterfly spawn constraint to the creation of caterpillars too 2015-02-04 01:23:33 -08:00
mezz bf2da35086 #19 prevent bees and butterflies from converting leaves when checking 2015-02-04 01:22:49 -08:00
mezz e0737d2851 #19 Increase cooldown for butterfly pollination and breeding 2015-02-04 01:19:30 -08:00
mezz dceffe23c3 #19 end butterfly lifecycle after a Minecraft week 2015-02-04 01:18:37 -08:00
mezz f6e1147271 Bump unstable branch to version 3.5.0 2015-02-04 00:45:44 -08:00
mezz 7028a17649 Fix #497 Clockwork Engine animations runs forever when it stores energy 2015-02-03 20:46:07 -08:00
mezz b08a618baa Fix #478 Manual peat bog doesn't replace bog earth 2015-02-02 22:01:10 -08:00
mezz 433c516166 Merge pull request #493 from Nirek-K/HC_fixes
Slight Orchard logic fixes
2015-02-02 20:47:36 -08:00
Nirek-K 1ce2d45417 Slight Orchard logic fixes
Slightly increase search grid to include outlying fruit
Don't skip over trunk on first level
2015-02-02 06:55:09 -06:00
mezz b18cee80cb Close #489 Worktable accept items from automation 2015-02-02 00:31:03 -08:00
mezz 62fcb24160 Fix #492 Add electron tube info to tooltip 2015-02-02 00:25:31 -08:00
Nirek-K f6b92ad6ac HarvestCraft Integration part 1
Multifarm support for all plant based crops. Plants/Tree Fruit
ferment-able/squeezable (Add Fluid Vegetable Juice) Seeds squeezable into Seed
Oil Honey squeezable into Honey Beeswax can be made into wax capsules Grain
crops can be used for Compost

HarvestCraft Integration part 2
Add Basic Orchard Tube (Apple Infused)
Supports all trees, bark and fruit-ish
All crops should now be supported
Vegetables produce Vegetable juice and go into the Vegetables tube
Everything else ground based goes to the Wheat(Crop) tube

Lastminute typos are the best.

mezz - Have regular orchard handle HarvestCraft too
2015-02-01 23:43:48 -08:00
Nirek-K c576f745fb Add Cotton to Wheat(Crop)tube. 2015-02-01 19:42:56 -08:00
Nirek-K 870906188c ExUtil support:
New Managed Farm: Ender (Tube:Ender Eye)
Places Endstone, plants Enderlily seeds

Add Config Option.

Add Ender Tube(Ender Eye, 3 End stone, 2 Redstone)

mezz - fixes for extra utilities plugin
2015-02-01 19:37:42 -08:00
mezz 9df241b1ac Fix bee flowerPot growth and fertilization growth 2015-01-30 23:09:34 -08:00
mezz c218d6c9e1 Fix #475 Bees changing blocks via pollination 2015-01-30 21:35:55 -08:00
Nirek-K ee55d90746 Basic BoP Plugin: Add Multifarm support for BoP Trees Add Turnip to Vegetable tube. 2015-01-29 23:39:14 -08:00
Nirek-K 8597d67416 Add missing crated honeycombs, fruit, nuts,vanilla saplings,wood,red sand and podzol
Minor Cleanup
2015-01-29 23:28:38 -08:00
mezz 56dfae034d Fix #480 Increase hive spawn rate 25%, add config option for spawn rate 2015-01-29 00:09:06 -08:00
mezz 636201ce5a Fix #479 Try to make sure hives are always glowing 2015-01-28 23:48:21 -08:00
mezz f6bbf33b7a Fix #483 Catalogue GUI fixes 2015-01-28 22:20:12 -08:00
Nirek-K 9eec976f7b Natura Crates, Compost, Barley Multifarm
Crates for most Natura items.
Barley Compost recipe.
Add barley to the Wheat(Crops) Multifarm tube.
Add Potash Apple to squeezer (Half Apple yield)
2015-01-27 22:50:35 -08:00
mezz 5b8b0c78b0 Close #477 Auto-Format code with new formatting settings 2015-01-26 22:26:21 -08:00
mezz 8e92d16320 #477 Add formatting profile settings 2015-01-26 22:25:02 -08:00
mezz 853d69a0f1 Cleanup of an unchecked List 2015-01-26 21:27:52 -08:00
mezz 97285cfcb2 Fix FlowerType pollination rules 2015-01-25 23:10:41 -08:00
mezz d4f3f0d327 Fix #475 fix leaves not pollinating 2015-01-25 22:59:45 -08:00
mezz 0b71684778 Fix #475 Bee pollination broken 2015-01-25 22:21:58 -08:00
mezz 0f085e0691 Close #463 Bring back and improve the Habitat Locator! 2015-01-25 20:00:19 -08:00
mezz c3f37a379a Fix bee biome temperature check for nether biomes 2015-01-25 19:50:29 -08:00
mezz 5a7bd9f57a Fix crash from missing block when a plugin mod is uninstalled 2015-01-25 18:26:29 -08:00
mezz 7ec3b8bf9b #457 Add config option for village generation (forgot lumberjack) 2015-01-24 00:25:33 -08:00
mezz dab217eab0 Close #457 Add config option for village generation 2015-01-24 00:21:20 -08:00
mezz dffa845851 Fix #470 Engines don't output to other mods' machines 2015-01-23 23:25:57 -08:00
mezz 1aefd5863e Fix #472 Crash with Thaumic Tinkerer Ichorium Axe 2015-01-23 22:57:33 -08:00
mezz 8745f56f8b Merge pull request #471 from Samtrion/dev
Minor Changes/fixes to Flower Registry
2015-01-23 22:31:24 -08:00
mezz 273dae3298 Fix #473 Still wasting fluid at near full output. 2015-01-23 22:28:22 -08:00
samtrion b1b877f530 Minor Changes/fixes
- A cache for flowerType treemaps added
- If a flower is already registered, the lowest weight wins.
2015-01-22 10:03:16 +01:00
mezz 6870dafe02 Add fuel handler info for Forestry wooden slabs #469 2015-01-21 23:59:38 -08:00
mezz b3b1a6a415 Close #441 Add Underground Biomes Constructs integration 2015-01-21 23:36:21 -08:00
mezz 953a84f346 Update lang 2015-01-21 23:19:27 -08:00
mezz 3ac0ac9625 Fix #464 Breaking a farm block shows wrong colored particles 2015-01-19 21:55:33 -08:00
mezz c6dae0318c Fix #467 Carpenter automation 2015-01-19 14:30:28 -08:00
Martin Stühmer 7ace6d7faa Flower Rewrite Based on a weighted distribution system
Create cla-signatures.txt
Fixed code convention in Flower Class
2015-01-19 13:46:38 -08:00
mezz 8eb366997d Minor Cleanup 2015-01-19 11:34:38 -08:00
mezz dc1449855e Fix #465 crash after closing catalogue and opening another item gui 2015-01-19 11:34:18 -08:00
mezz f832025f6d Farm refactor, Fix #187 Multifarms do not give equal space 2015-01-18 14:21:23 -08:00
mezz b36d10308b Let farm break replaceable blocks (such as Railcraft's residual heat) 2015-01-18 14:21:22 -08:00
mezz 195c8fc524 Fix possible reservoir crash from thermionic fabricator 2015-01-18 14:21:21 -08:00
mezz bdd386c431 Add VectUtil for World functions using vects 2015-01-17 15:51:25 -08:00
923 changed files with 28441 additions and 21824 deletions

No files matched your search

+3 -4
View File
@@ -1,6 +1,5 @@
mcversion=1.7.10
forgeversion=10.13.2.1286
forgeversion=10.13.3.1370-1.7.10
version_major=3
version_minor=4
version_patch=0
version_minor=6
version_patch=9
+6 -2
View File
@@ -70,6 +70,10 @@ repositories {
name = "ic2"
url = "http://maven.ic2.player.to/"
}
ivy {
name "BuildCraft"
artifactPattern "http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision]-[classifier].[ext]"
}
}
configurations {
@@ -78,8 +82,8 @@ configurations {
}
dependencies {
api 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
api 'com.mod-buildcraft:buildcraft:6.3.1:dev'
api 'net.industrial-craft:industrialcraft-2:2.2.713-experimental:api'
api name: "buildcraft", version: "6.4.10", classifier: "dev"
}
processResources {
+5
View File
@@ -0,0 +1,5 @@
Account;Email;Date;
samtrion;[email protected];2015-01-18
GenuineSounds;[email protected];2015-02-26
airbreather;[email protected];2015-04-10
ganymedes01;[email protected];2015-05-27
Binary file not shown.
+1 -1
Submodule lang updated: 1b85a75323...e111b835ad.
+18 -12
View File
@@ -4,12 +4,19 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
@@ -22,6 +29,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
import forestry.api.fuels.EngineBronzeFuel;
import forestry.api.fuels.EngineCopperFuel;
import forestry.api.fuels.FermenterFuel;
@@ -38,12 +46,6 @@ import forestry.core.proxy.Proxies;
import forestry.core.utils.FluidMap;
import forestry.core.utils.ItemStackMap;
import forestry.core.utils.StringUtil;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
/**
* Forestry Minecraft Mod
@@ -55,10 +57,12 @@ import net.minecraft.item.Item;
name = "Forestry",
version = Version.VERSION,
dependencies = "required-after:Forge@[10.13.0.1207,);"
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,)")
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,);"
+ "after:Natura@[2.2.0,);"
+ "after:HardcoreEnderExpansion;")
//, certificateFingerprint = Version.FINGERPRINT)
public class Forestry {
@@ -90,6 +94,7 @@ public class Forestry {
FuelManager.copperEngineFuel = new ItemStackMap<EngineCopperFuel>();
FuelManager.generatorFuel = new FluidMap<GeneratorFuel>();
}
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
public static ForestryCore core = new ForestryCore();
public static PacketHandler packetHandler;
@@ -136,7 +141,7 @@ public class Forestry {
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
for (MissingMapping mapping : event.get())
for (MissingMapping mapping : event.get()) {
if (mapping.type == Type.BLOCK) {
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
if (block != null) {
@@ -156,5 +161,6 @@ public class Forestry {
}
}
}
}
}
}
@@ -4,12 +4,21 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import java.util.Collections;
import java.util.Set;
import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
@@ -23,27 +32,42 @@ import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class BeekeepingLogic implements IBeekeepingLogic {
private static final int MAX_POLLINATION_ATTEMPTS = 20;
private static final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
private static final int ticksPerCheckQueenCanWork = 10;
private final IBeeHousing housing;
private final boolean housingSupportsMultipleErrorStates;
// Breeding
private int breedingTime;
private final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
private int queenWorkCycleThrottle;
private IEffectData effectData[] = new IEffectData[2];
private ItemStack queenStack;
private IBee queen;
private IIndividual pollen;
private int attemptedPollinations = 0;
private final Stack<ItemStack> spawn = new Stack<ItemStack>();
// Cached flowers check
private boolean hasFlowersCached = false;
private int hasFlowersCooldown = 0;
private Set<IErrorState> queenCanWorkCached = Collections.emptySet();
private int queenCanWorkCooldown = 0;
public BeekeepingLogic(IBeeHousing housing) {
this.housing = housing;
Set<IErrorState> errorStateSet = null;
try {
errorStateSet = housing.getErrorStates();
} catch (Throwable ignored) {
}
housingSupportsMultipleErrorStates = (errorStateSet != null);
}
// / SAVING & LOADING
@@ -84,7 +108,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
@Override
public int getTotalBreedingTime() {
return this.totalBreedingTime;
return totalBreedingTime;
}
@Override
@@ -103,27 +127,82 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
/* UPDATING */
@Override
public boolean canWork() {
if (housingSupportsMultipleErrorStates) {
Set<IErrorState> errorStates = housing.getErrorStates();
for (IErrorState errorState : errorStates) {
housing.setErrorCondition(false, errorState);
}
}
boolean hasSpace = addPendingProducts();
if (hasBreedablePrincess()) {
return hasSpace;
}
if (hasHealthyQueen()) {
boolean canWork = queenCanWork();
boolean hasFlowers = hasFlowers();
return hasSpace && canWork && hasFlowers;
}
return false;
}
@Override
public void doWork() {
if (hasBreedablePrincess()) {
tickBreed();
} else if (queen != null) {
queenWorkTick();
}
}
@Override
public void update() {
this.queen = null;
if (!addPendingProducts()) {
return;
if (canWork()) {
doWork();
}
if (tryBreedingPrincess() || !hasHealthyQueen()) {
return;
}
if (!queenCanWork()) {
return;
}
private boolean hasFlowers() {
if (queen == null) {
return true;
}
queenWorkTick();
if (hasFlowersCooldown <= 0) {
hasFlowersCached = queen.hasFlower(housing);
hasFlowersCooldown = PluginApiculture.ticksPerBeeWorkCycle;
// check more often if we haven't found flowers
if (!hasFlowersCached) {
hasFlowersCooldown /= 2;
}
} else {
hasFlowersCooldown--;
}
if (housingSupportsMultipleErrorStates) {
housing.setErrorCondition(!hasFlowersCached, EnumErrorCode.NOFLOWER);
} else {
if (hasFlowersCached) {
housing.setErrorState(EnumErrorCode.OK);
} else {
housing.setErrorState(EnumErrorCode.NOFLOWER);
}
}
return hasFlowersCached;
}
private void queenWorkTick() {
if (queen == null) {
return;
}
// Effects only fire when queen can work.
effectData = queen.doEffect(effectData, housing);
@@ -131,29 +210,27 @@ public class BeekeepingLogic implements IBeekeepingLogic {
queenWorkCycleThrottle++;
if (queenWorkCycleThrottle >= PluginApiculture.ticksPerBeeWorkCycle) {
queenWorkCycleThrottle = 0;
// Need a flower
if (queen.hasFlower(housing)) {
housing.setErrorState(EnumErrorCode.OK.ordinal());
doQueenWorkCycle();
} else {
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
}
doProduction();
queen.plantFlowerRandom(housing);
doPollination();
// Age the queen
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
updateQueenItemNBT();
}
}
private void doQueenWorkCycle() {
doProduction();
queen.plantFlowerRandom(housing);
doPollination();
// Age the queen
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
updateQueenItemNBT();
}
private void doProduction() {
if (queen == null) {
return;
}
// Produce and add stacks
ItemStack[] products = queen.produceStacks(housing);
if (products == null) {
return;
}
housing.wearOutEquipment(1);
for (ItemStack stack : products) {
housing.addProduct(stack, false);
@@ -161,6 +238,10 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
private void doPollination() {
if (queen == null) {
return;
}
// Get pollen if none available yet
if (pollen == null) {
pollen = queen.retrievePollen(housing);
@@ -180,6 +261,10 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
private void updateQueenItemNBT() {
if (queen == null) {
return;
}
// Write the changed queen back into the item stack.
NBTTagCompound nbttagcompound = new NBTTagCompound();
queen.writeToNBT(nbttagcompound);
@@ -201,55 +286,77 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
if (housingErrorState != null) {
try {
if (housingSupportsMultipleErrorStates) {
boolean hasSpace = (housingErrorState == EnumErrorCode.OK);
housing.setErrorCondition(!hasSpace, EnumErrorCode.NOSPACE);
} else {
housing.setErrorState(housingErrorState);
} catch (Error e) {
housing.setErrorState(housingErrorState.ordinal());
}
}
return housingErrorState != EnumErrorCode.NOSPACE;
}
/** Checks if a queen is alive. Much faster than reading the whole bee nbt */
private static boolean isQueenAlive(ItemStack queenStack) {
NBTTagCompound nbtTagCompound = queenStack.getTagCompound();
int health = nbtTagCompound.getInteger("Health");
return health > 0;
}
private boolean hasHealthyQueen() {
boolean hasQueen = true;
EnumErrorCode housingErrorState = null;
if (housing.getQueen() == null || !ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
ItemStack queenStack = housing.getQueen();
if (!ItemStack.areItemStacksEqual(this.queenStack, queenStack)) {
this.queen = BeeManager.beeRoot.getMember(queenStack);
this.queenStack = queenStack;
}
if (queenStack == null || !ForestryItem.beeQueenGE.isItemEqual(queenStack)) {
housingErrorState = EnumErrorCode.NOQUEEN;
hasQueen = false;
queen = null;
} else if (!isQueenAlive(queenStack)) {
if (queen == null) {
queen = BeeManager.beeRoot.getMember(queenStack);
}
killQueen();
housingErrorState = EnumErrorCode.OK;
hasQueen = false;
queen = null;
}
if (housingSupportsMultipleErrorStates) {
housing.setErrorCondition(!hasQueen, EnumErrorCode.NOQUEEN);
} else {
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
// Kill dying queens
if (!queen.isAlive()) {
killQueen(queen);
housingErrorState = EnumErrorCode.OK;
hasQueen = false;
} else {
this.queen = queen;
}
}
if (housingErrorState != null) {
try {
if (housingErrorState != null) {
housing.setErrorState(housingErrorState);
} catch (Error e) {
housing.setErrorState(housingErrorState.ordinal());
}
}
if (hasQueen && queen == null) {
queen = BeeManager.beeRoot.getMember(queenStack);
}
return hasQueen;
}
private boolean tryBreedingPrincess() {
boolean isBreedingPrincess = false;
// Princess available? Try to breed!
private boolean hasBreedablePrincess() {
boolean isBreedingPrincess = false;
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone())) {
housing.setErrorState(EnumErrorCode.OK.ordinal());
boolean hasDrone = ForestryItem.beeDroneGE.isItemEqual(housing.getDrone());
if (housingSupportsMultipleErrorStates) {
housing.setErrorCondition(!hasDrone, EnumErrorCode.NODRONE);
} else {
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
if (hasDrone) {
housing.setErrorState(EnumErrorCode.OK);
} else {
housing.setErrorState(EnumErrorCode.NODRONE);
}
}
tickBreed();
isBreedingPrincess = true;
}
@@ -257,35 +364,46 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
private boolean queenCanWork() {
try {
boolean canWork = true;
// Not while raining, at night or without light
IErrorState state = queen.canWork(housing);
if (state != EnumErrorCode.OK) {
housing.setErrorState(state);
canWork = false;
} else if (housing.getErrorState() != EnumErrorCode.NOFLOWER) {
housing.setErrorState(EnumErrorCode.OK);
if (queenCanWorkCooldown > 0) {
queenCanWorkCooldown--;
} else {
if (queen == null) {
return false;
}
return canWork;
} catch (Error e) {
Proxies.log.logErrorAPI("Forestry", e, IBee.class);
return queenCanWorkDeprecated();
queenCanWorkCached = checkQueenCanWork();
queenCanWorkCooldown = ticksPerCheckQueenCanWork;
}
Set<IErrorState> errorStates = queenCanWorkCached;
if (errorStates.size() > 0) {
if (housingSupportsMultipleErrorStates) {
for (IErrorState errorState : errorStates) {
housing.setErrorCondition(true, errorState);
}
} else {
IErrorState state = errorStates.iterator().next();
housing.setErrorState(state);
}
return false;
} else {
return true;
}
}
// fallback for outdated APIs
private boolean queenCanWorkDeprecated() {
boolean canWork = true;
// Not while raining, at night or without light
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
if (state != EnumErrorCode.OK) {
housing.setErrorState(state.ordinal());
canWork = false;
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal()) {
housing.setErrorState(EnumErrorCode.OK.ordinal());
private Set<IErrorState> checkQueenCanWork() {
try {
return queen.getCanWork(housing);
} catch (Throwable ignored) {
// queen might not support getCanWork
}
return canWork;
IErrorState state = queen.canWork(housing);
if (state != EnumErrorCode.OK) {
return Collections.singleton(state);
}
return Collections.emptySet();
}
// / BREEDING
@@ -295,18 +413,21 @@ public class BeekeepingLogic implements IBeekeepingLogic {
return;
}
if (breedingTime < totalBreedingTime)
if (breedingTime < totalBreedingTime) {
breedingTime++;
if (breedingTime < totalBreedingTime)
}
if (breedingTime < totalBreedingTime) {
return;
}
// Breeding done, create new queen if slot available
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
return;
}
// Replace
IBee princess = PluginApiculture.beeInterface.getMember(housing.getQueen());
IBee drone = PluginApiculture.beeInterface.getMember(housing.getDrone());
IBee princess = BeeManager.beeRoot.getMember(housing.getQueen());
IBee drone = BeeManager.beeRoot.getMember(housing.getDrone());
princess.mate(drone);
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -318,31 +439,36 @@ public class BeekeepingLogic implements IBeekeepingLogic {
housing.onQueenChange(housing.getQueen());
// Register the new queen with the breeding tracker
PluginApiculture.beeInterface.getBreedingTracker(housing.getWorld(), housing.getOwnerName()).registerQueen(princess);
BeeManager.beeRoot.getBreedingTracker(housing.getWorld(), housing.getOwnerName()).registerQueen(princess);
// Remove drone
housing.getDrone().stackSize--;
if (housing.getDrone().stackSize <= 0)
if (housing.getDrone().stackSize <= 0) {
housing.setDrone(null);
}
// Reset breeding time
breedingTime = 0;
}
private boolean tryBreed() {
if (housing.getDrone() == null || housing.getQueen() == null)
if (housing.getDrone() == null || housing.getQueen() == null) {
return false;
}
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
return false;
}
if (!housing.canBreed())
return false;
return housing.canBreed();
return true;
}
private void killQueen(IBee queen) {
private void killQueen() {
if (queen == null) {
return;
}
if (queen.canSpawn()) {
spawnOffspring(queen);
housing.getQueen().stackSize = 0;
@@ -367,30 +493,36 @@ public class BeekeepingLogic implements IBeekeepingLogic {
private void spawnOffspring(IBee queen) {
Stack<ItemStack> offspring = new Stack<ItemStack>();
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(housing.getWorld(), housing.getOwnerName());
IApiaristTracker breedingTracker = BeeManager.beeRoot.getBreedingTracker(housing.getWorld(), housing.getOwnerName());
housing.onQueenDeath(getQueen());
// Princess
IBee heiress = queen.spawnPrincess(housing);
if (heiress != null) {
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
breedingTracker.registerPrincess(heiress);
offspring.push(princess);
boolean secondPrincess = this.housing.getWorld().rand.nextInt(10000) < PluginApiculture.getSecondPrincessChance() * 100;
int count = secondPrincess ? 2 : 1;
while (count > 0) {
count--;
IBee heiress = queen.spawnPrincess(housing);
if (heiress != null) {
ItemStack princess = BeeManager.beeRoot.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
breedingTracker.registerPrincess(heiress);
offspring.push(princess);
}
}
// Drones
IBee[] larvae = queen.spawnDrones(housing);
for (IBee larva : larvae) {
ItemStack drone = PluginApiculture.beeInterface.getMemberStack(larva, EnumBeeType.DRONE.ordinal());
ItemStack drone = BeeManager.beeRoot.getMemberStack(larva, EnumBeeType.DRONE.ordinal());
breedingTracker.registerDrone(larva);
offspring.push(drone);
}
while (!offspring.isEmpty()) {
ItemStack spawned = offspring.pop();
if (!housing.addProduct(spawned, true))
if (!housing.addProduct(spawned, true)) {
spawn.add(spawned);
}
}
housing.onPostQueenDeath(getQueen());
@@ -1,79 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderCacti implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(world.getBlockMetadata(x, y, z));
return block == Blocks.cactus;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
return pollinatable.getPlantType().contains(EnumPlantType.Desert);
}
private boolean checkFlowerPot(int meta) {
return meta == 9;
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
return growInPot(world, x, y, z);
return false;
}
private boolean growInPot(World world, int x, int y, int z) {
if (world.rand.nextBoolean())
world.setBlock(x, y, z, Blocks.flower_pot, 9, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlock(x, y, z, Blocks.flower_pot, 10, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.cacti");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.cactus) };
}
}
@@ -1,58 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.utils.StringUtil;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderEnd implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.dragon_egg;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.end");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.dragon_egg) };
}
}
@@ -1,76 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StringUtil;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderGourd implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.pumpkin_stem || block == Blocks.melon_stem;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// We only grow wheat, we don't plant it
if (block != Blocks.pumpkin_stem && block != Blocks.melon_stem)
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta > 6)
return false;
if (meta < 6)
meta += 2;
else
meta = 7;
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.gourd");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
}
}
@@ -1,97 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StringUtil;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderMushroom implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(world.getBlockMetadata(x, y, z));
return block == Blocks.brown_mushroom || block == Blocks.red_mushroom;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
private boolean checkFlowerPot(int meta) {
return meta == 7 || meta == 8;
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (!block.isAir(world, x, y, z))
if (block == Blocks.flower_pot)
return growInPot(world, x, y, z);
else
return false;
// Check ground
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.mycelium)
return false;
Block mushroom;
if (world.rand.nextBoolean())
mushroom = Blocks.brown_mushroom;
else
mushroom = Blocks.red_mushroom;
world.setBlock(x, y, z, mushroom, 0, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
private boolean growInPot(World world, int x, int y, int z) {
if (world.rand.nextBoolean())
world.setBlock(x, y, z, Blocks.flower_pot, 7, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlock(x, y, z, Blocks.flower_pot, 8, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.mushroom");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom) };
}
}
@@ -1,74 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderNetherwart implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.nether_wart;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
return pollinatable.getPlantType().contains(EnumPlantType.Nether);
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// We only grow netherwart, we don't plant it
if (block != Blocks.nether_wart)
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 3)
return false;
if (meta == 2)
meta = 3;
else
meta = 2;
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.nether");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.nether_wart) };
}
}
@@ -1,106 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
import java.util.Collections;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderVanilla implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(meta);
ItemStack flower = new ItemStack(block, 1, meta);
for (ItemStack stack : FlowerManager.plainFlowers)
if (flower.isItemEqual(stack))
return true;
return false;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
private boolean checkFlowerPot(int meta) {
return meta == 1 || meta == 2;
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (!block.isAir(world, x, y, z))
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
return growInPot(world, x, y, z);
else
return false;
// Check ground
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass)
return false;
// Determine flower to plant
Collections.shuffle(FlowerManager.plainFlowers);
ItemStack flower = FlowerManager.plainFlowers.get(world.rand.nextInt(FlowerManager.plainFlowers.size() - 1));
world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH);
return true;
}
private boolean growInPot(World world, int x, int y, int z) {
if (world.rand.nextBoolean())
world.setBlock(x, y, z, Blocks.flower_pot, 1, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlock(x, y, z, Blocks.flower_pot, 2, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.vanilla");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return FlowerManager.plainFlowers.toArray(new ItemStack[FlowerManager.plainFlowers.size()]);
}
}
@@ -1,76 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StringUtil;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderWheat implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.wheat;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// We only grow wheat, we don't plant it
if (block != Blocks.wheat)
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta > 6)
return false;
if (meta < 6)
meta += 2;
else
meta = 7;
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.wheat");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
import forestry.apiculture.gadgets.TileAlvearyPlain;
import forestry.apiculture.gadgets.TileAlvearySieve;
@@ -37,12 +38,11 @@ import forestry.apiculture.gui.GuiBeealyzer;
import forestry.apiculture.gui.GuiHabitatLocator;
import forestry.apiculture.gui.GuiImprinter;
import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory;
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
import forestry.core.GuiHandlerBase;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.network.GuiId;
import forestry.plugins.PluginApiculture;
public class GuiHandlerApiculture extends GuiHandlerBase {
@@ -51,56 +51,60 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
int cleanId = decodeGuiID(id);
int guiData = decodeGuiData(id);
if (cleanId >= GuiId.values().length)
if (cleanId >= GuiId.values().length) {
return null;
}
ItemStack equipped;
switch (GuiId.values()[cleanId]) {
case AlvearyGUI:
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearyGUI:
return new GuiAlveary(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyPlain.class));
case AlvearySieveGUI:
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new GuiAlvearySieve(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySieve.class));
case AlvearySwarmerGUI:
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new GuiAlvearySwarmer(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySwarmer.class));
case ApiaristChestGUI:
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaristChestGUI:
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
case ApiaryGUI:
return new GuiApiary(player.inventory, getTileForestry(world, x, y, z, player, TileApiary.class));
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
return new GuiApiary(player.inventory, getTileForestry(world, x, y, z, player, TileBeehouse.class));
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
case HygroregulatorGUI:
return new GuiAlvearyHygroregulator(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyHygroregulator.class));
case ImprinterGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new GuiHabitatLocator(player.inventory, new BiomefinderInventory(equipped));
case HygroregulatorGUI:
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
}
}
@@ -109,65 +113,69 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
int cleanId = decodeGuiID(id);
int guiData = decodeGuiData(id);
if (cleanId >= GuiId.values().length)
if (cleanId >= GuiId.values().length) {
return null;
}
ItemStack equipped;
switch (GuiId.values()[cleanId]) {
case AlvearyGUI:
synchApiaristTracker(world, player);
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearyGUI:
synchApiaristTracker(world, player);
return new ContainerAlveary(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyPlain.class));
case AlvearySieveGUI:
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new ContainerAlvearySieve(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySieve.class));
case AlvearySwarmerGUI:
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new ContainerAlvearySwarmer(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySwarmer.class));
case ApiaristChestGUI:
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaristChestGUI:
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
case ApiaryGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, getTileForestry(world, x, y, z, player, TileApiary.class), true);
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
synchApiaristTracker(world, player);
return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player);
case BeehouseGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, getTileForestry(world, x, y, z, player, TileBeehouse.class), false);
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new ContainerHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
case HygroregulatorGUI:
return new ContainerAlvearyHygroregulator(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyHygroregulator.class));
case ImprinterGUI:
synchApiaristTracker(world, player);
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
synchApiaristTracker(world, player);
return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player);
case BeehouseGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new ContainerHabitatLocator(player.inventory, new BiomefinderInventory(equipped));
case HygroregulatorGUI:
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
synchApiaristTracker(world, player);
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
}
}
private void synchApiaristTracker(World world, EntityPlayer player) {
PluginApiculture.beeInterface.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player);
private static void synchApiaristTracker(World world, EntityPlayer player) {
BeeManager.beeRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player);
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -17,8 +17,9 @@ public class MaterialBeehive extends Material {
public MaterialBeehive(boolean noHarvest) {
super(MapColor.stoneColor);
if (noHarvest)
if (noHarvest) {
this.setRequiresTool();
}
setImmovableMobility();
}
@@ -1,52 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.apiculture.gui.ContainerImprinter;
import forestry.core.interfaces.IPacketHandler;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketIds;
import forestry.core.proxy.Proxies;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
public class PacketHandlerApiculture implements IPacketHandler {
@Override
public void onPacketData(int packetID, DataInputStream data, EntityPlayer player) {
try {
switch (packetID) {
case PacketIds.HABITAT_BIOME_POINTER:
PacketCoordinates packetC = new PacketCoordinates();
packetC.readData(data);
Proxies.common.setBiomefinderCoordinates(player, packetC.getCoordinates());
break;
case PacketIds.IMPRINT_SELECTION_GET:
onImprintSelectionGet(player);
break;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void onImprintSelectionGet(EntityPlayer playerEntity) {
if (!(playerEntity.openContainer instanceof ContainerImprinter))
return;
((ContainerImprinter) playerEntity.openContainer).sendSelection(playerEntity);
}
}
@@ -4,21 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import forestry.core.interfaces.ISaveEventHandler;
import forestry.plugins.PluginApiculture;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.core.interfaces.ISaveEventHandler;
public class SaveEventHandlerApiculture implements ISaveEventHandler {
@Override
public void onWorldLoad(World world) {
PluginApiculture.beeInterface.resetBeekeepingMode();
BeeManager.beeRoot.resetBeekeepingMode();
}
@Override
@@ -4,25 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
import forestry.api.apiculture.EnumBeeType;
import forestry.apiculture.genetics.BeeTemplates;
import forestry.apiculture.items.ItemHoneycomb;
import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -33,6 +23,18 @@ import net.minecraft.village.MerchantRecipeList;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
import forestry.api.apiculture.EnumBeeType;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.apiculture.items.ItemHoneycomb;
import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
public static void registerVillageComponents() {
@@ -50,10 +52,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
recipeList.add(new MerchantRecipe(new ItemStack(Items.wheat, 2), ItemHoneycomb.getRandomComb(1, random, false)));
recipeList.add(new MerchantRecipe(new ItemStack(Blocks.log, 24, Defaults.WILDCARD), ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARY_META)));
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), ForestryItem.frameProven.getItemStack(6)));
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 12), ForestryItem.beePrincessGE.getItemStack(1, Defaults.WILDCARD),
PluginApiculture.beeInterface.getMemberStack(
PluginApiculture.beeInterface.getBee(villager.worldObj, PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getMonasticTemplate())),
EnumBeeType.DRONE.ordinal())));
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 12), ForestryItem.beePrincessGE.getItemStack(1, Defaults.WILDCARD), BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE)));
}
@Override
@@ -10,47 +10,51 @@
******************************************************************************/
package forestry.apiculture.commands;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.core.commands.ICommandModeHelper;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.core.commands.ICommandModeHelper;
public class BeeModeHelper implements ICommandModeHelper {
@Override
public String[] getModeNames() {
ArrayList<IBeekeepingMode> beekeepingModes = PluginApiculture.beeInterface.getBeekeepingModes();
ArrayList<IBeekeepingMode> beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
int modeStringCount = beekeepingModes.size();
List<String> modeStrings = new ArrayList<String>(modeStringCount);
for (IBeekeepingMode mode : beekeepingModes)
for (IBeekeepingMode mode : beekeepingModes) {
modeStrings.add(mode.getName());
}
return modeStrings.toArray(new String[modeStringCount]);
}
@Override
public String getModeNameMatching(String desired) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
if (mode == null)
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(desired);
if (mode == null) {
return null;
}
return mode.getName();
}
@Override
public String getModeName(World world) {
return PluginApiculture.beeInterface.getBeekeepingMode(world).getName();
return BeeManager.beeRoot.getBeekeepingMode(world).getName();
}
@Override
public void setMode(World world, String modeName) {
PluginApiculture.beeInterface.setBeekeepingMode(world, modeName);
BeeManager.beeRoot.setBeekeepingMode(world, modeName);
}
@Override
public Iterable<String> getDescription(String modeName) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(modeName);
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(modeName);
return mode.getDescription();
}
@@ -10,7 +10,15 @@
******************************************************************************/
package forestry.apiculture.commands;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.AlleleManager;
@@ -19,11 +27,6 @@ import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IBreedingTracker;
import forestry.core.commands.IStatsSaveHelper;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
public class BeeStatsSaveHelper implements IStatsSaveHelper {
@@ -34,7 +37,7 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper {
@Override
public void addExtraInfo(Collection<String> statistics, IBreedingTracker breedingTracker) {
IApiaristTracker tracker = (IApiaristTracker)breedingTracker;
IApiaristTracker tracker = (IApiaristTracker) breedingTracker;
String discoveredLine = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered") + ":";
statistics.add(discoveredLine);
statistics.add(StringUtil.line(discoveredLine.length()));
@@ -51,9 +54,11 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper {
@Override
public Collection<IAlleleSpecies> getSpecies() {
Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
species.add((IAlleleBeeSpecies) allele);
}
}
return species;
}
@@ -64,7 +69,7 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper {
@Override
public IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile) {
return PluginApiculture.beeInterface.getBreedingTracker(world, gameProfile);
return BeeManager.beeRoot.getBreedingTracker(world, gameProfile);
}
}
@@ -4,12 +4,21 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.commands;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
@@ -20,13 +29,6 @@ import forestry.core.commands.CommandHelpers;
import forestry.core.commands.SpeciesNotFoundException;
import forestry.core.commands.SubCommand;
import forestry.core.commands.TemplateNotFoundException;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class CommandBeeGive extends SubCommand {
@@ -39,8 +41,9 @@ public class CommandBeeGive extends SubCommand {
List<String> beeTypeStrings = new ArrayList<String>();
for (EnumBeeType type : EnumBeeType.values()) {
if (type == EnumBeeType.NONE)
if (type == EnumBeeType.NONE) {
continue;
}
beeTypeStrings.add(type.getName());
}
@@ -52,8 +55,9 @@ public class CommandBeeGive extends SubCommand {
Iterator<String> iter = beeTypeStrings.iterator();
while (iter.hasNext()) {
beeTypeHelp.append(iter.next());
if (iter.hasNext())
if (iter.hasNext()) {
beeTypeHelp.append(separator);
}
}
beeTypeHelpString = beeTypeHelp.toString();
}
@@ -83,12 +87,13 @@ public class CommandBeeGive extends SubCommand {
return;
}
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome);
IBee bee = BeeManager.beeRoot.getBee(player.worldObj, beeGenome);
if(beeType == EnumBeeType.QUEEN)
if (beeType == EnumBeeType.QUEEN) {
bee.mate(bee);
}
ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal());
ItemStack beeStack = BeeManager.beeRoot.getMemberStack(bee, beeType.ordinal());
player.dropPlayerItemWithRandomChoice(beeStack, true);
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName());
@@ -99,8 +104,9 @@ public class CommandBeeGive extends SubCommand {
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
if (!uid.equals(speciesName))
if (!uid.equals(speciesName)) {
continue;
}
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
@@ -117,15 +123,17 @@ public class CommandBeeGive extends SubCommand {
}
}
if (species == null)
if (species == null) {
throw new SpeciesNotFoundException(speciesName);
}
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
IAllele[] template = BeeManager.beeRoot.getTemplate(species.getUID());
if (template == null)
if (template == null) {
throw new TemplateNotFoundException(species);
}
return PluginApiculture.beeInterface.templateAsGenome(template);
return BeeManager.beeRoot.templateAsGenome(template);
}
@Override
@@ -145,17 +153,20 @@ public class CommandBeeGive extends SubCommand {
String[] getSpecies() {
List<String> species = new ArrayList<String>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
species.add(allele.getName());
}
}
return species.toArray(new String[species.size()]);
}
EnumBeeType getBeeType(String beeTypeName) {
for (EnumBeeType beeType : EnumBeeType.values()) {
if (beeType.getName().equalsIgnoreCase(beeTypeName))
if (beeType.getName().equalsIgnoreCase(beeTypeName)) {
return beeType;
}
}
return EnumBeeType.NONE;
}
@@ -10,18 +10,20 @@
******************************************************************************/
package forestry.apiculture.entities;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.core.config.Defaults;
import forestry.core.utils.ForestryResource;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class EntityBee extends EntityCreature implements IAnimals {
@@ -43,10 +45,11 @@ public class EntityBee extends EntityCreature implements IAnimals {
}
public EntityBee setIndividual(IBee bee) {
if (bee != null)
if (bee != null) {
contained = bee;
else
contained = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());
} else {
contained = BeeManager.beeRoot.templateAsIndividual(BeeManager.beeRoot.getDefaultTemplate());
}
//isImmuneToFire = contained.getGenome().getFireResist();
setSpecies(contained.getGenome().getPrimary());
@@ -81,8 +84,9 @@ public class EntityBee extends EntityCreature implements IAnimals {
@SideOnly(Side.CLIENT)
public ResourceLocation getTexture() {
if (textureResource == null || lastTextureUpdate != lastUpdate)
if (textureResource == null || lastTextureUpdate != lastUpdate) {
textureResource = new ForestryResource(beeTexture);
}
return textureResource;
}
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.genetics.IFlower;
final class Flower implements IFlower {
private final Block block;
private final int meta;
private Double weight;
public Flower(Block block, int meta, double weight) {
this.block = block;
this.meta = meta;
this.weight = weight;
}
public boolean isPlantable() {
return this.weight != 0.0;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof IFlower)) {
return false;
}
IFlower flower = (IFlower) obj;
return Block.isEqualTo(this.block, flower.getBlock()) && (this.meta == OreDictionary.WILDCARD_VALUE || flower.getMeta() == OreDictionary.WILDCARD_VALUE || this.meta == flower.getMeta());
}
@Override
public int compareTo(IFlower other) {
return this.weight.compareTo(other.getWeight());
}
@Override
public Block getBlock() {
return block;
}
@Override
public int getMeta() {
return meta;
}
@Override
public double getWeight() {
return weight;
}
@Override
public void setWeight(double weight) {
this.weight = weight;
}
}
@@ -4,66 +4,64 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
package forestry.apiculture.flowers;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StringUtil;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProviderJungle implements IFlowerProvider {
public class FlowerProvider implements IFlowerProvider {
private final String flowerType;
private final String description;
public FlowerProvider(String flowerType, String description) {
this.flowerType = flowerType;
this.description = description;
}
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(meta);
return block == Blocks.vine || (block == Blocks.tallgrass && meta == 2);
return FlowerManager.flowerRegistry.isAcceptedFlower(this.flowerType, world, individual, x, y, z);
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
private boolean checkFlowerPot(int meta) {
return meta == 11;
EnumSet<EnumPlantType> plantTypes = pollinatable.getPlantType();
if (flowerType.equals(FlowerManager.FlowerTypeNether)) {
return plantTypes.contains(EnumPlantType.Nether);
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
return plantTypes.contains(EnumPlantType.Desert);
} else {
return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether);
}
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block == Blocks.flower_pot)
return growInPot(world, x, y, z);
return false;
}
private boolean growInPot(World world, int x, int y, int z) {
world.setBlock(x, y, z, Blocks.flower_pot, 11, Defaults.FLAG_BLOCK_SYNCH);
return true;
return FlowerManager.flowerRegistry.growFlower(this.flowerType, world, individual, x, y, z);
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.jungle");
return StringUtil.localize(this.description);
}
@Override
@@ -72,8 +70,8 @@ public class FlowerProviderJungle implements IFlowerProvider {
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.vine), new ItemStack(Blocks.tallgrass, 1, 2) };
public List<IFlower> getFlowers() {
return FlowerManager.flowerRegistry.getAcceptableFlowers(this.flowerType);
}
}
@@ -0,0 +1,251 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import com.google.common.collect.ArrayListMultimap;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public final class FlowerRegistry implements IFlowerRegistry {
private final ArrayListMultimap<String, IFlower> registeredFlowers;
private final ArrayListMultimap<String, IFlowerGrowthRule> growthRules;
private final Map<String, TreeMap<Double, IFlower>> chances;
private boolean hasDeprecatedFlowersImported;
public FlowerRegistry() {
this.registeredFlowers = ArrayListMultimap.create();
this.growthRules = ArrayListMultimap.create();
this.chances = new HashMap<String, TreeMap<Double, IFlower>>();
this.hasDeprecatedFlowersImported = false;
registerVanillaFlowers();
registerVanillaGrowthRules();
}
@Override
public void registerAcceptableFlower(Block block, String... flowerTypes) {
registerFlower(block, OreDictionary.WILDCARD_VALUE, 0.0, flowerTypes);
}
@Override
public void registerAcceptableFlower(Block block, int meta, String... flowerTypes) {
registerFlower(block, meta, 0.0, flowerTypes);
}
@Override
public void registerPlantableFlower(Block block, int meta, double weight, String... flowerTypes) {
registerFlower(block, meta, weight, flowerTypes);
}
private void registerFlower(Block block, int meta, double weight, String... flowerTypes) {
if (block == null) {
return;
}
if (weight <= 0.0) {
weight = 0.0;
}
if (weight >= 1.0) {
weight = 1.0;
}
Flower newFlower = new Flower(block, meta, weight);
Integer index;
for (String flowerType : flowerTypes) {
List<IFlower> flowers = this.registeredFlowers.get(flowerType);
index = flowers.indexOf(newFlower);
if (index == -1) {
flowers.add(newFlower);
} else if (flowers.get(index).getMeta() != newFlower.getMeta()) {
flowers.add(newFlower);
} else if (flowers.get(index).getWeight() < newFlower.getWeight() && flowers.get(index).getMeta() == newFlower.getMeta()) {
flowers.get(index).setWeight(newFlower.getWeight());
}
if (this.chances.containsKey(flowerType)) {
this.chances.remove(flowerType);
}
Collections.sort(this.registeredFlowers.get(flowerType));
}
}
@Override
public boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
internalInitialize();
if (!this.registeredFlowers.containsKey(flowerType)) {
return false;
}
Block block = world.getBlock(x, y, z);
if (block.isAir(world, x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) {
return false;
}
int meta;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlowerPot) {
TileEntityFlowerPot tileFlowerPot = (TileEntityFlowerPot) tile;
Item item = tileFlowerPot.getFlowerPotItem();
block = Block.getBlockFromItem(item);
meta = tileFlowerPot.getFlowerPotData();
} else {
meta = world.getBlockMetadata(x, y, z);
}
Flower flower = new Flower(block, meta, 0);
List<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
return acceptedFlowers.contains(flower);
}
@Override
public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
internalInitialize();
if (!this.growthRules.containsKey(flowerType)) {
return false;
}
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
if (rule.growFlower(this, flowerType, world, individual, x, y, z)) {
return true;
}
}
return false;
}
@Override
public List<IFlower> getAcceptableFlowers(String flowerType) {
internalInitialize();
return this.registeredFlowers.get(flowerType);
}
@Override
public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) {
if (rule == null) {
return;
}
for (String flowerType : flowerTypes) {
this.growthRules.get(flowerType).add(rule);
}
}
@Override
public IFlower getRandomPlantableFlower(String flowerType, Random rand) {
TreeMap<Double, IFlower> chancesMap = getChancesMap(flowerType);
double maxKey = chancesMap.lastKey() + 1.0;
return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey));
}
private TreeMap<Double, IFlower> getChancesMap(String flowerType) {
if (!this.chances.containsKey(flowerType)) {
TreeMap<Double, IFlower> flowerChances = new TreeMap<Double, IFlower>();
double count = 0.0;
for (IFlower flower : this.registeredFlowers.get(flowerType)) {
if (flower.isPlantable()) {
flowerChances.put(count, flower);
count += flower.getWeight();
}
}
this.chances.put(flowerType, flowerChances);
}
return this.chances.get(flowerType);
}
/*
* Method to support deprecated FlowerManager.plainFlowers
*/
@SuppressWarnings("deprecation")
private void internalInitialize() {
if (!hasDeprecatedFlowersImported) {
for (ItemStack plainFlower : FlowerManager.plainFlowers) {
Block flowerBlock = Block.getBlockFromItem(plainFlower.getItem());
int meta = plainFlower.getItemDamage();
registerPlantableFlower(flowerBlock, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
hasDeprecatedFlowersImported = true;
}
}
private void registerVanillaFlowers() {
// Register acceptable plants
registerAcceptableFlower(Blocks.red_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.yellow_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.brown_mushroom, FlowerManager.FlowerTypeMushrooms);
registerAcceptableFlower(Blocks.red_mushroom, FlowerManager.FlowerTypeMushrooms);
registerAcceptableFlower(Blocks.cactus, FlowerManager.FlowerTypeCacti);
registerAcceptableFlower(Blocks.dragon_egg, FlowerManager.FlowerTypeEnd);
registerAcceptableFlower(Blocks.vine, FlowerManager.FlowerTypeJungle);
registerAcceptableFlower(Blocks.tallgrass, FlowerManager.FlowerTypeJungle);
registerAcceptableFlower(Blocks.wheat, FlowerManager.FlowerTypeWheat);
registerAcceptableFlower(Blocks.pumpkin_stem, FlowerManager.FlowerTypeGourd);
registerAcceptableFlower(Blocks.melon_stem, FlowerManager.FlowerTypeGourd);
registerAcceptableFlower(Blocks.nether_wart, FlowerManager.FlowerTypeNether);
registerAcceptableFlower(Blocks.double_plant, 0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
// Register plantable plants
for (int meta = 0; meta <= 8; meta++) {
registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti);
}
private void registerVanillaGrowthRules() {
registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow);
registerGrowthRule(new VanillaFlowerPotGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
FlowerManager.FlowerTypeJungle);
registerGrowthRule(new VanillaMyceliumGrowthRule(), FlowerManager.FlowerTypeMushrooms);
registerGrowthRule(new VanillaDefaultGrowthRule(), FlowerManager.FlowerTypeEnd);
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.wheat), FlowerManager.FlowerTypeWheat);
}
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaDefaultGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return true;
}
}
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Defaults;
public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
}
}
@@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule {
private final List<Block> allowedItems;
public VanillaFertilizeGrowthRule(Block... allowedItems) {
this.allowedItems = Arrays.asList(allowedItems);
}
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
Block ground = world.getBlock(x, y, z);
int groundMeta;
for (Block b : this.allowedItems) {
if (b == ground) {
groundMeta = world.getBlockMetadata(x, y, z);
if (groundMeta > 6) {
return false;
}
if (groundMeta < 6) {
groundMeta += world.rand.nextInt(2) + 1;
} else {
groundMeta = 7;
}
return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2);
}
}
return false;
}
}
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlowerPot;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.world.World;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlowerPot)) {
return false;
}
TileEntityFlowerPot flowerPotTile = (TileEntityFlowerPot) tile;
if (flowerPotTile.getFlowerPotItem() != null) {
return false;
}
Block block = world.getBlock(x, y, z);
if (!(block instanceof BlockFlowerPot)) {
return false;
}
BlockFlowerPot flowerPot = (BlockFlowerPot) block;
int flower;
if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) {
flower = world.rand.nextInt(2) + 1;
} else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) {
flower = 6;
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
flower = world.rand.nextInt(2) + 9;
} else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) {
flower = world.rand.nextInt(2) + 7;
} else {
return false;
}
TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower);
flowerPotTile.func_145964_a(newTile.getFlowerPotItem(), newTile.getFlowerPotData());
flowerPotTile.markDirty();
if (!world.setBlockMetadataWithNotify(x, y, z, 1, 2)) {
world.markBlockForUpdate(x, y, z);
}
return true;
}
}
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Defaults;
public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.mycelium) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
}
}
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Defaults;
public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (world.getBlock(x, y, z) != Blocks.snow) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
}
}
@@ -4,20 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.gadgets.BlockStructure;
import forestry.core.render.TextureManager;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -28,6 +23,14 @@ 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 forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.gadgets.BlockStructure;
import forestry.core.render.TextureManager;
public class BlockAlveary extends BlockStructure {
public BlockAlveary() {
@@ -36,13 +39,14 @@ public class BlockAlveary extends BlockStructure {
setCreativeTab(Tabs.tabApiculture);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 8; i++) {
if (i == 1)
if (i == 1) {
continue;
}
list.add(new ItemStack(item, 1, i));
}
}
@@ -74,20 +78,20 @@ public class BlockAlveary extends BlockStructure {
@Override
public TileEntity createTileEntity(World world, int metadata) {
switch (metadata) {
case TileAlvearySwarmer.BLOCK_META:
return new TileAlvearySwarmer();
case TileAlvearyFan.BLOCK_META:
return new TileAlvearyFan();
case TileAlvearyHeater.BLOCK_META:
return new TileAlvearyHeater();
case TileAlvearyHygroregulator.BLOCK_META:
return new TileAlvearyHygroregulator();
case TileAlvearyStabiliser.BLOCK_META:
return new TileAlvearyStabiliser();
case TileAlvearySieve.BLOCK_META:
return new TileAlvearySieve();
default:
return new TileAlvearyPlain();
case TileAlvearySwarmer.BLOCK_META:
return new TileAlvearySwarmer();
case TileAlvearyFan.BLOCK_META:
return new TileAlvearyFan();
case TileAlvearyHeater.BLOCK_META:
return new TileAlvearyHeater();
case TileAlvearyHygroregulator.BLOCK_META:
return new TileAlvearyHygroregulator();
case TileAlvearyStabiliser.BLOCK_META:
return new TileAlvearyStabiliser();
case TileAlvearySieve.BLOCK_META:
return new TileAlvearySieve();
default:
return new TileAlvearyPlain();
}
}
@@ -140,28 +144,29 @@ public class BlockAlveary extends BlockStructure {
public IIcon getIcon(int side, int metadata) {
if ((metadata <= 1
|| metadata == TileAlvearySieve.BLOCK_META || metadata == TileAlvearySwarmer.BLOCK_META || metadata == TileAlvearyStabiliser.BLOCK_META)
&& (side == 1 || side == 0))
&& (side == 1 || side == 0)) {
return icons[BOTTOM];
}
switch (metadata) {
case TileAlvearyPlain.BLOCK_META:
return icons[PLAIN];
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
return icons[ALVEARY_SWARMER_OFF];
case TileAlvearyFan.BLOCK_META:
return icons[ALVEARY_FAN_OFF];
case TileAlvearyHeater.BLOCK_META:
return icons[ALVEARY_HEATER_OFF];
case TileAlvearyHygroregulator.BLOCK_META:
return icons[ALVEARY_HYGRO];
case TileAlvearyStabiliser.BLOCK_META:
return icons[STABILISER];
case TileAlvearySieve.BLOCK_META:
return icons[SIEVE];
default:
return null;
case TileAlvearyPlain.BLOCK_META:
return icons[PLAIN];
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
return icons[ALVEARY_SWARMER_OFF];
case TileAlvearyFan.BLOCK_META:
return icons[ALVEARY_FAN_OFF];
case TileAlvearyHeater.BLOCK_META:
return icons[ALVEARY_HEATER_OFF];
case TileAlvearyHygroregulator.BLOCK_META:
return icons[ALVEARY_HYGRO];
case TileAlvearyStabiliser.BLOCK_META:
return icons[STABILISER];
case TileAlvearySieve.BLOCK_META:
return icons[SIEVE];
default:
return null;
}
}
@@ -171,10 +176,11 @@ public class BlockAlveary extends BlockStructure {
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 1)
if (meta == 1) {
return this.getIcon(side, meta);
else if (meta > 1)
} else if (meta > 1) {
return getBlockTextureFromSideAndTile(world, x, y, z, side);
}
Block blockXP = world.getBlock(x + 1, y, z);
Block blockXM = world.getBlock(x - 1, y, z);
@@ -183,24 +189,29 @@ public class BlockAlveary extends BlockStructure {
if (world.getBlockMetadata(x + 1, y, z) == 1) {
if (world.getBlock(x, y, z + 1) != this)
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(42, side);
else
} else {
return switchForSide(41, side);
}
} else
} else {
return this.getIcon(side, meta);
}
} else if (blockXP != this && blockXM == this)
} else if (blockXP != this && blockXM == this) {
if (world.getBlockMetadata(x - 1, y, z) == 1) {
if (world.getBlock(x, y, z + 1) != this)
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(41, side);
else
} else {
return switchForSide(42, side);
}
} else
} else {
return this.getIcon(side, meta);
}
}
return this.getIcon(side, meta);
}
@@ -208,8 +219,9 @@ public class BlockAlveary extends BlockStructure {
@SideOnly(Side.CLIENT)
private IIcon getBlockTextureFromSideAndTile(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile == null || !(tile instanceof TileAlveary))
if (tile == null || !(tile instanceof TileAlveary)) {
return getIcon(side, 0);
}
return icons[((TileAlveary) tile).getIcon(side, world.getBlockMetadata(x, y, z))];
}
@@ -218,14 +230,16 @@ public class BlockAlveary extends BlockStructure {
private IIcon switchForSide(int textureId, int side) {
if (side == 4 || side == 5) {
if (textureId == 41)
if (textureId == 41) {
return icons[LEFT];
else
} else {
return icons[RIGHT];
} else if (textureId == 41)
}
} else if (textureId == 41) {
return icons[RIGHT];
else
} else {
return icons[LEFT];
}
}
}
@@ -4,27 +4,16 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IHiveDrop;
import forestry.apiculture.worldgen.HiveRegistry;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.config.Config;
import forestry.core.inventory.InvTools;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.BlockContainer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -37,6 +26,19 @@ 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 forestry.api.apiculture.IHiveDrop;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.apiculture.worldgen.HiveRegistry;
import forestry.core.config.Config;
import forestry.core.inventory.InvTools;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
public class BlockBeehives extends BlockContainer {
public BlockBeehives() {
@@ -58,17 +60,20 @@ public class BlockBeehives extends BlockContainer {
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
if (canHarvestBlock(player, world.getBlockMetadata(x, y, z))) {
// Handle TE'd beehives
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileSwarm) {
TileSwarm swarm = (TileSwarm) tile;
if (swarm.containsBees())
for (ItemStack beeStack : InvTools.getStacks(swarm.contained))
if (beeStack != null)
if (swarm.containsBees()) {
for (ItemStack beeStack : InvTools.getStacks(swarm.contained)) {
if (beeStack != null) {
StackUtils.dropItemStackAsEntity(beeStack, world, x, y, z);
}
}
}
}
}
@@ -94,26 +99,29 @@ public class BlockBeehives extends BlockContainer {
while (tries <= 10 && !hasPrincess) {
tries++;
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.add(drop.getPrincess(world, x, y, z, fortune));
hasPrincess = true;
break;
}
}
}
// Grab drones
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getDrones(world, x, y, z, fortune));
break;
}
}
// Grab anything else on offer
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getAdditional(world, x, y, z, fortune));
break;
}
}
return ret;
}
@@ -126,25 +134,33 @@ public class BlockBeehives extends BlockContainer {
private List<IHiveDrop> getDropsForHive(int meta) {
String hiveName = getHiveNameForMeta(meta);
if (hiveName == null)
if (hiveName == null) {
return Collections.emptyList();
}
return PluginApiculture.hiveRegistry.getDrops(hiveName);
}
private String getHiveNameForMeta(int meta) {
switch (meta) {
case 1: return HiveRegistry.forest;
case 2: return HiveRegistry.meadows;
case 3: return HiveRegistry.desert;
case 4: return HiveRegistry.jungle;
case 5: return HiveRegistry.end;
case 6: return HiveRegistry.snow;
case 7: return HiveRegistry.swamp;
case 1:
return HiveRegistry.forest;
case 2:
return HiveRegistry.meadows;
case 3:
return HiveRegistry.desert;
case 4:
return HiveRegistry.jungle;
case 5:
return HiveRegistry.end;
case 6:
return HiveRegistry.snow;
case 7:
return HiveRegistry.swamp;
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 1));
@@ -152,7 +168,7 @@ public class BlockBeehives extends BlockContainer {
itemList.add(new ItemStack(this, 1, 3));
itemList.add(new ItemStack(this, 1, 4));
if (Config.isDebug) {
itemList.add(new ItemStack(this, 1 ,5));
itemList.add(new ItemStack(this, 1, 5));
}
itemList.add(new ItemStack(this, 1, 6));
itemList.add(new ItemStack(this, 1, 7));
@@ -176,18 +192,21 @@ public class BlockBeehives extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) {
if (j == 0 || j > 8)
if (j == 0 || j > 8) {
return null;
}
if (i == 0 || i == 1) {
if (j * 2 < icons.length && icons[j * 2] != null)
if (j * 2 < icons.length && icons[j * 2] != null) {
return icons[j * 2];
else
} else {
return icons[2];
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null)
}
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null) {
return icons[j * 2 + 1];
else
} else {
return icons[3];
}
}
}
@@ -4,24 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.ForestryClient;
import forestry.core.config.Defaults;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
import com.google.common.collect.ImmutableMap;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import java.util.Set;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -34,14 +33,53 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.ForestryClient;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
public class BlockCandle extends BlockTorch {
private final ArrayList<Item> lightingItems = new ArrayList<Item>();
private static final ImmutableMap<String, Integer> colours;
private static final Set<Item> lightingItems;
public static final String colourTagName = "colour";
static {
colours = ImmutableMap.<String, Integer>builder()
.put("dyeWhite", new Color(255, 255, 255).getRGB())
.put("dyeOrange", new Color(219, 125, 62).getRGB())
.put("dyeMagenta", new Color(255, 20, 255).getRGB())
.put("dyeLightBlue", new Color(107, 138, 201).getRGB())
.put("dyeYellow", new Color(255, 255, 20).getRGB())
.put("dyeLime", new Color(20, 255, 20).getRGB())
.put("dyePink", new Color(208, 132, 153).getRGB())
.put("dyeGray", new Color(74, 74, 74).getRGB())
.put("dyeLightGray", new Color(154, 161, 161).getRGB())
.put("dyeCyan", new Color(20, 255, 255).getRGB())
.put("dyePurple", new Color(126, 61, 181).getRGB())
.put("dyeBlue", new Color(20, 20, 255).getRGB())
.put("dyeBrown", new Color(79, 50, 31).getRGB())
.put("dyeGreen", new Color(53, 70, 27).getRGB())
.put("dyeRed", new Color(150, 52, 48).getRGB())
.put("dyeBlack", new Color(20, 20, 20).getRGB())
.build();
lightingItems = new HashSet<Item>(Arrays.asList(
Items.flint_and_steel,
Items.flint,
Item.getItemFromBlock(Blocks.torch)
));
}
@SideOnly(Side.CLIENT)
private IIcon litStump;
@@ -57,10 +95,6 @@ public class BlockCandle extends BlockTorch {
this.setHardness(0.0F);
this.setStepSound(soundTypeWood);
setCreativeTab(Tabs.tabApiculture);
lightingItems.add(Items.flint_and_steel);
lightingItems.add(Items.flint);
lightingItems.add(Item.getItemFromBlock(Blocks.torch));
}
@Override
@@ -91,299 +125,183 @@ public class BlockCandle extends BlockTorch {
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return (isLit(meta))? 14 : 0;
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileCandle && ((TileCandle) tileEntity).isLit()) {
return 14;
}
return 0;
}
/*@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
IIcon i = this.unlitStump;
if (this.isLit(world.getBlockMetadata(x, y, z))) {
i = this.litStump;
}
return i;
}*/
@SideOnly(Side.CLIENT)
public IIcon getTextureFromPassAndMeta(int meta, int pass) {
public IIcon getTextureFromPassAndLit(int pass, boolean isLit) {
IIcon i;
if (pass == 0) {
if (isLit(meta)) {
if (isLit) {
i = this.litTip;
}
else {
} else {
i = this.unlitTip;
}
}
else {
if (isLit(meta)) {
} else {
if (isLit) {
i = this.litStump;
}
else {
} else {
i = this.unlitStump;
}
}
return i;
}
public int getColourFromItemStack(ItemStack stack) {
int colour = 0xffffff;
if (stack.hasTagCompound()) {
NBTTagCompound tag = stack.getTagCompound();
colour = (tag.getByte("red") << 16) | (tag.getByte("green") << 8) | tag.getByte("blue");
}
return colour;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
}
// Dye names correspond to colour values as below.
private static final String[] dyes = { "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" };
private static final int[][] colours = { { 255, 255, 255 } , { 219, 125, 62 } , { 255, 20, 255 } , { 107, 138, 201 } ,
{ 255, 255, 20 } , { 20, 255, 20 } , { 208, 132, 153 } , { 74, 74, 74 } ,
{ 154, 161, 161 } , { 20, 255, 255 } , { 126, 61, 181 } , { 20, 20, 255 } ,
{ 79, 50, 31 } , { 53, 70, 27 } , { 150, 52, 48 } , { 20, 20, 20 } };
public static final String colourTagName = "colour";
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float facingX, float facingY, float facingZ) {
boolean flag = false;
int meta = world.getBlockMetadata(x, y, z);
boolean toggleLitState = true;
ItemStack held = player.getCurrentEquippedItem();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileCandle)) {
return false;
}
if (!isLit(meta)) {
if (held == null || !lightingItems.contains(held.getItem())) {
TileCandle tileCandle = (TileCandle) tileEntity;
final boolean isLit = tileCandle.isLit();
boolean flag = false;
boolean toggleLitState = true;
ItemStack heldItem = player.getCurrentEquippedItem();
if (!isLit) {
if (heldItem == null || !lightingItems.contains(heldItem.getItem())) {
toggleLitState = false;
}
else if (StackUtils.equals(this, held) && isLit(held)) {
} else if (StackUtils.equals(this, heldItem) && isLit(heldItem)) {
toggleLitState = true;
}
}
if (held != null) {
// Ensure a TileEntity exists. May be able to remove this in future versions.
TileCandle te = (TileCandle)world.getTileEntity(x, y, z);
if (te == null) {
world.setTileEntity(x, y, z, this.createTileEntity(world, meta));
te = (TileCandle)world.getTileEntity(x, y, z);
}
if (StackUtils.equals(this, held)) {
if (!isLit(held)) {
if (heldItem != null) {
if (StackUtils.equals(this, heldItem)) {
if (!isLit(heldItem)) {
// Copy the colour of an unlit, coloured candle.
if (held.hasTagCompound() && held.getTagCompound().hasKey(colourTagName)) {
te.setColour(held.getTagCompound().getInteger(colourTagName));
}
else {
if (heldItem.hasTagCompound() && heldItem.getTagCompound().hasKey(colourTagName)) {
tileCandle.setColour(heldItem.getTagCompound().getInteger(colourTagName));
} else {
// Reset to white if item has no
te.setColour(0xffffff);
tileCandle.setColour(0xffffff);
}
}
else {
} else {
toggleLitState = true;
}
flag = true;
}
else {
// Check for dye-able ness.
boolean matched = false;
for (int i = 0; i < dyes.length; ++i) {
for (ItemStack stack : OreDictionary.getOres(dyes[i])) {
if (OreDictionary.itemMatches(stack, held, true)) {
if (isLit(meta)) {
te.setColour(colours[i][0], colours[i][1], colours[i][2]);
}
else {
te.addColour(colours[i][0], colours[i][1], colours[i][2]);
}
world.markBlockForUpdate(x, y, z);
matched = true;
toggleLitState = false;
flag = true;
break;
}
}
if (matched) {
break;
}
} else {
boolean dyed = tryDye(heldItem, isLit, tileCandle);
if (dyed) {
world.markBlockForUpdate(x, y, z);
toggleLitState = false;
flag = true;
}
}
}
if (toggleLitState) {
meta = this.toggleLitStatus(meta);
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH | Defaults.FLAG_BLOCK_UPDATE);
tileCandle.setLit(!isLit);
world.markBlockForUpdate(x, y, z);
flag = true;
}
return flag;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileCandle tc = (TileCandle)world.getTileEntity(x, y, z);
int newMeta = isLit(meta) ? 1 : 0;
ItemStack stack = new ItemStack(this, 1, newMeta);
if (tc != null && tc.getColour() != 0xffffff) {
// When dropped, tag new item stack with colour. Unless it's white, then do no such thing for maximum stacking.
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger(colourTagName, tc.getColour());
stack.setTagCompound(tag);
private static boolean tryDye(ItemStack held, boolean isLit, TileCandle tileCandle) {
// Check for dye-able ness.
boolean matched = false;
for (Map.Entry<String, Integer> colour : colours.entrySet()) {
String colourName = colour.getKey();
for (ItemStack stack : OreDictionary.getOres(colourName)) {
if (OreDictionary.itemMatches(stack, held, true)) {
if (isLit) {
tileCandle.setColour(colour.getValue());
} else {
tileCandle.addColour(colour.getValue());
}
return true;
}
}
this.dropBlockAsItem(world, x, y, z, stack);
}
super.breakBlock(world, x, y, z, block, meta);
return false;
}
/* DROP HANDLING */
// Hack: When harvesting we need to get the drops in onBlockHarvested,
// because Mojang destroys the block and tile before calling getDrops.
protected ThreadLocal<ItemStack> drop = new ThreadLocal<ItemStack>();
@Override
public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) {
if (!world.isRemote) {
ItemStack itemStack = getCandleDrop(world, x, y, z);
drop.set(itemStack);
}
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ItemStack dropStack = drop.get();
drop.remove();
// not harvested, get drops normally
if (dropStack == null) {
dropStack = getCandleDrop(world, x, y, z);
}
ArrayList<ItemStack> drops = new ArrayList<ItemStack>(1);
drops.add(dropStack);
return drops;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return getCandleDrop(world, x, y, z);
}
private ItemStack getCandleDrop(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileCandle)) {
return null;
}
TileCandle tileCandle = (TileCandle) tileEntity;
int colour = tileCandle.getColour();
int newMeta = tileCandle.isLit() ? 1 : 0;
ItemStack itemStack = new ItemStack(this, 1, newMeta);
if (colour != 0xffffff) {
// When dropped, tag new item stack with colour. Unless it's white, then do no such thing for maximum stacking.
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger(colourTagName, colour);
itemStack.setTagCompound(tag);
}
return itemStack;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
TileCandle tc = (TileCandle)(world.getTileEntity(x, y, z));
tc.setColour(this.getColourValueFromItemStack(itemStack));
if (isLit(itemStack)) {
int meta = world.getBlockMetadata(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, this.toggleLitStatus(meta), Defaults.FLAG_BLOCK_SYNCH | Defaults.FLAG_BLOCK_UPDATE);
}
}
@Override
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) {
// Does nothing to prevent extra candles from falling.
}
@Override
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
// Does nothing to prevent extra candles from falling.
}
@Override
protected boolean func_150109_e(World world, int x, int y, int z) {
// Slightly tweaked version of BlockTorch's version to account for TE nonsense.
if (!this.canPlaceBlockAt(world, x, y, z)) {
if (world.getBlock(x, y, z) == this) {
world.setBlockToAir(x, y, z);
}
return false;
}
else {
return true;
}
TileCandle tileCandle = (TileCandle) (world.getTileEntity(x, y, z));
int colour = getColourValueFromItemStack(itemStack);
boolean isLit = isLit(itemStack);
tileCandle.setColour(colour);
tileCandle.setLit(isLit);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (isLit(world.getBlockMetadata(x, y, z))) {
int l = world.getBlockMetadata(x, y, z) & 0x07;
double d0 = x + 0.5F;
double d1 = y + 0.7F;
double d2 = z + 0.5F;
double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
if (l == 1)
{
world.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (l == 2)
{
world.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (l == 3)
{
world.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
}
else if (l == 4)
{
world.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
}
else
{
world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileCandle && ((TileCandle) tileEntity).isLit()) {
super.randomDisplayTick(world, x, y, z, random);
}
}
@Override
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block)
{
if (this.func_150109_e(par1World, par2, par3, par4))
{
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 0x07;
boolean flag = false;
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1)
{
flag = true;
}
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2)
{
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3)
{
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4)
{
flag = true;
}
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5)
{
flag = true;
}
if (flag)
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(par2, par3, par4);
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
// Yes, function hiding. Go away.
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
{
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4))
{
return true;
}
else
{
Block block = par1World.getBlock(par2, par3, par4);
return block.canPlaceTorchOnTop(par1World, par2, par3, par4);
}
}
protected int getColourValueFromItemStack(ItemStack itemStack) {
protected static int getColourValueFromItemStack(ItemStack itemStack) {
int value = 0xffffff; // default to white.
if (itemStack.hasTagCompound()) {
NBTTagCompound tag = itemStack.getTagCompound();
@@ -394,23 +312,17 @@ public class BlockCandle extends BlockTorch {
return value;
}
public static boolean isLit(int meta) {
return (meta & 0x08) > 0;
}
public static boolean isLit(ItemStack itemStack) {
return itemStack.getItemDamage() > 0;
}
protected int toggleLitStatus(int meta) {
return meta ^ 0x08;
}
public static void addItemToLightingList(Item item) {
if (item == null) {
throw new NullPointerException();
}
public void addItemToLightingList(Item item) {
if (item == null) throw new NullPointerException();
if (!this.lightingItems.contains(item)) {
this.lightingItems.add(item);
if (!lightingItems.contains(item)) {
lightingItems.add(item);
}
}
@@ -4,22 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
import java.util.List;
import java.util.Random;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -30,6 +23,16 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
public class BlockStump extends BlockTorch {
public BlockStump() {
@@ -45,7 +48,7 @@ public class BlockStump extends BlockTorch {
this.blockIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanBlockName(this));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
@@ -57,8 +60,8 @@ public class BlockStump extends BlockTorch {
ItemStack held = player.getCurrentEquippedItem();
if (held != null &&
(held.getItem() == Items.flint_and_steel ||
held.getItem() == Items.flint ||
StackUtils.equals(Blocks.torch, held))) {
held.getItem() == Items.flint ||
StackUtils.equals(Blocks.torch, held))) {
world.setBlock(x, y, z, ForestryBlock.candle.block(), world.getBlockMetadata(x, y, z) | 0x08, Defaults.FLAG_BLOCK_SYNCH);
TileCandle tc = new TileCandle();
tc.setColour(0); // default to white
+84 -50
View File
@@ -4,45 +4,52 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.core.ITileStructure;
import forestry.core.config.ForestryBlock;
import forestry.core.gadgets.BlockStructure.EnumStructureState;
import forestry.core.gadgets.StructureLogic;
import forestry.core.utils.Schemata;
import forestry.core.utils.Schemata.EnumStructureBlock;
import forestry.core.vect.Vect;
import java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
public class StructureLogicAlveary extends StructureLogic {
/* CONSTANTS */
public static final String UID_ALVEARY = "alveary";
public static final Schemata SCHEMATA_ALVEARY = new Schemata("alveary3x3", 5, 6, 5, "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FAAAF",
"FAAAF", "FABAF", "FCCCF", "FFFFF", "FFFFF", "FAAAF", "FAAAF", "FBMBF", "FCCCF", "FFFFF", "FFFFF", "FAAAF", "FAAAF", "FABAF", "FCCCF", "FFFFF",
public static final Schemata SCHEMATA_ALVEARY = new Schemata("alveary3x3", 5, 6, 5,
"FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF",
"FFFFF", "FAAAF", "FAAAF", "FABAF", "FCCCF", "FFFFF",
"FFFFF", "FAAAF", "FAAAF", "FBMBF", "FCCCF", "FFFFF",
"FFFFF", "FAAAF", "FAAAF", "FABAF", "FCCCF", "FFFFF",
"FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-2, -3, -2);
public static final HashSet<Block> slabBlocks = new HashSet<Block>();
private static final Set<Block> slabBlocks = new HashSet<Block>();
private static final Set<Integer> slabOreDictIds = new HashSet<Integer>();
static {
slabBlocks.add(Blocks.wooden_slab);
slabBlocks.add(ForestryBlock.slabs1.block());
slabBlocks.add(ForestryBlock.slabs2.block());
slabBlocks.add(ForestryBlock.slabs3.block());
slabBlocks.add(ForestryBlock.slabs4.block());
int slabWoodId = OreDictionary.getOreID("slabWood");
slabOreDictIds.add(slabWoodId);
}
public StructureLogicAlveary(ITileStructure structure) {
super(UID_ALVEARY, structure);
schematas = new Schemata[] { SCHEMATA_ALVEARY };
schematas = new Schemata[]{SCHEMATA_ALVEARY};
metaOnValid.put(EnumStructureBlock.BLOCK_B, 1);
}
@@ -57,59 +64,86 @@ public class StructureLogicAlveary extends StructureLogic {
offsetZ = schemata.getxOffset();
}
for (int i = 0; i < dimensions.x; i++)
for (int j = 0; j < schemata.getHeight(); j++)
for (int i = 0; i < dimensions.x; i++) {
for (int j = 0; j < schemata.getHeight(); j++) {
for (int k = 0; k < dimensions.z; k++) {
int x = structureTile.xCoord + i + offsetX;
int y = structureTile.yCoord + j + schemata.getyOffset();
int z = structureTile.zCoord + k + offsetZ;
if (!structureTile.getWorldObj().blockExists(x, y, z))
if (!structureTile.getWorldObj().blockExists(x, y, z)) {
return EnumStructureState.INDETERMINATE;
}
EnumStructureBlock required = schemata.getAt(i, j, k, rotate);
if (required == EnumStructureBlock.ANY)
if (required == EnumStructureBlock.ANY) {
continue;
}
TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z);
Block block = structureTile.getWorldObj().getBlock(x, y, z);
switch (required) {
case AIR:
if (!block.isAir(structureTile.getWorldObj(), x, y, z))
return EnumStructureState.INVALID;
break;
case BLOCK_A:
if (tile == null || !(tile instanceof IAlvearyComponent))
return EnumStructureState.INVALID;
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY))
return EnumStructureState.INVALID;
break;
case MASTER:
case BLOCK_B:
if (tile == null || !(tile instanceof TileAlvearyPlain))
return EnumStructureState.INVALID;
break;
case BLOCK_C:
if (!slabBlocks.contains(block))
return EnumStructureState.INVALID;
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0)
return EnumStructureState.INVALID;
break;
case BLOCK_D:
if (block != Blocks.spruce_stairs)
return EnumStructureState.INVALID;
break;
case FOREIGN:
if (tile instanceof ITileStructure)
return EnumStructureState.INVALID;
break;
default:
return EnumStructureState.INDETERMINATE;
case AIR:
if (!block.isAir(structureTile.getWorldObj(), x, y, z)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_A:
if (tile == null || !(tile instanceof IAlvearyComponent)) {
return EnumStructureState.INVALID;
}
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY)) {
return EnumStructureState.INVALID;
}
break;
case MASTER:
case BLOCK_B:
if (tile == null || !(tile instanceof TileAlvearyPlain)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_C:
if (!isWoodSlabBlock(block)) {
return EnumStructureState.INVALID;
}
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_D:
if (block != Blocks.spruce_stairs) {
return EnumStructureState.INVALID;
}
break;
case FOREIGN:
if (tile instanceof ITileStructure) {
return EnumStructureState.INVALID;
}
break;
default:
return EnumStructureState.INDETERMINATE;
}
}
}
}
return EnumStructureState.VALID;
}
private static boolean isWoodSlabBlock(Block block) {
int[] oreIds = OreDictionary.getOreIDs(new ItemStack(block));
for (int oreId : oreIds) {
if (slabOreDictIds.contains(oreId)) {
return true;
}
}
return slabBlocks.contains(block);
}
public static void addSlabBlock(Block block) {
slabBlocks.add(block);
}
}
@@ -4,12 +4,13 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
@@ -31,8 +32,8 @@ import forestry.core.config.ForestryBlock;
import forestry.core.gadgets.TileForestry;
import forestry.core.inventory.FakeInventoryAdapter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.PacketPayload;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import buildcraft.api.statements.ITriggerExternal;
@@ -61,28 +62,11 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
}
}
@Override
public void updateEntity() {
if (!Proxies.common.isSimulating(worldObj))
updateClientSide();
else {
if (!isInited) {
initialize();
isInited = true;
}
// Periodic validation if needed
if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster()))
validateStructure();
updateServerSide();
}
}
protected void updateServerSide() {
}
protected void updateClientSide() {
// Periodic validation if needed
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
validateStructure();
}
}
/* TEXTURES */
@@ -99,8 +83,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
this.masterZ = nbttagcompound.getInteger("MasterZ");
// Init for master state
if (isMaster)
makeMaster();
if (isMaster) {
makeMaster();
}
super.readFromNBT(nbttagcompound);
@@ -123,23 +108,23 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 2);
payload.shortPayload[0] = (short) (isMaster() ? 1 : 0);
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(isMaster);
// so the client can know if it is part of an integrated structure
payload.shortPayload[1] = (short) this.masterY;
return payload;
data.writeVarInt(masterY);
}
@Override
public void fromPacketPayload(PacketPayload payload) {
if (payload.shortPayload[0] > 0)
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
if (data.readBoolean()) {
makeMaster();
}
// so the client can know if it is part of an integrated structure
this.masterY = payload.shortPayload[1];
masterY = data.readVarInt();
}
/* ITILESTRUCTURE */
@@ -158,15 +143,21 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
setCentralTE(null);
isMaster = true;
if (getInternalInventory() instanceof FakeInventoryAdapter)
if (getInternalInventory() instanceof FakeInventoryAdapter) {
createInventory();
}
if (worldObj != null && !worldObj.isRemote) {
setNeedsNetworkUpdate();
}
}
@Override
public void onStructureReset() {
setCentralTE(null);
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1)
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 0);
}
isMaster = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@@ -174,21 +165,25 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
@Override
public ITileStructure getCentralTE() {
if (!isIntegratedIntoStructure())
if (!isIntegratedIntoStructure()) {
return null;
}
if (!isMaster()) {
TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ);
if (tile instanceof ITileStructure) {
ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ);
if (master.isMaster())
if (master.isMaster()) {
return master;
else
} else {
return null;
} else
}
} else {
return null;
} else
}
} else {
return this;
}
}
@@ -224,11 +219,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
return isMaster || masterY >= 0;
}
@Override
public final IInventoryAdapter getInventory() {
return getStructureInventory();
}
@Override
public IInventoryAdapter getStructureInventory() {
return getInternalInventory();
@@ -4,21 +4,29 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cofh.api.energy.IEnergyHandler;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.core.network.PacketPayload;
import forestry.energy.EnergyManager;
import net.minecraft.entity.player.EntityPlayer;
import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
import forestry.api.apiculture.IAlvearyComponent;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.core.interfaces.IActivatable;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import forestry.energy.EnergyManager;
import cofh.api.energy.IEnergyHandler;
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler, IActivatable {
public static class ClimateControl {
@@ -32,12 +40,16 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.boundaryUp = boundaryUp;
}
}
protected final EnergyManager energyManager;
private final ClimateControl climateControl;
private int workingTime = 0;
private final int textureOff;
private final int textureOn;
// CLIENT
private boolean active;
public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) {
super(componentBlockMeta);
this.climateControl = control;
@@ -47,19 +59,14 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.textureOn = textureOn;
}
@Override
public void openGui(EntityPlayer player) {
}
/* UPDATING */
@Override
protected void updateServerSide() {
super.updateServerSide();
if (!this.hasMaster())
if (!this.hasMaster()) {
return;
boolean wasInactive = (workingTime == 0);
}
if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
// consume 10 RF per tick of work
@@ -69,13 +76,12 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
if (workingTime > 0) {
workingTime--;
IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
if (component != null)
if (component != null) {
component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp);
}
}
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
sendNetworkUpdate();
}
setActive(workingTime > 0);
}
@Override
@@ -86,10 +92,11 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if (workingTime > 0)
if (active) {
return textureOn;
else
} else {
return textureOff;
}
}
/* LOADING & SAVING */
@@ -98,6 +105,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
super.readFromNBT(nbttagcompound);
energyManager.readFromNBT(nbttagcompound);
workingTime = nbttagcompound.getInteger("Heating");
setActive(workingTime > 0);
}
@Override
@@ -107,22 +115,39 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
nbttagcompound.setInteger("Heating", workingTime);
}
/* NETWORK */
@Override
public void fromPacketPayload(PacketPayload payload) {
short workingTime = payload.shortPayload[0];
if (this.workingTime != workingTime) {
this.workingTime = workingTime;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
payload.shortPayload[0] = (short) workingTime;
return payload;
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
setActive(data.readBoolean());
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.func_147479_m(xCoord, yCoord, zCoord);
} else {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
}
/* IEnergyHandler */
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -69,16 +69,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
public TileAlvearyHygroregulator() {
super(BLOCK_META);
setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_INPUT) {
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
return liquidTank.accepts(fluid);
}
return false;
}
});
setInternalInventory(new HygroInventoryAdapter(this));
Fluid water = Fluids.WATER.getFluid();
Fluid lava = Fluids.LAVA.getFluid();
@@ -88,8 +79,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
tankManager = new TankManager(liquidTank);
recipes = new HygroregulatorRecipe[]{new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f)};
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f)};
}
@Override
@@ -131,19 +122,19 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
component.addHumidityChange(currentRecipe.humidChange, 0.0f, 1.0f);
component.addTemperatureChange(currentRecipe.tempChange, 0.0f, 2.0f);
}
} else
} else {
transferTime = 0;
}
}
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
return;
IInventoryAdapter canInventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null)
FluidHelper.drainContainers(tankManager, canInventory, 0);
if (updateOnInterval(20)) {
IInventoryAdapter canInventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null) {
FluidHelper.drainContainers(tankManager, canInventory, 0);
}
}
}
@Override
@@ -228,4 +219,19 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
@Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
}
private static class HygroInventoryAdapter extends TileInventoryAdapter<TileAlvearyHygroregulator> {
public HygroInventoryAdapter(TileAlvearyHygroregulator alvearyHygroregulator) {
super(alvearyHygroregulator, 1, "CanInv");
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_INPUT) {
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
return tile.liquidTank.accepts(fluid);
}
return false;
}
}
}
@@ -4,18 +4,18 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -24,6 +24,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
@@ -38,29 +39,28 @@ import forestry.api.core.IErrorState;
import forestry.api.core.ITileStructure;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.gui.ContainerAlveary;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.interfaces.IActivatable;
import forestry.core.interfaces.IClimatised;
import forestry.core.interfaces.IErrorSource;
import forestry.core.interfaces.IHintSource;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketInventoryStack;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource {
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource, IActivatable {
// / CONSTANTS
public static final int SLOT_QUEEN = 0;
public static final int SLOT_DRONE = 1;
public static final int SLOT_PRODUCT_1 = 2;
public static final int SLOT_PRODUCTION_COUNT = 7;
public static final int SLOT_PRODUCT_COUNT = 7;
public static final int BLOCK_META = 0;
// / MEMBERS
@@ -68,8 +68,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
protected BiomeGenBase biome;
protected float tempChange = 0.0f;
protected float humidChange = 0.0f;
// CLIENT
private boolean active;
private int displayHealthMax = 0;
private int displayHealth = 0;
private IBee displayQueen;
public TileAlvearyPlain() {
super(0);
@@ -77,10 +81,11 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public void openGui(EntityPlayer player) {
if (isMaster())
if (isMaster()) {
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
else if (this.hasMaster())
} else if (this.hasMaster()) {
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ);
}
}
@Override
@@ -90,8 +95,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
private void setBiomeInformation() {
this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
setErrorState(EnumErrorCode.OK);
this.biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
}
/* LOADING & SAVING */
@@ -102,9 +106,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
this.tempChange = nbttagcompound.getFloat("TempChange");
this.humidChange = nbttagcompound.getFloat("HumidChange");
if (beekeepingLogic != null)
if (beekeepingLogic != null) {
beekeepingLogic.readFromNBT(nbttagcompound);
}
}
@Override
@@ -114,9 +118,46 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
nbttagcompound.setFloat("TempChange", tempChange);
nbttagcompound.setFloat("HumidChange", humidChange);
if (beekeepingLogic != null)
if (beekeepingLogic != null) {
beekeepingLogic.writeToNBT(nbttagcompound);
}
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
if (active) {
ItemStack queen = getStackInSlot(SLOT_QUEEN);
data.writeItemStack(queen);
}
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
active = data.readBoolean();
if (active) {
ItemStack queen = data.readItemStack();
setInventorySlotContents(SLOT_QUEEN, queen);
}
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
/* UPDATING */
@@ -128,115 +169,97 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
protected void updateServerSide() {
super.updateServerSide();
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
return;
if (!isMaster())
}
if (!isMaster()) {
return;
}
beekeepingLogic.update();
boolean canWork = beekeepingLogic.canWork();
setActive(canWork);
if (canWork) {
beekeepingLogic.doWork();
}
// Equalize humidity and temperature
equalizeTemperature();
equalizeHumidity();
IBee queen = beekeepingLogic.getQueen();
if (queen == null)
return;
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 == 0) {
ISidedInventory inventory = getStructureInventory();
if (inventory != null)
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
}
if (getErrorState() == EnumErrorCode.OK)
queen.doFX(beekeepingLogic.getEffectData(), this);
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
float f = xCoord + 0.5F;
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
float f2 = zCoord + 0.5F;
float f3 = 0.52F;
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
}
}
@Override
protected void updateClientSide() {
if (isMaster() && active && (displayQueen != null) && updateOnInterval(2)) {
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
if (!isMaster())
return;
if (updateOnInterval(50)) {
float fxX = xCoord + 0.5F;
float fxY = yCoord + 0.25F + (worldObj.rand.nextFloat() * 6F) / 16F;
float fxZ = zCoord + 0.5F;
float f3 = 1.6F;
float f4 = worldObj.rand.nextFloat() * f3 - 0.5F;
ISidedInventory inventory = getStructureInventory();
if (inventory == null)
return;
// / Multiplayer FX
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
if (PluginApiculture.beeInterface.isMated(queenStack)) {
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack);
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
Proxies.common.addEntitySwarmFX(worldObj, (fxX - f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ + f3), 0F, 0F, 0F);
}
}
}
private void equalizeTemperature() {
if (tempChange == 0)
if (tempChange == 0) {
return;
}
tempChange -= 0.05f * tempChange;
if (tempChange <= 0.001f && tempChange >= -0.001f)
if (tempChange <= 0.001f && tempChange >= -0.001f) {
tempChange = 0;
}
}
private void equalizeHumidity() {
if (humidChange == 0)
if (humidChange == 0) {
return;
}
humidChange -= 0.05f * humidChange;
if (humidChange <= 0.001f && humidChange >= 0.001f)
if (humidChange <= 0.001f && humidChange >= 0.001f) {
humidChange = 0;
}
}
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
if (displayQueen == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
if (displayQueen.getMate() != null) {
return displayQueen.getHealth();
} else {
return displayHealth;
else
return 0;
}
}
private int getMaxHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
if (displayQueen == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
if (displayQueen.getMate() != null) {
return displayQueen.getMaxHealth();
} else {
return displayHealthMax;
else
return 0;
}
}
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0)
if (getMaxHealthDisplay() == 0) {
return 0;
}
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
@@ -244,28 +267,15 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
/* STRUCTURE MANAGMENT */
@Override
protected void createInventory() {
setInternalInventory(new TileInventoryAdapter(this, 9, "Items") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack);
} else if (slotIndex == SLOT_DRONE) {
return PluginApiculture.beeInterface.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
}
});
setInternalInventory(new AlvearyInventoryAdapter(this));
}
@Override
public void makeMaster() {
super.makeMaster();
if (beekeepingLogic == null)
this.beekeepingLogic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
if (beekeepingLogic == null) {
this.beekeepingLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
}
}
@Override
@@ -273,6 +283,8 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
super.onStructureReset();
modifiers.clear();
eventHandlers.clear();
setActive(false);
}
/* IALVEARYCOMPONENT */
@@ -301,7 +313,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
float temperature = biome.temperature;
float temperature = biome.getFloatTemperature(xCoord, yCoord, zCoord);
tempChange = Math.min(boundaryUp - temperature, Math.max(boundaryDown - temperature, tempChange + change));
}
@@ -343,13 +355,35 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
@Override
public void setDrone(ItemStack itemstack) {
setInventorySlotContents(SLOT_DRONE, itemstack);
public ItemStack decrStackSize(int slotIndex, int amount) {
ItemStack itemStack = super.decrStackSize(slotIndex, amount);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
return itemStack;
}
@Override
public int getBiomeId() {
return biome.biomeID;
public void setInventorySlotContents(int slotIndex, ItemStack itemStack) {
super.setInventorySlotContents(slotIndex, itemStack);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
}
private void handleQueenChange() {
if (!Proxies.common.isSimulating(worldObj)) {
TileAlvearyPlain master = (TileAlvearyPlain) getCentralTE();
if (master != null) {
ItemStack itemStack = getStackInSlot(SLOT_QUEEN);
master.displayQueen = BeeManager.beeRoot.getMember(itemStack);
}
}
}
@Override
public void setDrone(ItemStack itemstack) {
setInventorySlotContents(SLOT_DRONE, itemstack);
}
@Override
@@ -359,8 +393,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public EnumTemperature getTemperature() {
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0)
if (isHellish() && tempChange >= 0) {
return EnumTemperature.HELLISH;
}
return EnumTemperature.getFromValue(getExactTemperature());
}
@@ -429,16 +464,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return worldObj;
}
@Override
public void setErrorState(int state) {
setErrorState(EnumErrorCode.values()[state]);
}
@Override
public int getErrorOrdinal() {
return getErrorState().getID();
}
@Override
public boolean canBreed() {
return true;
@@ -447,10 +472,20 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean addProduct(ItemStack product, boolean all) {
IInventoryAdapter inventory = getStructureInventory();
if (inventory == null)
if (inventory == null) {
return false;
}
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all);
}
@Deprecated
@Override
public void setErrorState(IErrorState state) {
removeErrorStates();
if (state != EnumErrorCode.OK) {
addErrorState(state);
}
}
@Override
@@ -462,11 +497,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public void onQueenChange(ItemStack queenStack) {
if (!Proxies.common.isSimulating(worldObj))
if (!Proxies.common.isSimulating(worldObj)) {
return;
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
}
for (IBeeListener eventHandler : eventHandlers) {
eventHandler.onQueenChange(queenStack);
@@ -491,8 +524,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
for (IBeeListener eventHandler : eventHandlers) {
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled))
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled)) {
isHandled = true;
}
}
return isHandled;
@@ -501,8 +535,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean onEggLaid(IBee queen) {
for (IBeeListener eventHandler : eventHandlers) {
if (eventHandler.onEggLaid(queen))
if (eventHandler.onEggLaid(queen)) {
return true;
}
}
return false;
@@ -511,8 +546,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isSealed() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSealed())
if (modifier.isSealed()) {
return true;
}
}
return false;
}
@@ -520,8 +556,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isSelfLighted() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSelfLighted())
if (modifier.isSelfLighted()) {
return true;
}
}
return false;
}
@@ -529,17 +566,23 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isSunlightSimulated() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSunlightSimulated())
if (modifier.isSunlightSimulated()) {
return true;
}
}
return false;
}
@Override
public boolean isHellish() {
if (BiomeHelper.isBiomeHellish(biome)) {
return true;
}
for (IBeeModifier modifier : modifiers) {
if (modifier.isHellish())
if (modifier.isHellish()) {
return true;
}
}
return false;
}
@@ -552,8 +595,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return inventory;
} else if (hasMaster()) {
ITileStructure central = getCentralTE();
if (central instanceof TileAlveary)
if (central instanceof TileAlveary) {
return ((TileAlveary) central).getInternalInventory();
}
}
return inventory;
}
@@ -561,29 +605,30 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
/* SMP GUI */
public void getGUINetworkData(int i, int j) {
switch (i) {
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
case 4:
this.tempChange = (float) j / 100;
break;
case 5:
this.humidChange = (float) j / 100;
break;
case 6: {
this.biome = BiomeGenBase.getBiome(j);
break;
}
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
case 4:
this.tempChange = (float) j / 100;
break;
case 5:
this.humidChange = (float) j / 100;
break;
case 6: {
this.biome = BiomeGenBase.getBiome(j);
break;
}
}
}
public void sendGUINetworkData(ContainerAlveary container, ICrafting iCrafting) {
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
return;
}
iCrafting.sendProgressBarUpdate(container, 0, beekeepingLogic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, beekeepingLogic.getTotalBreedingTime());
@@ -593,15 +638,26 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
/* IERRORSOURCE */
@Deprecated
@Override
public IErrorState getErrorState() {
Set<IErrorState> errorStates = null;
if (hasMaster()) {
ITileStructure tile = this.getCentralTE();
if (tile != null)
return ((IErrorSource) tile).getErrorState();
ITileStructure tile = getCentralTE();
if (tile != null) {
errorStates = ((IErrorSource) tile).getErrorStates();
}
}
return errorState;
if (errorStates == null) {
errorStates = this.getErrorStates();
}
if (errorStates.size() == 0) {
return EnumErrorCode.OK;
} else {
return getErrorStates().iterator().next();
}
}
/* ICLIMATISED */
@@ -612,7 +668,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public float getExactTemperature() {
return biome.temperature + this.tempChange;
return biome.getFloatTemperature(xCoord, yCoord, zCoord) + this.tempChange;
}
@Override
@@ -631,15 +687,30 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return Config.hints.get("alveary");
}
/* IOWNABLE */
@Override
public boolean isOwnable() {
return true;
}
/* IHousing */
@Override
public GameProfile getOwnerName() {
return this.getOwnerProfile();
return this.getOwner();
}
private static class AlvearyInventoryAdapter extends TileInventoryAdapter<TileAlvearyPlain> {
public AlvearyInventoryAdapter(TileAlvearyPlain tileAlvearyPlain) {
super(tileAlvearyPlain, 9, "Items");
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
} else if (slotIndex == SLOT_DRONE) {
return BeeManager.beeRoot.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
}
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -25,6 +25,7 @@ import forestry.core.interfaces.ICrafter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener {
@@ -38,12 +39,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public TileAlvearySieve() {
super(BLOCK_META);
setInternalInventory(new TileInventoryAdapter(this, 5, "Items", 1) {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack);
}
});
setInternalInventory(new AlvearySieveInventoryAdapter(this));
}
@Override
@@ -61,29 +57,33 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public void initialize() {
super.initialize();
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
}
@Override
protected void updateServerSide() {
super.updateServerSide();
if(worldObj.getTotalWorldTime() % 200 != 0)
if (!updateOnInterval(200)) {
return;
}
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
}
/* TEXTURES & INTERNAL */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.SIEVE;
}
@@ -94,19 +94,21 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
private void destroyPollen() {
IInventoryAdapter inventory = getInternalInventory();
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
inventory.setInventorySlotContents(i, null);
}
}
private boolean canStorePollen() {
IInventoryAdapter inventory = getInternalInventory();
if(inventory.getStackInSlot(SLOT_SIEVE) == null)
if (inventory.getStackInSlot(SLOT_SIEVE) == null) {
return false;
}
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if(inventory.getStackInSlot(i) == null)
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if (inventory.getStackInSlot(i) == null) {
return true;
}
}
return false;
@@ -114,8 +116,8 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
private void storePollenStack(ItemStack itemstack) {
IInventoryAdapter inventory = getInternalInventory();
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if(inventory.getStackInSlot(i) == null) {
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if (inventory.getStackInSlot(i) == null) {
inventory.setInventorySlotContents(i, itemstack);
return;
}
@@ -129,9 +131,9 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
}
@Override
public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) {
public ItemStack takenFromSlot(int slotIndex, EntityPlayer player) {
IInventoryAdapter inventory = getInternalInventory();
if(slotIndex == SLOT_SIEVE) {
if (slotIndex == SLOT_SIEVE) {
destroyPollen();
return inventory.getStackInSlot(SLOT_SIEVE);
} else {
@@ -146,18 +148,31 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
}
/* IBEELISTENER */
@Override public void onQueenChange(ItemStack queen) {}
@Override public void wearOutEquipment(int amount) {}
@Override public void onQueenDeath(IBee queen) {}
@Override public void onPostQueenDeath(IBee queen) {}
@Override
public void onQueenChange(ItemStack queen) {
}
@Override
public void wearOutEquipment(int amount) {
}
@Override
public void onQueenDeath(IBee queen) {
}
@Override
public void onPostQueenDeath(IBee queen) {
}
@Override
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
if(isHandled)
if (isHandled) {
return true;
if(!canStorePollen())
}
if (!canStorePollen()) {
return false;
}
storePollenStack(AlleleManager.alleleRegistry.getSpeciesRoot(pollen.getClass()).getMemberStack(pollen, EnumGermlingType.POLLEN.ordinal()));
return true;
@@ -167,4 +182,15 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public boolean onEggLaid(IBee queen) {
return false;
}
private static class AlvearySieveInventoryAdapter extends TileInventoryAdapter<TileAlvearySieve> {
public AlvearySieveInventoryAdapter(TileAlvearySieve alvearySieve) {
super(alvearySieve, 5, "Items", 1);
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack);
}
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -13,6 +13,7 @@ package forestry.apiculture.gadgets;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeModifier;
import forestry.core.proxy.Proxies;
public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
@@ -27,23 +28,26 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
public void initialize() {
super.initialize();
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
}
@Override
protected void updateServerSide() {
super.updateServerSide();
if(worldObj.getTotalWorldTime() % 200 != 0)
if (!updateOnInterval(200)) {
return;
}
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
}
@@ -55,8 +59,9 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.STABILISER;
}
@@ -4,12 +4,13 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.Map.Entry;
import java.util.Stack;
@@ -25,33 +26,31 @@ import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.ForestryAPI;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.apiculture.worldgen.Hive;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveDescriptionSwarmer;
import forestry.core.interfaces.IActivatable;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.inventory.wrappers.IInvSlot;
import forestry.core.inventory.wrappers.InventoryIterator;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.network.PacketPayload;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable {
/* CONSTANTS */
public static final int BLOCK_META = 2;
private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>();
private boolean isActive;
private boolean active;
public TileAlvearySwarmer() {
super(BLOCK_META);
setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
}
});
setInternalInventory(new SwarmerInventoryAdapter(this));
}
@Override
@@ -65,52 +64,62 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
super.updateServerSide();
if (pendingSpawns.size() > 0) {
setIsActive(true);
if (worldObj.getTotalWorldTime() % 1000 == 0)
setActive(true);
if (updateOnInterval(1000)) {
trySpawnSwarm();
} else
setIsActive(false);
}
} else {
setActive(false);
}
if (worldObj.getTotalWorldTime() % 500 != 0)
if (!updateOnInterval(500)) {
return;
}
ItemStack princessStack = getPrincessStack();
if (princessStack == null)
if (princessStack == null) {
return;
}
int chance = consumeInducerAndGetChance();
if (chance == 0)
if (chance == 0) {
return;
}
// Try to spawn princess
if (worldObj.rand.nextInt(1000) >= chance)
if (worldObj.rand.nextInt(1000) >= chance) {
return;
}
// Queue swarm spawn
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
IBee princess = BeeManager.beeRoot.getMember(princessStack);
princess.setIsNatural(false);
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
pendingSpawns.push(BeeManager.beeRoot.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
}
private ItemStack getPrincessStack() {
if (!this.hasMaster())
if (!this.hasMaster()) {
return null;
}
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
if (!(master instanceof IBeeHousing))
if (!(master instanceof IBeeHousing)) {
return null;
}
IBeeHousing housing = (IBeeHousing) master;
ItemStack princessStack = housing.getQueen();
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack))
if (princessStack == null || !BeeManager.beeRoot.isMated(princessStack)) {
return null;
}
return princessStack;
}
private int consumeInducerAndGetChance() {
if (getInternalInventory() == null)
if (getInternalInventory() == null) {
return 0;
}
for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) {
ItemStack stack = slot.getStackInSlot();
@@ -134,32 +143,27 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive))
if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) {
pendingSpawns.pop();
}
private void setIsActive(boolean isActive) {
if (this.isActive != isActive) {
this.isActive = isActive;
sendNetworkUpdate();
}
}
/* NETWORK */
@Override
public void fromPacketPayload(PacketPayload payload) {
boolean act = payload.shortPayload[0] > 0;
if (this.isActive != act) {
this.isActive = act;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
payload.shortPayload[0] = (short) (isActive ? 1 : 0);
return payload;
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
boolean active = data.readBoolean();
if (this.active != active) {
this.active = active;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
@Override
@@ -170,13 +174,15 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if (side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
if (isActive)
if (active) {
return BlockAlveary.ALVEARY_SWARMER_ON;
else
} else {
return BlockAlveary.ALVEARY_SWARMER_OFF;
}
}
/* SAVING & LOADING */
@@ -209,4 +215,33 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
nbttagcompound.setTag("PendingSpawns", nbttaglist);
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
private static class SwarmerInventoryAdapter extends TileInventoryAdapter<TileAlvearySwarmer> {
public SwarmerInventoryAdapter(TileAlvearySwarmer alvearySwarmer) {
super(alvearySwarmer, 4, "SwarmInv");
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
}
}
}
@@ -4,21 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import forestry.api.genetics.AlleleManager;
import forestry.apiculture.genetics.BeeHelper;
import forestry.api.apiculture.BeeManager;
import forestry.core.gadgets.TileNaturalistChest;
import forestry.core.network.GuiId;
public class TileApiaristChest extends TileNaturalistChest {
public TileApiaristChest() {
super(AlleleManager.alleleRegistry.getSpeciesRoot(BeeHelper.UID), GuiId.ApiaristChestGUI.ordinal());
super(BeeManager.beeRoot, GuiId.ApiaristChestGUI.ordinal());
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -20,6 +20,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.ForestryAPI;
@@ -27,7 +28,6 @@ import forestry.apiculture.trigger.ApicultureTriggers;
import forestry.core.gadgets.TileBase;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.network.GuiId;
import forestry.plugins.PluginApiculture;
import buildcraft.api.statements.ITriggerExternal;
@@ -48,10 +48,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1.0f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getTerritoryModifier(genome, mod);
}
}
return mod;
}
@@ -61,10 +63,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 0.1f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getProductionModifier(genome, mod);
}
}
return mod;
}
@@ -74,10 +78,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1.0f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getMutationModifier(genome, mate, mod);
}
}
return mod;
}
@@ -87,10 +93,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1.0f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getLifespanModifier(genome, mate, mod);
}
}
return mod;
}
@@ -100,10 +108,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getFloweringModifier(genome, mod);
}
}
return mod;
}
@@ -113,10 +123,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getGeneticDecay(genome, mod);
}
}
return mod;
}
@@ -124,18 +136,20 @@ public class TileApiary extends TileBeehouse {
@Override
public void wearOutEquipment(int amount) {
IInventoryAdapter inventory = getInternalInventory();
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
int wear = Math.round(amount * BeeManager.beeRoot.getBeekeepingMode(worldObj).getWearModifier());
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame))
}
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)) {
continue;
}
inventory.setInventorySlotContents(
i,
((IHiveFrame) inventory.getStackInSlot(i).getItem()).frameUsed(this, inventory.getStackInSlot(i),
PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)), wear));
BeeManager.beeRoot.getMember(inventory.getStackInSlot(SLOT_QUEEN)), wear));
}
}
@@ -4,12 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -20,6 +23,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
@@ -28,67 +32,43 @@ import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.ForestryItem;
import forestry.core.gadgets.TileBase;
import forestry.core.gadgets.TileForestry;
import forestry.core.interfaces.IActivatable;
import forestry.core.interfaces.IClimatised;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketInventoryStack;
import forestry.core.network.PacketTileUpdate;
import forestry.core.proxy.Proxies;
import forestry.core.utils.GuiUtil;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
protected static class BeehouseInventoryAdapter extends TileInventoryAdapter {
public BeehouseInventoryAdapter(TileForestry tile, int size, String name) {
super(tile, size, name);
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack);
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
return itemStack.getItem() instanceof IHiveFrame;
} else if (slotIndex == SLOT_DRONE) {
return PluginApiculture.beeInterface.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
}
}
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, IActivatable {
// CONSTANTS
public static final int SLOT_QUEEN = 0;
public static final int SLOT_DRONE = 1;
public static final int SLOT_PRODUCT_1 = 2;
public static final int SLOT_PRODUCT_COUNT = 7;
public static final int SLOT_FRAMES_1 = 9;
public static final int SLOT_FRAMES_2 = 10;
public static final int SLOT_FRAMES_3 = 11;
public static final int SLOT_FRAMES_COUNT = 3;
private final IBeekeepingLogic logic;
private BiomeGenBase biome;
// CLIENT
private boolean active;
private int displayHealthMax = 0;
private int displayHealth = 0;
private IBee displayQueen;
public TileBeehouse() {
setHints(Config.hints.get("apiary"));
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
logic = BeeManager.beeRoot.createBeekeepingLogic(this);
setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items").disableAutomation());
}
@@ -103,8 +83,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
super.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("BiomeId", biome.biomeID);
if (logic != null)
if (logic != null) {
logic.writeToNBT(nbttagcompound);
}
}
@Override
@@ -114,7 +95,26 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
int biomeId = nbttagcompound.getInteger("BiomeId");
biome = BiomeGenBase.getBiome(biomeId);
logic.readFromNBT(nbttagcompound);
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
if (active) {
ItemStack queen = getStackInSlot(SLOT_QUEEN);
data.writeItemStack(queen);
}
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
active = data.readBoolean();
if (active) {
ItemStack queen = data.readItemStack();
setInventorySlotContents(SLOT_QUEEN, queen);
}
}
@Override
@@ -136,7 +136,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public EnumTemperature getTemperature() {
return EnumTemperature.getFromBiome(biome);
return EnumTemperature.getFromBiome(biome, xCoord, yCoord, zCoord);
}
@Override
@@ -144,9 +144,29 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
return EnumHumidity.getFromValue(getExactHumidity());
}
@Deprecated
@Override
public void setErrorState(IErrorState state) {
removeErrorStates();
if (state != EnumErrorCode.OK) {
addErrorState(state);
}
}
@Deprecated
@Override
public IErrorState getErrorState() {
Set<IErrorState> errorStates = getErrorStates();
if (errorStates.size() == 0) {
return EnumErrorCode.OK;
} else {
return getErrorStates().iterator().next();
}
}
@Override
public float getExactTemperature() {
return biome.temperature;
return biome.getFloatTemperature(xCoord, yCoord, zCoord);
}
@Override
@@ -157,50 +177,36 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* UPDATING */
@Override
public void updateClientSide() {
if (isActive() && (displayQueen != null) && updateOnInterval(4)) {
displayQueen.doFX(logic.getEffectData(), this);
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN)))
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
displayQueen.doFX(logic.getEffectData(), this);
if (updateOnInterval(50)) {
float fxX = xCoord + 0.5F;
float fxY = yCoord + 0.25F + (worldObj.rand.nextFloat() * 6F) / 16F;
float fxZ = zCoord + 0.5F;
float f3 = 0.6F;
float f4 = worldObj.rand.nextFloat() * f3 - 0.5F;
Proxies.common.addEntitySwarmFX(worldObj, (fxX - f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ + f3), 0F, 0F, 0F);
}
}
}
@Override
public void updateServerSide() {
logic.update();
IBee queen = logic.getQueen();
if (queen == null)
return;
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN));
/* These should get already done on the client / doesn't work server-side anyway
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0)
queen.doFX(logic.getEffectData(), this);
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
float f = xCoord + 0.5F;
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
float f2 = zCoord + 0.5F;
float f3 = 0.52F;
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
}*/
boolean canWork = logic.canWork();
setActive(canWork);
if (canWork) {
logic.doWork();
}
}
// @Override
public boolean isWorking() {
return getErrorState() == EnumErrorCode.OK;
return !hasErrorState();
}
@Override
@@ -211,65 +217,49 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* NETWORK SYNCH */
@Override
public void onQueenChange(ItemStack queenStack) {
if (!Proxies.common.isSimulating(worldObj))
return;
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
Proxies.net.sendNetworkPacket(new PacketTileUpdate(this), xCoord, yCoord, zCoord);
}
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
if (displayQueen == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
if (displayQueen.getMate() != null) {
return displayQueen.getHealth();
} else {
return displayHealth;
else
return 0;
}
}
private int getMaxHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
if (displayQueen == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
if (displayQueen.getMate() != null) {
return displayQueen.getMaxHealth();
} else {
return displayHealthMax;
else
return 0;
}
}
/**
* Returns scaled queen health or breeding progress
*/
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0)
if (getMaxHealthDisplay() == 0) {
return 0;
}
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
public int getTemperatureScaled(int i) {
return Math.round(i * (getExactTemperature() / 2));
}
public int getHumidityScaled(int i) {
return Math.round(i * getExactHumidity());
}
public void updateBiome() {
if (worldObj != null) {
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
if (biome != null) {
this.biome = biome;
setErrorState(EnumErrorCode.OK);
}
}
}
@@ -277,23 +267,25 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* SMP */
// @Override
public void getGUINetworkData(int i, int j) {
if (logic == null)
if (logic == null) {
return;
}
switch (i) {
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
}
}
// @Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
if (logic == null)
if (logic == null) {
return;
}
iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
@@ -315,11 +307,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
return zCoord;
}
@Override
public int getBiomeId() {
return biome.biomeID;
}
@Override
public BiomeGenBase getBiome() {
return biome;
@@ -340,6 +327,30 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
setInventorySlotContents(SLOT_QUEEN, itemstack);
}
@Override
public ItemStack decrStackSize(int slotIndex, int amount) {
ItemStack itemStack = super.decrStackSize(slotIndex, amount);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
return itemStack;
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemStack) {
super.setInventorySlotContents(slotIndex, itemStack);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
}
private void handleQueenChange() {
if (!Proxies.common.isSimulating(worldObj)) {
ItemStack itemStack = getStackInSlot(SLOT_QUEEN);
displayQueen = BeeManager.beeRoot.getMember(itemStack);
}
}
@Override
public void setDrone(ItemStack itemstack) {
setInventorySlotContents(SLOT_DRONE, itemstack);
@@ -350,16 +361,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
return worldObj;
}
@Override
public void setErrorState(int state) {
setErrorState(EnumErrorCode.values()[state]);
}
@Override
public int getErrorOrdinal() {
return getErrorState().getID();
}
@Override
public boolean canBreed() {
return true;
@@ -440,6 +441,46 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* IHousing */
@Override
public GameProfile getOwnerName() {
return this.getOwnerProfile();
return this.getOwner();
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
protected static class BeehouseInventoryAdapter extends TileInventoryAdapter<TileBeehouse> {
public BeehouseInventoryAdapter(TileBeehouse tile, int size, String name) {
super(tile, size, name);
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
return itemStack.getItem() instanceof IHiveFrame;
} else if (slotIndex == SLOT_DRONE) {
return BeeManager.beeRoot.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
}
}
}
@@ -4,20 +4,21 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import forestry.apiculture.network.PacketUpdateCandle;
public class TileCandle extends TileEntity {
private int colour;
private boolean lit;
// This is a non-ticking Tile Entity.
@Override
@@ -27,48 +28,49 @@ public class TileCandle extends TileEntity {
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbt);
PacketUpdateCandle updateCandle = new PacketUpdateCandle(this);
return updateCandle.getPacket();
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
public void onPacketUpdate(PacketUpdateCandle updateCandle) {
colour = updateCandle.getColour();
lit = updateCandle.isLit();
}
@Override
public void readFromNBT(NBTTagCompound tagRoot) {
super.readFromNBT(tagRoot);
this.setColour(tagRoot.getInteger("colour"));
colour = tagRoot.getInteger("colour");
lit = tagRoot.getBoolean("lit");
}
@Override
public void writeToNBT(NBTTagCompound tagRoot) {
super.writeToNBT(tagRoot);
tagRoot.setInteger("colour", this.colour);
tagRoot.setBoolean("lit", this.lit);
}
public boolean isLit() {
return lit;
}
public void setLit(boolean lit) {
this.lit = lit;
}
public int getColour() {
return this.colour;
return colour;
}
public void setColour(int value) {
this.colour = value;
}
public void setColour(int red, int green, int blue) {
this.colour = toIntColour(red, green, blue);
}
/*public void setColour(int[] cs) {
this.colour = toIntColour(cs[0], cs[1], cs[2]);
}*/
public void addColour(int red, int green, int blue) {
public void addColour(int colour2) {
int[] myColour = fromIntColour(this.colour);
this.colour = toIntColour((red + myColour[0]) / 2, (green + myColour[0]) / 2, (blue + myColour[2]) / 2);
int[] addColour = fromIntColour(colour2);
this.colour = toIntColour((addColour[0] + myColour[0]) / 2, (addColour[0] + myColour[0]) / 2, (addColour[2] + myColour[2]) / 2);
}
private static int[] fromIntColour(int value) {
+11 -7
View File
@@ -4,19 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.InventoryAdapter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.EnumSkyBlock;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.InventoryAdapter;
public class TileSwarm extends TileEntity {
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
@@ -41,16 +42,19 @@ public class TileSwarm extends TileEntity {
}
public TileSwarm setContained(ItemStack[] bees) {
for (ItemStack itemstack : bees)
InvTools.addStack(contained, itemstack, false, true);
for (ItemStack itemstack : bees) {
InvTools.addStack(contained, itemstack, true);
}
return this;
}
public boolean containsBees() {
for (int i = 0; i < contained.getSizeInventory(); i++)
if (contained.getStackInSlot(i) != null)
for (int i = 0; i < contained.getSizeInventory(); i++) {
if (contained.getStackInSlot(i) != null) {
return true;
}
}
return false;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -46,20 +46,24 @@ public class AIAvoidPlayers extends EntityAIBase {
player = mob.worldObj.getClosestPlayerToEntity(mob, minDistance);
if (player == null)
if (player == null) {
return false;
}
if (!mob.getEntitySenses().canSee(player))
if (!mob.getEntitySenses().canSee(player)) {
return false;
}
Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7,
Vec3.createVectorHelper(player.posX, player.posY, player.posZ));
if (randomTarget == null)
if (randomTarget == null) {
return false;
}
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob))
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob)) {
return false;
}
pathing = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
return pathing != null && pathing.isDestinationSame(randomTarget);
@@ -82,9 +86,10 @@ public class AIAvoidPlayers extends EntityAIBase {
@Override
public void updateTask() {
if (mob.getDistanceSqToEntity(player) < 49.0D)
if (mob.getDistanceSqToEntity(player) < 49.0D) {
mob.getNavigator().setSpeed(nearSpeed);
else
} else {
mob.getNavigator().setSpeed(farSpeed);
}
}
}
@@ -4,101 +4,124 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.core.IIconProvider;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.core.config.Defaults;
import forestry.core.genetics.AlleleSpecies;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies, IIconProvider {
import com.mojang.authlib.GameProfile;
public IJubilanceProvider jubilanceProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
private final IBeeRoot root;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeIconProvider;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.core.IIconProvider;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.core.genetics.alleles.AlleleSpecies;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
private final HashMap<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
private final HashMap<ItemStack, Integer> specialty = new HashMap<ItemStack, Integer>();
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpeciesCustom {
@Deprecated
private final Map<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
@Deprecated
private final Map<ItemStack, Integer> specialty = new HashMap<ItemStack, Integer>();
private final Map<ItemStack, Float> productChances = new HashMap<ItemStack, Float>();
private final Map<ItemStack, Float> specialtyChances = new HashMap<ItemStack, Float>();
private String texture;
private final int primaryColour;
private final int secondaryColour;
private static final String iconType = "default";
private IBeeIconProvider beeIconProvider;
private IJubilanceProvider jubilanceProvider;
private boolean nocturnal = false;
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, int primaryColor, int secondaryColor) {
this(uid, dominant, name, branch, null, primaryColor, secondaryColor);
}
public AlleleBeeSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, false);
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
this(uid, dominant, name, branch, binomial, primaryColor, secondaryColor, new JubilanceDefault());
}
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, String binomial, int primaryColor, int secondaryColor,
IJubilanceProvider jubilanceProvider) {
super(uid, dominant, name, branch, binomial);
this.root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
this.primaryColour = primaryColor;
this.secondaryColour = secondaryColor;
this.jubilanceProvider = jubilanceProvider;
texture = Defaults.TEXTURE_PATH_ENTITIES + "/bees/honeyBee.png";
setCustomBeeIconProvider(DefaultBeeIconProvider.getInstance());
setJubilanceProvider(JubilanceDefault.getInstance());
}
@Override
public IBeeRoot getRoot() {
return root;
return BeeManager.beeRoot;
}
public AlleleBeeSpecies setEntityTexture(String texture) {
this.texture = Defaults.TEXTURE_PATH_ENTITIES + "/bees/" + texture + ".png";
return this;
}
public AlleleBeeSpecies addProduct(ItemStack product, int chance) {
if (product == null || product.getItem() == null)
@Override
public IAlleleBeeSpeciesCustom addProduct(ItemStack product, Float chance) {
if (product == null || product.getItem() == null) {
throw new IllegalArgumentException("Tried to add null product");
this.products.put(product, chance);
}
if (chance <= 0.0f || chance > 1.0f) {
throw new IllegalArgumentException("chance must be in the range (0, 1]");
}
this.productChances.put(product, chance);
int intChance = Math.max(1, Math.round(chance * 100));
this.products.put(product, intChance);
return this;
}
public AlleleBeeSpecies addSpecialty(ItemStack specialty, int chance) {
this.specialty.put(specialty, chance);
@Override
public IAlleleBeeSpeciesCustom addSpecialty(ItemStack specialty, Float chance) {
if (specialty == null || specialty.getItem() == null) {
throw new IllegalArgumentException("Tried to add null specialty");
}
if (chance <= 0.0f || chance > 1.0f) {
throw new IllegalArgumentException("chance must be in the range (0, 1]");
}
this.specialtyChances.put(specialty, chance);
int intChance = Math.max(1, Math.round(chance * 100));
this.specialty.put(specialty, intChance);
return this;
}
public AlleleBeeSpecies setJubilanceProvider(IJubilanceProvider provider) {
@Override
public IAlleleBeeSpeciesCustom setJubilanceProvider(IJubilanceProvider provider) {
this.jubilanceProvider = provider;
return this;
}
@Override
public IAlleleBeeSpeciesCustom setNocturnal() {
nocturnal = true;
return this;
}
@Override
public IAlleleBeeSpeciesCustom setCustomBeeIconProvider(IBeeIconProvider beeIconProvider) {
this.beeIconProvider = beeIconProvider;
return this;
}
/* RESEARCH */
@Override
public int getComplexity() {
@@ -111,16 +134,18 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
int highest = 0;
exclude.add(species);
for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) {
if(!exclude.contains(mutation.getAllele0())) {
for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) {
if (!exclude.contains(mutation.getAllele0())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude);
if(otherAdvance > highest)
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
if(!exclude.contains(mutation.getAllele1())) {
if (!exclude.contains(mutation.getAllele1())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude);
if(otherAdvance > highest)
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
}
@@ -129,15 +154,20 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public float getResearchSuitability(ItemStack itemstack) {
if(itemstack == null)
if (itemstack == null) {
return 0f;
}
for(ItemStack stack : products.keySet())
if(stack.isItemEqual(itemstack))
for (ItemStack stack : productChances.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
for(ItemStack stack : specialty.keySet())
if(stack.isItemEqual(itemstack))
}
}
for (ItemStack stack : specialtyChances.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
}
return super.getResearchSuitability(itemstack);
}
@@ -147,13 +177,13 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
ArrayList<ItemStack> bounty = new ArrayList<ItemStack>();
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
if(bountyLevel > 10) {
for(ItemStack stack : specialty.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
if (bountyLevel > 10) {
for (ItemStack stack : specialtyChances.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
}
for(ItemStack stack : products.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
for (ItemStack stack : productChances.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
return bounty.toArray(new ItemStack[bounty.size()]);
}
@@ -161,76 +191,119 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
/* OTHER */
@Override
public boolean isNocturnal() {
return false;
return nocturnal;
}
@Override
public HashMap<ItemStack, Integer> getProducts() {
public Map<ItemStack, Integer> getProducts() {
return products;
}
@Override
public HashMap<ItemStack, Integer> getSpecialty() {
public Map<ItemStack, Float> getProductChances() {
return productChances;
}
@Override
public Map<ItemStack, Integer> getSpecialty() {
return specialty;
}
@Override
public Map<ItemStack, Float> getSpecialtyChances() {
return specialtyChances;
}
@Override
public boolean isJubilant(IBeeGenome genome, IBeeHousing housing) {
return jubilanceProvider.isJubilant(this, genome, housing);
}
@Override
public String getEntityTexture() {
return texture;
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return new BeeIconProviderWrapper(beeIconProvider);
}
@Override
public IIcon getIcon(EnumBeeType type, int renderPass) {
return beeIconProvider.getIcon(type, renderPass);
}
@Override
public int getIconColour(int renderPass) {
if (renderPass == 0)
if (renderPass == 0) {
return primaryColour;
if (renderPass == 1)
}
if (renderPass == 1) {
return secondaryColour;
}
return 0xffffff;
}
@SideOnly(Side.CLIENT)
private static IIcon[][] icons;
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
icons = new IIcon[EnumBeeType.values().length][3];
IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
if(EnumBeeType.values()[i] == EnumBeeType.NONE)
continue;
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
: TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body");
icons[i][2] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body2");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(EnumBeeType type, int renderPass) {
return icons[type.ordinal()][renderPass];
}
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return this;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(short texUID) {
public String getEntityTexture() {
return null;
}
private static class DefaultBeeIconProvider implements IBeeIconProvider {
private static final String iconType = "default";
private static DefaultBeeIconProvider instance;
public static DefaultBeeIconProvider getInstance() {
if (instance == null) {
instance = new DefaultBeeIconProvider();
}
return instance;
}
private DefaultBeeIconProvider() {
}
private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3];
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
if (EnumBeeType.values()[i] == EnumBeeType.NONE) {
continue;
}
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
: TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body");
icons[i][2] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body2");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(EnumBeeType type, int renderPass) {
return icons[type.ordinal()][renderPass];
}
}
private static class BeeIconProviderWrapper implements IIconProvider {
private final IBeeIconProvider beeIconProvider;
public BeeIconProviderWrapper(IBeeIconProvider beeIconProvider) {
this.beeIconProvider = beeIconProvider;
}
@Override
public IIcon getIcon(short texUID) {
return null;
}
@Override
public void registerIcons(IIconRegister register) {
beeIconProvider.registerIcons(register);
}
}
}
@@ -4,36 +4,39 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.utils.DamageSourceForestry;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
public class AlleleEffectAggressive extends AlleleEffectThrottled {
public static final DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
public AlleleEffectAggressive(String uid) {
super(uid, "aggressive", true, 40, false, false);
public AlleleEffectAggressive() {
super("aggressive", true, 40, false, false);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -49,14 +52,15 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
}
entity.attackEntityFrom(damageSourceBeeAggressive, damage);
@@ -4,21 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.genetics.EffectData;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class AlleleEffectCreeper extends AlleleEffectThrottled {
@@ -27,17 +29,19 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
private final byte indexExplosionTimer = 1;
private final byte indexExplosionForce = 2;
public AlleleEffectCreeper(String uid) {
super(uid, "creeper", true, 20, false, true);
public AlleleEffectCreeper() {
super("creeper", true, 20, false, true);
}
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (!(storedData instanceof EffectData))
if (!(storedData instanceof EffectData)) {
return new EffectData(3, 0);
}
if (((EffectData) storedData).getIntSize() < 3)
if (((EffectData) storedData).getIntSize() < 3) {
return new EffectData(3, 0);
}
return storedData;
}
@@ -47,8 +51,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
// If we are already triggered, we continue the explosion sequence.
if (storedData.getInteger(indexExplosionTimer) > 0) {
@@ -72,9 +77,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2) {
} else if (count > 2) {
chance = 5;
storedData.setInteger(indexExplosionForce, 6);
} else if (count > 1) {
@@ -85,8 +90,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
storedData.setInteger(indexExplosionForce, 10);
}
if (world.rand.nextInt(1000) >= chance)
if (world.rand.nextInt(1000) >= chance) {
continue;
}
world.playSoundEffect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), "mob.creeper", 4F,
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
@@ -103,8 +109,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
explosionTimer--;
storedData.setInteger(indexExplosionTimer, explosionTimer);
if (explosionTimer > 0)
if (explosionTimer > 0) {
return;
}
world.createExplosion(null, x, y, z, storedData.getInteger(indexExplosionForce), false);
}
@@ -4,30 +4,33 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
public class AlleleEffectExploration extends AlleleEffectThrottled {
public AlleleEffectExploration(String uid) {
super(uid, "exploration", false, 80, true, false);
public AlleleEffectExploration() {
super("exploration", false, 80, true, false);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -1,18 +1,20 @@
package forestry.apiculture.genetics;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
public class AlleleEffectFertile extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 5;
public AlleleEffectFertile(String uid) {
super(uid, "fertile", false, 6, true, false);
public AlleleEffectFertile() {
super("fertile", false, 6, true, false);
}
@Override
@@ -1,13 +1,9 @@
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.init.Blocks;
@@ -15,13 +11,18 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
public class AlleleEffectFungification extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 10;
public static final int ENTITY_THROTTLE = 6;
public AlleleEffectFungification(String uid) {
super(uid, "mycophilic", true, 10, false, false);
public AlleleEffectFungification() {
super("mycophilic", true, 10, false, false);
}
@Override
@@ -48,7 +49,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
} else {
++entityThrottle;
}
storedData.setInteger(1, entityThrottle);
storedData.setInteger(1, entityThrottle);
return storedData;
}
@@ -74,18 +75,18 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
}
}
private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
AxisAlignedBB aabb = this.getBounding(genome, housing, 1f);
World world = housing.getWorld();
@SuppressWarnings("unchecked") // Quiets warnings. Eventually returns a list of entities.
List<Entity> entities = (List<Entity>)world.getEntitiesWithinAABB(EntityCow.class, aabb);
for (Entity entity : entities) {
List entities = world.getEntitiesWithinAABB(EntityCow.class, aabb);
for (Object entity : entities) {
if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) {
convertCowToMooshroom((EntityCow)entity);
break;
convertCowToMooshroom((EntityCow) entity);
break;
}
}
}
@@ -104,25 +105,25 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
private static void convertCowToMooshroom(EntityCow cow) {
World worldObj = cow.worldObj;
cow.setDead();
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double)(cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
cow.setDead();
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double) (cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
}
private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) {
WorldGenBigMushroom giantMushroomGenerator;
if (block == Blocks.brown_mushroom) {
giantMushroomGenerator = new WorldGenBigMushroom(0);
} else {
giantMushroomGenerator = new WorldGenBigMushroom(1);
}
world.setBlockToAir(blockX, blockY, blockZ);
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
WorldGenBigMushroom giantMushroomGenerator;
if (block == Blocks.brown_mushroom) {
giantMushroomGenerator = new WorldGenBigMushroom(0);
} else {
giantMushroomGenerator = new WorldGenBigMushroom(1);
}
world.setBlockToAir(blockX, blockY, blockZ);
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
}
}
@@ -4,27 +4,28 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IEffectData;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
public class AlleleEffectGlacial extends AlleleEffectThrottled {
public AlleleEffectGlacial(String uid) {
super(uid, "glacial", false, 200, true, false);
public AlleleEffectGlacial() {
super("glacial", false, 200, true, false);
}
@Override
@@ -32,17 +33,18 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
EnumTemperature temp = housing.getTemperature();
switch (temp) {
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
}
int[] areaAr = genome.getTerritory();
@@ -58,11 +60,13 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
// Freeze water
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block != Blocks.water)
if (block != Blocks.water) {
continue;
}
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z))
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) {
continue;
}
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.ice);
}
@@ -4,31 +4,34 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.List;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
public class AlleleEffectHeroic extends AlleleEffectThrottled {
public AlleleEffectHeroic(String uid) {
super(uid, "heroic", false, 40, true, false);
public AlleleEffectHeroic() {
super("heroic", false, 40, true, false);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -4,30 +4,32 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.plugins.PluginApiculture;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class AlleleEffectIgnition extends AlleleEffectThrottled {
private static final int ignitionChance = 50;
private static final int fireDuration = 500;
public AlleleEffectIgnition(String uid) {
super(uid, "ignition", false, 20, false, true);
public AlleleEffectIgnition() {
super("ignition", false, 20, false, true);
}
@Override
@@ -35,8 +37,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -53,9 +56,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2) {
} else if (count > 2) {
chance = 5;
duration = 50;
} else if (count > 1) {
@@ -67,8 +70,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
}
}
if (world.rand.nextInt(1000) >= chance)
if (world.rand.nextInt(1000) >= chance) {
continue;
}
entity.setFire(duration);
}
@@ -81,12 +85,13 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
int[] area = getModifiedArea(genome, housing);
if (housing.getWorld().rand.nextBoolean())
if (housing.getWorld().rand.nextBoolean()) {
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
else
} else {
PluginApiculture.proxy.addBeeHiveFX("particles/ember", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
}
return storedData;
}
@@ -4,30 +4,32 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.plugins.PluginApiculture;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.plugins.PluginApiculture;
public class AlleleEffectMiasmic extends AlleleEffectThrottled {
private static final int infectionChance = 50;
public AlleleEffectMiasmic(String uid) {
super(uid, "misasmic", false, 50, false, false);
public AlleleEffectMiasmic() {
super("miasmic", false, 50, false, false);
}
@Override
@@ -35,8 +37,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB infectionBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -44,8 +47,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
for (Object obj : list) {
if (world.rand.nextInt(1000) >= infectionChance)
if (world.rand.nextInt(1000) >= infectionChance) {
continue;
}
EntityPlayer player = (EntityPlayer) obj;
@@ -55,14 +59,15 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
duration = 200;
else if (count > 1)
} else if (count > 1) {
duration = 400;
else if (count > 0)
} else if (count > 0) {
duration = 600;
}
player.addPotionEffect(new PotionEffect(Potion.poison.id, duration, 0));
}
@@ -75,12 +80,13 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
int[] area = getModifiedArea(genome, housing);
if (housing.getWorld().rand.nextBoolean())
if (housing.getWorld().rand.nextBoolean()) {
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
else
} else {
PluginApiculture.proxy.addBeeHiveFX("particles/poison", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
}
return storedData;
}
@@ -4,35 +4,38 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.utils.DamageSourceForestry;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
public static final DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
public AlleleEffectMisanthrope(String uid) {
super(uid, "misanthrope", true, 20, false, false);
public AlleleEffectMisanthrope() {
super("misanthrope", true, 20, false, false);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -47,14 +50,15 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
player.attackEntityFrom(damageSourceBeeEnd, damage);
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -14,14 +14,13 @@ import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.Allele;
import forestry.core.genetics.alleles.AlleleCategorized;
import forestry.plugins.PluginApiculture;
import net.minecraft.world.World;
public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
public class AlleleEffectNone extends AlleleCategorized implements IAlleleBeeEffect {
public AlleleEffectNone(String uid) {
super(uid, true);
public AlleleEffectNone(String name) {
super("forestry", "effect", name, true);
}
@Override
@@ -36,18 +35,9 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
return doEffect(genome, storedData, housing.getWorld(), housing.getBiomeId(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
}
protected IEffectData doEffect(IBeeGenome genome, IEffectData storedData, World world, int biomeid, int x, int y, int z) {
return storedData;
}
@Override
public String getUnlocalizedName() {
return "apiculture.effect.none";
}
@Override
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
@@ -56,12 +46,15 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
area[1] *= housing.getTerritoryModifier(genome, 1f);
area[2] *= housing.getTerritoryModifier(genome, 1f);
if (area[0] < 1)
if (area[0] < 1) {
area[0] = 1;
if (area[1] < 1)
}
if (area[1] < 1) {
area[1] = 1;
if (area[2] < 1)
}
if (area[2] < 1) {
area[2] = 1;
}
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
@@ -4,23 +4,26 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.relauncher.ReflectionHelper;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.proxy.Proxies;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
public class AlleleEffectPotion extends AlleleEffectThrottled {
@@ -28,8 +31,8 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
private final boolean isBadEffect;
private final int duration;
public AlleleEffectPotion(String uid, String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) {
super(uid, name, isDominant, 200, requiresWorking, false);
public AlleleEffectPotion(String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) {
super(name, isDominant, 200, requiresWorking, false);
this.potion = potion;
this.isBadEffect = isBadEffect(potion);
this.duration = duration;
@@ -38,15 +41,17 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox);
for (Object entity : list) {
if (!(entity instanceof EntityPlayer))
if (!(entity instanceof EntityPlayer)) {
continue;
}
EntityPlayer player = (EntityPlayer) entity;
@@ -54,14 +59,15 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
if (isBadEffect) {
// Players are not attacked if they wear a full set of apiarist's armor.
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
if (count >= 4)
if (count >= 4) {
continue; // Full set, no damage/effect
else if (count == 3)
} else if (count == 3) {
dur = this.duration / 4;
else if (count == 2)
} else if (count == 2) {
dur = this.duration / 2;
else if (count == 1)
} else if (count == 1) {
dur = this.duration * 3 / 4;
}
}
player.addPotionEffect(new PotionEffect(potion.getId(), dur, 0));
@@ -4,12 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
@@ -18,22 +29,13 @@ import forestry.apiculture.gadgets.TileAlveary;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.vect.Vect;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class AlleleEffectRadioactive extends AlleleEffectThrottled {
public static final DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
public AlleleEffectRadioactive(String uid) {
super(uid, "radioactive", true, 40, false, true);
public AlleleEffectRadioactive() {
super("radioactive", true, 40, false, true);
}
@Override
@@ -41,8 +43,9 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0] * 2, areaAr[1] * 2, areaAr[2] * 2);
@@ -67,14 +70,15 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
}
entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
@@ -90,29 +94,36 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
posBlock = posBlock.add(offset);
if(posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight())
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
continue;
}
// Don't destroy ourself and blocks below us.
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord())
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) {
continue;
}
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
}
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block instanceof BlockAlveary)
if (block instanceof BlockAlveary) {
continue;
}
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
if (tile instanceof IBeeHousing)
if (tile instanceof IBeeHousing) {
continue;
if (tile instanceof TileAlveary)
}
if (tile instanceof TileAlveary) {
continue;
}
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0)
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
continue;
}
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
break;
@@ -4,33 +4,37 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.List;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
public class AlleleEffectRepulsion extends AlleleEffectThrottled {
public AlleleEffectRepulsion(String uid) {
super(uid, "repulsion", false, 100, true, true);
public AlleleEffectRepulsion() {
super("repulsion", false, 100, true, true);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
if (housing.getOwnerName() == null)
if (housing.getOwnerName() == null) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -41,8 +45,9 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
for (Object objT : mob.tasks.taskEntries) {
EntityAITaskEntry task = (EntityAITaskEntry) objT;
if (task.action instanceof AIAvoidPlayers)
if (task.action instanceof AIAvoidPlayers) {
return storedData;
}
}
mob.tasks.addTask(3, new AIAvoidPlayers(mob, 6.0f, 0.25f, 0.3f));
@@ -4,20 +4,16 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.item.EntityItem;
@@ -34,6 +30,12 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
public class AlleleEffectResurrection extends AlleleEffectThrottled {
public static class Resurrectable {
@@ -70,37 +72,42 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
private final List<Resurrectable> resurrectables;
public AlleleEffectResurrection(String uid, String name, List<Resurrectable> resurrectables) {
super(uid, name, true, 40, true, true);
public AlleleEffectResurrection(String name, List<Resurrectable> resurrectables) {
super(name, true, 40, true, true);
this.resurrectables = resurrectables;
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, bounding);
if (list.size() > 0)
if (list.size() > 0) {
Collections.shuffle(resurrectables);
}
for (Object obj : list) {
EntityItem item = (EntityItem) obj;
if (item.isDead)
if (item.isDead) {
continue;
}
ItemStack contained = item.getEntityItem();
for (Resurrectable entry : resurrectables)
for (Resurrectable entry : resurrectables) {
if (StackUtils.isIdenticalItem(entry.res, contained)) {
Utils.spawnEntity(housing.getWorld(), entry.risen, item.posX, item.posY, item.posZ);
contained.stackSize--;
if (contained.stackSize <= 0)
if (contained.stackSize <= 0) {
item.setDead();
}
break;
}
}
}
return storedData;
@@ -4,27 +4,29 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IEffectData;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
public class AlleleEffectSnowing extends AlleleEffectThrottled {
public AlleleEffectSnowing(String uid) {
super(uid, "snowing", false, 20, true, true);
public AlleleEffectSnowing() {
super("snowing", false, 20, true, true);
}
@Override
@@ -32,17 +34,18 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
EnumTemperature temp = housing.getTemperature();
switch (temp) {
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
}
int[] areaAr = genome.getTerritory();
@@ -57,11 +60,13 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
posBlock = posBlock.add(offset);
// Put snow on the ground
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false))
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) {
continue;
}
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
}
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.snow_layer);
}
@@ -4,32 +4,32 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.EnumErrorCode;
import forestry.core.genetics.Allele;
import forestry.core.genetics.EffectData;
import forestry.core.genetics.alleles.AlleleCategorized;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.util.AxisAlignedBB;
public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect {
public abstract class AlleleEffectThrottled extends AlleleCategorized implements IAlleleBeeEffect {
private boolean isCombinable = false;
private final int throttle;
private boolean requiresWorkingQueen = false;
public AlleleEffectThrottled(String uid, String name, boolean isDominant, int throttle, boolean requiresWorking, boolean isCombinable) {
super(uid, isDominant);
this.name = "apiculture.effect." + name;
public AlleleEffectThrottled(String name, boolean isDominant, int throttle, boolean requiresWorking, boolean isCombinable) {
super("forestry", "effect", name, isDominant);
this.throttle = throttle;
this.isCombinable = isCombinable;
this.requiresWorkingQueen = requiresWorking;
@@ -46,23 +46,26 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (storedData instanceof EffectData)
if (storedData instanceof EffectData) {
return storedData;
}
return new EffectData(1, 0);
}
public boolean isHalted(IEffectData storedData, IBeeHousing housing) {
if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK)
if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) {
return true;
}
int throt = storedData.getInteger(0);
throt++;
storedData.setInteger(0, throt);
if (throt < getThrottle())
if (throt < getThrottle()) {
return true;
}
// Reset since we are done throttling.
storedData.setInteger(0, 0);
@@ -85,12 +88,15 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
area[1] *= housing.getTerritoryModifier(genome, 1f) * 3;
area[2] *= housing.getTerritoryModifier(genome, 1f) * 3;
if (area[0] < 1)
if (area[0] < 1) {
area[0] = 1;
if (area[1] < 1)
}
if (area[1] < 1) {
area[1] = 1;
if (area[2] < 1)
}
if (area[2] < 1) {
area[2] = 1;
}
return area;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -12,18 +12,14 @@ package forestry.apiculture.genetics;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IFlowerProvider;
import forestry.core.genetics.Allele;
import forestry.core.genetics.alleles.AlleleCategorized;
public class AlleleFlowers extends Allele implements IAlleleFlowers {
public class AlleleFlowers extends AlleleCategorized implements IAlleleFlowers {
private final IFlowerProvider provider;
public AlleleFlowers(String uid, IFlowerProvider provider) {
this(uid, provider, false);
}
public AlleleFlowers(String uid, IFlowerProvider provider, boolean isDominant) {
super(uid, isDominant);
public AlleleFlowers(String modId, String category, String name, IFlowerProvider provider, boolean isDominant) {
super(modId, category, name, isDominant);
this.provider = provider;
}
@@ -4,24 +4,27 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IIndividual;
import forestry.core.genetics.BreedingTracker;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
public class ApiaristTracker extends BreedingTracker implements IApiaristTracker {
/** Required for creation from map storage */
public ApiaristTracker(String s) {
this(s, null);
}
@@ -58,12 +61,15 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
@Override
public void registerPickup(IIndividual individual) {
if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID))
if (!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) {
return;
if(!individual.isPureBred(EnumBeeChromosome.SPECIES))
}
if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) {
return;
if(PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0)
}
if (BeeManager.beeRoot.getCombinations(individual.getGenome().getPrimary()).size() > 0) {
return;
}
registerSpecies(individual.getGenome().getPrimary());
}
@@ -102,12 +108,12 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
}
@Override
protected IBreedingTracker getCommonTracker(EntityPlayer player) {
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, null);
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
return BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile());
}
@Override
protected String getPacketTag() {
protected String speciesRootUID() {
return BeeHelper.UID;
}
+184 -145
View File
@@ -4,13 +4,14 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -24,6 +25,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -36,15 +38,17 @@ import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorState;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.arboriculture.genetics.FakePollinatable;
import forestry.arboriculture.genetics.ICheckPollinatable;
import forestry.core.EnumErrorCode;
import forestry.core.config.Defaults;
import forestry.core.genetics.Chromosome;
@@ -55,7 +59,6 @@ import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.StringUtil;
import forestry.core.vect.MutableVect;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
public class Bee extends IndividualLiving implements IBee {
@@ -91,25 +94,29 @@ public class Bee extends IndividualLiving implements IBee {
public void readFromNBT(NBTTagCompound nbttagcompound) {
if (nbttagcompound == null) {
this.genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
genome = BeeDefinition.FOREST.getGenome();
return;
}
super.readFromNBT(nbttagcompound);
if (nbttagcompound.hasKey("NA"))
if (nbttagcompound.hasKey("NA")) {
isNatural = nbttagcompound.getBoolean("NA");
}
if (nbttagcompound.hasKey("GEN"))
if (nbttagcompound.hasKey("GEN")) {
generation = nbttagcompound.getInteger("GEN");
}
if (nbttagcompound.hasKey("Genome"))
if (nbttagcompound.hasKey("Genome")) {
genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome"));
else
genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
} else {
genome = BeeDefinition.FOREST.getGenome();
}
if (nbttagcompound.hasKey("Mate"))
if (nbttagcompound.hasKey("Mate")) {
mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate"));
}
}
@@ -118,22 +125,19 @@ public class Bee extends IndividualLiving implements IBee {
super.writeToNBT(nbttagcompound);
if (!isNatural)
if (!isNatural) {
nbttagcompound.setBoolean("NA", false);
}
if (generation > 0)
if (generation > 0) {
nbttagcompound.setInteger("GEN", generation);
}
}
public void setIsNatural(boolean flag) {
this.isNatural = flag;
}
@Override
public boolean isIrregularMating() {
return false;
}
public boolean isNatural() {
return this.isNatural;
}
@@ -144,10 +148,11 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public void mate(IIndividual individual) {
if(!(individual instanceof IBee))
if (!(individual instanceof IBee)) {
return;
}
IBee drone = (IBee)individual;
IBee drone = (IBee) individual;
mate = drone.getGenome();
}
@@ -156,18 +161,21 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
if (effect == null)
if (effect == null) {
return null;
}
storedData[0] = doEffect(effect, storedData[0], housing);
// Return here if the primary can already not be combined
if (!effect.isCombinable())
if (!effect.isCombinable()) {
return storedData;
}
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable())
if (!secondary.isCombinable()) {
return storedData;
}
storedData[1] = doEffect(secondary, storedData[1], housing);
@@ -183,18 +191,21 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
if (effect == null)
if (effect == null) {
return null;
}
storedData[0] = doFX(effect, storedData[0], housing);
// Return here if the primary can already not be combined
if (!effect.isCombinable())
if (!effect.isCombinable()) {
return storedData;
}
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable())
if (!secondary.isCombinable()) {
return storedData;
}
storedData[1] = doFX(secondary, storedData[1], housing);
@@ -230,45 +241,56 @@ public class Bee extends IndividualLiving implements IBee {
}
@Override
public int isWorking(IBeeHousing housing) {
return canWork(housing).ordinal();
}
@Override
public EnumErrorCode canWork(IBeeHousing housing) {
public Set<IErrorState> getCanWork(IBeeHousing housing) {
World world = housing.getWorld();
BiomeGenBase biome = housing.getBiome();
Set<IErrorState> errorStates = new HashSet<IErrorState>();
// / Rain needs tolerant flyers
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(housing.getBiomeId()) && !housing.isSealed()) {
return EnumErrorCode.ISRAINING;
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(biome) && !housing.isSealed()) {
errorStates.add(EnumErrorCode.ISRAINING);
}
// / Night or darkness requires nocturnal species
if(world.isDaytime()) {
if(!canWorkDuringDay())
return EnumErrorCode.NOTNIGHT;
} else if (!canWorkAtNight() && !housing.isSelfLighted())
return EnumErrorCode.NOTDAY;
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
errorStates.add(EnumErrorCode.NOTNIGHT);
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
errorStates.add(EnumErrorCode.NOTDAY);
}
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
if(!canWorkDuringDay())
return EnumErrorCode.NOTGLOOMY;
} else if(!canWorkAtNight() && !housing.isSelfLighted())
return EnumErrorCode.NOTLUCID;
if (!canWorkDuringDay()) {
errorStates.add(EnumErrorCode.NOTGLOOMY);
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
errorStates.add(EnumErrorCode.NOTLUCID);
}
// / No sky, except if in hell
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if(biome == null)
return EnumErrorCode.NOSKY;
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated())
return EnumErrorCode.NOSKY;
if (biome != null && !BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
errorStates.add(EnumErrorCode.NOSKY);
}
// / And finally climate check
if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity()))
return EnumErrorCode.INVALIDBIOME;
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
errorStates.add(EnumErrorCode.INVALIDBIOME);
}
return EnumErrorCode.OK;
return errorStates;
}
@Override
public IErrorState canWork(IBeeHousing housing) {
Set<IErrorState> errorStates = getCanWork(housing);
if (errorStates.size() == 0) {
return EnumErrorCode.OK;
} else {
return errorStates.iterator().next();
}
}
private boolean canWorkAtNight() {
@@ -279,19 +301,17 @@ public class Bee extends IndividualLiving implements IBee {
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
}
private boolean checkBiomeHazard(BiomeGenBase biome) {
if (biome == null)
public boolean isSuitableBiome(BiomeGenBase biome) {
if (biome == null) {
return false;
}
EnumTemperature temperature = EnumTemperature.getFromBiome(biome);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
return isSuitableClimate(temperature, humidity);
}
private boolean checkSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
private boolean isSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
@@ -323,22 +343,14 @@ public class Bee extends IndividualLiving implements IBee {
return hasFlower;
}
@Override
public ArrayList<Integer> getSuitableBiomeIds() {
ArrayList<Integer> suitableBiomes = new ArrayList<Integer>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
if (checkBiomeHazard(biome))
suitableBiomes.add(biome.biomeID);
return suitableBiomes;
}
@Override
public ArrayList<BiomeGenBase> getSuitableBiomes() {
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
if (checkBiomeHazard(biome))
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (isSuitableBiome(biome)) {
suitableBiomes.add(biome);
}
}
return suitableBiomes;
}
@@ -355,36 +367,39 @@ public class Bee extends IndividualLiving implements IBee {
// You analyzed it? Juicy tooltip coming up!
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
if (!isPureBred(EnumBeeChromosome.SPECIES))
list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName()));
if (!isPureBred(EnumBeeChromosome.SPECIES)) {
list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY", primary.getName()).replaceAll("%SECONDARY", secondary.getName()));
}
if (generation > 0) {
EnumRarity rarity;
if (generation >= 1000)
if (generation >= 1000) {
rarity = EnumRarity.epic;
else if (generation >= 100)
} else if (generation >= 100) {
rarity = EnumRarity.rare;
else if (generation >= 10)
} else if (generation >= 10) {
rarity = EnumRarity.uncommon;
else
} else {
rarity = EnumRarity.common;
}
String generationString = rarity.rarityColor + StringUtil.localizeAndFormat("gui.beealyzer.generations", generation);
list.add(generationString);
}
IAllele speedAllele = genome.getActiveAllele(EnumBeeChromosome.SPEED);
IAlleleTolerance tempToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance humidToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance tempToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance humidToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", "");
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceAll("(.*)\\.", "");
String speed;
if (StringUtil.canTranslate(unlocalizedCustomSpeed))
if (StringUtil.canTranslate(unlocalizedCustomSpeed)) {
speed = StringUtil.localize(unlocalizedCustomSpeed);
else
speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker");
} else {
speed = speedAllele.getName() + ' ' + StringUtil.localize("gui.worker");
}
String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life");
String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + ' ' + StringUtil.localize("gui.life");
String tempTolerance = EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempToleranceAllele.getName();
String humidTolerance = EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidToleranceAllele.getName();
String flowers = genome.getFlowerProvider().getDescription();
@@ -395,13 +410,18 @@ public class Bee extends IndividualLiving implements IBee {
list.add(humidTolerance);
list.add(flowers);
if (genome.getNocturnal())
if (genome.getNocturnal()) {
list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
}
if (genome.getTolerantFlyer()) {
list.add(EnumChatFormatting.WHITE + StringUtil.localize("gui.flyer.tooltip"));
}
}
@Override
public void age(World world, float housingLifespanModifier) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
float finalModifier = housingLifespanModifier * mode.getLifespanModifier(genome, mate, housingLifespanModifier);
super.age(world, finalModifier);
@@ -422,14 +442,16 @@ public class Bee extends IndividualLiving implements IBee {
for (ItemStack second : secondaryProducts) {
boolean skip = false;
for (ItemStack compare : products)
for (ItemStack compare : products) {
if (second.isItemEqual(compare)) {
skip = true;
break;
}
}
if (!skip)
if (!skip) {
products.add(second);
}
}
@@ -444,51 +466,53 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ItemStack[] produceStacks(IBeeHousing housing) {
if (!hasFlower(housing))
return null;
if (housing == null) {
Proxies.log.warning("Failed to produce in an apiary because the beehousing was null.");
return null;
}
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld());
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(housing.getWorld());
if (mode == null) {
Proxies.log.warning("Failed to produce in an apiary because the beekeeping mode was null.");
return null;
}
ArrayList<ItemStack> products = new ArrayList<ItemStack>();
List<ItemStack> products = new ArrayList<ItemStack>();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
// All work and no play makes queen a dull girl.
if(mode.isOverworked(this, housing))
if (mode.isOverworked(this, housing)) {
setIsNatural(false);
}
// Bee genetic speed * beehousing * beekeeping mode
float speed = genome.getSpeed() * housing.getProductionModifier(genome, 1f) * mode.getProductionModifier(genome, 1f);
// / Primary Products
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet())
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
// / Secondary Products
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet())
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed)
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed) {
products.add(entry.getKey().copy());
// We are done if the we are not jubilant.
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing))
return products.toArray(new ItemStack[products.size()]);
}
}
// / Specialty products
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet())
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
products.add(entry.getKey().copy());
if (primary.isJubilant(genome, housing) && secondary.isJubilant(genome, housing)) {
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
}
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
products.toArray(new ItemStack[products.size()]));
ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), productsArray);
}
/* REPRODUCTION */
@@ -496,12 +520,14 @@ public class Bee extends IndividualLiving implements IBee {
public IBee spawnPrincess(IBeeHousing housing) {
// We need a mated queen to produce offspring.
if (mate == null)
if (mate == null) {
return null;
}
// Fatigued queens do not produce princesses.
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing))
if (BeeManager.beeRoot.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) {
return null;
}
return createOffspring(housing, getGeneration() + 1);
}
@@ -512,16 +538,18 @@ public class Bee extends IndividualLiving implements IBee {
World world = housing.getWorld();
// We need a mated queen to produce offspring.
if (mate == null)
if (mate == null) {
return null;
}
ArrayList<IBee> bees = new ArrayList<IBee>();
int toCreate = PluginApiculture.beeInterface.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(),
int toCreate = BeeManager.beeRoot.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(),
housing.getZCoord());
if (toCreate <= 0)
if (toCreate <= 0) {
toCreate = 1;
}
for (int i = 0; i < toCreate; i++) {
IBee offspring = createOffspring(housing, 0);
@@ -531,10 +559,11 @@ public class Bee extends IndividualLiving implements IBee {
}
}
if (bees.size() > 0)
if (bees.size() > 0) {
return bees.toArray(new IBee[bees.size()]);
else
} else {
return null;
}
}
private IBee createOffspring(IBeeHousing housing, int generation) {
@@ -548,36 +577,33 @@ public class Bee extends IndividualLiving implements IBee {
// Check for mutation. Replace one of the parents with the mutation
// template if mutation occured.
IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
if (mutated1 != null)
if (mutated1 != null) {
parent1 = mutated1;
}
IChromosome[] mutated2 = mutateSpecies(housing, mate, genome);
if (mutated2 != null)
if (mutated2 != null) {
parent2 = mutated2;
}
for (int i = 0; i < parent1.length; i++)
if (parent1[i] != null && parent2[i] != null)
for (int i = 0; i < parent1.length; i++) {
if (parent1[i] != null && parent2[i] != null) {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
}
}
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
IBee offspring = new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
/* Disabling the mutation rate nerf
// All mutation and no play makes queen a dull girl.
if(mode.isDegenerating(this, offspring, housing))
offspring.setIsNatural(false);*/
return offspring;
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
}
private IChromosome[] mutateSpecies(IBeeHousing housing, IGenome genomeOne, IGenome genomeTwo) {
private static IChromosome[] mutateSpecies(IBeeHousing housing, IBeeGenome genomeOne, IBeeGenome genomeTwo) {
World world = housing.getWorld();
IChromosome[] parent1 = genomeOne.getChromosomes();
IChromosome[] parent2 = genomeTwo.getChromosomes();
IGenome genome0;
IGenome genome1;
IBeeGenome genome0;
IBeeGenome genome1;
IAllele allele0;
IAllele allele1;
@@ -595,12 +621,12 @@ public class Bee extends IndividualLiving implements IBee {
genome1 = genomeOne;
}
for (IBeeMutation mutation : PluginApiculture.beeInterface.getMutations(true)) {
for (IBeeMutation mutation : BeeManager.beeRoot.getMutations(true)) {
float chance = mutation.getChance(housing, allele0, allele1, genome0, genome1);
if (chance > world.rand.nextFloat() * 100) {
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
IApiaristTracker breedingTracker = BeeManager.beeRoot.getBreedingTracker(world, housing.getOwnerName());
breedingTracker.registerMutation(mutation);
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
return BeeManager.beeRoot.templateAsChromosomes(mutation.getTemplate());
}
}
@@ -617,8 +643,9 @@ public class Bee extends IndividualLiving implements IBee {
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance)
if (random.nextInt(100) >= chance) {
return null;
}
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
@@ -633,14 +660,16 @@ public class Bee extends IndividualLiving implements IBee {
if (tile instanceof IPollinatable) {
IPollinatable pitcher = (IPollinatable) tile;
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher))
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) {
pollen = pitcher.getPollen();
}
} else {
pollen = GeneticsUtil.getErsatzPollen(world, blockPos.x, blockPos.y, blockPos.z);
}
if (pollen != null)
if (pollen != null) {
return pollen;
}
}
return null;
@@ -655,8 +684,9 @@ public class Bee extends IndividualLiving implements IBee {
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance)
if (random.nextInt(100) >= chance) {
return false;
}
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
@@ -667,17 +697,24 @@ public class Bee extends IndividualLiving implements IBee {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
if(receiver == null)
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock.x, posBlock.y, posBlock.z);
if (checkPollinatable == null) {
continue;
}
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver))
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, new FakePollinatable(checkPollinatable))) {
continue;
if (!receiver.canMateWith(pollen))
}
if (!checkPollinatable.canMateWith(pollen)) {
continue;
}
receiver.mateWith(pollen);
return true;
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
if (realPollinatable != null) {
realPollinatable.mateWith(pollen);
return true;
}
}
return false;
@@ -692,8 +729,9 @@ public class Bee extends IndividualLiving implements IBee {
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance)
if (random.nextInt(100) >= chance) {
return;
}
// Gather required info
IFlowerProvider provider = genome.getFlowerProvider();
@@ -705,8 +743,9 @@ public class Bee extends IndividualLiving implements IBee {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z))
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) {
break;
}
}
}
@@ -0,0 +1,155 @@
package forestry.apiculture.genetics;
import java.util.Arrays;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
import forestry.core.genetics.alleles.Allele;
import forestry.core.genetics.alleles.EnumAllele;
public enum BeeBranchDefinition {
HONEY("Apis"),
NOBLE("Probapis"),
INDUSTRIOUS("Industrapis"),
HEROIC("Herapis"),
INFERNAL("Diapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.DOWN_2);
Allele.helper.set(alleles, EnumBeeChromosome.NOCTURNAL, true);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.NETHER);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.AVERAGE);
}
},
AUSTERE("Modapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.DOWN_1);
Allele.helper.set(alleles, EnumBeeChromosome.NOCTURNAL, true);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.CACTI);
}
},
TROPICAL("Caldapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.JUNGLE);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectMiasmic);
}
},
END("Finapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.END);
Allele.helper.set(alleles, EnumBeeChromosome.NOCTURNAL, true);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectMisanthrope);
}
},
FROZEN("Coagapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.SNOW);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectGlacial);
}
},
VENGEFUL("Punapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGEST);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectRadioactive);
}
},
FESTIVE("Festapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
}
},
AGRARIAN("Rustapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
}
},
BOGGY("Paludapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.MUSHROOMS);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
}
},
MONASTIC("Monapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
Allele.helper.set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.CAVE_DWELLING, true);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
}
}
;
private final IClassification branch;
BeeBranchDefinition(String scientific) {
branch = BeeManager.beeFactory.createBranch(this.name().toLowerCase(), scientific);
}
protected void setBranchProperties(IAllele[] template) {
}
public final IAllele[] getTemplate() {
IAllele[] template = getDefaultTemplate();
setBranchProperties(template);
return template;
}
public final IClassification getBranch() {
return branch;
}
private static IAllele[] defaultTemplate;
private static IAllele[] getDefaultTemplate() {
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
Allele.helper.set(defaultTemplate, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.NORMAL);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.NONE);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.NOCTURNAL, false);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.NONE);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.TOLERANT_FLYER, false);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.CAVE_DWELLING, false);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.VANILLA);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWEST);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.AVERAGE);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.EFFECT, Allele.effectNone);
}
return Arrays.copyOf(defaultTemplate, defaultTemplate.length);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
import forestry.api.apiculture.IBeeFactory;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IClassification;
public class BeeFactory implements IBeeFactory {
@Override
public IAlleleBeeSpeciesCustom createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
IAlleleBeeSpeciesCustom species = new AlleleBeeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor);
AlleleManager.alleleRegistry.registerAllele(species);
return species;
}
@Override
public IClassification createBranch(String uid, String scientific) {
return new BranchBees(uid, scientific);
}
}
@@ -4,61 +4,66 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleFloat;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.AlleleArea;
import forestry.core.genetics.AlleleBoolean;
import forestry.core.genetics.AlleleTolerance;
import forestry.core.genetics.Chromosome;
import forestry.core.genetics.Genome;
import forestry.core.genetics.alleles.AlleleArea;
import forestry.core.genetics.alleles.AlleleBoolean;
import forestry.core.genetics.alleles.AlleleTolerance;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class BeeGenome extends Genome implements IBeeGenome {
/**
* 0 - Species (determines product)
*
*
* 1 - Speed
*
*
* 2 - Lifespan
*
*
* 3 - Fertility (Maximum number of offspring)
*
*
* 4 - Preferred temperature Icy: Snow biomes Cold: Tundra/Steppe, Extreme Mountains/Hills? Normal: Plains, Forests, Mountains Hot: Desert Hellish: Nether
*
*
* 5 - Temperature tolerance (Range +/-)
*
*
* 6 - Nocturnal
*
*
* 7 - Preferred humidity (Arid - Normal - Damp)
*
*
* 8 - Humidity tolerance (Range +/-)
*
*
* 9 - Flight interference tolerance (stuff falling from the sky/other hindrances -> tolerates dampness + flight interference tolerance => rain resistance)
*
*
* 10 - Cave dwelling
*
*
* 11 - Required flowers
*
*
* 12 - Flower plant chance
*
*
* 13 - Territory
*/
/* CONSTRUCTOR */
@@ -72,11 +77,16 @@ public class BeeGenome extends Genome implements IBeeGenome {
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleBeeSpecies)
return (IAlleleBeeSpecies)speciesAllele;
else
if (!BeeManager.beeRoot.isMember(itemStack)) {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(itemStack);
if (species instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) species;
}
return (IAlleleBeeSpecies) getActiveAllele(itemStack, EnumBeeChromosome.SPECIES, BeeManager.beeRoot);
}
// / INFORMATION RETRIEVAL
@@ -143,7 +153,7 @@ public class BeeGenome extends Genome implements IBeeGenome {
@Override
public int[] getTerritory() {
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea();
return new int[] { area.x, area.y, area.z };
return new int[]{area.x, area.y, area.z};
}
@Override
@@ -153,6 +163,6 @@ public class BeeGenome extends Genome implements IBeeGenome {
@Override
public ISpeciesRoot getSpeciesRoot() {
return PluginApiculture.beeInterface;
return BeeManager.beeRoot;
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -25,6 +25,7 @@ import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -69,9 +70,11 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
if (beeSpeciesCount < 0) {
beeSpeciesCount = 0;
for (Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
if (entry.getValue() instanceof IAlleleBeeSpecies)
if (((IAlleleBeeSpecies) entry.getValue()).isCounted())
if (entry.getValue() instanceof IAlleleBeeSpecies) {
if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) {
beeSpeciesCount++;
}
}
}
}
@@ -95,25 +98,26 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public ItemStack getMemberStack(IIndividual bee, int type) {
if (!isMember(bee))
if (!isMember(bee)) {
return null;
}
Item beeItem;
switch (EnumBeeType.VALUES[type]) {
case QUEEN:
beeItem = ForestryItem.beeQueenGE.item();
break;
case PRINCESS:
beeItem = ForestryItem.beePrincessGE.item();
break;
case DRONE:
beeItem = ForestryItem.beeDroneGE.item();
break;
case LARVAE:
beeItem = ForestryItem.beeLarvaeGE.item();
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
case QUEEN:
beeItem = ForestryItem.beeQueenGE.item();
break;
case PRINCESS:
beeItem = ForestryItem.beePrincessGE.item();
break;
case DRONE:
beeItem = ForestryItem.beeDroneGE.item();
break;
case LARVAE:
beeItem = ForestryItem.beeLarvaeGE.item();
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -125,17 +129,19 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public EnumBeeType getType(ItemStack stack) {
if (stack == null)
if (stack == null) {
return EnumBeeType.NONE;
}
if (ForestryItem.beeDroneGE.isItemEqual(stack))
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
return EnumBeeType.DRONE;
else if (ForestryItem.beePrincessGE.isItemEqual(stack))
} else if (ForestryItem.beePrincessGE.isItemEqual(stack)) {
return EnumBeeType.PRINCESS;
else if (ForestryItem.beeQueenGE.isItemEqual(stack))
} else if (ForestryItem.beeQueenGE.isItemEqual(stack)) {
return EnumBeeType.QUEEN;
else if (ForestryItem.beeLarvaeGE.isItemEqual(stack))
} else if (ForestryItem.beeLarvaeGE.isItemEqual(stack)) {
return EnumBeeType.LARVAE;
}
return EnumBeeType.NONE;
}
@@ -147,17 +153,19 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public boolean isMated(ItemStack stack) {
if (getType(stack) != EnumBeeType.QUEEN)
if (getType(stack) != EnumBeeType.QUEEN) {
return false;
}
IBee bee = getMember(stack);
return bee.getMate() != null;
NBTTagCompound nbt = stack.getTagCompound();
return nbt != null && nbt.hasKey("Mate");
}
@Override
public IBee getMember(ItemStack stack) {
if (!isMember(stack))
if (!isMember(stack)) {
return null;
}
return new Bee(stack.getTagCompound());
}
@@ -208,36 +216,40 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public void registerTemplate(String identifier, IAllele[] template) {
beeTemplates.add(new Bee(PluginApiculture.beeInterface.templateAsGenome(template)));
beeTemplates.add(new Bee(BeeManager.beeRoot.templateAsGenome(template)));
speciesTemplates.put(identifier, template);
}
@Override
public IAllele[] getDefaultTemplate() {
return BeeTemplates.getDefaultTemplate();
return BeeDefinition.FOREST.getTemplate();
}
/* MUTATIONS */
/**
* List of possible mutations on species alleles.
*/
private static ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
@Override
public Collection<IBeeMutation> getMutations(boolean shuffle) {
if (shuffle)
if (shuffle) {
Collections.shuffle(beeMutations);
}
return beeMutations;
}
@Override
public void registerMutation(IMutation mutation) {
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID()))
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) {
return;
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID()))
}
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) {
return;
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID()))
}
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) {
return;
}
beeMutations.add((IBeeMutation) mutation);
}
@@ -258,14 +270,16 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBeekeepingMode getBeekeepingMode(World world) {
if (activeBeekeepingMode != null)
if (activeBeekeepingMode != null) {
return activeBeekeepingMode;
}
// No beekeeping mode yet, get it.
IApiaristTracker tracker = getBreedingTracker(world, null);
String mode = tracker.getModeName();
if (mode == null || mode.isEmpty())
if (mode == null || mode.isEmpty()) {
mode = PluginApiculture.beekeepingMode;
}
setBeekeepingMode(world, mode);
FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode);
@@ -287,8 +301,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBeekeepingMode getBeekeepingMode(String name) {
for (IBeekeepingMode mode : beekeepingModes) {
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH)))
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) {
return mode;
}
}
FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a beekeeping mode called '%s', reverting to fallback.");
@@ -4,120 +4,65 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.genetics.Mutation;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
public class BeeMutation extends Mutation implements IBeeMutation {
public class BeeMutation extends Mutation implements IBeeMutationCustom {
private final IBeeRoot root;
boolean requiresDay = false;
boolean requiresNight = false;
private final ArrayList<BiomeDictionary.Type> restrictBiomeTypes = new ArrayList<BiomeDictionary.Type>();
private boolean strictBiomeCheck = false;
public BeeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) {
super(allele0, allele1, template, chance);
root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
PluginApiculture.beeInterface.registerMutation(this);
public BeeMutation(IAlleleBeeSpecies bee0, IAlleleBeeSpecies bee1, IAllele[] result, int chance) {
super(bee0, bee1, result, chance);
}
@Override
public IBeeRoot getRoot() {
return root;
}
public BeeMutation enableStrictBiomeCheck() {
strictBiomeCheck = true;
return this;
}
public BeeMutation restrictBiomeType(BiomeDictionary.Type type) {
restrictBiomeTypes.add(type);
specialConditions.add(String.format("Is restricted to %s-like environments.", type.toString()));
return this;
}
public BeeMutation requireDay() {
requiresDay = true;
requiresNight = false;
specialConditions.add("Can only occur during the day.");
return this;
}
public BeeMutation requireNight() {
requiresDay = false;
requiresNight = true;
specialConditions.add("Can only occur during the night.");
return this;
return BeeManager.beeRoot;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
return getChance(housing, (IAlleleBeeSpecies) allele0, (IAlleleBeeSpecies) allele1, (IBeeGenome) genome0, (IBeeGenome) genome1);
}
@Override
public float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1) {
World world = housing.getWorld();
if (requiresDay && !world.isDaytime())
int x = housing.getXCoord();
int y = housing.getYCoord();
int z = housing.getZCoord();
float processedChance = super.getChance(world, x, y, z, allele0, allele1, genome0, genome1);
if (processedChance <= 0) {
return 0;
if (requiresNight && world.isDaytime())
return 0;
// Skip if we are restricted by biomes and this one does not match.
if (restrictBiomeTypes.size() > 0) {
boolean noneMatched = true;
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if(strictBiomeCheck) {
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
if(types.length == 1 && restrictBiomeTypes.contains(types[0]))
noneMatched = false;
} else {
for(BiomeDictionary.Type type : restrictBiomeTypes) {
if(BiomeDictionary.isBiomeOfType(biome, type)) {
noneMatched = false;
break;
}
}
}
if (noneMatched)
return 0;
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(housing.getXCoord(), housing.getZCoord());
if (biome.temperature < minTemperature || biome.temperature > maxTemperature)
return 0;
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall)
processedChance *= housing.getMutationModifier(genome0, genome1, 1f);
processedChance *= BeeManager.beeRoot.getBeekeepingMode(world).getMutationModifier(genome0, genome1, 1f);
if (processedChance <= 0) {
return 0;
}
float processedChance = chance * housing.getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f)
* PluginApiculture.beeInterface.getBeekeepingMode(world).getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f);
if(processedChance <= 0)
return 0;
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID()))
if (this.species0.getUID().equals(allele0.getUID()) && this.species1.getUID().equals(allele1.getUID())) {
return processedChance;
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID()))
}
if (this.species1.getUID().equals(allele0.getUID()) && this.species0.getUID().equals(allele1.getUID())) {
return processedChance;
}
return 0;
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutationFactory;
import forestry.api.genetics.IAllele;
public class BeeMutationFactory implements IBeeMutationFactory {
@Override
public IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance) {
IBeeMutationCustom mutation = new BeeMutation(parentBee0, parentBee1, result, chance);
BeeManager.beeRoot.registerMutation(mutation);
return mutation;
}
}
@@ -1,639 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IMutation;
import forestry.core.genetics.Allele;
import java.util.Arrays;
public class BeeTemplates {
// / MUTATIONS
public static IMutation commonA;
public static IMutation commonB;
public static IMutation commonC;
public static IMutation commonD;
public static IMutation commonE;
public static IMutation commonF;
public static IMutation commonG;
public static IMutation commonH;
public static IMutation commonI;
public static IMutation commonJ;
public static IMutation commonK;
public static IMutation commonL;
public static IMutation commonM;
public static IMutation commonN;
public static IMutation commonO;
public static IMutation cultivatedA;
public static IMutation cultivatedB;
public static IMutation cultivatedC;
public static IMutation cultivatedD;
public static IMutation cultivatedE;
public static IMutation cultivatedF;
public static IMutation nobleA;
public static IMutation majesticA;
public static IMutation imperialA;
public static IMutation diligentA;
public static IMutation unwearyA;
public static IMutation industriousA;
public static IMutation heroicA;
public static IMutation sinisterA;
public static IMutation sinisterB;
public static IMutation fiendishA;
public static IMutation fiendishB;
public static IMutation fiendishC;
public static IMutation demonicA;
// Austere branch
public static IMutation frugalA;
public static IMutation frugalB;
public static IMutation austereA;
// Tropical branch
public static IMutation exoticA;
public static IMutation edenicA;
// Wintry branch
public static IMutation icyA;
public static IMutation glacialA;
// Festive branch
public static IMutation leporineA;
public static IMutation merryA;
public static IMutation tipsyA;
public static IMutation trickyA;
// Agrarian branch
public static IMutation ruralA;
// Monastic branch
public static IMutation secludedA;
public static IMutation hermiticA;
// End branch
public static IMutation spectralA;
public static IMutation phantasmalA;
public static IMutation vindictiveA;
public static IMutation vengefulA;
public static IMutation vengefulB;
public static IMutation avengingA;
public static IAllele[] defaultTemplate;
public static IAllele[] getDefaultTemplate() {
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
defaultTemplate[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesForest;
defaultTemplate[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
defaultTemplate[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
defaultTemplate[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityNormal;
defaultTemplate[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceNone;
defaultTemplate[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolFalse;
defaultTemplate[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceNone;
defaultTemplate[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolFalse;
defaultTemplate[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolFalse;
defaultTemplate[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersVanilla;
defaultTemplate[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlowest;
defaultTemplate[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryDefault;
defaultTemplate[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectNone;
}
return Arrays.copyOf(defaultTemplate, defaultTemplate.length);
}
// / COMMON BRANCH
public static IAllele[] getForestTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityHigh;
return alleles;
}
public static IAllele[] getForestRainResistTemplate() {
IAllele[] alleles = getForestTemplate();
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getMeadowsTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMeadows;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
return alleles;
}
public static IAllele[] getCommonTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesCommon;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
return alleles;
}
public static IAllele[] getCultivatedTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesCultivated;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedFast;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShortest;
return alleles;
}
// / NOBLE BRANCH
public static IAllele[] getNobleTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesNoble;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlow;
return alleles;
}
public static IAllele[] getMajesticTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMajestic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShortened;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
return alleles;
}
public static IAllele[] getImperialTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesImperial;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectBeatific;
return alleles;
}
// / INDUSTRIOUS BRANCH
public static IAllele[] getDiligentTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesDiligent;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlow;
return alleles;
}
public static IAllele[] getUnwearyTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesUnweary;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShortened;
return alleles;
}
public static IAllele[] getIndustriousTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesIndustrious;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFast;
return alleles;
}
// / HEROIC BRANCH
public static IAllele[] getSteadfastTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSteadfast;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getValiantTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesValiant;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getHeroicTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesHeroic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectHeroic;
return alleles;
}
// / INFERNAL BRANCH
public static IAllele[] getBranchInfernalTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceDown2;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersNether;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringAverage;
return alleles;
}
public static IAllele[] getSinisterTemplate() {
IAllele[] alleles = getBranchInfernalTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSinister;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectAggressive;
return alleles;
}
public static IAllele[] getFiendishTemplate() {
IAllele[] alleles = getBranchInfernalTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFiendish;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectAggressive;
return alleles;
}
public static IAllele[] getDemonicTemplate() {
IAllele[] alleles = getBranchInfernalTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesDemonic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectIgnition;
return alleles;
}
// / AUSTERE BRANCH
public static IAllele[] getAustereBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersCacti;
return alleles;
}
public static IAllele[] getModestTemplate() {
IAllele[] alleles = getAustereBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesModest;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
public static IAllele[] getFrugalTemplate() {
IAllele[] alleles = getAustereBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFrugal;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
return alleles;
}
public static IAllele[] getAustereTemplate() {
IAllele[] alleles = getAustereBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesAustere;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceDown2;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectCreeper;
return alleles;
}
// / TROPICAL BRANCH
public static IAllele[] getTropicalBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersJungle;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMiasmic;
return alleles;
}
public static IAllele[] getTropicalTemplate() {
IAllele[] alleles = getTropicalBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesTropical;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
public static IAllele[] getExoticTemplate() {
IAllele[] alleles = getTropicalBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesExotic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
return alleles;
}
public static IAllele[] getEdenicTemplate() {
IAllele[] alleles = getTropicalBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesEdenic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectExploration;
return alleles;
}
// / END BRANCH
public static IAllele[] getEndBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityLow;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersEnd;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMisanthrope;
return alleles;
}
public static IAllele[] getEnderTemplate() {
IAllele[] alleles = getEndBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesEnded;
return alleles;
}
public static IAllele[] getSpectralTemplate() {
IAllele[] alleles = getEndBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSpectral;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectReanimation;
return alleles;
}
public static IAllele[] getPhantasmalTemplate() {
IAllele[] alleles = getEndBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesPhantasmal;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLongest;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectResurrection;
return alleles;
}
// / FROZEN BRANCH
public static IAllele[] getFrozenBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersSnow;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectGlacial;
return alleles;
}
public static IAllele[] getWintryTemplate() {
IAllele[] alleles = getFrozenBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesWintry;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
return alleles;
}
public static IAllele[] getIcyTemplate() {
IAllele[] alleles = getFrozenBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesIcy;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
public static IAllele[] getGlacialTemplate() {
IAllele[] alleles = getFrozenBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesGlacial;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
// / VENGEFUL BRANCH
public static IAllele[] getVengefulBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLargest;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectRadioactive;
return alleles;
}
public static IAllele[] getVindictiveTemplate() {
IAllele[] alleles = getVengefulBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesVindictive;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
return alleles;
}
public static IAllele[] getVengefulTemplate() {
IAllele[] alleles = getVengefulBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesVengeful;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
return alleles;
}
public static IAllele[] getAvengingTemplate() {
IAllele[] alleles = getVengefulBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesAvenging;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLongest;
return alleles;
}
// / REDDENED BRANCH
public static IAllele[] getReddenedBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
return alleles;
}
public static IAllele[] getDarkenedTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesDarkened;
return alleles;
}
public static IAllele[] getReddenedTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesReddened;
return alleles;
}
public static IAllele[] getOmegaTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesOmega;
return alleles;
}
// / FESTIVE BRANCH
public static IAllele[] getFestiveBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
return alleles;
}
public static IAllele[] getLeporineTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesLeporine;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectFestiveEaster;
return alleles;
}
public static IAllele[] getMerryTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMerry;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectSnowing;
return alleles;
}
public static IAllele[] getTipsyTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesTipsy;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectDrunkard;
return alleles;
}
public static IAllele[] getTrickyTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesTricky;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersGourd;
return alleles;
}
// / AGRARIAN BRANCH
public static IAllele[] getAgrarianBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersWheat;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFaster;
return alleles;
}
public static IAllele[] getRuralTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesRural;
return alleles;
}
public static IAllele[] getFarmerlyTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFarmerly;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
return alleles;
}
public static IAllele[] getAgrarianTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesArgrarian;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectFertile;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
return alleles;
}
// / BOGGY BRANCH
public static IAllele[] getBoggyBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersMushrooms;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
return alleles;
}
public static IAllele[] getMarshyTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMarshy;
return alleles;
}
public static IAllele[] getMiryTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMiry;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getBoggyTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesBoggy;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger;
return alleles;
}
/* MONASTIC BRANCH */
public static IAllele[] getMonasticBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityLow;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFaster;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersWheat;
return alleles;
}
public static IAllele[] getMonasticTemplate() {
IAllele[] alleles = getMonasticBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMonastic;
return alleles;
}
public static IAllele[] getSecludedTemplate() {
IAllele[] alleles = getMonasticBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSecluded;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFastest;
return alleles;
}
public static IAllele[] getHermiticTemplate() {
IAllele[] alleles = getMonasticBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesHermitic;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFastest;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectRepulsion;
return alleles;
}
}
@@ -0,0 +1,57 @@
package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.IAllele;
import forestry.core.genetics.alleles.Allele;
public abstract class BeeVariation implements IBeeDefinition {
private final IAllele[] template;
private final IBeeGenome genome;
public BeeVariation(IBeeDefinition bee) {
template = bee.getTemplate();
initializeTemplate(template);
genome = BeeManager.beeRoot.templateAsGenome(template);
}
protected abstract void initializeTemplate(IAllele[] template);
@Override
public IAllele[] getTemplate() {
return template;
}
@Override
public IBeeGenome getGenome() {
return genome;
}
@Override
public IBee getIndividual() {
return new Bee(genome);
}
@Override
public final ItemStack getMemberStack(EnumBeeType beeType) {
IBee bee = getIndividual();
return BeeManager.beeRoot.getMemberStack(bee, beeType.ordinal());
}
public static class RainResist extends BeeVariation {
public RainResist(IBeeDefinition bee) {
super(bee);
}
@Override
protected void initializeTemplate(IAllele[] template) {
Allele.helper.set(template, EnumBeeChromosome.TOLERANT_FLYER, true);
}
}
}
@@ -4,20 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Random;
import net.minecraft.world.World;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingMode;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Random;
import net.minecraft.world.World;
public class BeekeepingMode implements IBeekeepingMode {
@@ -96,23 +98,27 @@ public class BeekeepingMode implements IBeekeepingMode {
public int getFinalFertility(IBee queen, World world, int x, int y, int z) {
int toCreate = queen.getGenome().getFertility();
if (reducesFertility)
if (reducesFertility) {
toCreate = new Random().nextInt(toCreate);
}
return toCreate;
}
@Override
public boolean isFatigued(IBee queen, IBeeHousing housing) {
if (!canFatigue)
if (!canFatigue) {
return false;
}
if (queen.isNatural())
if (queen.isNatural()) {
return false;
}
if (queen.getGeneration() > 96 + rand.nextInt(6) + rand.nextInt(6) &&
rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f))
rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f)) {
return true;
}
return false;
}
@@ -120,9 +126,10 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isOverworked(IBee queen, IBeeHousing housing) {
float productionModifier = housing.getProductionModifier(queen.getGenome(), 1f);
if(productionModifier > 16) {
if(housing.getWorld().rand.nextFloat()*100 < 0.01 * ((productionModifier*productionModifier) - 100))
if (productionModifier > 16) {
if (housing.getWorld().rand.nextFloat() * 100 < 0.01 * ((productionModifier * productionModifier) - 100)) {
return true;
}
}
return false;
@@ -131,9 +138,10 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing) {
float mutationModifier = housing.getMutationModifier(queen.getGenome(), queen.getMate(), 1.0f);
if(mutationModifier > 10) {
if(housing.getWorld().rand.nextFloat()*100 < 0.4 * ((mutationModifier*mutationModifier) - 100))
if (mutationModifier > 10) {
if (housing.getWorld().rand.nextFloat() * 100 < 0.4 * ((mutationModifier * mutationModifier) - 100)) {
return true;
}
}
return false;
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,31 +4,33 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.genetics.IAllele;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IHiveDrop;
public class HiveDrop implements IHiveDrop {
private final IAllele[] template;
private final IBeeDefinition beeTemplate;
private final ArrayList<ItemStack> additional = new ArrayList<ItemStack>();
private final int chance;
private float ignobleShare = 0.0f;
public HiveDrop(IAllele[] template, ItemStack[] bonus, int chance) {
this.template = template;
public HiveDrop(int chance, IBeeDefinition beeTemplate, ItemStack... bonus) {
this.beeTemplate = beeTemplate;
this.chance = chance;
Collections.addAll(this.additional, bonus);
@@ -39,31 +41,28 @@ public class HiveDrop implements IHiveDrop {
return this;
}
private IBee createBee(World world) {
return PluginApiculture.beeInterface.getBee(world, PluginApiculture.beeInterface.templateAsGenome(template));
}
@Override
public ItemStack getPrincess(World world, int x, int y, int z, int fortune) {
IBee bee = createBee(world);
if(world.rand.nextFloat() < ignobleShare)
IBee bee = beeTemplate.getIndividual();
if (world.rand.nextFloat() < ignobleShare) {
bee.setIsNatural(false);
}
return PluginApiculture.beeInterface.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal());
return BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal());
}
@Override
public ArrayList<ItemStack> getDrones(World world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(PluginApiculture.beeInterface.getMemberStack(createBee(world), EnumBeeType.DRONE.ordinal()));
return ret;
public List<ItemStack> getDrones(World world, int x, int y, int z, int fortune) {
ItemStack drone = beeTemplate.getMemberStack(EnumBeeType.DRONE);
return Collections.singletonList(drone);
}
@Override
public ArrayList<ItemStack> getAdditional(World world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
for (ItemStack stack : additional)
for (ItemStack stack : additional) {
ret.add(stack.copy());
}
return ret;
}
@@ -0,0 +1,18 @@
package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.core.genetics.IGeneticDefinition;
public interface IBeeDefinition extends IGeneticDefinition {
@Override
IBeeGenome getGenome();
@Override
IBee getIndividual();
ItemStack getMemberStack(EnumBeeType beeType);
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -13,34 +13,31 @@ package forestry.apiculture.genetics;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.vect.Vect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.biome.BiomeGenBase;
public class JubilanceDefault implements IJubilanceProvider {
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
private static JubilanceDefault instance;
if (EnumTemperature.getFromValue(biome.temperature) != species.getTemperature() ||
EnumHumidity.getFromValue(biome.rainfall) != species.getHumidity())
return false;
return true;
public static JubilanceDefault getInstance() {
if (instance == null) {
instance = new JubilanceDefault();
}
return instance;
}
protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
protected JubilanceDefault() {
Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
}
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
EnumTemperature temperature = housing.getTemperature();
EnumHumidity humidity = housing.getHumidity();
return temperature == species.getTemperature() && humidity == species.getHumidity();
}
}
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import forestry.api.apiculture.IJubilanceFactory;
import forestry.api.apiculture.IJubilanceProvider;
public class JubilanceFactory implements IJubilanceFactory {
@Override
public IJubilanceProvider getDefault() {
return JubilanceDefault.getInstance();
}
@Override
public IJubilanceProvider getRequiresResource(Block block, int meta) {
return new JubilanceRequiresResource(block, meta);
}
}
@@ -4,18 +4,21 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.AxisAlignedBB;
import forestry.core.vect.Vect;
/**
* Hermits will not produce if there are any other living creatures nearby.
@@ -24,11 +27,22 @@ public class JubilanceProviderHermit extends JubilanceDefault {
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
AxisAlignedBB bounding = this.getBounding(genome, housing, 1.0f);
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityLiving.class, bounding);
return list.size() <= 0;
}
private static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
}
}
@@ -4,34 +4,32 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.core.utils.StackUtils;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class JubilanceReqRes implements IJubilanceProvider {
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.core.utils.StackUtils;
public class JubilanceRequiresResource implements IJubilanceProvider {
private final ItemStack blockRequired;
public JubilanceReqRes(ItemStack blockRequired) {
this.blockRequired = blockRequired;
public JubilanceRequiresResource(Block block, int meta) {
this.blockRequired = new ItemStack(block, meta);
}
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
if (blockRequired == null)
return true;
World world = housing.getWorld();
Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
@@ -1,94 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
import java.lang.reflect.Field;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class MutationEMC extends MutationReqRes {
private final int emcRequired;
private final Class<?> condenserClass;
private final Field emcField;
public MutationEMC(IAllele allele0, IAllele allele1, IAllele[] template, int chance, ItemStack blockRequired, Class<?> condenserClass, Field emcField,
int emcRequired) {
super(allele0, allele1, template, chance, blockRequired);
this.condenserClass = condenserClass;
this.emcField = emcField;
this.emcRequired = emcRequired;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
// If we don't have any chance, return at once.
if (chance <= 0)
return 0;
if (emcRequired <= 0)
return chance;
World world = housing.getWorld();
Vect[] possibleTargets = new Vect[] { new Vect(housing.getXCoord() + 1, housing.getYCoord(), housing.getZCoord()),
new Vect(housing.getXCoord() - 1, housing.getYCoord(), housing.getZCoord()),
new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() + 1),
new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() - 1) };
for (Vect target : possibleTargets) {
if (!world.blockExists(target.x, target.y, target.z))
continue;
TileEntity entity = world.getTileEntity(target.x, target.y, target.z);
if (entity == null)
continue;
if (!condenserClass.isInstance(entity)) {
Proxies.log.warning("Did not find a relay at " + target.toString());
continue;
}
int emc = 0;
try {
emc = emcField.getInt(entity);
} catch (Exception ex) {
Proxies.log.warning("Failed to fetch EMC information.");
}
if (emc < emcRequired * 80)
continue;
boolean removedEMC = false;
try {
emcField.set(entity, emc - (emcRequired * 80));
removedEMC = true;
} catch (Exception ex) {
Proxies.log.warning("Failed to set EMC information.");
}
if (removedEMC)
return chance;
}
return 0;
}
}
@@ -1,49 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.utils.StackUtils;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class MutationReqRes extends BeeMutation {
private final ItemStack blockRequired;
public MutationReqRes(IAllele allele0, IAllele allele1, IAllele[] template, int chance, ItemStack blockRequired) {
super(allele0, allele1, template, chance);
this.blockRequired = blockRequired;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
// If we have no chance anyway, we don't need to check.
if (chance <= 0)
return 0;
World world = housing.getWorld();
if (blockRequired == null)
return chance;
Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
int meta = world.getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage())
return chance;
else
return 0;
}
}
@@ -1,140 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import java.util.Calendar;
public class MutationTimeLimited extends BeeMutation {
/**
* Fed up with Date and Calendar and their shenanigans
*/
public static class DayMonth {
public final int day;
public final int month;
public DayMonth() {
this.day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
this.month = Calendar.getInstance().get(Calendar.MONTH) + 1;
}
public DayMonth(int day, int month) {
this.day = day;
this.month = month;
}
public boolean between(DayMonth start, DayMonth end) {
if (equals(start) || equals(end))
return true;
if (start.month > end.month)
return after(start) || before(end);
return after(start) && before(end);
}
public boolean before(DayMonth other) {
if (other.month > this.month)
return true;
if (other.month < this.month)
return false;
return this.day < other.day;
}
public boolean after(DayMonth other) {
if (other.month < this.month)
return true;
if (other.month > this.month)
return false;
return this.day > other.day;
}
@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + this.day;
hash = 89 * hash + this.month;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final DayMonth other = (DayMonth) obj;
if (this.day != other.day)
return false;
if (this.month != other.month)
return false;
return true;
}
@Override
public String toString() {
return day + "." + month;
}
}
private final DayMonth start;
private final DayMonth end;
public MutationTimeLimited(IAllele allele0, IAllele allele1, IAllele[] template, int chance, DayMonth start) {
this(allele0, allele1, template, chance, start, null);
}
public MutationTimeLimited(IAllele allele0, IAllele allele1, IAllele[] template, int chance, DayMonth start, DayMonth end) {
super(allele0, allele1, template, chance);
this.start = start;
this.end = end;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
if (chance == 0)
return 0;
if (start == null)
return chance;
DayMonth now = new DayMonth();
// If we are equal to start day, return chance.
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == start.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == start.month)
return chance;
// Still here but not time span? No mutation!
if (end == null)
return 0;
// Equal to end date, return chance.
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == end.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == end.month)
return chance;
// Still a chance we are in between
if (now.between(start, end))
return chance;
// Now we finally failed.
return 0;
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -12,22 +12,16 @@ package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearyPlain;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerAlveary extends ContainerForestry {
private final TileAlvearyPlain tile;
public class ContainerAlveary extends ContainerTile<TileAlvearyPlain> {
public ContainerAlveary(InventoryPlayer player, TileAlvearyPlain tile) {
super(tile);
this.tile = tile;
tile.sendNetworkUpdate();
super(tile, player, 8, 108);
// Queen/Princess
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39));
@@ -43,14 +37,6 @@ public class ContainerAlveary extends ContainerForestry {
this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65));
this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39));
this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26));
// Player inventory
for (int i = 0; i < 3; i++)
for (int j = 0; j < 9; j++)
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18));
// Player hotbar
for (int i = 0; i < 9; i++)
addSlotToContainer(new Slot(player, i, 8 + i * 18, 166));
}
@Override
@@ -61,8 +47,8 @@ public class ContainerAlveary extends ContainerForestry {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (Object crafter : crafters)
for (Object crafter : crafters) {
tile.sendGUINetworkData(this, (ICrafting) crafter);
}
}
}
@@ -4,33 +4,24 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
import forestry.core.gui.ContainerLiquidTanks;
import forestry.core.gui.slots.SlotFiltered;
public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks {
public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks<TileAlvearyHygroregulator> {
public ContainerAlvearyHygroregulator(IInventory playerInventory, TileAlvearyHygroregulator tile) {
super(tile);
public ContainerAlvearyHygroregulator(InventoryPlayer playerInventory, TileAlvearyHygroregulator tile) {
super(tile, playerInventory, 8, 84);
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyHygroregulator.SLOT_INPUT, 56, 38));
for (int i = 0; i < 3; ++i)
for (int var4 = 0; var4 < 9; ++var4)
this.addSlotToContainer(new Slot(playerInventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18));
for (int i = 0; i < 9; ++i)
this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142));
}
}
@@ -4,24 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearySieve;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerAlvearySieve extends ContainerForestry {
public class ContainerAlvearySieve extends ContainerTile<TileAlvearySieve> {
public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) {
super(tile);
super(tile, player, 8, 87);
addSlotToContainer(new SlotOutput(tile, 0, 94, 52).setCrafter(tile));
addSlotToContainer(new SlotOutput(tile, 1, 115, 39).setCrafter(tile));
@@ -29,18 +28,5 @@ public class ContainerAlvearySieve extends ContainerForestry {
addSlotToContainer(new SlotOutput(tile, 3, 94, 26).setCrafter(tile));
addSlotToContainer(new SlotFiltered(tile, TileAlvearySieve.SLOT_SIEVE, 43, 39).setCrafter(tile));
// Player inventory
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
}
}
// Player hotbar
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(player, i, 8 + i * 18, 145));
}
}
}
@@ -4,36 +4,26 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearySwarmer;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
public class ContainerAlvearySwarmer extends ContainerForestry {
public class ContainerAlvearySwarmer extends ContainerTile<TileAlvearySwarmer> {
public ContainerAlvearySwarmer(InventoryPlayer player, TileAlvearySwarmer tile) {
super(tile);
super(tile, player, 8, 87);
this.addSlotToContainer(new SlotFiltered(tile, 0, 79, 52));
this.addSlotToContainer(new SlotFiltered(tile, 1, 100, 39));
this.addSlotToContainer(new SlotFiltered(tile, 2, 58, 39));
this.addSlotToContainer(new SlotFiltered(tile, 3, 79, 26));
// Player inventory
for (int i = 0; i < 3; i++)
for (int j = 0; j < 9; j++)
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
// Player hotbar
for (int i = 0; i < 9; i++)
addSlotToContainer(new Slot(player, i, 8 + i * 18, 145));
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -12,22 +12,16 @@ package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileBeehouse;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerApiary extends ContainerForestry {
private final TileBeehouse tile;
public class ContainerApiary extends ContainerTile<TileBeehouse> {
public ContainerApiary(InventoryPlayer player, TileBeehouse tile, boolean hasFrames) {
super(tile);
this.tile = tile;
tile.sendNetworkUpdate();
super(tile, player, 8, 108);
// Queen/Princess
this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_QUEEN, 29, 39));
@@ -50,17 +44,6 @@ public class ContainerApiary extends ContainerForestry {
this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65));
this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39));
this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26));
// Player inventory
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18));
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++) {
addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 166));
}
}
@Override
@@ -4,30 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import forestry.apiculture.items.ItemBiomefinder;
import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory;
import forestry.core.config.ForestryItem;
import net.minecraft.entity.player.EntityPlayer;
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
import forestry.core.gui.ContainerItemInventory;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.proxy.Proxies;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import forestry.core.gui.slots.SlotOutput;
public class ContainerHabitatLocator extends ContainerItemInventory {
public class ContainerHabitatLocator extends ContainerItemInventory<HabitatLocatorInventory> {
public final BiomefinderInventory inventory;
public ContainerHabitatLocator(InventoryPlayer inventoryplayer, BiomefinderInventory inventory) {
super(inventory, inventoryplayer.player);
this.inventory = inventory;
public ContainerHabitatLocator(EntityPlayer player, HabitatLocatorInventory inventory) {
super(inventory, player.inventory, 8, 102);
// Energy
this.addSlotToContainer(new SlotFiltered(inventory, 2, 152, 8));
@@ -35,36 +28,6 @@ public class ContainerHabitatLocator extends ContainerItemInventory {
// Bee to analyze
this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 32));
// Analyzed bee
this.addSlotToContainer(new SlotFiltered(inventory, 1, 152, 75));
// Player inventory
for (int i1 = 0; i1 < 3; i1++)
for (int l1 = 0; l1 < 9; l1++)
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 102 + i1 * 18);
// Player hotbar
for (int j1 = 0; j1 < 9; j1++)
addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 160);
this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 75));
}
@Override
public void onContainerClosed(EntityPlayer entityplayer) {
if (!Proxies.common.isSimulating(entityplayer.worldObj))
return;
((ItemBiomefinder) ForestryItem.biomeFinder.item()).startBiomeSearch(entityplayer.worldObj, entityplayer, inventory.biomesToSearch);
for (int i = 0; i < inventory.getSizeInventory() - 1; i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null)
continue;
Proxies.common.dropItemPlayer(entityplayer, stack);
inventory.setInventorySlotContents(i, null);
}
inventory.onGuiSaved(entityplayer);
}
}
Loaded 100 of 923 files, more files were not shown because too many files have changed in this diff. Show more