Compare commits

..
275 Commits
Author SHA1 Message Date
CovertJaguar fcad67a1c2 Update lang 2015-01-29 14:45:38 -08:00
mezz 1bd3b61df9 Fix #480 Increase hive spawn rate 25%, add config option for spawn rate
(cherry picked from commit 56dfae034d)

Conflicts:
	src/main/java/forestry/apiculture/worldgen/HiveDecorator.java
2015-01-29 00:11:35 -08:00
mezz 060ca1eb80 Fix #479 Try to make sure hives are always glowing
(cherry picked from commit 636201ce5a)
2015-01-29 00:09:47 -08:00
mezz 98a2d9c65e Fix bee biome temperature check for nether biomes
(cherry picked from commit c3f37a379a)
2015-01-25 22:26:39 -08:00
mezz eb010094ca Fix crash from missing block when a plugin mod is uninstalled
(cherry picked from commit 5a7bd9f57a)
2015-01-25 22:25:36 -08:00
mezz e6cbced8a2 #457 Add config option for village generation (forgot lumberjack) 2015-01-24 00:25:50 -08:00
mezz d300078227 Close #457 Add config option for village generation
(cherry picked from commit dab217eab0)
2015-01-24 00:21:56 -08:00
mezz 65c7f0242c Fix #470 Engines don't output to other mods' machines
(cherry picked from commit dffa845851)
2015-01-23 23:27:46 -08:00
mezz c4140ef9c3 Fix #472 Crash with Thaumic Tinkerer Ichorium Axe
(cherry picked from commit 1aefd5863e)
2015-01-23 23:26:54 -08:00
mezz 389e5e01e7 Fix #467 Carpenter automation
(cherry picked from commit c6dae0318c)
2015-01-23 22:34:21 -08:00
mezz a55b2645b7 Fix #465 crash after closing catalogue and opening another item gui
(cherry picked from commit dc1449855e)
2015-01-23 22:33:46 -08:00
mezz 9a36381ce0 Fix possible reservoir crash from thermionic fabricator
(cherry picked from commit 195c8fc524)
2015-01-23 22:32:37 -08:00
CovertJaguar 2565eea5ba Set version to 3.4 2015-01-17 20:44:55 -08:00
CovertJaguar 13ae9ece47 Fix submodule issues 2015-01-17 20:36:25 -08:00
CovertJaguar d3e87b1aaf Merge branch 'dev' into release_3.4
Conflicts:
	application.properties
	src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java
	src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java
	src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java
	src/main/java/forestry/apiculture/worldgen/HiveDecorator.java
	src/main/java/forestry/apiculture/worldgen/HiveForest.java
	src/main/java/forestry/apiculture/worldgen/HiveGen.java
	src/main/java/forestry/apiculture/worldgen/HiveGenHelper.java
	src/main/java/forestry/apiculture/worldgen/HiveMeadows.java
	src/main/java/forestry/apiculture/worldgen/HiveSnow.java
	src/main/java/forestry/apiculture/worldgen/HiveSwamp.java
	src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java
	src/main/java/forestry/core/gui/ContainerForestry.java
	src/main/java/forestry/core/utils/RecipeUtil.java
	src/main/java/forestry/factory/gadgets/TileWorktable.java
	src/main/java/forestry/factory/gui/ContainerFabricator.java
	src/main/java/forestry/factory/gui/ContainerWorktable.java
	src/main/java/forestry/factory/recipes/RecipeMemory.java
2015-01-17 20:33:15 -08:00
mezz 1e9952e908 Update for BuildCraft 6.3 2015-01-15 23:03:07 -08:00
mezz 10678d6469 Fix deprecation warnings from Forge 2015-01-15 22:50:33 -08:00
mezz 1601136304 Fix #456 Pipes cannot extract from Farm Hatch 2015-01-15 21:12:23 -08:00
mezz e1758f63cd Fix #455 Item duplicating by letters 2015-01-15 21:02:24 -08:00
mezz f46bcf228c Fix #454 Forestry fences don't connect to fence gates 2015-01-15 20:36:46 -08:00
Nirek-K baa70ece6d Add Fermenter support for Barley, Natura Saplings 2015-01-15 00:24:01 -08:00
mezz 8977d04de0 Fix #446 Special products don't align in beealyzer 2015-01-14 23:37:37 -08:00
mezz 2a35b05ec1 Fix #452 Opening a multiblock inventory momentarily places a block 2015-01-14 23:25:08 -08:00
mezz 122af6d72d Update developer forge 2015-01-14 22:38:37 -08:00
mezz 9cd3b9af5b Fix forced retrogen not disabling itself after being set 2015-01-11 22:36:47 -08:00
mezz 61704192fe Skip hive postGen when in hiveGen debug mode 2015-01-11 20:55:59 -08:00
mezz a3ae2b797f Improve hiveGen debug setting 2015-01-11 20:42:08 -08:00
mezz d94a688f28 Fix #135 Feature for adding Forestry resources to existing chunks 2015-01-11 19:33:37 -08:00
mezz b3fbadce84 Shuffle the order that hives try to generate 2015-01-11 13:57:47 -08:00
mezz 04d6b979ab Clean and simplify the implementation of hives through the API 2015-01-11 01:40:54 -08:00
mezz fae3b3d24e Update development Forge version 2015-01-10 10:37:25 -08:00
mezz 98372c3e08 Fix #445 Beehouse and Apiary do not detect hellish biome 2015-01-09 20:30:00 -08:00
CovertJaguar 0a68dc0307 Issue #431 Work around no longer required, fix merged into Forge 1.7.10-10.13.2.1283 and 1.8-11.14.0.1282 2015-01-09 13:15:31 -08:00
mezz 4c72917c05 Fix #444 Upper half slabs render incorrectly 2015-01-07 20:30:50 -08:00
CovertJaguar b41646540c Issue #431 Restore mezz's original fix, with a TODO comment 2015-01-07 16:01:12 -08:00
CovertJaguar 8dc81b53d6 Improves #431 Calling markBlockForUpdate() on the server is unneccesary, plus other optimizations. 2015-01-07 13:46:30 -08:00
mezz ec111e38c3 #443 Squeezer should not squeeze if it has no room for the liquid 2015-01-07 08:49:24 -08:00
mezz 8edd081de6 Update lang 2015-01-07 08:41:23 -08:00
mezz 852604e9d4 Fix pipette display. Updates icon on click, shows fluid amount tooltip 2015-01-07 07:54:35 -08:00
mezz 58a8b29bbf Minor render optimization for stopped engines 2015-01-07 07:13:18 -08:00
mezz 0fc61f46b0 Allow disabling Factory Module 2015-01-07 07:07:45 -08:00
mezz 92d53626ce Add generation count to bee tooltips for bred bees. 2015-01-05 20:59:56 -08:00
mezz 24ca3d20f3 Fix #436 Tooltip order for trees should match treealyzer order 2015-01-05 20:58:27 -08:00
mezz 080e026285 Fix #433 Stairs have wrong pick-block and Waila name 2015-01-05 20:37:00 -08:00
mezz e5979367ee Fix #431 Leaves become invisible when they start to decay 2015-01-04 22:58:10 -08:00
mezz 960b322e86 Fix #439 Some Drones have GEN tag 2015-01-04 17:39:25 -08:00
mezz d536d5cf46 Fix #437 Warnings from bee villager house construction 2015-01-04 16:46:19 -08:00
mezz 3850b1b172 Fix #435 machines consume thermal expansion tanks on right click 2015-01-03 21:03:05 -08:00
mezz 7981288250 Fix #432 Client crash when crafting fence with new planks 2015-01-02 15:49:32 -08:00
mezz e77f62d8e7 Fix #430 farm hatch should only automatically output downward 2015-01-02 15:30:19 -08:00
mezz 5326e41c9f Fix #417 Villager Beekeeper House Crashes with Arboriculture disabled 2015-01-02 04:01:47 -08:00
mezz f2395d27a8 Close #271. Improve usability of the Escritoire 2015-01-02 02:26:54 -08:00
mezz ca9c99c283 Add info about disabled plugins on crash reports 2015-01-02 00:08:35 -08:00
mezz 8cbb94aed0 Fix #429 Filled capsules are placed in armor slot when inventory is full 2015-01-01 23:13:15 -08:00
mezz e00d96ff08 Fix #428 Electrical Engine shows "no fuel" when inactive 2015-01-01 23:02:18 -08:00
mezz d436657556 Fix #426 Throttle the speed of the Generator accepting liquid containers 2015-01-01 23:01:05 -08:00
mezz f862485a05 Fix #298. xupaosso - Add Ipe, Padauk, Cocobolo, and Zebrawood trees 2015-01-01 19:43:23 -08:00
mezz 9af62513e5 Add grammars for wood products, generalize for new trees 2015-01-01 19:41:07 -08:00
mezz e8fa5ebca9 Fix #423 Mushroom growth crashes in rare cases 2014-12-31 15:30:32 -08:00
mezz a9fbfbbe74 Don't register fluids that are not Forestry's. #420 #422 2014-12-31 05:17:47 -08:00
mezz c54b7c40bb Giant Inventory Refactor 2. Slots will only accept valid items
Moved logic out of Containers, the old filtered slots were not always the same
logic as the IInventory.

Moved ISidedInventory logic up to TileForestry and use InventoryAdapters
to override only the methods we need to.

Tested a ton but there will be some new issues given the scope.
2014-12-31 04:22:33 -08:00
mezz 2b3b590cf4 Close #414 add better shift click for trade station 2014-12-28 18:04:40 -08:00
mezz 291fa98639 Fix #413, Fix access permissions 2014-12-28 16:59:28 -08:00
mezz a2938d8e55 Fix OpenGL stack overflow in worktable 2014-12-28 16:31:54 -08:00
mezz 0d1d8295b4 Fix #411 Trade Station does not show its name in the GUI 2014-12-28 12:56:31 -08:00
mezz daa3ab13be Fix catalog display bug introduced in the previous fix 2014-12-28 00:47:50 -08:00
mezz 17182cc2b2 Fix java.io.EOFException console spam 2014-12-28 00:46:50 -08:00
mezz 8f1b1e03f4 Use EnumChatFormatting values instead of unicode text 2014-12-27 22:00:51 -08:00
mezz d55b119019 Fix #410 Catalogue has glitched text 2014-12-27 21:58:41 -08:00
mezz 00c444a46d Improve GUI ItemStack rendering. Fix tooltip hover area 2014-12-27 20:29:34 -08:00
mezz e780215100 Cleanup 2014-12-27 12:02:13 -08:00
mezz 3c5c624251 Update development Forge (not the required version) 2014-12-26 23:42:13 -08:00
mezz 36508a191a Fix #408 Bronze and Copper storage blocks break into Apatite blocks 2014-12-26 23:40:52 -08:00
mezz 550462221c Cleanup 2014-12-26 23:29:12 -08:00
mezz defbdc8e71 Fix #407 Crash after naming a new Trade Station 2014-12-26 22:24:31 -08:00
mezz 6346039f14 Fix worktable lock icon rendering poorly over enchanted items 2014-12-26 22:14:22 -08:00
mezz d32530caba Fix #409 Custom book duplication on Worktable crashes client 2014-12-26 22:13:47 -08:00
mezz f5a73db68d Minor Cleanup 2014-12-26 21:42:11 -08:00
mezz e23a38e1f1 Fix #393 Farm block icons are sometimes black 2014-12-26 18:06:18 -08:00
mezz 6763619289 Expose crate registration to the API 2014-12-26 02:13:39 -08:00
mezz d652cd7a9b Minor cleanup in MachineCarpenter 2014-12-25 23:54:49 -08:00
mezz 7183d734f0 Close #354 Add Crated Potatoes and Crated Carrots 2014-12-25 23:44:18 -08:00
mezz 7b93aca1e6 Clean up crates code 2014-12-25 23:43:30 -08:00
mezz bcaaf251c6 Fix #397, Fix #404, GUI showing incorrect genetic info 2014-12-25 16:05:28 -08:00
CovertJaguar eefd71ef56 Grab and insert the Buildcraft License file into the jar 2014-12-25 09:26:04 -08:00
mezz f2d315c251 Only need one crate renderer instance 2014-12-25 01:09:13 -08:00
mezz e4b8342e1c Close #392 Generate Crate Icons Automatically 2014-12-25 01:00:13 -08:00
mezz 107047a04c Fix #394. Add shift-for-more-info on long tooltips 2014-12-24 20:48:52 -08:00
mezz 1430becdff Fix #406 locked worktable recipes sometimes become unlocked 2014-12-24 20:21:15 -08:00
mezz 77295ab74e Add better logs for invalid genome errors #400 2014-12-24 20:02:11 -08:00
mezz 68f61ab9ab Fix #405 Alveary should only be made with wooden slabs 2014-12-24 16:11:08 -08:00
mezz 1c6d55931d Fix #399 Middle clicking Forestry slabs gets the wrong slab 2014-12-24 16:04:03 -08:00
mezz 8fe121f8b9 Use HTTPS for git subomdules 2014-12-24 13:42:10 -08:00
CovertJaguar 0fcd151776 Update build.gradle with the submodule changes....clean up api inclusion code (hacks on top of hacks! one hack adds APIs to the jar while another is removing it lol) 2014-12-24 08:07:51 -08:00
CovertJaguar 52994b2a39 Fix Lang submodule default url to use the github protocol. 2014-12-24 08:05:17 -08:00
CovertJaguar 885fc1291e Remove RF API sources from repo 2014-12-24 07:34:16 -08:00
CovertJaguar b23167d468 Readd Forestry API correctly this time. 2014-12-24 07:31:59 -08:00
CovertJaguar 6d7f30ea6b Remove Forestry API again because I derped it up 2014-12-24 07:30:42 -08:00
CovertJaguar 70d8d76934 Readd APIs as submodules 2014-12-24 07:28:20 -08:00
CovertJaguar a449e1b3b2 Remove API from the ignored folders 2014-12-24 07:26:14 -08:00
CovertJaguar ca64f88113 Remove Forestry API in prep for adding RF API as a submodule (changing the directory tree) 2014-12-24 07:21:11 -08:00
CovertJaguar 62261a5b8f TankManager.tankCanDrainFluid() should take the fluid type into account (oops) 2014-12-24 07:10:06 -08:00
mezz 20b2dcf9c3 Clean up Fluids comments. method name setDrink -> setProperties 2014-12-24 01:09:33 -08:00
mezz 98e62aa1e3 Refactor fluids code, create PluginFluids 2014-12-24 01:00:53 -08:00
mezz a4f7e4c583 rename Fluids.get() to Fluids.getFluid() in preparation for refactor 2014-12-24 00:43:22 -08:00
mezz 305be1b979 Convert old honey using the still #390 2014-12-23 13:30:42 -08:00
mezz 43bd276389 Close #390 Forestry Fluids should have FluidBlocks 2014-12-23 01:16:29 -08:00
mezz eb20049b6d Fix #391 Some inventory slots have Xs when they're empty 2014-12-20 21:39:32 -08:00
mezz 4432b0dac4 Fix #395 Crashes without BuildCraft 2014-12-20 21:16:55 -08:00
mezz 8d5b19787e Fix #388 Multifarm not loading its inventory 2014-12-20 15:56:51 -08:00
mezz d705f4f4db Move EnumFarmBlock to its own file 2014-12-20 15:52:48 -08:00
mezz 2f6969e141 Cleanup 2014-12-20 04:18:52 -08:00
mezz 26ff21f446 Fix #387 bee tooltip shows wrong humidity tolerance 2014-12-20 04:06:07 -08:00
mezz 4cfa8f7338 Minor bugfixes 2014-12-20 03:59:47 -08:00
mezz e2fff11ea8 Simple Cleanup 2014-12-20 03:59:31 -08:00
mezz 09df969bcf Fix drawing bee icons in the Imprinter 2014-12-20 03:21:00 -08:00
mezz 483a21cd7d Remove unused imports 2014-12-20 01:07:36 -08:00
mezz 71dcbdf0e4 Fix #385 Server crash when opening AlvearySieve 2014-12-20 00:13:28 -08:00
mezz d63377532c Fix #384 Client crash at forestry.farming.gadgets.TileHatch 2014-12-19 23:40:07 -08:00
mezz 46348fca07 Fix #383 Fermenter crash when opening the gui 2014-12-19 23:25:45 -08:00
mezz 08555326b2 Clean up Bee.java. Split Vect into MutableVect and (immutable) Vect. 2014-12-19 23:16:15 -08:00
mezz 90f80da4da Clean up pollination. Add pollination for vanilla Acacia and Dark Oak 2014-12-18 22:46:54 -08:00
CovertJaguar db0ab5feda Fixes #379 Clean up and fix Naturalist Chest 2014-12-18 06:02:38 -08:00
CovertJaguar 06549d1e2d Fix usage usability checks to account for access setting. 2014-12-18 06:01:42 -08:00
CovertJaguar 8406073107 Fixes #378 Alveary should ensure it has a an inventory before it tries to read item into it. 2014-12-18 01:53:55 -08:00
mezz e55b21028e #232 #373 Stop shipping the BuildCraft API in Jar 2014-12-18 00:29:19 -08:00
mezz a1cf0ddf77 Fix #377 Centrifuge, Peat Engine, Analyzer won't accept items 2014-12-17 23:18:30 -08:00
mezz 2d8cadea26 Fix #376 Farm Hatch does not accept any items 2014-12-17 23:12:13 -08:00
CovertJaguar 4e963ca6e1 Improve ErrorStateRegistry 2014-12-17 00:28:21 -08:00
CovertJaguar 947717873d Fix faulty pipe selection randomizer in moveOneItemToPipe() 2014-12-16 23:44:39 -08:00
mezz 45f167754a Cleanup TODOs 2014-12-16 22:34:43 -08:00
mezz 35afdc66b8 Remove unused config options, fix enableBackpackResupply option 2014-12-16 22:34:43 -08:00
CovertJaguar 89c3fb8bdf Attempt to fix issues with structure inventories.
Also cleaned up the Hatch pipe/inventory interaction code, modernizing it and removing duplicate code.
This involved adding my AdjecentInventoryCache and AdjecentTileCache code from Railcraft for greatly improved performance.
ISpecialInventory is now 100% unused.
2014-12-16 03:09:15 -08:00
CovertJaguar c7d88d73d3 Clean imports 2014-12-15 08:15:21 -08:00
CovertJaguar 344bb7514b Finish Inventory cleanup 2014-12-15 08:09:46 -08:00
CovertJaguar db93c6e930 Merge branch 'dev' into inventory-cleanup
Conflicts:
	src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java
	src/main/java/forestry/core/circuits/ItemSolderingIron.java
	src/main/java/forestry/core/gadgets/TileAnalyzer.java
	src/main/java/forestry/energy/gadgets/EngineBronze.java
	src/main/java/forestry/energy/gadgets/MachineGenerator.java
	src/main/java/forestry/factory/gadgets/MachineBottler.java
	src/main/java/forestry/factory/gadgets/MachineCarpenter.java
	src/main/java/forestry/factory/gadgets/MachineFabricator.java
	src/main/java/forestry/factory/gadgets/MachineMoistener.java
	src/main/java/forestry/factory/gadgets/MachineRaintank.java
	src/main/java/forestry/factory/gadgets/MachineSqueezer.java
	src/main/java/forestry/factory/gadgets/MachineStill.java
	src/main/java/forestry/mail/gadgets/MachineTrader.java
2014-12-15 07:56:29 -08:00
CovertJaguar aaa00d0184 For whatever reason the Potion.isBadEffect() reflection was giving me generics related compile errors. This fixes it. 2014-12-15 07:46:28 -08:00
CovertJaguar d4b8c6b503 Bump version 2014-12-15 07:45:25 -08:00
CovertJaguar ccdcce47cc Fixes #369 The Solding Iron and other Cicruit stuff should no longer crash if no layouts are defined.
The fix kind of grew out of control because I had to add a new EnumErrorCode and didn't want to keep breaking the API every time I did that. So I needed to decouple the ErrorStates from EnumErrorCode.
2014-12-15 07:45:10 -08:00
CovertJaguar 990d4990db Fix lang 2014-12-14 21:39:45 -08:00
mezz 364ed4cf53 Remove unused defaults 2014-12-14 18:35:14 -08:00
mezz 84da3cc939 Remove ClassMap and EntityNetData 2014-12-14 18:28:38 -08:00
mezz 344e842764 Fix some mail glitches. Check valid addresses for writing letters 2014-12-14 18:07:57 -08:00
mezz 3d4ba15751 Minor Cleanup bee and tree commands 2014-12-14 14:46:25 -08:00
mezz d8beaa92b9 Fix #367 Fix fabricator crash 2014-12-14 13:54:47 -08:00
mezz a68cbc54e7 Fix and migrate Tree commands to new format. Remove CommandMC 2014-12-13 23:38:36 -08:00
mezz a8b7098f39 Implement spawn tree and spawn forest commands 2014-12-13 21:29:55 -08:00
mezz 1b741eaac5 Remove vialEmpty, vialCatalyst 2014-12-13 19:19:49 -08:00
mezz 9cbb6e390b Cleanup, use Fluids enum 2014-12-13 18:58:49 -08:00
mezz c4b3f7e9f1 Only consume fluid containers with null getContainerItem 2014-12-13 18:56:31 -08:00
CovertJaguar 792ab77a48 More Inventory rewrite stuff. 2014-12-13 18:20:52 -08:00
CovertJaguar 3326f4db03 Merge branch 'dev' of github.com:ForestryMC/ForestryMC into inventory-cleanup
Conflicts:
	src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java
	src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java
	src/main/java/forestry/core/gui/ContainerForestry.java
	src/main/java/forestry/energy/gadgets/EngineBronze.java
	src/main/java/forestry/energy/gadgets/MachineGenerator.java
	src/main/java/forestry/factory/gadgets/MachineBottler.java
	src/main/java/forestry/factory/gadgets/MachineCarpenter.java
	src/main/java/forestry/factory/gadgets/MachineFabricator.java
	src/main/java/forestry/factory/gadgets/MachineFermenter.java
	src/main/java/forestry/factory/gadgets/MachineMoistener.java
	src/main/java/forestry/factory/gadgets/MachineRaintank.java
	src/main/java/forestry/factory/gadgets/MachineStill.java
	src/main/java/forestry/factory/gadgets/TileWorktable.java
	src/main/java/forestry/farming/gadgets/TileFarmPlain.java
	src/main/java/forestry/farming/gui/ContainerFarm.java
2014-12-13 16:39:40 -08:00
mezz 5ea4770a2d Fix #364. Cleanup of Liquid/Fluid handling, handle IFluidContainerItem 2014-12-13 01:42:52 -08:00
mezz 5c4bd5307c Fix #365 Fluid pipe connected to farmblock 2014-12-12 01:30:51 -08:00
mezz 2242dfdfb9 Cleanup 2014-12-12 00:34:44 -08:00
mezz e26da52d21 Closes #363. Ore dictionary support for IC2's Rubberized Electron Tubes 2014-12-11 22:00:03 -08:00
mezz dbf6202a90 Fix Alveary Swarmer and Swarm Hive 2014-12-09 01:09:10 -08:00
mezz ce232e808e Fix Alveary Swarmer and Swarm Hive
(cherry picked from commit 2577ee9c930cdc91bdf3d207cbeaaebbe1141257)

Conflicts:
	src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java
2014-12-09 01:08:14 -08:00
mezz 31574a9c6e Cleanup
(cherry picked from commit 4f95ceab29)
2014-12-09 01:03:05 -08:00
mezz 1d2266a524 update lang 2014-12-09 00:58:59 -08:00
mezz a300e97aa0 Cleanup MachineFabricator 2014-12-08 22:41:37 -08:00
mezz 76fe2b1c90 cleanup 2014-12-08 22:41:36 -08:00
mezz 099f33549b Refactor out worktable canCraftRecipe logic to RecipeUtil 2014-12-08 22:41:36 -08:00
MysteriousAges e281cb4591 Welcoming Miry and Boggy bees! Marshy bees are no longer in a branch all on their lonesome. 2014-12-08 21:42:22 -08:00
MysteriousAges 99f09b4037 Fertile effect should now respect housing territory modifiers. 2014-12-08 21:41:08 -08:00
mezz cd9a4110ee Refactor out worktable canCraftRecipe logic to RecipeUtil 2014-12-08 20:26:51 -08:00
mezz 6b35ff2ba1 Improve null safety of memorized recipe isValid check
(cherry picked from commit 23ffb78ab3)
2014-12-07 16:25:01 -08:00
mezz 23ffb78ab3 Improve null safety of memorized recipe isValid check 2014-12-07 16:23:03 -08:00
mezz 5133e721cc Add blacklist to worktable memory, blacklist non-empty maps
(cherry picked from commit 2cb1959421)
2014-12-07 16:18:23 -08:00
mezz 09ced92f5b Support left click drag on Worktable
(cherry picked from commit 029604222c)
2014-12-07 16:18:17 -08:00
mezz 12477a7711 Fix crash when crafting with a Map on a Worktable 2014-12-07 16:17:21 -08:00
mezz b7dc4d9144 Fix #359 Crafting with a worktable does not trigger achievements.
(cherry picked from commit c010977a0b)
2014-12-07 16:16:24 -08:00
mezz 2cb1959421 Add blacklist to worktable memory, blacklist non-empty maps 2014-12-07 16:15:40 -08:00
mezz da48d317ff Fix #362 Missing Analyzer Crafting recipe
(cherry picked from commit 7ffb9d5c1d)
2014-12-07 15:32:02 -08:00
mezz 5bfb11e952 Fix #353 Alveary heater/fan energy consumption, animation
(cherry picked from commit 475d99eae8)
2014-12-07 15:30:30 -08:00
mezz 4dffb9f352 Fix biome error in Alveary
(cherry picked from commit d0244ece32)
2014-12-07 15:30:20 -08:00
mezz beadb47539 Fix #356 Worktable using the wrong wood with Shift-use all
(cherry picked from commit 0105f36668)
2014-12-07 15:30:08 -08:00
mezz 6301d3c193 Fix #357 Forestry stained glass not silk touchable
(cherry picked from commit ab3ba0c4db)
2014-12-07 15:30:02 -08:00
mezz 883863e047 Safety check for IC2 Plugin. #351
(cherry picked from commit 38009bb32a)
2014-12-07 15:29:42 -08:00
mezz 2c14f02151 Fix #352 Backpack deletion/duplication bug
(cherry picked from commit d827a0f132)
2014-12-07 15:29:07 -08:00
mezz 7ffb9d5c1d Fix #362 Missing Analyzer Crafting recipe 2014-12-07 12:45:21 -08:00
mezz 029604222c Support left click drag on Worktable 2014-12-07 01:46:15 -08:00
mezz c6f205864f oops 2014-12-06 23:34:40 -08:00
mezz 4cc318bc1d Fix crash when crafting with a Map on a Worktable 2014-12-06 23:31:56 -08:00
mezz c010977a0b Fix #359 Crafting with a worktable does not trigger achievements. 2014-12-06 23:28:05 -08:00
mezz 84e9673454 Fix lang typo: agrarain -> agrarian 2014-12-06 20:01:18 -08:00
mezz 54e4aafc0e Improve bee give command format 2014-12-06 19:54:53 -08:00
mezz 46256bac41 Fix crash from checking Potion.isBadEffect on server 2014-12-06 18:52:32 -08:00
CovertJaguar 4f48cd5890 More progress on inventory rework 2014-12-05 12:43:23 -08:00
CovertJaguar 48d6230ed1 Update lang 2014-12-05 12:43:00 -08:00
CovertJaguar f3895aeaab Merge branch 'dev' into inventory-cleanup 2014-12-04 19:09:37 -08:00
mezz 4c6a461425 Partially Revert "Swapping out deprecated method for non-deprecated call."
This reverts commit fafee34803.

There are 3rd party housings that don't implement the new getErrorState() yet.
We can only get rid of this with the next major API change.
2014-12-04 18:28:39 -08:00
MysteriousAges f6a166c87f Merge pull request #358 from Vexatos/patch-1
Fixed PluginApiculture.java
2014-12-04 10:30:25 -08:00
Vexatos 8be4298ca9 Update PluginApiculture.java 2014-12-04 17:54:33 +01:00
MysteriousAges fafee34803 Swapping out deprecated method for non-deprecated call. 2014-12-04 01:56:43 -08:00
MysteriousAges 4ab3e7ddb4 Merge branch 'dev' of github.com:ForestryMC/ForestryMC into dev 2014-12-04 01:37:01 -08:00
MysteriousAges 8ff72af9d2 Farmerly & Agrarian bees. Buzz buzz 2014-12-04 01:13:29 -08:00
mezz b2d722a4c5 Make Apiarist's Armor protect against potion effects from bees 2014-12-04 00:12:07 -08:00
mezz 475d99eae8 Fix #353 Alveary heater/fan energy consumption, animation 2014-12-03 23:50:39 -08:00
mezz d0244ece32 Fix biome error in Alveary 2014-12-03 23:50:00 -08:00
mezz 4f95ceab29 Cleanup 2014-12-03 22:45:32 -08:00
mezz 0105f36668 Fix #356 Worktable using the wrong wood with Shift-use all 2014-12-03 21:56:41 -08:00
mezz ab3ba0c4db Fix #357 Forestry stained glass not silk touchable 2014-12-03 21:22:21 -08:00
mezz 38009bb32a Safety check for IC2 Plugin. #351 2014-12-03 20:46:10 -08:00
mezz d132a0ae62 Cleanup 2014-12-02 23:23:11 -08:00
mezz d827a0f132 Fix #352 Backpack deletion/duplication bug 2014-12-02 23:22:58 -08:00
mezz 891c0c6133 Add beePrincessGE.name for trader's princess trade for monastic drone 2014-12-02 22:09:53 -08:00
mezz f8a9bf44c3 Suppress unhandled exception warnings 2014-11-30 18:31:42 -08:00
mezz 874a49262d Cleanup *alyzers 2014-11-30 18:31:05 -08:00
CovertJaguar 3636af5b9c More work on inventory stuff, and fix all the broken merge stuff 2014-11-30 17:59:31 -08:00
CovertJaguar 00771b1a42 Bump version 2014-11-30 17:22:40 -08:00
CovertJaguar 46ec2f2740 Merge branch 'dev' into release_3.3 2014-11-30 17:21:03 -08:00
CovertJaguar 034cdf2860 Intial stages of an cleanup of the inventory code, this commit is very broken. 2014-11-30 17:19:16 -08:00
CovertJaguar 3d765067cf Merge branch 'dev' of github.com:ForestryMC/ForestryMC into dev
Conflicts:
	src/main/java/forestry/core/utils/BlockUtil.java
2014-11-30 16:50:09 -08:00
mezz 9da092e6d4 Fix #347 Squeezer progress bar interferes with tank display 2014-11-30 16:12:03 -08:00
mezz 0b5a5bc34d Fix trade stations failing to initialize because of GameProfile check 2014-11-30 15:26:46 -08:00
mezz c17a6af267 Fix trees growing with wrong wood. relates to #344 2014-11-30 14:44:53 -08:00
mezz 3884fecf77 Minor Cleanup
Fix up some null checks

Clean up redundant array creation to varargs parameter

Remove redundant type casts

Simplify arithmetic

Use foreach loops

Remove unused code

Minor cleanup
2014-11-29 23:49:47 -08:00
mezz 05a7ac6d93 Fix bonemealed pods growing too large 2014-11-29 23:49:42 -08:00
mezz 7f5108f26c Update for BuildCraft 6.2.1. Fix #348 2014-11-29 19:53:40 -08:00
mezz be82dd318b Clean up GuiFlutterlyzer 2014-11-28 18:20:40 -08:00
mezz ce2930b1ab Clean up Treealyzer, fix showing secondary fruits 2014-11-28 18:20:03 -08:00
mezz cc187d6b8b Semi-automatic minor cleanup 2014-11-28 18:09:51 -08:00
mezz 1d2c4e438d cleanup BlockBeehives 2014-11-28 17:49:08 -08:00
mezz be0a62b831 Fix use of GameProfile.equals() 2014-11-28 16:58:53 -08:00
mezz 8b37aa86ff Fix #346. Legacy crash from old Apiarist chest 2014-11-28 16:52:51 -08:00
mezz 9d70a1b0ec Cleanup imports 2014-11-28 16:47:18 -08:00
CovertJaguar 6ea4ab4491 Clean up Engines a bit.
Remove ISpecialInventory implementations on Engines.
Change Engines to IEnergyConnection instead of IEnergyHandler.
2014-11-28 10:36:13 -08:00
CovertJaguar 10a5ba3eb8 Update lang 2014-11-28 10:34:52 -08:00
CovertJaguar 8ce7e49d5f Update dependencies 2014-11-28 10:03:11 -08:00
mezz 34c1956cc1 Fix #345 Pipette not depositing liquid 2014-11-27 23:00:39 -08:00
mezz cfbde3eb83 Minor tree cleanup 2014-11-27 11:42:10 -08:00
mezz 328b9e8356 Fix #344 Teak Trees have Lime wood 2014-11-27 11:41:41 -08:00
mezz 878fe51866 Fix up BuildCraft triggers 2014-11-26 23:40:37 -08:00
mezz efe1236326 Fix #338 Fixed soil detection multifarm trigger 2014-11-26 22:57:06 -08:00
mezz abe0563550 Fix null biome error for multifarms 2014-11-26 22:25:48 -08:00
mezz 14b34e0b01 Fix #343 AbstractMethodError from Command's getRequiredPermissionLevel() 2014-11-26 21:34:56 -08:00
mezz dba8b5448a Use BiomeGenBase instead of biomeID 2014-11-26 21:13:57 -08:00
mezz 91206dce35 Fix #342 Raintank - wrong biome message in correct biomes 2014-11-26 20:08:12 -08:00
mezz 6cdafc05de Fix enum type in ContainerCatalogue 2014-11-22 01:38:48 -08:00
mezz 00924ccd68 Fix checking for fuels 2014-11-22 01:38:43 -08:00
mezz e251d28893 Fix operator precedence error with sending UUIDs 2014-11-22 01:32:27 -08:00
mezz 0ec13d6966 Cleanup: typo variables 2014-11-22 01:31:19 -08:00
mezz 07ba130dc6 Fix #336. infinite loop on server when bee housing is full 2014-11-21 22:00:46 -08:00
mezz 6927c4d5fb Add wildcard for OreDictionary where appropriate 2014-11-20 19:10:10 -08:00
mezz e2144b140b Fix broken API 2014-11-20 19:09:19 -08:00
mezz aab26dca3e bump to fix broken build
api submodule wasn't pushed
2014-11-17 19:37:09 -08:00
CovertJaguar bb5f2b0977 Remove some crashy debug statements from AIButterflyPollinate 2014-11-17 19:12:07 -08:00
mezz eca3be2e63 #232 make BuildCraft @Optional statements more specific 2014-11-16 20:09:28 -08:00
CovertJaguar feef3b8a63 Merge branch 'dev' of github.com:ForestryMC/ForestryMC into dev 2014-11-16 20:06:05 -08:00
CovertJaguar 6e33a55bcb TIL that fake players now implement EntityPlayerMP 2014-11-16 20:05:47 -08:00
mezz 53f512d7aa Improve performance of reading bees from NBT 2014-11-16 20:01:41 -08:00
mezz b6ba59f9f9 Move EnumErrorCode to the API (tick performance) 2014-11-16 20:01:33 -08:00
mezz ae3f75e22a Improve bee logic performance 2014-11-16 16:14:41 -08:00
MysteriousAges 9dd73935d7 Refactoring BeekeepingLogic's monolithic update(). Down from 200+ lines to 20, and a buttload of functions. Hopefully it's a bit easier to read & understand now.
Tabs.
Switched order of hasQueen/tryBreedingPrincess to ensure that princesses are bred into queens.
2014-11-16 15:17:15 -08:00
mezz b69897ff3d Fix #326. Don't pollinate decorative vanilla leaves 2014-11-16 15:00:04 -08:00
mezz 4da4a7cf56 Fix hives dropping ignoble drones (which shouldn't exist) 2014-11-16 13:32:35 -08:00
mezz 9ddb43e388 Fix watered farms not replacing flowing water 2014-11-15 15:08:09 -08:00
mezz ead6b2c9b9 #282 Make tree farms pick up entities up to the world height. 2014-11-15 14:43:09 -08:00
mezz 25a88df47c #232 use @Optional for BuildCraft triggers 2014-11-15 14:21:33 -08:00
CovertJaguar 968ad8189e Update lang 2014-11-15 04:08:33 -08:00
CovertJaguar aba03f6364 Merge pull request #330 from ForestryMC/beekeepingCommands
update beekeeping commands
2014-11-15 00:39:49 -08:00
mezz 70e8654adb update beekeeping commands 2014-11-14 22:53:46 -08:00
CovertJaguar 8fe22130d3 Use ChastStyle instead of formatting codes 2014-11-13 04:33:41 -08:00
CovertJaguar 79c7ae435c Convert Mail Commands.
And various other improvements to the command code and localization support.
2014-11-13 04:25:10 -08:00
CovertJaguar 6a3d92e825 Add license header file, for IDE use. 2014-11-13 02:36:38 -08:00
CovertJaguar c2acb36c44 I really need to tell my IDE to use Forestry's file header for this project, not Railcraft's.... 2014-11-13 02:22:40 -08:00
CovertJaguar 4609ebc754 Major Butterfly AI rework, they should be less derpy about getting stuck in holes and flying over oceans.
Various other tweaks and improvements as well, including a fix for the spazzy wing movement that 1.7 introduced.
2014-11-13 02:14:17 -08:00
CovertJaguar aea3c55192 Update Buildcraft to 6.1.7 2014-11-13 02:11:03 -08:00
CovertJaguar e7ae15c81d Merge branch 'dev' of github.com:ForestryMC/ForestryMC into dev 2014-11-12 03:53:40 -08:00
CovertJaguar 4a390fe967 Creates a new command framework that supports trees of commands simply and easily.
Depreciated CommandMC. Many commands remain to be converted to the new system.
Added a butterfly kill command.
2014-11-12 03:53:01 -08:00
CovertJaguar 2132c4457d Apply formatting to Butterfly classes 2014-11-12 03:24:07 -08:00
mezz 267905ef3f Fix #326 decorative leaves should not pollinate 2014-11-11 19:54:34 -08:00
mezz e528609212 Minor code cleanup 2014-11-11 19:07:47 -08:00
mezz 6fb07b9d40 Fix #325 Centrifuge dupe bug 2014-11-11 19:07:27 -08:00
851 changed files with 16291 additions and 17628 deletions

No files matched your search

+2
View File
@@ -5,6 +5,7 @@
!/forestry_techne
!/gradle/wrapper
!/src
!/api
# files
!/.gitignore
@@ -12,6 +13,7 @@
!/CLA.txt
!/CONTRIBUTING.md
!/LICENSE.txt
!/license-header.txt
!/README.md
!/application.properties
!/build.gradle
+5 -2
View File
@@ -1,6 +1,9 @@
[submodule "lang"]
path = lang
url = https://github.com/ForestryMC/Forestry-Localization.git
[submodule "api"]
path = api
[submodule "api/redstoneflux"]
path = api/redstoneflux
url = https://github.com/CoFH/RedstoneFlux-API.git
[submodule "api/forestry"]
path = api/forestry
url = https://github.com/ForestryMC/ForestryAPI.git
+1 -1
View File
@@ -1,6 +1,6 @@
Forestry
====================================
### What is it?
Forestry is a modification for the game Minecraft and known primarily for its farms and bees.
Submodule api deleted from 4f7ca82190.
Submodule
+1
Submodule api/forestry added at b41c05d38a.
+1
Submodule api/redstoneflux added at 10e10af214.
+2 -2
View File
@@ -1,6 +1,6 @@
mcversion=1.7.10
forgeversion=10.13.0.1207
forgeversion=10.13.2.1286
version_major=3
version_minor=2
version_minor=4
version_patch=0
+30 -34
View File
@@ -31,7 +31,9 @@ archivesBaseName = "forestry_" + mcversion
ext.dirDest = './build/dist'
ext.dirLang = "./lang"
ext.dirApi = "./api"
ext.apiForestry = "./api/forestry"
ext.apiRedstoneFlux = "./api/redstoneflux"
ext.CraftGuideRepo = "https://github.com/Uristqwerty/CraftGuide.git"
ext.CraftGuideTmp = "build/tmp/CraftGuide"
@@ -54,7 +56,8 @@ sourceSets {
main {
java {
srcDir project.dirApi
srcDir project.apiForestry
srcDir project.apiRedstoneFlux + "/src/main/java"
}
resources {
srcDir project.dirLang
@@ -70,13 +73,13 @@ repositories {
}
configurations {
apis
compile.extendsFrom apis
api
compile.extendsFrom api
}
dependencies {
compile 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
apis 'com.mod-buildcraft:buildcraft:6.1.5:dev'
api 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
api 'com.mod-buildcraft:buildcraft:6.3.1:dev'
}
processResources {
@@ -178,12 +181,15 @@ jar {
destinationDir = file("build/tmp")
archiveName = "main.jar"
from {
configurations.apis.collect {
it.isDirectory() ? it : zipTree(it).matching {
include '**/api/**'
}
}
// Copy various READMEs and Licensing files into the jar
into ('forestry/api') {
from project.apiForestry + "/LICENSE.txt"
}
into ('cofh/api') {
from project.apiRedstoneFlux + "/LICENSE - LGPLv3.txt"
}
into ('buildcraft/api') {
from "./src/main/java/buildcraft/LICENSE-API"
}
}
@@ -191,7 +197,6 @@ task mainJarSigned ( type: Jar, dependsOn: 'reobf' ) {
from (zipTree(jar.getArchivePath())) {
exclude '**/api/**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@@ -218,7 +223,6 @@ task mainJar ( type: Zip, dependsOn: mainJarSigned ) {
from (zipTree(jar.getArchivePath())) {
include '**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@@ -231,7 +235,6 @@ task devJarSigned ( type: Jar, dependsOn: 'classes' ) {
from(sourceSets.main.output) {
exclude '**/api/**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
destinationDir = file("build/tmp")
@@ -257,21 +260,11 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) {
from(sourceSets.main.allSource) {
include '**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
from(sourceSets.main.output) {
include '**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
from {
configurations.apis.collect {
it.isDirectory() ? it : zipTree(it).matching {
include '**/api/**'
}
}
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@@ -282,9 +275,7 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) {
}
task apiJar(type: Jar, dependsOn: 'classes') {
from (dirApi) {
include '**'
}
from project.apiForestry
from (sourceSets.main.output) {
include 'forestry/api/**'
@@ -295,14 +286,19 @@ task apiJar(type: Jar, dependsOn: 'classes') {
classifier = 'api'
}
task release(dependsOn: [apiJar, devJar, mainJar]) {
doLast {
println '*************************************************************'
println 'This build will be version: ' + project.version
println '*************************************************************'
}
task releaseInit << {
println '*************************************************************'
println 'This build will be version: ' + rootProject.version
println '*************************************************************'
}
task release (dependsOn: [releaseInit, apiJar, devJar, mainJar]) {
}
mainJar.shouldRunAfter releaseInit
devJar.shouldRunAfter releaseInit
apiJar.shouldRunAfter releaseInit
afterEvaluate {
compileApiJava.dependsOn initCraftGuide
}
+1 -1
Submodule lang updated: 8ca6c91070...1b85a75323.
+12
View File
@@ -0,0 +1,12 @@
/*
*******************************************************************************
* 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
*******************************************************************************
*/
+21
View File
@@ -0,0 +1,21 @@
BuildCraft API License
Copyright (c) 2011-2014 SpaceToad and the BuildCraft team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.tools;
import net.minecraft.entity.player.EntityPlayer;
/***
* Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft
*/
public interface IToolWrench {
/***
* Called to ensure that the wrench can be used. To get the ItemStack that is used, check player.inventory.getCurrentItem()
*
* @param player
* - The player doing the wrenching
* @param x
* ,y,z - The coordinates for the block being wrenched
*
* @return true if wrenching is allowed, false if not
*/
boolean canWrench(EntityPlayer player, int x, int y, int z);
/***
* Callback after the wrench has been used. This can be used to decrease durability or for other purposes. To get the ItemStack that was used, check
* player.inventory.getCurrentItem()
*
* @param player
* - The player doing the wrenching
* @param x
* ,y,z - The coordinates of the block being wrenched
*/
void wrenchUsed(EntityPlayer player, int x, int y, int z);
}
@@ -0,0 +1,11 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tools")
package buildcraft.api.tools;
import cpw.mods.fml.common.API;
-11
View File
@@ -1,11 +0,0 @@
package cofh.api;
public class CoFHAPIProps {
private CoFHAPIProps() {
}
public static final String VERSION = "1.7.10R1.0.1";
}
@@ -1,158 +0,0 @@
package cofh.api.energy;
import net.minecraft.nbt.NBTTagCompound;
/**
* Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
*
* @author King Lemming
*
*/
public class EnergyStorage implements IEnergyStorage {
protected int energy;
protected int capacity;
protected int maxReceive;
protected int maxExtract;
public EnergyStorage(int capacity) {
this(capacity, capacity, capacity);
}
public EnergyStorage(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer);
}
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
this.energy = nbt.getInteger("Energy");
if (energy > capacity) {
energy = capacity;
}
return this;
}
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
if (energy < 0) {
energy = 0;
}
nbt.setInteger("Energy", energy);
return nbt;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
if (energy > capacity) {
energy = capacity;
}
}
public void setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer);
}
public void setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
}
public void setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
}
public int getMaxReceive() {
return maxReceive;
}
public int getMaxExtract() {
return maxExtract;
}
/**
* This function is included to allow for server -&gt; client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers are
* guaranteed to have it.
*
* @param energy
*/
public void setEnergyStored(int energy) {
this.energy = energy;
if (this.energy > capacity) {
this.energy = capacity;
} else if (this.energy < 0) {
this.energy = 0;
}
}
/**
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
* externally, as not all IEnergyHandlers are guaranteed to have it.
*
* @param energy
*/
public void modifyEnergyStored(int energy) {
this.energy += energy;
if (this.energy > capacity) {
this.energy = capacity;
} else if (this.energy < 0) {
this.energy = 0;
}
}
/* IEnergyStorage */
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) {
energy += energyReceived;
}
return energyReceived;
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) {
energy -= energyExtracted;
}
return energyExtracted;
}
@Override
public int getEnergyStored() {
return energy;
}
@Override
public int getMaxEnergyStored() {
return capacity;
}
}
@@ -1,21 +0,0 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
* accept it; otherwise just use IEnergyHandler.
*
* Note that {@link IEnergyHandler} is an extension of this.
*
* @author King Lemming
*
*/
public interface IEnergyConnection {
/**
* Returns TRUE if the TileEntity can connect on a given side.
*/
boolean canConnectEnergy(ForgeDirection from);
}
@@ -1,52 +0,0 @@
package cofh.api.energy;
import net.minecraft.item.ItemStack;
/**
* Implement this interface on Item classes that support external manipulation of their internal energy storages.
*
* A reference implementation is provided {@link ItemEnergyContainer}.
*
* @author King Lemming
*
*/
public interface IEnergyContainerItem {
/**
* Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
*
* @param container
* ItemStack to be charged.
* @param maxReceive
* Maximum amount of energy to be sent into the item.
* @param simulate
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received by the item.
*/
int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
/**
* Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally
* discharged.
*
* @param container
* ItemStack to be discharged.
* @param maxExtract
* Maximum amount of energy to be extracted from the item.
* @param simulate
* If TRUE, the discharge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted from the item.
*/
int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
/**
* Get the amount of energy currently stored in the container item.
*/
int getEnergyStored(ItemStack container);
/**
* Get the max amount of energy that can be stored in the container item.
*/
int getMaxEnergyStored(ItemStack container);
}
@@ -1,51 +0,0 @@
package cofh.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
*
* A reference implementation is provided {@link TileEnergyHandler}.
*
* @author King Lemming
*
*/
public interface IEnergyHandler extends IEnergyConnection {
/**
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
*
* @param from
* Orientation the energy is received from.
* @param maxReceive
* Maximum amount of energy to receive.
* @param simulate
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received.
*/
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
/**
* Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
*
* @param from
* Orientation the energy is extracted from.
* @param maxExtract
* Maximum amount of energy to extract.
* @param simulate
* If TRUE, the extraction will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted.
*/
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
int getEnergyStored(ForgeDirection from);
/**
* Returns the maximum amount of energy that can be stored.
*/
int getMaxEnergyStored(ForgeDirection from);
}
@@ -1,45 +0,0 @@
package cofh.api.energy;
/**
* An energy storage is the unit of interaction with Energy inventories.
*
* A reference implementation can be found at {@link EnergyStorage}.
*
* @author King Lemming
*
*/
public interface IEnergyStorage {
/**
* Adds energy to the storage. Returns quantity of energy that was accepted.
*
* @param maxReceive
* Maximum amount of energy to be inserted.
* @param simulate
* If TRUE, the insertion will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
*/
int receiveEnergy(int maxReceive, boolean simulate);
/**
* Removes energy from the storage. Returns quantity of energy that was removed.
*
* @param maxExtract
* Maximum amount of energy to be extracted.
* @param simulate
* If TRUE, the extraction will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
*/
int extractEnergy(int maxExtract, boolean simulate);
/**
* Returns the amount of energy currently stored.
*/
int getEnergyStored();
/**
* Returns the maximum amount of energy that can be stored.
*/
int getMaxEnergyStored();
}
@@ -1,110 +0,0 @@
package cofh.api.energy;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/**
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
*
* @author King Lemming
*
*/
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
protected int capacity;
protected int maxReceive;
protected int maxExtract;
public ItemEnergyContainer() {
}
public ItemEnergyContainer(int capacity) {
this(capacity, capacity, capacity);
}
public ItemEnergyContainer(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer);
}
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
public ItemEnergyContainer setCapacity(int capacity) {
this.capacity = capacity;
return this;
}
public void setMaxTransfer(int maxTransfer) {
setMaxReceive(maxTransfer);
setMaxExtract(maxTransfer);
}
public void setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
}
public void setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
}
/* IEnergyContainerItem */
@Override
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if (container.stackTagCompound == null) {
container.stackTagCompound = new NBTTagCompound();
}
int energy = container.stackTagCompound.getInteger("Energy");
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
if (!simulate) {
energy += energyReceived;
container.stackTagCompound.setInteger("Energy", energy);
}
return energyReceived;
}
@Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
return 0;
}
int energy = container.stackTagCompound.getInteger("Energy");
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if (!simulate) {
energy -= energyExtracted;
container.stackTagCompound.setInteger("Energy", energy);
}
return energyExtracted;
}
@Override
public int getEnergyStored(ItemStack container) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
return 0;
}
return container.stackTagCompound.getInteger("Energy");
}
@Override
public int getMaxEnergyStored(ItemStack container) {
return capacity;
}
}
@@ -1,62 +0,0 @@
package cofh.api.energy;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own.
*
* @author King Lemming
*
*/
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
protected EnergyStorage storage = new EnergyStorage(32000);
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
storage.readFromNBT(nbt);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
storage.writeToNBT(nbt);
}
/* IEnergyHandler */
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return true;
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return storage.receiveEnergy(maxReceive, simulate);
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return storage.extractEnergy(maxExtract, simulate);
}
@Override
public int getEnergyStored(ForgeDirection from) {
return storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return storage.getMaxEnergyStored();
}
}
@@ -1,10 +0,0 @@
/**
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
package cofh.api.energy;
import cofh.api.CoFHAPIProps;
import cpw.mods.fml.common.API;
-9
View File
@@ -1,9 +0,0 @@
/**
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
package cofh.api;
import cpw.mods.fml.common.API;
+27 -17
View File
@@ -39,6 +39,9 @@ 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;
@@ -52,10 +55,10 @@ import net.minecraft.item.Item;
name = "Forestry",
version = Version.VERSION,
dependencies = "required-after:Forge@[10.13.0.1207,);"
+ "after:Buildcraft|Core;"
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2")
+ "after:IC2@[2.0.140,)")
//, certificateFingerprint = Version.FINGERPRINT)
public class Forestry {
@@ -63,6 +66,22 @@ public class Forestry {
public static Forestry instance;
private File configFolder;
private static final Map<String, ForestryItem> mappedItems = new HashMap<String, ForestryItem>();
static {
mappedItems.put("Forestry:builderBackpack", ForestryItem.builderBackpack);
mappedItems.put("Forestry:builderBackpackT2", ForestryItem.builderBackpackT2);
mappedItems.put("Forestry:adventurerBackpack", ForestryItem.adventurerBackpack);
mappedItems.put("Forestry:adventurerBackpackT2", ForestryItem.adventurerBackpackT2);
mappedItems.put("Forestry:shortMead", ForestryItem.beverage);
mappedItems.put("Forestry:waterCan", ForestryItem.canWater);
mappedItems.put("Forestry:biofuelCan", ForestryItem.canEthanol);
mappedItems.put("Forestry:biomassCan", ForestryItem.canBiomass);
mappedItems.put("Forestry:bucketBiofuel", ForestryItem.bucketEthanol);
mappedItems.put("Forestry:refractoryBiofuel", ForestryItem.refractoryEthanol);
mappedItems.put("Forestry:waxCapsuleBiofuel", ForestryItem.waxCapsuleEthanol);
}
public Forestry() {
FuelManager.fermenterFuel = new ItemStackMap<FermenterFuel>();
FuelManager.moistenerResource = new ItemStackMap<MoistenerFuel>();
@@ -129,21 +148,12 @@ public class Forestry {
if (block != null) {
mapping.remap(Item.getItemFromBlock(block));
Proxies.log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block));
} else if (mapping.name.equals("Forestry:builderBackpack")) {
mapping.remap(ForestryItem.builderBackpack.item());
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpack.name());
} else if (mapping.name.equals("Forestry:builderBackpackT2")) {
mapping.remap(ForestryItem.builderBackpackT2.item());
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpackT2.name());
} else if (mapping.name.equals("Forestry:adventurerBackpack")) {
mapping.remap(ForestryItem.adventurerBackpack.item());
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpack.name());
} else if (mapping.name.equals("Forestry:adventurerBackpackT2")) {
mapping.remap(ForestryItem.adventurerBackpackT2.item());
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpackT2.name());
} else if (mapping.name.equals("Forestry:shortMead")) {
mapping.remap(ForestryItem.beverage.item());
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.beverage.name());
} else {
ForestryItem mappedItem = mappedItems.get(mapping.name);
if (mappedItem != null) {
mapping.remap(mappedItem.item());
Proxies.log.warning("Remapping item " + mapping.name + " to " + mappedItem.name());
}
}
}
}
@@ -10,17 +10,12 @@
******************************************************************************/
package forestry.apiculture;
import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.core.EnumErrorCode;
@@ -28,15 +23,19 @@ 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;
IBeeHousing housing;
private final IBeeHousing housing;
// Breeding
private int breedingTime;
private final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
private int throttle;
private int queenWorkCycleThrottle;
private IEffectData effectData[] = new IEffectData[2];
private IBee queen;
private IIndividual pollen;
@@ -51,7 +50,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
breedingTime = nbttagcompound.getInteger("BreedingTime");
throttle = nbttagcompound.getInteger("Throttle");
queenWorkCycleThrottle = nbttagcompound.getInteger("Throttle");
NBTTagList nbttaglist = nbttagcompound.getTagList("Offspring", 10);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
@@ -63,7 +62,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("BreedingTime", breedingTime);
nbttagcompound.setInteger("Throttle", throttle);
nbttagcompound.setInteger("Throttle", queenWorkCycleThrottle);
Stack<ItemStack> spawnCopy = new Stack<ItemStack>();
spawnCopy.addAll(spawn);
@@ -107,116 +106,186 @@ public class BeekeepingLogic implements IBeekeepingLogic {
@Override
public void update() {
resetQueen(null);
this.queen = null;
// Still something to spawn, try it
while (!spawn.isEmpty()) {
ItemStack next = spawn.peek();
if (housing.addProduct(next, true)) {
spawn.pop();
housing.setErrorState(EnumErrorCode.OK.ordinal());
} else
housing.setErrorState(EnumErrorCode.NOSPACE.ordinal());
if (!addPendingProducts()) {
return;
}
if (tryBreedingPrincess() || !hasHealthyQueen()) {
return;
}
if (!queenCanWork()) {
return;
}
// No queen? And no princess?
if (housing.getQueen() == null) {
housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
return;
}
// Princess available? Try to breed!
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()))
housing.setErrorState(EnumErrorCode.OK.ordinal());
else
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
tickBreed();
return;
}
// Can't continue if an item of the wrong type is in the queen slot.
if (!ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
return;
}
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
// Kill dying queens
if (!queen.isAlive()) {
killQueen(queen);
housing.setErrorState(EnumErrorCode.OK.ordinal());
return;
}
resetQueen(queen);
// Not while raining, at night or without light
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
if (state != EnumErrorCode.OK) {
housing.setErrorState(state.ordinal());
return;
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal())
housing.setErrorState(EnumErrorCode.OK.ordinal());
queenWorkTick();
}
private void queenWorkTick() {
// Effects only fire when queen can work.
effectData = queen.doEffect(effectData, housing);
// We have a queen, work!
throttle++;
if (throttle >= PluginApiculture.beeCycleTicks)
throttle = 0;
else
return;
// Need a flower
if (!queen.hasFlower(housing)) {
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
return;
} else
housing.setErrorState(EnumErrorCode.OK.ordinal());
// Work cycles are throttled, rather than occurring every game tick.
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());
}
}
}
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() {
// Produce and add stacks
ItemStack[] products = queen.produceStacks(housing);
housing.wearOutEquipment(1);
for (ItemStack stack : products) {
housing.addProduct(stack, false);
}
}
// Plant a flower
queen.plantFlowerRandom(housing);
private void doPollination() {
// Get pollen if none available yet
if (pollen == null) {
pollen = queen.retrievePollen(housing);
attemptedPollinations = 0;
if (pollen != null) {
if (housing.onPollenRetrieved(queen, pollen, false))
if (housing.onPollenRetrieved(queen, pollen, false)) {
pollen = null;
}
}
}
if (pollen != null) {
attemptedPollinations++;
if (queen.pollinateRandom(housing, pollen)
|| attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
if (queen.pollinateRandom(housing, pollen) || attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
pollen = null;
}
}
}
// Age the queen
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
private void updateQueenItemNBT() {
// Write the changed queen back into the item stack.
NBTTagCompound nbttagcompound = new NBTTagCompound();
queen.writeToNBT(nbttagcompound);
housing.getQueen().setTagCompound(nbttagcompound);
return;
}
private void resetQueen(IBee bee) {
this.queen = bee;
private boolean addPendingProducts() {
EnumErrorCode housingErrorState = null;
while (!spawn.isEmpty()) {
ItemStack next = spawn.peek();
if (housing.addProduct(next, true)) {
spawn.pop();
housingErrorState = EnumErrorCode.OK;
} else {
housingErrorState = EnumErrorCode.NOSPACE;
break;
}
}
if (housingErrorState != null) {
try {
housing.setErrorState(housingErrorState);
} catch (Error e) {
housing.setErrorState(housingErrorState.ordinal());
}
}
return housingErrorState != EnumErrorCode.NOSPACE;
}
private boolean hasHealthyQueen() {
boolean hasQueen = true;
EnumErrorCode housingErrorState = null;
if (housing.getQueen() == null || !ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
housingErrorState = EnumErrorCode.NOQUEEN;
hasQueen = false;
} 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 {
housing.setErrorState(housingErrorState);
} catch (Error e) {
housing.setErrorState(housingErrorState.ordinal());
}
}
return hasQueen;
}
private boolean tryBreedingPrincess() {
boolean isBreedingPrincess = false;
// Princess available? Try to breed!
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone())) {
housing.setErrorState(EnumErrorCode.OK.ordinal());
} else {
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
}
tickBreed();
isBreedingPrincess = true;
}
return isBreedingPrincess;
}
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);
}
return canWork;
} catch (Error e) {
Proxies.log.logErrorAPI("Forestry", e, IBee.class);
return queenCanWorkDeprecated();
}
}
// 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());
}
return canWork;
}
// / BREEDING
@@ -1,255 +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 java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.core.config.Defaults;
import forestry.core.config.Version;
import forestry.core.proxy.Proxies;
import forestry.core.utils.CommandMC;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
public class CommandBeekeepingMode extends CommandMC {
String[] modeStrings;
public CommandBeekeepingMode() {
modeStrings = new String[PluginApiculture.beeInterface.getBeekeepingModes().size()];
for (int i = 0; i < PluginApiculture.beeInterface.getBeekeepingModes().size(); i++)
modeStrings[i] = PluginApiculture.beeInterface.getBeekeepingModes().get(i).getName();
}
@Override
public int compareTo(Object arg0) {
return this.getCommandName().compareTo(((ICommand) arg0).getCommandName());
}
@Override
public String getCommandName() {
return "beekeeping";
}
@Override
public String getCommandUsage(ICommandSender var1) {
return "/" + this.getCommandName() + " help";
}
@SuppressWarnings("rawtypes")
@Override
public List getCommandAliases() {
return null;
}
@Override
public void processCommand(ICommandSender sender, String[] arguments) {
if (arguments.length <= 0)
throw new WrongUsageException(StringUtil.localizeAndFormat("chat.help", this.getCommandUsage(sender)));
if (arguments[0].matches("list"))
listModes(sender, arguments);
else if (arguments[0].matches("info"))
listModeInfo(sender, arguments);
else if (arguments[0].matches("set")) {
if (arguments.length <= 1)
throw new WrongUsageException("/" + this.getCommandName() + " set [<world-#>] <mode-name>");
World world = getWorld(sender, arguments);
String desired = arguments[arguments.length - 1];
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
if (mode == null)
throw new CommandException(StringUtil.localize("chat.bees.command.beekeeping.error"), desired);
PluginApiculture.beeInterface.setBeekeepingMode(world, mode.getName());
func_152373_a(sender, this, StringUtil.localize("chat.bees.command.beekeeping.set"), mode.getName());
} else if (arguments[0].matches("save")) {
if (arguments.length <= 1)
throw new WrongUsageException("/" + this.getCommandName() + " save <player-name>");
saveStatistics(sender, arguments);
} else if (arguments[0].matches("help")) {
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.help.0", this.getCommandName()));
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.1"));
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.2"));
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.3"));
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.4"));
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.5"));
}
}
private void saveStatistics(ICommandSender sender, String[] arguments) {
String newLine = System.getProperty("line.separator");
World world = getWorld(sender, arguments);
String player = arguments[1];
Collection<String> statistics = new ArrayList<String>();
statistics.add(String.format("Beekeeping statistics for %s on %s:", player, DateFormat.getInstance().format(new Date())));
statistics.add("");
statistics.add("MODE: " + PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
statistics.add("");
GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(player);
IApiaristTracker tracker = PluginApiculture.beeInterface.getBreedingTracker(world, profile);
if (tracker == null)
statistics.add("No statistics found.");
else {
statistics.add("BRED:");
statistics.add("-----");
statistics.add("");
statistics.add("Queens:\t\t" + tracker.getQueenCount());
statistics.add("Princesses:\t" + tracker.getPrincessCount());
statistics.add("Drones:\t\t" + tracker.getDroneCount());
statistics.add("");
Collection<IAlleleBeeSpecies> species = new ArrayList<IAlleleBeeSpecies>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
species.add((IAlleleBeeSpecies) allele);
statistics.add(String.format("SPECIES (%s):", species.size()));
statistics.add("-------------");
statistics.add("");
for (IAlleleBeeSpecies allele : species)
statistics.add(generateSpeciesListEntry(allele, tracker));
}
File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player + ".log");
try {
if (file.getParentFile() != null)
file.getParentFile().mkdirs();
if (!file.exists() && !file.createNewFile()) {
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error1"));
return;
}
if (!file.canWrite()) {
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error2"));
return;
}
FileOutputStream fileout = new FileOutputStream(file);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileout, "UTF-8"));
writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine);
for (String line : statistics)
writer.write(line + newLine);
writer.close();
} catch (Exception ex) {
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error3"));
ex.printStackTrace();
}
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.stats.saved", player));
}
private String generateSpeciesListEntry(IAlleleBeeSpecies species, IApiaristTracker tracker) {
String discovered = "[ ]";
if (tracker.isDiscovered(species))
discovered = "[ X ]";
String blacklisted = "[ ]";
if (AlleleManager.alleleRegistry.isBlacklisted(species.getUID()))
blacklisted = "[ BL ]";
String notcounted = "[ ]";
if (!species.isCounted())
notcounted = "[ NC ]";
return String.format("%s %s %s\t%-40s %-20s %-20s", discovered, blacklisted, notcounted, species.getUID(), species.getName(), species.getAuthority());
}
private void listModes(ICommandSender sender, String[] arguments) {
World world = getWorld(sender, arguments);
String message = StringUtil.localize("chat.bees.command.mode.current");
message = message.replaceAll("%MODE", PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
message = message.replaceAll("%WORLD", String.valueOf(world.getWorldInfo().getSaveVersion()));
sendChatMessage(sender, message);
String help = "";
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) {
if (!help.isEmpty())
help += ", ";
help += mode.getName();
}
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.mode.help", help));
return;
}
private void listModeInfo(ICommandSender sender, String[] arguments) {
if (arguments.length <= 1)
throw new WrongUsageException("/" + this.getCommandName() + " info <mode-name>");
IBeekeepingMode found = null;
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes())
if (mode.getName().equalsIgnoreCase(arguments[1])) {
found = mode;
break;
}
if (found == null)
throw new CommandException("No beekeeping mode called '%s' is available.", arguments[1]);
sendChatMessage(sender, "\u00A7aMode: " + found.getName());
for (String desc : found.getDescription())
sendChatMessage(sender, StringUtil.localize(desc));
}
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
if (sender instanceof EntityPlayer)
return Proxies.common.isOp((EntityPlayer) sender);
else
return sender.canCommandSenderUseCommand(4, getCommandName());
}
@SuppressWarnings("rawtypes")
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] incomplete) {
return getListOfStringsMatchingLastWord(incomplete, modeStrings);
}
}
@@ -1,122 +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 java.util.ArrayList;
import java.util.List;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.core.utils.CommandMC;
import forestry.plugins.PluginApiculture;
public class CommandGiveBee extends CommandMC {
EnumBeeType type;
public CommandGiveBee(EnumBeeType type) {
this.type = type;
}
@Override
public String getCommandName() {
return "give" + type.toString().toLowerCase();
}
@Override
public String getCommandUsage(ICommandSender par1ICommandSender) {
return "/" + getCommandName() + " <player-name> <species-name>";
}
@Override
public void processCommand(ICommandSender sender, String[] arguments) {
if (arguments.length >= 2) {
EntityPlayer player = getPlayer(sender, arguments[0]);
String parameter = arguments[1];
IAlleleBeeSpecies species = null;
search: for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
if (!uid.equals(parameter))
continue;
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
break search;
}
}
search: if (species == null)
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
if (((IAlleleBeeSpecies) allele).getName().equals(parameter)) {
species = (IAlleleBeeSpecies) allele;
break search;
}
if (species == null)
throw new SpeciesNotFoundException(parameter);
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
if (template == null)
throw new TemplateNotFoundException(species);
IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template);
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome);
if(this.type == EnumBeeType.QUEEN)
bee.mate(bee);
ItemStack beestack = PluginApiculture.beeInterface.getMemberStack(bee, type.ordinal());
player.dropPlayerItemWithRandomChoice(beestack, true);
func_152373_a(sender, this, "Player %s was given a %s bee.", player.getCommandSenderName(), ((IAlleleSpecies) template[0]).getName());
} else
throw new WrongUsageException("/" + getCommandName() + " <player-name> <species-name>");
}
/**
* Adds the strings available in this command to the given list of tab completion options.
*/
@SuppressWarnings("rawtypes")
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] parameters) {
if (parameters.length == 1)
return getListOfStringsMatchingLastWord(parameters, this.getPlayers());
else if (parameters.length == 2)
return getListOfStringsMatchingLastWord(parameters, this.getSpecies());
else
return null;
}
protected String[] getSpecies() {
List<String> species = new ArrayList<String>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
species.add(((IAlleleSpecies) allele).getName());
return species.toArray(new String[] {});
}
}
@@ -10,18 +10,16 @@
******************************************************************************/
package forestry.apiculture;
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;
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 {
@@ -42,10 +40,7 @@ public class FlowerProviderCacti implements IFlowerProvider {
}
private boolean checkFlowerPot(int meta) {
if (meta == 9)
return true;
else
return false;
return meta == 9;
}
@Override
@@ -10,19 +10,16 @@
******************************************************************************/
package forestry.apiculture;
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;
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 {
@@ -10,20 +10,17 @@
******************************************************************************/
package forestry.apiculture;
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;
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 {
@@ -10,20 +10,17 @@
******************************************************************************/
package forestry.apiculture;
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;
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 {
@@ -46,10 +43,7 @@ public class FlowerProviderJungle implements IFlowerProvider {
}
private boolean checkFlowerPot(int meta) {
if (meta == 11)
return true;
else
return false;
return meta == 11;
}
@Override
@@ -10,20 +10,17 @@
******************************************************************************/
package forestry.apiculture;
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;
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 {
@@ -45,10 +42,7 @@ public class FlowerProviderMushroom implements IFlowerProvider {
}
private boolean checkFlowerPot(int meta) {
if (meta == 7 || meta == 8)
return true;
else
return false;
return meta == 7 || meta == 8;
}
@Override
@@ -10,18 +10,16 @@
******************************************************************************/
package forestry.apiculture;
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;
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 {
@@ -10,16 +10,6 @@
******************************************************************************/
package forestry.apiculture;
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;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
@@ -27,6 +17,13 @@ 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 {
@@ -56,10 +53,7 @@ public class FlowerProviderVanilla implements IFlowerProvider {
}
private boolean checkFlowerPot(int meta) {
if (meta == 1 || meta == 2)
return true;
else
return false;
return meta == 1 || meta == 2;
}
@Override
@@ -106,7 +100,7 @@ public class FlowerProviderVanilla implements IFlowerProvider {
@Override
public ItemStack[] getItemStacks() {
return FlowerManager.plainFlowers.toArray(new ItemStack[0]);
return FlowerManager.plainFlowers.toArray(new ItemStack[FlowerManager.plainFlowers.size()]);
}
}
@@ -10,20 +10,17 @@
******************************************************************************/
package forestry.apiculture;
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;
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 {
@@ -26,7 +26,6 @@ import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
import forestry.apiculture.gui.ContainerAlvearySieve;
import forestry.apiculture.gui.ContainerAlvearySwarmer;
import forestry.apiculture.gui.ContainerApiary;
import forestry.apiculture.gui.ContainerBeealyzer;
import forestry.apiculture.gui.ContainerHabitatLocator;
import forestry.apiculture.gui.ContainerImprinter;
import forestry.apiculture.gui.GuiAlveary;
@@ -41,6 +40,7 @@ import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory;
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
import forestry.core.GuiHandlerBase;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.network.GuiId;
import forestry.plugins.PluginApiculture;
@@ -73,7 +73,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
case BeealyzerGUI:
equipped = getEquippedItem(player);
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
@@ -83,7 +83,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
case HabitatLocatorGUI:
equipped = getEquippedItem(player);
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
@@ -93,7 +93,10 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
return new GuiImprinter(player.inventory, new ImprinterInventory(player));
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
@@ -130,19 +133,19 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
case BeealyzerGUI:
equipped = getEquippedItem(player);
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
synchApiaristTracker(world, player);
return new ContainerBeealyzer(player.inventory, new BeealyzerInventory(player, equipped));
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 = getEquippedItem(player);
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
@@ -153,7 +156,10 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
case ImprinterGUI:
synchApiaristTracker(world, player);
return new ContainerImprinter(player.inventory, new ImprinterInventory(player));
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
@@ -10,15 +10,13 @@
******************************************************************************/
package forestry.apiculture;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
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 {
@@ -10,10 +10,9 @@
******************************************************************************/
package forestry.apiculture;
import net.minecraft.world.World;
import forestry.core.interfaces.ISaveEventHandler;
import forestry.plugins.PluginApiculture;
import net.minecraft.world.World;
public class SaveEventHandlerApiculture implements ISaveEventHandler {
@@ -10,9 +10,19 @@
******************************************************************************/
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;
@@ -23,24 +33,13 @@ 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.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.plugins.PluginApiculture;
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
public static void registerVillageComponents() {
try {
MapGenStructureIO.func_143031_a(ComponentVillageBeeHouse.class, "Forestry:BeeHouse");
} catch (Throwable e) {
Proxies.log.severe("Failed to register village beehouse.");
}
}
@@ -59,7 +58,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
@Override
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int size) {
return new StructureVillagePieces.PieceWeight(ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, 0 + size, 1 + size));
return new StructureVillagePieces.PieceWeight(ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, size, 1 + size));
}
@Override
@@ -0,0 +1,57 @@
/*******************************************************************************
* 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.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;
public class BeeModeHelper implements ICommandModeHelper {
@Override
public String[] getModeNames() {
ArrayList<IBeekeepingMode> beekeepingModes = PluginApiculture.beeInterface.getBeekeepingModes();
int modeStringCount = beekeepingModes.size();
List<String> modeStrings = new ArrayList<String>(modeStringCount);
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)
return null;
return mode.getName();
}
@Override
public String getModeName(World world) {
return PluginApiculture.beeInterface.getBeekeepingMode(world).getName();
}
@Override
public void setMode(World world, String modeName) {
PluginApiculture.beeInterface.setBeekeepingMode(world, modeName);
}
@Override
public Iterable<String> getDescription(String modeName) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(modeName);
return mode.getDescription();
}
}
@@ -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.commands;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
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 {
@Override
public String getUnlocalizedSaveStatsString() {
return "for.chat.command.forestry.bee.save.stats";
}
@Override
public void addExtraInfo(Collection<String> statistics, IBreedingTracker 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()));
String queen = StatCollector.translateToLocal("for.bees.grammar.queen.type");
String princess = StatCollector.translateToLocal("for.bees.grammar.princess.type");
String drone = StatCollector.translateToLocal("for.bees.grammar.drone.type");
statistics.add(queen + ":\t\t" + tracker.getQueenCount());
statistics.add(princess + ":\t" + tracker.getPrincessCount());
statistics.add(drone + ":\t\t" + tracker.getDroneCount());
statistics.add("");
}
@Override
public Collection<IAlleleSpecies> getSpecies() {
Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
species.add((IAlleleBeeSpecies) allele);
return species;
}
@Override
public String getFileSuffix() {
return "bees";
}
@Override
public IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile) {
return PluginApiculture.beeInterface.getBreedingTracker(world, gameProfile);
}
}
@@ -0,0 +1,32 @@
/*******************************************************************************
* 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.commands;
import forestry.core.commands.CommandMode;
import forestry.core.commands.CommandSaveStats;
import forestry.core.commands.ICommandModeHelper;
import forestry.core.commands.IStatsSaveHelper;
import forestry.core.commands.SubCommand;
public class CommandBee extends SubCommand {
public CommandBee() {
super("bee");
addAlias("beekeeping");
IStatsSaveHelper saveHelper = new BeeStatsSaveHelper();
ICommandModeHelper modeHelper = new BeeModeHelper();
addChildCommand(new CommandMode(modeHelper));
addChildCommand(new CommandSaveStats(saveHelper, modeHelper));
addChildCommand(new CommandBeeGive());
}
}
@@ -0,0 +1,168 @@
/*******************************************************************************
* 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.commands;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
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 {
private final String beeTypeHelpString;
private final String[] beeTypeArr;
public CommandBeeGive() {
super("give");
setPermLevel(PermLevel.ADMIN);
List<String> beeTypeStrings = new ArrayList<String>();
for (EnumBeeType type : EnumBeeType.values()) {
if (type == EnumBeeType.NONE)
continue;
beeTypeStrings.add(type.getName());
}
beeTypeArr = beeTypeStrings.toArray(new String[beeTypeStrings.size()]);
StringBuilder beeTypeHelp = new StringBuilder();
String separator = ", ";
Iterator<String> iter = beeTypeStrings.iterator();
while (iter.hasNext()) {
beeTypeHelp.append(iter.next());
if (iter.hasNext())
beeTypeHelp.append(separator);
}
beeTypeHelpString = beeTypeHelp.toString();
}
@Override
public void processSubCommand(ICommandSender sender, String[] arguments) {
if (arguments.length < 2) {
printHelp(sender);
return;
}
IBeeGenome beeGenome = getBeeGenome(arguments[0]);
EnumBeeType beeType = getBeeType(arguments[1]);
if (beeType == EnumBeeType.NONE) {
printHelp(sender);
return;
}
EntityPlayer player;
if (arguments.length == 3) {
player = CommandHelpers.getPlayer(sender, arguments[2]);
} else {
player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName());
}
if (player == null) {
printHelp(sender);
return;
}
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome);
if(beeType == EnumBeeType.QUEEN)
bee.mate(bee);
ItemStack beeStack = PluginApiculture.beeInterface.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());
}
private static IBeeGenome getBeeGenome(String speciesName) {
IAlleleBeeSpecies species = null;
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
if (!uid.equals(speciesName))
continue;
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
break;
}
}
if (species == null) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(speciesName)) {
species = (IAlleleBeeSpecies) allele;
break;
}
}
}
if (species == null)
throw new SpeciesNotFoundException(speciesName);
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
if (template == null)
throw new TemplateNotFoundException(species);
return PluginApiculture.beeInterface.templateAsGenome(template);
}
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters) {
if (parameters.length == 1) {
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
tabCompletion.add("help");
return tabCompletion;
} else if (parameters.length == 2) {
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr);
} else if (parameters.length == 3) {
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
}
return null;
}
String[] getSpecies() {
List<String> species = new ArrayList<String>();
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))
return beeType;
}
return EnumBeeType.NONE;
}
@Override
public void printHelp(ICommandSender sender) {
super.printHelp(sender);
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.available", beeTypeHelpString);
}
}
@@ -10,20 +10,18 @@
******************************************************************************/
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.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 {
@@ -10,9 +10,14 @@
******************************************************************************/
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;
@@ -23,14 +28,6 @@ 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() {
@@ -105,13 +102,13 @@ public class BlockAlveary extends BlockStructure {
public static final int BOTTOM = 2;
public static final int LEFT = 3;
public static final int RIGHT = 4;
public static final int TX_55_SWOF = 5;
public static final int TX_56_SWON = 6;
public static final int TX_57_HTOF = 7;
public static final int TX_58_HTON = 8;
public static final int TX_71_FNOF = 9;
public static final int TX_72_FNON = 10;
public static final int TX_73_VLVE = 11;
public static final int ALVEARY_SWARMER_OFF = 5;
public static final int ALVEARY_SWARMER_ON = 6;
public static final int ALVEARY_HEATER_OFF = 7;
public static final int ALVEARY_HEATER_ON = 8;
public static final int ALVEARY_FAN_OFF = 9;
public static final int ALVEARY_FAN_ON = 10;
public static final int ALVEARY_HYGRO = 11;
public static final int STABILISER = 12;
public static final int SIEVE = 13;
@@ -152,13 +149,13 @@ public class BlockAlveary extends BlockStructure {
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
return icons[TX_55_SWOF];
return icons[ALVEARY_SWARMER_OFF];
case TileAlvearyFan.BLOCK_META:
return icons[TX_71_FNOF];
return icons[ALVEARY_FAN_OFF];
case TileAlvearyHeater.BLOCK_META:
return icons[TX_57_HTOF];
return icons[ALVEARY_HEATER_OFF];
case TileAlvearyHygroregulator.BLOCK_META:
return icons[TX_73_VLVE];
return icons[ALVEARY_HYGRO];
case TileAlvearyStabiliser.BLOCK_META:
return icons[STABILISER];
case TileAlvearySieve.BLOCK_META:
@@ -10,10 +10,21 @@
******************************************************************************/
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;
@@ -26,17 +37,6 @@ 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.BeeManager;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.config.Config;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
public class BlockBeehives extends BlockContainer {
public BlockBeehives() {
@@ -44,6 +44,7 @@ public class BlockBeehives extends BlockContainer {
setLightLevel(0.8f);
setHardness(1.0f);
setCreativeTab(Tabs.tabApiculture);
setHarvestLevel("scoop", 0);
}
@Override
@@ -65,7 +66,7 @@ public class BlockBeehives extends BlockContainer {
if (tile instanceof TileSwarm) {
TileSwarm swarm = (TileSwarm) tile;
if (swarm.containsBees())
for (ItemStack beeStack : swarm.contained.getStacks())
for (ItemStack beeStack : InvTools.getStacks(swarm.contained))
if (beeStack != null)
StackUtils.dropItemStackAsEntity(beeStack, world, x, y, z);
}
@@ -84,7 +85,7 @@ public class BlockBeehives extends BlockContainer {
return ret;
}
ArrayList<IHiveDrop> dropList = BeeManager.hiveDrops[metadata - 1];
List<IHiveDrop> dropList = getDropsForHive(metadata);
Collections.shuffle(dropList);
// Grab a princess
@@ -123,6 +124,26 @@ public class BlockBeehives extends BlockContainer {
return meta;
}
private List<IHiveDrop> getDropsForHive(int meta) {
String hiveName = getHiveNameForMeta(meta);
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;
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
@@ -155,7 +176,7 @@ 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) {
@@ -10,10 +10,17 @@
******************************************************************************/
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 java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -29,20 +36,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
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;
public class BlockCandle extends BlockTorch {
private final ArrayList<Item> lightingItems = new ArrayList<Item>();
@@ -111,7 +107,7 @@ public class BlockCandle extends BlockTorch {
@SideOnly(Side.CLIENT)
public IIcon getTextureFromPassAndMeta(int meta, int pass) {
IIcon i = this.unlitStump;
IIcon i;
if (pass == 0) {
if (isLit(meta)) {
i = this.litTip;
@@ -180,6 +176,7 @@ public class BlockCandle extends BlockTorch {
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)) {
@@ -10,9 +10,16 @@
******************************************************************************/
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;
@@ -23,16 +30,6 @@ 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() {
@@ -10,12 +10,6 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.core.ITileStructure;
import forestry.core.config.ForestryBlock;
@@ -23,7 +17,11 @@ 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.utils.Vect;
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 {
@@ -35,13 +33,11 @@ public class StructureLogicAlveary extends StructureLogic {
public static final HashSet<Block> slabBlocks = new HashSet<Block>();
static {
slabBlocks.add(Blocks.stone_slab);
slabBlocks.add(Blocks.wooden_slab);
slabBlocks.add(ForestryBlock.slabs1.block());
slabBlocks.add(ForestryBlock.slabs2.block());
slabBlocks.add(ForestryBlock.slabs3.block());
if (ForestryBlock.slabs4 != null)
slabBlocks.add(ForestryBlock.slabs4.block());
slabBlocks.add(ForestryBlock.slabs4.block());
}
public StructureLogicAlveary(ITileStructure structure) {
@@ -10,30 +10,39 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import buildcraft.api.statements.ITriggerExternal;
import java.util.Collection;
import java.util.LinkedList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.core.IStructureLogic;
import forestry.api.core.ITileStructure;
import forestry.apiculture.trigger.ApicultureTriggers;
import forestry.core.config.Defaults;
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.proxy.Proxies;
import forestry.core.triggers.ForestryTrigger;
import forestry.core.utils.TileInventoryAdapter;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import java.util.LinkedList;
import buildcraft.api.statements.ITriggerExternal;
public abstract class TileAlveary extends TileForestry implements IAlvearyComponent {
protected TileInventoryAdapter inventory;
private final IStructureLogic structureLogic;
private boolean isMaster;
protected int masterX, masterZ;
protected int masterY = -99;
protected final int componentBlockMeta;
public TileAlveary(int componentBlockMeta) {
@@ -84,8 +93,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
/* LOADING & SAVING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
this.isMaster = nbttagcompound.getBoolean("IsMaster");
this.masterX = nbttagcompound.getInteger("MasterX");
this.masterY = nbttagcompound.getInteger("MasterY");
@@ -93,7 +100,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
// Init for master state
if (isMaster)
makeMaster();
makeMaster();
super.readFromNBT(nbttagcompound);
structureLogic.readFromNBT(nbttagcompound);
}
@@ -114,21 +123,26 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
}
@Override
public void fromPacketPayload(PacketPayload payload) {
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 2);
payload.shortPayload[0] = (short) (isMaster() ? 1 : 0);
// so the client can know if it is part of an integrated structure
payload.shortPayload[1] = (short) this.masterY;
return payload;
}
@Override
public PacketPayload getPacketPayload() {
return null;
public void fromPacketPayload(PacketPayload payload) {
if (payload.shortPayload[0] > 0)
makeMaster();
// so the client can know if it is part of an integrated structure
this.masterY = payload.shortPayload[1];
}
/* ITILESTRUCTURE */
IStructureLogic structureLogic;
private boolean isMaster;
protected int masterX, masterZ;
protected int masterY = -99;
@Override
public String getTypeUID() {
return structureLogic.getTypeUID();
@@ -144,7 +158,7 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
setCentralTE(null);
isMaster = true;
if (inventory == null)
if (getInternalInventory() instanceof FakeInventoryAdapter)
createInventory();
}
@@ -211,8 +225,13 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
}
@Override
public IInventory getInventory() {
return inventory;
public final IInventoryAdapter getInventory() {
return getStructureInventory();
}
@Override
public IInventoryAdapter getStructureInventory() {
return getInternalInventory();
}
/* IALVEARY COMPONENT */
@@ -245,18 +264,14 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
public void removeBeeListener(IBeeListener event) {
}
// / ITRIGGERPROVIDER
/* ITRIGGERPROVIDER */
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
public LinkedList<ITriggerExternal> getCustomTriggers() {
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
res.add(ForestryTrigger.missingQueen);
res.add(ForestryTrigger.missingDrone);
res.add(ApicultureTriggers.missingQueen);
res.add(ApicultureTriggers.missingDrone);
return res;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return Utils.isUseableByPlayer(player, this, worldObj, xCoord, yCoord, zCoord);
}
}
@@ -32,17 +32,16 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.boundaryUp = boundaryUp;
}
}
protected EnergyManager energyManager;
ClimateControl climateControl;
private int transferTime = 0;
private int animationDelay = 0;
protected final EnergyManager energyManager;
private final ClimateControl climateControl;
private int workingTime = 0;
private final int textureOff;
private final int textureOn;
public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) {
super(componentBlockMeta);
this.climateControl = control;
energyManager = new EnergyManager(1000, 250, 2000);
energyManager = new EnergyManager(1000, 50, 2000);
energyManager.setReceiveOnly();
this.textureOff = textureOff;
this.textureOn = textureOn;
@@ -60,28 +59,22 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
if (!this.hasMaster())
return;
if (energyManager.consumeEnergyToDoWork()) {
boolean wasInactive = (workingTime == 0);
transferTime = energyManager.getEnergyPerWork();
if (animationDelay <= 0) {
animationDelay = 100;
sendNetworkUpdate();
} else
animationDelay = 100;
if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
// consume 10 RF per tick of work
workingTime += energyManager.getEnergyPerWork() / 10;
}
if (transferTime > 0) {
transferTime--;
if (workingTime > 0) {
workingTime--;
IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
if (component != null)
component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp);
}
if (animationDelay > 0) {
animationDelay--;
if (animationDelay <= 0)
sendNetworkUpdate();
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
sendNetworkUpdate();
}
}
@@ -93,7 +86,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if (animationDelay > 0)
if (workingTime > 0)
return textureOn;
else
return textureOff;
@@ -104,23 +97,23 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
energyManager.readFromNBT(nbttagcompound);
transferTime = nbttagcompound.getInteger("Heating");
workingTime = nbttagcompound.getInteger("Heating");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
energyManager.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("Heating", transferTime);
nbttagcompound.setInteger("Heating", workingTime);
}
/* NETWORK */
@Override
public void fromPacketPayload(PacketPayload payload) {
short delay = payload.shortPayload[0];
if (animationDelay != delay) {
animationDelay = delay;
short workingTime = payload.shortPayload[0];
if (this.workingTime != workingTime) {
this.workingTime = workingTime;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
@@ -128,7 +121,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
payload.shortPayload[0] = (short) animationDelay;
payload.shortPayload[0] = (short) workingTime;
return payload;
}
@@ -16,7 +16,7 @@ public class TileAlvearyFan extends TileAlvearyClimatiser {
public static final int BLOCK_META = 3;
public TileAlvearyFan() {
super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.TX_71_FNOF, BlockAlveary.TX_72_FNON, BLOCK_META);
super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.ALVEARY_FAN_OFF, BlockAlveary.ALVEARY_FAN_ON, BLOCK_META);
}
}
@@ -12,14 +12,11 @@ package forestry.apiculture.gadgets;
public class TileAlvearyHeater extends TileAlvearyClimatiser {
public static final int TEXTURE_OFF = 57;
public static final int TEXTURE_ON = 58;
/* CONSTANTS */
public static final int BLOCK_META = 4;
public TileAlvearyHeater() {
super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.TX_57_HTOF, BlockAlveary.TX_58_HTON, BLOCK_META);
super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.ALVEARY_HEATER_OFF, BlockAlveary.ALVEARY_HEATER_ON, BLOCK_META);
}
}
@@ -19,22 +19,20 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.core.ForestryAPI;
import forestry.core.config.Defaults;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.Fluids;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankContainer {
@@ -43,6 +41,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
/* RECIPE MANAGMENT */
private static class HygroregulatorRecipe {
public final FluidStack liquid;
public final int transferTime;
public final float humidChange;
@@ -56,12 +55,13 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
}
public static final short SLOT_INPUT = 0;
private final HygroregulatorRecipe[] recipes;
/* MEMBERS */
InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv");
private final TankManager tankManager;
private FilteredTank liquidTank;
private final FilteredTank liquidTank;
private HygroregulatorRecipe currentRecipe;
private int transferTime;
@@ -69,16 +69,27 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
public TileAlvearyHygroregulator() {
super(BLOCK_META);
Fluid water = LiquidHelper.getFluid(Defaults.LIQUID_WATER);
Fluid lava = LiquidHelper.getFluid(Defaults.LIQUID_LAVA);
Fluid liquidIce = LiquidHelper.getFluid(Defaults.LIQUID_ICE);
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;
}
});
Fluid water = Fluids.WATER.getFluid();
Fluid lava = Fluids.LAVA.getFluid();
Fluid liquidIce = Fluids.ICE.getFluid();
liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce);
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) };
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)};
}
@Override
@@ -86,19 +97,15 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
player.openGui(ForestryAPI.instance, GuiId.HygroregulatorGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
}
@Override
public String getInventoryName() {
return getUnlocalizedName();
}
/* UPDATING */
private HygroregulatorRecipe getRecipe(FluidStack liquid) {
HygroregulatorRecipe recipe = null;
for (HygroregulatorRecipe rec : recipes)
for (HygroregulatorRecipe rec : recipes) {
if (rec.liquid.isFluidEqual(liquid)) {
recipe = rec;
break;
}
}
return recipe;
}
@@ -131,17 +138,11 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
return;
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(canInventory.getStackInSlot(0));
if (container != null &&
(container.fluid.getFluid() == FluidRegistry.WATER || container.fluid.getFluid() == FluidRegistry.LAVA)) {
IInventoryAdapter canInventory = getInternalInventory();
canInventory.setInventorySlotContents(0, StackUtils.replenishByContainer(this, canInventory.getStackInSlot(0), container, liquidTank));
if (canInventory.getStackInSlot(0).stackSize <= 0)
canInventory.setInventorySlotContents(0, null);
}
}
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null)
FluidHelper.drainContainers(tankManager, canInventory, 0);
}
@@ -154,9 +155,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
canInventory.readFromNBT(nbttagcompound);
tankManager.readTanksFromNBT(nbttagcompound);
transferTime = nbttagcompound.getInteger("TransferTime");
@@ -170,9 +168,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
canInventory.writeToNBT(nbttagcompound);
tankManager.writeTanksToNBT(nbttagcompound);
nbttagcompound.setInteger("TransferTime", transferTime);
@@ -187,102 +182,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
return BlockAlveary.TX_73_VLVE;
}
@Override
public IInventory getInventory() {
return canInventory;
}
/* IINVENTORY */
@Override
public int getSizeInventory() {
if (canInventory != null)
return canInventory.getSizeInventory();
else
return 0;
}
@Override
public ItemStack getStackInSlot(int slotIndex) {
if (canInventory != null)
return canInventory.getStackInSlot(slotIndex);
else
return null;
}
@Override
public ItemStack decrStackSize(int slotIndex, int amount) {
if (canInventory != null)
return canInventory.decrStackSize(slotIndex, amount);
else
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex) {
if (canInventory != null)
return canInventory.getStackInSlotOnClosing(slotIndex);
else
return null;
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
// Client side handling for container synch
if (canInventory == null && !Proxies.common.isSimulating(worldObj))
createInventory();
if (canInventory != null)
canInventory.setInventorySlotContents(slotIndex, itemstack);
}
@Override
public int getInventoryStackLimit() {
if (canInventory != null)
return canInventory.getInventoryStackLimit();
else
return 0;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return super.isUseableByPlayer(player);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean hasCustomInventoryName() {
return super.hasCustomInventoryName();
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
if (slotIndex == 0) {
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
if (fluid == null || fluid.amount <= 0)
return false;
return liquidTank.accepts(fluid.getFluid());
}
return super.isItemValidForSlot(slotIndex, itemstack);
return BlockAlveary.ALVEARY_HYGRO;
}
/* ILIQUIDTANKCONTAINER */
@@ -296,6 +196,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
return tankManager.fill(from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return tankManager.drain(from, resource, doDrain);
}
@@ -321,8 +222,10 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
@Override
public void getGUINetworkData(int messageId, int data) {}
public void getGUINetworkData(int messageId, int data) {
}
@Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {}
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
}
}
@@ -13,8 +13,6 @@ package forestry.apiculture.gadgets;
import java.util.LinkedHashSet;
import java.util.Set;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
@@ -23,31 +21,40 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.core.*;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorState;
import forestry.api.core.ITileStructure;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.gui.ContainerAlveary;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.ForestryItem;
import forestry.core.config.Defaults;
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.GuiId;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketInventoryStack;
import forestry.core.proxy.Proxies;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.TileInventoryAdapter;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, ISpecialInventory, IBeeHousing, IClimatised, IHintSource {
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource {
// / CONSTANTS
public static final int SLOT_QUEEN = 0;
@@ -58,9 +65,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
// / MEMBERS
protected IBeekeepingLogic beekeepingLogic;
protected int biomeId;
protected float temperature;
protected float humidity;
protected BiomeGenBase biome;
protected float tempChange = 0.0f;
protected float humidChange = 0.0f;
private int displayHealthMax = 0;
@@ -78,6 +83,17 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ);
}
@Override
public void validate() {
super.validate();
setBiomeInformation();
}
private void setBiomeInformation() {
this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
setErrorState(EnumErrorCode.OK);
}
/* LOADING & SAVING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
@@ -86,8 +102,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
this.tempChange = nbttagcompound.getFloat("TempChange");
this.humidChange = nbttagcompound.getFloat("HumidChange");
if (inventory != null)
inventory.readFromNBT(nbttagcompound);
if (beekeepingLogic != null)
beekeepingLogic.readFromNBT(nbttagcompound);
@@ -100,8 +114,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
nbttagcompound.setFloat("TempChange", tempChange);
nbttagcompound.setFloat("HumidChange", humidChange);
if (inventory != null)
inventory.writeToNBT(nbttagcompound);
if (beekeepingLogic != null)
beekeepingLogic.writeToNBT(nbttagcompound);
@@ -111,11 +123,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public void initialize() {
super.initialize();
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
this.biomeId = biome.biomeID;
this.temperature = biome.temperature;
this.humidity = biome.rainfall;
setErrorState(EnumErrorCode.OK);
setBiomeInformation();
}
@Override
@@ -137,8 +145,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
return;
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
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);
@@ -163,17 +175,18 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
if (!isMaster())
return;
ISidedInventory inventory = getStructureInventory();
if (inventory == null)
return;
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
if (PluginApiculture.beeInterface.isMated(queenStack)) {
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack);
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
}
return;
}
}
private void equalizeTemperature() {
@@ -196,6 +209,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
return 0;
@@ -208,6 +222,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
}
private int getMaxHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
return 0;
@@ -226,18 +241,24 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
@Override
public boolean allowsInteraction(EntityPlayer player) {
if (!super.allowsInteraction(player))
return false;
return this.isIntegratedIntoStructure();
}
/* STRUCTURE MANAGMENT */
@Override
protected void createInventory() {
this.inventory = new TileInventoryAdapter(this, 9, "Items");
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;
}
});
}
@Override
@@ -280,11 +301,13 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
float temperature = biome.temperature;
tempChange = Math.min(boundaryUp - temperature, Math.max(boundaryDown - temperature, tempChange + change));
}
@Override
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
float humidity = biome.rainfall;
humidChange = Math.min(boundaryUp - humidity, Math.max(boundaryDown - humidity, humidChange + change));
}
@@ -326,12 +349,17 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public int getBiomeId() {
return this.biomeId;
return biome.biomeID;
}
@Override
public BiomeGenBase getBiome() {
return biome;
}
@Override
public EnumTemperature getTemperature() {
if (EnumTemperature.isBiomeHellish(biomeId) && tempChange >= 0)
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0)
return EnumTemperature.HELLISH;
return EnumTemperature.getFromValue(getExactTemperature());
@@ -408,7 +436,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public int getErrorOrdinal() {
return getErrorState().ordinal();
return getErrorState().getID();
}
@Override
@@ -418,10 +446,11 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public boolean addProduct(ItemStack product, boolean all) {
IInventoryAdapter inventory = getStructureInventory();
if (inventory == null)
return false;
return inventory.tryAddStack(product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
}
@Override
@@ -517,238 +546,16 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
/* IINVENTORY */
@Override
public InventoryAdapter getInternalInventory() {
return (InventoryAdapter) getStructureInventory();
}
private IInventory getStructureInventory() {
if (inventory != null) {
if (isMaster() || !Proxies.common.isSimulating(worldObj))
return inventory;
public IInventoryAdapter getInternalInventory() {
IInventoryAdapter inventory = super.getInternalInventory();
if (isMaster()) {
return inventory;
} else if (hasMaster()) {
ITileStructure central = getCentralTE();
if (central != null)
return central.getInventory();
if (central instanceof TileAlveary)
return ((TileAlveary) central).getInternalInventory();
}
return null;
}
@Override
public int getSizeInventory() {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getSizeInventory();
else
return 0;
}
@Override
public ItemStack getStackInSlot(int slotIndex) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getStackInSlot(slotIndex);
else
return null;
}
@Override
public ItemStack decrStackSize(int slotIndex, int amount) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.decrStackSize(slotIndex, amount);
else
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex) {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getStackInSlotOnClosing(slotIndex);
else
return null;
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
// Client side handling for container synch
if (inventory == null && !Proxies.common.isSimulating(worldObj))
createInventory();
IInventory inv = getStructureInventory();
if (inv != null)
inv.setInventorySlotContents(slotIndex, itemstack);
}
@Override
public String getInventoryName() {
return getUnlocalizedName();
}
@Override
public int getInventoryStackLimit() {
IInventory inv = getStructureInventory();
if (inv != null)
return inv.getInventoryStackLimit();
else
return 0;
}
@Override
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
return false;
if (slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE)
return true;
return false;
}
@Override
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
if (!super.canPutStackFromSide(slotIndex, itemstack, side))
return false;
if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack)
&& !PluginApiculture.beeInterface.isDrone(itemstack))
return true;
if (slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack))
return true;
return false;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return super.isUseableByPlayer(player);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean hasCustomInventoryName() {
return super.hasCustomInventoryName();
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
return super.isItemValidForSlot(slotIndex, itemstack);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return super.canInsertItem(i, itemstack, j);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return super.canExtractItem(i, itemstack, j);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return super.getAccessibleSlotsFromSide(side);
}
/* ISPECIALINVENTORY */
@Override
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
IInventory inv = getStructureInventory();
if (inv == null)
return 0;
// Princesses && Queens
if (ForestryItem.beePrincessGE.isItemEqual(stack) || ForestryItem.beeQueenGE.isItemEqual(stack))
if (inv.getStackInSlot(SLOT_QUEEN) == null) {
if (doAdd) {
inv.setInventorySlotContents(SLOT_QUEEN, stack.copy());
inv.getStackInSlot(SLOT_QUEEN).stackSize = 1;
}
return 1;
}
// Drones
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
ItemStack droneStack = inv.getStackInSlot(SLOT_DRONE);
if (droneStack == null) {
if (doAdd)
inv.setInventorySlotContents(SLOT_DRONE, stack.copy());
return stack.stackSize;
} else {
if (!droneStack.isItemEqual(stack))
return 0;
if (!ItemStack.areItemStackTagsEqual(droneStack, stack))
return 0;
int space = droneStack.getMaxStackSize() - droneStack.stackSize;
if (space <= 0)
return 0;
int added = space > stack.stackSize ? stack.stackSize : space;
if (doAdd)
droneStack.stackSize += added;
return added;
}
}
return 0;
}
@Override
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
IInventory inv = getStructureInventory();
if (inv == null)
return new ItemStack[0];
ItemStack product = null;
for (int i = SLOT_PRODUCT_1; i < inv.getSizeInventory(); i++) {
if (inv.getStackInSlot(i) == null)
continue;
ItemStack stack = inv.getStackInSlot(i);
if (doRemove)
product = inv.decrStackSize(i, 1);
else {
product = stack.copy();
product.stackSize = 1;
}
break;
}
return new ItemStack[] { product };
return inventory;
}
/* SMP GUI */
@@ -760,22 +567,17 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
case 1:
displayHealthMax = j;
break;
case 2:
this.temperature = (float) j / 100;
break;
case 3:
this.humidity = (float) j / 100;
break;
case 4:
this.tempChange = (float) j / 100;
break;
case 5:
this.humidChange = (float) j / 100;
break;
case 6:
this.biomeId = j;
case 6: {
this.biome = BiomeGenBase.getBiome(j);
break;
}
}
}
@@ -785,16 +587,14 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
iCrafting.sendProgressBarUpdate(container, 0, beekeepingLogic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, beekeepingLogic.getTotalBreedingTime());
iCrafting.sendProgressBarUpdate(container, 2, Math.round(temperature * 100));
iCrafting.sendProgressBarUpdate(container, 3, Math.round(humidity * 100));
iCrafting.sendProgressBarUpdate(container, 4, Math.round(tempChange * 100));
iCrafting.sendProgressBarUpdate(container, 5, Math.round(humidChange * 100));
iCrafting.sendProgressBarUpdate(container, 6, biomeId);
iCrafting.sendProgressBarUpdate(container, 6, biome.biomeID);
}
/* IERRORSOURCE */
@Override
public EnumErrorCode getErrorState() {
public IErrorState getErrorState() {
if (hasMaster()) {
ITileStructure tile = this.getCentralTE();
if (tile != null)
@@ -812,12 +612,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public float getExactTemperature() {
return this.temperature + this.tempChange;
return biome.temperature + this.tempChange;
}
@Override
public float getExactHumidity() {
return this.humidity + this.humidChange;
return biome.rainfall + this.humidChange;
}
/* IHINTSOURCE */
@@ -836,7 +636,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
public boolean isOwnable() {
return true;
}
/* IHousing */
@Override
public GameProfile getOwnerName() {
@@ -12,7 +12,6 @@ package forestry.apiculture.gadgets;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBee;
@@ -21,9 +20,12 @@ import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.core.ForestryAPI;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.core.config.ForestryItem;
import forestry.core.interfaces.ICrafter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.GuiId;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.StackUtils;
public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener {
@@ -33,11 +35,15 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public static final int SLOT_POLLEN_1 = 0;
public static final int SLOTS_POLLEN_COUNT = 4;
public static final int SLOT_SIEVE = 4;
InventoryAdapter inventory = new InventoryAdapter(5, "Items", 1);
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);
}
});
}
@Override
@@ -45,7 +51,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
player.openGui(ForestryAPI.instance, GuiId.AlvearySieveGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
}
@Override
public boolean hasFunction() {
return true;
@@ -62,7 +67,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
}
@Override
protected void updateServerSide() {
super.updateServerSide();
@@ -75,19 +79,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
}
/* SAVING & LOADING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
inventory.readFromNBT(nbttagcompound);
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
inventory.writeToNBT(nbttagcompound);
}
/* TEXTURES & INTERNAL */
@Override
public int getIcon(int side, int metadata) {
@@ -97,15 +88,19 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
}
private void destroySieve() {
IInventoryAdapter inventory = getInternalInventory();
inventory.setInventorySlotContents(SLOT_SIEVE, null);
}
private void destroyPollen() {
IInventoryAdapter inventory = getInternalInventory();
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)
return false;
@@ -118,6 +113,7 @@ 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) {
inventory.setInventorySlotContents(i, itemstack);
@@ -125,11 +121,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
}
}
}
/* INVENTORY */
public InventoryAdapter getInternalInventory() {
return inventory;
}
/* ICRAFTER */
@Override
@@ -139,6 +130,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
@Override
public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) {
IInventoryAdapter inventory = getInternalInventory();
if(slotIndex == SLOT_SIEVE) {
destroyPollen();
return inventory.getStackInSlot(SLOT_SIEVE);
@@ -163,7 +155,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
if(isHandled)
return isHandled;
return true;
if(!canStorePollen())
return false;
@@ -53,6 +53,7 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
}
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
return BlockAlveary.BOTTOM;
@@ -14,44 +14,44 @@ import java.util.Map.Entry;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpecialInventory;
import forestry.apiculture.worldgen.WorldGenHive;
import forestry.apiculture.worldgen.WorldGenHiveSwamer;
import forestry.apiculture.worldgen.Hive;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveDescriptionSwarmer;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.inventory.wrappers.IInvSlot;
import forestry.core.inventory.wrappers.InventoryIterator;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.TileInventoryAdapter;
import forestry.core.network.PacketPayload;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory {
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
/* CONSTANTS */
public static final int BLOCK_META = 2;
TileInventoryAdapter swarmerInventory;
private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>();
private boolean isActive;
public TileAlvearySwarmer() {
super(BLOCK_META);
}
@Override
public void initialize() {
super.initialize();
if (swarmerInventory == null)
createInventory();
setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
}
});
}
@Override
@@ -64,86 +64,102 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
protected void updateServerSide() {
super.updateServerSide();
if (worldObj.getTotalWorldTime() % 100 != 0)
if (pendingSpawns.size() > 0)
if (pendingSpawns.size() > 0) {
setIsActive(true);
if (worldObj.getTotalWorldTime() % 1000 == 0)
trySpawnSwarm();
} else
setIsActive(false);
if (worldObj.getTotalWorldTime() % 500 != 0)
return;
if (!this.hasMaster())
ItemStack princessStack = getPrincessStack();
if (princessStack == null)
return;
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
if (!(master instanceof IBeeHousing))
int chance = consumeInducerAndGetChance();
if (chance == 0)
return;
IBeeHousing housing = (IBeeHousing) master;
ItemStack queenstack = housing.getQueen();
if (queenstack == null)
return;
if (!PluginApiculture.beeInterface.isMated(queenstack))
return;
// Calculate chance
int slot = getInducerSlot();
if (slot < 0)
return;
int chance = getChanceFor(swarmerInventory.getStackInSlot(slot));
// Remove resource
swarmerInventory.decrStackSize(slot, 1);
// Try to spawn princess
if (worldObj.rand.nextInt(1000) >= chance)
return;
// Queue swarm spawn
IBee spawn = PluginApiculture.beeInterface.getMember(queenstack);
spawn.setIsNatural(false);
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(spawn, EnumBeeType.PRINCESS.ordinal()));
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
princess.setIsNatural(false);
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
}
private int getChanceFor(ItemStack stack) {
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
if (entry.getKey().isItemEqual(stack))
return entry.getValue();
private ItemStack getPrincessStack() {
if (!this.hasMaster())
return null;
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
if (!(master instanceof IBeeHousing))
return null;
IBeeHousing housing = (IBeeHousing) master;
ItemStack princessStack = housing.getQueen();
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack))
return null;
return princessStack;
}
private int consumeInducerAndGetChance() {
if (getInternalInventory() == null)
return 0;
for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) {
ItemStack stack = slot.getStackInSlot();
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
if (StackUtils.isIdenticalItem(entry.getKey(), stack)) {
slot.decreaseStackInSlot();
return entry.getValue();
}
}
}
return 0;
}
private int getInducerSlot() {
for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) {
if (swarmerInventory.getStackInSlot(i) == null)
continue;
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
if (entry.getKey().isItemEqual(swarmerInventory.getStackInSlot(i)))
return i;
}
}
return -1;
}
private void trySpawnSwarm() {
ItemStack toSpawn = pendingSpawns.peek();
WorldGenHive generator = new WorldGenHiveSwamer(new ItemStack[] { toSpawn });
HiveDescriptionSwarmer hiveDescription = new HiveDescriptionSwarmer(toSpawn);
Hive hive = new Hive(hiveDescription);
int i = 0;
while (i < 10) {
i++;
int spawnX = xCoord + worldObj.rand.nextInt(40 * 2) - 40;
int spawnY = yCoord + worldObj.rand.nextInt(40);
int spawnZ = zCoord + worldObj.rand.nextInt(40 * 2) - 40;
if (generator.generate(worldObj, worldObj.rand, spawnX, spawnY, spawnZ)) {
pendingSpawns.pop();
break;
}
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))
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);
}
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
payload.shortPayload[0] = (short) (isActive ? 1 : 0);
return payload;
}
@Override
@@ -154,22 +170,19 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
if (side == 0 || side == 1)
return BlockAlveary.BOTTOM;
if (pendingSpawns.size() > 0)
return BlockAlveary.TX_56_SWON;
if (isActive)
return BlockAlveary.ALVEARY_SWARMER_ON;
else
return BlockAlveary.TX_55_SWOF;
return BlockAlveary.ALVEARY_SWARMER_OFF;
}
/* SAVING & LOADING */
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
if (swarmerInventory == null)
createInventory();
swarmerInventory.readFromNBT(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingSpawns", 10);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
@@ -182,126 +195,18 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
if (swarmerInventory != null)
swarmerInventory.writeToNBT(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList();
ItemStack[] offspring = pendingSpawns.toArray(new ItemStack[pendingSpawns.size()]);
for (int i = 0; i < offspring.length; i++)
for (int i = 0; i < offspring.length; i++) {
if (offspring[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
offspring[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
nbttagcompound.setTag("PendingSpawns", nbttaglist);
}
@Override
protected void createInventory() {
swarmerInventory = new TileInventoryAdapter(this, 4, "SwarmInv");
}
@Override
public IInventory getInventory() {
return swarmerInventory;
}
/* ISPECIALINVENTORY */
@Override
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
if (swarmerInventory != null)
return swarmerInventory.addStack(stack, false, doAdd);
else
return 0;
}
@Override
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
return null;
}
/* IINVENTORY */
@Override
public int getSizeInventory() {
if (swarmerInventory != null)
return swarmerInventory.getSizeInventory();
else
return 0;
}
@Override
public ItemStack getStackInSlot(int slotIndex) {
if (swarmerInventory != null)
return swarmerInventory.getStackInSlot(slotIndex);
else
return null;
}
@Override
public ItemStack decrStackSize(int slotIndex, int amount) {
if (swarmerInventory != null)
return swarmerInventory.decrStackSize(slotIndex, amount);
else
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex) {
if (swarmerInventory != null)
return swarmerInventory.getStackInSlotOnClosing(slotIndex);
else
return null;
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
// Client side handling for container synch
if (swarmerInventory == null && !Proxies.common.isSimulating(worldObj))
createInventory();
if (swarmerInventory != null)
swarmerInventory.setInventorySlotContents(slotIndex, itemstack);
}
@Override
public String getInventoryName() {
return getUnlocalizedName();
}
@Override
public int getInventoryStackLimit() {
if (swarmerInventory != null)
return swarmerInventory.getInventoryStackLimit();
else
return 0;
}
@Override public void openInventory() {}
@Override public void closeInventory() {}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return super.isUseableByPlayer(player);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean hasCustomInventoryName() {
return super.hasCustomInventoryName();
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
return super.isItemValidForSlot(slotIndex, itemstack);
}
}
@@ -10,25 +10,31 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import buildcraft.api.statements.ITriggerExternal;
import java.util.Collection;
import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.ForestryAPI;
import forestry.apiculture.trigger.ApicultureTriggers;
import forestry.core.gadgets.TileBase;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.network.GuiId;
import forestry.core.triggers.ForestryTrigger;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import java.util.LinkedList;
import buildcraft.api.statements.ITriggerExternal;
public class TileApiary extends TileBeehouse implements ISidedInventory {
public class TileApiary extends TileBeehouse {
@Override
public String getInventoryName() {
return getUnlocalizedName();
public TileApiary() {
setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items"));
}
@Override
@@ -39,6 +45,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
/* IBEEHOUSING */
@Override
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
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)
@@ -51,6 +58,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
@Override
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
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)
@@ -63,6 +71,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
@Override
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
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)
@@ -75,6 +84,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
@Override
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
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)
@@ -87,6 +97,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
@Override
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
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)
@@ -99,6 +110,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
@Override
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
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)
@@ -111,6 +123,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
@Override
public void wearOutEquipment(int amount) {
IInventoryAdapter inventory = getInternalInventory();
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
@@ -126,128 +139,6 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
}
}
/* IINVENTORY */
@Override
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
return false;
switch (slotIndex) {
case SLOT_QUEEN:
case SLOT_DRONE:
case SLOT_FRAMES_1:
case SLOT_FRAMES_2:
case SLOT_FRAMES_3:
return false;
default:
return true;
}
}
@Override
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
if (!super.canPutStackFromSide(slotIndex, itemstack, side))
return false;
if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack)
&& !PluginApiculture.beeInterface.isDrone(itemstack))
return true;
if (slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack))
return true;
return false;
}
/**
* TODO: just a specialsource workaround
*/
@Override
public ItemStack getStackInSlot(int i) {
return super.getStackInSlot(i);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
super.setSlotContents(i, itemstack);
}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();
}
@Override
public ItemStack decrStackSize(int i, int j) {
return inventory.decrStackSize(i, j);
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return inventory.getStackInSlotOnClosing(slot);
}
@Override
public int getInventoryStackLimit() {
return inventory.getInventoryStackLimit();
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return super.isUseableByPlayer(player);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean hasCustomInventoryName() {
return super.hasCustomInventoryName();
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
return super.isItemValidForSlot(slotIndex, itemstack);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
return super.canInsertItem(i, itemstack, j);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
return super.canExtractItem(i, itemstack, j);
}
/**
* TODO: just a specialsource workaround
*/
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return super.getAccessibleSlotsFromSide(side);
}
/* ISPECIALINVENTORY */
// @Override
// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
@@ -342,12 +233,13 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
// }
/* ITRIGGERPROVIDER */
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
public LinkedList<ITriggerExternal> getCustomTriggers() {
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
res.add(ForestryTrigger.missingQueen);
res.add(ForestryTrigger.missingDrone);
res.add(PluginApiculture.triggerNoFrames);
res.add(ApicultureTriggers.missingQueen);
res.add(ApicultureTriggers.missingDrone);
res.add(ApicultureTriggers.noFrames);
return res;
}
}
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -19,10 +17,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
@@ -31,41 +33,63 @@ 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.IClimatised;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.TileInventoryAdapter;
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.InventoryAdapter;
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);
}
}
// CONSTANTS
public static final int SLOT_QUEEN = 0;
public static final int SLOT_DRONE = 1;
public static final int SLOT_INVENTORY_1 = 2;
protected static int SLOT_PRODUCT_1 = 2;
protected static int SLOT_PRODUCT_COUNT = 7;
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_INVENTORY_COUNT = 7;
public static final int SLOT_FRAMES_COUNT = 3;
// Inventory
protected InventoryAdapter inventory = new InventoryAdapter(12, "Items");
private final IBeekeepingLogic logic;
private int biomeId = -1;
private float temperature;
private float humidity;
private BiomeGenBase biome;
private int displayHealthMax = 0;
private int displayHealth = 0;
public TileBeehouse() {
setHints(Config.hints.get("apiary"));
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items").disableAutomation());
}
@Override
@@ -78,11 +102,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setFloat("Temp", temperature);
nbttagcompound.setFloat("Humidity", humidity);
nbttagcompound.setInteger("BiomeId", biomeId);
inventory.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("BiomeId", biome.biomeID);
if (logic != null)
logic.writeToNBT(nbttagcompound);
}
@@ -91,11 +111,8 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
temperature = nbttagcompound.getFloat("Temp");
humidity = nbttagcompound.getFloat("Humidity");
biomeId = nbttagcompound.getInteger("BiomeId");
inventory.readFromNBT(nbttagcompound);
int biomeId = nbttagcompound.getInteger("BiomeId");
biome = BiomeGenBase.getBiome(biomeId);
logic.readFromNBT(nbttagcompound);
}
@@ -119,24 +136,22 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public EnumTemperature getTemperature() {
if (EnumTemperature.isBiomeHellish(biomeId))
return EnumTemperature.HELLISH;
return EnumTemperature.getFromValue(temperature);
return EnumTemperature.getFromBiome(biome);
}
@Override
public EnumHumidity getHumidity() {
return EnumHumidity.getFromValue(humidity);
return EnumHumidity.getFromValue(getExactHumidity());
}
@Override
public float getExactTemperature() {
return this.temperature;
return biome.temperature;
}
@Override
public float getExactHumidity() {
return this.humidity;
return biome.rainfall;
}
/* UPDATING */
@@ -144,12 +159,11 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public void updateClientSide() {
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN)))
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
displayQueen.doFX(logic.getEffectData(), this);
}
return;
}
@@ -164,7 +178,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
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);
@@ -191,7 +205,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public boolean addProduct(ItemStack product, boolean all) {
return inventory.tryAddStack(product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
return InvTools.tryAddStack(getInternalInventory(), product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
}
/* NETWORK SYNCH */
@@ -207,6 +221,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
return 0;
@@ -219,6 +234,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
}
private int getMaxHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
return 0;
@@ -232,9 +248,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/**
* Returns scaled queen health or breeding progress
*
* @param i
* @return
*/
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0)
@@ -244,20 +257,18 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
}
public int getTemperatureScaled(int i) {
return Math.round(i * (temperature / 2));
return Math.round(i * (getExactTemperature() / 2));
}
public int getHumidityScaled(int i) {
return Math.round(i * humidity);
return Math.round(i * getExactHumidity());
}
public void updateBiome() {
if (worldObj != null) {
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
if (biome != null) {
this.biomeId = biome.biomeID;
this.temperature = biome.temperature;
this.humidity = biome.rainfall;
this.biome = biome;
setErrorState(EnumErrorCode.OK);
}
}
@@ -288,20 +299,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
}
/* INVENTORY MANAGMENT */
@Override
public InventoryAdapter getInternalInventory() {
return inventory;
}
public ItemStack getStackInSlot(int i) {
return inventory.getStackInSlot(i);
}
public void setSlotContents(int i, ItemStack itemstack) {
inventory.setInventorySlotContents(i, itemstack);
}
// / IBEEHOUSING
@Override
public int getXCoord() {
@@ -320,7 +317,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public int getBiomeId() {
return this.biomeId;
return biome.biomeID;
}
@Override
public BiomeGenBase getBiome() {
return biome;
}
@Override
@@ -335,12 +337,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public void setQueen(ItemStack itemstack) {
setSlotContents(SLOT_QUEEN, itemstack);
setInventorySlotContents(SLOT_QUEEN, itemstack);
}
@Override
public void setDrone(ItemStack itemstack) {
setSlotContents(SLOT_DRONE, itemstack);
setInventorySlotContents(SLOT_DRONE, itemstack);
}
@Override
@@ -355,7 +357,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public int getErrorOrdinal() {
return getErrorState().ordinal();
return getErrorState().getID();
}
@Override
@@ -434,7 +436,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public boolean onEggLaid(IBee queen) {
return false;
}
/* IHousing */
@Override
public GameProfile getOwnerName() {
@@ -10,24 +10,39 @@
******************************************************************************/
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 forestry.core.utils.InventoryAdapter;
import net.minecraft.world.EnumSkyBlock;
public class TileSwarm extends TileEntity {
public InventoryAdapter contained = new InventoryAdapter(2, "Contained");
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
@Override
public boolean canUpdate() {
return false;
return true;
}
// Hack to make sure that hives glow.
// TODO: remove when Mojang fixes this bug: https://bugs.mojang.com/browse/MC-3329
// Hives should not need to tick normally.
private boolean updatedLight;
@Override
public void updateEntity() {
super.updateEntity();
if (worldObj.isRemote && !updatedLight && worldObj.getWorldTime() % 20 == 0) {
updatedLight = worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
}
}
public TileSwarm setContained(ItemStack[] bees) {
for (ItemStack itemstack : bees)
contained.addStack(itemstack, false, true);
InvTools.addStack(contained, itemstack, false, true);
return this;
}
@@ -62,7 +62,7 @@ public class AIAvoidPlayers extends EntityAIBase {
return false;
pathing = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
return pathing == null ? false : pathing.isDestinationSame(randomTarget);
return pathing != null && pathing.isDestinationSame(randomTarget);
}
@Override
@@ -10,20 +10,9 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -40,6 +29,14 @@ 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 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 {
@@ -54,7 +51,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
private final int primaryColour;
private final int secondaryColour;
private final String iconType = "default";
private static final String iconType = "default";
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, int primaryColor, int secondaryColor) {
this(uid, dominant, name, branch, null, primaryColor, secondaryColor);
@@ -114,7 +111,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
int highest = 0;
exclude.add(species);
for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES.ordinal())) {
for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) {
if(!exclude.contains(mutation.getAllele0())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude);
if(otherAdvance > highest)
@@ -148,8 +145,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
ArrayList<ItemStack> bounty = new ArrayList<ItemStack>();
for(ItemStack stack : super.getResearchBounty(world, researcher, individual, bountyLevel))
bounty.add(stack);
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
if(bountyLevel > 10) {
for(ItemStack stack : specialty.keySet()) {
@@ -159,7 +155,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
for(ItemStack stack : products.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
}
return bounty.toArray(StackUtils.EMPTY_STACK_ARRAY);
return bounty.toArray(new ItemStack[bounty.size()]);
}
/* OTHER */
@@ -211,7 +207,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
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][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");
@@ -10,22 +10,20 @@
******************************************************************************/
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 DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
public static final DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
public AlleleEffectAggressive(String uid) {
super(uid, "aggressive", true, 40, false, false);
@@ -10,24 +10,22 @@
******************************************************************************/
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 {
private final int explosionChance = 50;
byte defaultForce = 12;
byte indexExplosionTimer = 1;
byte indexExplosionForce = 2;
private static final int explosionChance = 50;
private static final byte defaultForce = 12;
private final byte indexExplosionTimer = 1;
private final byte indexExplosionForce = 2;
public AlleleEffectCreeper(String uid) {
super(uid, "creeper", true, 20, false, true);
@@ -10,14 +10,12 @@
******************************************************************************/
package forestry.apiculture.genetics;
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;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
public class AlleleEffectExploration extends AlleleEffectThrottled {
@@ -0,0 +1,59 @@
package forestry.apiculture.genetics;
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);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing)) {
return storedData;
}
World world = housing.getWorld();
int territorySize[] = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
int blockMaxY = housing.getYCoord() + territorySize[1] / 2 + 1;
int blockMinY = housing.getYCoord() - (territorySize[1] / 2) - 1;
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
if (tryTickColumn(world, blockX, blockZ, blockMaxY, blockMinY)) {
break;
}
blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
}
return storedData;
}
private int getRandomOffset(Random random, int centrePos, int offset) {
return centrePos + random.nextInt(offset) - (offset / 2);
}
private boolean tryTickColumn(World world, int x, int z, int maxY, int minY) {
for (int y = maxY; y >= minY; --y) {
if (!world.isAirBlock(x, y, z)) {
Block block = world.getBlock(x, y, z);
world.scheduleBlockUpdate(x, y, z, block, 5);
return true;
}
}
return false;
}
}
@@ -0,0 +1,128 @@
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;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
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);
}
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (storedData instanceof EffectData && ((EffectData) storedData).getIntSize() == 2) {
return storedData;
}
return new EffectData(2, 0);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing)) {
return storedData;
}
doBlockEffect(genome, housing);
int entityThrottle = storedData.getInteger(1);
if (entityThrottle >= ENTITY_THROTTLE) {
doEntityEffect(genome, housing);
entityThrottle = 0;
} else {
++entityThrottle;
}
storedData.setInteger(1, entityThrottle);
return storedData;
}
private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorld();
int territorySize[] = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
int blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
Block block = world.getBlock(blockX, blockY, blockZ);
if (isSuitableForMycelium(world, block, blockX, blockY, blockZ)) {
world.setBlock(blockX, blockY, blockZ, Blocks.mycelium);
break;
} else if (isSuitableForGrowth(block)) {
doMushroomGrowth(block, world, blockX, blockY, blockZ);
break;
}
blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
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) {
if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) {
convertCowToMooshroom((EntityCow)entity);
break;
}
}
}
private int getRandomOffset(Random random, int centrePos, int offset) {
return centrePos + random.nextInt(offset) - (offset / 2);
}
private boolean isSuitableForMycelium(World world, Block block, int blockX, int blockY, int blockZ) {
return block == Blocks.grass || (block == Blocks.dirt && world.canBlockSeeTheSky(blockX, blockY, blockZ));
}
private boolean isSuitableForGrowth(Block block) {
return block == Blocks.red_mushroom || block == Blocks.brown_mushroom;
}
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);
}
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);
}
}
@@ -10,17 +10,16 @@
******************************************************************************/
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.utils.Vect;
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 {
@@ -10,15 +10,13 @@
******************************************************************************/
package forestry.apiculture.genetics;
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;
import java.util.List;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
public class AlleleEffectHeroic extends AlleleEffectThrottled {
@@ -10,23 +10,21 @@
******************************************************************************/
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 {
int ignitionChance = 50;
int fireDuration = 500;
private static final int ignitionChance = 50;
private static final int fireDuration = 500;
public AlleleEffectIgnition(String uid) {
super(uid, "ignition", false, 20, false, true);
@@ -10,23 +10,21 @@
******************************************************************************/
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 final int infectionChance = 50;
private static final int infectionChance = 50;
public AlleleEffectMiasmic(String uid) {
super(uid, "misasmic", false, 50, false, false);
@@ -10,21 +10,19 @@
******************************************************************************/
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 DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
public static final DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
public AlleleEffectMisanthrope(String uid) {
super(uid, "misanthrope", true, 20, false, false);
@@ -10,14 +10,13 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.world.World;
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.plugins.PluginApiculture;
import net.minecraft.world.World;
public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
@@ -10,25 +10,28 @@
******************************************************************************/
package forestry.apiculture.genetics;
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;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
public class AlleleEffectPotion extends AlleleEffectThrottled {
private int potionId = 0;
private final Potion potion;
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);
potionId = potion.getId();
this.potion = potion;
this.isBadEffect = isBadEffect(potion);
this.duration = duration;
}
@@ -39,15 +42,42 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
return storedData;
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox);
for (Object obj : list) {
EntityPlayer player = (EntityPlayer) obj;
player.addPotionEffect(new PotionEffect(potionId, duration, 0));
for (Object entity : list) {
if (!(entity instanceof EntityPlayer))
continue;
EntityPlayer player = (EntityPlayer) entity;
int dur = this.duration;
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)
continue; // Full set, no damage/effect
else if (count == 3)
dur = this.duration / 4;
else if (count == 2)
dur = this.duration / 2;
else if (count == 1)
dur = this.duration * 3 / 4;
}
player.addPotionEffect(new PotionEffect(potion.getId(), dur, 0));
}
return storedData;
}
//FIXME: remove when Potion.isBadEffect() is available server-side
private static boolean isBadEffect(Potion potion) {
try {
return (Boolean) ReflectionHelper.getPrivateValue(Potion.class, potion, "field_76418_K", "isBadEffect");
} catch (ReflectionHelper.UnableToFindFieldException e) {
Proxies.log.severe("Could not access potion field isBadEffect.");
return false;
}
}
}
@@ -10,9 +10,16 @@
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.gadgets.BlockAlveary;
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;
@@ -21,18 +28,9 @@ 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;
import forestry.apiculture.gadgets.BlockAlveary;
import forestry.apiculture.gadgets.TileAlveary;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.utils.Vect;
public class AlleleEffectRadioactive extends AlleleEffectThrottled {
public static DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
public static final DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
public AlleleEffectRadioactive(String uid) {
super(uid, "radioactive", true, 40, false, true);
@@ -10,15 +10,13 @@
******************************************************************************/
package forestry.apiculture.genetics;
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;
import java.util.List;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.AxisAlignedBB;
public class AlleleEffectRepulsion extends AlleleEffectThrottled {
@@ -10,10 +10,14 @@
******************************************************************************/
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;
@@ -30,12 +34,6 @@ 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 {
@@ -10,18 +10,16 @@
******************************************************************************/
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.utils.Vect;
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 {
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
@@ -19,8 +17,9 @@ import forestry.api.genetics.IEffectData;
import forestry.core.EnumErrorCode;
import forestry.core.genetics.Allele;
import forestry.core.genetics.EffectData;
import forestry.core.utils.Vect;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.util.AxisAlignedBB;
public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect {
@@ -55,14 +54,14 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
public boolean isHalted(IEffectData storedData, IBeeHousing housing) {
if (requiresWorkingQueen && housing.getErrorOrdinal() != EnumErrorCode.OK.ordinal())
if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK)
return true;
int throttle = storedData.getInteger(0);
throttle++;
storedData.setInteger(0, throttle);
int throt = storedData.getInteger(0);
throt++;
storedData.setInteger(0, throt);
if (throttle < getThrottle())
if (throt < getThrottle())
return true;
// Reset since we are done throttling.
@@ -16,7 +16,7 @@ import forestry.core.genetics.Allele;
public class AlleleFlowers extends Allele implements IAlleleFlowers {
IFlowerProvider provider;
private final IFlowerProvider provider;
public AlleleFlowers(String uid, IFlowerProvider provider) {
this(uid, provider, false);
@@ -10,16 +10,15 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import com.mojang.authlib.GameProfile;
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 {
@@ -61,7 +60,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
public void registerPickup(IIndividual individual) {
if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID))
return;
if(!individual.isPureBred(0))
if(!individual.isPureBred(EnumBeeChromosome.SPECIES))
return;
if(PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0)
return;
@@ -10,6 +10,20 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -19,6 +33,7 @@ import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleManager;
@@ -36,25 +51,17 @@ import forestry.core.genetics.Chromosome;
import forestry.core.genetics.GenericRatings;
import forestry.core.genetics.IndividualLiving;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Utils;
import forestry.core.utils.Vect;
import forestry.core.vect.MutableVect;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Bee extends IndividualLiving implements IBee {
protected int generation;
protected boolean isNatural = true;
public IBeeGenome genome;
public IBeeGenome mate;
@@ -63,34 +70,20 @@ public class Bee extends IndividualLiving implements IBee {
readFromNBT(nbttagcompound);
}
public Bee(World world, IBeeGenome genome, IBee mate) {
this(world, genome);
this.mate = mate.getGenome();
this.isIrregularMating = mate.isNatural() != this.isNatural;
}
public Bee(IBeeGenome genome, IBee mate) {
this(genome);
this.mate = mate.getGenome();
this.isIrregularMating = mate.isNatural() != this.isNatural;
}
public Bee(World world, IBeeGenome genome) {
this(world, genome, true, 0);
}
public Bee(IBeeGenome genome) {
this(genome, true, 0);
}
public Bee(World world, IBeeGenome genome, boolean isNatural, int generation) {
super(genome.getLifespan(), isNatural, generation);
this.genome = genome;
}
public Bee(IBeeGenome genome, boolean isNatural, int generation) {
super(genome.getLifespan(), isNatural, generation);
super(genome.getLifespan());
this.genome = genome;
this.isNatural = isNatural;
this.generation = generation;
}
/* SAVING & LOADING */
@@ -104,15 +97,51 @@ public class Bee extends IndividualLiving implements IBee {
super.readFromNBT(nbttagcompound);
if (nbttagcompound.hasKey("NA"))
isNatural = nbttagcompound.getBoolean("NA");
if (nbttagcompound.hasKey("GEN"))
generation = nbttagcompound.getInteger("GEN");
if (nbttagcompound.hasKey("Genome"))
genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome"));
else
genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
if (nbttagcompound.hasKey("Mate"))
mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate"));
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
if (!isNatural)
nbttagcompound.setBoolean("NA", false);
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;
}
public int getGeneration() {
return generation;
}
@Override
public void mate(IIndividual individual) {
if(!(individual instanceof IBee))
@@ -120,7 +149,6 @@ public class Bee extends IndividualLiving implements IBee {
IBee drone = (IBee)individual;
mate = drone.getGenome();
this.isIrregularMating = drone.isNatural() != this.isNatural;
}
/* EFFECTS */
@@ -137,7 +165,7 @@ public class Bee extends IndividualLiving implements IBee {
if (!effect.isCombinable())
return storedData;
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal());
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable())
return storedData;
@@ -164,7 +192,7 @@ public class Bee extends IndividualLiving implements IBee {
if (!effect.isCombinable())
return storedData;
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal());
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable())
return storedData;
@@ -203,38 +231,44 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public int isWorking(IBeeHousing housing) {
return canWork(housing).ordinal();
}
@Override
public EnumErrorCode canWork(IBeeHousing housing) {
World world = housing.getWorld();
// / Rain needs tolerant flyers
if (world.isRaining() && !genome.getTolerantFlyer() && housing.getHumidity() != EnumHumidity.ARID && !housing.isSealed())
return EnumErrorCode.ISRAINING.ordinal();
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(housing.getBiomeId()) && !housing.isSealed()) {
return EnumErrorCode.ISRAINING;
}
// / Night or darkness requires nocturnal species
if(world.isDaytime()) {
if(!canWorkDuringDay())
return EnumErrorCode.NOTNIGHT.ordinal();
return EnumErrorCode.NOTNIGHT;
} else if (!canWorkAtNight() && !housing.isSelfLighted())
return EnumErrorCode.NOTDAY.ordinal();
return EnumErrorCode.NOTDAY;
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
if(!canWorkDuringDay())
return EnumErrorCode.NOTGLOOMY.ordinal();
return EnumErrorCode.NOTGLOOMY;
} else if(!canWorkAtNight() && !housing.isSelfLighted())
return EnumErrorCode.NOTLUCID.ordinal();
return EnumErrorCode.NOTLUCID;
// / No sky, except if in hell
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if(biome == null)
return EnumErrorCode.NOSKY.ordinal();
if (!BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.NETHER) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
return EnumErrorCode.NOSKY;
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated())
return EnumErrorCode.NOSKY.ordinal();
return EnumErrorCode.NOSKY;
// / And finally climate check
if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity()))
return EnumErrorCode.INVALIDBIOME.ordinal();
return EnumErrorCode.INVALIDBIOME;
return EnumErrorCode.OK.ordinal();
return EnumErrorCode.OK;
}
private boolean canWorkAtNight() {
@@ -246,8 +280,10 @@ public class Bee extends IndividualLiving implements IBee {
}
private boolean checkBiomeHazard(BiomeGenBase biome) {
if (biome == null)
return false;
EnumTemperature temperature = EnumTemperature.getFromValue(biome.temperature);
EnumTemperature temperature = EnumTemperature.getFromBiome(biome);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
@@ -266,26 +302,16 @@ public class Bee extends IndividualLiving implements IBee {
IFlowerProvider provider = genome.getFlowerProvider();
Vect coords = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
Vect posCurrent = new Vect(0, 0, 0);
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f));
if (area.x < 1)
area.x = 1;
if (area.y < 1)
area.y = 1;
if (area.z < 1)
area.z = 1;
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 2, -area.z / 2);
boolean hasFlower = false;
while (advancePosition(posCurrent, area)) {
MutableVect posCurrent = new MutableVect(0, 0, 0);
while (posCurrent.advancePositionInArea(area)) {
Vect posBlock = posCurrent.add(coords);
posBlock = posBlock.add(offset);
Vect posBlock = Vect.add(housingPos, posCurrent, offset);
if (provider.isAcceptedFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z)) {
hasFlower = true;
@@ -297,28 +323,6 @@ public class Bee extends IndividualLiving implements IBee {
return hasFlower;
}
private boolean advancePosition(Vect posCurrent, Vect area) {
// Increment z first until end reached
if (posCurrent.z < area.z - 1)
posCurrent.z++;
else {
posCurrent.z = 0;
if (posCurrent.x < area.x - 1)
posCurrent.x++;
else {
posCurrent.x = 0;
if (posCurrent.y < area.y - 1)
posCurrent.y++;
else
return false;
}
}
return true;
}
@Override
public ArrayList<Integer> getSuitableBiomeIds() {
ArrayList<Integer> suitableBiomes = new ArrayList<Integer>();
@@ -329,6 +333,16 @@ public class Bee extends IndividualLiving implements IBee {
return suitableBiomes;
}
@Override
public ArrayList<BiomeGenBase> getSuitableBiomes() {
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
if (checkBiomeHazard(biome))
suitableBiomes.add(biome);
return suitableBiomes;
}
@Override
public void addTooltip(List<String> list) {
@@ -341,27 +355,48 @@ 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.ordinal()))
list.add("\u00A79" + 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()));
IAllele speed = genome.getActiveAllele(EnumBeeChromosome.SPEED.ordinal());
String customWorker = "tooltip.worker." + speed.getUnlocalizedName().replaceFirst("gui.", "");
if (StringUtil.canTranslate(customWorker))
list.add(StringUtil.localize(customWorker));
if (generation > 0) {
EnumRarity rarity;
if (generation >= 1000)
rarity = EnumRarity.epic;
else if (generation >= 100)
rarity = EnumRarity.rare;
else if (generation >= 10)
rarity = EnumRarity.uncommon;
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);
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", "");
String speed;
if (StringUtil.canTranslate(unlocalizedCustomSpeed))
speed = StringUtil.localize(unlocalizedCustomSpeed);
else
list.add(speed.getName() + " " + StringUtil.localize("gui.worker"));
speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker");
list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal()).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();
IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName());
list.add(lifespan);
list.add(speed);
list.add(tempTolerance);
list.add(humidTolerance);
list.add(flowers);
IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName());
list.add(genome.getFlowerProvider().getDescription());
if (genome.getNocturnal())
list.add("\u00A7c" + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
}
@Override
@@ -398,12 +433,13 @@ public class Bee extends IndividualLiving implements IBee {
}
return products.toArray(new ItemStack[0]);
return products.toArray(new ItemStack[products.size()]);
}
@Override
public ItemStack[] getSpecialtyList() {
return genome.getPrimary().getSpecialty().keySet().toArray(new ItemStack[0]);
Set<ItemStack> specialties = genome.getPrimary().getSpecialty().keySet();
return specialties.toArray(new ItemStack[specialties.size()]);
}
@Override
@@ -444,7 +480,7 @@ public class Bee extends IndividualLiving implements IBee {
// We are done if the we are not jubilant.
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing))
return products.toArray(StackUtils.EMPTY_STACK_ARRAY);
return products.toArray(new ItemStack[products.size()]);
// / Specialty products
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet())
@@ -452,7 +488,7 @@ public class Bee extends IndividualLiving implements IBee {
products.add(entry.getKey().copy());
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
products.toArray(StackUtils.EMPTY_STACK_ARRAY));
products.toArray(new ItemStack[products.size()]));
}
/* REPRODUCTION */
@@ -488,7 +524,7 @@ public class Bee extends IndividualLiving implements IBee {
toCreate = 1;
for (int i = 0; i < toCreate; i++) {
IBee offspring = createOffspring(housing, -1);
IBee offspring = createOffspring(housing, 0);
if (offspring != null) {
offspring.setIsNatural(true);
bees.add(offspring);
@@ -496,7 +532,7 @@ public class Bee extends IndividualLiving implements IBee {
}
if (bees.size() > 0)
return bees.toArray(new IBee[0]);
return bees.toArray(new IBee[bees.size()]);
else
return null;
}
@@ -523,7 +559,7 @@ public class Bee extends IndividualLiving implements IBee {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
IBee offspring = new Bee(world, new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
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.
@@ -560,14 +596,12 @@ public class Bee extends IndividualLiving implements IBee {
}
for (IBeeMutation mutation : PluginApiculture.beeInterface.getMutations(true)) {
float chance = 0;
if ((chance = mutation.getChance(housing, allele0, allele1, genome0, genome1)) > 0)
if (world.rand.nextFloat()*100 < chance) {
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
breedingTracker.registerMutation(mutation);
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
}
float chance = mutation.getChance(housing, allele0, allele1, genome0, genome1);
if (chance > world.rand.nextFloat() * 100) {
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
breedingTracker.registerMutation(mutation);
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
}
}
return null;
@@ -577,56 +611,34 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public IIndividual retrievePollen(IBeeHousing housing) {
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
World world = housing.getWorld();
Random random = world.rand;
// Correct speed
if (housing.getWorld().rand.nextInt(100) >= chance)
if (random.nextInt(100) >= chance)
return null;
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
if (area.x < 1)
area.x = 1;
if (area.y < 1)
area.y = 1;
if (area.z < 1)
area.z = 1;
IIndividual pollen = null;
// We have up to ten attempts
for (int i = 0; i < 20; i++) {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect blockPos = Vect.add(housingPos, randomPos, offset);
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
posBlock = posBlock.add(offset);
TileEntity tile = housing.getWorld().getTileEntity(posBlock.x, posBlock.y, posBlock.z);
if (!(tile instanceof IPollinatable)) {
if (housing.getWorld().isAirBlock(posBlock.x, posBlock.y, posBlock.z))
continue;
// Test for ersatz genomes
for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSpecimen.entrySet()) {
if (!StackUtils.equals(housing.getWorld().getBlock(posBlock.x, posBlock.y, posBlock.z), entry.getKey()))
continue;
if (entry.getKey().getItemDamage() != housing.getWorld().getBlockMetadata(posBlock.x, posBlock.y, posBlock.z))
continue;
// We matched, return ersatz genome
return entry.getValue().copy();
}
continue;
if (tile instanceof IPollinatable) {
IPollinatable pitcher = (IPollinatable) tile;
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher))
pollen = pitcher.getPollen();
} else {
pollen = GeneticsUtil.getErsatzPollen(world, blockPos.x, blockPos.y, blockPos.z);
}
IPollinatable pitcher = (IPollinatable) tile;
if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), pitcher))
continue;
IIndividual pollen = pitcher.getPollen();
if (pollen != null)
return pollen;
}
@@ -639,34 +651,27 @@ public class Bee extends IndividualLiving implements IBee {
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
World world = housing.getWorld();
Random random = world.rand;
// Correct speed
if (housing.getWorld().rand.nextInt(100) >= chance)
if (random.nextInt(100) >= chance)
return false;
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2));
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
if (area.x < 1)
area.x = 1;
if (area.y < 1)
area.y = 1;
if (area.z < 1)
area.z = 1;
// We have up to ten attempts
for (int i = 0; i < 30; i++) {
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
posBlock = posBlock.add(offset);
IPollinatable receiver = Utils.getOrCreatePollinatable(housing.getOwnerName(), housing.getWorld(), posBlock.x, posBlock.y, posBlock.z);
IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
if(receiver == null)
continue;
if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), receiver))
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver))
continue;
if (!receiver.canMateWith(pollen))
continue;
@@ -681,35 +686,33 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public void plantFlowerRandom(IBeeHousing housing) {
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
World world = housing.getWorld();
Random random = world.rand;
// Correct speed
if (housing.getWorld().rand.nextInt(100) >= chance)
if (random.nextInt(100) >= chance)
return;
// Gather required info
IFlowerProvider provider = genome.getFlowerProvider();
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2));
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
if (area.x < 1)
area.x = 1;
if (area.y < 1)
area.y = 1;
if (area.z < 1)
area.z = 1;
// We have up to ten attempts
for (int i = 0; i < 10; i++) {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
posBlock = posBlock.add(offset);
if (provider.growFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z))
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z))
break;
}
}
private static Vect getArea(IBeeGenome genome, IBeeHousing housing) {
int[] genomeTerritory = genome.getTerritory();
float housingModifier = housing.getTerritoryModifier(genome, 1f);
return new Vect(genomeTerritory).multiply(housingModifier * 3.0f);
}
}
@@ -26,7 +26,7 @@ import forestry.core.genetics.AlleleArea;
import forestry.core.genetics.AlleleBoolean;
import forestry.core.genetics.AlleleTolerance;
import forestry.core.genetics.Genome;
import forestry.core.utils.Vect;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -72,7 +72,7 @@ public class BeeGenome extends Genome implements IBeeGenome {
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumBeeChromosome.SPECIES);
IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleBeeSpecies)
return (IAlleleBeeSpecies)speciesAllele;
else
@@ -82,73 +82,73 @@ public class BeeGenome extends Genome implements IBeeGenome {
// / INFORMATION RETRIEVAL
@Override
public IAlleleBeeSpecies getPrimary() {
return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES.ordinal());
return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES);
}
@Override
public IAlleleBeeSpecies getSecondary() {
return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES.ordinal());
return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES);
}
@Override
public float getSpeed() {
return ((IAlleleFloat) getActiveAllele(EnumBeeChromosome.SPEED.ordinal())).getValue();
return ((IAlleleFloat) getActiveAllele(EnumBeeChromosome.SPEED)).getValue();
}
@Override
public int getLifespan() {
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal())).getValue();
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.LIFESPAN)).getValue();
}
@Override
public int getFertility() {
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FERTILITY.ordinal())).getValue();
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FERTILITY)).getValue();
}
@Override
public EnumTolerance getToleranceTemp() {
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal())).getValue();
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE)).getValue();
}
@Override
public boolean getNocturnal() {
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.NOCTURNAL.ordinal())).getValue();
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue();
}
@Override
public EnumTolerance getToleranceHumid() {
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal())).getValue();
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE)).getValue();
}
@Override
public boolean getTolerantFlyer() {
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.TOLERANT_FLYER.ordinal())).getValue();
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.TOLERANT_FLYER)).getValue();
}
@Override
public boolean getCaveDwelling() {
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.CAVE_DWELLING.ordinal())).getValue();
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue();
}
@Override
public IFlowerProvider getFlowerProvider() {
return ((IAlleleFlowers) getActiveAllele(EnumBeeChromosome.FLOWER_PROVIDER.ordinal())).getProvider();
return ((IAlleleFlowers) getActiveAllele(EnumBeeChromosome.FLOWER_PROVIDER)).getProvider();
}
@Override
public int getFlowering() {
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FLOWERING.ordinal())).getValue();
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FLOWERING)).getValue();
}
@Override
public int[] getTerritory() {
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY.ordinal())).getArea();
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea();
return new int[] { area.x, area.y, area.z };
}
@Override
public IAlleleBeeEffect getEffect() {
return (IAlleleBeeEffect) getActiveAllele(EnumBeeChromosome.EFFECT.ordinal());
return (IAlleleBeeEffect) getActiveAllele(EnumBeeChromosome.EFFECT);
}
@Override
@@ -13,7 +13,6 @@ package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map.Entry;
@@ -22,10 +21,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -69,9 +68,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
public int getSpeciesCount() {
if (beeSpeciesCount < 0) {
beeSpeciesCount = 0;
Iterator<Entry<String, IAllele> > it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator();
while (it.hasNext()) {
Entry<String, IAllele> entry = it.next();
for (Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
if (entry.getValue() instanceof IAlleleBeeSpecies)
if (((IAlleleBeeSpecies) entry.getValue()).isCounted())
beeSpeciesCount++;
@@ -101,7 +98,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
if (!isMember(bee))
return null;
Item beeItem = null;
Item beeItem;
switch (EnumBeeType.VALUES[type]) {
case QUEEN:
beeItem = ForestryItem.beeQueenGE.item();
@@ -117,7 +114,6 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -160,8 +156,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBee getMember(ItemStack stack) {
if (!ForestryItem.beeQueenGE.isItemEqual(stack) && !ForestryItem.beePrincessGE.isItemEqual(stack)
&& !ForestryItem.beeDroneGE.isItemEqual(stack) && !ForestryItem.beeLarvaeGE.isItemEqual(stack))
if (!isMember(stack))
return null;
return new Bee(stack.getTagCompound());
@@ -174,12 +169,12 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBee getBee(World world, IBeeGenome genome) {
return new Bee(world, genome);
return new Bee(genome);
}
@Override
public IBee getBee(World world, IBeeGenome genome, IBee mate) {
return new Bee(world, genome, mate);
return new Bee(genome, mate);
}
/* GENOME CONVERSIONS */
@@ -204,7 +199,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
}
/* TEMPLATES */
public static ArrayList<IBee> beeTemplates = new ArrayList<IBee>();
public static final ArrayList<IBee> beeTemplates = new ArrayList<IBee>();
@Override
public ArrayList<IBee> getIndividualTemplates() {
@@ -248,7 +243,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
}
/* BREEDING MODES */
ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<IBeekeepingMode>();
final ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<IBeekeepingMode>();
public static IBeekeepingMode activeBeekeepingMode;
@Override
@@ -10,13 +10,6 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeMutation;
@@ -26,6 +19,10 @@ 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 {
@@ -14,6 +14,7 @@ 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 {
@@ -98,24 +99,27 @@ public class BeeTemplates {
public static IMutation vengefulB;
public static IMutation avengingA;
public static IAllele[] defaultTemplate;
public static IAllele[] getDefaultTemplate() {
IAllele[] alleles = new IAllele[EnumBeeChromosome.values().length];
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesForest;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityNormal;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceNone;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolFalse;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceNone;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolFalse;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolFalse;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersVanilla;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlowest;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryDefault;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectNone;
return alleles;
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
@@ -543,6 +547,24 @@ public class BeeTemplates {
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() {
@@ -559,6 +581,25 @@ public class BeeTemplates {
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() {
@@ -10,24 +10,22 @@
******************************************************************************/
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 {
public static IBeekeepingMode easy = new BeekeepingMode("EASY", 2.0f, 1.0f, 1.0f, false, false);
public static IBeekeepingMode normal = new BeekeepingMode("NORMAL", 1.0f, 1.0f, 1.0f, false, true);
public static IBeekeepingMode hard = new BeekeepingMode("HARD", 0.75f, 1.5f, 1.0f, false, true);
public static IBeekeepingMode hardcore = new BeekeepingMode("HARDCORE", 0.5f, 5.0f, 0.8f, true, true);
public static IBeekeepingMode insane = new BeekeepingMode("INSANE", 0.2f, 10.0f, 0.6f, true, true);
public static final IBeekeepingMode easy = new BeekeepingMode("EASY", 2.0f, 1.0f, 1.0f, false, false);
public static final IBeekeepingMode normal = new BeekeepingMode("NORMAL", 1.0f, 1.0f, 1.0f, false, true);
public static final IBeekeepingMode hard = new BeekeepingMode("HARD", 0.75f, 1.5f, 1.0f, false, true);
public static final IBeekeepingMode hardcore = new BeekeepingMode("HARDCORE", 0.5f, 5.0f, 0.8f, true, true);
public static final IBeekeepingMode insane = new BeekeepingMode("INSANE", 0.2f, 10.0f, 0.6f, true, true);
final Random rand;
final String name;
@@ -143,10 +141,7 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isNaturalOffspring(IBee queen) {
if (!queen.isNatural())
return false;
return true;
return queen.isNatural();
}
@Override
@@ -10,30 +10,28 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
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 net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class HiveDrop implements IHiveDrop {
private IAllele[] template;
private ArrayList<ItemStack> additional = new ArrayList<ItemStack>();
private int chance;
private final IAllele[] template;
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;
this.chance = chance;
for (ItemStack stack : bonus)
this.additional.add(stack);
Collections.addAll(this.additional, bonus);
}
public HiveDrop setIgnobleShare(float share) {
@@ -42,22 +40,22 @@ public class HiveDrop implements IHiveDrop {
}
private IBee createBee(World world) {
IBee bee = PluginApiculture.beeInterface.getBee(world, PluginApiculture.beeInterface.templateAsGenome(template));
if(world.rand.nextFloat() < ignobleShare)
bee.setIsNatural(false);
return bee;
return PluginApiculture.beeInterface.getBee(world, PluginApiculture.beeInterface.templateAsGenome(template));
}
@Override
public ItemStack getPrincess(World world, int x, int y, int z, int fortune) {
return PluginApiculture.beeInterface.getMemberStack(createBee(world), EnumBeeType.PRINCESS.ordinal());
IBee bee = createBee(world);
if(world.rand.nextFloat() < ignobleShare)
bee.setIsNatural(false);
return PluginApiculture.beeInterface.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()));
ret.add(PluginApiculture.beeInterface.getMemberStack(createBee(world), EnumBeeType.DRONE.ordinal()));
return ret;
}
@@ -10,15 +10,14 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.utils.Vect;
import forestry.core.vect.Vect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.biome.BiomeGenBase;
public class JubilanceDefault implements IJubilanceProvider {
@@ -10,14 +10,12 @@
******************************************************************************/
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;
/**
* Hermits will not produce if there are any other living creatures nearby.
@@ -30,10 +28,7 @@ public class JubilanceProviderHermit extends JubilanceDefault {
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityLiving.class, bounding);
if (list.size() > 0)
return false;
return true;
return list.size() <= 0;
}
}
@@ -10,13 +10,13 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
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 {
@@ -32,12 +32,11 @@ public class JubilanceReqRes implements IJubilanceProvider {
if (blockRequired == null)
return true;
Block block = housing.getWorld().getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
int meta = housing.getWorld().getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage())
return true;
else
return false;
World world = housing.getWorld();
Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
int meta = world.getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
return StackUtils.equals(block, meta, blockRequired);
}
}
@@ -10,23 +10,21 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.lang.reflect.Field;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Vect;
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 {
int emcRequired = 0;
Class<?> condenserClass;
Field emcField;
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) {
@@ -10,14 +10,13 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
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 {
@@ -10,21 +10,20 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.Calendar;
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 shinenigans
* Fed up with Date and Calendar and their shenanigans
*/
public static class DayMonth {
public int day;
public int month;
public final int day;
public final int month;
public DayMonth() {
this.day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
@@ -93,8 +92,9 @@ public class MutationTimeLimited extends BeeMutation {
return day + "." + month;
}
}
DayMonth start;
DayMonth end;
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);
@@ -113,7 +113,7 @@ public class MutationTimeLimited extends BeeMutation {
if (chance == 0)
return 0;
if (start == null && end == null)
if (start == null)
return chance;
DayMonth now = new DayMonth();
@@ -15,14 +15,13 @@ import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearyPlain;
import forestry.core.config.ForestryItem;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.slots.SlotClosed;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerAlveary extends ContainerForestry {
private TileAlvearyPlain tile;
private final TileAlvearyPlain tile;
public ContainerAlveary(InventoryPlayer player, TileAlvearyPlain tile) {
super(tile);
@@ -31,27 +30,27 @@ public class ContainerAlveary extends ContainerForestry {
tile.sendNetworkUpdate();
// Queen/Princess
this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, new Object[] { ForestryItem.beePrincessGE, ForestryItem.beeQueenGE }));
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39));
// Drone
this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, new Object[] { ForestryItem.beeDroneGE }));
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65));
// Product Inventory
this.addSlot(new SlotClosed(tile, 2, 116, 52));
this.addSlot(new SlotClosed(tile, 3, 137, 39));
this.addSlot(new SlotClosed(tile, 4, 137, 65));
this.addSlot(new SlotClosed(tile, 5, 116, 78));
this.addSlot(new SlotClosed(tile, 6, 95, 65));
this.addSlot(new SlotClosed(tile, 7, 95, 39));
this.addSlot(new SlotClosed(tile, 8, 116, 26));
this.addSlotToContainer(new SlotOutput(tile, 2, 116, 52));
this.addSlotToContainer(new SlotOutput(tile, 3, 137, 39));
this.addSlotToContainer(new SlotOutput(tile, 4, 137, 65));
this.addSlotToContainer(new SlotOutput(tile, 5, 116, 78));
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++)
addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18));
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18));
// Player hotbar
for (int i = 0; i < 9; i++)
addSlot(new Slot(player, i, 8 + i * 18, 166));
addSlotToContainer(new Slot(player, i, 8 + i * 18, 166));
}
@Override
@@ -62,8 +61,8 @@ public class ContainerAlveary extends ContainerForestry {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++)
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
for (Object crafter : crafters)
tile.sendGUINetworkData(this, (ICrafting) crafter);
}
}
@@ -10,30 +10,26 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
import forestry.core.gui.ContainerLiquidTanks;
import forestry.core.gui.slots.SlotLiquidContainer;
import forestry.core.gui.slots.SlotFiltered;
public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks {
TileAlvearyHygroregulator tile;
public ContainerAlvearyHygroregulator(IInventory playerInventory, TileAlvearyHygroregulator tile) {
super(tile);
public ContainerAlvearyHygroregulator(IInventory inventory, TileAlvearyHygroregulator tile) {
super(inventory, tile);
this.tile = tile;
this.addSlot(new SlotLiquidContainer(tile, 0, 56, 38));
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.addSlot(new Slot(inventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18));
this.addSlotToContainer(new Slot(playerInventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18));
for (int i = 0; i < 9; ++i)
this.addSlot(new Slot(inventory, i, 8 + i * 18, 142));
this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142));
}
@@ -10,48 +10,37 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearySieve;
import forestry.core.config.ForestryItem;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerAlvearySieve extends ContainerForestry {
TileAlvearySieve tile;
public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) {
super(tile.getInternalInventory());
super(tile);
this.tile = tile;
IInventory inventory = tile.getInternalInventory();
addSlotToContainer(new SlotOutput(tile, 0, 94, 52).setCrafter(tile));
addSlotToContainer(new SlotOutput(tile, 1, 115, 39).setCrafter(tile));
addSlotToContainer(new SlotOutput(tile, 2, 73, 39).setCrafter(tile));
addSlotToContainer(new SlotOutput(tile, 3, 94, 26).setCrafter(tile));
addSlot(new SlotCustom(inventory, 0, 94, 52, new Object[0]).setCrafter(tile));
addSlot(new SlotCustom(inventory, 1, 115, 39, new Object[0]).setCrafter(tile));
addSlot(new SlotCustom(inventory, 2, 73, 39, new Object[0]).setCrafter(tile));
addSlot(new SlotCustom(inventory, 3, 94, 26, new Object[0]).setCrafter(tile));
addSlot(new SlotCustom(inventory, TileAlvearySieve.SLOT_SIEVE, 43, 39, ForestryItem.craftingMaterial.getItemStack(1, 3)).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++) {
addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
}
}
// Player hotbar
for (int i = 0; i < 9; i++) {
addSlot(new Slot(player, i, 8 + i * 18, 145));
addSlotToContainer(new Slot(player, i, 8 + i * 18, 145));
}
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return tile.isUseableByPlayer(entityplayer);
}
}
@@ -13,32 +13,27 @@ package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import forestry.api.apiculture.BeeManager;
import forestry.apiculture.gadgets.TileAlvearySwarmer;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.gui.slots.SlotFiltered;
public class ContainerAlvearySwarmer extends ContainerForestry {
public ContainerAlvearySwarmer(InventoryPlayer player, TileAlvearySwarmer tile) {
super(tile);
this.addSlot(new SlotCustom(tile, 0, 79, 52, getInducerItems()));
this.addSlot(new SlotCustom(tile, 1, 100, 39, getInducerItems()));
this.addSlot(new SlotCustom(tile, 2, 58, 39, getInducerItems()));
this.addSlot(new SlotCustom(tile, 3, 79, 26, getInducerItems()));
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++)
addSlot(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
// Player hotbar
for (int i = 0; i < 9; i++)
addSlot(new Slot(player, i, 8 + i * 18, 145));
addSlotToContainer(new Slot(player, i, 8 + i * 18, 145));
}
private Object[] getInducerItems() {
return BeeManager.inducers.keySet().toArray(new Object[0]);
}
}
@@ -10,62 +10,56 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import forestry.api.apiculture.IHiveFrame;
import forestry.apiculture.gadgets.TileBeehouse;
import forestry.core.config.ForestryItem;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.slots.SlotClosed;
import forestry.core.gui.slots.SlotCustom;
import forestry.core.utils.Utils;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerApiary extends ContainerForestry {
private final TileBeehouse tile;
public ContainerApiary(InventoryPlayer player, TileBeehouse tile, boolean hasFrames) {
super(tile.getInternalInventory());
super(tile);
this.tile = tile;
tile.sendNetworkUpdate();
IInventory inventory = tile.getInternalInventory();
// Queen/Princess
this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE));
this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_QUEEN, 29, 39));
// Drone
this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE));
this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_DRONE, 29, 65));
// Frames
if (hasFrames) {
this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_FRAMES_1, 66, 23, IHiveFrame.class));
this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52, IHiveFrame.class));
this.addSlot(new SlotCustom(inventory, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81, IHiveFrame.class));
this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_FRAMES_1, 66, 23));
this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_FRAMES_1 + 1, 66, 52));
this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_FRAMES_1 + 2, 66, 81));
}
// Product Inventory
this.addSlot(new SlotClosed(inventory, 2, 116, 52));
this.addSlot(new SlotClosed(inventory, 3, 137, 39));
this.addSlot(new SlotClosed(inventory, 4, 137, 65));
this.addSlot(new SlotClosed(inventory, 5, 116, 78));
this.addSlot(new SlotClosed(inventory, 6, 95, 65));
this.addSlot(new SlotClosed(inventory, 7, 95, 39));
this.addSlot(new SlotClosed(inventory, 8, 116, 26));
this.addSlotToContainer(new SlotOutput(tile, 2, 116, 52));
this.addSlotToContainer(new SlotOutput(tile, 3, 137, 39));
this.addSlotToContainer(new SlotOutput(tile, 4, 137, 65));
this.addSlotToContainer(new SlotOutput(tile, 5, 116, 78));
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++) {
addSlot(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18));
addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18));
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++) {
addSlot(new Slot(player, j1, 8 + j1 * 18, 166));
addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 166));
}
}
@@ -77,13 +71,9 @@ public class ContainerApiary extends ContainerForestry {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++) {
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
for (Object crafter : crafters) {
tile.sendGUINetworkData(this, (ICrafting) crafter);
}
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return Utils.isUseableByPlayer(entityplayer, tile, tile.getWorld(), tile.xCoord, tile.yCoord, tile.zCoord);
}
}
Loaded 100 of 851 files, more files were not shown because too many files have changed in this diff. Show more