Compare commits

...
329 Commits
Author SHA1 Message Date
mezz 3978a068d1 Bump minor patch version 2015-04-05 21:15:14 -07:00
mezz 9d2d0af432 Fix #594 Crash in Natura plugin
(cherry picked from commit 689adab411)
2015-04-05 21:14:56 -07:00
mezz d451309170 bump patch version to 3.5.1 2015-04-05 20:28:27 -07:00
mezz c82dd0fbfb Fix #592 Some Crates are missing a recipe 2015-04-05 20:22:21 -07:00
mezz 803911e10a Fix #588 crash on crate registry with disabled storage module and natura
(cherry picked from commit 536254af42)
2015-04-05 20:20:40 -07:00
Nirek-K 29eedf9011 Fix #588 Bulletproof null checks for Natura Plugin
(cherry picked from commit 3f6f12f7cc)
2015-04-05 20:15:05 -07:00
mezz 882848a00f Revert "Close #441 Add Underground Biomes Constructs integration"
This reverts commit b3b1a6a415.

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

(cherry picked from commit 1ca041a29f)

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

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

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

Lastminute typos are the best.

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

Add Config Option.

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

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

No files matched your search

+1
View File
@@ -5,6 +5,7 @@
!/forestry_techne
!/gradle/wrapper
!/src
!/api
# files
!/.gitignore
+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
Submodule api deleted from 2bb45e18be.
Submodule
+1
Submodule api/forestry added at 3e5b83d1b9.
+1
Submodule api/redstoneflux added at 10e10af214.
+3 -4
View File
@@ -1,6 +1,5 @@
mcversion=1.7.10
forgeversion=10.13.0.1207
forgeversion=10.13.2.1286
version_major=3
version_minor=3
version_patch=0
version_minor=5
version_patch=2
+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.2.1: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
}
+3
View File
@@ -0,0 +1,3 @@
Account;Email;Date;
samtrion;[email protected];2015-01-18
GenuineSounds;[email protected];2015-02-26
Binary file not shown.
+1 -1
Submodule lang updated: 3c34adcc54...fa0f81998b.
+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 final 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;
+39 -24
View File
@@ -4,12 +4,19 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
@@ -22,6 +29,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
import forestry.api.fuels.EngineBronzeFuel;
import forestry.api.fuels.EngineCopperFuel;
import forestry.api.fuels.FermenterFuel;
@@ -38,9 +46,6 @@ import forestry.core.proxy.Proxies;
import forestry.core.utils.FluidMap;
import forestry.core.utils.ItemStackMap;
import forestry.core.utils.StringUtil;
import java.io.File;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
/**
* Forestry Minecraft Mod
@@ -52,10 +57,11 @@ import net.minecraft.item.Item;
name = "Forestry",
version = Version.VERSION,
dependencies = "required-after:Forge@[10.13.0.1207,);"
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,)")
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,);"
+ "after:Natura@[2.2.0,);")
//, certificateFingerprint = Version.FINGERPRINT)
public class Forestry {
@@ -63,6 +69,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>();
@@ -71,6 +93,7 @@ public class Forestry {
FuelManager.copperEngineFuel = new ItemStackMap<EngineCopperFuel>();
FuelManager.generatorFuel = new FluidMap<GeneratorFuel>();
}
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
public static ForestryCore core = new ForestryCore();
public static PacketHandler packetHandler;
@@ -117,7 +140,7 @@ public class Forestry {
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
for (MissingMapping mapping : event.get())
for (MissingMapping mapping : event.get()) {
if (mapping.type == Type.BLOCK) {
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
if (block != null) {
@@ -129,22 +152,14 @@ 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());
}
}
}
}
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -21,9 +21,10 @@ 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.api.core.EnumErrorCode;
import forestry.core.EnumErrorCode;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
@@ -261,7 +262,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
try {
boolean canWork = true;
// Not while raining, at night or without light
EnumErrorCode state = queen.canWork(housing);
IErrorState state = queen.canWork(housing);
if (state != EnumErrorCode.OK) {
housing.setErrorState(state);
canWork = false;
@@ -270,6 +271,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
return canWork;
} catch (Error e) {
Proxies.log.logErrorAPI("Forestry", e, IBee.class);
return queenCanWorkDeprecated();
}
}
@@ -295,14 +297,17 @@ public class BeekeepingLogic implements IBeekeepingLogic {
return;
}
if (breedingTime < totalBreedingTime)
if (breedingTime < totalBreedingTime) {
breedingTime++;
if (breedingTime < totalBreedingTime)
}
if (breedingTime < totalBreedingTime) {
return;
}
// Breeding done, create new queen if slot available
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
return;
}
// Replace
IBee princess = PluginApiculture.beeInterface.getMember(housing.getQueen());
@@ -322,22 +327,26 @@ public class BeekeepingLogic implements IBeekeepingLogic {
// Remove drone
housing.getDrone().stackSize--;
if (housing.getDrone().stackSize <= 0)
if (housing.getDrone().stackSize <= 0) {
housing.setDrone(null);
}
// Reset breeding time
breedingTime = 0;
}
private boolean tryBreed() {
if (housing.getDrone() == null || housing.getQueen() == null)
if (housing.getDrone() == null || housing.getQueen() == null) {
return false;
}
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
return false;
}
if (!housing.canBreed())
if (!housing.canBreed()) {
return false;
}
return true;
}
@@ -372,11 +381,16 @@ public class BeekeepingLogic implements IBeekeepingLogic {
housing.onQueenDeath(getQueen());
// Princess
IBee heiress = queen.spawnPrincess(housing);
if (heiress != null) {
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
breedingTracker.registerPrincess(heiress);
offspring.push(princess);
boolean secondPrincess = this.housing.getWorld().rand.nextInt(100) < PluginApiculture.getSecondPrincessChance();
int count = secondPrincess ? 2 : 1;
while (count > 0) {
count--;
IBee heiress = queen.spawnPrincess(housing);
if (heiress != null) {
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
breedingTracker.registerPrincess(heiress);
offspring.push(princess);
}
}
// Drones
@@ -389,8 +403,9 @@ public class BeekeepingLogic implements IBeekeepingLogic {
while (!offspring.isEmpty()) {
ItemStack spawned = offspring.pop();
if (!housing.addProduct(spawned, true))
if (!housing.addProduct(spawned, true)) {
spawn.add(spawned);
}
}
housing.onPostQueenDeath(getQueen());
@@ -1,84 +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 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;
public class FlowerProviderCacti implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(world.getBlockMetadata(x, y, z));
return block == Blocks.cactus;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
return pollinatable.getPlantType().contains(EnumPlantType.Desert);
}
private boolean checkFlowerPot(int meta) {
if (meta == 9)
return true;
else
return false;
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
return growInPot(world, x, y, z);
return false;
}
private boolean growInPot(World world, int x, int y, int z) {
if (world.rand.nextBoolean())
world.setBlock(x, y, z, Blocks.flower_pot, 9, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlock(x, y, z, Blocks.flower_pot, 10, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.cacti");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.cactus) };
}
}
@@ -1,61 +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.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;
public class FlowerProviderEnd implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.dragon_egg;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.end");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.dragon_egg) };
}
}
@@ -1,79 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import 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;
public class FlowerProviderGourd implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.pumpkin_stem || block == Blocks.melon_stem;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// We only grow wheat, we don't plant it
if (block != Blocks.pumpkin_stem && block != Blocks.melon_stem)
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta > 6)
return false;
if (meta < 6)
meta += 2;
else
meta = 7;
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.gourd");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
}
}
@@ -1,85 +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.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;
public class FlowerProviderJungle implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(meta);
return block == Blocks.vine || (block == Blocks.tallgrass && meta == 2);
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
private boolean checkFlowerPot(int meta) {
if (meta == 11)
return true;
else
return false;
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block == Blocks.flower_pot)
return growInPot(world, x, y, z);
return false;
}
private boolean growInPot(World world, int x, int y, int z) {
world.setBlock(x, y, z, Blocks.flower_pot, 11, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.jungle");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.vine), new ItemStack(Blocks.tallgrass, 1, 2) };
}
}
@@ -1,103 +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.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;
public class FlowerProviderMushroom implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(world.getBlockMetadata(x, y, z));
return block == Blocks.brown_mushroom || block == Blocks.red_mushroom;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
private boolean checkFlowerPot(int meta) {
if (meta == 7 || meta == 8)
return true;
else
return false;
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (!block.isAir(world, x, y, z))
if (block == Blocks.flower_pot)
return growInPot(world, x, y, z);
else
return false;
// Check ground
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.mycelium)
return false;
Block mushroom;
if (world.rand.nextBoolean())
mushroom = Blocks.brown_mushroom;
else
mushroom = Blocks.red_mushroom;
world.setBlock(x, y, z, mushroom, 0, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
private boolean growInPot(World world, int x, int y, int z) {
if (world.rand.nextBoolean())
world.setBlock(x, y, z, Blocks.flower_pot, 7, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlock(x, y, z, Blocks.flower_pot, 8, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.mushroom");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom) };
}
}
@@ -1,76 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import 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;
public class FlowerProviderNetherwart implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.nether_wart;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
return pollinatable.getPlantType().contains(EnumPlantType.Nether);
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// We only grow netherwart, we don't plant it
if (block != Blocks.nether_wart)
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 3)
return false;
if (meta == 2)
meta = 3;
else
meta = 2;
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.nether");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.nether_wart) };
}
}
@@ -1,112 +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.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;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
public class FlowerProviderVanilla implements IFlowerProvider {
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
// Specific check for flower pots.
if (block == Blocks.flower_pot)
return checkFlowerPot(meta);
ItemStack flower = new ItemStack(block, 1, meta);
for (ItemStack stack : FlowerManager.plainFlowers)
if (flower.isItemEqual(stack))
return true;
return false;
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
private boolean checkFlowerPot(int meta) {
if (meta == 1 || meta == 2)
return true;
else
return false;
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (!block.isAir(world, x, y, z))
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
return growInPot(world, x, y, z);
else
return false;
// Check ground
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass)
return false;
// Determine flower to plant
Collections.shuffle(FlowerManager.plainFlowers);
ItemStack flower = FlowerManager.plainFlowers.get(world.rand.nextInt(FlowerManager.plainFlowers.size() - 1));
world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH);
return true;
}
private boolean growInPot(World world, int x, int y, int z) {
if (world.rand.nextBoolean())
world.setBlock(x, y, z, Blocks.flower_pot, 1, Defaults.FLAG_BLOCK_SYNCH);
else
world.setBlock(x, y, z, Blocks.flower_pot, 2, Defaults.FLAG_BLOCK_SYNCH);
return true;
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.vanilla");
}
@Override
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
return products;
}
@Override
public ItemStack[] getItemStacks() {
return FlowerManager.plainFlowers.toArray(new ItemStack[FlowerManager.plainFlowers.size()]);
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -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;
@@ -38,9 +37,10 @@ import forestry.apiculture.gui.GuiBeealyzer;
import forestry.apiculture.gui.GuiHabitatLocator;
import forestry.apiculture.gui.GuiImprinter;
import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory;
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
import forestry.core.GuiHandlerBase;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.network.GuiId;
import forestry.plugins.PluginApiculture;
@@ -51,53 +51,60 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
int cleanId = decodeGuiID(id);
int guiData = decodeGuiData(id);
if (cleanId >= GuiId.values().length)
if (cleanId >= GuiId.values().length) {
return null;
}
ItemStack equipped;
switch (GuiId.values()[cleanId]) {
case AlvearyGUI:
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearyGUI:
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case ApiaristChestGUI:
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaristChestGUI:
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
case ApiaryGUI:
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
case BeealyzerGUI:
equipped = getEquippedItem(player);
if (equipped == null)
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
case HygroregulatorGUI:
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
case HabitatLocatorGUI:
equipped = getEquippedItem(player);
if (equipped == null)
return null;
return new GuiHabitatLocator(player.inventory, new BiomefinderInventory(equipped));
case HygroregulatorGUI:
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
return new GuiImprinter(player.inventory, new ImprinterInventory(player));
default:
return null;
}
}
@@ -106,58 +113,65 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
int cleanId = decodeGuiID(id);
int guiData = decodeGuiData(id);
if (cleanId >= GuiId.values().length)
if (cleanId >= GuiId.values().length) {
return null;
}
ItemStack equipped;
switch (GuiId.values()[cleanId]) {
case AlvearyGUI:
synchApiaristTracker(world, player);
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearyGUI:
synchApiaristTracker(world, player);
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case ApiaristChestGUI:
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaristChestGUI:
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
case ApiaryGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
case BeealyzerGUI:
equipped = getEquippedItem(player);
if (equipped == null)
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
synchApiaristTracker(world, player);
return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player);
case BeehouseGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
case HygroregulatorGUI:
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
synchApiaristTracker(world, player);
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
synchApiaristTracker(world, player);
return new ContainerBeealyzer(player.inventory, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
case HabitatLocatorGUI:
equipped = getEquippedItem(player);
if (equipped == null)
return null;
return new ContainerHabitatLocator(player.inventory, new BiomefinderInventory(equipped));
case HygroregulatorGUI:
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
synchApiaristTracker(world, player);
return new ContainerImprinter(player.inventory, new ImprinterInventory(player));
default:
return null;
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -17,8 +17,9 @@ public class MaterialBeehive extends Material {
public MaterialBeehive(boolean noHarvest) {
super(MapColor.stoneColor);
if (noHarvest)
if (noHarvest) {
this.setRequiresTool();
}
setImmovableMobility();
}
@@ -4,13 +4,14 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
@@ -23,29 +24,27 @@ import forestry.core.proxy.Proxies;
public class PacketHandlerApiculture implements IPacketHandler {
@Override
public void onPacketData(int packetID, DataInputStream data, EntityPlayer player) {
public boolean onPacketData(int packetID, DataInputStream data, EntityPlayer player) throws IOException {
try {
switch (packetID) {
switch (packetID) {
case PacketIds.HABITAT_BIOME_POINTER:
PacketCoordinates packetC = new PacketCoordinates();
packetC.readData(data);
Proxies.common.setBiomefinderCoordinates(player, packetC.getCoordinates());
break;
Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates());
return true;
case PacketIds.IMPRINT_SELECTION_GET:
onImprintSelectionGet(player);
break;
}
} catch (Exception ex) {
ex.printStackTrace();
return true;
}
return false;
}
private void onImprintSelectionGet(EntityPlayer playerEntity) {
if (!(playerEntity.openContainer instanceof ContainerImprinter))
if (!(playerEntity.openContainer instanceof ContainerImprinter)) {
return;
}
((ContainerImprinter) playerEntity.openContainer).sendSelection(playerEntity);
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -33,6 +33,7 @@ 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;
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
@@ -41,6 +42,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
try {
MapGenStructureIO.func_143031_a(ComponentVillageBeeHouse.class, "Forestry:BeeHouse");
} catch (Throwable e) {
Proxies.log.severe("Failed to register village beehouse.");
}
}
@@ -0,0 +1,61 @@
/*******************************************************************************
* 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 java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.core.commands.ICommandModeHelper;
import forestry.plugins.PluginApiculture;
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,75 @@
/*******************************************************************************
* 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 java.util.ArrayList;
import java.util.Collection;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.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;
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());
}
}
@@ -4,44 +4,46 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.commands;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.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.apiculture.SpeciesNotFoundException;
import forestry.apiculture.TemplateNotFoundException;
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 net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class CommandBeekeepingGiveBee extends SubCommand {
public class CommandBeeGive extends SubCommand {
private final String beeTypeHelpString;
private final String[] beeTypeArr;
public CommandBeekeepingGiveBee() {
public CommandBeeGive() {
super("give");
setPermLevel(PermLevel.ADMIN);
List<String> beeTypeStrings = new ArrayList<String>();
for (EnumBeeType type : EnumBeeType.values()) {
if (type == EnumBeeType.NONE)
if (type == EnumBeeType.NONE) {
continue;
}
beeTypeStrings.add(type.getName());
}
@@ -53,35 +55,58 @@ public class CommandBeekeepingGiveBee extends SubCommand {
Iterator<String> iter = beeTypeStrings.iterator();
while (iter.hasNext()) {
beeTypeHelp.append(iter.next());
if (iter.hasNext())
if (iter.hasNext()) {
beeTypeHelp.append(separator);
}
}
beeTypeHelpString = beeTypeHelp.toString();
}
@Override
public void processSubCommand(ICommandSender sender, String[] arguments) {
if (arguments.length < 3) {
if (arguments.length < 2) {
printHelp(sender);
return;
}
EnumBeeType beeType = getBeeType(arguments[0]);
IBeeGenome beeGenome = getBeeGenome(arguments[0]);
EnumBeeType beeType = getBeeType(arguments[1]);
if (beeType == EnumBeeType.NONE) {
printHelp(sender);
return;
}
EntityPlayer player = CommandHelpers.getPlayer(sender, arguments[1]);
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;
}
String parameter = arguments[2];
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(parameter))
if (!uid.equals(speciesName)) {
continue;
}
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
@@ -91,44 +116,36 @@ public class CommandBeekeepingGiveBee extends SubCommand {
if (species == null) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(parameter)) {
if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(speciesName)) {
species = (IAlleleBeeSpecies) allele;
break;
}
}
}
if (species == null)
throw new SpeciesNotFoundException(parameter);
if (species == null) {
throw new SpeciesNotFoundException(speciesName);
}
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
if (template == null)
if (template == null) {
throw new TemplateNotFoundException(species);
}
IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template);
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome);
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.beekeeping.give.given", player.getCommandSenderName(), template[0].getName(), beeType.getName());
return PluginApiculture.beeInterface.templateAsGenome(template);
}
@Override
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters) {
if (parameters.length == 1) {
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr);
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
tabCompletion.add("help");
return tabCompletion;
} else if (parameters.length == 2) {
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr);
} else if (parameters.length == 3) {
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
}
return null;
}
@@ -136,17 +153,20 @@ public class CommandBeekeepingGiveBee extends SubCommand {
String[] getSpecies() {
List<String> species = new ArrayList<String>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
species.add(allele.getName());
}
}
return species.toArray(new String[species.size()]);
}
EnumBeeType getBeeType(String beeTypeName) {
for (EnumBeeType beeType : EnumBeeType.values()) {
if (beeType.getName().equalsIgnoreCase(beeTypeName))
if (beeType.getName().equalsIgnoreCase(beeTypeName)) {
return beeType;
}
}
return EnumBeeType.NONE;
}
@@ -45,10 +45,11 @@ public class EntityBee extends EntityCreature implements IAnimals {
}
public EntityBee setIndividual(IBee bee) {
if (bee != null)
if (bee != null) {
contained = bee;
else
} else {
contained = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());
}
//isImmuneToFire = contained.getGenome().getFireResist();
setSpecies(contained.getGenome().getPrimary());
@@ -83,8 +84,9 @@ public class EntityBee extends EntityCreature implements IAnimals {
@SideOnly(Side.CLIENT)
public ResourceLocation getTexture() {
if (textureResource == null || lastTextureUpdate != lastUpdate)
if (textureResource == null || lastTextureUpdate != lastUpdate) {
textureResource = new ForestryResource(beeTexture);
}
return textureResource;
}
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.genetics.IFlower;
final class Flower implements IFlower {
private final Block block;
private final int meta;
private Double weight;
public Flower(Block block, int meta, double weight) {
this.block = block;
this.meta = meta;
this.weight = weight;
}
public boolean isPlantable() {
return this.weight != 0.0;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof IFlower)) {
return false;
}
IFlower flower = (IFlower) obj;
return Block.isEqualTo(this.block, flower.getBlock()) && (this.meta == OreDictionary.WILDCARD_VALUE || flower.getMeta() == OreDictionary.WILDCARD_VALUE || this.meta == flower.getMeta());
}
@Override
public int compareTo(IFlower other) {
return this.weight.compareTo(other.getWeight());
}
@Override
public Block getBlock() {
return block;
}
@Override
public int getMeta() {
return meta;
}
@Override
public double getWeight() {
return weight;
}
@Override
public void setWeight(double weight) {
this.weight = weight;
}
}
@@ -4,66 +4,64 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
package forestry.apiculture.flowers;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.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.IFlower;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Defaults;
import forestry.core.utils.StringUtil;
public class FlowerProviderWheat implements IFlowerProvider {
public class FlowerProvider implements IFlowerProvider {
private final String flowerType;
private final String description;
public FlowerProvider(String flowerType, String description) {
this.flowerType = flowerType;
this.description = description;
}
@Override
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return block == Blocks.wheat;
return FlowerManager.flowerRegistry.isAcceptedFlower(this.flowerType, world, individual, x, y, z);
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
EnumSet<EnumPlantType> plantTypes = pollinatable.getPlantType();
if (flowerType.equals(FlowerManager.FlowerTypeNether)) {
return plantTypes.contains(EnumPlantType.Nether);
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
return plantTypes.contains(EnumPlantType.Desert);
} else {
return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether);
}
}
@Override
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
// We only grow wheat, we don't plant it
if (block != Blocks.wheat)
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta > 6)
return false;
if (meta < 6)
meta += 2;
else
meta = 7;
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
return true;
return FlowerManager.flowerRegistry.growFlower(this.flowerType, world, individual, x, y, z);
}
@Override
public String getDescription() {
return StringUtil.localize("flowers.wheat");
return StringUtil.localize(this.description);
}
@Override
@@ -72,8 +70,8 @@ public class FlowerProviderWheat implements IFlowerProvider {
}
@Override
public ItemStack[] getItemStacks() {
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
public List<IFlower> getFlowers() {
return FlowerManager.flowerRegistry.getAcceptableFlowers(this.flowerType);
}
}
@@ -0,0 +1,248 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import com.google.common.collect.ArrayListMultimap;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public final class FlowerRegistry implements IFlowerRegistry {
private final ArrayListMultimap<String, IFlower> registeredFlowers;
private final ArrayListMultimap<String, IFlowerGrowthRule> growthRules;
private final Map<String, TreeMap<Double, IFlower>> chances;
private boolean hasDeprecatedFlowersImported;
public FlowerRegistry() {
this.registeredFlowers = ArrayListMultimap.create();
this.growthRules = ArrayListMultimap.create();
this.chances = new HashMap<String, TreeMap<Double, IFlower>>();
this.hasDeprecatedFlowersImported = false;
registerVanillaFlowers();
registerVanillaGrowthRules();
}
@Override
public void registerAcceptableFlower(Block block, String... flowerTypes) {
registerFlower(block, OreDictionary.WILDCARD_VALUE, 0.0, flowerTypes);
}
@Override
public void registerAcceptableFlower(Block block, int meta, String... flowerTypes) {
registerFlower(block, meta, 0.0, flowerTypes);
}
@Override
public void registerPlantableFlower(Block block, int meta, double weight, String... flowerTypes) {
registerFlower(block, meta, weight, flowerTypes);
}
private void registerFlower(Block block, int meta, double weight, String... flowerTypes) {
if (block == null) {
return;
}
if (weight <= 0.0) {
weight = 0.0;
}
if (weight >= 1.0) {
weight = 1.0;
}
Flower newFlower = new Flower(block, meta, weight);
Integer index;
for (String flowerType : flowerTypes) {
List<IFlower> flowers = this.registeredFlowers.get(flowerType);
index = flowers.indexOf(newFlower);
if (index == -1) {
flowers.add(newFlower);
} else if (flowers.get(index).getWeight() > newFlower.getWeight()) {
flowers.get(index).setWeight(newFlower.getWeight());
}
if (this.chances.containsKey(flowerType)) {
this.chances.remove(flowerType);
}
Collections.sort(this.registeredFlowers.get(flowerType));
}
}
@Override
public boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
internalInitialize();
if (!this.registeredFlowers.containsKey(flowerType)) {
return false;
}
Block block = world.getBlock(x, y, z);
if (block.isAir(world, x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) {
return false;
}
int meta;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlowerPot) {
TileEntityFlowerPot tileFlowerPot = (TileEntityFlowerPot) tile;
Item item = tileFlowerPot.getFlowerPotItem();
block = Block.getBlockFromItem(item);
meta = tileFlowerPot.getFlowerPotData();
} else {
meta = world.getBlockMetadata(x, y, z);
}
Flower flower = new Flower(block, meta, 0);
List<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
return acceptedFlowers.contains(flower);
}
@Override
public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
internalInitialize();
if (!this.growthRules.containsKey(flowerType)) {
return false;
}
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
if (rule.growFlower(this, flowerType, world, individual, x, y, z)) {
return true;
}
}
return false;
}
@Override
public List<IFlower> getAcceptableFlowers(String flowerType) {
internalInitialize();
return this.registeredFlowers.get(flowerType);
}
@Override
public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) {
if (rule == null) {
return;
}
for (String flowerType : flowerTypes) {
this.growthRules.get(flowerType).add(rule);
}
}
@Override
public IFlower getRandomPlantableFlower(String flowerType, Random rand) {
TreeMap<Double, IFlower> chancesMap = getChancesMap(flowerType);
double maxKey = chancesMap.lastKey() + 1.0;
return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey));
}
private TreeMap<Double, IFlower> getChancesMap(String flowerType) {
if (!this.chances.containsKey(flowerType)) {
TreeMap<Double, IFlower> flowerChances = new TreeMap<Double, IFlower>();
double count = 0.0;
for (IFlower flower : this.registeredFlowers.get(flowerType)) {
if (flower.isPlantable()) {
flowerChances.put(count, flower);
count += flower.getWeight();
}
}
this.chances.put(flowerType, flowerChances);
}
return this.chances.get(flowerType);
}
/*
* Method to support deprecated FlowerManager.plainFlowers
*/
@SuppressWarnings("deprecation")
private void internalInitialize() {
if (!hasDeprecatedFlowersImported) {
for (ItemStack plainFlower : FlowerManager.plainFlowers) {
Block flowerBlock = Block.getBlockFromItem(plainFlower.getItem());
int meta = plainFlower.getItemDamage();
registerPlantableFlower(flowerBlock, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
hasDeprecatedFlowersImported = true;
}
}
private void registerVanillaFlowers() {
// Register plantable plants
for (int meta = 0; meta <= 8; meta++) {
registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti);
// Register acceptable plants
registerAcceptableFlower(Blocks.red_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.yellow_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.brown_mushroom, FlowerManager.FlowerTypeMushrooms);
registerAcceptableFlower(Blocks.red_mushroom, FlowerManager.FlowerTypeMushrooms);
registerAcceptableFlower(Blocks.cactus, FlowerManager.FlowerTypeCacti);
registerAcceptableFlower(Blocks.dragon_egg, FlowerManager.FlowerTypeEnd);
registerAcceptableFlower(Blocks.vine, FlowerManager.FlowerTypeJungle);
registerAcceptableFlower(Blocks.tallgrass, FlowerManager.FlowerTypeJungle);
registerAcceptableFlower(Blocks.wheat, FlowerManager.FlowerTypeWheat);
registerAcceptableFlower(Blocks.pumpkin_stem, FlowerManager.FlowerTypeGourd);
registerAcceptableFlower(Blocks.melon_stem, FlowerManager.FlowerTypeGourd);
registerAcceptableFlower(Blocks.nether_wart, FlowerManager.FlowerTypeNether);
registerAcceptableFlower(Blocks.double_plant, 0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
private void registerVanillaGrowthRules() {
registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow);
registerGrowthRule(new VanillaFlowerPotGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
FlowerManager.FlowerTypeJungle);
registerGrowthRule(new VanillaMyceliumGrowthRule(), FlowerManager.FlowerTypeMushrooms);
registerGrowthRule(new VanillaDefaultGrowthRule(), FlowerManager.FlowerTypeEnd);
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.wheat), FlowerManager.FlowerTypeWheat);
}
}
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaDefaultGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return true;
}
}
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Defaults;
public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
}
}
@@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule {
private final List<Block> allowedItems;
public VanillaFertilizeGrowthRule(Block... allowedItems) {
this.allowedItems = Arrays.asList(allowedItems);
}
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
Block ground = world.getBlock(x, y, z);
int groundMeta;
for (Block b : this.allowedItems) {
if (b == ground) {
groundMeta = world.getBlockMetadata(x, y, z);
if (groundMeta > 6) {
return false;
}
if (groundMeta < 6) {
groundMeta += world.rand.nextInt(2) + 1;
} else {
groundMeta = 7;
}
return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2);
}
}
return false;
}
}
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlowerPot;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.world.World;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlowerPot)) {
return false;
}
TileEntityFlowerPot flowerPotTile = (TileEntityFlowerPot) tile;
if (flowerPotTile.getFlowerPotItem() != null) {
return false;
}
Block block = world.getBlock(x, y, z);
if (!(block instanceof BlockFlowerPot)) {
return false;
}
BlockFlowerPot flowerPot = (BlockFlowerPot) block;
int flower;
if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) {
flower = world.rand.nextInt(2) + 1;
} else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) {
flower = 6;
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
flower = world.rand.nextInt(2) + 9;
} else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) {
flower = world.rand.nextInt(2) + 7;
} else {
return false;
}
TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower);
flowerPotTile.func_145964_a(newTile.getFlowerPotItem(), newTile.getFlowerPotData());
flowerPotTile.markDirty();
if (!world.setBlockMetadataWithNotify(x, y, z, 1, 2)) {
world.markBlockForUpdate(x, y, z);
}
return true;
}
}
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Defaults;
public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.mycelium) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
}
}
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Defaults;
public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (world.getBlock(x, y, z) != Blocks.snow) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -39,13 +39,14 @@ public class BlockAlveary extends BlockStructure {
setCreativeTab(Tabs.tabApiculture);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 8; i++) {
if (i == 1)
if (i == 1) {
continue;
}
list.add(new ItemStack(item, 1, i));
}
}
@@ -77,20 +78,20 @@ public class BlockAlveary extends BlockStructure {
@Override
public TileEntity createTileEntity(World world, int metadata) {
switch (metadata) {
case TileAlvearySwarmer.BLOCK_META:
return new TileAlvearySwarmer();
case TileAlvearyFan.BLOCK_META:
return new TileAlvearyFan();
case TileAlvearyHeater.BLOCK_META:
return new TileAlvearyHeater();
case TileAlvearyHygroregulator.BLOCK_META:
return new TileAlvearyHygroregulator();
case TileAlvearyStabiliser.BLOCK_META:
return new TileAlvearyStabiliser();
case TileAlvearySieve.BLOCK_META:
return new TileAlvearySieve();
default:
return new TileAlvearyPlain();
case TileAlvearySwarmer.BLOCK_META:
return new TileAlvearySwarmer();
case TileAlvearyFan.BLOCK_META:
return new TileAlvearyFan();
case TileAlvearyHeater.BLOCK_META:
return new TileAlvearyHeater();
case TileAlvearyHygroregulator.BLOCK_META:
return new TileAlvearyHygroregulator();
case TileAlvearyStabiliser.BLOCK_META:
return new TileAlvearyStabiliser();
case TileAlvearySieve.BLOCK_META:
return new TileAlvearySieve();
default:
return new TileAlvearyPlain();
}
}
@@ -143,28 +144,29 @@ public class BlockAlveary extends BlockStructure {
public IIcon getIcon(int side, int metadata) {
if ((metadata <= 1
|| metadata == TileAlvearySieve.BLOCK_META || metadata == TileAlvearySwarmer.BLOCK_META || metadata == TileAlvearyStabiliser.BLOCK_META)
&& (side == 1 || side == 0))
&& (side == 1 || side == 0)) {
return icons[BOTTOM];
}
switch (metadata) {
case TileAlvearyPlain.BLOCK_META:
return icons[PLAIN];
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
return icons[ALVEARY_SWARMER_OFF];
case TileAlvearyFan.BLOCK_META:
return icons[ALVEARY_FAN_OFF];
case TileAlvearyHeater.BLOCK_META:
return icons[ALVEARY_HEATER_OFF];
case TileAlvearyHygroregulator.BLOCK_META:
return icons[ALVEARY_HYGRO];
case TileAlvearyStabiliser.BLOCK_META:
return icons[STABILISER];
case TileAlvearySieve.BLOCK_META:
return icons[SIEVE];
default:
return null;
case TileAlvearyPlain.BLOCK_META:
return icons[PLAIN];
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
return icons[ALVEARY_SWARMER_OFF];
case TileAlvearyFan.BLOCK_META:
return icons[ALVEARY_FAN_OFF];
case TileAlvearyHeater.BLOCK_META:
return icons[ALVEARY_HEATER_OFF];
case TileAlvearyHygroregulator.BLOCK_META:
return icons[ALVEARY_HYGRO];
case TileAlvearyStabiliser.BLOCK_META:
return icons[STABILISER];
case TileAlvearySieve.BLOCK_META:
return icons[SIEVE];
default:
return null;
}
}
@@ -174,10 +176,11 @@ public class BlockAlveary extends BlockStructure {
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 1)
if (meta == 1) {
return this.getIcon(side, meta);
else if (meta > 1)
} else if (meta > 1) {
return getBlockTextureFromSideAndTile(world, x, y, z, side);
}
Block blockXP = world.getBlock(x + 1, y, z);
Block blockXM = world.getBlock(x - 1, y, z);
@@ -186,24 +189,29 @@ public class BlockAlveary extends BlockStructure {
if (world.getBlockMetadata(x + 1, y, z) == 1) {
if (world.getBlock(x, y, z + 1) != this)
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(42, side);
else
} else {
return switchForSide(41, side);
}
} else
} else {
return this.getIcon(side, meta);
}
} else if (blockXP != this && blockXM == this)
} else if (blockXP != this && blockXM == this) {
if (world.getBlockMetadata(x - 1, y, z) == 1) {
if (world.getBlock(x, y, z + 1) != this)
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(41, side);
else
} else {
return switchForSide(42, side);
}
} else
} else {
return this.getIcon(side, meta);
}
}
return this.getIcon(side, meta);
}
@@ -211,8 +219,9 @@ public class BlockAlveary extends BlockStructure {
@SideOnly(Side.CLIENT)
private IIcon getBlockTextureFromSideAndTile(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile == null || !(tile instanceof TileAlveary))
if (tile == null || !(tile instanceof TileAlveary)) {
return getIcon(side, 0);
}
return icons[((TileAlveary) tile).getIcon(side, world.getBlockMetadata(x, y, z))];
}
@@ -221,14 +230,16 @@ public class BlockAlveary extends BlockStructure {
private IIcon switchForSide(int textureId, int side) {
if (side == 4 || side == 5) {
if (textureId == 41)
if (textureId == 41) {
return icons[LEFT];
else
} else {
return icons[RIGHT];
} else if (textureId == 41)
}
} else if (textureId == 41) {
return icons[RIGHT];
else
} else {
return icons[LEFT];
}
}
}
@@ -4,21 +4,16 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.apiculture.hives.HiveManager;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.config.Config;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
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;
@@ -31,9 +26,18 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.apiculture.worldgen.HiveRegistry;
import forestry.core.config.Config;
import forestry.core.inventory.InvTools;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
public class BlockBeehives extends BlockContainer {
@@ -42,6 +46,7 @@ public class BlockBeehives extends BlockContainer {
setLightLevel(0.8f);
setHardness(1.0f);
setCreativeTab(Tabs.tabApiculture);
setHarvestLevel("scoop", 0);
}
@Override
@@ -55,17 +60,20 @@ public class BlockBeehives extends BlockContainer {
}
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
if (canHarvestBlock(player, world.getBlockMetadata(x, y, z))) {
// Handle TE'd beehives
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileSwarm) {
TileSwarm swarm = (TileSwarm) tile;
if (swarm.containsBees())
for (ItemStack beeStack : swarm.contained.getStacks())
if (beeStack != null)
if (swarm.containsBees()) {
for (ItemStack beeStack : InvTools.getStacks(swarm.contained)) {
if (beeStack != null) {
StackUtils.dropItemStackAsEntity(beeStack, world, x, y, z);
}
}
}
}
}
@@ -91,26 +99,29 @@ public class BlockBeehives extends BlockContainer {
while (tries <= 10 && !hasPrincess) {
tries++;
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.add(drop.getPrincess(world, x, y, z, fortune));
hasPrincess = true;
break;
}
}
}
// Grab drones
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getDrones(world, x, y, z, fortune));
break;
}
}
// Grab anything else on offer
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getAdditional(world, x, y, z, fortune));
break;
}
}
return ret;
}
@@ -123,25 +134,33 @@ public class BlockBeehives extends BlockContainer {
private List<IHiveDrop> getDropsForHive(int meta) {
String hiveName = getHiveNameForMeta(meta);
if (hiveName == null)
if (hiveName == null) {
return Collections.emptyList();
return HiveManager.get(hiveName).getDrops();
}
return PluginApiculture.hiveRegistry.getDrops(hiveName);
}
private String getHiveNameForMeta(int meta) {
switch (meta) {
case 1: return HiveManager.forest;
case 2: return HiveManager.meadows;
case 3: return HiveManager.desert;
case 4: return HiveManager.jungle;
case 5: return HiveManager.end;
case 6: return HiveManager.snow;
case 7: return HiveManager.swamp;
case 1:
return HiveRegistry.forest;
case 2:
return HiveRegistry.meadows;
case 3:
return HiveRegistry.desert;
case 4:
return HiveRegistry.jungle;
case 5:
return HiveRegistry.end;
case 6:
return HiveRegistry.snow;
case 7:
return HiveRegistry.swamp;
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 1));
@@ -149,7 +168,7 @@ public class BlockBeehives extends BlockContainer {
itemList.add(new ItemStack(this, 1, 3));
itemList.add(new ItemStack(this, 1, 4));
if (Config.isDebug) {
itemList.add(new ItemStack(this, 1 ,5));
itemList.add(new ItemStack(this, 1, 5));
}
itemList.add(new ItemStack(this, 1, 6));
itemList.add(new ItemStack(this, 1, 7));
@@ -173,18 +192,21 @@ public class BlockBeehives extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) {
if (j == 0 || j > 8)
if (j == 0 || j > 8) {
return null;
}
if (i == 0 || i == 1) {
if (j * 2 < icons.length && icons[j * 2] != null)
if (j * 2 < icons.length && icons[j * 2] != null) {
return icons[j * 2];
else
} else {
return icons[2];
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null)
}
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null) {
return icons[j * 2 + 1];
else
} else {
return icons[3];
}
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -30,12 +30,12 @@ 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 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;
@@ -96,7 +96,7 @@ public class BlockCandle extends BlockTorch {
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return (isLit(meta))? 14 : 0;
return (isLit(meta)) ? 14 : 0;
}
/*@SideOnly(Side.CLIENT)
@@ -111,20 +111,17 @@ 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;
}
else {
} else {
i = this.unlitTip;
}
}
else {
} else {
if (isLit(meta)) {
i = this.litStump;
}
else {
} else {
i = this.unlitStump;
}
}
@@ -140,22 +137,22 @@ public class BlockCandle extends BlockTorch {
return colour;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
}
// Dye names correspond to colour values as below.
private static final String[] dyes = { "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" };
private static final String[] dyes = {"dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack"};
private static final int[][] colours = { { 255, 255, 255 } , { 219, 125, 62 } , { 255, 20, 255 } , { 107, 138, 201 } ,
{ 255, 255, 20 } , { 20, 255, 20 } , { 208, 132, 153 } , { 74, 74, 74 } ,
{ 154, 161, 161 } , { 20, 255, 255 } , { 126, 61, 181 } , { 20, 20, 255 } ,
{ 79, 50, 31 } , { 53, 70, 27 } , { 150, 52, 48 } , { 20, 20, 20 } };
private static final int[][] colours = {{255, 255, 255}, {219, 125, 62}, {255, 20, 255}, {107, 138, 201},
{255, 255, 20}, {20, 255, 20}, {208, 132, 153}, {74, 74, 74},
{154, 161, 161}, {20, 255, 255}, {126, 61, 181}, {20, 20, 255},
{79, 50, 31}, {53, 70, 27}, {150, 52, 48}, {20, 20, 20}};
public static final String colourTagName = "colour";
@@ -169,17 +166,17 @@ public class BlockCandle extends BlockTorch {
if (!isLit(meta)) {
if (held == null || !lightingItems.contains(held.getItem())) {
toggleLitState = false;
}
else if (StackUtils.equals(this, held) && isLit(held)) {
} else if (StackUtils.equals(this, held) && isLit(held)) {
toggleLitState = true;
}
}
if (held != null) {
// Ensure a TileEntity exists. May be able to remove this in future versions.
TileCandle te = (TileCandle)world.getTileEntity(x, y, z);
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)) {
@@ -187,18 +184,15 @@ public class BlockCandle extends BlockTorch {
// Copy the colour of an unlit, coloured candle.
if (held.hasTagCompound() && held.getTagCompound().hasKey(colourTagName)) {
te.setColour(held.getTagCompound().getInteger(colourTagName));
}
else {
} else {
// Reset to white if item has no
te.setColour(0xffffff);
}
}
else {
} else {
toggleLitState = true;
}
flag = true;
}
else {
} else {
// Check for dye-able ness.
boolean matched = false;
for (int i = 0; i < dyes.length; ++i) {
@@ -206,8 +200,7 @@ public class BlockCandle extends BlockTorch {
if (OreDictionary.itemMatches(stack, held, true)) {
if (isLit(meta)) {
te.setColour(colours[i][0], colours[i][1], colours[i][2]);
}
else {
} else {
te.addColour(colours[i][0], colours[i][1], colours[i][2]);
}
world.markBlockForUpdate(x, y, z);
@@ -235,7 +228,7 @@ public class BlockCandle extends BlockTorch {
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileCandle tc = (TileCandle)world.getTileEntity(x, y, z);
TileCandle tc = (TileCandle) world.getTileEntity(x, y, z);
int newMeta = isLit(meta) ? 1 : 0;
ItemStack stack = new ItemStack(this, 1, newMeta);
if (tc != null && tc.getColour() != 0xffffff) {
@@ -251,7 +244,7 @@ public class BlockCandle extends BlockTorch {
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
TileCandle tc = (TileCandle)(world.getTileEntity(x, y, z));
TileCandle tc = (TileCandle) (world.getTileEntity(x, y, z));
tc.setColour(this.getColourValueFromItemStack(itemStack));
if (isLit(itemStack)) {
int meta = world.getBlockMetadata(x, y, z);
@@ -277,8 +270,7 @@ public class BlockCandle extends BlockTorch {
world.setBlockToAir(x, y, z);
}
return false;
}
else {
} else {
return true;
}
}
@@ -294,28 +286,19 @@ public class BlockCandle extends BlockTorch {
double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
if (l == 1)
{
if (l == 1) {
world.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (l == 2)
{
} else if (l == 2) {
world.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (l == 3)
{
} else if (l == 3) {
world.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
}
else if (l == 4)
{
} else if (l == 4) {
world.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
}
else
{
} else {
world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
@@ -323,64 +306,48 @@ public class BlockCandle extends BlockTorch {
}
@Override
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block)
{
if (this.func_150109_e(par1World, par2, par3, par4))
{
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block) {
if (this.func_150109_e(par1World, par2, par3, par4)) {
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 0x07;
boolean flag = false;
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1)
{
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1) {
flag = true;
}
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2)
{
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2) {
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3)
{
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3) {
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4)
{
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4) {
flag = true;
}
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5)
{
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) {
flag = true;
}
if (flag)
{
if (flag) {
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(par2, par3, par4);
return true;
}
else
{
} else {
return false;
}
}
else
{
} else {
return true;
}
}
// Yes, function hiding. Go away.
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
{
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4))
{
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4) {
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4)) {
return true;
}
else
{
} else {
Block block = par1World.getBlock(par2, par3, par4);
return block.canPlaceTorchOnTop(par1World, par2, par3, par4);
}
@@ -410,7 +377,9 @@ public class BlockCandle extends BlockTorch {
}
public void addItemToLightingList(Item item) {
if (item == null) throw new NullPointerException();
if (item == null) {
throw new NullPointerException();
}
if (!this.lightingItems.contains(item)) {
this.lightingItems.add(item);
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -48,7 +48,7 @@ public class BlockStump extends BlockTorch {
this.blockIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanBlockName(this));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
@@ -60,8 +60,8 @@ public class BlockStump extends BlockTorch {
ItemStack held = player.getCurrentEquippedItem();
if (held != null &&
(held.getItem() == Items.flint_and_steel ||
held.getItem() == Items.flint ||
StackUtils.equals(Blocks.torch, held))) {
held.getItem() == Items.flint ||
StackUtils.equals(Blocks.torch, held))) {
world.setBlock(x, y, z, ForestryBlock.candle.block(), world.getBlockMetadata(x, y, z) | 0x08, Defaults.FLAG_BLOCK_SYNCH);
TileCandle tc = new TileCandle();
tc.setColour(0); // default to white
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -23,7 +23,7 @@ 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;
public class StructureLogicAlveary extends StructureLogic {
@@ -34,19 +34,18 @@ public class StructureLogicAlveary extends StructureLogic {
"FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-2, -3, -2);
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.block() != null)
slabBlocks.add(ForestryBlock.slabs4.block());
slabBlocks.add(ForestryBlock.slabs4.block());
}
public StructureLogicAlveary(ITileStructure structure) {
super(UID_ALVEARY, structure);
schematas = new Schemata[] { SCHEMATA_ALVEARY };
schematas = new Schemata[]{SCHEMATA_ALVEARY};
metaOnValid.put(EnumStructureBlock.BLOCK_B, 1);
}
@@ -61,57 +60,69 @@ public class StructureLogicAlveary extends StructureLogic {
offsetZ = schemata.getxOffset();
}
for (int i = 0; i < dimensions.x; i++)
for (int j = 0; j < schemata.getHeight(); j++)
for (int i = 0; i < dimensions.x; i++) {
for (int j = 0; j < schemata.getHeight(); j++) {
for (int k = 0; k < dimensions.z; k++) {
int x = structureTile.xCoord + i + offsetX;
int y = structureTile.yCoord + j + schemata.getyOffset();
int z = structureTile.zCoord + k + offsetZ;
if (!structureTile.getWorldObj().blockExists(x, y, z))
if (!structureTile.getWorldObj().blockExists(x, y, z)) {
return EnumStructureState.INDETERMINATE;
}
EnumStructureBlock required = schemata.getAt(i, j, k, rotate);
if (required == EnumStructureBlock.ANY)
if (required == EnumStructureBlock.ANY) {
continue;
}
TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z);
Block block = structureTile.getWorldObj().getBlock(x, y, z);
switch (required) {
case AIR:
if (!block.isAir(structureTile.getWorldObj(), x, y, z))
return EnumStructureState.INVALID;
break;
case BLOCK_A:
if (tile == null || !(tile instanceof IAlvearyComponent))
return EnumStructureState.INVALID;
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY))
return EnumStructureState.INVALID;
break;
case MASTER:
case BLOCK_B:
if (tile == null || !(tile instanceof TileAlvearyPlain))
return EnumStructureState.INVALID;
break;
case BLOCK_C:
if (!slabBlocks.contains(block))
return EnumStructureState.INVALID;
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0)
return EnumStructureState.INVALID;
break;
case BLOCK_D:
if (block != Blocks.spruce_stairs)
return EnumStructureState.INVALID;
break;
case FOREIGN:
if (tile instanceof ITileStructure)
return EnumStructureState.INVALID;
break;
default:
return EnumStructureState.INDETERMINATE;
case AIR:
if (!block.isAir(structureTile.getWorldObj(), x, y, z)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_A:
if (tile == null || !(tile instanceof IAlvearyComponent)) {
return EnumStructureState.INVALID;
}
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY)) {
return EnumStructureState.INVALID;
}
break;
case MASTER:
case BLOCK_B:
if (tile == null || !(tile instanceof TileAlvearyPlain)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_C:
if (!slabBlocks.contains(block)) {
return EnumStructureState.INVALID;
}
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_D:
if (block != Blocks.spruce_stairs) {
return EnumStructureState.INVALID;
}
break;
case FOREIGN:
if (tile instanceof ITileStructure) {
return EnumStructureState.INVALID;
}
break;
default:
return EnumStructureState.INDETERMINATE;
}
}
}
}
return EnumStructureState.VALID;
}
@@ -4,14 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.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;
@@ -21,18 +29,12 @@ 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.network.PacketPayload;
import forestry.core.proxy.Proxies;
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 net.minecraftforge.common.util.ForgeDirection;
import java.util.Collection;
import java.util.LinkedList;
import buildcraft.api.statements.ITriggerExternal;
public abstract class TileAlveary extends TileForestry implements IAlvearyComponent {
@@ -40,8 +42,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
private boolean isMaster;
protected int masterX, masterZ;
protected int masterY = -99;
protected TileInventoryAdapter inventory;
protected final int componentBlockMeta;
public TileAlveary(int componentBlockMeta) {
@@ -62,17 +62,15 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
@Override
public void updateEntity() {
if (!Proxies.common.isSimulating(worldObj))
updateClientSide();
else {
if (!isInited) {
initialize();
isInited = true;
}
super.updateEntity();
if (!Proxies.common.isSimulating(worldObj)) {
updateClientSide();
} else {
// Periodic validation if needed
if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster()))
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
validateStructure();
}
updateServerSide();
}
@@ -92,16 +90,17 @@ 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");
this.masterZ = nbttagcompound.getInteger("MasterZ");
// Init for master state
if (isMaster)
if (isMaster) {
makeMaster();
}
super.readFromNBT(nbttagcompound);
structureLogic.readFromNBT(nbttagcompound);
}
@@ -122,16 +121,27 @@ 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 */
@Override
public String getTypeUID() {
return structureLogic.getTypeUID();
@@ -147,15 +157,17 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
setCentralTE(null);
isMaster = true;
if (inventory == null)
if (getInternalInventory() instanceof FakeInventoryAdapter) {
createInventory();
}
}
@Override
public void onStructureReset() {
setCentralTE(null);
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1)
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 0);
}
isMaster = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@@ -163,21 +175,25 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
@Override
public ITileStructure getCentralTE() {
if (!isIntegratedIntoStructure())
if (!isIntegratedIntoStructure()) {
return null;
}
if (!isMaster()) {
TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ);
if (tile instanceof ITileStructure) {
ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ);
if (master.isMaster())
if (master.isMaster()) {
return master;
else
} else {
return null;
} else
}
} else {
return null;
} else
}
} else {
return this;
}
}
@@ -214,8 +230,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 */
@@ -258,9 +279,4 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
return res;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return Utils.isUseableByPlayer(player, this, worldObj, xCoord, yCoord, zCoord);
}
}
@@ -4,19 +4,21 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cofh.api.energy.IEnergyHandler;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.core.network.PacketPayload;
import forestry.energy.EnergyManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyHandler;
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
@@ -32,6 +34,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.boundaryUp = boundaryUp;
}
}
protected final EnergyManager energyManager;
private final ClimateControl climateControl;
private int workingTime = 0;
@@ -47,17 +50,14 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.textureOn = textureOn;
}
@Override
public void openGui(EntityPlayer player) {
}
/* UPDATING */
@Override
protected void updateServerSide() {
super.updateServerSide();
if (!this.hasMaster())
if (!this.hasMaster()) {
return;
}
boolean wasInactive = (workingTime == 0);
@@ -69,8 +69,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
if (workingTime > 0) {
workingTime--;
IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
if (component != null)
if (component != null) {
component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp);
}
}
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
@@ -86,10 +87,11 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if (workingTime > 0)
if (workingTime > 0) {
return textureOn;
else
} else {
return textureOff;
}
}
/* LOADING & SAVING */
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -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,10 +55,11 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
}
public static final short SLOT_INPUT = 0;
private final HygroregulatorRecipe[] recipes;
/* MEMBERS */
private final InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv");
private final TankManager tankManager;
private final FilteredTank liquidTank;
@@ -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),
recipes = new HygroregulatorRecipe[]{new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f) };
new HygroregulatorRecipe(new FluidStack(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;
}
@@ -124,23 +131,20 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
component.addHumidityChange(currentRecipe.humidChange, 0.0f, 1.0f);
component.addTemperatureChange(currentRecipe.tempChange, 0.0f, 2.0f);
}
} else
} else {
transferTime = 0;
}
}
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
if (!updateOnInterval(20)) {
return;
}
IInventoryAdapter canInventory = getInternalInventory();
// 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)) {
canInventory.setInventorySlotContents(0, StackUtils.replenishByContainer(this, canInventory.getStackInSlot(0), container, liquidTank));
if (canInventory.getStackInSlot(0).stackSize <= 0)
canInventory.setInventorySlotContents(0, null);
}
FluidHelper.drainContainers(tankManager, canInventory, 0);
}
}
@@ -154,9 +158,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 +171,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);
@@ -190,101 +188,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
return BlockAlveary.ALVEARY_HYGRO;
}
@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);
}
/* ILIQUIDTANKCONTAINER */
@Override
public TankManager getTankManager() {
@@ -296,6 +199,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 +225,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) {
}
}
@@ -4,41 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import 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.BiomeHelper;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpecialInventory;
import forestry.api.core.ITileStructure;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.gui.ContainerAlveary;
import forestry.core.config.Config;
import forestry.core.config.ForestryItem;
import forestry.core.interfaces.IClimatised;
import forestry.core.interfaces.IErrorSource;
import forestry.core.interfaces.IHintSource;
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;
import java.util.LinkedHashSet;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
@@ -47,12 +21,39 @@ 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 java.util.LinkedHashSet;
import java.util.Set;
import com.mojang.authlib.GameProfile;
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, ISpecialInventory, IBeeHousing, IClimatised, IHintSource {
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.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.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.Utils;
import forestry.plugins.PluginApiculture;
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource {
// / CONSTANTS
public static final int SLOT_QUEEN = 0;
@@ -75,10 +76,11 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public void openGui(EntityPlayer player) {
if (isMaster())
if (isMaster()) {
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
else if (this.hasMaster())
} else if (this.hasMaster()) {
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ);
}
}
@Override
@@ -100,10 +102,9 @@ 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)
if (beekeepingLogic != null) {
beekeepingLogic.readFromNBT(nbttagcompound);
}
}
@@ -114,10 +115,9 @@ 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)
if (beekeepingLogic != null) {
beekeepingLogic.writeToNBT(nbttagcompound);
}
}
@@ -131,10 +131,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
protected void updateServerSide() {
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
return;
if (!isMaster())
}
if (!isMaster()) {
return;
}
beekeepingLogic.update();
@@ -143,16 +145,23 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
equalizeHumidity();
IBee queen = beekeepingLogic.getQueen();
if (queen == null)
if (queen == null) {
return;
}
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
if (getErrorState() == EnumErrorCode.OK)
queen.doFX(beekeepingLogic.getEffectData(), this);
if (updateOnInterval(200)) {
ISidedInventory inventory = getStructureInventory();
if (inventory != null) {
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
}
}
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
if (getErrorState() == EnumErrorCode.OK) {
queen.doFX(beekeepingLogic.getEffectData(), this);
}
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(50)) {
float f = xCoord + 0.5F;
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
float f2 = zCoord + 0.5F;
@@ -170,90 +179,113 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
protected void updateClientSide() {
if (!isMaster())
if (!isMaster()) {
return;
}
if (inventory == null)
ISidedInventory inventory = getStructureInventory();
if (inventory == null) {
return;
}
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
if (PluginApiculture.beeInterface.isMated(queenStack)) {
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack);
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
}
}
}
private void equalizeTemperature() {
if (tempChange == 0)
if (tempChange == 0) {
return;
}
tempChange -= 0.05f * tempChange;
if (tempChange <= 0.001f && tempChange >= -0.001f)
if (tempChange <= 0.001f && tempChange >= -0.001f) {
tempChange = 0;
}
}
private void equalizeHumidity() {
if (humidChange == 0)
if (humidChange == 0) {
return;
}
humidChange -= 0.05f * humidChange;
if (humidChange <= 0.001f && humidChange >= 0.001f)
if (humidChange <= 0.001f && humidChange >= 0.001f) {
humidChange = 0;
}
}
/* STATE INFORMATION */
private int getHealthDisplay() {
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealth;
else
} else {
return 0;
}
}
private int getMaxHealthDisplay() {
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealthMax;
else
} else {
return 0;
}
}
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0)
if (getMaxHealthDisplay() == 0) {
return 0;
}
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
public void makeMaster() {
super.makeMaster();
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
this.beekeepingLogic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
}
}
@Override
@@ -347,8 +379,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public EnumTemperature getTemperature() {
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0)
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0) {
return EnumTemperature.HELLISH;
}
return EnumTemperature.getFromValue(getExactTemperature());
}
@@ -424,7 +457,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public int getErrorOrdinal() {
return getErrorState().ordinal();
return getErrorState().getID();
}
@Override
@@ -434,10 +467,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public boolean addProduct(ItemStack product, boolean all) {
if (inventory == null)
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
@@ -449,8 +484,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public void onQueenChange(ItemStack queenStack) {
if (!Proxies.common.isSimulating(worldObj))
if (!Proxies.common.isSimulating(worldObj)) {
return;
}
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
@@ -478,8 +514,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
for (IBeeListener eventHandler : eventHandlers) {
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled))
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled)) {
isHandled = true;
}
}
return isHandled;
@@ -488,8 +525,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public boolean onEggLaid(IBee queen) {
for (IBeeListener eventHandler : eventHandlers) {
if (eventHandler.onEggLaid(queen))
if (eventHandler.onEggLaid(queen)) {
return true;
}
}
return false;
@@ -498,8 +536,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public boolean isSealed() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSealed())
if (modifier.isSealed()) {
return true;
}
}
return false;
}
@@ -507,8 +546,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public boolean isSelfLighted() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSelfLighted())
if (modifier.isSelfLighted()) {
return true;
}
}
return false;
}
@@ -516,8 +556,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public boolean isSunlightSimulated() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSunlightSimulated())
if (modifier.isSunlightSimulated()) {
return true;
}
}
return false;
}
@@ -525,246 +566,26 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
@Override
public boolean isHellish() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isHellish())
if (modifier.isHellish()) {
return true;
}
}
return false;
}
/* 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();
}
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;
if (central instanceof TileAlveary) {
return ((TileAlveary) central).getInternalInventory();
}
}
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 */
@@ -791,8 +612,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
}
public void sendGUINetworkData(ContainerAlveary container, ICrafting iCrafting) {
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
return;
}
iCrafting.sendProgressBarUpdate(container, 0, beekeepingLogic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, beekeepingLogic.getTotalBreedingTime());
@@ -803,11 +625,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
/* IERRORSOURCE */
@Override
public EnumErrorCode getErrorState() {
public IErrorState getErrorState() {
if (hasMaster()) {
ITileStructure tile = this.getCentralTE();
if (tile != null)
if (tile != null) {
return ((IErrorSource) tile).getErrorState();
}
}
return errorState;
@@ -845,7 +668,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
public boolean isOwnable() {
return true;
}
/* IHousing */
@Override
public GameProfile getOwnerName() {
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -12,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,13 @@ 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.proxy.Proxies;
import forestry.core.utils.StackUtils;
public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener {
@@ -33,11 +36,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;
private final 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 +52,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;
@@ -56,80 +62,72 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public void initialize() {
super.initialize();
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
}
@Override
protected void updateServerSide() {
super.updateServerSide();
if(worldObj.getTotalWorldTime() % 200 != 0)
if (!updateOnInterval(200)) {
return;
}
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
}
/* 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);
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
}
/* TEXTURES & INTERNAL */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.SIEVE;
}
private void destroySieve() {
IInventoryAdapter inventory = getInternalInventory();
inventory.setInventorySlotContents(SLOT_SIEVE, null);
}
private void destroyPollen() {
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
IInventoryAdapter inventory = getInternalInventory();
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
inventory.setInventorySlotContents(i, null);
}
}
private boolean canStorePollen() {
if(inventory.getStackInSlot(SLOT_SIEVE) == null)
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_SIEVE) == null) {
return false;
}
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if(inventory.getStackInSlot(i) == null)
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if (inventory.getStackInSlot(i) == null) {
return true;
}
}
return false;
}
private void storePollenStack(ItemStack itemstack) {
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if(inventory.getStackInSlot(i) == null) {
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);
return;
}
}
}
/* INVENTORY */
public InventoryAdapter getInternalInventory() {
return inventory;
}
/* ICRAFTER */
@Override
@@ -138,8 +136,9 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
}
@Override
public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) {
if(slotIndex == SLOT_SIEVE) {
public ItemStack takenFromSlot(int slotIndex, EntityPlayer player) {
IInventoryAdapter inventory = getInternalInventory();
if (slotIndex == SLOT_SIEVE) {
destroyPollen();
return inventory.getStackInSlot(SLOT_SIEVE);
} else {
@@ -154,18 +153,31 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
}
/* IBEELISTENER */
@Override public void onQueenChange(ItemStack queen) {}
@Override public void wearOutEquipment(int amount) {}
@Override public void onQueenDeath(IBee queen) {}
@Override public void onPostQueenDeath(IBee queen) {}
@Override
public void onQueenChange(ItemStack queen) {
}
@Override
public void wearOutEquipment(int amount) {
}
@Override
public void onQueenDeath(IBee queen) {
}
@Override
public void onPostQueenDeath(IBee queen) {
}
@Override
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
if(isHandled)
return isHandled;
if(!canStorePollen())
if (isHandled) {
return true;
}
if (!canStorePollen()) {
return false;
}
storePollenStack(AlleleManager.alleleRegistry.getSpeciesRoot(pollen.getClass()).getMemberStack(pollen, EnumGermlingType.POLLEN.ordinal()));
return true;
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -13,6 +13,7 @@ package forestry.apiculture.gadgets;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeModifier;
import forestry.core.proxy.Proxies;
public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
@@ -27,23 +28,26 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
public void initialize() {
super.initialize();
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
}
@Override
protected void updateServerSide() {
super.updateServerSide();
if(worldObj.getTotalWorldTime() % 200 != 0)
if (!updateOnInterval(200)) {
return;
}
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
}
@@ -53,9 +57,11 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
}
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.STABILISER;
}
@@ -4,55 +4,54 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.Map.Entry;
import java.util.Stack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.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.Hive;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveSwarmer;
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.network.PacketPayload;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
import forestry.core.utils.TileInventoryAdapter;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.Map.Entry;
import java.util.Stack;
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
@@ -67,26 +66,31 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
if (pendingSpawns.size() > 0) {
setIsActive(true);
if (worldObj.getTotalWorldTime() % 1000 == 0)
if (updateOnInterval(1000)) {
trySpawnSwarm();
}
} else {
setIsActive(false);
}
if (worldObj.getTotalWorldTime() % 500 != 0)
if (!updateOnInterval(500)) {
return;
}
ItemStack princessStack = getPrincessStack();
if (princessStack == null)
if (princessStack == null) {
return;
}
int chance = consumeInducerAndGetChance();
if (chance == 0)
if (chance == 0) {
return;
}
// Try to spawn princess
if (worldObj.rand.nextInt(1000) >= chance)
if (worldObj.rand.nextInt(1000) >= chance) {
return;
}
// Queue swarm spawn
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
@@ -95,30 +99,34 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
}
private ItemStack getPrincessStack() {
if (!this.hasMaster())
if (!this.hasMaster()) {
return null;
}
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
if (!(master instanceof IBeeHousing))
if (!(master instanceof IBeeHousing)) {
return null;
}
IBeeHousing housing = (IBeeHousing) master;
ItemStack princessStack = housing.getQueen();
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack))
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) {
return null;
}
return princessStack;
}
private int consumeInducerAndGetChance() {
if (swarmerInventory == null)
if (getInternalInventory() == null) {
return 0;
}
for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) {
ItemStack stack = swarmerInventory.getStackInSlot(i);
for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) {
ItemStack stack = slot.getStackInSlot();
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
if (StackUtils.isIdenticalItem(entry.getKey(), stack)) {
swarmerInventory.decrStackSize(i, 1);
slot.decreaseStackInSlot();
return entry.getValue();
}
}
@@ -130,7 +138,8 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
private void trySpawnSwarm() {
ItemStack toSpawn = pendingSpawns.peek();
HiveSwarmer hive = new HiveSwarmer(128, toSpawn);
HiveDescriptionSwarmer hiveDescription = new HiveDescriptionSwarmer(toSpawn);
Hive hive = new Hive(hiveDescription);
int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
@@ -150,9 +159,9 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
/* NETWORK */
@Override
public void fromPacketPayload(PacketPayload payload) {
boolean isActive = payload.shortPayload[0] > 0;
if (this.isActive != isActive) {
this.isActive = isActive;
boolean act = payload.shortPayload[0] > 0;
if (this.isActive != act) {
this.isActive = act;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
@@ -172,22 +181,21 @@ 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 (isActive)
if (isActive) {
return BlockAlveary.ALVEARY_SWARMER_ON;
else
} else {
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++) {
@@ -200,126 +208,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);
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,35 +4,37 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.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.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.Collection;
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
@@ -43,85 +45,106 @@ 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)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getTerritoryModifier(genome, mod);
}
}
return mod;
}
@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)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getProductionModifier(genome, mod);
}
}
return mod;
}
@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)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getMutationModifier(genome, mate, mod);
}
}
return mod;
}
@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)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getLifespanModifier(genome, mate, mod);
}
}
return mod;
}
@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)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getFloweringModifier(genome, mod);
}
}
return mod;
}
@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)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getGeneticDecay(genome, mod);
}
}
return mod;
}
@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++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame))
}
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)) {
continue;
}
inventory.setInventorySlotContents(
i,
@@ -130,128 +153,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) {
@@ -4,34 +4,12 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import 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.core.EnumErrorCode;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Config;
import forestry.core.config.ForestryItem;
import forestry.core.gadgets.TileBase;
import forestry.core.interfaces.IClimatised;
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.Utils;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -40,22 +18,69 @@ 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;
import forestry.api.genetics.IIndividual;
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.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;
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 final InventoryAdapter inventory = new InventoryAdapter(12, "Items");
private final IBeekeepingLogic logic;
private BiomeGenBase biome;
private int displayHealthMax = 0;
@@ -64,6 +89,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public TileBeehouse() {
setHints(Config.hints.get("apiary"));
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items").disableAutomation());
}
@Override
@@ -77,10 +103,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
super.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("BiomeId", biome.biomeID);
inventory.writeToNBT(nbttagcompound);
if (logic != null)
if (logic != null) {
logic.writeToNBT(nbttagcompound);
}
}
@Override
@@ -89,8 +114,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
int biomeId = nbttagcompound.getInteger("BiomeId");
biome = BiomeGenBase.getBiome(biomeId);
inventory.readFromNBT(nbttagcompound);
logic.readFromNBT(nbttagcompound);
}
@@ -114,7 +137,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public EnumTemperature getTemperature() {
return EnumTemperature.getFromValue(getExactTemperature());
return EnumTemperature.getFromBiome(biome);
}
@Override
@@ -137,9 +160,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public void updateClientSide() {
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) {
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
displayQueen.doFX(logic.getEffectData(), this);
}
}
@@ -152,29 +175,14 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
logic.update();
IBee queen = logic.getQueen();
if (queen == null)
if (queen == null) {
return;
}
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
/* These should get already done on the client / doesn't work server-side anyway
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0)
queen.doFX(logic.getEffectData(), this);
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
float f = xCoord + 0.5F;
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
float f2 = zCoord + 0.5F;
float f3 = 0.52F;
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
}*/
if (updateOnInterval(200)) {
onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN));
}
}
// @Override
@@ -184,14 +192,15 @@ 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 */
@Override
public void onQueenChange(ItemStack queenStack) {
if (!Proxies.common.isSimulating(worldObj))
if (!Proxies.common.isSimulating(worldObj)) {
return;
}
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
@@ -200,38 +209,42 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* STATE INFORMATION */
private int getHealthDisplay() {
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealth;
else
} else {
return 0;
}
}
private int getMaxHealthDisplay() {
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealthMax;
else
} else {
return 0;
}
}
/**
* Returns scaled queen health or breeding progress
*
* @param i
* @return
*/
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0)
if (getMaxHealthDisplay() == 0) {
return 0;
}
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
@@ -257,42 +270,30 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* SMP */
// @Override
public void getGUINetworkData(int i, int j) {
if (logic == null)
if (logic == null) {
return;
}
switch (i) {
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
}
}
// @Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
if (logic == null)
if (logic == null) {
return;
}
iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
}
/* 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() {
@@ -331,12 +332,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
@@ -351,7 +352,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public int getErrorOrdinal() {
return getErrorState().ordinal();
return getErrorState().getID();
}
@Override
@@ -430,7 +431,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public boolean onEggLaid(IBee queen) {
return false;
}
/* IHousing */
@Override
public GameProfile getOwnerName() {
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
+26 -7
View File
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -13,8 +13,10 @@ package forestry.apiculture.gadgets;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.EnumSkyBlock;
import forestry.core.utils.InventoryAdapter;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.InventoryAdapter;
public class TileSwarm extends TileEntity {
@@ -22,20 +24,37 @@ public class TileSwarm extends TileEntity {
@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);
for (ItemStack itemstack : bees) {
InvTools.addStack(contained, itemstack, true);
}
return this;
}
public boolean containsBees() {
for (int i = 0; i < contained.getSizeInventory(); i++)
if (contained.getStackInSlot(i) != null)
for (int i = 0; i < contained.getSizeInventory(); i++) {
if (contained.getStackInSlot(i) != null) {
return true;
}
}
return false;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -46,20 +46,24 @@ public class AIAvoidPlayers extends EntityAIBase {
player = mob.worldObj.getClosestPlayerToEntity(mob, minDistance);
if (player == null)
if (player == null) {
return false;
}
if (!mob.getEntitySenses().canSee(player))
if (!mob.getEntitySenses().canSee(player)) {
return false;
}
Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7,
Vec3.createVectorHelper(player.posX, player.posY, player.posZ));
if (randomTarget == null)
if (randomTarget == null) {
return false;
}
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob))
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob)) {
return false;
}
pathing = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
return pathing != null && pathing.isDestinationSame(randomTarget);
@@ -82,9 +86,10 @@ public class AIAvoidPlayers extends EntityAIBase {
@Override
public void updateTask() {
if (mob.getDistanceSqToEntity(player) < 49.0D)
if (mob.getDistanceSqToEntity(player) < 49.0D) {
mob.getNavigator().setSpeed(nearSpeed);
else
} else {
mob.getNavigator().setSpeed(farSpeed);
}
}
}
@@ -4,15 +4,27 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import 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;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -29,15 +41,6 @@ import forestry.core.config.Defaults;
import forestry.core.genetics.AlleleSpecies;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies, IIconProvider {
@@ -52,7 +55,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);
@@ -66,7 +69,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
IJubilanceProvider jubilanceProvider) {
super(uid, dominant, name, branch, binomial);
this.root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
this.root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
this.primaryColour = primaryColor;
this.secondaryColour = secondaryColor;
this.jubilanceProvider = jubilanceProvider;
@@ -84,8 +87,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
}
public AlleleBeeSpecies addProduct(ItemStack product, int chance) {
if (product == null || product.getItem() == null)
if (product == null || product.getItem() == null) {
throw new IllegalArgumentException("Tried to add null product");
}
this.products.put(product, chance);
return this;
}
@@ -112,16 +116,18 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
int highest = 0;
exclude.add(species);
for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES.ordinal())) {
if(!exclude.contains(mutation.getAllele0())) {
for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) {
if (!exclude.contains(mutation.getAllele0())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude);
if(otherAdvance > highest)
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
if(!exclude.contains(mutation.getAllele1())) {
if (!exclude.contains(mutation.getAllele1())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude);
if(otherAdvance > highest)
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
}
@@ -130,15 +136,20 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public float getResearchSuitability(ItemStack itemstack) {
if(itemstack == null)
if (itemstack == null) {
return 0f;
}
for(ItemStack stack : products.keySet())
if(stack.isItemEqual(itemstack))
for (ItemStack stack : products.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
for(ItemStack stack : specialty.keySet())
if(stack.isItemEqual(itemstack))
}
}
for (ItemStack stack : specialty.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
}
return super.getResearchSuitability(itemstack);
}
@@ -148,13 +159,13 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
ArrayList<ItemStack> bounty = new ArrayList<ItemStack>();
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
if(bountyLevel > 10) {
for(ItemStack stack : specialty.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
if (bountyLevel > 10) {
for (ItemStack stack : specialty.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
}
for(ItemStack stack : products.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
for (ItemStack stack : products.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
return bounty.toArray(new ItemStack[bounty.size()]);
}
@@ -187,10 +198,12 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public int getIconColour(int renderPass) {
if (renderPass == 0)
if (renderPass == 0) {
return primaryColour;
if (renderPass == 1)
}
if (renderPass == 1) {
return secondaryColour;
}
return 0xffffff;
}
@@ -205,8 +218,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
if(EnumBeeType.values()[i] == EnumBeeType.NONE)
if (EnumBeeType.values()[i] == EnumBeeType.NONE) {
continue;
}
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -34,8 +34,9 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -51,14 +52,15 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
}
entity.attackEntityFrom(damageSourceBeeAggressive, damage);
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -24,8 +24,8 @@ import forestry.core.genetics.EffectData;
public class AlleleEffectCreeper extends AlleleEffectThrottled {
private final int explosionChance = 50;
private final byte defaultForce = 12;
private static final int explosionChance = 50;
private static final byte defaultForce = 12;
private final byte indexExplosionTimer = 1;
private final byte indexExplosionForce = 2;
@@ -35,11 +35,13 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (!(storedData instanceof EffectData))
if (!(storedData instanceof EffectData)) {
return new EffectData(3, 0);
}
if (((EffectData) storedData).getIntSize() < 3)
if (((EffectData) storedData).getIntSize() < 3) {
return new EffectData(3, 0);
}
return storedData;
}
@@ -49,8 +51,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
// If we are already triggered, we continue the explosion sequence.
if (storedData.getInteger(indexExplosionTimer) > 0) {
@@ -74,9 +77,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2) {
} else if (count > 2) {
chance = 5;
storedData.setInteger(indexExplosionForce, 6);
} else if (count > 1) {
@@ -87,8 +90,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
storedData.setInteger(indexExplosionForce, 10);
}
if (world.rand.nextInt(1000) >= chance)
if (world.rand.nextInt(1000) >= chance) {
continue;
}
world.playSoundEffect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), "mob.creeper", 4F,
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
@@ -105,8 +109,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
explosionTimer--;
storedData.setInteger(indexExplosionTimer, explosionTimer);
if (explosionTimer > 0)
if (explosionTimer > 0) {
return;
}
world.createExplosion(null, x, y, z, storedData.getInteger(indexExplosionForce), false);
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -28,8 +28,9 @@ public class AlleleEffectExploration extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -0,0 +1,61 @@
package forestry.apiculture.genetics;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
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,129 @@
package forestry.apiculture.genetics;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
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;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
public class AlleleEffectFungification extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 10;
public static final int ENTITY_THROTTLE = 6;
public AlleleEffectFungification(String uid) {
super(uid, "mycophilic", true, 10, false, false);
}
@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();
List entities = world.getEntitiesWithinAABB(EntityCow.class, aabb);
for (Object 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);
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -20,7 +20,7 @@ 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;
public class AlleleEffectGlacial extends AlleleEffectThrottled {
@@ -33,17 +33,18 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
switch (temp) {
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
}
int[] areaAr = genome.getTerritory();
@@ -59,11 +60,13 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
// Freeze water
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block != Blocks.water)
if (block != Blocks.water) {
continue;
}
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z))
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) {
continue;
}
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.ice);
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -29,8 +29,9 @@ public class AlleleEffectHeroic extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -25,8 +25,8 @@ import forestry.plugins.PluginApiculture;
public class AlleleEffectIgnition extends AlleleEffectThrottled {
private final int ignitionChance = 50;
private final 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);
@@ -37,8 +37,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -55,9 +56,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2) {
} else if (count > 2) {
chance = 5;
duration = 50;
} else if (count > 1) {
@@ -69,8 +70,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
}
}
if (world.rand.nextInt(1000) >= chance)
if (world.rand.nextInt(1000) >= chance) {
continue;
}
entity.setFire(duration);
}
@@ -83,12 +85,13 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
int[] area = getModifiedArea(genome, housing);
if (housing.getWorld().rand.nextBoolean())
if (housing.getWorld().rand.nextBoolean()) {
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
else
} else {
PluginApiculture.proxy.addBeeHiveFX("particles/ember", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
}
return storedData;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -26,7 +26,7 @@ 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);
@@ -37,8 +37,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB infectionBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -46,8 +47,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
for (Object obj : list) {
if (world.rand.nextInt(1000) >= infectionChance)
if (world.rand.nextInt(1000) >= infectionChance) {
continue;
}
EntityPlayer player = (EntityPlayer) obj;
@@ -57,14 +59,15 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
duration = 200;
else if (count > 1)
} else if (count > 1) {
duration = 400;
else if (count > 0)
} else if (count > 0) {
duration = 600;
}
player.addPotionEffect(new PotionEffect(Potion.poison.id, duration, 0));
}
@@ -77,12 +80,13 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
int[] area = getModifiedArea(genome, housing);
if (housing.getWorld().rand.nextBoolean())
if (housing.getWorld().rand.nextBoolean()) {
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
else
} else {
PluginApiculture.proxy.addBeeHiveFX("particles/poison", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
}
return storedData;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -33,8 +33,9 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -49,14 +50,15 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
player.attackEntityFrom(damageSourceBeeEnd, damage);
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -57,12 +57,15 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
area[1] *= housing.getTerritoryModifier(genome, 1f);
area[2] *= housing.getTerritoryModifier(genome, 1f);
if (area[0] < 1)
if (area[0] < 1) {
area[0] = 1;
if (area[1] < 1)
}
if (area[1] < 1) {
area[1] = 1;
if (area[2] < 1)
}
if (area[2] < 1) {
area[2] = 1;
}
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -17,37 +17,73 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.relauncher.ReflectionHelper;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.proxy.Proxies;
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;
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
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;
}
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -28,7 +28,7 @@ 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;
import forestry.core.vect.Vect;
public class AlleleEffectRadioactive extends AlleleEffectThrottled {
@@ -43,8 +43,9 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0] * 2, areaAr[1] * 2, areaAr[2] * 2);
@@ -69,14 +70,15 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
}
entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
@@ -92,29 +94,36 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
posBlock = posBlock.add(offset);
if(posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight())
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
continue;
}
// Don't destroy ourself and blocks below us.
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord())
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) {
continue;
}
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
}
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block instanceof BlockAlveary)
if (block instanceof BlockAlveary) {
continue;
}
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
if (tile instanceof IBeeHousing)
if (tile instanceof IBeeHousing) {
continue;
if (tile instanceof TileAlveary)
}
if (tile instanceof TileAlveary) {
continue;
}
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0)
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
continue;
}
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
break;
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -28,11 +28,13 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
if (housing.getOwnerName() == null)
if (housing.getOwnerName() == null) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -43,8 +45,9 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
for (Object objT : mob.tasks.taskEntries) {
EntityAITaskEntry task = (EntityAITaskEntry) objT;
if (task.action instanceof AIAvoidPlayers)
if (task.action instanceof AIAvoidPlayers) {
return storedData;
}
}
mob.tasks.addTask(3, new AIAvoidPlayers(mob, 6.0f, 0.25f, 0.3f));
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -79,30 +79,35 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, bounding);
if (list.size() > 0)
if (list.size() > 0) {
Collections.shuffle(resurrectables);
}
for (Object obj : list) {
EntityItem item = (EntityItem) obj;
if (item.isDead)
if (item.isDead) {
continue;
}
ItemStack contained = item.getEntityItem();
for (Resurrectable entry : resurrectables)
for (Resurrectable entry : resurrectables) {
if (StackUtils.isIdenticalItem(entry.res, contained)) {
Utils.spawnEntity(housing.getWorld(), entry.risen, item.posX, item.posY, item.posZ);
contained.stackSize--;
if (contained.stackSize <= 0)
if (contained.stackSize <= 0) {
item.setDead();
}
break;
}
}
}
return storedData;
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -21,7 +21,7 @@ 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;
public class AlleleEffectSnowing extends AlleleEffectThrottled {
@@ -34,17 +34,18 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
switch (temp) {
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
}
int[] areaAr = genome.getTerritory();
@@ -59,11 +60,13 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
posBlock = posBlock.add(offset);
// Put snow on the ground
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false))
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) {
continue;
}
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
}
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.snow_layer);
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -16,10 +16,10 @@ import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.api.core.EnumErrorCode;
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;
public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect {
@@ -47,23 +47,26 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (storedData instanceof EffectData)
if (storedData instanceof EffectData) {
return storedData;
}
return new EffectData(1, 0);
}
public boolean isHalted(IEffectData storedData, IBeeHousing housing) {
if (requiresWorkingQueen && housing.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.
storedData.setInteger(0, 0);
@@ -86,12 +89,15 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
area[1] *= housing.getTerritoryModifier(genome, 1f) * 3;
area[2] *= housing.getTerritoryModifier(genome, 1f) * 3;
if (area[0] < 1)
if (area[0] < 1) {
area[0] = 1;
if (area[1] < 1)
}
if (area[1] < 1) {
area[1] = 1;
if (area[2] < 1)
}
if (area[2] < 1) {
area[2] = 1;
}
return area;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -15,6 +15,7 @@ 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;
@@ -23,6 +24,7 @@ import forestry.plugins.PluginApiculture;
public class ApiaristTracker extends BreedingTracker implements IApiaristTracker {
/** Required for creation from map storage */
public ApiaristTracker(String s) {
this(s, null);
}
@@ -59,12 +61,15 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
@Override
public void registerPickup(IIndividual individual) {
if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID))
if (!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) {
return;
if(!individual.isPureBred(0))
}
if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) {
return;
if(PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0)
}
if (PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0) {
return;
}
registerSpecies(individual.getGenome().getPrimary());
}
@@ -103,12 +108,12 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
}
@Override
protected IBreedingTracker getCommonTracker(EntityPlayer player) {
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, null);
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile());
}
@Override
protected String getPacketTag() {
protected String speciesRootUID() {
return BeeHelper.UID;
}
+282 -236
View File
@@ -4,12 +4,26 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.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;
@@ -20,7 +34,6 @@ import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumErrorCode;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleManager;
@@ -32,29 +45,25 @@ import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.arboriculture.genetics.FakePollinatable;
import forestry.arboriculture.genetics.ICheckPollinatable;
import forestry.core.EnumErrorCode;
import forestry.core.config.Defaults;
import forestry.core.genetics.Chromosome;
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 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,28 +72,20 @@ public class Bee extends IndividualLiving implements IBee {
readFromNBT(nbttagcompound);
}
public Bee(World world, IBeeGenome genome, IBee mate) {
this(world, genome);
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 */
@@ -98,23 +99,65 @@ public class Bee extends IndividualLiving implements IBee {
super.readFromNBT(nbttagcompound);
if (nbttagcompound.hasKey("Genome"))
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
} else {
genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
if (nbttagcompound.hasKey("Mate"))
}
if (nbttagcompound.hasKey("Mate")) {
mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate"));
}
}
@Override
public void mate(IIndividual individual) {
if(!(individual instanceof IBee))
return;
public void writeToNBT(NBTTagCompound nbttagcompound) {
IBee drone = (IBee)individual;
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)) {
return;
}
IBee drone = (IBee) individual;
mate = drone.getGenome();
this.isIrregularMating = drone.isNatural() != this.isNatural;
}
/* EFFECTS */
@@ -122,18 +165,21 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
if (effect == null)
if (effect == null) {
return null;
}
storedData[0] = doEffect(effect, storedData[0], housing);
// Return here if the primary can already not be combined
if (!effect.isCombinable())
if (!effect.isCombinable()) {
return storedData;
}
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal());
if (!secondary.isCombinable())
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable()) {
return storedData;
}
storedData[1] = doEffect(secondary, storedData[1], housing);
@@ -149,18 +195,21 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
if (effect == null)
if (effect == null) {
return null;
}
storedData[0] = doFX(effect, storedData[0], housing);
// Return here if the primary can already not be combined
if (!effect.isCombinable())
if (!effect.isCombinable()) {
return storedData;
}
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal());
if (!secondary.isCombinable())
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable()) {
return storedData;
}
storedData[1] = doFX(secondary, storedData[1], housing);
@@ -210,29 +259,36 @@ public class Bee extends IndividualLiving implements IBee {
}
// / Night or darkness requires nocturnal species
if(world.isDaytime()) {
if(!canWorkDuringDay())
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTNIGHT;
} else if (!canWorkAtNight() && !housing.isSelfLighted())
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTDAY;
}
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
if(!canWorkDuringDay())
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTGLOOMY;
} else if(!canWorkAtNight() && !housing.isSelfLighted())
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTLUCID;
}
// / No sky, except if in hell
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if(biome == null)
if (biome == null) {
return EnumErrorCode.NOSKY;
}
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
return EnumErrorCode.NOSKY;
}
// / And finally climate check
if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity()))
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
return EnumErrorCode.INVALIDBIOME;
}
return EnumErrorCode.OK;
}
@@ -245,17 +301,17 @@ public class Bee extends IndividualLiving implements IBee {
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
}
private boolean checkBiomeHazard(BiomeGenBase biome) {
public boolean isSuitableBiome(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(),
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
return isSuitableClimate(temperature, humidity);
}
private boolean checkSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
private boolean isSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
@@ -266,26 +322,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,34 +343,14 @@ 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>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
if (checkBiomeHazard(biome))
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (isSuitableBiome(biome)) {
suitableBiomes.add(biome.biomeID);
}
}
return suitableBiomes;
}
@@ -332,9 +358,11 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ArrayList<BiomeGenBase> getSuitableBiomes() {
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
if (checkBiomeHazard(biome))
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (isSuitableBiome(biome)) {
suitableBiomes.add(biome);
}
}
return suitableBiomes;
}
@@ -351,27 +379,52 @@ 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));
else
list.add(speed.getName() + " " + StringUtil.localize("gui.worker"));
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;
}
list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal()).getName() + " " + StringUtil.localize("gui.life"));
String generationString = rarity.rarityColor + StringUtil.localizeAndFormat("gui.beealyzer.generations", generation);
list.add(generationString);
}
IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName());
IAllele speedAllele = genome.getActiveAllele(EnumBeeChromosome.SPEED);
IAlleleTolerance tempToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance humidToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName());
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", "");
String speed;
if (StringUtil.canTranslate(unlocalizedCustomSpeed)) {
speed = StringUtil.localize(unlocalizedCustomSpeed);
} else {
speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker");
}
list.add(genome.getFlowerProvider().getDescription());
if (genome.getNocturnal())
list.add("\u00A7c" + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
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();
list.add(lifespan);
list.add(speed);
list.add(tempTolerance);
list.add(humidTolerance);
list.add(flowers);
if (genome.getNocturnal()) {
list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
}
}
@Override
@@ -397,14 +450,16 @@ public class Bee extends IndividualLiving implements IBee {
for (ItemStack second : secondaryProducts) {
boolean skip = false;
for (ItemStack compare : products)
for (ItemStack compare : products) {
if (second.isItemEqual(compare)) {
skip = true;
break;
}
}
if (!skip)
if (!skip) {
products.add(second);
}
}
@@ -419,8 +474,9 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ItemStack[] produceStacks(IBeeHousing housing) {
if (!hasFlower(housing))
if (!hasFlower(housing)) {
return null;
}
if (housing == null) {
Proxies.log.warning("Failed to produce in an apiary because the beehousing was null.");
@@ -438,29 +494,37 @@ public class Bee extends IndividualLiving implements IBee {
IAlleleBeeSpecies secondary = genome.getSecondary();
// All work and no play makes queen a dull girl.
if(mode.isOverworked(this, housing))
if (mode.isOverworked(this, housing)) {
setIsNatural(false);
}
// Bee genetic speed * beehousing * beekeeping mode
float speed = genome.getSpeed() * housing.getProductionModifier(genome, 1f) * mode.getProductionModifier(genome, 1f);
// / Primary Products
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet())
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
// / Secondary Products
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet())
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed)
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed) {
products.add(entry.getKey().copy());
}
}
// We are done if the we are not jubilant.
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing))
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing)) {
return products.toArray(new ItemStack[products.size()]);
}
// / Specialty products
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet())
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
products.toArray(new ItemStack[products.size()]));
@@ -471,12 +535,14 @@ public class Bee extends IndividualLiving implements IBee {
public IBee spawnPrincess(IBeeHousing housing) {
// We need a mated queen to produce offspring.
if (mate == null)
if (mate == null) {
return null;
}
// Fatigued queens do not produce princesses.
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing))
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) {
return null;
}
return createOffspring(housing, getGeneration() + 1);
}
@@ -487,29 +553,32 @@ public class Bee extends IndividualLiving implements IBee {
World world = housing.getWorld();
// We need a mated queen to produce offspring.
if (mate == null)
if (mate == null) {
return null;
}
ArrayList<IBee> bees = new ArrayList<IBee>();
int toCreate = PluginApiculture.beeInterface.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(),
housing.getZCoord());
if (toCreate <= 0)
if (toCreate <= 0) {
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);
}
}
if (bees.size() > 0)
if (bees.size() > 0) {
return bees.toArray(new IBee[bees.size()]);
else
} else {
return null;
}
}
private IBee createOffspring(IBeeHousing housing, int generation) {
@@ -523,25 +592,22 @@ public class Bee extends IndividualLiving implements IBee {
// Check for mutation. Replace one of the parents with the mutation
// template if mutation occured.
IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
if (mutated1 != null)
if (mutated1 != null) {
parent1 = mutated1;
}
IChromosome[] mutated2 = mutateSpecies(housing, mate, genome);
if (mutated2 != null)
if (mutated2 != null) {
parent2 = mutated2;
}
for (int i = 0; i < parent1.length; i++)
if (parent1[i] != null && parent2[i] != null)
for (int i = 0; i < parent1.length; i++) {
if (parent1[i] != null && parent2[i] != null) {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
}
}
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
IBee offspring = new Bee(world, new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
/* Disabling the mutation rate nerf
// All mutation and no play makes queen a dull girl.
if(mode.isDegenerating(this, offspring, housing))
offspring.setIsNatural(false);*/
return offspring;
return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
}
private IChromosome[] mutateSpecies(IBeeHousing housing, IGenome genomeOne, IGenome genomeTwo) {
@@ -571,14 +637,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;
@@ -588,58 +652,39 @@ 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();
if (tile instanceof IPollinatable) {
IPollinatable pitcher = (IPollinatable) tile;
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) {
pollen = pitcher.getPollen();
}
continue;
} 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)
if (pollen != null) {
return pollen;
}
}
return null;
@@ -650,40 +695,41 @@ 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);
if(receiver == null)
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock.x, posBlock.y, posBlock.z);
if (checkPollinatable == null) {
continue;
}
if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), receiver))
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, new FakePollinatable(checkPollinatable))) {
continue;
if (!receiver.canMateWith(pollen))
}
if (!checkPollinatable.canMateWith(pollen)) {
continue;
}
receiver.mateWith(pollen);
return true;
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
if (realPollinatable != null) {
realPollinatable.mateWith(pollen);
return true;
}
}
return false;
@@ -692,35 +738,35 @@ 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);
}
}
@@ -4,12 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -26,39 +29,37 @@ 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;
public class BeeGenome extends Genome implements IBeeGenome {
/**
* 0 - Species (determines product)
*
*
* 1 - Speed
*
*
* 2 - Lifespan
*
*
* 3 - Fertility (Maximum number of offspring)
*
*
* 4 - Preferred temperature Icy: Snow biomes Cold: Tundra/Steppe, Extreme Mountains/Hills? Normal: Plains, Forests, Mountains Hot: Desert Hellish: Nether
*
*
* 5 - Temperature tolerance (Range +/-)
*
*
* 6 - Nocturnal
*
*
* 7 - Preferred humidity (Arid - Normal - Damp)
*
*
* 8 - Humidity tolerance (Range +/-)
*
*
* 9 - Flight interference tolerance (stuff falling from the sky/other hindrances -> tolerates dampness + flight interference tolerance => rain resistance)
*
*
* 10 - Cave dwelling
*
*
* 11 - Required flowers
*
*
* 12 - Flower plant chance
*
*
* 13 - Territory
*/
/* CONSTRUCTOR */
@@ -72,83 +73,84 @@ public class BeeGenome extends Genome implements IBeeGenome {
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumBeeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleBeeSpecies)
return (IAlleleBeeSpecies)speciesAllele;
else
IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) speciesAllele;
} else {
return null;
}
}
// / 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();
return new int[] { area.x, area.y, area.z };
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
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -13,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,12 +68,12 @@ 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();
if (entry.getValue() instanceof IAlleleBeeSpecies)
if (((IAlleleBeeSpecies) entry.getValue()).isCounted())
for (Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
if (entry.getValue() instanceof IAlleleBeeSpecies) {
if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) {
beeSpeciesCount++;
}
}
}
}
@@ -98,26 +97,26 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public ItemStack getMemberStack(IIndividual bee, int type) {
if (!isMember(bee))
if (!isMember(bee)) {
return null;
}
Item beeItem = null;
Item beeItem;
switch (EnumBeeType.VALUES[type]) {
case QUEEN:
beeItem = ForestryItem.beeQueenGE.item();
break;
case PRINCESS:
beeItem = ForestryItem.beePrincessGE.item();
break;
case DRONE:
beeItem = ForestryItem.beeDroneGE.item();
break;
case LARVAE:
beeItem = ForestryItem.beeLarvaeGE.item();
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
case QUEEN:
beeItem = ForestryItem.beeQueenGE.item();
break;
case PRINCESS:
beeItem = ForestryItem.beePrincessGE.item();
break;
case DRONE:
beeItem = ForestryItem.beeDroneGE.item();
break;
case LARVAE:
beeItem = ForestryItem.beeLarvaeGE.item();
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -129,17 +128,19 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public EnumBeeType getType(ItemStack stack) {
if (stack == null)
if (stack == null) {
return EnumBeeType.NONE;
}
if (ForestryItem.beeDroneGE.isItemEqual(stack))
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
return EnumBeeType.DRONE;
else if (ForestryItem.beePrincessGE.isItemEqual(stack))
} else if (ForestryItem.beePrincessGE.isItemEqual(stack)) {
return EnumBeeType.PRINCESS;
else if (ForestryItem.beeQueenGE.isItemEqual(stack))
} else if (ForestryItem.beeQueenGE.isItemEqual(stack)) {
return EnumBeeType.QUEEN;
else if (ForestryItem.beeLarvaeGE.isItemEqual(stack))
} else if (ForestryItem.beeLarvaeGE.isItemEqual(stack)) {
return EnumBeeType.LARVAE;
}
return EnumBeeType.NONE;
}
@@ -151,8 +152,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public boolean isMated(ItemStack stack) {
if (getType(stack) != EnumBeeType.QUEEN)
if (getType(stack) != EnumBeeType.QUEEN) {
return false;
}
IBee bee = getMember(stack);
return bee.getMate() != null;
@@ -160,9 +162,9 @@ 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 +176,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 */
@@ -226,23 +228,27 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
/**
* List of possible mutations on species alleles.
*/
private static ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
@Override
public Collection<IBeeMutation> getMutations(boolean shuffle) {
if (shuffle)
if (shuffle) {
Collections.shuffle(beeMutations);
}
return beeMutations;
}
@Override
public void registerMutation(IMutation mutation) {
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID()))
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) {
return;
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID()))
}
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) {
return;
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID()))
}
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) {
return;
}
beeMutations.add((IBeeMutation) mutation);
}
@@ -263,14 +269,16 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBeekeepingMode getBeekeepingMode(World world) {
if (activeBeekeepingMode != null)
if (activeBeekeepingMode != null) {
return activeBeekeepingMode;
}
// No beekeeping mode yet, get it.
IApiaristTracker tracker = getBreedingTracker(world, null);
String mode = tracker.getModeName();
if (mode == null || mode.isEmpty())
if (mode == null || mode.isEmpty()) {
mode = PluginApiculture.beekeepingMode;
}
setBeekeepingMode(world, mode);
FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode);
@@ -292,8 +300,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBeekeepingMode getBeekeepingMode(String name) {
for (IBeekeepingMode mode : beekeepingModes) {
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH)))
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) {
return mode;
}
}
FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a beekeeping mode called '%s', reverting to fallback.");
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -40,7 +40,7 @@ public class BeeMutation extends Mutation implements IBeeMutation {
public BeeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) {
super(allele0, allele1, template, chance);
root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
PluginApiculture.beeInterface.registerMutation(this);
}
@@ -78,49 +78,58 @@ public class BeeMutation extends Mutation implements IBeeMutation {
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
World world = housing.getWorld();
if (requiresDay && !world.isDaytime())
if (requiresDay && !world.isDaytime()) {
return 0;
}
if (requiresNight && world.isDaytime())
if (requiresNight && world.isDaytime()) {
return 0;
}
// Skip if we are restricted by biomes and this one does not match.
if (restrictBiomeTypes.size() > 0) {
boolean noneMatched = true;
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if(strictBiomeCheck) {
if (strictBiomeCheck) {
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
if(types.length == 1 && restrictBiomeTypes.contains(types[0]))
if (types.length == 1 && restrictBiomeTypes.contains(types[0])) {
noneMatched = false;
}
} else {
for(BiomeDictionary.Type type : restrictBiomeTypes) {
if(BiomeDictionary.isBiomeOfType(biome, type)) {
for (BiomeDictionary.Type type : restrictBiomeTypes) {
if (BiomeDictionary.isBiomeOfType(biome, type)) {
noneMatched = false;
break;
}
}
}
if (noneMatched)
if (noneMatched) {
return 0;
}
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(housing.getXCoord(), housing.getZCoord());
if (biome.temperature < minTemperature || biome.temperature > maxTemperature)
if (biome.temperature < minTemperature || biome.temperature > maxTemperature) {
return 0;
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall)
}
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) {
return 0;
}
float processedChance = chance * housing.getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f)
* PluginApiculture.beeInterface.getBeekeepingMode(world).getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f);
if(processedChance <= 0)
if (processedChance <= 0) {
return 0;
}
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID()))
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
return processedChance;
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID()))
}
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
return processedChance;
}
return 0;
@@ -4,19 +4,19 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.Arrays;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IMutation;
import forestry.core.genetics.Allele;
import java.util.Arrays;
public class BeeTemplates {
// / MUTATIONS
@@ -293,7 +293,7 @@ public class BeeTemplates {
public static IAllele[] getAustereBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersCacti;
return alleles;
@@ -328,8 +328,8 @@ public class BeeTemplates {
// / TROPICAL BRANCH
public static IAllele[] getTropicalBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersJungle;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMiasmic;
return alleles;
@@ -401,6 +401,7 @@ public class BeeTemplates {
public static IAllele[] getFrozenBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersSnow;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectGlacial;
return alleles;
@@ -548,13 +549,30 @@ 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() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersMushrooms;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
return alleles;
}
@@ -564,6 +582,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() {
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -98,23 +98,27 @@ public class BeekeepingMode implements IBeekeepingMode {
public int getFinalFertility(IBee queen, World world, int x, int y, int z) {
int toCreate = queen.getGenome().getFertility();
if (reducesFertility)
if (reducesFertility) {
toCreate = new Random().nextInt(toCreate);
}
return toCreate;
}
@Override
public boolean isFatigued(IBee queen, IBeeHousing housing) {
if (!canFatigue)
if (!canFatigue) {
return false;
}
if (queen.isNatural())
if (queen.isNatural()) {
return false;
}
if (queen.getGeneration() > 96 + rand.nextInt(6) + rand.nextInt(6) &&
rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f))
rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f)) {
return true;
}
return false;
}
@@ -122,9 +126,10 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isOverworked(IBee queen, IBeeHousing housing) {
float productionModifier = housing.getProductionModifier(queen.getGenome(), 1f);
if(productionModifier > 16) {
if(housing.getWorld().rand.nextFloat()*100 < 0.01 * ((productionModifier*productionModifier) - 100))
if (productionModifier > 16) {
if (housing.getWorld().rand.nextFloat() * 100 < 0.01 * ((productionModifier * productionModifier) - 100)) {
return true;
}
}
return false;
@@ -133,9 +138,10 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing) {
float mutationModifier = housing.getMutationModifier(queen.getGenome(), queen.getMate(), 1.0f);
if(mutationModifier > 10) {
if(housing.getWorld().rand.nextFloat()*100 < 0.4 * ((mutationModifier*mutationModifier) - 100))
if (mutationModifier > 10) {
if (housing.getWorld().rand.nextFloat() * 100 < 0.4 * ((mutationModifier * mutationModifier) - 100)) {
return true;
}
}
return false;
@@ -143,10 +149,7 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isNaturalOffspring(IBee queen) {
if (!queen.isNatural())
return false;
return true;
return queen.isNatural();
}
@Override
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,22 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.Collections;
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 net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Collections;
public class HiveDrop implements IHiveDrop {
@@ -47,8 +48,9 @@ public class HiveDrop implements IHiveDrop {
@Override
public ItemStack getPrincess(World world, int x, int y, int z, int fortune) {
IBee bee = createBee(world);
if(world.rand.nextFloat() < ignobleShare)
if (world.rand.nextFloat() < ignobleShare) {
bee.setIsNatural(false);
}
return PluginApiculture.beeInterface.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal());
}
@@ -63,8 +65,9 @@ public class HiveDrop implements IHiveDrop {
@Override
public ArrayList<ItemStack> getAdditional(World world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
for (ItemStack stack : additional)
for (ItemStack stack : additional) {
ret.add(stack.copy());
}
return ret;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
Loaded 100 of 955 files, more files were not shown because too many files have changed in this diff. Show more