Compare commits

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

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

Sign CLA
2015-04-10 19:26:33 -07:00
Nirek-K 4be4606854 Add AgriCraft cropstick plants to Orchard 2015-04-09 21:37:59 -07:00
Nirek-K f4d671ba2a Add Water Artichoke to orchard.
Add other crops to orchard.
2015-04-09 21:36:18 -07:00
Nirek-K 38ea1061d1 Add Spinach.
Add HC crops to the Orchard Tube, diverse crop fields can be built and the farm will maintain the design.
2015-04-09 21:35:17 -07:00
Nirek-K e26fde5cc0 Plant Mega Pack Stage 4
Add Forest and Plains plant types to bee plant/acceptable and Multifarm (Crop)
Slight Refactor and Cleanup
More minor Cleanup
2015-04-09 21:31:21 -07:00
mezz ae1ed86b50 #606 Allow Flutterlyzer to show mutations 2015-04-09 21:28:51 -07:00
mezz 784a47ba11 Fix #597 Crash from Butterfly Genome.getActiveAllele 2015-04-06 20:24:47 -07:00
mezz b5370254c4 Optimize compression of png assets 2015-04-06 00:58:17 -07:00
mezz 689adab411 Fix #594 Crash in Natura plugin 2015-04-05 21:06:19 -07:00
mezz 1526b2cb3f Close #586 Disabled "Generated apatite vein around *coords*" messages 2015-04-05 20:55:37 -07:00
mezz 536254af42 Fix #588 crash on crate registry with disabled storage module and natura 2015-04-05 20:04:49 -07:00
mezz eee22d3e5c Rename loadPlugin to registerHandlers in PluginManager 2015-04-05 20:03:58 -07:00
mezz f7bc38c7e4 Fix #592 Some Crates are missing a recipe 2015-04-05 14:17:34 -07:00
Nirek-K 3f6f12f7cc Fix #588 Bulletproof null checks for Natura Plugin 2015-04-05 14:17:34 -07:00
mezz f8f949850b Bump unstable branch to version 3.6.0 2015-04-04 20:58:53 -07:00
mezz fd88173e6f Fix #584 Carpenter doesn't work 2015-04-04 19:41:16 -07:00
Nirek-K 70d6db8bf2 Plant Mega Pack Stage 3
Add most basic flowers to plantable and usable by bees. This should include almost all flowers that don't 'grow' like crops.
2015-03-30 22:07:18 -07:00
mezz 29dddc76ef Make escritoir inventory a private static class instead of anonymous 2015-03-30 22:07:17 -07:00
mezz e80a4e9dfa Organize modules 2015-03-30 22:04:30 -07:00
mezz 1ca041a29f Revert "Close #441 Add Underground Biomes Constructs integration"
This reverts commit b3b1a6a415.

Conflicts:
	lang
	src/main/java/forestry/Forestry.java
	src/main/java/forestry/plugins/PluginManager.java
2015-03-29 23:44:48 -07:00
mezz 4bfb2a3662 make worktable inventory adapter a private static class 2015-03-29 23:39:50 -07:00
mezz 59b90044b7 Clean up slot handling code 2015-03-29 22:00:00 -07:00
mezz 6a8b9af626 Fix #579 Centrifuge recipes do not work with wildcard metadata 2015-03-29 22:00:00 -07:00
mezz 9df39e48eb Move slot handling code out of ContainerForestry, in to SlotHelper 2015-03-29 22:00:00 -07:00
mezz 54fdeab46e Merge pull request #571 from Nirek-K/Witchery
Witchery Support #223
2015-03-28 23:13:46 -07:00
mezz 80cfe423aa Fix #574 clean up candle code 2015-03-28 23:03:52 -07:00
mezz 614ba3f6a9 Merge pull request #575 from Nirek-K/F573
Fix #573 Add Vanilla Acacia and Dark oak to fermenter
2015-03-28 17:16:02 -07:00
Nirek-K ac83f6107d Fix #573 Add Vanilla Acacia and Dark oak to fermenter 2015-03-28 18:25:35 -05:00
Nirek-K 51497c98f7 Witchery Support
BloodRose, Dandelion, Poppy, Shrub added to Flowers Acceptable (not spread)
Belladonna, Mandrake, Mindrake, Snowbell, Wolfsbane, Wormwood, Garlic added
to Crop Multifarm, seeds to squeezer.
Saplings added to multifarm, fermenter.
2015-03-28 02:01:16 -05:00
mezz ed7b200c56 Merge pull request #567 from Nirek-K/PlantMP2
Plant Mega Pack Stage 2
2015-03-27 22:27:51 -07:00
MysteriousAges 5d2d350a96 Merge pull request #568 from Nirek-K/dev
Remove old animation files no longer used (as per Hanfox)
2015-03-27 21:10:47 -07:00
Nirek-K 9ffe216f4a Remove old animation files no longer used. (as per Hanfox) 2015-03-27 18:20:04 -05:00
Nirek-K a3f23ea1cb Plant Mega Pack Stage 2
Cactus/Desert plants to crop multifarm, acceptable to Cacti bee flower allele
Land Crops to crop multifarm, seeds to seed oil, products to juice in Squeezer
2015-03-27 05:28:07 -05:00
472 changed files with 11709 additions and 11235 deletions

No files matched your search

+3 -3
View File
@@ -1,5 +1,5 @@
mcversion=1.7.10
forgeversion=10.13.2.1286
forgeversion=10.13.3.1370-1.7.10
version_major=3
version_minor=5
version_patch=5
version_minor=6
version_patch=1
+6 -2
View File
@@ -70,6 +70,10 @@ repositories {
name = "ic2"
url = "http://maven.ic2.player.to/"
}
ivy {
name "BuildCraft"
artifactPattern "http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision]-[classifier].[ext]"
}
}
configurations {
@@ -78,8 +82,8 @@ configurations {
}
dependencies {
api 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
api 'com.mod-buildcraft:buildcraft:6.3.1:dev'
api 'net.industrial-craft:industrialcraft-2:2.2.713-experimental:api'
api name: "buildcraft", version: "6.4.10", classifier: "dev"
}
processResources {
+2
View File
@@ -1,3 +1,5 @@
Account;Email;Date;
samtrion;[email protected];2015-01-18
GenuineSounds;[email protected];2015-02-26
airbreather;[email protected];2015-04-10
ganymedes01;[email protected];2015-05-27
+1 -1
Submodule lang updated: fa0f81998b...e111b835ad.
+2 -1
View File
@@ -61,7 +61,8 @@ import forestry.core.utils.StringUtil;
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,);"
+ "after:Natura@[2.2.0,);")
+ "after:Natura@[2.2.0,);"
+ "after:HardcoreEnderExpansion;")
//, certificateFingerprint = Version.FINGERPRINT)
public class Forestry {
@@ -10,12 +10,14 @@
******************************************************************************/
package forestry.apiculture;
import java.util.Set;
import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
@@ -33,10 +35,14 @@ import forestry.plugins.PluginApiculture;
public class BeekeepingLogic implements IBeekeepingLogic {
private static final int MAX_POLLINATION_ATTEMPTS = 20;
private static final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
private static final int ticksPerCheckCanWork = 10;
private final IBeeHousing housing;
private final boolean housingSupportsMultipleErrorStates;
// Breeding
private int breedingTime;
private final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
private int queenWorkCycleThrottle;
private IEffectData effectData[] = new IEffectData[2];
private IBee queen;
@@ -44,8 +50,22 @@ public class BeekeepingLogic implements IBeekeepingLogic {
private int attemptedPollinations = 0;
private final Stack<ItemStack> spawn = new Stack<ItemStack>();
// Cached flowers check
private boolean hasFlowersCached = false;
private int hasFlowersCooldown = 0;
private boolean canWorkCached = false;
private int canWorkCooldown = 0;
public BeekeepingLogic(IBeeHousing housing) {
this.housing = housing;
Set<IErrorState> errorStateSet = null;
try {
errorStateSet = housing.getErrorStates();
} catch (Throwable ignored) {
}
housingSupportsMultipleErrorStates = (errorStateSet != null);
}
// / SAVING & LOADING
@@ -86,7 +106,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
@Override
public int getTotalBreedingTime() {
return this.totalBreedingTime;
return totalBreedingTime;
}
@Override
@@ -105,27 +125,92 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
/* UPDATING */
@Override
public boolean canWork() {
if (canWorkCooldown > 0) {
canWorkCooldown--;
} else {
canWorkCached = checkCanWork();
canWorkCooldown = ticksPerCheckCanWork;
}
return canWorkCached;
}
private boolean checkCanWork() {
if (housingSupportsMultipleErrorStates) {
Set<IErrorState> errorStates = housing.getErrorStates();
for (IErrorState errorState : errorStates) {
housing.setErrorCondition(false, errorState);
}
}
boolean hasSpace = addPendingProducts();
if (hasBreedablePrincess()) {
return hasSpace;
}
if (hasHealthyQueen()) {
boolean canWork = queenCanWork();
boolean hasFlowers = hasFlowers();
return hasSpace && canWork && hasFlowers;
}
return false;
}
@Override
public void doWork() {
if (hasBreedablePrincess()) {
tickBreed();
} else if (queen != null) {
queenWorkTick();
}
}
@Override
public void update() {
this.queen = null;
if (!addPendingProducts()) {
return;
if (canWork()) {
doWork();
}
if (tryBreedingPrincess() || !hasHealthyQueen()) {
return;
}
if (!queenCanWork()) {
return;
}
private boolean hasFlowers() {
if (queen == null) {
return true;
}
queenWorkTick();
if (hasFlowersCooldown <= 0) {
hasFlowersCached = queen.hasFlower(housing);
hasFlowersCooldown = PluginApiculture.ticksPerBeeWorkCycle / ticksPerCheckCanWork;
// check more often if we haven't found flowers
if (!hasFlowersCached) {
hasFlowersCooldown /= 2;
}
} else {
hasFlowersCooldown--;
}
if (housingSupportsMultipleErrorStates) {
housing.setErrorCondition(!hasFlowersCached, EnumErrorCode.NOFLOWER);
} else {
if (hasFlowersCached) {
housing.setErrorState(EnumErrorCode.OK);
} else {
housing.setErrorState(EnumErrorCode.NOFLOWER);
}
}
return hasFlowersCached;
}
private void queenWorkTick() {
if (queen == null) {
return;
}
// Effects only fire when queen can work.
effectData = queen.doEffect(effectData, housing);
@@ -133,29 +218,27 @@ public class BeekeepingLogic implements IBeekeepingLogic {
queenWorkCycleThrottle++;
if (queenWorkCycleThrottle >= PluginApiculture.ticksPerBeeWorkCycle) {
queenWorkCycleThrottle = 0;
// Need a flower
if (queen.hasFlower(housing)) {
housing.setErrorState(EnumErrorCode.OK.ordinal());
doQueenWorkCycle();
} else {
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
}
doProduction();
queen.plantFlowerRandom(housing);
doPollination();
// Age the queen
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
updateQueenItemNBT();
}
}
private void doQueenWorkCycle() {
doProduction();
queen.plantFlowerRandom(housing);
doPollination();
// Age the queen
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
updateQueenItemNBT();
}
private void doProduction() {
if (queen == null) {
return;
}
// Produce and add stacks
ItemStack[] products = queen.produceStacks(housing);
if (products == null) {
return;
}
housing.wearOutEquipment(1);
for (ItemStack stack : products) {
housing.addProduct(stack, false);
@@ -163,6 +246,10 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
private void doPollination() {
if (queen == null) {
return;
}
// Get pollen if none available yet
if (pollen == null) {
pollen = queen.retrievePollen(housing);
@@ -182,6 +269,10 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
private void updateQueenItemNBT() {
if (queen == null) {
return;
}
// Write the changed queen back into the item stack.
NBTTagCompound nbttagcompound = new NBTTagCompound();
queen.writeToNBT(nbttagcompound);
@@ -203,55 +294,72 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
if (housingErrorState != null) {
try {
if (housingSupportsMultipleErrorStates) {
boolean hasSpace = (housingErrorState == EnumErrorCode.OK);
housing.setErrorCondition(!hasSpace, EnumErrorCode.NOSPACE);
} else {
housing.setErrorState(housingErrorState);
} catch (Error e) {
housing.setErrorState(housingErrorState.ordinal());
}
}
return housingErrorState != EnumErrorCode.NOSPACE;
}
/** Checks if a queen is alive. Much faster than reading the whole bee nbt */
private static boolean isQueenAlive(ItemStack queenStack) {
NBTTagCompound nbtTagCompound = queenStack.getTagCompound();
int health = nbtTagCompound.getInteger("Health");
return health > 0;
}
private boolean hasHealthyQueen() {
boolean hasQueen = true;
EnumErrorCode housingErrorState = null;
if (housing.getQueen() == null || !ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
ItemStack queenStack = housing.getQueen();
if (queenStack == null || !ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
housingErrorState = EnumErrorCode.NOQUEEN;
hasQueen = false;
queen = null;
} else if (!isQueenAlive(queenStack)) {
if (queen == null) {
queen = BeeManager.beeRoot.getMember(queenStack);
}
killQueen();
housingErrorState = EnumErrorCode.OK;
hasQueen = false;
queen = null;
}
if (housingSupportsMultipleErrorStates) {
housing.setErrorCondition(!hasQueen, EnumErrorCode.NOQUEEN);
} else {
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
// Kill dying queens
if (!queen.isAlive()) {
killQueen(queen);
housingErrorState = EnumErrorCode.OK;
hasQueen = false;
} else {
this.queen = queen;
}
}
if (housingErrorState != null) {
try {
if (housingErrorState != null) {
housing.setErrorState(housingErrorState);
} catch (Error e) {
housing.setErrorState(housingErrorState.ordinal());
}
}
if (hasQueen && queen == null) {
queen = BeeManager.beeRoot.getMember(queenStack);
}
return hasQueen;
}
private boolean tryBreedingPrincess() {
boolean isBreedingPrincess = false;
// Princess available? Try to breed!
private boolean hasBreedablePrincess() {
boolean isBreedingPrincess = false;
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone())) {
housing.setErrorState(EnumErrorCode.OK.ordinal());
boolean hasDrone = ForestryItem.beeDroneGE.isItemEqual(housing.getDrone());
if (housingSupportsMultipleErrorStates) {
housing.setErrorCondition(!hasDrone, EnumErrorCode.NODRONE);
} else {
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
if (hasDrone) {
housing.setErrorState(EnumErrorCode.OK);
} else {
housing.setErrorState(EnumErrorCode.NODRONE);
}
}
tickBreed();
isBreedingPrincess = true;
}
@@ -259,35 +367,30 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
private boolean queenCanWork() {
try {
boolean canWork = true;
// Not while raining, at night or without light
IErrorState state = queen.canWork(housing);
if (state != EnumErrorCode.OK) {
housing.setErrorState(state);
canWork = false;
} else if (housing.getErrorState() != EnumErrorCode.NOFLOWER) {
housing.setErrorState(EnumErrorCode.OK);
}
return canWork;
} catch (Error e) {
Proxies.log.logErrorAPI("Forestry", e, IBee.class);
return queenCanWorkDeprecated();
if (queen == null) {
return false;
}
}
// fallback for outdated APIs
private boolean queenCanWorkDeprecated() {
boolean canWork = true;
// Not while raining, at night or without light
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
if (state != EnumErrorCode.OK) {
housing.setErrorState(state.ordinal());
canWork = false;
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal()) {
housing.setErrorState(EnumErrorCode.OK.ordinal());
if (housingSupportsMultipleErrorStates) {
try {
Set<IErrorState> errorStates = queen.getCanWork(housing);
for (IErrorState errorState : errorStates) {
housing.setErrorCondition(true, errorState);
}
return (errorStates.size() == 0);
} catch (Throwable ignored) {
// queen might not support getCanWork(housing)
}
}
return canWork;
IErrorState state = queen.canWork(housing);
if (state != EnumErrorCode.OK) {
housing.setErrorState(state);
return false;
}
return true;
}
// / BREEDING
@@ -310,8 +413,8 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
// Replace
IBee princess = PluginApiculture.beeInterface.getMember(housing.getQueen());
IBee drone = PluginApiculture.beeInterface.getMember(housing.getDrone());
IBee princess = BeeManager.beeRoot.getMember(housing.getQueen());
IBee drone = BeeManager.beeRoot.getMember(housing.getDrone());
princess.mate(drone);
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -323,7 +426,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
housing.onQueenChange(housing.getQueen());
// Register the new queen with the breeding tracker
PluginApiculture.beeInterface.getBreedingTracker(housing.getWorld(), housing.getOwnerName()).registerQueen(princess);
BeeManager.beeRoot.getBreedingTracker(housing.getWorld(), housing.getOwnerName()).registerQueen(princess);
// Remove drone
housing.getDrone().stackSize--;
@@ -344,14 +447,15 @@ public class BeekeepingLogic implements IBeekeepingLogic {
return false;
}
if (!housing.canBreed()) {
return false;
}
return housing.canBreed();
return true;
}
private void killQueen(IBee queen) {
private void killQueen() {
if (queen == null) {
return;
}
if (queen.canSpawn()) {
spawnOffspring(queen);
housing.getQueen().stackSize = 0;
@@ -376,18 +480,18 @@ public class BeekeepingLogic implements IBeekeepingLogic {
private void spawnOffspring(IBee queen) {
Stack<ItemStack> offspring = new Stack<ItemStack>();
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(housing.getWorld(), housing.getOwnerName());
IApiaristTracker breedingTracker = BeeManager.beeRoot.getBreedingTracker(housing.getWorld(), housing.getOwnerName());
housing.onQueenDeath(getQueen());
// Princess
boolean secondPrincess = this.housing.getWorld().rand.nextInt(100) < PluginApiculture.getSecondPrincessChance();
boolean secondPrincess = this.housing.getWorld().rand.nextInt(10000) < PluginApiculture.getSecondPrincessChance() * 100;
int count = secondPrincess ? 2 : 1;
while (count > 0) {
count--;
IBee heiress = queen.spawnPrincess(housing);
if (heiress != null) {
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
ItemStack princess = BeeManager.beeRoot.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
breedingTracker.registerPrincess(heiress);
offspring.push(princess);
}
@@ -396,7 +500,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
// Drones
IBee[] larvae = queen.spawnDrones(housing);
for (IBee larva : larvae) {
ItemStack drone = PluginApiculture.beeInterface.getMemberStack(larva, EnumBeeType.DRONE.ordinal());
ItemStack drone = BeeManager.beeRoot.getMemberStack(larva, EnumBeeType.DRONE.ordinal());
breedingTracker.registerDrone(larva);
offspring.push(drone);
}
@@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
import forestry.apiculture.gadgets.TileAlvearyPlain;
import forestry.apiculture.gadgets.TileAlvearySieve;
@@ -42,7 +43,6 @@ import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
import forestry.core.GuiHandlerBase;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.network.GuiId;
import forestry.plugins.PluginApiculture;
public class GuiHandlerApiculture extends GuiHandlerBase {
@@ -59,19 +59,19 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
switch (GuiId.values()[cleanId]) {
case AlvearyGUI:
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
return new GuiAlveary(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyPlain.class));
case AlvearySieveGUI:
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
return new GuiAlvearySieve(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySieve.class));
case AlvearySwarmerGUI:
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
return new GuiAlvearySwarmer(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySwarmer.class));
case ApiaristChestGUI:
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
return new GuiApiary(player.inventory, getTileForestry(world, x, y, z, player, TileApiary.class));
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
@@ -82,7 +82,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
return new GuiApiary(player.inventory, getTileForestry(world, x, y, z, player, TileBeehouse.class));
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
@@ -90,10 +90,10 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
return null;
}
return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
return new GuiHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
case HygroregulatorGUI:
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
return new GuiAlvearyHygroregulator(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyHygroregulator.class));
case ImprinterGUI:
equipped = player.getCurrentEquippedItem();
@@ -122,20 +122,20 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
case AlvearyGUI:
synchApiaristTracker(world, player);
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
return new ContainerAlveary(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyPlain.class));
case AlvearySieveGUI:
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
return new ContainerAlvearySieve(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySieve.class));
case AlvearySwarmerGUI:
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
return new ContainerAlvearySwarmer(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearySwarmer.class));
case ApiaristChestGUI:
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
return new ContainerApiary(player.inventory, getTileForestry(world, x, y, z, player, TileApiary.class), true);
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
@@ -148,7 +148,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
case BeehouseGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
return new ContainerApiary(player.inventory, getTileForestry(world, x, y, z, player, TileBeehouse.class), false);
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
@@ -156,10 +156,10 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
return null;
}
return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
return new ContainerHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
case HygroregulatorGUI:
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
return new ContainerAlvearyHygroregulator(player.inventory, getTileForestry(world, x, y, z, player, TileAlvearyHygroregulator.class));
case ImprinterGUI:
synchApiaristTracker(world, player);
@@ -175,7 +175,7 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
}
}
private void synchApiaristTracker(World world, EntityPlayer player) {
PluginApiculture.beeInterface.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player);
private static void synchApiaristTracker(World world, EntityPlayer player) {
BeeManager.beeRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player);
}
}
@@ -12,14 +12,14 @@ package forestry.apiculture;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.core.interfaces.ISaveEventHandler;
import forestry.plugins.PluginApiculture;
public class SaveEventHandlerApiculture implements ISaveEventHandler {
@Override
public void onWorldLoad(World world) {
PluginApiculture.beeInterface.resetBeekeepingMode();
BeeManager.beeRoot.resetBeekeepingMode();
}
@Override
@@ -27,14 +27,13 @@ import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
import forestry.api.apiculture.EnumBeeType;
import forestry.apiculture.genetics.BeeTemplates;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.apiculture.items.ItemHoneycomb;
import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
@@ -53,10 +52,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
recipeList.add(new MerchantRecipe(new ItemStack(Items.wheat, 2), ItemHoneycomb.getRandomComb(1, random, false)));
recipeList.add(new MerchantRecipe(new ItemStack(Blocks.log, 24, Defaults.WILDCARD), ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARY_META)));
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), ForestryItem.frameProven.getItemStack(6)));
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 12), ForestryItem.beePrincessGE.getItemStack(1, Defaults.WILDCARD),
PluginApiculture.beeInterface.getMemberStack(
PluginApiculture.beeInterface.getBee(villager.worldObj, PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getMonasticTemplate())),
EnumBeeType.DRONE.ordinal())));
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 12), ForestryItem.beePrincessGE.getItemStack(1, Defaults.WILDCARD), BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE)));
}
@Override
@@ -15,15 +15,15 @@ import java.util.List;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
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();
ArrayList<IBeekeepingMode> beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
int modeStringCount = beekeepingModes.size();
List<String> modeStrings = new ArrayList<String>(modeStringCount);
for (IBeekeepingMode mode : beekeepingModes) {
@@ -35,7 +35,7 @@ public class BeeModeHelper implements ICommandModeHelper {
@Override
public String getModeNameMatching(String desired) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(desired);
if (mode == null) {
return null;
}
@@ -44,17 +44,17 @@ public class BeeModeHelper implements ICommandModeHelper {
@Override
public String getModeName(World world) {
return PluginApiculture.beeInterface.getBeekeepingMode(world).getName();
return BeeManager.beeRoot.getBeekeepingMode(world).getName();
}
@Override
public void setMode(World world, String modeName) {
PluginApiculture.beeInterface.setBeekeepingMode(world, modeName);
BeeManager.beeRoot.setBeekeepingMode(world, modeName);
}
@Override
public Iterable<String> getDescription(String modeName) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(modeName);
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(modeName);
return mode.getDescription();
}
@@ -18,6 +18,7 @@ import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.AlleleManager;
@@ -26,7 +27,6 @@ import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IBreedingTracker;
import forestry.core.commands.IStatsSaveHelper;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
public class BeeStatsSaveHelper implements IStatsSaveHelper {
@@ -69,7 +69,7 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper {
@Override
public IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile) {
return PluginApiculture.beeInterface.getBreedingTracker(world, gameProfile);
return BeeManager.beeRoot.getBreedingTracker(world, gameProfile);
}
}
@@ -18,6 +18,7 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
@@ -28,7 +29,6 @@ import forestry.core.commands.CommandHelpers;
import forestry.core.commands.SpeciesNotFoundException;
import forestry.core.commands.SubCommand;
import forestry.core.commands.TemplateNotFoundException;
import forestry.plugins.PluginApiculture;
public class CommandBeeGive extends SubCommand {
@@ -87,13 +87,13 @@ public class CommandBeeGive extends SubCommand {
return;
}
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome);
IBee bee = BeeManager.beeRoot.getBee(player.worldObj, beeGenome);
if (beeType == EnumBeeType.QUEEN) {
bee.mate(bee);
}
ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal());
ItemStack beeStack = BeeManager.beeRoot.getMemberStack(bee, beeType.ordinal());
player.dropPlayerItemWithRandomChoice(beeStack, true);
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName());
@@ -127,13 +127,13 @@ public class CommandBeeGive extends SubCommand {
throw new SpeciesNotFoundException(speciesName);
}
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
IAllele[] template = BeeManager.beeRoot.getTemplate(species.getUID());
if (template == null) {
throw new TemplateNotFoundException(species);
}
return PluginApiculture.beeInterface.templateAsGenome(template);
return BeeManager.beeRoot.templateAsGenome(template);
}
@Override
@@ -18,12 +18,12 @@ import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.core.config.Defaults;
import forestry.core.utils.ForestryResource;
import forestry.plugins.PluginApiculture;
public class EntityBee extends EntityCreature implements IAnimals {
@@ -48,7 +48,7 @@ public class EntityBee extends EntityCreature implements IAnimals {
if (bee != null) {
contained = bee;
} else {
contained = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());
contained = BeeManager.beeRoot.templateAsIndividual(BeeManager.beeRoot.getDefaultTemplate());
}
//isImmuneToFire = contained.getGenome().getFireResist();
@@ -89,7 +89,9 @@ public final class FlowerRegistry implements IFlowerRegistry {
index = flowers.indexOf(newFlower);
if (index == -1) {
flowers.add(newFlower);
} else if (flowers.get(index).getWeight() > newFlower.getWeight()) {
} else if (flowers.get(index).getMeta() != newFlower.getMeta()) {
flowers.add(newFlower);
} else if (flowers.get(index).getWeight() < newFlower.getWeight() && flowers.get(index).getMeta() == newFlower.getMeta()) {
flowers.get(index).setWeight(newFlower.getWeight());
}
@@ -204,16 +206,6 @@ public final class FlowerRegistry implements IFlowerRegistry {
}
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);
@@ -233,6 +225,17 @@ public final class FlowerRegistry implements IFlowerRegistry {
registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
// Register plantable plants
for (int meta = 0; meta <= 8; meta++) {
registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
}
registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti);
}
private void registerVanillaGrowthRules() {
@@ -10,11 +10,17 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.google.common.collect.ImmutableMap;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -27,10 +33,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.relauncher.Side;
@@ -38,14 +44,42 @@ import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.ForestryClient;
import forestry.core.config.Defaults;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
public class BlockCandle extends BlockTorch {
private final ArrayList<Item> lightingItems = new ArrayList<Item>();
private static final ImmutableMap<String, Integer> colours;
private static final Set<Item> lightingItems;
public static final String colourTagName = "colour";
static {
colours = ImmutableMap.<String, Integer>builder()
.put("dyeWhite", new Color(255, 255, 255).getRGB())
.put("dyeOrange", new Color(219, 125, 62).getRGB())
.put("dyeMagenta", new Color(255, 20, 255).getRGB())
.put("dyeLightBlue", new Color(107, 138, 201).getRGB())
.put("dyeYellow", new Color(255, 255, 20).getRGB())
.put("dyeLime", new Color(20, 255, 20).getRGB())
.put("dyePink", new Color(208, 132, 153).getRGB())
.put("dyeGray", new Color(74, 74, 74).getRGB())
.put("dyeLightGray", new Color(154, 161, 161).getRGB())
.put("dyeCyan", new Color(20, 255, 255).getRGB())
.put("dyePurple", new Color(126, 61, 181).getRGB())
.put("dyeBlue", new Color(20, 20, 255).getRGB())
.put("dyeBrown", new Color(79, 50, 31).getRGB())
.put("dyeGreen", new Color(53, 70, 27).getRGB())
.put("dyeRed", new Color(150, 52, 48).getRGB())
.put("dyeBlack", new Color(20, 20, 20).getRGB())
.build();
lightingItems = new HashSet<Item>(Arrays.asList(
Items.flint_and_steel,
Items.flint,
Item.getItemFromBlock(Blocks.torch)
));
}
@SideOnly(Side.CLIENT)
private IIcon litStump;
@@ -61,10 +95,6 @@ public class BlockCandle extends BlockTorch {
this.setHardness(0.0F);
this.setStepSound(soundTypeWood);
setCreativeTab(Tabs.tabApiculture);
lightingItems.add(Items.flint_and_steel);
lightingItems.add(Items.flint);
lightingItems.add(Item.getItemFromBlock(Blocks.torch));
}
@Override
@@ -95,31 +125,24 @@ public class BlockCandle extends BlockTorch {
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return (isLit(meta)) ? 14 : 0;
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileCandle && ((TileCandle) tileEntity).isLit()) {
return 14;
}
return 0;
}
/*@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
IIcon i = this.unlitStump;
if (this.isLit(world.getBlockMetadata(x, y, z))) {
i = this.litStump;
}
return i;
}*/
@SideOnly(Side.CLIENT)
public IIcon getTextureFromPassAndMeta(int meta, int pass) {
public IIcon getTextureFromPassAndLit(int pass, boolean isLit) {
IIcon i;
if (pass == 0) {
if (isLit(meta)) {
if (isLit) {
i = this.litTip;
} else {
i = this.unlitTip;
}
} else {
if (isLit(meta)) {
if (isLit) {
i = this.litStump;
} else {
i = this.unlitStump;
@@ -128,232 +151,157 @@ public class BlockCandle extends BlockTorch {
return i;
}
public int getColourFromItemStack(ItemStack stack) {
int colour = 0xffffff;
if (stack.hasTagCompound()) {
NBTTagCompound tag = stack.getTagCompound();
colour = (tag.getByte("red") << 16) | (tag.getByte("green") << 8) | tag.getByte("blue");
}
return colour;
}
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
}
// Dye names correspond to colour values as below.
private static final String[] dyes = {"dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack"};
private static final int[][] colours = {{255, 255, 255}, {219, 125, 62}, {255, 20, 255}, {107, 138, 201},
{255, 255, 20}, {20, 255, 20}, {208, 132, 153}, {74, 74, 74},
{154, 161, 161}, {20, 255, 255}, {126, 61, 181}, {20, 20, 255},
{79, 50, 31}, {53, 70, 27}, {150, 52, 48}, {20, 20, 20}};
public static final String colourTagName = "colour";
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float facingX, float facingY, float facingZ) {
boolean flag = false;
int meta = world.getBlockMetadata(x, y, z);
boolean toggleLitState = true;
ItemStack held = player.getCurrentEquippedItem();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileCandle)) {
return false;
}
if (!isLit(meta)) {
if (held == null || !lightingItems.contains(held.getItem())) {
TileCandle tileCandle = (TileCandle) tileEntity;
final boolean isLit = tileCandle.isLit();
boolean flag = false;
boolean toggleLitState = true;
ItemStack heldItem = player.getCurrentEquippedItem();
if (!isLit) {
if (heldItem == null || !lightingItems.contains(heldItem.getItem())) {
toggleLitState = false;
} else if (StackUtils.equals(this, held) && isLit(held)) {
} else if (StackUtils.equals(this, heldItem) && isLit(heldItem)) {
toggleLitState = true;
}
}
if (held != null) {
// Ensure a TileEntity exists. May be able to remove this in future versions.
TileCandle te = (TileCandle) world.getTileEntity(x, y, z);
if (te == null) {
world.setTileEntity(x, y, z, this.createTileEntity(world, meta));
te = (TileCandle) world.getTileEntity(x, y, z);
}
if (StackUtils.equals(this, held)) {
if (!isLit(held)) {
if (heldItem != null) {
if (StackUtils.equals(this, heldItem)) {
if (!isLit(heldItem)) {
// Copy the colour of an unlit, coloured candle.
if (held.hasTagCompound() && held.getTagCompound().hasKey(colourTagName)) {
te.setColour(held.getTagCompound().getInteger(colourTagName));
if (heldItem.hasTagCompound() && heldItem.getTagCompound().hasKey(colourTagName)) {
tileCandle.setColour(heldItem.getTagCompound().getInteger(colourTagName));
} else {
// Reset to white if item has no
te.setColour(0xffffff);
tileCandle.setColour(0xffffff);
}
} else {
toggleLitState = true;
}
flag = true;
} else {
// Check for dye-able ness.
boolean matched = false;
for (int i = 0; i < dyes.length; ++i) {
for (ItemStack stack : OreDictionary.getOres(dyes[i])) {
if (OreDictionary.itemMatches(stack, held, true)) {
if (isLit(meta)) {
te.setColour(colours[i][0], colours[i][1], colours[i][2]);
} else {
te.addColour(colours[i][0], colours[i][1], colours[i][2]);
}
world.markBlockForUpdate(x, y, z);
matched = true;
toggleLitState = false;
flag = true;
break;
}
}
if (matched) {
break;
}
boolean dyed = tryDye(heldItem, isLit, tileCandle);
if (dyed) {
world.markBlockForUpdate(x, y, z);
toggleLitState = false;
flag = true;
}
}
}
if (toggleLitState) {
meta = this.toggleLitStatus(meta);
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH | Defaults.FLAG_BLOCK_UPDATE);
tileCandle.setLit(!isLit);
world.markBlockForUpdate(x, y, z);
flag = true;
}
return flag;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileCandle tc = (TileCandle) world.getTileEntity(x, y, z);
int newMeta = isLit(meta) ? 1 : 0;
ItemStack stack = new ItemStack(this, 1, newMeta);
if (tc != null && tc.getColour() != 0xffffff) {
// When dropped, tag new item stack with colour. Unless it's white, then do no such thing for maximum stacking.
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger(colourTagName, tc.getColour());
stack.setTagCompound(tag);
private static boolean tryDye(ItemStack held, boolean isLit, TileCandle tileCandle) {
// Check for dye-able ness.
boolean matched = false;
for (Map.Entry<String, Integer> colour : colours.entrySet()) {
String colourName = colour.getKey();
for (ItemStack stack : OreDictionary.getOres(colourName)) {
if (OreDictionary.itemMatches(stack, held, true)) {
if (isLit) {
tileCandle.setColour(colour.getValue());
} else {
tileCandle.addColour(colour.getValue());
}
return true;
}
}
this.dropBlockAsItem(world, x, y, z, stack);
}
super.breakBlock(world, x, y, z, block, meta);
return false;
}
/* DROP HANDLING */
// Hack: When harvesting we need to get the drops in onBlockHarvested,
// because Mojang destroys the block and tile before calling getDrops.
protected ThreadLocal<ItemStack> drop = new ThreadLocal<ItemStack>();
@Override
public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) {
if (!world.isRemote) {
ItemStack itemStack = getCandleDrop(world, x, y, z);
drop.set(itemStack);
}
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ItemStack dropStack = drop.get();
drop.remove();
// not harvested, get drops normally
if (dropStack == null) {
dropStack = getCandleDrop(world, x, y, z);
}
ArrayList<ItemStack> drops = new ArrayList<ItemStack>(1);
drops.add(dropStack);
return drops;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return getCandleDrop(world, x, y, z);
}
private ItemStack getCandleDrop(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileCandle)) {
return null;
}
TileCandle tileCandle = (TileCandle) tileEntity;
int colour = tileCandle.getColour();
int newMeta = tileCandle.isLit() ? 1 : 0;
ItemStack itemStack = new ItemStack(this, 1, newMeta);
if (colour != 0xffffff) {
// When dropped, tag new item stack with colour. Unless it's white, then do no such thing for maximum stacking.
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger(colourTagName, colour);
itemStack.setTagCompound(tag);
}
return itemStack;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
TileCandle tc = (TileCandle) (world.getTileEntity(x, y, z));
tc.setColour(this.getColourValueFromItemStack(itemStack));
if (isLit(itemStack)) {
int meta = world.getBlockMetadata(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, this.toggleLitStatus(meta), Defaults.FLAG_BLOCK_SYNCH | Defaults.FLAG_BLOCK_UPDATE);
}
}
@Override
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) {
// Does nothing to prevent extra candles from falling.
}
@Override
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
// Does nothing to prevent extra candles from falling.
}
@Override
protected boolean func_150109_e(World world, int x, int y, int z) {
// Slightly tweaked version of BlockTorch's version to account for TE nonsense.
if (!this.canPlaceBlockAt(world, x, y, z)) {
if (world.getBlock(x, y, z) == this) {
world.setBlockToAir(x, y, z);
}
return false;
} else {
return true;
}
TileCandle tileCandle = (TileCandle) (world.getTileEntity(x, y, z));
int colour = getColourValueFromItemStack(itemStack);
boolean isLit = isLit(itemStack);
tileCandle.setColour(colour);
tileCandle.setLit(isLit);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (isLit(world.getBlockMetadata(x, y, z))) {
int l = world.getBlockMetadata(x, y, z) & 0x07;
double d0 = x + 0.5F;
double d1 = y + 0.7F;
double d2 = z + 0.5F;
double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
if (l == 1) {
world.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
} else if (l == 2) {
world.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
} else if (l == 3) {
world.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
} else if (l == 4) {
world.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
} else {
world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileCandle && ((TileCandle) tileEntity).isLit()) {
super.randomDisplayTick(world, x, y, z, random);
}
}
@Override
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block) {
if (this.func_150109_e(par1World, par2, par3, par4)) {
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 0x07;
boolean flag = false;
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1) {
flag = true;
}
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2) {
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3) {
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4) {
flag = true;
}
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) {
flag = true;
}
if (flag) {
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(par2, par3, par4);
return true;
} else {
return false;
}
} else {
return true;
}
}
// Yes, function hiding. Go away.
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4) {
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4)) {
return true;
} else {
Block block = par1World.getBlock(par2, par3, par4);
return block.canPlaceTorchOnTop(par1World, par2, par3, par4);
}
}
protected int getColourValueFromItemStack(ItemStack itemStack) {
protected static int getColourValueFromItemStack(ItemStack itemStack) {
int value = 0xffffff; // default to white.
if (itemStack.hasTagCompound()) {
NBTTagCompound tag = itemStack.getTagCompound();
@@ -364,25 +312,17 @@ public class BlockCandle extends BlockTorch {
return value;
}
public static boolean isLit(int meta) {
return (meta & 0x08) > 0;
}
public static boolean isLit(ItemStack itemStack) {
return itemStack.getItemDamage() > 0;
}
protected int toggleLitStatus(int meta) {
return meta ^ 0x08;
}
public void addItemToLightingList(Item item) {
public static void addItemToLightingList(Item item) {
if (item == null) {
throw new NullPointerException();
}
if (!this.lightingItems.contains(item)) {
this.lightingItems.add(item);
if (!lightingItems.contains(item)) {
lightingItems.add(item);
}
}
+29 -10
View File
@@ -11,14 +11,17 @@
package forestry.apiculture.gadgets;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.core.ITileStructure;
import forestry.core.config.ForestryBlock;
import forestry.core.gadgets.BlockStructure.EnumStructureState;
import forestry.core.gadgets.StructureLogic;
import forestry.core.utils.Schemata;
@@ -29,18 +32,19 @@ public class StructureLogicAlveary extends StructureLogic {
/* CONSTANTS */
public static final String UID_ALVEARY = "alveary";
public static final Schemata SCHEMATA_ALVEARY = new Schemata("alveary3x3", 5, 6, 5, "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FAAAF",
"FAAAF", "FABAF", "FCCCF", "FFFFF", "FFFFF", "FAAAF", "FAAAF", "FBMBF", "FCCCF", "FFFFF", "FFFFF", "FAAAF", "FAAAF", "FABAF", "FCCCF", "FFFFF",
public static final Schemata SCHEMATA_ALVEARY = new Schemata("alveary3x3", 5, 6, 5,
"FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF",
"FFFFF", "FAAAF", "FAAAF", "FABAF", "FCCCF", "FFFFF",
"FFFFF", "FAAAF", "FAAAF", "FBMBF", "FCCCF", "FFFFF",
"FFFFF", "FAAAF", "FAAAF", "FABAF", "FCCCF", "FFFFF",
"FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-2, -3, -2);
public static final HashSet<Block> slabBlocks = new HashSet<Block>();
private static final Set<Block> slabBlocks = new HashSet<Block>();
private static final Set<Integer> slabOreDictIds = new HashSet<Integer>();
static {
slabBlocks.add(Blocks.wooden_slab);
slabBlocks.add(ForestryBlock.slabs1.block());
slabBlocks.add(ForestryBlock.slabs2.block());
slabBlocks.add(ForestryBlock.slabs3.block());
slabBlocks.add(ForestryBlock.slabs4.block());
int slabWoodId = OreDictionary.getOreID("slabWood");
slabOreDictIds.add(slabWoodId);
}
public StructureLogicAlveary(ITileStructure structure) {
@@ -100,7 +104,7 @@ public class StructureLogicAlveary extends StructureLogic {
}
break;
case BLOCK_C:
if (!slabBlocks.contains(block)) {
if (!isWoodSlabBlock(block)) {
return EnumStructureState.INVALID;
}
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) {
@@ -127,4 +131,19 @@ public class StructureLogicAlveary extends StructureLogic {
return EnumStructureState.VALID;
}
private static boolean isWoodSlabBlock(Block block) {
int[] oreIds = OreDictionary.getOreIDs(new ItemStack(block));
for (int oreId : oreIds) {
if (slabOreDictIds.contains(oreId)) {
return true;
}
}
return slabBlocks.contains(block);
}
public static void addSlabBlock(Block block) {
slabBlocks.add(block);
}
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
@@ -31,7 +32,8 @@ import forestry.core.config.ForestryBlock;
import forestry.core.gadgets.TileForestry;
import forestry.core.inventory.FakeInventoryAdapter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.network.PacketPayload;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import buildcraft.api.statements.ITriggerExternal;
@@ -60,26 +62,11 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
}
}
@Override
public void updateEntity() {
super.updateEntity();
if (!Proxies.common.isSimulating(worldObj)) {
updateClientSide();
} else {
// Periodic validation if needed
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
validateStructure();
}
updateServerSide();
}
}
protected void updateServerSide() {
}
protected void updateClientSide() {
// Periodic validation if needed
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
validateStructure();
}
}
/* TEXTURES */
@@ -121,24 +108,23 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 2);
payload.shortPayload[0] = (short) (isMaster() ? 1 : 0);
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(isMaster);
// so the client can know if it is part of an integrated structure
payload.shortPayload[1] = (short) this.masterY;
return payload;
data.writeVarInt(masterY);
}
@Override
public void fromPacketPayload(PacketPayload payload) {
if (payload.shortPayload[0] > 0) {
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
if (data.readBoolean()) {
makeMaster();
}
// so the client can know if it is part of an integrated structure
this.masterY = payload.shortPayload[1];
masterY = data.readVarInt();
}
/* ITILESTRUCTURE */
@@ -160,6 +146,10 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
if (getInternalInventory() instanceof FakeInventoryAdapter) {
createInventory();
}
if (worldObj != null && !worldObj.isRemote) {
setNeedsNetworkUpdate();
}
}
@Override
@@ -229,11 +219,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
return isMaster || masterY >= 0;
}
@Override
public final IInventoryAdapter getInventory() {
return getStructureInventory();
}
@Override
public IInventoryAdapter getStructureInventory() {
return getInternalInventory();
@@ -10,17 +10,23 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.core.network.PacketPayload;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.core.interfaces.IActivatable;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import forestry.energy.EnergyManager;
import cofh.api.energy.IEnergyHandler;
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler, IActivatable {
public static class ClimateControl {
@@ -41,6 +47,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
private final int textureOff;
private final int textureOn;
// CLIENT
private boolean active;
public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) {
super(componentBlockMeta);
this.climateControl = control;
@@ -59,8 +68,6 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
return;
}
boolean wasInactive = (workingTime == 0);
if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
// consume 10 RF per tick of work
workingTime += energyManager.getEnergyPerWork() / 10;
@@ -74,9 +81,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
}
}
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
sendNetworkUpdate();
}
setActive(workingTime > 0);
}
@Override
@@ -87,7 +92,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if (workingTime > 0) {
if (active) {
return textureOn;
} else {
return textureOff;
@@ -100,6 +105,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
super.readFromNBT(nbttagcompound);
energyManager.readFromNBT(nbttagcompound);
workingTime = nbttagcompound.getInteger("Heating");
setActive(workingTime > 0);
}
@Override
@@ -109,22 +115,37 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
nbttagcompound.setInteger("Heating", workingTime);
}
/* NETWORK */
@Override
public void fromPacketPayload(PacketPayload payload) {
short workingTime = payload.shortPayload[0];
if (this.workingTime != workingTime) {
this.workingTime = workingTime;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
payload.shortPayload[0] = (short) workingTime;
return payload;
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
setActive(data.readBoolean());
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (worldObj.isRemote) {
worldObj.func_147479_m(xCoord, yCoord, zCoord);
} else {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
/* IEnergyHandler */
@@ -69,16 +69,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
public TileAlvearyHygroregulator() {
super(BLOCK_META);
setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_INPUT) {
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
return liquidTank.accepts(fluid);
}
return false;
}
});
setInternalInventory(new HygroInventoryAdapter(this));
Fluid water = Fluids.WATER.getFluid();
Fluid lava = Fluids.LAVA.getFluid();
@@ -136,17 +127,14 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
}
if (!updateOnInterval(20)) {
return;
if (updateOnInterval(20)) {
IInventoryAdapter canInventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null) {
FluidHelper.drainContainers(tankManager, canInventory, 0);
}
}
IInventoryAdapter canInventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null) {
FluidHelper.drainContainers(tankManager, canInventory, 0);
}
}
@Override
@@ -231,4 +219,19 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
@Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
}
private static class HygroInventoryAdapter extends TileInventoryAdapter<TileAlvearyHygroregulator> {
public HygroInventoryAdapter(TileAlvearyHygroregulator alvearyHygroregulator) {
super(alvearyHygroregulator, 1, "CanInv");
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_INPUT) {
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
return tile.liquidTank.accepts(fluid);
}
return false;
}
}
}
@@ -10,12 +10,12 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -24,6 +24,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
@@ -38,28 +39,28 @@ import forestry.api.core.IErrorState;
import forestry.api.core.ITileStructure;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.gui.ContainerAlveary;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.interfaces.IActivatable;
import forestry.core.interfaces.IClimatised;
import forestry.core.interfaces.IErrorSource;
import forestry.core.interfaces.IHintSource;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketInventoryStack;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource {
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource, IActivatable {
// / CONSTANTS
public static final int SLOT_QUEEN = 0;
public static final int SLOT_DRONE = 1;
public static final int SLOT_PRODUCT_1 = 2;
public static final int SLOT_PRODUCTION_COUNT = 7;
public static final int SLOT_PRODUCT_COUNT = 7;
public static final int BLOCK_META = 0;
// / MEMBERS
@@ -67,8 +68,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
protected BiomeGenBase biome;
protected float tempChange = 0.0f;
protected float humidChange = 0.0f;
// CLIENT
private boolean active;
private int displayHealthMax = 0;
private int displayHealth = 0;
private IBee displayQueen;
public TileAlvearyPlain() {
super(0);
@@ -90,8 +95,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
private void setBiomeInformation() {
this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
setErrorState(EnumErrorCode.OK);
this.biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
}
/* LOADING & SAVING */
@@ -105,7 +109,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
if (beekeepingLogic != null) {
beekeepingLogic.readFromNBT(nbttagcompound);
}
}
@Override
@@ -118,7 +121,43 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
if (beekeepingLogic != null) {
beekeepingLogic.writeToNBT(nbttagcompound);
}
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
if (active) {
ItemStack queen = getStackInSlot(SLOT_QUEEN);
data.writeItemStack(queen);
}
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
active = data.readBoolean();
if (active) {
ItemStack queen = data.readItemStack();
setInventorySlotContents(SLOT_QUEEN, queen);
}
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (!worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
/* UPDATING */
@@ -130,6 +169,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
protected void updateServerSide() {
super.updateServerSide();
if (beekeepingLogic == null) {
return;
@@ -138,62 +178,33 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return;
}
beekeepingLogic.update();
boolean canWork = beekeepingLogic.canWork();
setActive(canWork);
if (canWork) {
beekeepingLogic.doWork();
}
// Equalize humidity and temperature
equalizeTemperature();
equalizeHumidity();
IBee queen = beekeepingLogic.getQueen();
if (queen == null) {
return;
}
// Add swarm effects
if (updateOnInterval(200)) {
ISidedInventory inventory = getStructureInventory();
if (inventory != null) {
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
}
}
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;
float f3 = 0.52F;
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
}
}
@Override
protected void updateClientSide() {
if (isMaster() && active && (displayQueen != null) && updateOnInterval(2)) {
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
if (!isMaster()) {
return;
}
if (updateOnInterval(50)) {
float fxX = xCoord + 0.5F;
float fxY = yCoord + 0.25F + (worldObj.rand.nextFloat() * 6F) / 16F;
float fxZ = zCoord + 0.5F;
float f3 = 1.6F;
float f4 = worldObj.rand.nextFloat() * f3 - 0.5F;
ISidedInventory inventory = getStructureInventory();
if (inventory == null) {
return;
}
// / Multiplayer FX
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
if (PluginApiculture.beeInterface.isMated(queenStack)) {
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack);
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
Proxies.common.addEntitySwarmFX(worldObj, (fxX - f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ + f3), 0F, 0F, 0F);
}
}
}
@@ -222,32 +233,26 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
if (displayQueen == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealth;
if (displayQueen.getMate() != null) {
return displayQueen.getHealth();
} else {
return 0;
return displayHealth;
}
}
private int getMaxHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
if (displayQueen == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealthMax;
if (displayQueen.getMate() != null) {
return displayQueen.getMaxHealth();
} else {
return 0;
return displayHealthMax;
}
}
@@ -262,29 +267,14 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
/* STRUCTURE MANAGMENT */
@Override
protected void createInventory() {
setInternalInventory(new TileInventoryAdapter(this, 9, "Items") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack);
} else if (slotIndex == SLOT_DRONE) {
return PluginApiculture.beeInterface.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
}
});
setInternalInventory(new AlvearyInventoryAdapter(this));
}
@Override
public void makeMaster() {
super.makeMaster();
if (beekeepingLogic == null) {
this.beekeepingLogic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
this.beekeepingLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
}
}
@@ -293,6 +283,8 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
super.onStructureReset();
modifiers.clear();
eventHandlers.clear();
setActive(false);
}
/* IALVEARYCOMPONENT */
@@ -321,7 +313,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
float temperature = biome.temperature;
float temperature = biome.getFloatTemperature(xCoord, yCoord, zCoord);
tempChange = Math.min(boundaryUp - temperature, Math.max(boundaryDown - temperature, tempChange + change));
}
@@ -363,13 +355,35 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
@Override
public void setDrone(ItemStack itemstack) {
setInventorySlotContents(SLOT_DRONE, itemstack);
public ItemStack decrStackSize(int slotIndex, int amount) {
ItemStack itemStack = super.decrStackSize(slotIndex, amount);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
return itemStack;
}
@Override
public int getBiomeId() {
return biome.biomeID;
public void setInventorySlotContents(int slotIndex, ItemStack itemStack) {
super.setInventorySlotContents(slotIndex, itemStack);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
}
private void handleQueenChange() {
if (!Proxies.common.isSimulating(worldObj)) {
TileAlvearyPlain master = (TileAlvearyPlain) getCentralTE();
if (master != null) {
ItemStack itemStack = getStackInSlot(SLOT_QUEEN);
master.displayQueen = BeeManager.beeRoot.getMember(itemStack);
}
}
}
@Override
public void setDrone(ItemStack itemstack) {
setInventorySlotContents(SLOT_DRONE, itemstack);
}
@Override
@@ -379,7 +393,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public EnumTemperature getTemperature() {
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0) {
if (isHellish() && tempChange >= 0) {
return EnumTemperature.HELLISH;
}
@@ -450,16 +464,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return worldObj;
}
@Override
public void setErrorState(int state) {
setErrorState(EnumErrorCode.values()[state]);
}
@Override
public int getErrorOrdinal() {
return getErrorState().getID();
}
@Override
public boolean canBreed() {
return true;
@@ -472,7 +476,16 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return false;
}
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all);
}
@Deprecated
@Override
public void setErrorState(IErrorState state) {
removeErrorStates();
if (state != EnumErrorCode.OK) {
addErrorState(state);
}
}
@Override
@@ -488,9 +501,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return;
}
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
for (IBeeListener eventHandler : eventHandlers) {
eventHandler.onQueenChange(queenStack);
}
@@ -565,6 +575,10 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isHellish() {
if (BiomeHelper.isBiomeHellish(biome)) {
return true;
}
for (IBeeModifier modifier : modifiers) {
if (modifier.isHellish()) {
return true;
@@ -624,16 +638,26 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
/* IERRORSOURCE */
@Deprecated
@Override
public IErrorState getErrorState() {
Set<IErrorState> errorStates = null;
if (hasMaster()) {
ITileStructure tile = this.getCentralTE();
ITileStructure tile = getCentralTE();
if (tile != null) {
return ((IErrorSource) tile).getErrorState();
errorStates = ((IErrorSource) tile).getErrorStates();
}
}
return errorState;
if (errorStates == null) {
errorStates = this.getErrorStates();
}
if (errorStates.size() == 0) {
return EnumErrorCode.OK;
} else {
return getErrorStates().iterator().next();
}
}
/* ICLIMATISED */
@@ -644,7 +668,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public float getExactTemperature() {
return biome.temperature + this.tempChange;
return biome.getFloatTemperature(xCoord, yCoord, zCoord) + this.tempChange;
}
@Override
@@ -663,15 +687,30 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return Config.hints.get("alveary");
}
/* IOWNABLE */
@Override
public boolean isOwnable() {
return true;
}
/* IHousing */
@Override
public GameProfile getOwnerName() {
return this.getOwnerProfile();
return this.getOwner();
}
private static class AlvearyInventoryAdapter extends TileInventoryAdapter<TileAlvearyPlain> {
public AlvearyInventoryAdapter(TileAlvearyPlain tileAlvearyPlain) {
super(tileAlvearyPlain, 9, "Items");
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
} else if (slotIndex == SLOT_DRONE) {
return BeeManager.beeRoot.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
}
}
}
@@ -39,12 +39,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public TileAlvearySieve() {
super(BLOCK_META);
setInternalInventory(new TileInventoryAdapter(this, 5, "Items", 1) {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack);
}
});
setInternalInventory(new AlvearySieveInventoryAdapter(this));
}
@Override
@@ -187,4 +182,15 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public boolean onEggLaid(IBee queen) {
return false;
}
private static class AlvearySieveInventoryAdapter extends TileInventoryAdapter<TileAlvearySieve> {
public AlvearySieveInventoryAdapter(TileAlvearySieve alvearySieve) {
super(alvearySieve, 5, "Items", 1);
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack);
}
}
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.Map.Entry;
import java.util.Stack;
@@ -25,33 +26,31 @@ import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.ForestryAPI;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.apiculture.worldgen.Hive;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveDescriptionSwarmer;
import forestry.core.interfaces.IActivatable;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.inventory.wrappers.IInvSlot;
import forestry.core.inventory.wrappers.InventoryIterator;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.network.PacketPayload;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable {
/* CONSTANTS */
public static final int BLOCK_META = 2;
private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>();
private boolean isActive;
private boolean active;
public TileAlvearySwarmer() {
super(BLOCK_META);
setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv") {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
}
});
setInternalInventory(new SwarmerInventoryAdapter(this));
}
@Override
@@ -65,12 +64,12 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
super.updateServerSide();
if (pendingSpawns.size() > 0) {
setIsActive(true);
setActive(true);
if (updateOnInterval(1000)) {
trySpawnSwarm();
}
} else {
setIsActive(false);
setActive(false);
}
if (!updateOnInterval(500)) {
@@ -93,9 +92,9 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
}
// Queue swarm spawn
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
IBee princess = BeeManager.beeRoot.getMember(princessStack);
princess.setIsNatural(false);
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
pendingSpawns.push(BeeManager.beeRoot.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
}
private ItemStack getPrincessStack() {
@@ -110,7 +109,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
IBeeHousing housing = (IBeeHousing) master;
ItemStack princessStack = housing.getQueen();
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) {
if (princessStack == null || !BeeManager.beeRoot.isMated(princessStack)) {
return null;
}
@@ -149,30 +148,24 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
}
}
private void setIsActive(boolean isActive) {
if (this.isActive != isActive) {
this.isActive = isActive;
sendNetworkUpdate();
}
/* NETWORK */
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
}
/* NETWORK */
@Override
public void fromPacketPayload(PacketPayload payload) {
boolean act = payload.shortPayload[0] > 0;
if (this.isActive != act) {
this.isActive = act;
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
boolean active = data.readBoolean();
if (this.active != active) {
this.active = active;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(0, 1);
payload.shortPayload[0] = (short) (isActive ? 1 : 0);
return payload;
}
@Override
public boolean hasFunction() {
return true;
@@ -185,7 +178,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
return BlockAlveary.BOTTOM;
}
if (isActive) {
if (active) {
return BlockAlveary.ALVEARY_SWARMER_ON;
} else {
return BlockAlveary.ALVEARY_SWARMER_OFF;
@@ -222,4 +215,33 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
nbttagcompound.setTag("PendingSpawns", nbttaglist);
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (!worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
private static class SwarmerInventoryAdapter extends TileInventoryAdapter<TileAlvearySwarmer> {
public SwarmerInventoryAdapter(TileAlvearySwarmer alvearySwarmer) {
super(alvearySwarmer, 4, "SwarmInv");
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
}
}
}
@@ -10,15 +10,14 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import forestry.api.genetics.AlleleManager;
import forestry.apiculture.genetics.BeeHelper;
import forestry.api.apiculture.BeeManager;
import forestry.core.gadgets.TileNaturalistChest;
import forestry.core.network.GuiId;
public class TileApiaristChest extends TileNaturalistChest {
public TileApiaristChest() {
super(AlleleManager.alleleRegistry.getSpeciesRoot(BeeHelper.UID), GuiId.ApiaristChestGUI.ordinal());
super(BeeManager.beeRoot, GuiId.ApiaristChestGUI.ordinal());
}
}
@@ -20,6 +20,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.ForestryAPI;
@@ -27,7 +28,6 @@ import forestry.apiculture.trigger.ApicultureTriggers;
import forestry.core.gadgets.TileBase;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.network.GuiId;
import forestry.plugins.PluginApiculture;
import buildcraft.api.statements.ITriggerExternal;
@@ -136,7 +136,7 @@ public class TileApiary extends TileBeehouse {
@Override
public void wearOutEquipment(int amount) {
IInventoryAdapter inventory = getInternalInventory();
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
int wear = Math.round(amount * BeeManager.beeRoot.getBeekeepingMode(worldObj).getWearModifier());
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null) {
@@ -149,7 +149,7 @@ public class TileApiary extends TileBeehouse {
inventory.setInventorySlotContents(
i,
((IHiveFrame) inventory.getStackInSlot(i).getItem()).frameUsed(this, inventory.getStackInSlot(i),
PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)), wear));
BeeManager.beeRoot.getMember(inventory.getStackInSlot(SLOT_QUEEN)), wear));
}
}
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.io.IOException;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
@@ -20,6 +23,7 @@ import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
@@ -28,67 +32,43 @@ import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.network.PacketActiveUpdate;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.ForestryItem;
import forestry.core.gadgets.TileBase;
import forestry.core.gadgets.TileForestry;
import forestry.core.interfaces.IActivatable;
import forestry.core.interfaces.IClimatised;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketInventoryStack;
import forestry.core.network.PacketTileUpdate;
import forestry.core.proxy.Proxies;
import forestry.core.utils.GuiUtil;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
protected static class BeehouseInventoryAdapter extends TileInventoryAdapter {
public BeehouseInventoryAdapter(TileForestry tile, int size, String name) {
super(tile, size, name);
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack);
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
return itemStack.getItem() instanceof IHiveFrame;
} else if (slotIndex == SLOT_DRONE) {
return PluginApiculture.beeInterface.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
}
}
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, IActivatable {
// CONSTANTS
public static final int SLOT_QUEEN = 0;
public static final int SLOT_DRONE = 1;
public static final int SLOT_PRODUCT_1 = 2;
public static final int SLOT_PRODUCT_COUNT = 7;
public static final int SLOT_FRAMES_1 = 9;
public static final int SLOT_FRAMES_2 = 10;
public static final int SLOT_FRAMES_3 = 11;
public static final int SLOT_FRAMES_COUNT = 3;
private final IBeekeepingLogic logic;
private BiomeGenBase biome;
// CLIENT
private boolean active;
private int displayHealthMax = 0;
private int displayHealth = 0;
private IBee displayQueen;
public TileBeehouse() {
setHints(Config.hints.get("apiary"));
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
logic = BeeManager.beeRoot.createBeekeepingLogic(this);
setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items").disableAutomation());
}
@@ -115,7 +95,26 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
int biomeId = nbttagcompound.getInteger("BiomeId");
biome = BiomeGenBase.getBiome(biomeId);
logic.readFromNBT(nbttagcompound);
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(active);
if (active) {
ItemStack queen = getStackInSlot(SLOT_QUEEN);
data.writeItemStack(queen);
}
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
active = data.readBoolean();
if (active) {
ItemStack queen = data.readItemStack();
setInventorySlotContents(SLOT_QUEEN, queen);
}
}
@Override
@@ -137,7 +136,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
@Override
public EnumTemperature getTemperature() {
return EnumTemperature.getFromBiome(biome);
return EnumTemperature.getFromBiome(biome, xCoord, yCoord, zCoord);
}
@Override
@@ -145,9 +144,29 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
return EnumHumidity.getFromValue(getExactHumidity());
}
@Deprecated
@Override
public void setErrorState(IErrorState state) {
removeErrorStates();
if (state != EnumErrorCode.OK) {
addErrorState(state);
}
}
@Deprecated
@Override
public IErrorState getErrorState() {
Set<IErrorState> errorStates = getErrorStates();
if (errorStates.size() == 0) {
return EnumErrorCode.OK;
} else {
return getErrorStates().iterator().next();
}
}
@Override
public float getExactTemperature() {
return biome.temperature;
return biome.getFloatTemperature(xCoord, yCoord, zCoord);
}
@Override
@@ -158,36 +177,36 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* UPDATING */
@Override
public void updateClientSide() {
if (isActive() && (displayQueen != null) && updateOnInterval(4)) {
displayQueen.doFX(logic.getEffectData(), this);
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) {
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
displayQueen.doFX(logic.getEffectData(), this);
if (updateOnInterval(50)) {
float fxX = xCoord + 0.5F;
float fxY = yCoord + 0.25F + (worldObj.rand.nextFloat() * 6F) / 16F;
float fxZ = zCoord + 0.5F;
float f3 = 0.6F;
float f4 = worldObj.rand.nextFloat() * f3 - 0.5F;
Proxies.common.addEntitySwarmFX(worldObj, (fxX - f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f3), fxY, (fxZ + f4), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ - f3), 0F, 0F, 0F);
Proxies.common.addEntitySwarmFX(worldObj, (fxX + f4), fxY, (fxZ + f3), 0F, 0F, 0F);
}
}
}
@Override
public void updateServerSide() {
logic.update();
IBee queen = logic.getQueen();
if (queen == null) {
return;
}
// Add swarm effects
if (updateOnInterval(200)) {
onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN));
boolean canWork = logic.canWork();
setActive(canWork);
if (canWork) {
logic.doWork();
}
}
// @Override
public boolean isWorking() {
return getErrorState() == EnumErrorCode.OK;
return !hasErrorState();
}
@Override
@@ -198,43 +217,30 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* NETWORK SYNCH */
@Override
public void onQueenChange(ItemStack queenStack) {
if (!Proxies.common.isSimulating(worldObj)) {
return;
}
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
Proxies.net.sendNetworkPacket(new PacketTileUpdate(this), xCoord, yCoord, zCoord);
}
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
if (displayQueen == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealth;
if (displayQueen.getMate() != null) {
return displayQueen.getHealth();
} else {
return 0;
return displayHealth;
}
}
private int getMaxHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
if (displayQueen == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealthMax;
if (displayQueen.getMate() != null) {
return displayQueen.getMaxHealth();
} else {
return 0;
return displayHealthMax;
}
}
@@ -249,20 +255,11 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
public int getTemperatureScaled(int i) {
return Math.round(i * (getExactTemperature() / 2));
}
public int getHumidityScaled(int i) {
return Math.round(i * getExactHumidity());
}
public void updateBiome() {
if (worldObj != null) {
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
if (biome != null) {
this.biome = biome;
setErrorState(EnumErrorCode.OK);
}
}
}
@@ -310,11 +307,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
return zCoord;
}
@Override
public int getBiomeId() {
return biome.biomeID;
}
@Override
public BiomeGenBase getBiome() {
return biome;
@@ -335,6 +327,30 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
setInventorySlotContents(SLOT_QUEEN, itemstack);
}
@Override
public ItemStack decrStackSize(int slotIndex, int amount) {
ItemStack itemStack = super.decrStackSize(slotIndex, amount);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
return itemStack;
}
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemStack) {
super.setInventorySlotContents(slotIndex, itemStack);
if (slotIndex == SLOT_QUEEN) {
handleQueenChange();
}
}
private void handleQueenChange() {
if (!Proxies.common.isSimulating(worldObj)) {
ItemStack itemStack = getStackInSlot(SLOT_QUEEN);
displayQueen = BeeManager.beeRoot.getMember(itemStack);
}
}
@Override
public void setDrone(ItemStack itemstack) {
setInventorySlotContents(SLOT_DRONE, itemstack);
@@ -345,16 +361,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
return worldObj;
}
@Override
public void setErrorState(int state) {
setErrorState(EnumErrorCode.values()[state]);
}
@Override
public int getErrorOrdinal() {
return getErrorState().getID();
}
@Override
public boolean canBreed() {
return true;
@@ -435,6 +441,46 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* IHousing */
@Override
public GameProfile getOwnerName() {
return this.getOwnerProfile();
return this.getOwner();
}
@Override
public boolean isActive() {
return active;
}
@Override
public void setActive(boolean active) {
if (this.active == active) {
return;
}
this.active = active;
if (!worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
protected static class BeehouseInventoryAdapter extends TileInventoryAdapter<TileBeehouse> {
public BeehouseInventoryAdapter(TileBeehouse tile, int size, String name) {
super(tile, size, name);
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_QUEEN) {
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
return itemStack.getItem() instanceof IHiveFrame;
} else if (slotIndex == SLOT_DRONE) {
return BeeManager.beeRoot.isDrone(itemStack);
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
}
}
}
@@ -11,13 +11,14 @@
package forestry.apiculture.gadgets;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import forestry.apiculture.network.PacketUpdateCandle;
public class TileCandle extends TileEntity {
private int colour;
private boolean lit;
// This is a non-ticking Tile Entity.
@Override
@@ -27,48 +28,49 @@ public class TileCandle extends TileEntity {
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbt);
PacketUpdateCandle updateCandle = new PacketUpdateCandle(this);
return updateCandle.getPacket();
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
public void onPacketUpdate(PacketUpdateCandle updateCandle) {
colour = updateCandle.getColour();
lit = updateCandle.isLit();
}
@Override
public void readFromNBT(NBTTagCompound tagRoot) {
super.readFromNBT(tagRoot);
this.setColour(tagRoot.getInteger("colour"));
colour = tagRoot.getInteger("colour");
lit = tagRoot.getBoolean("lit");
}
@Override
public void writeToNBT(NBTTagCompound tagRoot) {
super.writeToNBT(tagRoot);
tagRoot.setInteger("colour", this.colour);
tagRoot.setBoolean("lit", this.lit);
}
public boolean isLit() {
return lit;
}
public void setLit(boolean lit) {
this.lit = lit;
}
public int getColour() {
return this.colour;
return colour;
}
public void setColour(int value) {
this.colour = value;
}
public void setColour(int red, int green, int blue) {
this.colour = toIntColour(red, green, blue);
}
/*public void setColour(int[] cs) {
this.colour = toIntColour(cs[0], cs[1], cs[2]);
}*/
public void addColour(int red, int green, int blue) {
public void addColour(int colour2) {
int[] myColour = fromIntColour(this.colour);
this.colour = toIntColour((red + myColour[0]) / 2, (green + myColour[0]) / 2, (blue + myColour[2]) / 2);
int[] addColour = fromIntColour(colour2);
this.colour = toIntColour((addColour[0] + myColour[0]) / 2, (addColour[0] + myColour[0]) / 2, (addColour[2] + myColour[2]) / 2);
}
private static int[] fromIntColour(int value) {
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
@@ -25,85 +26,102 @@ import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeIconProvider;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.core.IIconProvider;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.core.config.Defaults;
import forestry.core.genetics.AlleleSpecies;
import forestry.core.genetics.alleles.AlleleSpecies;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies, IIconProvider {
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpeciesCustom {
public IJubilanceProvider jubilanceProvider;
@Deprecated
private final Map<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
@Deprecated
private final Map<ItemStack, Integer> specialty = new HashMap<ItemStack, Integer>();
private final IBeeRoot root;
private final Map<ItemStack, Float> productChances = new HashMap<ItemStack, Float>();
private final Map<ItemStack, Float> specialtyChances = new HashMap<ItemStack, Float>();
private final HashMap<ItemStack, Integer> products = new HashMap<ItemStack, Integer>();
private final HashMap<ItemStack, Integer> specialty = new HashMap<ItemStack, Integer>();
private String texture;
private final int primaryColour;
private final int secondaryColour;
private static final String iconType = "default";
private IBeeIconProvider beeIconProvider;
private IJubilanceProvider jubilanceProvider;
private boolean nocturnal = false;
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, int primaryColor, int secondaryColor) {
this(uid, dominant, name, branch, null, primaryColor, secondaryColor);
}
public AlleleBeeSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, false);
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
this(uid, dominant, name, branch, binomial, primaryColor, secondaryColor, new JubilanceDefault());
}
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, String binomial, int primaryColor, int secondaryColor,
IJubilanceProvider jubilanceProvider) {
super(uid, dominant, name, branch, binomial);
this.root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
this.primaryColour = primaryColor;
this.secondaryColour = secondaryColor;
this.jubilanceProvider = jubilanceProvider;
texture = Defaults.TEXTURE_PATH_ENTITIES + "/bees/honeyBee.png";
setCustomBeeIconProvider(DefaultBeeIconProvider.getInstance());
setJubilanceProvider(JubilanceDefault.getInstance());
}
@Override
public IBeeRoot getRoot() {
return root;
return BeeManager.beeRoot;
}
public AlleleBeeSpecies setEntityTexture(String texture) {
this.texture = Defaults.TEXTURE_PATH_ENTITIES + "/bees/" + texture + ".png";
return this;
}
public AlleleBeeSpecies addProduct(ItemStack product, int chance) {
@Override
public IAlleleBeeSpeciesCustom addProduct(ItemStack product, Float chance) {
if (product == null || product.getItem() == null) {
throw new IllegalArgumentException("Tried to add null product");
}
this.products.put(product, chance);
if (chance <= 0.0f || chance > 1.0f) {
throw new IllegalArgumentException("chance must be in the range (0, 1]");
}
this.productChances.put(product, chance);
int intChance = Math.max(1, Math.round(chance * 100));
this.products.put(product, intChance);
return this;
}
public AlleleBeeSpecies addSpecialty(ItemStack specialty, int chance) {
this.specialty.put(specialty, chance);
@Override
public IAlleleBeeSpeciesCustom addSpecialty(ItemStack specialty, Float chance) {
if (specialty == null || specialty.getItem() == null) {
throw new IllegalArgumentException("Tried to add null specialty");
}
if (chance <= 0.0f || chance > 1.0f) {
throw new IllegalArgumentException("chance must be in the range (0, 1]");
}
this.specialtyChances.put(specialty, chance);
int intChance = Math.max(1, Math.round(chance * 100));
this.specialty.put(specialty, intChance);
return this;
}
public AlleleBeeSpecies setJubilanceProvider(IJubilanceProvider provider) {
@Override
public IAlleleBeeSpeciesCustom setJubilanceProvider(IJubilanceProvider provider) {
this.jubilanceProvider = provider;
return this;
}
@Override
public IAlleleBeeSpeciesCustom setNocturnal() {
nocturnal = true;
return this;
}
@Override
public IAlleleBeeSpeciesCustom setCustomBeeIconProvider(IBeeIconProvider beeIconProvider) {
this.beeIconProvider = beeIconProvider;
return this;
}
/* RESEARCH */
@Override
public int getComplexity() {
@@ -140,12 +158,12 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
return 0f;
}
for (ItemStack stack : products.keySet()) {
for (ItemStack stack : productChances.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
}
for (ItemStack stack : specialty.keySet()) {
for (ItemStack stack : specialtyChances.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
@@ -160,11 +178,11 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
if (bountyLevel > 10) {
for (ItemStack stack : specialty.keySet()) {
for (ItemStack stack : specialtyChances.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
}
for (ItemStack stack : products.keySet()) {
for (ItemStack stack : productChances.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
return bounty.toArray(new ItemStack[bounty.size()]);
@@ -173,27 +191,43 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
/* OTHER */
@Override
public boolean isNocturnal() {
return false;
return nocturnal;
}
@Override
public HashMap<ItemStack, Integer> getProducts() {
public Map<ItemStack, Integer> getProducts() {
return products;
}
@Override
public HashMap<ItemStack, Integer> getSpecialty() {
public Map<ItemStack, Float> getProductChances() {
return productChances;
}
@Override
public Map<ItemStack, Integer> getSpecialty() {
return specialty;
}
@Override
public Map<ItemStack, Float> getSpecialtyChances() {
return specialtyChances;
}
@Override
public boolean isJubilant(IBeeGenome genome, IBeeHousing housing) {
return jubilanceProvider.isJubilant(this, genome, housing);
}
@Override
public String getEntityTexture() {
return texture;
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return new BeeIconProviderWrapper(beeIconProvider);
}
@Override
public IIcon getIcon(EnumBeeType type, int renderPass) {
return beeIconProvider.getIcon(type, renderPass);
}
@Override
@@ -207,45 +241,69 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
return 0xffffff;
}
@SideOnly(Side.CLIENT)
private static IIcon[][] icons;
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
icons = new IIcon[EnumBeeType.values().length][3];
IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
if (EnumBeeType.values()[i] == EnumBeeType.NONE) {
continue;
}
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
: TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body");
icons[i][2] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body2");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(EnumBeeType type, int renderPass) {
return icons[type.ordinal()][renderPass];
}
@Override
@SideOnly(Side.CLIENT)
public IIconProvider getIconProvider() {
return this;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(short texUID) {
public String getEntityTexture() {
return null;
}
private static class DefaultBeeIconProvider implements IBeeIconProvider {
private static final String iconType = "default";
private static DefaultBeeIconProvider instance;
public static DefaultBeeIconProvider getInstance() {
if (instance == null) {
instance = new DefaultBeeIconProvider();
}
return instance;
}
private DefaultBeeIconProvider() {
}
private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3];
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
if (EnumBeeType.values()[i] == EnumBeeType.NONE) {
continue;
}
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
: TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body");
icons[i][2] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + '/' + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body2");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(EnumBeeType type, int renderPass) {
return icons[type.ordinal()][renderPass];
}
}
private static class BeeIconProviderWrapper implements IIconProvider {
private final IBeeIconProvider beeIconProvider;
public BeeIconProviderWrapper(IBeeIconProvider beeIconProvider) {
this.beeIconProvider = beeIconProvider;
}
@Override
public IIcon getIcon(short texUID) {
return null;
}
@Override
public void registerIcons(IIconRegister register) {
beeIconProvider.registerIcons(register);
}
}
}
@@ -27,8 +27,8 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
public static final DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
public AlleleEffectAggressive(String uid) {
super(uid, "aggressive", true, 40, false, false);
public AlleleEffectAggressive() {
super("aggressive", true, 40, false, false);
}
@Override
@@ -29,8 +29,8 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
private final byte indexExplosionTimer = 1;
private final byte indexExplosionForce = 2;
public AlleleEffectCreeper(String uid) {
super(uid, "creeper", true, 20, false, true);
public AlleleEffectCreeper() {
super("creeper", true, 20, false, true);
}
@Override
@@ -21,8 +21,8 @@ import forestry.api.genetics.IEffectData;
public class AlleleEffectExploration extends AlleleEffectThrottled {
public AlleleEffectExploration(String uid) {
super(uid, "exploration", false, 80, true, false);
public AlleleEffectExploration() {
super("exploration", false, 80, true, false);
}
@Override
@@ -13,8 +13,8 @@ public class AlleleEffectFertile extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 5;
public AlleleEffectFertile(String uid) {
super(uid, "fertile", false, 6, true, false);
public AlleleEffectFertile() {
super("fertile", false, 6, true, false);
}
@Override
@@ -21,8 +21,8 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 10;
public static final int ENTITY_THROTTLE = 6;
public AlleleEffectFungification(String uid) {
super(uid, "mycophilic", true, 10, false, false);
public AlleleEffectFungification() {
super("mycophilic", true, 10, false, false);
}
@Override
@@ -24,8 +24,8 @@ import forestry.core.vect.Vect;
public class AlleleEffectGlacial extends AlleleEffectThrottled {
public AlleleEffectGlacial(String uid) {
super(uid, "glacial", false, 200, true, false);
public AlleleEffectGlacial() {
super("glacial", false, 200, true, false);
}
@Override
@@ -37,7 +37,7 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
EnumTemperature temp = housing.getTemperature();
switch (temp) {
case HELLISH:
@@ -22,8 +22,8 @@ import forestry.api.genetics.IEffectData;
public class AlleleEffectHeroic extends AlleleEffectThrottled {
public AlleleEffectHeroic(String uid) {
super(uid, "heroic", false, 40, true, false);
public AlleleEffectHeroic() {
super("heroic", false, 40, true, false);
}
@Override
@@ -28,8 +28,8 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
private static final int ignitionChance = 50;
private static final int fireDuration = 500;
public AlleleEffectIgnition(String uid) {
super(uid, "ignition", false, 20, false, true);
public AlleleEffectIgnition() {
super("ignition", false, 20, false, true);
}
@Override
@@ -28,8 +28,8 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
private static final int infectionChance = 50;
public AlleleEffectMiasmic(String uid) {
super(uid, "misasmic", false, 50, false, false);
public AlleleEffectMiasmic() {
super("miasmic", false, 50, false, false);
}
@Override
@@ -26,8 +26,8 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
public static final DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
public AlleleEffectMisanthrope(String uid) {
super(uid, "misanthrope", true, 20, false, false);
public AlleleEffectMisanthrope() {
super("misanthrope", true, 20, false, false);
}
@Override
@@ -10,19 +10,17 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.world.World;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.Allele;
import forestry.core.genetics.alleles.AlleleCategorized;
import forestry.plugins.PluginApiculture;
public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
public class AlleleEffectNone extends AlleleCategorized implements IAlleleBeeEffect {
public AlleleEffectNone(String uid) {
super(uid, true);
public AlleleEffectNone(String name) {
super("forestry", "effect", name, true);
}
@Override
@@ -37,18 +35,9 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
return doEffect(genome, storedData, housing.getWorld(), housing.getBiomeId(), housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
}
protected IEffectData doEffect(IBeeGenome genome, IEffectData storedData, World world, int biomeid, int x, int y, int z) {
return storedData;
}
@Override
public String getUnlocalizedName() {
return "apiculture.effect.none";
}
@Override
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
@@ -31,8 +31,8 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
private final boolean isBadEffect;
private final int duration;
public AlleleEffectPotion(String uid, String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) {
super(uid, name, isDominant, 200, requiresWorking, false);
public AlleleEffectPotion(String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) {
super(name, isDominant, 200, requiresWorking, false);
this.potion = potion;
this.isBadEffect = isBadEffect(potion);
this.duration = duration;
@@ -34,8 +34,8 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
public static final DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
public AlleleEffectRadioactive(String uid) {
super(uid, "radioactive", true, 40, false, true);
public AlleleEffectRadioactive() {
super("radioactive", true, 40, false, true);
}
@Override
@@ -22,8 +22,8 @@ import forestry.api.genetics.IEffectData;
public class AlleleEffectRepulsion extends AlleleEffectThrottled {
public AlleleEffectRepulsion(String uid) {
super(uid, "repulsion", false, 100, true, true);
public AlleleEffectRepulsion() {
super("repulsion", false, 100, true, true);
}
@Override
@@ -72,8 +72,8 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
private final List<Resurrectable> resurrectables;
public AlleleEffectResurrection(String uid, String name, List<Resurrectable> resurrectables) {
super(uid, name, true, 40, true, true);
public AlleleEffectResurrection(String name, List<Resurrectable> resurrectables) {
super(name, true, 40, true, true);
this.resurrectables = resurrectables;
}
@@ -25,8 +25,8 @@ import forestry.core.vect.Vect;
public class AlleleEffectSnowing extends AlleleEffectThrottled {
public AlleleEffectSnowing(String uid) {
super(uid, "snowing", false, 20, true, true);
public AlleleEffectSnowing() {
super("snowing", false, 20, true, true);
}
@Override
@@ -38,7 +38,7 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
EnumTemperature temp = housing.getTemperature();
switch (temp) {
case HELLISH:
@@ -17,20 +17,19 @@ import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.EnumErrorCode;
import forestry.core.genetics.Allele;
import forestry.core.genetics.EffectData;
import forestry.core.genetics.alleles.AlleleCategorized;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect {
public abstract class AlleleEffectThrottled extends AlleleCategorized implements IAlleleBeeEffect {
private boolean isCombinable = false;
private final int throttle;
private boolean requiresWorkingQueen = false;
public AlleleEffectThrottled(String uid, String name, boolean isDominant, int throttle, boolean requiresWorking, boolean isCombinable) {
super(uid, isDominant);
this.name = "apiculture.effect." + name;
public AlleleEffectThrottled(String name, boolean isDominant, int throttle, boolean requiresWorking, boolean isCombinable) {
super("forestry", "effect", name, isDominant);
this.throttle = throttle;
this.isCombinable = isCombinable;
this.requiresWorkingQueen = requiresWorking;
@@ -12,18 +12,14 @@ package forestry.apiculture.genetics;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IFlowerProvider;
import forestry.core.genetics.Allele;
import forestry.core.genetics.alleles.AlleleCategorized;
public class AlleleFlowers extends Allele implements IAlleleFlowers {
public class AlleleFlowers extends AlleleCategorized implements IAlleleFlowers {
private final IFlowerProvider provider;
public AlleleFlowers(String uid, IFlowerProvider provider) {
this(uid, provider, false);
}
public AlleleFlowers(String uid, IFlowerProvider provider, boolean isDominant) {
super(uid, isDominant);
public AlleleFlowers(String modId, String category, String name, IFlowerProvider provider, boolean isDominant) {
super(modId, category, name, isDominant);
this.provider = provider;
}
@@ -15,12 +15,12 @@ import net.minecraft.nbt.NBTTagCompound;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IIndividual;
import forestry.core.genetics.BreedingTracker;
import forestry.plugins.PluginApiculture;
public class ApiaristTracker extends BreedingTracker implements IApiaristTracker {
@@ -67,7 +67,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) {
return;
}
if (PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0) {
if (BeeManager.beeRoot.getCombinations(individual.getGenome().getPrimary()).size() > 0) {
return;
}
@@ -109,7 +109,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
@Override
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile());
return BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile());
}
@Override
@@ -11,6 +11,7 @@
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -24,6 +25,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -36,13 +38,13 @@ import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorState;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.arboriculture.genetics.FakePollinatable;
@@ -57,7 +59,6 @@ import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.StringUtil;
import forestry.core.vect.MutableVect;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
public class Bee extends IndividualLiving implements IBee {
@@ -93,7 +94,7 @@ public class Bee extends IndividualLiving implements IBee {
public void readFromNBT(NBTTagCompound nbttagcompound) {
if (nbttagcompound == null) {
this.genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
genome = BeeDefinition.FOREST.getGenome();
return;
}
@@ -110,7 +111,7 @@ public class Bee extends IndividualLiving implements IBee {
if (nbttagcompound.hasKey("Genome")) {
genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome"));
} else {
genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
genome = BeeDefinition.FOREST.getGenome();
}
if (nbttagcompound.hasKey("Mate")) {
@@ -137,11 +138,6 @@ public class Bee extends IndividualLiving implements IBee {
this.isNatural = flag;
}
@Override
public boolean isIrregularMating() {
return false;
}
public boolean isNatural() {
return this.isNatural;
}
@@ -245,52 +241,56 @@ public class Bee extends IndividualLiving implements IBee {
}
@Override
public int isWorking(IBeeHousing housing) {
return canWork(housing).ordinal();
}
@Override
public EnumErrorCode canWork(IBeeHousing housing) {
public Set<IErrorState> getCanWork(IBeeHousing housing) {
World world = housing.getWorld();
BiomeGenBase biome = housing.getBiome();
Set<IErrorState> errorStates = new HashSet<IErrorState>();
// / Rain needs tolerant flyers
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(housing.getBiomeId()) && !housing.isSealed()) {
return EnumErrorCode.ISRAINING;
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(biome) && !housing.isSealed()) {
errorStates.add(EnumErrorCode.ISRAINING);
}
// / Night or darkness requires nocturnal species
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTNIGHT;
errorStates.add(EnumErrorCode.NOTNIGHT);
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTDAY;
errorStates.add(EnumErrorCode.NOTDAY);
}
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTGLOOMY;
errorStates.add(EnumErrorCode.NOTGLOOMY);
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTLUCID;
errorStates.add(EnumErrorCode.NOTLUCID);
}
// / No sky, except if in hell
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if (biome == null) {
return EnumErrorCode.NOSKY;
}
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
return EnumErrorCode.NOSKY;
if (biome != null && !BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
errorStates.add(EnumErrorCode.NOSKY);
}
// / And finally climate check
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
return EnumErrorCode.INVALIDBIOME;
errorStates.add(EnumErrorCode.INVALIDBIOME);
}
return EnumErrorCode.OK;
return errorStates;
}
@Override
public IErrorState canWork(IBeeHousing housing) {
Set<IErrorState> errorStates = getCanWork(housing);
if (errorStates.size() == 0) {
return EnumErrorCode.OK;
} else {
return errorStates.iterator().next();
}
}
private boolean canWorkAtNight() {
@@ -343,18 +343,6 @@ public class Bee extends IndividualLiving implements IBee {
return hasFlower;
}
@Override
public ArrayList<Integer> getSuitableBiomeIds() {
ArrayList<Integer> suitableBiomes = new ArrayList<Integer>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (isSuitableBiome(biome)) {
suitableBiomes.add(biome.biomeID);
}
}
return suitableBiomes;
}
@Override
public ArrayList<BiomeGenBase> getSuitableBiomes() {
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
@@ -403,15 +391,15 @@ public class Bee extends IndividualLiving implements IBee {
IAlleleTolerance tempToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance humidToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", "");
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceAll("(.*)\\.", "");
String speed;
if (StringUtil.canTranslate(unlocalizedCustomSpeed)) {
speed = StringUtil.localize(unlocalizedCustomSpeed);
} else {
speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker");
speed = speedAllele.getName() + ' ' + StringUtil.localize("gui.worker");
}
String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life");
String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + ' ' + StringUtil.localize("gui.life");
String tempTolerance = EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempToleranceAllele.getName();
String humidTolerance = EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidToleranceAllele.getName();
String flowers = genome.getFlowerProvider().getDescription();
@@ -425,11 +413,15 @@ public class Bee extends IndividualLiving implements IBee {
if (genome.getNocturnal()) {
list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
}
if (genome.getTolerantFlyer()) {
list.add(EnumChatFormatting.WHITE + StringUtil.localize("gui.flyer.tooltip"));
}
}
@Override
public void age(World world, float housingLifespanModifier) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
float finalModifier = housingLifespanModifier * mode.getLifespanModifier(genome, mate, housingLifespanModifier);
super.age(world, finalModifier);
@@ -474,21 +466,17 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ItemStack[] produceStacks(IBeeHousing housing) {
if (!hasFlower(housing)) {
return null;
}
if (housing == null) {
Proxies.log.warning("Failed to produce in an apiary because the beehousing was null.");
return null;
}
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld());
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(housing.getWorld());
if (mode == null) {
Proxies.log.warning("Failed to produce in an apiary because the beekeeping mode was null.");
return null;
}
ArrayList<ItemStack> products = new ArrayList<ItemStack>();
List<ItemStack> products = new ArrayList<ItemStack>();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
@@ -514,20 +502,17 @@ public class Bee extends IndividualLiving implements IBee {
}
}
// We are done if the we are not jubilant.
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing)) {
return products.toArray(new ItemStack[products.size()]);
}
// / Specialty products
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
if (primary.isJubilant(genome, housing) && secondary.isJubilant(genome, housing)) {
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
}
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
products.toArray(new ItemStack[products.size()]));
ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), productsArray);
}
/* REPRODUCTION */
@@ -540,7 +525,7 @@ public class Bee extends IndividualLiving implements IBee {
}
// Fatigued queens do not produce princesses.
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) {
if (BeeManager.beeRoot.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) {
return null;
}
@@ -559,7 +544,7 @@ public class Bee extends IndividualLiving implements IBee {
ArrayList<IBee> bees = new ArrayList<IBee>();
int toCreate = PluginApiculture.beeInterface.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(),
int toCreate = BeeManager.beeRoot.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(),
housing.getZCoord());
if (toCreate <= 0) {
@@ -606,19 +591,19 @@ public class Bee extends IndividualLiving implements IBee {
}
}
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
}
private IChromosome[] mutateSpecies(IBeeHousing housing, IGenome genomeOne, IGenome genomeTwo) {
private static IChromosome[] mutateSpecies(IBeeHousing housing, IBeeGenome genomeOne, IBeeGenome genomeTwo) {
World world = housing.getWorld();
IChromosome[] parent1 = genomeOne.getChromosomes();
IChromosome[] parent2 = genomeTwo.getChromosomes();
IGenome genome0;
IGenome genome1;
IBeeGenome genome0;
IBeeGenome genome1;
IAllele allele0;
IAllele allele1;
@@ -636,12 +621,12 @@ public class Bee extends IndividualLiving implements IBee {
genome1 = genomeOne;
}
for (IBeeMutation mutation : PluginApiculture.beeInterface.getMutations(true)) {
for (IBeeMutation mutation : BeeManager.beeRoot.getMutations(true)) {
float chance = mutation.getChance(housing, allele0, allele1, genome0, genome1);
if (chance > world.rand.nextFloat() * 100) {
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
IApiaristTracker breedingTracker = BeeManager.beeRoot.getBreedingTracker(world, housing.getOwnerName());
breedingTracker.registerMutation(mutation);
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
return BeeManager.beeRoot.templateAsChromosomes(mutation.getTemplate());
}
}
@@ -0,0 +1,155 @@
package forestry.apiculture.genetics;
import java.util.Arrays;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
import forestry.core.genetics.alleles.Allele;
import forestry.core.genetics.alleles.EnumAllele;
public enum BeeBranchDefinition {
HONEY("Apis"),
NOBLE("Probapis"),
INDUSTRIOUS("Industrapis"),
HEROIC("Herapis"),
INFERNAL("Diapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.DOWN_2);
Allele.helper.set(alleles, EnumBeeChromosome.NOCTURNAL, true);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.NETHER);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.AVERAGE);
}
},
AUSTERE("Modapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.DOWN_1);
Allele.helper.set(alleles, EnumBeeChromosome.NOCTURNAL, true);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.CACTI);
}
},
TROPICAL("Caldapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.JUNGLE);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectMiasmic);
}
},
END("Finapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.END);
Allele.helper.set(alleles, EnumBeeChromosome.NOCTURNAL, true);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectMisanthrope);
}
},
FROZEN("Coagapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.SNOW);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectGlacial);
}
},
VENGEFUL("Punapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGEST);
Allele.helper.set(alleles, EnumBeeChromosome.EFFECT, Allele.effectRadioactive);
}
},
FESTIVE("Festapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
}
},
AGRARIAN("Rustapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
}
},
BOGGY("Paludapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.MUSHROOMS);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
}
},
MONASTIC("Monapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
Allele.helper.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
Allele.helper.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
Allele.helper.set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
Allele.helper.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
Allele.helper.set(alleles, EnumBeeChromosome.CAVE_DWELLING, true);
Allele.helper.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
}
}
;
private final IClassification branch;
BeeBranchDefinition(String scientific) {
branch = BeeManager.beeFactory.createBranch(this.name().toLowerCase(), scientific);
}
protected void setBranchProperties(IAllele[] template) {
}
public final IAllele[] getTemplate() {
IAllele[] template = getDefaultTemplate();
setBranchProperties(template);
return template;
}
public final IClassification getBranch() {
return branch;
}
private static IAllele[] defaultTemplate;
private static IAllele[] getDefaultTemplate() {
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
Allele.helper.set(defaultTemplate, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.NORMAL);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.NONE);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.NOCTURNAL, false);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.NONE);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.TOLERANT_FLYER, false);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.CAVE_DWELLING, false);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.VANILLA);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWEST);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.AVERAGE);
Allele.helper.set(defaultTemplate, EnumBeeChromosome.EFFECT, Allele.effectNone);
}
return Arrays.copyOf(defaultTemplate, defaultTemplate.length);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
import forestry.api.apiculture.IBeeFactory;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IClassification;
public class BeeFactory implements IBeeFactory {
@Override
public IAlleleBeeSpeciesCustom createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
IAlleleBeeSpeciesCustom species = new AlleleBeeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor);
AlleleManager.alleleRegistry.registerAllele(species);
return species;
}
@Override
public IClassification createBranch(String uid, String scientific) {
return new BranchBees(uid, scientific);
}
}
@@ -12,25 +12,29 @@ package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleFloat;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.AlleleArea;
import forestry.core.genetics.AlleleBoolean;
import forestry.core.genetics.AlleleTolerance;
import forestry.core.genetics.Chromosome;
import forestry.core.genetics.Genome;
import forestry.core.genetics.alleles.AlleleArea;
import forestry.core.genetics.alleles.AlleleBoolean;
import forestry.core.genetics.alleles.AlleleTolerance;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
public class BeeGenome extends Genome implements IBeeGenome {
/**
@@ -73,12 +77,12 @@ public class BeeGenome extends Genome implements IBeeGenome {
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) speciesAllele;
} else {
return null;
IAlleleSpecies species = getSpeciesDirectly(itemStack);
if (species instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) species;
}
return (IAlleleBeeSpecies) getActiveAllele(itemStack, EnumBeeChromosome.SPECIES, BeeManager.beeRoot);
}
// / INFORMATION RETRIEVAL
@@ -155,6 +159,6 @@ public class BeeGenome extends Genome implements IBeeGenome {
@Override
public ISpeciesRoot getSpeciesRoot() {
return PluginApiculture.beeInterface;
return BeeManager.beeRoot;
}
}
@@ -25,6 +25,7 @@ import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -156,8 +157,8 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
return false;
}
IBee bee = getMember(stack);
return bee.getMate() != null;
NBTTagCompound nbt = stack.getTagCompound();
return nbt != null && nbt.hasKey("Mate");
}
@Override
@@ -215,13 +216,13 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public void registerTemplate(String identifier, IAllele[] template) {
beeTemplates.add(new Bee(PluginApiculture.beeInterface.templateAsGenome(template)));
beeTemplates.add(new Bee(BeeManager.beeRoot.templateAsGenome(template)));
speciesTemplates.put(identifier, template);
}
@Override
public IAllele[] getDefaultTemplate() {
return BeeTemplates.getDefaultTemplate();
return BeeDefinition.FOREST.getTemplate();
}
/* MUTATIONS */
@@ -10,124 +10,57 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.genetics.Mutation;
import forestry.plugins.PluginApiculture;
public class BeeMutation extends Mutation implements IBeeMutation {
public class BeeMutation extends Mutation implements IBeeMutationCustom {
private final IBeeRoot root;
boolean requiresDay = false;
boolean requiresNight = false;
private final ArrayList<BiomeDictionary.Type> restrictBiomeTypes = new ArrayList<BiomeDictionary.Type>();
private boolean strictBiomeCheck = false;
public BeeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) {
super(allele0, allele1, template, chance);
root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
PluginApiculture.beeInterface.registerMutation(this);
public BeeMutation(IAlleleBeeSpecies bee0, IAlleleBeeSpecies bee1, IAllele[] result, int chance) {
super(bee0, bee1, result, chance);
}
@Override
public IBeeRoot getRoot() {
return root;
}
public BeeMutation enableStrictBiomeCheck() {
strictBiomeCheck = true;
return this;
}
public BeeMutation restrictBiomeType(BiomeDictionary.Type type) {
restrictBiomeTypes.add(type);
specialConditions.add(String.format("Is restricted to %s-like environments.", type.toString()));
return this;
}
public BeeMutation requireDay() {
requiresDay = true;
requiresNight = false;
specialConditions.add("Can only occur during the day.");
return this;
}
public BeeMutation requireNight() {
requiresDay = false;
requiresNight = true;
specialConditions.add("Can only occur during the night.");
return this;
return BeeManager.beeRoot;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
return getChance(housing, (IAlleleBeeSpecies) allele0, (IAlleleBeeSpecies) allele1, (IBeeGenome) genome0, (IBeeGenome) genome1);
}
@Override
public float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1) {
World world = housing.getWorld();
if (requiresDay && !world.isDaytime()) {
return 0;
}
int x = housing.getXCoord();
int y = housing.getYCoord();
int z = housing.getZCoord();
if (requiresNight && world.isDaytime()) {
return 0;
}
// Skip if we are restricted by biomes and this one does not match.
if (restrictBiomeTypes.size() > 0) {
boolean noneMatched = true;
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if (strictBiomeCheck) {
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
if (types.length == 1 && restrictBiomeTypes.contains(types[0])) {
noneMatched = false;
}
} else {
for (BiomeDictionary.Type type : restrictBiomeTypes) {
if (BiomeDictionary.isBiomeOfType(biome, type)) {
noneMatched = false;
break;
}
}
}
if (noneMatched) {
return 0;
}
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(housing.getXCoord(), housing.getZCoord());
if (biome.temperature < minTemperature || biome.temperature > maxTemperature) {
return 0;
}
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) {
return 0;
}
float processedChance = chance * housing.getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f)
* PluginApiculture.beeInterface.getBeekeepingMode(world).getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f);
float processedChance = super.getChance(world, x, y, z, allele0, allele1, genome0, genome1);
if (processedChance <= 0) {
return 0;
}
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
processedChance *= housing.getMutationModifier(genome0, genome1, 1f);
processedChance *= BeeManager.beeRoot.getBeekeepingMode(world).getMutationModifier(genome0, genome1, 1f);
if (processedChance <= 0) {
return 0;
}
if (this.species0.getUID().equals(allele0.getUID()) && this.species1.getUID().equals(allele1.getUID())) {
return processedChance;
}
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
if (this.species1.getUID().equals(allele0.getUID()) && this.species0.getUID().equals(allele1.getUID())) {
return processedChance;
}
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutationFactory;
import forestry.api.genetics.IAllele;
public class BeeMutationFactory implements IBeeMutationFactory {
@Override
public IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance) {
IBeeMutationCustom mutation = new BeeMutation(parentBee0, parentBee1, result, chance);
BeeManager.beeRoot.registerMutation(mutation);
return mutation;
}
}
@@ -1,640 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.Arrays;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IMutation;
import forestry.core.genetics.Allele;
public class BeeTemplates {
// / MUTATIONS
public static IMutation commonA;
public static IMutation commonB;
public static IMutation commonC;
public static IMutation commonD;
public static IMutation commonE;
public static IMutation commonF;
public static IMutation commonG;
public static IMutation commonH;
public static IMutation commonI;
public static IMutation commonJ;
public static IMutation commonK;
public static IMutation commonL;
public static IMutation commonM;
public static IMutation commonN;
public static IMutation commonO;
public static IMutation cultivatedA;
public static IMutation cultivatedB;
public static IMutation cultivatedC;
public static IMutation cultivatedD;
public static IMutation cultivatedE;
public static IMutation cultivatedF;
public static IMutation nobleA;
public static IMutation majesticA;
public static IMutation imperialA;
public static IMutation diligentA;
public static IMutation unwearyA;
public static IMutation industriousA;
public static IMutation heroicA;
public static IMutation sinisterA;
public static IMutation sinisterB;
public static IMutation fiendishA;
public static IMutation fiendishB;
public static IMutation fiendishC;
public static IMutation demonicA;
// Austere branch
public static IMutation frugalA;
public static IMutation frugalB;
public static IMutation austereA;
// Tropical branch
public static IMutation exoticA;
public static IMutation edenicA;
// Wintry branch
public static IMutation icyA;
public static IMutation glacialA;
// Festive branch
public static IMutation leporineA;
public static IMutation merryA;
public static IMutation tipsyA;
public static IMutation trickyA;
// Agrarian branch
public static IMutation ruralA;
// Monastic branch
public static IMutation secludedA;
public static IMutation hermiticA;
// End branch
public static IMutation spectralA;
public static IMutation phantasmalA;
public static IMutation vindictiveA;
public static IMutation vengefulA;
public static IMutation vengefulB;
public static IMutation avengingA;
public static IAllele[] defaultTemplate;
public static IAllele[] getDefaultTemplate() {
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
defaultTemplate[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesForest;
defaultTemplate[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
defaultTemplate[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
defaultTemplate[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityNormal;
defaultTemplate[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceNone;
defaultTemplate[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolFalse;
defaultTemplate[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceNone;
defaultTemplate[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolFalse;
defaultTemplate[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolFalse;
defaultTemplate[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersVanilla;
defaultTemplate[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlowest;
defaultTemplate[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryDefault;
defaultTemplate[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectNone;
}
return Arrays.copyOf(defaultTemplate, defaultTemplate.length);
}
// / COMMON BRANCH
public static IAllele[] getForestTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityHigh;
return alleles;
}
public static IAllele[] getForestRainResistTemplate() {
IAllele[] alleles = getForestTemplate();
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getMeadowsTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMeadows;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
return alleles;
}
public static IAllele[] getCommonTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesCommon;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
return alleles;
}
public static IAllele[] getCultivatedTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesCultivated;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedFast;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShortest;
return alleles;
}
// / NOBLE BRANCH
public static IAllele[] getNobleTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesNoble;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlow;
return alleles;
}
public static IAllele[] getMajesticTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMajestic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShortened;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
return alleles;
}
public static IAllele[] getImperialTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesImperial;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectBeatific;
return alleles;
}
// / INDUSTRIOUS BRANCH
public static IAllele[] getDiligentTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesDiligent;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlow;
return alleles;
}
public static IAllele[] getUnwearyTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesUnweary;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShortened;
return alleles;
}
public static IAllele[] getIndustriousTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesIndustrious;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFast;
return alleles;
}
// / HEROIC BRANCH
public static IAllele[] getSteadfastTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSteadfast;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getValiantTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesValiant;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getHeroicTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesHeroic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectHeroic;
return alleles;
}
// / INFERNAL BRANCH
public static IAllele[] getBranchInfernalTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceDown2;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersNether;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringAverage;
return alleles;
}
public static IAllele[] getSinisterTemplate() {
IAllele[] alleles = getBranchInfernalTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSinister;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectAggressive;
return alleles;
}
public static IAllele[] getFiendishTemplate() {
IAllele[] alleles = getBranchInfernalTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFiendish;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectAggressive;
return alleles;
}
public static IAllele[] getDemonicTemplate() {
IAllele[] alleles = getBranchInfernalTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesDemonic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectIgnition;
return alleles;
}
// / AUSTERE BRANCH
public static IAllele[] getAustereBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersCacti;
return alleles;
}
public static IAllele[] getModestTemplate() {
IAllele[] alleles = getAustereBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesModest;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
public static IAllele[] getFrugalTemplate() {
IAllele[] alleles = getAustereBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFrugal;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
return alleles;
}
public static IAllele[] getAustereTemplate() {
IAllele[] alleles = getAustereBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesAustere;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceDown2;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectCreeper;
return alleles;
}
// / TROPICAL BRANCH
public static IAllele[] getTropicalBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersJungle;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMiasmic;
return alleles;
}
public static IAllele[] getTropicalTemplate() {
IAllele[] alleles = getTropicalBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesTropical;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
public static IAllele[] getExoticTemplate() {
IAllele[] alleles = getTropicalBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesExotic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
return alleles;
}
public static IAllele[] getEdenicTemplate() {
IAllele[] alleles = getTropicalBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesEdenic;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectExploration;
return alleles;
}
// / END BRANCH
public static IAllele[] getEndBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityLow;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersEnd;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMisanthrope;
return alleles;
}
public static IAllele[] getEnderTemplate() {
IAllele[] alleles = getEndBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesEnded;
return alleles;
}
public static IAllele[] getSpectralTemplate() {
IAllele[] alleles = getEndBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSpectral;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectReanimation;
return alleles;
}
public static IAllele[] getPhantasmalTemplate() {
IAllele[] alleles = getEndBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesPhantasmal;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLongest;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectResurrection;
return alleles;
}
// / FROZEN BRANCH
public static IAllele[] getFrozenBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersSnow;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectGlacial;
return alleles;
}
public static IAllele[] getWintryTemplate() {
IAllele[] alleles = getFrozenBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesWintry;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
return alleles;
}
public static IAllele[] getIcyTemplate() {
IAllele[] alleles = getFrozenBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesIcy;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
public static IAllele[] getGlacialTemplate() {
IAllele[] alleles = getFrozenBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesGlacial;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShort;
return alleles;
}
// / VENGEFUL BRANCH
public static IAllele[] getVengefulBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLargest;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectRadioactive;
return alleles;
}
public static IAllele[] getVindictiveTemplate() {
IAllele[] alleles = getVengefulBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesVindictive;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
return alleles;
}
public static IAllele[] getVengefulTemplate() {
IAllele[] alleles = getVengefulBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesVengeful;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedNorm;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLonger;
return alleles;
}
public static IAllele[] getAvengingTemplate() {
IAllele[] alleles = getVengefulBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesAvenging;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLongest;
return alleles;
}
// / REDDENED BRANCH
public static IAllele[] getReddenedBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
return alleles;
}
public static IAllele[] getDarkenedTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesDarkened;
return alleles;
}
public static IAllele[] getReddenedTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesReddened;
return alleles;
}
public static IAllele[] getOmegaTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesOmega;
return alleles;
}
// / FESTIVE BRANCH
public static IAllele[] getFestiveBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanNormal;
return alleles;
}
public static IAllele[] getLeporineTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesLeporine;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectFestiveEaster;
return alleles;
}
public static IAllele[] getMerryTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMerry;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectSnowing;
return alleles;
}
public static IAllele[] getTipsyTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesTipsy;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectDrunkard;
return alleles;
}
public static IAllele[] getTrickyTemplate() {
IAllele[] alleles = getFestiveBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesTricky;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersGourd;
return alleles;
}
// / AGRARIAN BRANCH
public static IAllele[] getAgrarianBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersWheat;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFaster;
return alleles;
}
public static IAllele[] getRuralTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesRural;
return alleles;
}
public static IAllele[] getFarmerlyTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFarmerly;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
return alleles;
}
public static IAllele[] getAgrarianTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesArgrarian;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectFertile;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
return alleles;
}
// / BOGGY BRANCH
public static IAllele[] getBoggyBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersMushrooms;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
return alleles;
}
public static IAllele[] getMarshyTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMarshy;
return alleles;
}
public static IAllele[] getMiryTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMiry;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getBoggyTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesBoggy;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger;
return alleles;
}
/* MONASTIC BRANCH */
public static IAllele[] getMonasticBranchTemplate() {
IAllele[] alleles = getDefaultTemplate();
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlower;
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanLong;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityLow;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFaster;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersWheat;
return alleles;
}
public static IAllele[] getMonasticTemplate() {
IAllele[] alleles = getMonasticBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMonastic;
return alleles;
}
public static IAllele[] getSecludedTemplate() {
IAllele[] alleles = getMonasticBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesSecluded;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFastest;
return alleles;
}
public static IAllele[] getHermiticTemplate() {
IAllele[] alleles = getMonasticBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesHermitic;
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringFastest;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectRepulsion;
return alleles;
}
}
@@ -0,0 +1,57 @@
package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.IAllele;
import forestry.core.genetics.alleles.Allele;
public abstract class BeeVariation implements IBeeDefinition {
private final IAllele[] template;
private final IBeeGenome genome;
public BeeVariation(IBeeDefinition bee) {
template = bee.getTemplate();
initializeTemplate(template);
genome = BeeManager.beeRoot.templateAsGenome(template);
}
protected abstract void initializeTemplate(IAllele[] template);
@Override
public IAllele[] getTemplate() {
return template;
}
@Override
public IBeeGenome getGenome() {
return genome;
}
@Override
public IBee getIndividual() {
return new Bee(genome);
}
@Override
public final ItemStack getMemberStack(EnumBeeType beeType) {
IBee bee = getIndividual();
return BeeManager.beeRoot.getMemberStack(bee, beeType.ordinal());
}
public static class RainResist extends BeeVariation {
public RainResist(IBeeDefinition bee) {
super(bee);
}
@Override
protected void initializeTemplate(IAllele[] template) {
Allele.helper.set(template, EnumBeeChromosome.TOLERANT_FLYER, true);
}
}
}
@@ -12,25 +12,25 @@ package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.genetics.IAllele;
import forestry.plugins.PluginApiculture;
public class HiveDrop implements IHiveDrop {
private final IAllele[] template;
private final IBeeDefinition beeTemplate;
private final ArrayList<ItemStack> additional = new ArrayList<ItemStack>();
private final int chance;
private float ignobleShare = 0.0f;
public HiveDrop(IAllele[] template, ItemStack[] bonus, int chance) {
this.template = template;
public HiveDrop(int chance, IBeeDefinition beeTemplate, ItemStack... bonus) {
this.beeTemplate = beeTemplate;
this.chance = chance;
Collections.addAll(this.additional, bonus);
@@ -41,25 +41,20 @@ public class HiveDrop implements IHiveDrop {
return this;
}
private IBee createBee(World world) {
return PluginApiculture.beeInterface.getBee(world, PluginApiculture.beeInterface.templateAsGenome(template));
}
@Override
public ItemStack getPrincess(World world, int x, int y, int z, int fortune) {
IBee bee = createBee(world);
IBee bee = beeTemplate.getIndividual();
if (world.rand.nextFloat() < ignobleShare) {
bee.setIsNatural(false);
}
return PluginApiculture.beeInterface.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal());
return BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal());
}
@Override
public ArrayList<ItemStack> getDrones(World world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(PluginApiculture.beeInterface.getMemberStack(createBee(world), EnumBeeType.DRONE.ordinal()));
return ret;
public List<ItemStack> getDrones(World world, int x, int y, int z, int fortune) {
ItemStack drone = beeTemplate.getMemberStack(EnumBeeType.DRONE);
return Collections.singletonList(drone);
}
@Override
@@ -0,0 +1,18 @@
package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.core.genetics.IGeneticDefinition;
public interface IBeeDefinition extends IGeneticDefinition {
@Override
IBeeGenome getGenome();
@Override
IBee getIndividual();
ItemStack getMemberStack(EnumBeeType beeType);
}
@@ -10,39 +10,34 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.vect.Vect;
public class JubilanceDefault implements IJubilanceProvider {
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
private static JubilanceDefault instance;
if (EnumTemperature.getFromValue(biome.temperature) != species.getTemperature() ||
EnumHumidity.getFromValue(biome.rainfall) != species.getHumidity()) {
return false;
public static JubilanceDefault getInstance() {
if (instance == null) {
instance = new JubilanceDefault();
}
return true;
return instance;
}
protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
protected JubilanceDefault() {
Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
}
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
EnumTemperature temperature = housing.getTemperature();
EnumHumidity humidity = housing.getHumidity();
return temperature == species.getTemperature() && humidity == species.getHumidity();
}
}
@@ -1,19 +1,28 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
public interface IJubilanceProvider {
boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing);
}
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import forestry.api.apiculture.IJubilanceFactory;
import forestry.api.apiculture.IJubilanceProvider;
public class JubilanceFactory implements IJubilanceFactory {
@Override
public IJubilanceProvider getDefault() {
return JubilanceDefault.getInstance();
}
@Override
public IJubilanceProvider getRequiresResource(Block block, int meta) {
return new JubilanceRequiresResource(block, meta);
}
}
@@ -18,6 +18,7 @@ import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.core.vect.Vect;
/**
* Hermits will not produce if there are any other living creatures nearby.
@@ -26,11 +27,22 @@ public class JubilanceProviderHermit extends JubilanceDefault {
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
AxisAlignedBB bounding = this.getBounding(genome, housing, 1.0f);
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityLiving.class, bounding);
return list.size() <= 0;
}
private static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(modifier);
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
}
}
@@ -17,23 +17,19 @@ import net.minecraft.world.World;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.core.utils.StackUtils;
public class JubilanceReqRes implements IJubilanceProvider {
public class JubilanceRequiresResource implements IJubilanceProvider {
private final ItemStack blockRequired;
public JubilanceReqRes(ItemStack blockRequired) {
this.blockRequired = blockRequired;
public JubilanceRequiresResource(Block block, int meta) {
this.blockRequired = new ItemStack(block, meta);
}
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
if (blockRequired == null) {
return true;
}
World world = housing.getWorld();
Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
@@ -1,102 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.lang.reflect.Field;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
public class MutationEMC extends MutationReqRes {
private final int emcRequired;
private final Class<?> condenserClass;
private final Field emcField;
public MutationEMC(IAllele allele0, IAllele allele1, IAllele[] template, int chance, ItemStack blockRequired, Class<?> condenserClass, Field emcField,
int emcRequired) {
super(allele0, allele1, template, chance, blockRequired);
this.condenserClass = condenserClass;
this.emcField = emcField;
this.emcRequired = emcRequired;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
// If we don't have any chance, return at once.
if (chance <= 0) {
return 0;
}
if (emcRequired <= 0) {
return chance;
}
World world = housing.getWorld();
Vect[] possibleTargets = new Vect[]{new Vect(housing.getXCoord() + 1, housing.getYCoord(), housing.getZCoord()),
new Vect(housing.getXCoord() - 1, housing.getYCoord(), housing.getZCoord()),
new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() + 1),
new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() - 1)};
for (Vect target : possibleTargets) {
if (!world.blockExists(target.x, target.y, target.z)) {
continue;
}
TileEntity entity = world.getTileEntity(target.x, target.y, target.z);
if (entity == null) {
continue;
}
if (!condenserClass.isInstance(entity)) {
Proxies.log.warning("Did not find a relay at " + target.toString());
continue;
}
int emc = 0;
try {
emc = emcField.getInt(entity);
} catch (Exception ex) {
Proxies.log.warning("Failed to fetch EMC information.");
}
if (emc < emcRequired * 80) {
continue;
}
boolean removedEMC = false;
try {
emcField.set(entity, emc - (emcRequired * 80));
removedEMC = true;
} catch (Exception ex) {
Proxies.log.warning("Failed to set EMC information.");
}
if (removedEMC) {
return chance;
}
}
return 0;
}
}
@@ -1,53 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.utils.StackUtils;
public class MutationReqRes extends BeeMutation {
private final ItemStack blockRequired;
public MutationReqRes(IAllele allele0, IAllele allele1, IAllele[] template, int chance, ItemStack blockRequired) {
super(allele0, allele1, template, chance);
this.blockRequired = blockRequired;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
// If we have no chance anyway, we don't need to check.
if (chance <= 0) {
return 0;
}
World world = housing.getWorld();
if (blockRequired == null) {
return chance;
}
Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
int meta = world.getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage()) {
return chance;
} else {
return 0;
}
}
}
@@ -1,157 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.Calendar;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
public class MutationTimeLimited extends BeeMutation {
/**
* Fed up with Date and Calendar and their shenanigans
*/
public static class DayMonth {
public final int day;
public final int month;
public DayMonth() {
this.day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
this.month = Calendar.getInstance().get(Calendar.MONTH) + 1;
}
public DayMonth(int day, int month) {
this.day = day;
this.month = month;
}
public boolean between(DayMonth start, DayMonth end) {
if (equals(start) || equals(end)) {
return true;
}
if (start.month > end.month) {
return after(start) || before(end);
}
return after(start) && before(end);
}
public boolean before(DayMonth other) {
if (other.month > this.month) {
return true;
}
if (other.month < this.month) {
return false;
}
return this.day < other.day;
}
public boolean after(DayMonth other) {
if (other.month < this.month) {
return true;
}
if (other.month > this.month) {
return false;
}
return this.day > other.day;
}
@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + this.day;
hash = 89 * hash + this.month;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DayMonth other = (DayMonth) obj;
if (this.day != other.day) {
return false;
}
if (this.month != other.month) {
return false;
}
return true;
}
@Override
public String toString() {
return day + "." + month;
}
}
private final DayMonth start;
private final DayMonth end;
public MutationTimeLimited(IAllele allele0, IAllele allele1, IAllele[] template, int chance, DayMonth start) {
this(allele0, allele1, template, chance, start, null);
}
public MutationTimeLimited(IAllele allele0, IAllele allele1, IAllele[] template, int chance, DayMonth start, DayMonth end) {
super(allele0, allele1, template, chance);
this.start = start;
this.end = end;
}
@Override
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
if (chance == 0) {
return 0;
}
if (start == null) {
return chance;
}
DayMonth now = new DayMonth();
// If we are equal to start day, return chance.
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == start.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == start.month) {
return chance;
}
// Still here but not time span? No mutation!
if (end == null) {
return 0;
}
// Equal to end date, return chance.
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == end.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == end.month) {
return chance;
}
// Still a chance we are in between
if (now.between(start, end)) {
return chance;
}
// Now we finally failed.
return 0;
}
}
@@ -12,22 +12,16 @@ package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearyPlain;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerAlveary extends ContainerForestry {
private final TileAlvearyPlain tile;
public class ContainerAlveary extends ContainerTile<TileAlvearyPlain> {
public ContainerAlveary(InventoryPlayer player, TileAlvearyPlain tile) {
super(tile);
this.tile = tile;
tile.sendNetworkUpdate();
super(tile, player, 8, 108);
// Queen/Princess
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39));
@@ -43,17 +37,6 @@ public class ContainerAlveary extends ContainerForestry {
this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65));
this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39));
this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26));
// Player inventory
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18));
}
}
// Player hotbar
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(player, i, 8 + i * 18, 166));
}
}
@Override
@@ -68,5 +51,4 @@ public class ContainerAlveary extends ContainerForestry {
tile.sendGUINetworkData(this, (ICrafting) crafter);
}
}
}
@@ -10,30 +10,18 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
import forestry.core.gui.ContainerLiquidTanks;
import forestry.core.gui.slots.SlotFiltered;
public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks {
public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks<TileAlvearyHygroregulator> {
public ContainerAlvearyHygroregulator(IInventory playerInventory, TileAlvearyHygroregulator tile) {
super(tile);
public ContainerAlvearyHygroregulator(InventoryPlayer playerInventory, TileAlvearyHygroregulator tile) {
super(tile, playerInventory, 8, 84);
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyHygroregulator.SLOT_INPUT, 56, 38));
for (int i = 0; i < 3; ++i) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot(playerInventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142));
}
}
}
@@ -11,17 +11,16 @@
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearySieve;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerAlvearySieve extends ContainerForestry {
public class ContainerAlvearySieve extends ContainerTile<TileAlvearySieve> {
public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) {
super(tile);
super(tile, player, 8, 87);
addSlotToContainer(new SlotOutput(tile, 0, 94, 52).setCrafter(tile));
addSlotToContainer(new SlotOutput(tile, 1, 115, 39).setCrafter(tile));
@@ -29,18 +28,5 @@ public class ContainerAlvearySieve extends ContainerForestry {
addSlotToContainer(new SlotOutput(tile, 3, 94, 26).setCrafter(tile));
addSlotToContainer(new SlotFiltered(tile, TileAlvearySieve.SLOT_SIEVE, 43, 39).setCrafter(tile));
// Player inventory
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
}
}
// Player hotbar
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(player, i, 8 + i * 18, 145));
}
}
}
@@ -11,32 +11,19 @@
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileAlvearySwarmer;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
public class ContainerAlvearySwarmer extends ContainerForestry {
public class ContainerAlvearySwarmer extends ContainerTile<TileAlvearySwarmer> {
public ContainerAlvearySwarmer(InventoryPlayer player, TileAlvearySwarmer tile) {
super(tile);
super(tile, player, 8, 87);
this.addSlotToContainer(new SlotFiltered(tile, 0, 79, 52));
this.addSlotToContainer(new SlotFiltered(tile, 1, 100, 39));
this.addSlotToContainer(new SlotFiltered(tile, 2, 58, 39));
this.addSlotToContainer(new SlotFiltered(tile, 3, 79, 26));
// Player inventory
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
}
}
// Player hotbar
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(player, i, 8 + i * 18, 145));
}
}
}
@@ -12,22 +12,16 @@ package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import forestry.apiculture.gadgets.TileBeehouse;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerTile;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerApiary extends ContainerForestry {
private final TileBeehouse tile;
public class ContainerApiary extends ContainerTile<TileBeehouse> {
public ContainerApiary(InventoryPlayer player, TileBeehouse tile, boolean hasFrames) {
super(tile);
this.tile = tile;
tile.sendNetworkUpdate();
super(tile, player, 8, 108);
// Queen/Princess
this.addSlotToContainer(new SlotFiltered(tile, TileBeehouse.SLOT_QUEEN, 29, 39));
@@ -50,17 +44,6 @@ public class ContainerApiary extends ContainerForestry {
this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65));
this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39));
this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26));
// Player inventory
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
addSlotToContainer(new Slot(player, l1 + i1 * 9 + 9, 8 + l1 * 18, 108 + i1 * 18));
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++) {
addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 166));
}
}
@Override
@@ -10,17 +10,17 @@
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.entity.player.EntityPlayer;
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
import forestry.core.gui.ContainerItemInventory;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
public class ContainerHabitatLocator extends ContainerItemInventory {
public class ContainerHabitatLocator extends ContainerItemInventory<HabitatLocatorInventory> {
public ContainerHabitatLocator(InventoryPlayer inventoryplayer, HabitatLocatorInventory inventory) {
super(inventory, inventoryplayer.player);
public ContainerHabitatLocator(EntityPlayer player, HabitatLocatorInventory inventory) {
super(inventory, player.inventory, 8, 102);
// Energy
this.addSlotToContainer(new SlotFiltered(inventory, 2, 152, 8));
@@ -29,16 +29,5 @@ public class ContainerHabitatLocator extends ContainerItemInventory {
this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 32));
// Analyzed bee
this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 75));
// Player inventory
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 102 + i1 * 18);
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++) {
addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 160);
}
}
}
@@ -12,44 +12,30 @@ package forestry.apiculture.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
import forestry.core.gui.ContainerForestry;
import forestry.core.gui.ContainerItemInventory;
import forestry.core.gui.IGuiSelectable;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketPayload;
import forestry.core.network.PacketUpdate;
import forestry.core.network.ForestryPacket;
import forestry.core.network.PacketGuiSelect;
import forestry.core.network.PacketId;
import forestry.core.proxy.Proxies;
public class ContainerImprinter extends ContainerForestry implements IGuiSelectable {
public class ContainerImprinter extends ContainerItemInventory<ImprinterInventory> implements IGuiSelectable {
public final ImprinterInventory inventory;
private boolean isNetSynced = false;
public ContainerImprinter(InventoryPlayer inventoryplayer, ImprinterInventory inventory) {
super(inventory);
super(inventory, inventoryplayer, 8, 103);
this.inventory = inventory;
// Input
this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 12));
// Output
this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 72));
// Player inventory
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18));
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++) {
addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161));
}
}
@Override
@@ -69,53 +55,38 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta
Proxies.common.dropItemPlayer(entityplayer, stack);
inventory.setInventorySlotContents(i, null);
}
}
public void advanceSelection(int index, World world) {
PacketPayload payload = new PacketPayload(2, 0, 0);
payload.intPayload[0] = index;
payload.intPayload[1] = 0;
sendSelectionChange(payload);
public void advanceSelection(int index) {
sendSelectionChange(index, 0);
}
public void regressSelection(int index, World world) {
PacketPayload payload = new PacketPayload(2, 0, 0);
payload.intPayload[0] = index;
payload.intPayload[1] = 1;
sendSelectionChange(payload);
}
private void sendSelectionChange(PacketPayload payload) {
PacketUpdate packet = new PacketUpdate(PacketIds.GUI_SELECTION_CHANGE, payload);
Proxies.net.sendToServer(packet);
isNetSynced = false;
}
@Override
public void setSelection(PacketUpdate packet) {
inventory.setPrimaryIndex(packet.payload.intPayload[0]);
inventory.setSecondaryIndex(packet.payload.intPayload[1]);
public void regressSelection(int index) {
sendSelectionChange(index, 1);
}
public void updateContainer(World world) {
if (!isNetSynced && !Proxies.common.isSimulating(world)) {
isNetSynced = true;
Proxies.net.sendToServer(new PacketUpdate(PacketIds.IMPRINT_SELECTION_GET));
Proxies.net.sendToServer(new ForestryPacket(PacketId.IMPRINT_SELECTION_GET));
}
}
@Override
public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) {
private void sendSelectionChange(int index, int advance) {
ForestryPacket packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, index, advance);
Proxies.net.sendToServer(packet);
isNetSynced = false;
}
if (packet.payload.intPayload[1] == 0) {
if (packet.payload.intPayload[0] == 0) {
@Override
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
if (packet.getSecondaryIndex() == 0) {
if (packet.getPrimaryIndex() == 0) {
inventory.advancePrimary();
} else {
inventory.advanceSecondary();
}
} else if (packet.payload.intPayload[0] == 0) {
} else if (packet.getPrimaryIndex() == 0) {
inventory.regressPrimary();
} else {
inventory.regressSecondary();
@@ -123,9 +94,13 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta
}
public void sendSelection(EntityPlayer player) {
PacketPayload payload = new PacketPayload(2, 0, 0);
payload.intPayload[0] = inventory.getPrimaryIndex();
payload.intPayload[1] = inventory.getSecondaryIndex();
Proxies.net.sendToPlayer(new PacketUpdate(PacketIds.GUI_SELECTION, payload), player);
ForestryPacket packet = new PacketGuiSelect(PacketId.GUI_SELECTION_SET, inventory.getPrimaryIndex(), inventory.getSecondaryIndex());
Proxies.net.sendToPlayer(packet, player);
}
@Override
public void setSelection(PacketGuiSelect packetPayload) {
inventory.setPrimaryIndex(packetPayload.getPrimaryIndex());
inventory.setSecondaryIndex(packetPayload.getSecondaryIndex());
}
}
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -27,12 +28,11 @@ import forestry.apiculture.genetics.BeeGenome;
import forestry.apiculture.items.ItemBeeGE;
import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
import forestry.core.config.ForestryItem;
import forestry.core.genetics.AlleleBoolean;
import forestry.core.genetics.alleles.AlleleBoolean;
import forestry.core.gui.ContainerAlyzer;
import forestry.core.gui.GuiAlyzer;
import forestry.core.utils.StringUtil;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
public class GuiBeealyzer extends GuiAlyzer {
@@ -65,8 +65,8 @@ public class GuiBeealyzer extends GuiAlyzer {
if (inventory.getStackInSlot(k) == null) {
continue;
}
bee = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(k));
beeType = PluginApiculture.beeInterface.getType(inventory.getStackInSlot(k));
bee = BeeManager.beeRoot.getMember(inventory.getStackInSlot(k));
beeType = BeeManager.beeRoot.getType(inventory.getStackInSlot(k));
if (bee == null || !bee.isAnalyzed()) {
continue;
}
@@ -11,14 +11,13 @@
package forestry.apiculture.gui;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.biome.BiomeGenBase;
@@ -37,6 +36,102 @@ import forestry.core.render.TextureManager;
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, HabitatLocatorInventory> {
private final HabitatSlot[] habitatSlots = new HabitatSlot[]{
new HabitatSlot(0, "Ocean"), // ocean, beach
new HabitatSlot(1, "Plains"),
new HabitatSlot(2, "Desert"), // desert, desert hills
new HabitatSlot(3, "Forest"), // forest, forestHills, river
new HabitatSlot(4, "Jungle"), // jungle, jungleHills
new HabitatSlot(5, "Taiga"), // taiga, taigaHills
new HabitatSlot(6, "Hills"), // extremeHills, extremeHillsEdge
new HabitatSlot(7, "Swamp"),
new HabitatSlot(8, "Snow"), // Ice plains, mountains, frozen rivers, frozen oceans
new HabitatSlot(9, "Mushroom"),
new HabitatSlot(10, "Nether"),
new HabitatSlot(11, "End")};
private final Map<BiomeDictionary.Type, HabitatSlot> biomeToHabitat = new EnumMap<BiomeDictionary.Type, HabitatSlot>(BiomeDictionary.Type.class);
private int startX;
private int startY;
public GuiHabitatLocator(EntityPlayer player, HabitatLocatorInventory item) {
super(Defaults.TEXTURE_PATH_GUI + "/biomefinder.png", new ContainerHabitatLocator(player, item), item);
xSize = 176;
ySize = 184;
int x;
int y;
for (HabitatSlot slot : habitatSlots) {
if (slot.slot > 5) {
x = 18 + (slot.slot - 6) * 20;
y = 50;
} else {
x = 18 + slot.slot * 20;
y = 32;
}
slot.setPosition(x, y);
this.widgetManager.add(slot);
}
biomeToHabitat.put(BiomeDictionary.Type.OCEAN, habitatSlots[0]);
biomeToHabitat.put(BiomeDictionary.Type.BEACH, habitatSlots[0]);
biomeToHabitat.put(BiomeDictionary.Type.PLAINS, habitatSlots[1]);
biomeToHabitat.put(BiomeDictionary.Type.SANDY, habitatSlots[2]);
biomeToHabitat.put(BiomeDictionary.Type.FOREST, habitatSlots[3]);
biomeToHabitat.put(BiomeDictionary.Type.RIVER, habitatSlots[3]);
biomeToHabitat.put(BiomeDictionary.Type.JUNGLE, habitatSlots[4]);
biomeToHabitat.put(BiomeDictionary.Type.CONIFEROUS, habitatSlots[5]);
biomeToHabitat.put(BiomeDictionary.Type.MOUNTAIN, habitatSlots[6]);
biomeToHabitat.put(BiomeDictionary.Type.SWAMP, habitatSlots[7]);
biomeToHabitat.put(BiomeDictionary.Type.SNOWY, habitatSlots[8]);
biomeToHabitat.put(BiomeDictionary.Type.MUSHROOM, habitatSlots[9]);
biomeToHabitat.put(BiomeDictionary.Type.NETHER, habitatSlots[10]);
biomeToHabitat.put(BiomeDictionary.Type.END, habitatSlots[11]);
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
String str = StatCollector.translateToLocal("item.for.habitatLocator.name").toUpperCase();
fontRendererObj.drawString(str, startX + 8 + getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen"));
// Set active according to valid biomes.
Set<BiomeDictionary.Type> activeBiomeTypes = EnumSet.noneOf(BiomeDictionary.Type.class);
for (HabitatSlot habitatSlot : habitatSlots) {
habitatSlot.isActive = false;
}
for (BiomeGenBase biome : inventory.getBiomesToSearch()) {
Collections.addAll(activeBiomeTypes, BiomeDictionary.getTypesForBiome(biome));
}
for (BiomeDictionary.Type biomeType : activeBiomeTypes) {
HabitatSlot habitatSlot = biomeToHabitat.get(biomeType);
if (habitatSlot != null) {
habitatSlot.isActive = true;
}
}
for (HabitatSlot slot : habitatSlots) {
slot.draw(startX, startY);
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Reset afterwards.
}
@Override
public void initGui() {
super.initGui();
startX = (this.width - this.xSize) / 2;
startY = (this.height - this.ySize) / 2;
}
public class HabitatSlot extends Widget {
private final int slot;
@@ -85,101 +180,4 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Habi
}
private final HabitatSlot[] habitatSlots = new HabitatSlot[]{
new HabitatSlot(0, "Ocean"), // ocean, beach
new HabitatSlot(1, "Plains"),
new HabitatSlot(2, "Desert"), // desert, desert hills
new HabitatSlot(3, "Forest"), // forest, forestHills, river
new HabitatSlot(4, "Jungle"), // jungle, jungleHills
new HabitatSlot(5, "Taiga"), // taiga, taigaHills
new HabitatSlot(6, "Hills"), // extremeHills, extremeHillsEdge
new HabitatSlot(7, "Swamp"),
new HabitatSlot(8, "Snow"), // Ice plains, mountains, frozen rivers, frozen oceans
new HabitatSlot(9, "Mushroom"),
new HabitatSlot(10, "Nether"),
new HabitatSlot(11, "End")};
private final Map<BiomeDictionary.Type, HabitatSlot> biomeToHabitat = new HashMap<BiomeDictionary.Type, HabitatSlot>();
private int startX;
private int startY;
public GuiHabitatLocator(InventoryPlayer inventory, HabitatLocatorInventory item) {
super(Defaults.TEXTURE_PATH_GUI + "/biomefinder.png", new ContainerHabitatLocator(inventory, item), item);
this.inventory.tryAnalyze();
xSize = 176;
ySize = 184;
int x;
int y;
for (HabitatSlot slot : habitatSlots) {
if (slot.slot > 5) {
x = 18 + (slot.slot - 6) * 20;
y = 50;
} else {
x = 18 + slot.slot * 20;
y = 32;
}
slot.setPosition(x, y);
this.widgetManager.add(slot);
}
biomeToHabitat.put(BiomeDictionary.Type.OCEAN, habitatSlots[0]);
biomeToHabitat.put(BiomeDictionary.Type.BEACH, habitatSlots[0]);
biomeToHabitat.put(BiomeDictionary.Type.PLAINS, habitatSlots[1]);
biomeToHabitat.put(BiomeDictionary.Type.SANDY, habitatSlots[2]);
biomeToHabitat.put(BiomeDictionary.Type.FOREST, habitatSlots[3]);
biomeToHabitat.put(BiomeDictionary.Type.RIVER, habitatSlots[3]);
biomeToHabitat.put(BiomeDictionary.Type.JUNGLE, habitatSlots[4]);
biomeToHabitat.put(BiomeDictionary.Type.CONIFEROUS, habitatSlots[5]);
biomeToHabitat.put(BiomeDictionary.Type.MOUNTAIN, habitatSlots[6]);
biomeToHabitat.put(BiomeDictionary.Type.SWAMP, habitatSlots[7]);
biomeToHabitat.put(BiomeDictionary.Type.SNOWY, habitatSlots[8]);
biomeToHabitat.put(BiomeDictionary.Type.MUSHROOM, habitatSlots[9]);
biomeToHabitat.put(BiomeDictionary.Type.NETHER, habitatSlots[10]);
biomeToHabitat.put(BiomeDictionary.Type.END, habitatSlots[11]);
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
String str = StatCollector.translateToLocal("item.for.habitatLocator.name").toUpperCase();
fontRendererObj.drawString(str, startX + 8 + getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen"));
// Set active according to valid biomes.
Set<BiomeDictionary.Type> activeBiomeTypes = new HashSet<BiomeDictionary.Type>();
for (HabitatSlot habitatSlot : habitatSlots) {
habitatSlot.isActive = false;
}
for (BiomeGenBase biome : inventory.biomesToSearch) {
Collections.addAll(activeBiomeTypes, BiomeDictionary.getTypesForBiome(biome));
}
for (BiomeDictionary.Type biomeType : activeBiomeTypes) {
HabitatSlot habitatSlot = biomeToHabitat.get(biomeType);
if (habitatSlot != null) {
habitatSlot.isActive = true;
}
}
for (HabitatSlot slot : habitatSlots) {
slot.draw(startX, startY);
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Reset afterwards.
}
@Override
public void initGui() {
super.initGui();
startX = (this.width - this.xSize) / 2;
startY = (this.height - this.ySize) / 2;
}
}
@@ -106,9 +106,9 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ImprinterInven
}
if (k == 0) {
container.advanceSelection(slot, Proxies.common.getRenderWorld());
container.advanceSelection(slot);
} else {
container.regressSelection(slot, Proxies.common.getRenderWorld());
container.regressSelection(slot);
}
}
@@ -24,6 +24,7 @@ import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -38,7 +39,6 @@ import forestry.apiculture.genetics.BeeGenome;
import forestry.core.config.Config;
import forestry.core.genetics.ItemGE;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
public class ItemBeeGE extends ItemGE {
@@ -123,7 +123,7 @@ public class ItemBeeGE extends ItemGE {
@SuppressWarnings({"rawtypes", "unchecked"})
public void addCreativeItems(List itemList, boolean hideSecrets) {
for (IIndividual individual : PluginApiculture.beeInterface.getIndividualTemplates()) {
for (IIndividual individual : BeeManager.beeRoot.getIndividualTemplates()) {
// Don't show secret bees unless ordered to.
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue;
@@ -150,7 +150,7 @@ public class ItemBeeGE extends ItemGE {
@Override
public int getColourFromSpecies(IAlleleSpecies species, int renderPass) {
if (species != null && species instanceof IAlleleBeeSpecies) {
if (species instanceof IAlleleBeeSpecies) {
return species.getIconColour(renderPass);
} else {
return 0xffffff;
@@ -188,7 +188,7 @@ public class ItemBeeGE extends ItemGE {
@SideOnly(Side.CLIENT)
public IIcon getIconFromSpecies(IAlleleBeeSpecies species, int renderPass) {
if (species == null) {
species = (IAlleleBeeSpecies) PluginApiculture.beeInterface.getDefaultTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
species = (IAlleleBeeSpecies) BeeManager.beeRoot.getDefaultTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
}
return species.getIcon(type, renderPass);
@@ -15,40 +15,38 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.core.ForestryAPI;
import forestry.api.core.Tabs;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.interfaces.IErrorSource;
import forestry.core.interfaces.IHintSource;
import forestry.core.inventory.AlyzerInventory;
import forestry.core.items.ItemInventoried;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
public class ItemBeealyzer extends ItemInventoried {
public static class BeealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
public static class BeealyzerInventory extends AlyzerInventory implements IHintSource {
public BeealyzerInventory(EntityPlayer player, ItemStack itemStack) {
super(ItemBeealyzer.class, 7, itemStack);
this.player = player;
super(player, 7, itemStack);
}
@Override
protected boolean isSpecimen(ItemStack itemStack) {
return PluginApiculture.beeInterface.isMember(itemStack);
return BeeManager.beeRoot.isMember(itemStack);
}
private void tryAnalyze() {
@Override
public void onSlotClick(EntityPlayer player) {
// Source slot to analyze empty
if (getStackInSlot(SLOT_SPECIMEN) == null) {
return;
}
IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_SPECIMEN));
IBee bee = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_SPECIMEN));
// No bee, abort
if (bee == null) {
return;
@@ -64,8 +62,8 @@ public class ItemBeealyzer extends ItemInventoried {
bee.analyze();
if (player != null) {
PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getPrimary());
PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getSecondary());
BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getPrimary());
BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getSecondary());
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -80,13 +78,6 @@ public class ItemBeealyzer extends ItemInventoried {
setInventorySlotContents(SLOT_SPECIMEN, null);
}
@Override
public void markDirty() {
// if (!Proxies.common.isSimulating(player.worldObj))
// return;
tryAnalyze();
}
// / IHINTSOURCE
@Override
public boolean hasHints() {
@@ -97,21 +88,6 @@ public class ItemBeealyzer extends ItemInventoried {
public String[] getHints() {
return Config.hints.get("beealyzer");
}
// / IERRORSOURCE
@Override
public boolean throwsErrors() {
return true;
}
@Override
public EnumErrorCode getErrorState() {
if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
return EnumErrorCode.NOHONEY;
}
return EnumErrorCode.OK;
}
}
public ItemBeealyzer() {
@@ -58,7 +58,7 @@ public class ItemCandleBlock extends ItemForestryBlock {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int meta, int pass) {
return ((BlockCandle) this.getBlock()).getTextureFromPassAndMeta((meta != 0) ? 8 : 0, pass);
return this.getBlock().getIcon((meta != 0) ? 8 : 0, pass);
}
@Override
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture.items;
import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -32,10 +34,12 @@ import net.minecraftforge.common.BiomeDictionary;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorState;
import forestry.api.core.Tabs;
import forestry.api.genetics.AlleleManager;
import forestry.apiculture.render.TextureHabitatLocator;
@@ -50,105 +54,12 @@ import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
public class ItemHabitatLocator extends ItemInventoried {
public static class HabitatLocatorInventory extends ItemInventory implements IErrorSource, IHintSource {
private static final short SLOT_ENERGY = 2;
private static final short SLOT_SPECIMEN = 0;
private static final short SLOT_ANALYZED = 1;
public Set<BiomeGenBase> biomesToSearch = new HashSet<BiomeGenBase>();
private final ItemHabitatLocator habitatLocator;
public HabitatLocatorInventory(ItemStack itemstack) {
super(ItemHabitatLocator.class, 3, itemstack);
this.habitatLocator = (ItemHabitatLocator) itemstack.getItem();
}
private static boolean isEnergy(ItemStack itemstack) {
if (itemstack == null || itemstack.stackSize <= 0) {
return false;
}
return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack);
}
public void tryAnalyze() {
if (getStackInSlot(SLOT_SPECIMEN) != null) {
// Requires energy
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
return;
}
// Decrease energy
decrStackSize(SLOT_ENERGY, 1);
setInventorySlotContents(SLOT_ANALYZED, getStackInSlot(SLOT_SPECIMEN));
setInventorySlotContents(SLOT_SPECIMEN, null);
}
IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_ANALYZED));
// No bee, abort
if (bee == null) {
return;
}
biomesToSearch = new HashSet<BiomeGenBase>(bee.getSuitableBiomes());
habitatLocator.startBiomeSearch(biomesToSearch);
}
@Override
public void markDirty() {
tryAnalyze();
}
// / IHINTSOURCE
@Override
public boolean hasHints() {
return Config.hints.get("habitatlocator") != null && Config.hints.get("habitatlocator").length > 0;
}
@Override
public String[] getHints() {
return Config.hints.get("habitatlocator");
}
// / IERRORSOURCE
@Override
public boolean throwsErrors() {
return true;
}
@Override
public EnumErrorCode getErrorState() {
if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
return EnumErrorCode.NOHONEY;
}
return EnumErrorCode.OK;
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_ENERGY) {
Item item = itemStack.getItem();
return item == ForestryItem.honeydew.item() || item == ForestryItem.honeyDrop.item();
} else if (slotIndex == SLOT_SPECIMEN) {
return PluginApiculture.beeInterface.isMember(itemStack);
}
return false;
}
}
private static final String iconName = "forestry:biomefinder";
private Set<BiomeGenBase> biomesToSearch = new HashSet<BiomeGenBase>();
private Set<BiomeGenBase> targetBiomes = new HashSet<BiomeGenBase>();
private boolean biomeFound = false;
private int searchRadiusIteration = 0;
private int searchAngleIteration = 0;
@@ -195,13 +106,16 @@ public class ItemHabitatLocator extends ItemInventoried {
list.add(StringUtil.localize("gui.humidity") + ": " + AlleleManager.climateHelper.toDisplay(humidity));
}
public void startBiomeSearch(Set<BiomeGenBase> biomesToSearch) {
public void startBiomeSearch(IBee bee, EntityPlayer player) {
this.biomesToSearch = biomesToSearch;
this.targetBiomes = new HashSet<BiomeGenBase>(bee.getSuitableBiomes());
this.searchAngleIteration = 0;
this.searchRadiusIteration = 0;
this.biomeFound = false;
this.searchCenter = null;
this.searchCenter = new Vect(player);
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords(searchCenter.x, searchCenter.z);
removeInvalidBiomes(currentBiome, targetBiomes);
// reset the locator coordinates
Proxies.common.setHabitatLocatorCoordinates(null, null);
@@ -214,14 +128,7 @@ public class ItemHabitatLocator extends ItemInventoried {
return;
}
if (this.searchCenter == null) {
this.searchCenter = new Vect((int) player.posX, (int) player.posY, (int) player.posZ);
BiomeGenBase currentBiome = world.getBiomeGenForCoords(searchCenter.x, searchCenter.z);
removeInvalidBiomes(currentBiome, biomesToSearch);
}
if (biomesToSearch.isEmpty()) {
if (targetBiomes.isEmpty()) {
return;
}
@@ -230,7 +137,7 @@ public class ItemHabitatLocator extends ItemInventoried {
return;
}
ChunkCoordinates target = findNearestBiome(player, biomesToSearch);
ChunkCoordinates target = findNearestBiome(player, targetBiomes);
// send an update if we find the biome
if (target != null) {
@@ -245,7 +152,7 @@ public class ItemHabitatLocator extends ItemInventoried {
final int maxSearchRadiusIterations = 500;
final int spacing = 20;
Vect playerPos = new Vect((int) player.posX, (int) player.posY, (int) player.posZ);
Vect playerPos = new Vect(player);
// If we are in a valid spot, we point to ourselves.
ChunkCoordinates coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch);
@@ -360,4 +267,105 @@ public class ItemHabitatLocator extends ItemInventoried {
biomesToSearch.removeAll(endBiomes);
}
}
public static class HabitatLocatorInventory extends ItemInventory implements IErrorSource, IHintSource {
private static final short SLOT_ENERGY = 2;
private static final short SLOT_SPECIMEN = 0;
private static final short SLOT_ANALYZED = 1;
private final ItemHabitatLocator habitatLocator;
public HabitatLocatorInventory(EntityPlayer player, ItemStack itemstack) {
super(player, 3, itemstack);
this.habitatLocator = (ItemHabitatLocator) itemstack.getItem();
}
private static boolean isEnergy(ItemStack itemstack) {
if (itemstack == null || itemstack.stackSize <= 0) {
return false;
}
return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack);
}
@Override
public void onSlotClick(EntityPlayer player) {
if (getStackInSlot(SLOT_ANALYZED) != null) {
if (habitatLocator.biomeFound) {
return;
}
} else if (getStackInSlot(SLOT_SPECIMEN) != null) {
// Requires energy
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
return;
}
// Decrease energy
decrStackSize(SLOT_ENERGY, 1);
setInventorySlotContents(SLOT_ANALYZED, getStackInSlot(SLOT_SPECIMEN));
setInventorySlotContents(SLOT_SPECIMEN, null);
}
IBee bee = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_ANALYZED));
// No bee, abort
if (bee == null) {
return;
}
habitatLocator.startBiomeSearch(bee, player);
}
public Set<BiomeGenBase> getBiomesToSearch() {
return habitatLocator.targetBiomes;
}
// / IHINTSOURCE
@Override
public boolean hasHints() {
return Config.hints.get("habitatlocator") != null && Config.hints.get("habitatlocator").length > 0;
}
@Override
public String[] getHints() {
return Config.hints.get("habitatlocator");
}
// / IERRORSOURCE
@Override
public ImmutableSet<IErrorState> getErrorStates() {
if (getStackInSlot(SLOT_ANALYZED) != null) {
return ImmutableSet.of();
}
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
ItemStack specimen = getStackInSlot(SLOT_SPECIMEN);
if (!BeeManager.beeRoot.isMember(specimen)) {
errorStates.add(EnumErrorCode.NOTHINGANALYZE);
}
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
errorStates.add(EnumErrorCode.NOHONEY);
}
return errorStates.build();
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (slotIndex == SLOT_ENERGY) {
Item item = itemStack.getItem();
return item == ForestryItem.honeydew.item() || item == ForestryItem.honeyDrop.item();
} else if (slotIndex == SLOT_SPECIMEN) {
return BeeManager.beeRoot.isMember(itemStack);
}
return false;
}
}
}
@@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.api.core.ForestryAPI;
@@ -24,27 +25,23 @@ import forestry.core.inventory.ItemInventory;
import forestry.core.items.ItemForestry;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
public class ItemImprinter extends ItemForestry {
public static class ImprinterInventory extends ItemInventory {
private final short specimenSlot = 0;
private final short imprintedSlot = 1;
private static final short specimenSlot = 0;
private static final short imprintedSlot = 1;
private int primaryIndex = 0;
private int secondaryIndex = 0;
private final EntityPlayer player;
public ImprinterInventory(EntityPlayer player, ItemStack itemStack) {
super(ItemImprinter.class, 2, itemStack);
this.player = player;
super(player, 2, itemStack);
}
public void advancePrimary() {
if (primaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) {
if (primaryIndex < BeeManager.beeRoot.getIndividualTemplates().size() - 1) {
primaryIndex++;
} else {
primaryIndex = 0;
@@ -52,7 +49,7 @@ public class ItemImprinter extends ItemForestry {
}
public void advanceSecondary() {
if (secondaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) {
if (secondaryIndex < BeeManager.beeRoot.getIndividualTemplates().size() - 1) {
secondaryIndex++;
} else {
secondaryIndex = 0;
@@ -63,7 +60,7 @@ public class ItemImprinter extends ItemForestry {
if (primaryIndex > 0) {
primaryIndex--;
} else {
primaryIndex = PluginApiculture.beeInterface.getIndividualTemplates().size() - 1;
primaryIndex = BeeManager.beeRoot.getIndividualTemplates().size() - 1;
}
}
@@ -71,22 +68,22 @@ public class ItemImprinter extends ItemForestry {
if (secondaryIndex > 0) {
secondaryIndex--;
} else {
secondaryIndex = PluginApiculture.beeInterface.getIndividualTemplates().size() - 1;
secondaryIndex = BeeManager.beeRoot.getIndividualTemplates().size() - 1;
}
}
public IAlleleBeeSpecies getPrimary() {
return PluginApiculture.beeInterface.getIndividualTemplates().get(primaryIndex).getGenome().getPrimary();
return BeeManager.beeRoot.getIndividualTemplates().get(primaryIndex).getGenome().getPrimary();
}
public IAlleleBeeSpecies getSecondary() {
return PluginApiculture.beeInterface.getIndividualTemplates().get(secondaryIndex).getGenome().getPrimary();
return BeeManager.beeRoot.getIndividualTemplates().get(secondaryIndex).getGenome().getPrimary();
}
public IBee getSelectedBee() {
return new Bee(PluginApiculture.beeInterface.templateAsGenome(
PluginApiculture.beeInterface.getGenomeTemplates().get(PluginApiculture.beeInterface.getIndividualTemplates().get(primaryIndex).getIdent()),
PluginApiculture.beeInterface.getGenomeTemplates().get(PluginApiculture.beeInterface.getIndividualTemplates().get(secondaryIndex).getIdent())));
return new Bee(BeeManager.beeRoot.templateAsGenome(
BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(primaryIndex).getIdent()),
BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(secondaryIndex).getIdent())));
}
public int getPrimaryIndex() {
@@ -105,19 +102,20 @@ public class ItemImprinter extends ItemForestry {
secondaryIndex = index;
}
private void tryImprint() {
if (inventoryStacks[specimenSlot] == null) {
@Override
public void onSlotClick(EntityPlayer player) {
ItemStack specimen = getStackInSlot(specimenSlot);
if (specimen == null) {
return;
}
// Only imprint bees
if (!PluginApiculture.beeInterface.isMember(inventoryStacks[specimenSlot])) {
if (!BeeManager.beeRoot.isMember(specimen)) {
return;
}
// Needs space
if (inventoryStacks[imprintedSlot] != null) {
if (getStackInSlot(imprintedSlot) != null) {
return;
}
@@ -128,18 +126,10 @@ public class ItemImprinter extends ItemForestry {
NBTTagCompound nbttagcompound = new NBTTagCompound();
imprint.writeToNBT(nbttagcompound);
inventoryStacks[specimenSlot].setTagCompound(nbttagcompound);
specimen.setTagCompound(nbttagcompound);
inventoryStacks[imprintedSlot] = inventoryStacks[specimenSlot];
inventoryStacks[specimenSlot] = null;
}
@Override
public void markDirty() {
if (!Proxies.common.isSimulating(player.worldObj)) {
return;
}
tryImprint();
setInventorySlotContents(imprintedSlot, specimen);
setInventorySlotContents(specimenSlot, null);
}
@Override
@@ -149,7 +139,7 @@ public class ItemImprinter extends ItemForestry {
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return PluginApiculture.beeInterface.isMember(itemStack);
return BeeManager.beeRoot.isMember(itemStack);
}
}
@@ -0,0 +1,59 @@
/*******************************************************************************
* 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.network;
import java.io.IOException;
import net.minecraft.tileentity.TileEntity;
import forestry.core.gadgets.TileForestry;
import forestry.core.interfaces.IActivatable;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
import forestry.core.proxy.Proxies;
public class PacketActiveUpdate extends PacketCoordinates {
private IActivatable activatable;
public static void onPacketData(DataInputStreamForestry data) throws IOException {
new PacketActiveUpdate(data);
}
private PacketActiveUpdate(DataInputStreamForestry data) throws IOException {
super(data);
}
public <T extends TileForestry & IActivatable> PacketActiveUpdate(T tile) {
super(PacketId.TILE_FORESTRY_ACTIVE, tile);
this.activatable = tile;
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeBoolean(activatable.isActive());
}
@Override
protected void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
boolean active = data.readBoolean();
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
if (tile instanceof IActivatable) {
((IActivatable) tile).setActive(active);
}
}
}
@@ -8,39 +8,47 @@
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
package forestry.apiculture.network;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import forestry.apiculture.gadgets.TileCandle;
import forestry.apiculture.gui.ContainerImprinter;
import forestry.core.interfaces.IPacketHandler;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.IPacketHandler;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketId;
import forestry.core.proxy.Proxies;
public class PacketHandlerApiculture implements IPacketHandler {
@Override
public boolean onPacketData(int packetID, DataInputStream data, EntityPlayer player) throws IOException {
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
switch (packetID) {
case PacketIds.HABITAT_BIOME_POINTER:
PacketCoordinates packetC = new PacketCoordinates();
packetC.readData(data);
Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates());
case HABITAT_BIOME_POINTER: {
PacketCoordinates packet = new PacketCoordinates(data);
Proxies.common.setHabitatLocatorCoordinates(player, packet.getCoordinates());
return true;
case PacketIds.IMPRINT_SELECTION_GET:
}
case IMPRINT_SELECTION_GET: {
onImprintSelectionGet(player);
return true;
}
case CANDLE: {
PacketUpdateCandle updateCandle = new PacketUpdateCandle(data);
onCandleUpdate(updateCandle);
return true;
}
}
return false;
}
private void onImprintSelectionGet(EntityPlayer playerEntity) {
private static void onImprintSelectionGet(EntityPlayer playerEntity) {
if (!(playerEntity.openContainer instanceof ContainerImprinter)) {
return;
@@ -50,4 +58,11 @@ public class PacketHandlerApiculture implements IPacketHandler {
}
private static void onCandleUpdate(PacketUpdateCandle updateCandle) {
TileEntity tileEntity = updateCandle.getTarget(Proxies.common.getRenderWorld());
if (tileEntity instanceof TileCandle) {
((TileCandle) tileEntity).onPacketUpdate(updateCandle);
}
}
}
@@ -0,0 +1,48 @@
package forestry.apiculture.network;
import java.io.IOException;
import forestry.apiculture.gadgets.TileCandle;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
public class PacketUpdateCandle extends PacketCoordinates {
private int colour;
private boolean lit;
public PacketUpdateCandle(DataInputStreamForestry data) throws IOException {
super(data);
}
public PacketUpdateCandle(TileCandle tileCandle) {
super(PacketId.CANDLE, tileCandle);
colour = tileCandle.getColour();
lit = tileCandle.isLit();
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeInt(colour);
data.writeBoolean(lit);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
colour = data.readInt();
lit = data.readBoolean();
}
public int getColour() {
return colour;
}
public boolean isLit() {
return lit;
}
}
@@ -22,9 +22,9 @@ import forestry.apiculture.render.BeeItemRenderer;
import forestry.apiculture.render.EntityBeeFX;
import forestry.apiculture.render.ParticleRenderer;
import forestry.apiculture.render.RenderBee;
import forestry.core.config.Config;
import forestry.core.config.ForestryItem;
import forestry.core.interfaces.IBlockRenderer;
import forestry.core.proxy.ClientProxyRender;
import forestry.core.render.RenderAnalyzer;
import forestry.core.render.TextureManager;
import forestry.plugins.PluginApiculture;
@@ -44,7 +44,7 @@ public class ClientProxyApiculture extends ProxyApiculture {
@Override
public void addBeeHiveFX(String icon, World world, double xCoord, double yCoord, double zCoord, int color, int areaX, int areaY, int areaZ) {
if (!Config.enableParticleFX) {
if (!ClientProxyRender.shouldSpawnParticle(world)) {
return;
}
@@ -66,7 +66,7 @@ public class ClientProxyApiculture extends ProxyApiculture {
@Override
public void addBeeSwarmFX(String icon, World world, double xCoord, double yCoord, double zCoord, int color) {
if (!Config.enableParticleFX) {
if (!ClientProxyRender.shouldSpawnParticle(world)) {
return;
}
@@ -20,10 +20,10 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.apiculture.entities.EntityBee;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
public class BeeItemRenderer implements IItemRenderer {
@@ -67,16 +67,16 @@ public class BeeItemRenderer implements IItemRenderer {
}
private IBee initBee(ItemStack item, boolean scaled) {
IBee bee = PluginApiculture.beeInterface.getMember(item);
IBee bee = BeeManager.beeRoot.getMember(item);
if (bee == null) {
bee = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());
bee = BeeManager.beeRoot.templateAsIndividual(BeeManager.beeRoot.getDefaultTemplate());
}
if (entity == null) {
entity = new EntityBee(Proxies.common.getClientInstance().theWorld);
}
entity.setSpecies(bee.getGenome().getPrimary());
entity.setType(PluginApiculture.beeInterface.getType(item));
entity.setType(BeeManager.beeRoot.getType(item));
/*
if(scaled)
entity.setScale(butterfly.getSize());
@@ -13,6 +13,7 @@ package forestry.apiculture.render;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@@ -26,19 +27,13 @@ public class BlockCandleRenderer implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
/*BlockCandle bc = (BlockCandle)block;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, -1.0F, 0.0F);
IIcon iconA = (bc.isLit(meta)) ? bc.
this.renderTorchAtAngle(block, -0.5D, -0.5D, -0.5D, 0.0D, 0.0D, 0);
tessellator.draw();*/
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
if (block.getRenderType() == ForestryClient.candleRenderId) {
this.renderBlockCandle(world, x, y, z, (BlockCandle) block, modelId, renderer);
renderBlockCandle(world, x, y, z, (BlockCandle) block);
}
return true;
}
@@ -53,13 +48,20 @@ public class BlockCandleRenderer implements ISimpleBlockRenderingHandler {
return ForestryClient.candleRenderId;
}
public boolean renderBlockCandle(IBlockAccess world, int x, int y, int z, BlockCandle block, int modelId, RenderBlocks renderer) {
private static boolean renderBlockCandle(IBlockAccess world, int x, int y, int z, BlockCandle block) {
int meta = world.getBlockMetadata(x, y, z);
IIcon iconA = block.getTextureFromPassAndMeta(meta, 0);
IIcon iconB = block.getTextureFromPassAndMeta(meta, 1);
meta = meta & 0x7;
TileCandle tc = (TileCandle) world.getTileEntity(x, y, z);
int colour = tc.getColour();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileCandle)) {
return false;
}
TileCandle tileCandle = (TileCandle) tileEntity;
boolean isLit = tileCandle.isLit();
IIcon iconA = block.getTextureFromPassAndLit(0, isLit);
IIcon iconB = block.getTextureFromPassAndLit(1, isLit);
int colour = tileCandle.getColour();
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(world.getLightBrightnessForSkyBlocks(x, y, z, block.getLightValue(world, x, y, z)));
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
@@ -68,26 +70,26 @@ public class BlockCandleRenderer implements ISimpleBlockRenderingHandler {
double d2 = 0.20000000298023224D;
if (meta == 1) {
this.renderCandleAtAngle(iconA, x - d1, y + d2, z, -d0, 0.0D, 0xffffff);
this.renderCandleAtAngle(iconB, x - d1, y + d2, z, -d0, 0.0D, colour);
renderCandleAtAngle(iconA, x - d1, y + d2, z, -d0, 0.0D, 0xffffff);
renderCandleAtAngle(iconB, x - d1, y + d2, z, -d0, 0.0D, colour);
} else if (meta == 2) {
this.renderCandleAtAngle(iconA, x + d1, y + d2, z, d0, 0.0D, 0xffffff);
this.renderCandleAtAngle(iconB, x + d1, y + d2, z, d0, 0.0D, colour);
renderCandleAtAngle(iconA, x + d1, y + d2, z, d0, 0.0D, 0xffffff);
renderCandleAtAngle(iconB, x + d1, y + d2, z, d0, 0.0D, colour);
} else if (meta == 3) {
this.renderCandleAtAngle(iconA, x, y + d2, z - d1, 0.0D, -d0, 0xffffff);
this.renderCandleAtAngle(iconB, x, y + d2, z - d1, 0.0D, -d0, colour);
renderCandleAtAngle(iconA, x, y + d2, z - d1, 0.0D, -d0, 0xffffff);
renderCandleAtAngle(iconB, x, y + d2, z - d1, 0.0D, -d0, colour);
} else if (meta == 4) {
this.renderCandleAtAngle(iconA, x, y + d2, z + d1, 0.0D, d0, 0xffffff);
this.renderCandleAtAngle(iconB, x, y + d2, z + d1, 0.0D, d0, colour);
renderCandleAtAngle(iconA, x, y + d2, z + d1, 0.0D, d0, 0xffffff);
renderCandleAtAngle(iconB, x, y + d2, z + d1, 0.0D, d0, colour);
} else {
this.renderCandleAtAngle(iconA, x, y, z, 0.0D, 0.0D, 0xffffff);
this.renderCandleAtAngle(iconB, x, y, z, 0.0D, 0.0D, colour);
renderCandleAtAngle(iconA, x, y, z, 0.0D, 0.0D, 0xffffff);
renderCandleAtAngle(iconB, x, y, z, 0.0D, 0.0D, colour);
}
return true;
}
public void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10, int colour) {
private static void renderCandleAtAngle(IIcon icon, double x, double y, double z, double par8, double par10, int colour) {
Tessellator tessellator = Tessellator.instance;
double minU = icon.getMinU();
double minV = icon.getMinV();
@@ -37,8 +37,7 @@ public class TriggerMissingDrone extends Trigger {
return false;
}
return ((IErrorSource) tile).getErrorState() == EnumErrorCode.NODRONE;
return ((IErrorSource) tile).getErrorStates().contains(EnumErrorCode.NODRONE);
}
}
@@ -37,6 +37,6 @@ public class TriggerMissingQueen extends Trigger {
return false;
}
return ((IErrorSource) tile).getErrorState() == EnumErrorCode.NOQUEEN;
return ((IErrorSource) tile).getErrorStates().contains(EnumErrorCode.NOQUEEN);
}
}
@@ -30,6 +30,7 @@ import net.minecraftforge.common.ChestGenHooks;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.core.EnumHumidity;
@@ -46,7 +47,6 @@ import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
import forestry.plugins.PluginManager;
public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
@@ -310,9 +310,9 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
TileBeehouse apiary = ((TileBeehouse) tile);
apiary.initialize();
apiary.setInventorySlotContents(TileBeehouse.SLOT_QUEEN,
PluginApiculture.beeInterface.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.PRINCESS.ordinal()));
BeeManager.beeRoot.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.PRINCESS.ordinal()));
apiary.setInventorySlotContents(TileBeehouse.SLOT_DRONE,
PluginApiculture.beeInterface.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.DRONE.ordinal()));
BeeManager.beeRoot.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.DRONE.ordinal()));
for (int i = TileBeehouse.SLOT_FRAMES_1; i < TileBeehouse.SLOT_FRAMES_1 + TileBeehouse.SLOT_FRAMES_COUNT; i++) {
float roll = world.rand.nextFloat();
@@ -329,7 +329,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
}
}
private IBee getVillageBee(World world, int xCoord, int yCoord, int zCoord) {
private static IBee getVillageBee(World world, int xCoord, int yCoord, int zCoord) {
// Get current biome
BiomeGenBase biome = world.getBiomeGenForCoords(xCoord, zCoord);
@@ -341,39 +341,30 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
candidates = BeeManager.villageBees[0];
}
EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, xCoord, yCoord, zCoord);
EnumHumidity biomeHumidity = EnumHumidity.getFromValue(biome.rainfall);
// Add bees that can live in this environment
ArrayList<IBeeGenome> valid = new ArrayList<IBeeGenome>();
List<IBeeGenome> valid = new ArrayList<IBeeGenome>();
for (IBeeGenome genome : candidates) {
if (checkBiomeHazard(genome, biome.temperature, biome.rainfall)) {
if (checkBiomeHazard(genome, biomeTemperature, biomeHumidity)) {
valid.add(genome);
}
}
// No valid ones found, return any of the common ones.
if (valid.isEmpty()) {
return PluginApiculture.beeInterface.getBee(world, BeeManager.villageBees[0].get(world.rand.nextInt(BeeManager.villageBees[0].size())));
return BeeManager.beeRoot.getBee(world, BeeManager.villageBees[0].get(world.rand.nextInt(BeeManager.villageBees[0].size())));
}
return PluginApiculture.beeInterface.getBee(world, valid.get(world.rand.nextInt(valid.size())));
return BeeManager.beeRoot.getBee(world, valid.get(world.rand.nextInt(valid.size())));
}
private boolean checkBiomeHazard(IBeeGenome genome, float temperature, float humidity) {
EnumTemperature beeTemperature = genome.getPrimary().getTemperature();
EnumTolerance temperatureTolerance = genome.getToleranceTemp();
Collection<EnumTemperature> toleratedTemperatures = AlleleManager.climateHelper.getToleratedTemperature(beeTemperature, temperatureTolerance);
if (!toleratedTemperatures.contains(EnumTemperature.getFromValue(temperature))) {
return false;
}
EnumHumidity beeHumidity = genome.getPrimary().getHumidity();
EnumTolerance humidityTolerance = genome.getToleranceHumid();
Collection<EnumHumidity> toleratedHumidity = AlleleManager.climateHelper.getToleratedHumidity(beeHumidity, humidityTolerance);
return toleratedHumidity.contains(EnumHumidity.getFromValue(humidity));
private static boolean checkBiomeHazard(IBeeGenome genome, EnumTemperature biomeTemperature, EnumHumidity biomeHumidity) {
IAlleleBeeSpecies species = genome.getPrimary();
return AlleleManager.climateHelper.isWithinLimits(biomeTemperature, biomeHumidity,
species.getTemperature(), genome.getToleranceTemp(),
species.getHumidity(), genome.getToleranceHumid());
}
protected void fillBoxWith(World world, StructureBoundingBox box, int par3, int par4, int par5, int par6, int par7, int par8, ItemStack buildingBlock,
@@ -26,24 +26,22 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import forestry.apiculture.genetics.BeeTemplates;
import forestry.apiculture.genetics.BeeDefinition;
import forestry.core.config.ForestryBlock;
import forestry.plugins.PluginApiculture;
public enum HiveDescription implements IHiveDescription {
FOREST(1, 3.0f, BeeTemplates.getForestTemplate(), HiveManager.genHelper.tree()),
MEADOWS(2, 1.0f, BeeTemplates.getMeadowsTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),
DESERT(3, 1.0f, BeeTemplates.getModestTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.sand, Blocks.sandstone)),
JUNGLE(4, 4.0f, BeeTemplates.getTropicalTemplate(), HiveManager.genHelper.tree()),
END(5, 4.0f, BeeTemplates.getEnderTemplate(), HiveManager.genHelper.ground(Blocks.end_stone)) {
FOREST(1, 3.0f, BeeDefinition.FOREST, HiveManager.genHelper.tree()),
MEADOWS(2, 1.0f, BeeDefinition.MEADOWS, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),
DESERT(3, 1.0f, BeeDefinition.MODEST, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.sand, Blocks.sandstone)),
JUNGLE(4, 4.0f, BeeDefinition.TROPICAL, HiveManager.genHelper.tree()),
END(5, 4.0f, BeeDefinition.ENDED, HiveManager.genHelper.ground(Blocks.end_stone)) {
@Override
public boolean isGoodBiome(BiomeGenBase biome) {
return BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.END);
}
},
SNOW(6, 2.0f, BeeTemplates.getWintryTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow)) {
SNOW(6, 2.0f, BeeDefinition.WINTRY, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass, Blocks.snow)) {
@Override
public void postGen(World world, int x, int y, int z) {
if (world.isAirBlock(x, y + 1, z)) {
@@ -51,17 +49,17 @@ public enum HiveDescription implements IHiveDescription {
}
}
},
SWAMP(7, 2.0f, BeeTemplates.getMarshyTemplate(), HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),;
SWAMP(7, 2.0f, BeeDefinition.MARSHY, HiveManager.genHelper.ground(Blocks.dirt, Blocks.grass)),;
private final int meta;
private final float genChance;
private final IBeeGenome beeGenome;
private final IHiveGen hiveGen;
HiveDescription(int meta, float genChance, IAllele[] beeTemplate, IHiveGen hiveGen) {
HiveDescription(int meta, float genChance, BeeDefinition beeTemplate, IHiveGen hiveGen) {
this.meta = meta;
this.genChance = genChance;
this.beeGenome = PluginApiculture.beeInterface.templateAsGenome(beeTemplate);
this.beeGenome = beeTemplate.getGenome();
this.hiveGen = hiveGen;
}
@@ -11,6 +11,7 @@
package forestry.apiculture.worldgen;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -33,6 +34,11 @@ public class HiveRegistry implements IHiveRegistry {
hives.put(hiveName, hive);
}
@Override
public void addDrops(String hiveName, IHiveDrop... drops) {
addDrops(hiveName, Arrays.asList(drops));
}
@Override
public void addDrops(String hiveName, List<IHiveDrop> drops) {
Hive hive = hives.get(hiveName);
@@ -1,54 +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.arboriculture;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.event.entity.player.BonemealEvent;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import forestry.api.genetics.IFruitBearer;
import forestry.arboriculture.gadgets.TileFruitPod;
import forestry.arboriculture.gadgets.TileSapling;
import forestry.core.proxy.Proxies;
public class EventHandlerArboriculture {
@SubscribeEvent
public void handleBonemeal(BonemealEvent event) {
if (!Proxies.common.isSimulating(event.world)) {
return;
}
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
if (tile instanceof TileSapling) {
int result = ((TileSapling) tile).tryGrow(true);
if (result == 1 || result == 2) {
event.setResult(Result.ALLOW);
}
} else if (tile instanceof TileFruitPod) {
if (((TileFruitPod) tile).canMature()) {
((TileFruitPod) tile).mature();
event.setResult(Result.ALLOW);
}
} else if (tile instanceof IFruitBearer) {
IFruitBearer bearer = (IFruitBearer) tile;
if (bearer.getRipeness() < 1.0f) {
bearer.addRipeness(1.0f);
event.setResult(Result.ALLOW);
}
}
}
}
@@ -1,82 +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.arboriculture;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.arboriculture.gadgets.TileSapling;
import forestry.arboriculture.network.PacketLeaf;
import forestry.arboriculture.network.PacketRipeningUpdate;
import forestry.arboriculture.network.PacketSapling;
import forestry.core.interfaces.IPacketHandler;
import forestry.core.network.PacketIds;
import forestry.core.proxy.Proxies;
public class PacketHandlerArboriculture implements IPacketHandler {
@Override
public boolean onPacketData(int packetID, DataInputStream data, EntityPlayer player) throws IOException {
switch (packetID) {
case PacketIds.SAPLING: {
PacketSapling packet = new PacketSapling();
packet.readData(data);
onSaplingPacket(packet);
return true;
}
case PacketIds.LEAF: {
PacketLeaf packet = new PacketLeaf();
packet.readData(data);
onLeafPacket(packet);
return true;
}
case PacketIds.RIPENING_UPDATE: {
PacketRipeningUpdate packet = new PacketRipeningUpdate();
packet.readData(data);
onRipeningUpdate(packet);
return true;
}
}
return false;
}
private void onSaplingPacket(PacketSapling packet) {
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileSapling) {
((TileSapling) tile).fromPacket(packet);
}
}
private void onLeafPacket(PacketLeaf packet) {
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileLeaves) {
((TileLeaves) tile).fromPacket(packet);
}
}
private void onRipeningUpdate(PacketRipeningUpdate packet) {
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileLeaves) {
((TileLeaves) tile).fromRipeningPacket(packet);
}
}
}
@@ -79,7 +79,7 @@ public class BlockArbStairs extends BlockStairs {
ItemStack stack = new ItemStack(this, 1, 0);
NBTTagCompound compound = new NBTTagCompound();
stairs.getType().saveToCompound(compound);
stairs.getWoodType().saveToCompound(compound);
stack.setTagCompound(compound);
StackUtils.dropItemStackAsEntity(stack, world, x, y, z);
}
@@ -122,11 +122,11 @@ public class BlockArbStairs extends BlockStairs {
TileStairs stairs = getStairTile(world, x, y, z);
NBTTagCompound nbttagcompound = new NBTTagCompound();
if (stairs == null || stairs.getType() == null) {
if (stairs == null || stairs.getWoodType() == null) {
return nbttagcompound;
}
stairs.getType().saveToCompound(nbttagcompound);
stairs.getWoodType().saveToCompound(nbttagcompound);
return nbttagcompound;
}
@@ -141,8 +141,8 @@ public class BlockArbStairs extends BlockStairs {
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileStairs stairs = getStairTile(world, x, y, z);
if (stairs != null && stairs.getType() != null) {
return stairs.getType().getPlankIcon();
if (stairs != null && stairs.getWoodType() != null) {
return stairs.getWoodType().getPlankIcon();
} else {
return WoodType.LARCH.getPlankIcon();
}
@@ -139,4 +139,30 @@ public class BlockFruitPod extends BlockCocoa {
return PluginArboriculture.modelIdPods;
}
/* IGrowable */
@Override
// canFertilize
public boolean func_149851_a(World world, int x, int y, int z, boolean isClient) {
TileFruitPod podTile = getPodTile(world, x, y, z);
if (podTile != null) {
return podTile.canMature();
}
return false;
}
@Override
// shouldFertilize
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
return true;
}
@Override
// fertilize
public void func_149853_b(World world, Random random, int x, int y, int z) {
TileFruitPod podTile = getPodTile(world, x, y, z);
if (podTile != null) {
podTile.mature();
}
}
}
@@ -11,8 +11,10 @@
package forestry.arboriculture.gadgets;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@@ -37,7 +39,7 @@ import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginArboriculture;
public class BlockSapling extends BlockTreeContainer {
public class BlockSapling extends BlockTreeContainer implements IGrowable {
public static TileSapling getSaplingTile(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
@@ -186,4 +188,25 @@ public class BlockSapling extends BlockTreeContainer {
}
}
@Override
/** canFertilize */
public boolean func_149851_a(World worldIn, int x, int y, int z, boolean isClient) {
return true;
}
@Override
/** shouldFertilize */
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
return (double) world.rand.nextFloat() < 0.45D;
}
@Override
/** fertilize */
public void func_149853_b(World world, Random random, int x, int y, int z) {
TileSapling saplingTile = getSaplingTile(world, x, y, z);
if (saplingTile != null) {
saplingTile.tryGrow(true);
}
}
}
@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.IGrowable;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -49,7 +50,7 @@ import forestry.core.utils.StackUtils;
import forestry.plugins.PluginArboriculture;
import forestry.plugins.PluginLepidopterology;
public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider {
public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider, IGrowable {
public ForestryBlockLeaves() {
this.setCreativeTab(Tabs.tabArboriculture);
@@ -328,4 +329,30 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv
return super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
}
/* IGrowable */
@Override
// canFertilize
public boolean func_149851_a(World world, int x, int y, int z, boolean isClient) {
TileLeaves leafTile = getLeafTile(world, x, y, z);
if (leafTile != null) {
return leafTile.hasFruit() && leafTile.getRipeness() < 1.0f;
}
return false;
}
@Override
// shouldFertilize
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
return true;
}
@Override
// fertilize
public void func_149853_b(World world, Random random, int x, int y, int z) {
TileLeaves leafTile = getLeafTile(world, x, y, z);
if (leafTile != null) {
leafTile.addRipeness(1.0f);
}
}
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.arboriculture.gadgets;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -28,15 +29,15 @@ import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IFruitBearer;
import forestry.api.genetics.IFruitFamily;
import forestry.core.network.ForestryPacket;
import forestry.core.network.INetworkedEntity;
import forestry.core.network.PacketIds;
import forestry.core.network.PacketPayload;
import forestry.core.network.PacketUpdate;
import forestry.arboriculture.network.PacketRipeningUpdate;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
import forestry.core.network.PacketTileStream;
import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruitBearer {
public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamable {
private static final short MAX_MATURITY = 2;
@@ -130,36 +131,18 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit
/* NETWORK */
@Override
public Packet getDescriptionPacket() {
return toPacket().getPacket();
}
@Override
public void sendNetworkUpdate() {
Proxies.net.sendNetworkPacket(toPacket(), xCoord, yCoord, zCoord);
return new PacketTileStream(this).getPacket();
}
private void sendNetworkUpdateRipening() {
Proxies.net.sendNetworkPacket(new PacketUpdate(PacketIds.TILE_UPDATE, xCoord, yCoord, zCoord, maturity), xCoord, yCoord, zCoord);
Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this));
}
private ForestryPacket toPacket() {
PacketPayload payload = new PacketPayload(indices.length, 1);
payload.shortPayload[0] = maturity;
payload.intPayload = indices;
return new PacketUpdate(PacketIds.TILE_UPDATE, xCoord, yCoord, zCoord, payload);
}
@Override
public void fromPacket(ForestryPacket packetRaw) {
PacketUpdate packet = (PacketUpdate) packetRaw;
maturity = packet.payload.shortPayload[0];
if (packet.payload.intPayload != null && packet.payload.intPayload.length > 0) {
indices = packet.payload.intPayload;
public void fromRipeningPacket(int newMaturity) {
if (newMaturity == maturity) {
return;
}
maturity = (short) newMaturity;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
@@ -183,7 +166,6 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit
return new ArrayList<ItemStack>();
}
Collection<ItemStack> fruits = Arrays.asList(getDrop());
maturity = 0;
sendNetworkUpdateRipening();
@@ -201,4 +183,24 @@ public class TileFruitPod extends TileEntity implements INetworkedEntity, IFruit
sendNetworkUpdateRipening();
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
data.writeShort(maturity);
data.writeShort(indices.length);
for (int i : indices) {
data.writeInt(i);
}
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
maturity = data.readShort();
int indicesLength = data.readShort();
indices = new int[indicesLength];
for (int i = 0; i < indicesLength; i++) {
indices[i] = data.readInt();
}
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.arboriculture.gadgets;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -31,6 +34,7 @@ import net.minecraftforge.common.EnumPlantType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ILeafTickHandler;
@@ -41,6 +45,7 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorState;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IFruitBearer;
import forestry.api.genetics.IFruitFamily;
@@ -50,11 +55,12 @@ import forestry.api.lepidopterology.IButterfly;
import forestry.api.lepidopterology.IButterflyGenome;
import forestry.api.lepidopterology.IButterflyNursery;
import forestry.api.lepidopterology.IButterflyRoot;
import forestry.arboriculture.network.PacketLeaf;
import forestry.arboriculture.network.PacketRipeningUpdate;
import forestry.core.EnumErrorCode;
import forestry.core.genetics.Allele;
import forestry.core.network.ForestryPacket;
import forestry.core.genetics.alleles.Allele;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketTileStream;
import forestry.core.proxy.Proxies;
import forestry.core.render.TextureManager;
import forestry.core.utils.GeneticsUtil;
@@ -89,7 +95,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
if (worldObj == null) {
return;
}
biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
}
/* SAVING & LOADING */
@@ -322,19 +328,21 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
}
public String getUnlocalizedName() {
return getTree().getGenome().getPrimary().getUnlocalizedName();
ITree tree = getTree();
if (tree == null) {
return "for.leaves.corrupted";
}
return tree.getGenome().getPrimary().getUnlocalizedName();
}
/* NETWORK */
@Override
public Packet getDescriptionPacket() {
return new PacketLeaf(this).getPacket();
return new PacketTileStream(this).getPacket();
}
@Override
public void sendNetworkUpdate() {
PacketLeaf packet = new PacketLeaf(this);
Proxies.net.sendNetworkPacket(packet, xCoord, yCoord, zCoord);
Proxies.net.sendNetworkPacket(new PacketTileStream(this));
}
private void sendNetworkUpdateRipening() {
@@ -345,31 +353,75 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
colourFruits = newColourFruits;
PacketRipeningUpdate ripeningUpdate = new PacketRipeningUpdate(this);
Proxies.net.sendNetworkPacket(ripeningUpdate, xCoord, yCoord, zCoord);
Proxies.net.sendNetworkPacket(ripeningUpdate);
}
private static final short hasFruitFlag = 1;
private static final short isPollinatedFlag = 1 << 1;
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
byte leafState = 0;
boolean hasFruit = hasFruit();
if (isPollinated()) {
leafState |= isPollinatedFlag;
}
if (hasFruit) {
leafState |= hasFruitFlag;
}
data.writeByte(leafState);
if (hasFruit) {
String fruitAlleleUID = getTree().getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).getUID();
int colourFruits = getFruitColour();
data.writeUTF(fruitAlleleUID);
data.writeInt(colourFruits);
}
}
@Override
public void fromPacket(ForestryPacket packetRaw) {
PacketLeaf packet = (PacketLeaf) packetRaw;
public void readData(DataInputStreamForestry data) throws IOException {
isFruitLeaf = packet.isFruitLeaf();
isPollinatedState = packet.isPollinated();
String speciesUID = data.readUTF(); // this is called instead of super.readData, be careful!
colourFruits = packet.getColourFruits();
byte leafState = data.readByte();
isFruitLeaf = (leafState & hasFruitFlag) > 0;
isPollinatedState = (leafState & isPollinatedFlag) > 0;
String fruitAlleleUID = null;
ITree tree = getTree();
if (!packet.matchesTree(tree)) {
ITree newTree = packet.getTree();
if (newTree != null) {
setTree(newTree);
if (isFruitLeaf) {
fruitAlleleUID = data.readUTF();
colourFruits = data.readInt();
}
IAllele[] treeTemplate = PluginArboriculture.treeInterface.getTemplate(speciesUID);
if (fruitAlleleUID != null) {
IAllele fruitAllele = AlleleManager.alleleRegistry.getAllele(fruitAlleleUID);
if (fruitAllele != null) {
treeTemplate[EnumTreeChromosome.FRUITS.ordinal()] = fruitAllele;
}
}
worldObj.func_147479_m(xCoord, yCoord, zCoord);
if (treeTemplate != null) {
ITree tree = PluginArboriculture.treeInterface.templateAsIndividual(treeTemplate);
if (isPollinatedState) {
tree.mate(tree);
}
setTree(tree);
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
public void fromRipeningPacket(PacketRipeningUpdate packet) {
int newColourFruits = packet.getColourFruits();
public void fromRipeningPacket(int newColourFruits) {
if (newColourFruits == colourFruits) {
return;
}
@@ -463,7 +515,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
}
}
private void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) {
private static void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) {
IButterflyRoot butterflyRoot = (IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies");
if (butterflyRoot.spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.1f, z) != null) {
Proxies.log.finest("A caterpillar '%s' hatched at %s/%s/%s.", butterfly.getDisplayName(), x, y, z);
@@ -490,11 +542,6 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
return zCoord;
}
@Override
public int getBiomeId() {
return biome.biomeID;
}
@Override
public BiomeGenBase getBiome() {
return biome;
@@ -511,18 +558,19 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
}
@Override
public void setErrorState(int state) {
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
return condition;
}
@Override
public ImmutableSet<IErrorState> getErrorStates() {
return ImmutableSet.of();
}
@Override
public void setErrorState(IErrorState state) {
}
@Override
public int getErrorOrdinal() {
return 0;
}
@Override
public EnumErrorCode getErrorState() {
return null;
@@ -562,6 +610,6 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
/* IHousing */
@Override
public GameProfile getOwnerName() {
return this.getOwnerProfile();
return this.getOwner();
}
}
Loaded 100 of 472 files, more files were not shown because too many files have changed in this diff. Show more