From 95deff231286189ac6c04999755d956434eadf92 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 14 Jun 2014 12:53:13 +1000 Subject: [PATCH] Readded Forestry integration --- .../forestry/api/apiculture/BeeManager.java | 46 ++++ .../api/apiculture/EnumBeeChromosome.java | 103 ++++++++ .../forestry/api/apiculture/EnumBeeType.java | 24 ++ .../api/apiculture/FlowerManager.java | 19 ++ .../api/apiculture/IAlleleBeeEffect.java | 36 +++ .../api/apiculture/IAlleleBeeSpecies.java | 53 ++++ .../api/apiculture/IAlvearyComponent.java | 32 +++ .../api/apiculture/IApiaristTracker.java | 57 +++++ .../api/apiculture/IArmorApiarist.java | 29 +++ .../java/forestry/api/apiculture/IBee.java | 91 +++++++ .../forestry/api/apiculture/IBeeGenome.java | 48 ++++ .../forestry/api/apiculture/IBeeHousing.java | 27 +++ .../forestry/api/apiculture/IBeeListener.java | 46 ++++ .../forestry/api/apiculture/IBeeModifier.java | 71 ++++++ .../forestry/api/apiculture/IBeeMutation.java | 25 ++ .../forestry/api/apiculture/IBeeRoot.java | 117 +++++++++ .../api/apiculture/IBeekeepingLogic.java | 27 +++ .../api/apiculture/IBeekeepingMode.java | 70 ++++++ .../forestry/api/apiculture/IHiveDrop.java | 38 +++ .../forestry/api/apiculture/IHiveFrame.java | 27 +++ .../forestry/api/apiculture/package-info.java | 8 + .../api/arboriculture/EnumGermlingType.java | 23 ++ .../arboriculture/EnumGrowthConditions.java | 10 + .../api/arboriculture/EnumTreeChromosome.java | 92 +++++++ .../api/arboriculture/IAlleleFruit.java | 17 ++ .../api/arboriculture/IAlleleGrowth.java | 17 ++ .../api/arboriculture/IAlleleLeafEffect.java | 20 ++ .../api/arboriculture/IAlleleTreeSpecies.java | 75 ++++++ .../api/arboriculture/IArboristTracker.java | 12 + .../api/arboriculture/IFruitProvider.java | 74 ++++++ .../api/arboriculture/IGrowthProvider.java | 38 +++ .../api/arboriculture/ILeafTickHandler.java | 12 + .../api/arboriculture/IToolGrafter.java | 24 ++ .../forestry/api/arboriculture/ITree.java | 99 ++++++++ .../api/arboriculture/ITreeGenome.java | 46 ++++ .../api/arboriculture/ITreeModifier.java | 45 ++++ .../api/arboriculture/ITreeMutation.java | 34 +++ .../forestry/api/arboriculture/ITreeRoot.java | 83 +++++++ .../api/arboriculture/ITreekeepingMode.java | 22 ++ .../api/arboriculture/TreeManager.java | 16 ++ .../api/arboriculture/package-info.java | 8 + .../forestry/api/circuits/ChipsetManager.java | 13 + .../java/forestry/api/circuits/ICircuit.java | 32 +++ .../forestry/api/circuits/ICircuitBoard.java | 32 +++ .../forestry/api/circuits/ICircuitLayout.java | 16 ++ .../api/circuits/ICircuitLibrary.java | 10 + .../api/circuits/ICircuitRegistry.java | 42 ++++ .../forestry/api/circuits/ISolderManager.java | 14 ++ .../forestry/api/circuits/package-info.java | 8 + .../forestry/api/core/BlockInterface.java | 40 +++ .../java/forestry/api/core/EnumHumidity.java | 77 ++++++ .../forestry/api/core/EnumTemperature.java | 150 ++++++++++++ .../java/forestry/api/core/ForestryAPI.java | 52 ++++ .../java/forestry/api/core/ForestryEvent.java | 58 +++++ .../forestry/api/core/IArmorNaturalist.java | 25 ++ .../forestry/api/core/IForestryConstants.java | 24 ++ src/api/java/forestry/api/core/IGameMode.java | 41 ++++ .../java/forestry/api/core/IIconProvider.java | 25 ++ .../java/forestry/api/core/INBTTagable.java | 14 ++ src/api/java/forestry/api/core/IPlugin.java | 37 +++ .../forestry/api/core/IStructureLogic.java | 20 ++ .../forestry/api/core/ITextureManager.java | 21 ++ .../forestry/api/core/ITileStructure.java | 63 +++++ .../java/forestry/api/core/IToolScoop.java | 13 + .../java/forestry/api/core/ItemInterface.java | 49 ++++ .../java/forestry/api/core/PluginInfo.java | 54 +++++ src/api/java/forestry/api/core/Tabs.java | 19 ++ .../java/forestry/api/core/package-info.java | 8 + .../java/forestry/api/farming/Farmables.java | 20 ++ src/api/java/forestry/api/farming/ICrop.java | 21 ++ .../forestry/api/farming/IFarmComponent.java | 17 ++ .../forestry/api/farming/IFarmHousing.java | 74 ++++++ .../forestry/api/farming/IFarmInterface.java | 20 ++ .../forestry/api/farming/IFarmListener.java | 77 ++++++ .../java/forestry/api/farming/IFarmLogic.java | 41 ++++ .../java/forestry/api/farming/IFarmable.java | 59 +++++ .../forestry/api/farming/package-info.java | 8 + .../forestry/api/food/BeverageManager.java | 13 + .../forestry/api/food/IBeverageEffect.java | 17 ++ .../forestry/api/food/IInfuserManager.java | 22 ++ .../forestry/api/food/IIngredientManager.java | 16 ++ .../java/forestry/api/food/package-info.java | 8 + .../forestry/api/fuels/EngineBronzeFuel.java | 34 +++ .../forestry/api/fuels/EngineCopperFuel.java | 31 +++ .../forestry/api/fuels/FermenterFuel.java | 29 +++ .../java/forestry/api/fuels/FuelManager.java | 34 +++ .../forestry/api/fuels/GeneratorFuel.java | 35 +++ .../forestry/api/fuels/MoistenerFuel.java | 34 +++ .../forestry/api/fuels/RainSubstrate.java | 40 +++ .../java/forestry/api/fuels/package-info.java | 8 + .../forestry/api/genetics/AlleleManager.java | 32 +++ .../forestry/api/genetics/EnumTolerance.java | 16 ++ .../java/forestry/api/genetics/IAllele.java | 34 +++ .../forestry/api/genetics/IAlleleArea.java | 15 ++ .../forestry/api/genetics/IAlleleBoolean.java | 16 ++ .../forestry/api/genetics/IAlleleEffect.java | 26 ++ .../forestry/api/genetics/IAlleleFloat.java | 15 ++ .../forestry/api/genetics/IAlleleFlowers.java | 16 ++ .../forestry/api/genetics/IAlleleHandler.java | 41 ++++ .../forestry/api/genetics/IAlleleInteger.java | 15 ++ .../api/genetics/IAllelePlantType.java | 16 ++ .../api/genetics/IAlleleRegistry.java | 227 ++++++++++++++++++ .../forestry/api/genetics/IAlleleSpecies.java | 113 +++++++++ .../api/genetics/IAlleleTolerance.java | 15 ++ .../api/genetics/IBreedingTracker.java | 99 ++++++++ .../forestry/api/genetics/IChromosome.java | 25 ++ .../api/genetics/IChromosomeType.java | 24 ++ .../api/genetics/IClassification.java | 107 +++++++++ .../forestry/api/genetics/IClimateHelper.java | 50 ++++ .../forestry/api/genetics/IEffectData.java | 27 +++ .../api/genetics/IFlowerProvider.java | 56 +++++ .../forestry/api/genetics/IFruitBearer.java | 50 ++++ .../forestry/api/genetics/IFruitFamily.java | 32 +++ .../java/forestry/api/genetics/IGenome.java | 30 +++ .../java/forestry/api/genetics/IHousing.java | 52 ++++ .../forestry/api/genetics/IIndividual.java | 57 +++++ .../api/genetics/IIndividualLiving.java | 45 ++++ .../forestry/api/genetics/ILegacyHandler.java | 15 ++ .../java/forestry/api/genetics/IMutation.java | 68 ++++++ .../forestry/api/genetics/IPollinatable.java | 48 ++++ .../forestry/api/genetics/ISpeciesRoot.java | 165 +++++++++++++ .../forestry/api/genetics/package-info.java | 8 + .../EnumButterflyChromosome.java | 98 ++++++++ .../api/lepidopterology/EnumFlutterType.java | 15 ++ .../IAlleleButterflyEffect.java | 21 ++ .../IAlleleButterflySpecies.java | 59 +++++ .../api/lepidopterology/IButterfly.java | 77 ++++++ .../api/lepidopterology/IButterflyGenome.java | 42 ++++ .../lepidopterology/IButterflyMutation.java | 14 ++ .../lepidopterology/IButterflyNursery.java | 21 ++ .../api/lepidopterology/IButterflyRoot.java | 60 +++++ .../api/lepidopterology/IEntityButterfly.java | 29 +++ .../ILepidopteristTracker.java | 14 ++ .../api/lepidopterology/package-info.java | 8 + .../java/forestry/api/mail/EnumPostage.java | 20 ++ src/api/java/forestry/api/mail/ILetter.java | 60 +++++ .../forestry/api/mail/ILetterHandler.java | 13 + .../java/forestry/api/mail/IPostOffice.java | 30 +++ .../java/forestry/api/mail/IPostRegistry.java | 52 ++++ .../forestry/api/mail/IPostalCarrier.java | 48 ++++ .../java/forestry/api/mail/IPostalState.java | 14 ++ src/api/java/forestry/api/mail/IStamps.java | 14 ++ .../java/forestry/api/mail/ITradeStation.java | 24 ++ .../java/forestry/api/mail/MailAddress.java | 60 +++++ .../java/forestry/api/mail/PostManager.java | 11 + .../forestry/api/mail/TradeStationInfo.java | 24 ++ .../java/forestry/api/mail/package-info.java | 8 + src/api/java/forestry/api/package-info.java | 8 + .../forestry/api/recipes/IBottlerManager.java | 40 +++ .../api/recipes/ICarpenterManager.java | 71 ++++++ .../api/recipes/ICentrifugeManager.java | 79 ++++++ .../api/recipes/ICraftingProvider.java | 17 ++ .../api/recipes/IFabricatorManager.java | 18 ++ .../api/recipes/IFermenterManager.java | 53 ++++ .../forestry/api/recipes/IGenericCrate.java | 16 ++ .../api/recipes/IMoistenerManager.java | 33 +++ .../api/recipes/ISqueezerManager.java | 51 ++++ .../forestry/api/recipes/IStillManager.java | 34 +++ .../api/recipes/IVariableFermentable.java | 21 ++ .../forestry/api/recipes/RecipeManagers.java | 49 ++++ .../forestry/api/recipes/package-info.java | 8 + .../forestry/api/storage/BackpackEvent.java | 25 ++ .../forestry/api/storage/BackpackManager.java | 27 +++ .../api/storage/BackpackResupplyEvent.java | 24 ++ .../api/storage/BackpackStowEvent.java | 27 +++ .../api/storage/EnumBackpackType.java | 10 + .../api/storage/IBackpackDefinition.java | 59 +++++ .../api/storage/IBackpackInterface.java | 22 ++ .../forestry/api/storage/package-info.java | 8 + .../java/forestry/api/world/ITreeGenData.java | 23 ++ .../api/world/IWorldGenInterface.java | 22 ++ .../forestry/api/world/WorldGenManager.java | 10 + .../java/forestry/api/world/package-info.java | 8 + .../java/biomesoplenty/BiomesOPlenty.java | 3 + .../java/biomesoplenty/api/package-info.java | 4 + .../biomesoplenty/common/blocks/BlockAsh.java | 2 +- .../common/blocks/BlockBOPGrass.java | 2 +- .../common/blocks/BlockBamboo.java | 2 +- .../common/blocks/BlockFlesh.java | 2 +- .../biomesoplenty/common/blocks/BlockMud.java | 2 +- .../common/integration/BOPIntegration.java | 32 +++ .../integration/ForestryIntegration.java | 107 +++++++++ 182 files changed, 6681 insertions(+), 5 deletions(-) create mode 100755 src/api/java/forestry/api/apiculture/BeeManager.java create mode 100755 src/api/java/forestry/api/apiculture/EnumBeeChromosome.java create mode 100755 src/api/java/forestry/api/apiculture/EnumBeeType.java create mode 100755 src/api/java/forestry/api/apiculture/FlowerManager.java create mode 100755 src/api/java/forestry/api/apiculture/IAlleleBeeEffect.java create mode 100755 src/api/java/forestry/api/apiculture/IAlleleBeeSpecies.java create mode 100755 src/api/java/forestry/api/apiculture/IAlvearyComponent.java create mode 100755 src/api/java/forestry/api/apiculture/IApiaristTracker.java create mode 100755 src/api/java/forestry/api/apiculture/IArmorApiarist.java create mode 100755 src/api/java/forestry/api/apiculture/IBee.java create mode 100755 src/api/java/forestry/api/apiculture/IBeeGenome.java create mode 100755 src/api/java/forestry/api/apiculture/IBeeHousing.java create mode 100755 src/api/java/forestry/api/apiculture/IBeeListener.java create mode 100755 src/api/java/forestry/api/apiculture/IBeeModifier.java create mode 100755 src/api/java/forestry/api/apiculture/IBeeMutation.java create mode 100755 src/api/java/forestry/api/apiculture/IBeeRoot.java create mode 100755 src/api/java/forestry/api/apiculture/IBeekeepingLogic.java create mode 100755 src/api/java/forestry/api/apiculture/IBeekeepingMode.java create mode 100755 src/api/java/forestry/api/apiculture/IHiveDrop.java create mode 100755 src/api/java/forestry/api/apiculture/IHiveFrame.java create mode 100755 src/api/java/forestry/api/apiculture/package-info.java create mode 100755 src/api/java/forestry/api/arboriculture/EnumGermlingType.java create mode 100755 src/api/java/forestry/api/arboriculture/EnumGrowthConditions.java create mode 100755 src/api/java/forestry/api/arboriculture/EnumTreeChromosome.java create mode 100755 src/api/java/forestry/api/arboriculture/IAlleleFruit.java create mode 100755 src/api/java/forestry/api/arboriculture/IAlleleGrowth.java create mode 100755 src/api/java/forestry/api/arboriculture/IAlleleLeafEffect.java create mode 100755 src/api/java/forestry/api/arboriculture/IAlleleTreeSpecies.java create mode 100755 src/api/java/forestry/api/arboriculture/IArboristTracker.java create mode 100755 src/api/java/forestry/api/arboriculture/IFruitProvider.java create mode 100755 src/api/java/forestry/api/arboriculture/IGrowthProvider.java create mode 100755 src/api/java/forestry/api/arboriculture/ILeafTickHandler.java create mode 100755 src/api/java/forestry/api/arboriculture/IToolGrafter.java create mode 100755 src/api/java/forestry/api/arboriculture/ITree.java create mode 100755 src/api/java/forestry/api/arboriculture/ITreeGenome.java create mode 100755 src/api/java/forestry/api/arboriculture/ITreeModifier.java create mode 100755 src/api/java/forestry/api/arboriculture/ITreeMutation.java create mode 100755 src/api/java/forestry/api/arboriculture/ITreeRoot.java create mode 100755 src/api/java/forestry/api/arboriculture/ITreekeepingMode.java create mode 100755 src/api/java/forestry/api/arboriculture/TreeManager.java create mode 100755 src/api/java/forestry/api/arboriculture/package-info.java create mode 100755 src/api/java/forestry/api/circuits/ChipsetManager.java create mode 100755 src/api/java/forestry/api/circuits/ICircuit.java create mode 100755 src/api/java/forestry/api/circuits/ICircuitBoard.java create mode 100755 src/api/java/forestry/api/circuits/ICircuitLayout.java create mode 100755 src/api/java/forestry/api/circuits/ICircuitLibrary.java create mode 100755 src/api/java/forestry/api/circuits/ICircuitRegistry.java create mode 100755 src/api/java/forestry/api/circuits/ISolderManager.java create mode 100755 src/api/java/forestry/api/circuits/package-info.java create mode 100755 src/api/java/forestry/api/core/BlockInterface.java create mode 100755 src/api/java/forestry/api/core/EnumHumidity.java create mode 100755 src/api/java/forestry/api/core/EnumTemperature.java create mode 100755 src/api/java/forestry/api/core/ForestryAPI.java create mode 100755 src/api/java/forestry/api/core/ForestryEvent.java create mode 100755 src/api/java/forestry/api/core/IArmorNaturalist.java create mode 100755 src/api/java/forestry/api/core/IForestryConstants.java create mode 100755 src/api/java/forestry/api/core/IGameMode.java create mode 100755 src/api/java/forestry/api/core/IIconProvider.java create mode 100755 src/api/java/forestry/api/core/INBTTagable.java create mode 100755 src/api/java/forestry/api/core/IPlugin.java create mode 100755 src/api/java/forestry/api/core/IStructureLogic.java create mode 100755 src/api/java/forestry/api/core/ITextureManager.java create mode 100755 src/api/java/forestry/api/core/ITileStructure.java create mode 100755 src/api/java/forestry/api/core/IToolScoop.java create mode 100755 src/api/java/forestry/api/core/ItemInterface.java create mode 100755 src/api/java/forestry/api/core/PluginInfo.java create mode 100755 src/api/java/forestry/api/core/Tabs.java create mode 100755 src/api/java/forestry/api/core/package-info.java create mode 100755 src/api/java/forestry/api/farming/Farmables.java create mode 100755 src/api/java/forestry/api/farming/ICrop.java create mode 100755 src/api/java/forestry/api/farming/IFarmComponent.java create mode 100755 src/api/java/forestry/api/farming/IFarmHousing.java create mode 100755 src/api/java/forestry/api/farming/IFarmInterface.java create mode 100755 src/api/java/forestry/api/farming/IFarmListener.java create mode 100755 src/api/java/forestry/api/farming/IFarmLogic.java create mode 100755 src/api/java/forestry/api/farming/IFarmable.java create mode 100755 src/api/java/forestry/api/farming/package-info.java create mode 100755 src/api/java/forestry/api/food/BeverageManager.java create mode 100755 src/api/java/forestry/api/food/IBeverageEffect.java create mode 100755 src/api/java/forestry/api/food/IInfuserManager.java create mode 100755 src/api/java/forestry/api/food/IIngredientManager.java create mode 100755 src/api/java/forestry/api/food/package-info.java create mode 100755 src/api/java/forestry/api/fuels/EngineBronzeFuel.java create mode 100755 src/api/java/forestry/api/fuels/EngineCopperFuel.java create mode 100755 src/api/java/forestry/api/fuels/FermenterFuel.java create mode 100755 src/api/java/forestry/api/fuels/FuelManager.java create mode 100755 src/api/java/forestry/api/fuels/GeneratorFuel.java create mode 100755 src/api/java/forestry/api/fuels/MoistenerFuel.java create mode 100755 src/api/java/forestry/api/fuels/RainSubstrate.java create mode 100755 src/api/java/forestry/api/fuels/package-info.java create mode 100755 src/api/java/forestry/api/genetics/AlleleManager.java create mode 100755 src/api/java/forestry/api/genetics/EnumTolerance.java create mode 100755 src/api/java/forestry/api/genetics/IAllele.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleArea.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleBoolean.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleEffect.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleFloat.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleFlowers.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleHandler.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleInteger.java create mode 100755 src/api/java/forestry/api/genetics/IAllelePlantType.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleRegistry.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleSpecies.java create mode 100755 src/api/java/forestry/api/genetics/IAlleleTolerance.java create mode 100755 src/api/java/forestry/api/genetics/IBreedingTracker.java create mode 100755 src/api/java/forestry/api/genetics/IChromosome.java create mode 100755 src/api/java/forestry/api/genetics/IChromosomeType.java create mode 100755 src/api/java/forestry/api/genetics/IClassification.java create mode 100755 src/api/java/forestry/api/genetics/IClimateHelper.java create mode 100755 src/api/java/forestry/api/genetics/IEffectData.java create mode 100755 src/api/java/forestry/api/genetics/IFlowerProvider.java create mode 100755 src/api/java/forestry/api/genetics/IFruitBearer.java create mode 100755 src/api/java/forestry/api/genetics/IFruitFamily.java create mode 100755 src/api/java/forestry/api/genetics/IGenome.java create mode 100755 src/api/java/forestry/api/genetics/IHousing.java create mode 100755 src/api/java/forestry/api/genetics/IIndividual.java create mode 100755 src/api/java/forestry/api/genetics/IIndividualLiving.java create mode 100755 src/api/java/forestry/api/genetics/ILegacyHandler.java create mode 100755 src/api/java/forestry/api/genetics/IMutation.java create mode 100755 src/api/java/forestry/api/genetics/IPollinatable.java create mode 100755 src/api/java/forestry/api/genetics/ISpeciesRoot.java create mode 100755 src/api/java/forestry/api/genetics/package-info.java create mode 100755 src/api/java/forestry/api/lepidopterology/EnumButterflyChromosome.java create mode 100755 src/api/java/forestry/api/lepidopterology/EnumFlutterType.java create mode 100755 src/api/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java create mode 100755 src/api/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java create mode 100755 src/api/java/forestry/api/lepidopterology/IButterfly.java create mode 100755 src/api/java/forestry/api/lepidopterology/IButterflyGenome.java create mode 100755 src/api/java/forestry/api/lepidopterology/IButterflyMutation.java create mode 100755 src/api/java/forestry/api/lepidopterology/IButterflyNursery.java create mode 100755 src/api/java/forestry/api/lepidopterology/IButterflyRoot.java create mode 100755 src/api/java/forestry/api/lepidopterology/IEntityButterfly.java create mode 100755 src/api/java/forestry/api/lepidopterology/ILepidopteristTracker.java create mode 100755 src/api/java/forestry/api/lepidopterology/package-info.java create mode 100755 src/api/java/forestry/api/mail/EnumPostage.java create mode 100755 src/api/java/forestry/api/mail/ILetter.java create mode 100755 src/api/java/forestry/api/mail/ILetterHandler.java create mode 100755 src/api/java/forestry/api/mail/IPostOffice.java create mode 100755 src/api/java/forestry/api/mail/IPostRegistry.java create mode 100755 src/api/java/forestry/api/mail/IPostalCarrier.java create mode 100755 src/api/java/forestry/api/mail/IPostalState.java create mode 100755 src/api/java/forestry/api/mail/IStamps.java create mode 100755 src/api/java/forestry/api/mail/ITradeStation.java create mode 100755 src/api/java/forestry/api/mail/MailAddress.java create mode 100755 src/api/java/forestry/api/mail/PostManager.java create mode 100755 src/api/java/forestry/api/mail/TradeStationInfo.java create mode 100755 src/api/java/forestry/api/mail/package-info.java create mode 100755 src/api/java/forestry/api/package-info.java create mode 100755 src/api/java/forestry/api/recipes/IBottlerManager.java create mode 100755 src/api/java/forestry/api/recipes/ICarpenterManager.java create mode 100755 src/api/java/forestry/api/recipes/ICentrifugeManager.java create mode 100755 src/api/java/forestry/api/recipes/ICraftingProvider.java create mode 100755 src/api/java/forestry/api/recipes/IFabricatorManager.java create mode 100755 src/api/java/forestry/api/recipes/IFermenterManager.java create mode 100755 src/api/java/forestry/api/recipes/IGenericCrate.java create mode 100755 src/api/java/forestry/api/recipes/IMoistenerManager.java create mode 100755 src/api/java/forestry/api/recipes/ISqueezerManager.java create mode 100755 src/api/java/forestry/api/recipes/IStillManager.java create mode 100755 src/api/java/forestry/api/recipes/IVariableFermentable.java create mode 100755 src/api/java/forestry/api/recipes/RecipeManagers.java create mode 100755 src/api/java/forestry/api/recipes/package-info.java create mode 100755 src/api/java/forestry/api/storage/BackpackEvent.java create mode 100755 src/api/java/forestry/api/storage/BackpackManager.java create mode 100755 src/api/java/forestry/api/storage/BackpackResupplyEvent.java create mode 100755 src/api/java/forestry/api/storage/BackpackStowEvent.java create mode 100755 src/api/java/forestry/api/storage/EnumBackpackType.java create mode 100755 src/api/java/forestry/api/storage/IBackpackDefinition.java create mode 100755 src/api/java/forestry/api/storage/IBackpackInterface.java create mode 100755 src/api/java/forestry/api/storage/package-info.java create mode 100755 src/api/java/forestry/api/world/ITreeGenData.java create mode 100755 src/api/java/forestry/api/world/IWorldGenInterface.java create mode 100755 src/api/java/forestry/api/world/WorldGenManager.java create mode 100755 src/api/java/forestry/api/world/package-info.java create mode 100644 src/main/java/biomesoplenty/api/package-info.java create mode 100644 src/main/java/biomesoplenty/common/integration/BOPIntegration.java create mode 100644 src/main/java/biomesoplenty/common/integration/ForestryIntegration.java diff --git a/src/api/java/forestry/api/apiculture/BeeManager.java b/src/api/java/forestry/api/apiculture/BeeManager.java new file mode 100755 index 000000000..332c550b9 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/BeeManager.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +import forestry.api.genetics.IMutation; +/** + * + * Some miscellaneous lists and settings for bees. + * + * @author SirSengir + */ +public class BeeManager { + + /** + * Get your own reference to this via AlleleManager.alleleRegistry.getSpeciesRoot("rootBees") and save it somewhere. + */ + @Deprecated + public static IBeeRoot beeInterface; + + /** + * Species templates for bees that can drop from hives. + * + * 0 - Forest 1 - Meadows 2 - Desert 3 - Jungle 4 - End 5 - Snow 6 - Swamp + * + * see {@link IMutation} for template format + */ + public static ArrayList[] hiveDrops; + + /** + * 0 - Common Village Bees 1 - Uncommon Village Bees (20 % of spawns) + */ + public static ArrayList[] villageBees; + + /** + * List of items that can induce swarming. Integer denotes x in 1000 chance. + */ + public static HashMap inducers = new HashMap(); +} diff --git a/src/api/java/forestry/api/apiculture/EnumBeeChromosome.java b/src/api/java/forestry/api/apiculture/EnumBeeChromosome.java new file mode 100755 index 000000000..049c8440d --- /dev/null +++ b/src/api/java/forestry/api/apiculture/EnumBeeChromosome.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleArea; +import forestry.api.genetics.IAlleleBoolean; +import forestry.api.genetics.IAlleleFloat; +import forestry.api.genetics.IAlleleFlowers; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAlleleTolerance; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.ISpeciesRoot; + +/** + * Enum representing the order of chromosomes in a bee's genome and what they control. + * + * @author SirSengir + */ +public enum EnumBeeChromosome implements IChromosomeType { + /** + * Species of the bee. Alleles here must implement {@link IAlleleBeeSpecies}. + */ + SPECIES(IAlleleBeeSpecies.class), + /** + * (Production) Speed of the bee. + */ + SPEED(IAlleleFloat.class), + /** + * Lifespan of the bee. + */ + LIFESPAN(IAlleleInteger.class), + /** + * Fertility of the bee. Determines number of offspring. + */ + FERTILITY(IAlleleInteger.class), + /** + * Temperature difference to its native supported one the bee can tolerate. + */ + TEMPERATURE_TOLERANCE(IAlleleTolerance.class), + /** + * Slightly incorrectly named. If true, a naturally dirunal bee can work during the night. If true, a naturally nocturnal bee can work during the day. + */ + NOCTURNAL(IAlleleBoolean.class), + /** + * Not used / superseded by fixed values for the species. Probably going to be replaced with a boolean for FIRE_RESIST. + */ + @Deprecated + HUMIDITY(IAllele.class), + /** + * Humidity difference to its native supported one the bee can tolerate. + */ + HUMIDITY_TOLERANCE(IAlleleTolerance.class), + /** + * If true the bee can work during rain. + */ + TOLERANT_FLYER(IAlleleBoolean.class), + /** + * If true, the bee can work without a clear view of the sky. + */ + CAVE_DWELLING(IAlleleBoolean.class), + /** + * Contains the supported flower provider. + */ + FLOWER_PROVIDER(IAlleleFlowers.class), + /** + * Determines pollination speed. + */ + FLOWERING(IAlleleInteger.class), + /** + * Determines the size of the bee's territory. + */ + TERRITORY(IAlleleArea.class), + /** + * Determines the bee's effect. + */ + EFFECT(IAlleleBeeEffect.class); + + Class clss; + + EnumBeeChromosome(Class clss) { + this.clss = clss; + } + + @Override + public Class getAlleleClass() { + return clss; + } + + @Override + public String getName() { + return this.toString().toLowerCase(); + } + + @Override + public ISpeciesRoot getSpeciesRoot() { + return AlleleManager.alleleRegistry.getSpeciesRoot("rootBees"); + } +} diff --git a/src/api/java/forestry/api/apiculture/EnumBeeType.java b/src/api/java/forestry/api/apiculture/EnumBeeType.java new file mode 100755 index 000000000..08f3cfc18 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/EnumBeeType.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.Locale; + +public enum EnumBeeType { + DRONE, PRINCESS, QUEEN, LARVAE, NONE; + + public static final EnumBeeType[] VALUES = values(); + + String name; + + private EnumBeeType() { + this.name = "bees." + this.toString().toLowerCase(Locale.ENGLISH); + } + + public String getName() { + return name; + } +} diff --git a/src/api/java/forestry/api/apiculture/FlowerManager.java b/src/api/java/forestry/api/apiculture/FlowerManager.java new file mode 100755 index 000000000..3c7503a79 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/FlowerManager.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import forestry.api.genetics.IFlowerProvider; + +public class FlowerManager { + /** + * ItemStacks representing simple flower blocks. Meta-sensitive, processed by the basic {@link IFlowerProvider}. + */ + public static ArrayList plainFlowers = new ArrayList(); +} diff --git a/src/api/java/forestry/api/apiculture/IAlleleBeeEffect.java b/src/api/java/forestry/api/apiculture/IAlleleBeeEffect.java new file mode 100755 index 000000000..b2dddb319 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IAlleleBeeEffect.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IAlleleEffect; +import forestry.api.genetics.IEffectData; + +public interface IAlleleBeeEffect extends IAlleleEffect { + + /** + * Called by apiaries to cause an effect in the world. + * + * @param genome + * Genome of the bee queen causing this effect + * @param storedData + * Object containing the stored effect data for the apiary/hive the bee is in. + * @param housing {@link IBeeHousing} the bee currently resides in. + * @return storedData, may have been manipulated. + */ + IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing); + + /** + * Is called to produce bee effects. + * + * @param genome + * @param storedData + * Object containing the stored effect data for the apiary/hive the bee is in. + * @param housing {@link IBeeHousing} the bee currently resides in. + * @return storedData, may have been manipulated. + */ + IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing); + +} diff --git a/src/api/java/forestry/api/apiculture/IAlleleBeeSpecies.java b/src/api/java/forestry/api/apiculture/IAlleleBeeSpecies.java new file mode 100755 index 000000000..f409b6a1f --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IAlleleBeeSpecies.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.genetics.IAlleleSpecies; + +public interface IAlleleBeeSpecies extends IAlleleSpecies { + + /** + * @return the IBeeRoot + */ + IBeeRoot getRoot(); + + /** + * @return true if this species is only active at night. + */ + boolean isNocturnal(); + + /** + * @return Map of possible products with the chance for drop each bee cycle. (0 - 100) + */ + Map getProducts(); + + /** + * @return Map of possible specialities with the chance for drop each bee cycle. (0 - 100) + */ + Map getSpecialty(); + + /** + * Only jubilant bees produce specialities. + * @return true if the bee is jubilant, false otherwise. + */ + boolean isJubilant(IBeeGenome genome, IBeeHousing housing); + + @SideOnly(Side.CLIENT) + IIcon getIcon(EnumBeeType type, int renderPass); + + /** + * @return Path of the texture to use for entity rendering. + */ + String getEntityTexture(); +} diff --git a/src/api/java/forestry/api/apiculture/IAlvearyComponent.java b/src/api/java/forestry/api/apiculture/IAlvearyComponent.java new file mode 100755 index 000000000..80cf98b1a --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IAlvearyComponent.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.core.ITileStructure; + +/** + * Needs to be implemented by TileEntities that want to be part of an alveary. + */ +public interface IAlvearyComponent extends ITileStructure { + + void registerBeeModifier(IBeeModifier modifier); + + void removeBeeModifier(IBeeModifier modifier); + + void registerBeeListener(IBeeListener event); + + void removeBeeListener(IBeeListener event); + + void addTemperatureChange(float change, float boundaryDown, float boundaryUp); + + void addHumidityChange(float change, float boundaryDown, float boundaryUp); + + /** + * @return true if this TE has a function other than a plain alveary block. Returning true prevents the TE from becoming master. + */ + boolean hasFunction(); + +} diff --git a/src/api/java/forestry/api/apiculture/IApiaristTracker.java b/src/api/java/forestry/api/apiculture/IApiaristTracker.java new file mode 100755 index 000000000..0c65f56be --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IApiaristTracker.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IIndividual; + +/** + * Can be used to garner information on bee breeding. See {@link forestry.api.genetics.ISpeciesRoot} for retrieval functions. + * + * @author SirSengir + */ +public interface IApiaristTracker extends IBreedingTracker { + + /** + * Register the birth of a queen. Will mark species as discovered. + * + * @param queen + * Created queen. + */ + void registerQueen(IIndividual queen); + + /** + * @return Amount of queens bred with this tracker. + */ + int getQueenCount(); + + /** + * Register the birth of a princess. Will mark species as discovered. + * + * @param princess + * Created princess. + */ + void registerPrincess(IIndividual princess); + + /** + * @return Amount of princesses bred with this tracker. + */ + int getPrincessCount(); + + /** + * Register the birth of a drone. Will mark species as discovered. + * + * @param drone + * Created drone. + */ + void registerDrone(IIndividual drone); + + /** + * @return Amount of drones bred with this tracker. + */ + int getDroneCount(); + +} diff --git a/src/api/java/forestry/api/apiculture/IArmorApiarist.java b/src/api/java/forestry/api/apiculture/IArmorApiarist.java new file mode 100755 index 000000000..fef81eb5c --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IArmorApiarist.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * When implemented by armor piece items, allows them to act as apiarist's armor. + */ +public interface IArmorApiarist { + /** + * Called when the apiarist's armor acts as protection against an attack. + * + * @param player + * Player being attacked + * @param armor + * Armor item + * @param cause + * Optional cause of attack, such as a bee effect identifier + * @param doProtect + * Whether or not to actually do the side effects of protection + * @return Whether or not the armor should protect the player from that attack + */ + public boolean protectPlayer(EntityPlayer player, ItemStack armor, String cause, boolean doProtect); +} diff --git a/src/api/java/forestry/api/apiculture/IBee.java b/src/api/java/forestry/api/apiculture/IBee.java new file mode 100755 index 000000000..b704b3ada --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBee.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import forestry.api.genetics.IEffectData; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IIndividualLiving; + +/** + * Other implementations than Forestry's default one are not supported. + * + * @author SirSengir + */ +public interface IBee extends IIndividualLiving { + + /** + * @return Bee's genetic information. + */ + IBeeGenome getGenome(); + + /** + * @return Genetic information of the bee's mate, null if unmated. + */ + IBeeGenome getMate(); + + /** + * @return true if the individual is originally of natural origin. + */ + boolean isNatural(); + + /** + * @return generation this individual is removed from the original individual. + */ + int getGeneration(); + + /** + * Set the natural flag on this bee. + * @param flag + */ + void setIsNatural(boolean flag); + + /** + * @return true if the bee is mated with another whose isNatural() doesn't match. + */ + boolean isIrregularMating(); + + IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing); + + IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing); + + /** + * @return true if the bee may spawn offspring + */ + boolean canSpawn(); + + /** + * Determines whether the queen can work. + * + * @param housing the {@link IBeeHousing} the bee currently resides in. + * @return Ordinal of the error code encountered. 0 - EnumErrorCode.OK + */ + int isWorking(IBeeHousing housing); + + boolean hasFlower(IBeeHousing housing); + + ArrayList getSuitableBiomeIds(); + + ItemStack[] getProduceList(); + + ItemStack[] getSpecialtyList(); + + ItemStack[] produceStacks(IBeeHousing housing); + + IBee spawnPrincess(IBeeHousing housing); + + IBee[] spawnDrones(IBeeHousing housing); + + void plantFlowerRandom(IBeeHousing housing); + + IIndividual retrievePollen(IBeeHousing housing); + + boolean pollinateRandom(IBeeHousing housing, IIndividual pollen); + +} diff --git a/src/api/java/forestry/api/apiculture/IBeeGenome.java b/src/api/java/forestry/api/apiculture/IBeeGenome.java new file mode 100755 index 000000000..642eeeb5c --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeeGenome.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IFlowerProvider; +import forestry.api.genetics.IGenome; + +/** + * Only the default implementation is supported. + * + * @author SirSengir + * + */ +public interface IBeeGenome extends IGenome { + + IAlleleBeeSpecies getPrimary(); + + IAlleleBeeSpecies getSecondary(); + + float getSpeed(); + + int getLifespan(); + + int getFertility(); + + EnumTolerance getToleranceTemp(); + + EnumTolerance getToleranceHumid(); + + boolean getNocturnal(); + + boolean getTolerantFlyer(); + + boolean getCaveDwelling(); + + IFlowerProvider getFlowerProvider(); + + int getFlowering(); + + int[] getTerritory(); + + IAlleleBeeEffect getEffect(); + +} diff --git a/src/api/java/forestry/api/apiculture/IBeeHousing.java b/src/api/java/forestry/api/apiculture/IBeeHousing.java new file mode 100755 index 000000000..5d795a3b6 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeeHousing.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; + +import forestry.api.genetics.IHousing; + +public interface IBeeHousing extends IBeeModifier, IBeeListener, IHousing { + + ItemStack getQueen(); + + ItemStack getDrone(); + + void setQueen(ItemStack itemstack); + + void setDrone(ItemStack itemstack); + + /** + * @return true if princesses and drones can (currently) mate in this housing to generate queens. + */ + boolean canBreed(); + +} diff --git a/src/api/java/forestry/api/apiculture/IBeeListener.java b/src/api/java/forestry/api/apiculture/IBeeListener.java new file mode 100755 index 000000000..7fd5865c3 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeeListener.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; + +import forestry.api.genetics.IIndividual; + +public interface IBeeListener { + + /** + * Called on queen update. + * + * @param queen + */ + void onQueenChange(ItemStack queen); + + /** + * Called when the bees wear out the housing's equipment. + * + * @param amount + * Integer indicating the amount worn out. + */ + void wearOutEquipment(int amount); + + /** + * Called just before the children are generated, and the queen removed. + * + * @param queen + */ + void onQueenDeath(IBee queen); + + /** + * Called after the children have been spawned, but before the queen appears + * + * @param queen + */ + void onPostQueenDeath(IBee queen); + + boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled); + + boolean onEggLaid(IBee queen); +} diff --git a/src/api/java/forestry/api/apiculture/IBeeModifier.java b/src/api/java/forestry/api/apiculture/IBeeModifier.java new file mode 100755 index 000000000..4f9f7bbec --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeeModifier.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +public interface IBeeModifier { + + /** + * @param genome Genome of the bee this modifier is called for. + * @param currentModifier Current modifier. + * @return Float used to modify the base territory. + */ + float getTerritoryModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @param mate + * @param currentModifier Current modifier. + * @return Float used to modify the base mutation chance. + */ + float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @param currentModifier Current modifier. + * @return Float used to modify the life span of queens. + */ + float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @param currentModifier Current modifier. + * @return Float modifying the production speed of queens. + */ + float getProductionModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @return Float modifying the flowering of queens. + */ + float getFloweringModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @return Float modifying the chance for a swarmer queen to die off. + */ + float getGeneticDecay(IBeeGenome genome, float currentModifier); + + /** + * @return Boolean indicating if housing can ignore rain + */ + boolean isSealed(); + + /** + * @return Boolean indicating if housing can ignore darkness/night + */ + boolean isSelfLighted(); + + /** + * @return Boolean indicating if housing can ignore not seeing the sky + */ + boolean isSunlightSimulated(); + + /** + * @return Boolean indicating whether this housing simulates the nether + */ + boolean isHellish(); + +} diff --git a/src/api/java/forestry/api/apiculture/IBeeMutation.java b/src/api/java/forestry/api/apiculture/IBeeMutation.java new file mode 100755 index 000000000..fffc7d6df --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeeMutation.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IMutation; + +public interface IBeeMutation extends IMutation { + + IBeeRoot getRoot(); + + /** + * @param housing + * @param allele0 + * @param allele1 + * @param genome0 + * @param genome1 + * @return float representing the chance for mutation to occur. note that this is 0 - 100 based, since it was an integer previously! + */ + float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); +} diff --git a/src/api/java/forestry/api/apiculture/IBeeRoot.java b/src/api/java/forestry/api/apiculture/IBeeRoot.java new file mode 100755 index 000000000..f8912c2c1 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeeRoot.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import forestry.api.core.IStructureLogic; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.ISpeciesRoot; + +public interface IBeeRoot extends ISpeciesRoot { + + /** + * @return true if passed item is a Forestry bee. Equal to getType(ItemStack stack) != EnumBeeType.NONE + */ + boolean isMember(ItemStack stack); + + /** + * @return {@link IBee} pattern parsed from the passed stack's nbt data. + */ + IBee getMember(ItemStack stack); + + IBee getMember(NBTTagCompound compound); + + /* GENOME CONVERSION */ + IBee templateAsIndividual(IAllele[] template); + + IBee templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); + + IBeeGenome templateAsGenome(IAllele[] template); + + IBeeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /* BREEDING TRACKER */ + /** + * @param world + * @return {@link IApiaristTracker} associated with the passed world. + */ + IApiaristTracker getBreedingTracker(World world, String player); + + /* BEE SPECIFIC */ + /** + * @return type of bee encoded on the itemstack. EnumBeeType.NONE if it isn't a bee. + */ + EnumBeeType getType(ItemStack stack); + + /** + * @return true if passed item is a drone. Equal to getType(ItemStack stack) == EnumBeeType.DRONE + */ + boolean isDrone(ItemStack stack); + + /** + * @return true if passed item is mated (i.e. a queen) + */ + boolean isMated(ItemStack stack); + + /** + * @param genome + * Valid {@link IBeeGenome} + * @return {@link IBee} from the passed genome + */ + IBee getBee(World world, IBeeGenome genome); + + /** + * Creates an IBee suitable for a queen containing the necessary second genome for the mate. + * + * @param genome + * Valid {@link IBeeGenome} + * @param mate + * Valid {@link IBee} representing the mate. + * @return Mated {@link IBee} from the passed genomes. + */ + IBee getBee(World world, IBeeGenome genome, IBee mate); + + /* TEMPLATES */ + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + Collection getMutations(boolean shuffle); + + /* GAME MODE */ + void resetBeekeepingMode(); + + ArrayList getBeekeepingModes(); + + IBeekeepingMode getBeekeepingMode(World world); + + IBeekeepingMode getBeekeepingMode(String name); + + void registerBeekeepingMode(IBeekeepingMode mode); + + void setBeekeepingMode(World world, String name); + + /* MISC */ + /** + * @param housing + * Object implementing IBeeHousing. + * @return IBeekeepingLogic + */ + IBeekeepingLogic createBeekeepingLogic(IBeeHousing housing); + + /** + * TileEntities wanting to function as alveary components need to implement structure logic for validation. + * + * @return IStructureLogic for alvearies. + */ + IStructureLogic createAlvearyStructureLogic(IAlvearyComponent structure); + +} diff --git a/src/api/java/forestry/api/apiculture/IBeekeepingLogic.java b/src/api/java/forestry/api/apiculture/IBeekeepingLogic.java new file mode 100755 index 000000000..0a4da7b3b --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeekeepingLogic.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.core.INBTTagable; +import forestry.api.genetics.IEffectData; + +public interface IBeekeepingLogic extends INBTTagable { + + /* STATE INFORMATION */ + int getBreedingTime(); + + int getTotalBreedingTime(); + + IBee getQueen(); + + IBeeHousing getHousing(); + + IEffectData[] getEffectData(); + + /* UPDATING */ + void update(); + +} diff --git a/src/api/java/forestry/api/apiculture/IBeekeepingMode.java b/src/api/java/forestry/api/apiculture/IBeekeepingMode.java new file mode 100755 index 000000000..80d30981d --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IBeekeepingMode.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; + +import net.minecraft.world.World; + +public interface IBeekeepingMode extends IBeeModifier { + + /** + * @return Localized name of this beekeeping mode. + */ + String getName(); + + /** + * @return Localized list of strings outlining the behaviour of this beekeeping mode. + */ + ArrayList getDescription(); + + /** + * @return Float used to modify the wear on comb frames. + */ + float getWearModifier(); + + /** + * @param queen + * @return fertility taking into account the birthing queen and surroundings. + */ + int getFinalFertility(IBee queen, World world, int x, int y, int z); + + /** + * @param queen + * @return true if the queen is genetically "fatigued" and should not be reproduced anymore. + */ + boolean isFatigued(IBee queen, IBeeHousing housing); + + /** + * @param queen + * @param housing + * @return true if the queen is being overworked in the bee housing (with chance). will trigger a negative effect. + */ + boolean isOverworked(IBee queen, IBeeHousing housing); + + /** + * + * @param queen + * @param offspring + * @param housing + * @return true if the genetic structure of the queen is breaking down during spawning of the offspring (with chance). will trigger a negative effect. + */ + boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing); + + /** + * @param queen + * @return true if an offspring of this queen is considered a natural + */ + boolean isNaturalOffspring(IBee queen); + + /** + * @param queen + * @return true if this mode allows the passed queen or princess to be multiplied + */ + boolean mayMultiplyPrincess(IBee queen); + + +} diff --git a/src/api/java/forestry/api/apiculture/IHiveDrop.java b/src/api/java/forestry/api/apiculture/IHiveDrop.java new file mode 100755 index 000000000..b7d15ff8d --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IHiveDrop.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +/** + * Bees can be seeded either as hive drops or as mutation results. + * + * Add IHiveDrops to BeeManager.hiveDrops + * + * @author SirSengir + */ +public interface IHiveDrop { + + ItemStack getPrincess(World world, int x, int y, int z, int fortune); + + Collection getDrones(World world, int x, int y, int z, int fortune); + + Collection getAdditional(World world, int x, int y, int z, int fortune); + + /** + * Chance to drop. Default drops have 80 (= 80 %). + * + * @param world Minecraft world this is called for. + * @param x x-Coordinate of the broken hive. + * @param y y-Coordinate of the broken hive. + * @param z z-Coordinate of the broken hive. + * @return Chance for drop as an integer of 0 - 100. + */ + int getChance(World world, int x, int y, int z); +} diff --git a/src/api/java/forestry/api/apiculture/IHiveFrame.java b/src/api/java/forestry/api/apiculture/IHiveFrame.java new file mode 100755 index 000000000..dabc9e019 --- /dev/null +++ b/src/api/java/forestry/api/apiculture/IHiveFrame.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; + +public interface IHiveFrame extends IBeeModifier { + + /** + * Wears out a frame. + * + * @param housing + * IBeeHousing the frame is contained in. + * @param frame + * ItemStack containing the actual frame. + * @param queen + * Current queen in the caller. + * @param wear + * Integer denoting the amount worn out. The wear modifier of the current beekeeping mode has already been taken into account. + * @return ItemStack containing the actual frame with adjusted damage. + */ + ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear); + +} diff --git a/src/api/java/forestry/api/apiculture/package-info.java b/src/api/java/forestry/api/apiculture/package-info.java new file mode 100755 index 000000000..b31ce877e --- /dev/null +++ b/src/api/java/forestry/api/apiculture/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|apiculture") +package forestry.api.apiculture; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/arboriculture/EnumGermlingType.java b/src/api/java/forestry/api/arboriculture/EnumGermlingType.java new file mode 100755 index 000000000..3b40f151d --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/EnumGermlingType.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public enum EnumGermlingType { + SAPLING("Sapling"), BLOSSOM("Blossom"), POLLEN("Pollen"), GERMLING("Germling"), NONE("None"); + + public static final EnumGermlingType[] VALUES = values(); + + String name; + + private EnumGermlingType(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/src/api/java/forestry/api/arboriculture/EnumGrowthConditions.java b/src/api/java/forestry/api/arboriculture/EnumGrowthConditions.java new file mode 100755 index 000000000..8b28601c1 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/EnumGrowthConditions.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public enum EnumGrowthConditions { + HOSTILE, PALTRY, NORMAL, GOOD, EXCELLENT +} diff --git a/src/api/java/forestry/api/arboriculture/EnumTreeChromosome.java b/src/api/java/forestry/api/arboriculture/EnumTreeChromosome.java new file mode 100755 index 000000000..68e185d00 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/EnumTreeChromosome.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleArea; +import forestry.api.genetics.IAlleleFloat; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAllelePlantType; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IFruitFamily; +import forestry.api.genetics.ISpeciesRoot; + +public enum EnumTreeChromosome implements IChromosomeType { + + /** + * Determines the following: - WorldGen, including the used wood blocks - {@link IFruitFamily}s supported. Limits which {@link IFruitProvider} + * will actually yield fruit with this species. - Native {@link EnumPlantType} for this tree. Combines with the PLANT chromosome. + */ + SPECIES(IAlleleTreeSpecies.class), + /** + * {@link IGrowthProvider}, determines conditions required by the tree to grow. + */ + GROWTH(IAlleleGrowth.class), + /** + * A float modifying the height of the tree. Taken into account at worldgen. + */ + HEIGHT(IAlleleFloat.class), + /** + * Chance for saplings. + */ + FERTILITY(IAlleleFloat.class), + /** + * {@link IFruitProvider}, determines if and what fruits are grown on the tree. Limited by the {@link IFruitFamily}s the species supports. + */ + FRUITS(IAlleleFruit.class), + /** + * Chance for fruit leaves and/or drops. + */ + YIELD(IAlleleFloat.class), + /** + * May add additional tolerances for {@link EnumPlantTypes}. + */ + PLANT(IAllelePlantType.class), + /** + * Determines the speed at which fruit will ripen on this tree. + */ + SAPPINESS(IAlleleFloat.class), + /** + * Territory for leaf effects. Unused. + */ + TERRITORY(IAlleleArea.class), + /** + * Leaf effect. Unused. + */ + EFFECT(IAlleleLeafEffect.class), + /** + * Amount of random ticks which need to elapse before a sapling will grow into a tree. + */ + MATURATION(IAlleleInteger.class), + + GIRTH(IAlleleInteger.class), + ; + + Class clss; + + EnumTreeChromosome(Class clss) { + this.clss = clss; + } + + @Override + public Class getAlleleClass() { + return clss; + } + + @Override + public String getName() { + return this.toString().toLowerCase(); + } + + @Override + public ISpeciesRoot getSpeciesRoot() { + return AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees"); + } + +} diff --git a/src/api/java/forestry/api/arboriculture/IAlleleFruit.java b/src/api/java/forestry/api/arboriculture/IAlleleFruit.java new file mode 100755 index 000000000..0f54db510 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IAlleleFruit.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IAllele; + +/** + * Simple allele encapsulating an {@link IFruitProvider}. + */ +public interface IAlleleFruit extends IAllele { + + IFruitProvider getProvider(); + +} diff --git a/src/api/java/forestry/api/arboriculture/IAlleleGrowth.java b/src/api/java/forestry/api/arboriculture/IAlleleGrowth.java new file mode 100755 index 000000000..6cb4b4389 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IAlleleGrowth.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IAllele; + +/** + * Simple allele encapsulating an {@link IGrowthProvider}. + */ +public interface IAlleleGrowth extends IAllele { + + IGrowthProvider getProvider(); + +} diff --git a/src/api/java/forestry/api/arboriculture/IAlleleLeafEffect.java b/src/api/java/forestry/api/arboriculture/IAlleleLeafEffect.java new file mode 100755 index 000000000..d52d963ac --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IAlleleLeafEffect.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.world.World; + +import forestry.api.genetics.IAlleleEffect; +import forestry.api.genetics.IEffectData; + +/** + * Simple allele encapsulating a leaf effect. (Not implemented) + */ +public interface IAlleleLeafEffect extends IAlleleEffect { + + IEffectData doEffect(ITreeGenome genome, IEffectData storedData, World world, int x, int y, int z); + +} diff --git a/src/api/java/forestry/api/arboriculture/IAlleleTreeSpecies.java b/src/api/java/forestry/api/arboriculture/IAlleleTreeSpecies.java new file mode 100755 index 000000000..c9f274aa3 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IAlleleTreeSpecies.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IFruitFamily; + +public interface IAlleleTreeSpecies extends IAlleleSpecies { + + ITreeRoot getRoot(); + + /** + * @return Native plant type of this species. + */ + EnumPlantType getPlantType(); + + /** + * @return List of all {@link IFruitFamily}s which can grow on leaves generated by this species. + */ + Collection getSuitableFruit(); + + /** + * @return Trunk girth. 1 = 1x1, 2 = 2x2, etc. + */ + @Deprecated + int getGirth(); + + /** + * @param tree + * @param world + * @param x + * @param y + * @param z + * @return Tree generator for the tree at the given location. + */ + WorldGenerator getGenerator(ITree tree, World world, int x, int y, int z); + + /** + * @return All available generator classes for this species. + */ + Class[] getGeneratorClasses(); + + /* TEXTURES AND OVERRIDES */ + int getLeafColour(ITree tree); + + short getLeafIconIndex(ITree tree, boolean fancy); + + @SideOnly(Side.CLIENT) + IIcon getGermlingIcon(EnumGermlingType type, int renderPass); + + @SideOnly(Side.CLIENT) + int getGermlingColour(EnumGermlingType type, int renderPass); + + /** + * + * @return Array of ItemStacks representing logs that these tree produces, the first one being the primary one + */ + ItemStack[] getLogStacks(); + +} diff --git a/src/api/java/forestry/api/arboriculture/IArboristTracker.java b/src/api/java/forestry/api/arboriculture/IArboristTracker.java new file mode 100755 index 000000000..9777e8763 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IArboristTracker.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IBreedingTracker; + +public interface IArboristTracker extends IBreedingTracker { + +} diff --git a/src/api/java/forestry/api/arboriculture/IFruitProvider.java b/src/api/java/forestry/api/arboriculture/IFruitProvider.java new file mode 100755 index 000000000..ef54fc99f --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IFruitProvider.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.genetics.IFruitFamily; + +public interface IFruitProvider { + + IFruitFamily getFamily(); + + int getColour(ITreeGenome genome, IBlockAccess world, int x, int y, int z, int ripeningTime); + + boolean markAsFruitLeaf(ITreeGenome genome, World world, int x, int y, int z); + + int getRipeningPeriod(); + + // / Products, Chance + ItemStack[] getProducts(); + + // / Specialty, Chance + ItemStack[] getSpecialty(); + + ItemStack[] getFruits(ITreeGenome genome, World world, int x, int y, int z, int ripeningTime); + + /** + * @return Short, human-readable identifier used in the treealyzer. + */ + String getDescription(); + + /* TEXTURE OVERLAY */ + /** + * @param genome + * @param world + * @param x + * @param y + * @param z + * @param ripeningTime + * Elapsed ripening time for the fruit. + * @param fancy + * @return IIcon index of the texture to overlay on the leaf block. + */ + short getIconIndex(ITreeGenome genome, IBlockAccess world, int x, int y, int z, int ripeningTime, boolean fancy); + + /** + * @return true if this fruit provider requires fruit blocks to spawn, false otherwise. + */ + boolean requiresFruitBlocks(); + + /** + * Tries to spawn a fruit block at the potential position when the tree generates. + * + * @param genome + * @param world + * @param x + * @param y + * @param z + * @return true if a fruit block was spawned, false otherwise. + */ + boolean trySpawnFruitBlock(ITreeGenome genome, World world, int x, int y, int z); + + @SideOnly(Side.CLIENT) + void registerIcons(IIconRegister register); +} diff --git a/src/api/java/forestry/api/arboriculture/IGrowthProvider.java b/src/api/java/forestry/api/arboriculture/IGrowthProvider.java new file mode 100755 index 000000000..92e553e0d --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IGrowthProvider.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.world.World; + +public interface IGrowthProvider { + + /** + * Check to see whether a sapling at the given location with the given genome can grow into a tree. + * + * @param genome Genome of the tree this is called for. + * @param world Minecraft world the tree will inhabit. + * @param xPos x-Coordinate to attempt growth at. + * @param yPos y-Coordinate to attempt growth at. + * @param zPos z-Coordinate to attempt growth at. + * @param expectedGirth Trunk size of the tree to generate. + * @param expectedHeight Height of the tree to generate. + * @return true if the tree can grow at the given coordinates, false otherwise. + */ + boolean canGrow(ITreeGenome genome, World world, int xPos, int yPos, int zPos, int expectedGirth, int expectedHeight); + + EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, int xPos, int yPos, int zPos); + + /** + * @return Short, human-readable identifier used in the treealyzer. + */ + String getDescription(); + + /** + * @return Detailed description of growth behaviour used in the treealyzer. + */ + String[] getInfo(); + +} diff --git a/src/api/java/forestry/api/arboriculture/ILeafTickHandler.java b/src/api/java/forestry/api/arboriculture/ILeafTickHandler.java new file mode 100755 index 000000000..4d7fba44b --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/ILeafTickHandler.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.world.World; + +public interface ILeafTickHandler { + boolean onRandomLeafTick(ITree tree, World world, int biomeId, int x, int y, int z, boolean isDestroyed); +} diff --git a/src/api/java/forestry/api/arboriculture/IToolGrafter.java b/src/api/java/forestry/api/arboriculture/IToolGrafter.java new file mode 100755 index 000000000..339725e6b --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/IToolGrafter.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IToolGrafter { + /** + * Called by leaves to determine the increase in sapling droprate. + * + * @param stack ItemStack containing the grafter. + * @param world Minecraft world the player and the target block inhabit. + * @param x x-Coordinate of the broken leaf block. + * @param y y-Coordinate of the broken leaf block. + * @param z z-Coordinate of the broken leaf block. + * @return Float representing the factor the usual drop chance is to be multiplied by. + */ + float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z); +} diff --git a/src/api/java/forestry/api/arboriculture/ITree.java b/src/api/java/forestry/api/arboriculture/ITree.java new file mode 100755 index 000000000..85a0085a2 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/ITree.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.EnumSet; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IEffectData; +import forestry.api.genetics.IIndividual; + +public interface ITree extends IIndividual { + + void mate(ITree other); + + IEffectData[] doEffect(IEffectData[] storedData, World world, int biomeid, int x, int y, int z); + + IEffectData[] doFX(IEffectData[] storedData, World world, int biomeid, int x, int y, int z); + + ITreeGenome getGenome(); + + ITreeGenome getMate(); + + EnumSet getPlantTypes(); + + ITree[] getSaplings(World world, int x, int y, int z, float modifier); + + ItemStack[] getProduceList(); + + ItemStack[] getSpecialtyList(); + + ItemStack[] produceStacks(World world, int x, int y, int z, int ripeningTime); + + /** + * + * @param world + * @param x + * @param y + * @param z + * @return Boolean indicating whether a sapling can stay planted at the given position. + */ + boolean canStay(World world, int x, int y, int z); + + /** + * + * @param world + * @param x + * @param y + * @param z + * @return Boolean indicating whether a sapling at the given position can grow into a tree. + */ + boolean canGrow(World world, int x, int y, int z, int expectedGirth, int expectedHeight); + + /** + * @return Integer denoting the maturity (block ticks) required for a sapling to attempt to grow into a tree. + */ + int getRequiredMaturity(); + + /** + * @return Integer denoting how resilient leaf blocks are against adverse influences (i.e. caterpillars). + */ + int getResilience(); + + /** + * @param world + * @param x + * @param y + * @param z + * @return Integer denoting the size of the tree trunk. + */ + int getGirth(World world, int x, int y, int z); + + + + /** + * + * @param world + * @param x + * @param y + * @param z + * @return Growth conditions at the given position. + */ + EnumGrowthConditions getGrowthCondition(World world, int x, int y, int z); + + WorldGenerator getTreeGenerator(World world, int x, int y, int z, boolean wasBonemealed); + + ITree copy(); + + boolean isPureBred(EnumTreeChromosome chromosome); + + boolean canBearFruit(); +} diff --git a/src/api/java/forestry/api/arboriculture/ITreeGenome.java b/src/api/java/forestry/api/arboriculture/ITreeGenome.java new file mode 100755 index 000000000..ee5a1f029 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/ITreeGenome.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IGenome; + +public interface ITreeGenome extends IGenome { + + IAlleleTreeSpecies getPrimary(); + + IAlleleTreeSpecies getSecondary(); + + IFruitProvider getFruitProvider(); + + IGrowthProvider getGrowthProvider(); + + float getHeight(); + + float getFertility(); + + /** + * @return Determines either a) how many fruit leaves there are or b) the chance for any fruit leave to drop a sapling. Exact usage determined by the + * IFruitProvider + */ + float getYield(); + + float getSappiness(); + + EnumSet getPlantTypes(); + + /** + * @return Amount of random block ticks required for a sapling to mature into a fully grown tree. + */ + int getMaturationTime(); + + int getGirth(); + + IAlleleLeafEffect getEffect(); +} diff --git a/src/api/java/forestry/api/arboriculture/ITreeModifier.java b/src/api/java/forestry/api/arboriculture/ITreeModifier.java new file mode 100755 index 000000000..775f91ebe --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/ITreeModifier.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public interface ITreeModifier { + + /** + * + * @param genome + * @return Float used to modify the height. + */ + float getHeightModifier(ITreeGenome genome, float currentModifier); + + /** + * + * @param genome + * @return Float used to modify the yield. + */ + float getYieldModifier(ITreeGenome genome, float currentModifier); + + /** + * + * @param genome + * @return Float used to modify the sappiness. + */ + float getSappinessModifier(ITreeGenome genome, float currentModifier); + + /** + * + * @param genome + * @return Float used to modify the maturation. + */ + float getMaturationModifier(ITreeGenome genome, float currentModifier); + + /** + * @param genome0 + * @param genome1 + * @return Float used to modify the base mutation chance. + */ + float getMutationModifier(ITreeGenome genome0, ITreeGenome genome1, float currentModifier); + +} diff --git a/src/api/java/forestry/api/arboriculture/ITreeMutation.java b/src/api/java/forestry/api/arboriculture/ITreeMutation.java new file mode 100755 index 000000000..65804969b --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/ITreeMutation.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.world.World; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; + +public interface ITreeMutation extends IMutation { + + /** + * @return {@link ISpeciesRoot} this mutation is associated with. + */ + ITreeRoot getRoot(); + + /** + * @param world + * @param x + * @param y + * @param z + * @param allele0 + * @param allele1 + * @param genome0 + * @param genome1 + * @return float representing the chance for mutation to occur. note that this is 0 - 100 based, since it was an integer previously! + */ + float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); +} diff --git a/src/api/java/forestry/api/arboriculture/ITreeRoot.java b/src/api/java/forestry/api/arboriculture/ITreeRoot.java new file mode 100755 index 000000000..02fda9c52 --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/ITreeRoot.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IChromosome; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.ISpeciesRoot; + +public interface ITreeRoot extends ISpeciesRoot { + + boolean isMember(ItemStack itemstack); + + ITree getMember(ItemStack itemstack); + + ITree getMember(NBTTagCompound compound); + + ITreeGenome templateAsGenome(IAllele[] template); + + ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /** + * @param world + * @return {@link IArboristTracker} associated with the passed world. + */ + IArboristTracker getBreedingTracker(World world, String player); + + /* TREE SPECIFIC */ + /** + * Register a leaf tick handler. + * @param handler the {@link ILeafTickHandler} to register. + */ + void registerLeafTickHandler(ILeafTickHandler handler); + + Collection getLeafTickHandlers(); + + /** + * @return type of tree encoded on the itemstack. EnumBeeType.NONE if it isn't a tree. + */ + EnumGermlingType getType(ItemStack stack); + + ITree getTree(World world, int x, int y, int z); + + ITree getTree(World world, ITreeGenome genome); + + boolean plantSapling(World world, ITree tree, String owner, int x, int y, int z); + + boolean setLeaves(World world, IIndividual tree, String owner, int x, int y, int z); + + IChromosome[] templateAsChromosomes(IAllele[] template); + + IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive); + + boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, short[] indices, int x, int y, int z); + + /* GAME MODE */ + ArrayList getTreekeepingModes(); + + ITreekeepingMode getTreekeepingMode(World world); + + ITreekeepingMode getTreekeepingMode(String name); + + void registerTreekeepingMode(ITreekeepingMode mode); + + void setTreekeepingMode(World world, String name); + + /* TEMPLATES */ + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + Collection getMutations(boolean shuffle); + +} diff --git a/src/api/java/forestry/api/arboriculture/ITreekeepingMode.java b/src/api/java/forestry/api/arboriculture/ITreekeepingMode.java new file mode 100755 index 000000000..cc5224d8a --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/ITreekeepingMode.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.ArrayList; + +public interface ITreekeepingMode extends ITreeModifier { + + /** + * @return Localized name of this treekeeping mode. + */ + String getName(); + + /** + * @return Localized list of strings outlining the behaviour of this treekeeping mode. + */ + ArrayList getDescription(); + +} diff --git a/src/api/java/forestry/api/arboriculture/TreeManager.java b/src/api/java/forestry/api/arboriculture/TreeManager.java new file mode 100755 index 000000000..be43cd31d --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/TreeManager.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public class TreeManager { + public static int treeSpeciesCount = 0; + + /** + * Get your own reference to this via AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees") and save it somewhere. + */ + @Deprecated + public static ITreeRoot treeInterface; +} diff --git a/src/api/java/forestry/api/arboriculture/package-info.java b/src/api/java/forestry/api/arboriculture/package-info.java new file mode 100755 index 000000000..7d99221ba --- /dev/null +++ b/src/api/java/forestry/api/arboriculture/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|arboriculture") +package forestry.api.arboriculture; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/circuits/ChipsetManager.java b/src/api/java/forestry/api/circuits/ChipsetManager.java new file mode 100755 index 000000000..c5f0db5c3 --- /dev/null +++ b/src/api/java/forestry/api/circuits/ChipsetManager.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +public class ChipsetManager { + + public static ISolderManager solderManager; + public static ICircuitRegistry circuitRegistry; + +} diff --git a/src/api/java/forestry/api/circuits/ICircuit.java b/src/api/java/forestry/api/circuits/ICircuit.java new file mode 100755 index 000000000..01b7e79d0 --- /dev/null +++ b/src/api/java/forestry/api/circuits/ICircuit.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import java.util.List; + +import net.minecraft.tileentity.TileEntity; + +public interface ICircuit { + String getUID(); + + boolean requiresDiscovery(); + + int getLimit(); + + String getName(); + + boolean isCircuitable(TileEntity tile); + + void onInsertion(int slot, TileEntity tile); + + void onLoad(int slot, TileEntity tile); + + void onRemoval(int slot, TileEntity tile); + + void onTick(int slot, TileEntity tile); + + void addTooltip(List list); +} diff --git a/src/api/java/forestry/api/circuits/ICircuitBoard.java b/src/api/java/forestry/api/circuits/ICircuitBoard.java new file mode 100755 index 000000000..3b424d75c --- /dev/null +++ b/src/api/java/forestry/api/circuits/ICircuitBoard.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import java.util.List; + +import net.minecraft.tileentity.TileEntity; + +import forestry.api.core.INBTTagable; + +public interface ICircuitBoard extends INBTTagable { + + int getPrimaryColor(); + + int getSecondaryColor(); + + void addTooltip(List list); + + void onInsertion(TileEntity tile); + + void onLoad(TileEntity tile); + + void onRemoval(TileEntity tile); + + void onTick(TileEntity tile); + + ICircuit[] getCircuits(); + +} diff --git a/src/api/java/forestry/api/circuits/ICircuitLayout.java b/src/api/java/forestry/api/circuits/ICircuitLayout.java new file mode 100755 index 000000000..e90853b9b --- /dev/null +++ b/src/api/java/forestry/api/circuits/ICircuitLayout.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +public interface ICircuitLayout { + + String getUID(); + + String getName(); + + String getUsage(); + +} diff --git a/src/api/java/forestry/api/circuits/ICircuitLibrary.java b/src/api/java/forestry/api/circuits/ICircuitLibrary.java new file mode 100755 index 000000000..0d65ba458 --- /dev/null +++ b/src/api/java/forestry/api/circuits/ICircuitLibrary.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +public interface ICircuitLibrary { + +} diff --git a/src/api/java/forestry/api/circuits/ICircuitRegistry.java b/src/api/java/forestry/api/circuits/ICircuitRegistry.java new file mode 100755 index 000000000..a9ad8a636 --- /dev/null +++ b/src/api/java/forestry/api/circuits/ICircuitRegistry.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import java.util.HashMap; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface ICircuitRegistry { + + /* CIRCUITS */ + HashMap getRegisteredCircuits(); + + void registerCircuit(ICircuit circuit); + + ICircuit getCircuit(String uid); + + ICircuitLibrary getCircuitLibrary(World world, String playername); + + void registerLegacyMapping(int id, String uid); + + ICircuit getFromLegacyMap(int id); + + /* LAYOUTS */ + HashMap getRegisteredLayouts(); + + void registerLayout(ICircuitLayout layout); + + ICircuitLayout getLayout(String uid); + + ICircuitLayout getDefaultLayout(); + + + ICircuitBoard getCircuitboard(ItemStack itemstack); + + boolean isChipset(ItemStack itemstack); + +} diff --git a/src/api/java/forestry/api/circuits/ISolderManager.java b/src/api/java/forestry/api/circuits/ISolderManager.java new file mode 100755 index 000000000..af9b41f1b --- /dev/null +++ b/src/api/java/forestry/api/circuits/ISolderManager.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import net.minecraft.item.ItemStack; + +public interface ISolderManager { + + void addRecipe(ICircuitLayout layout, ItemStack resource, ICircuit circuit); + +} diff --git a/src/api/java/forestry/api/circuits/package-info.java b/src/api/java/forestry/api/circuits/package-info.java new file mode 100755 index 000000000..f2545e578 --- /dev/null +++ b/src/api/java/forestry/api/circuits/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|circuits") +package forestry.api.circuits; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/core/BlockInterface.java b/src/api/java/forestry/api/core/BlockInterface.java new file mode 100755 index 000000000..9ca07c49f --- /dev/null +++ b/src/api/java/forestry/api/core/BlockInterface.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.FMLLog; + +public class BlockInterface { + /** + * Rather limited function to retrieve block ids. + * + * @param ident + * @return ItemStack representing the block. + */ + @Deprecated + public static ItemStack getBlock(String ident) { + ItemStack item = null; + + try { + String pack = ItemInterface.class.getPackage().getName(); + pack = pack.substring(0, pack.lastIndexOf('.')); + String itemClass = pack.substring(0, pack.lastIndexOf('.')) + ".core.config.ForestryBlock"; + Object obj = Class.forName(itemClass).getField(ident).get(null); + if (obj instanceof Block) + item = new ItemStack((Block) obj); + else if (obj instanceof ItemStack) + item = (ItemStack) obj; + } catch (Exception ex) { + FMLLog.warning("Could not retrieve Forestry block identified by: " + ident); + } + + return item; + } + +} diff --git a/src/api/java/forestry/api/core/EnumHumidity.java b/src/api/java/forestry/api/core/EnumHumidity.java new file mode 100755 index 000000000..ebb82c866 --- /dev/null +++ b/src/api/java/forestry/api/core/EnumHumidity.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import java.util.ArrayList; + +/** + * Many things Forestry use temperature and humidity of a biome to determine whether they can or how they can work or spawn at a given location. + * + * This enum concerns humidity. + */ +public enum EnumHumidity { + ARID("Arid"), NORMAL("Normal"), DAMP("Damp"); + + /** + * Populated by Forestry with vanilla biomes. Add additional arid biomes here. (ex. desert) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList aridBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional damp biomes here. (ex. jungle) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList dampBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional normal biomes here. + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList normalBiomeIds = new ArrayList(); + + public final String name; + + private EnumHumidity(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + @Deprecated + public static ArrayList getBiomeIds(EnumHumidity humidity) { + switch (humidity) { + case ARID: + return aridBiomeIds; + case DAMP: + return dampBiomeIds; + case NORMAL: + default: + return normalBiomeIds; + } + } + + /** + * Determines the EnumHumidity given a floating point representation of Minecraft Rainfall + * @param rawHumidity raw rainfall value + * @return EnumHumidity corresponding to rainfall value + */ + public static EnumHumidity getFromValue(float rawHumidity) { + EnumHumidity value = EnumHumidity.ARID; + + if (rawHumidity >= 0.9f) { + value = EnumHumidity.DAMP; + } + else if (rawHumidity >= 0.3f) { + value = EnumHumidity.NORMAL; + } + + return value; + } +} diff --git a/src/api/java/forestry/api/core/EnumTemperature.java b/src/api/java/forestry/api/core/EnumTemperature.java new file mode 100755 index 000000000..2ee0a94e4 --- /dev/null +++ b/src/api/java/forestry/api/core/EnumTemperature.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import java.util.ArrayList; + +import net.minecraft.util.IIcon; +import net.minecraft.world.biome.BiomeGenBase; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.BiomeDictionary; + +/** + * Many things Forestry use temperature and humidity of a biome to determine whether they can or how they can work or spawn at a given location. + * + * This enum concerns temperature. + */ +public enum EnumTemperature { + NONE("None", "habitats/ocean"), ICY("Icy", "habitats/snow"), COLD("Cold", "habitats/taiga"), + NORMAL("Normal", "habitats/plains"), WARM("Warm", "habitats/jungle"), HOT("Hot", "habitats/desert"), HELLISH("Hellish", "habitats/nether"); + + /** + * Populated by Forestry with vanilla biomes. Add additional icy/snow biomes here. (ex. snow plains) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList icyBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional cold biomes here. (ex. taiga) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList coldBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional normal biomes here. (ex. forest, plains) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList normalBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional warm biomes here. (ex. jungle) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList warmBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional hot biomes here. (ex. desert) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList hotBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional hellish biomes here. (ex. nether) + * @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them. + */ + @Deprecated + public static ArrayList hellishBiomeIds = new ArrayList(); + + public final String name; + public final String iconIndex; + + private EnumTemperature(String name, String iconIndex) { + this.name = name; + this.iconIndex = iconIndex; + } + + public String getName() { + return this.name; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return ForestryAPI.textureManager.getDefault(iconIndex); + } + /** + * @deprecated Switching most internals to use getFromValue to not rely on cached values. + */ + @Deprecated + public static ArrayList getBiomeIds(EnumTemperature temperature) { + + switch (temperature) { + case ICY: + return icyBiomeIds; + case COLD: + return coldBiomeIds; + case WARM: + return warmBiomeIds; + case HOT: + return hotBiomeIds; + case HELLISH: + return hellishBiomeIds; + case NORMAL: + default: + return normalBiomeIds; + } + + } + + /** + * Determines if a given BiomeGenBase is of HELLISH temperature, since it is treated seperatly from actual temperature values. + * Uses the BiomeDictionary. + * @param biomeGen BiomeGenBase of the biome in question + * @return true, if the BiomeGenBase is a Nether-type biome; false otherwise. + */ + public static boolean isBiomeHellish(BiomeGenBase biomeGen) { + return BiomeDictionary.isBiomeOfType(biomeGen, BiomeDictionary.Type.NETHER); + } + + /** + * Determines if a given biomeID is of HELLISH temperature, since it is treated seperatly from actual temperature values. + * Uses the BiomeDictionary. + * @param biomeID ID of the BiomeGenBase in question + * @return true, if the biomeID is a Nether-type biome; false otherwise. + */ + public static boolean isBiomeHellish(int biomeID) { + return BiomeDictionary.isBiomeRegistered(biomeID) && BiomeDictionary.isBiomeOfType(BiomeGenBase.getBiome(biomeID), BiomeDictionary.Type.NETHER); + } + + /** + * Determines the EnumTemperature given a floating point representation of + * Minecraft temperature. Hellish biomes are handled based on their biome + * type - check isBiomeHellish. + * @param rawTemp raw temperature value + * @return EnumTemperature corresponding to value of rawTemp + */ + public static EnumTemperature getFromValue(float rawTemp) { + EnumTemperature value = EnumTemperature.ICY; + + if (rawTemp >= 2.0f) { + value = EnumTemperature.HOT; + } + else if (rawTemp >= 0.95f) { + value = EnumTemperature.WARM; + } + else if (rawTemp >= 0.2f) { + value = EnumTemperature.NORMAL; + } + else if (rawTemp >= 0.05f) { + value = EnumTemperature.COLD; + } + + return value; + } + +} diff --git a/src/api/java/forestry/api/core/ForestryAPI.java b/src/api/java/forestry/api/core/ForestryAPI.java new file mode 100755 index 000000000..24c5b7ebc --- /dev/null +++ b/src/api/java/forestry/api/core/ForestryAPI.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Forestry's API is divided into several subcategories to make it easier to understand. + * + * If you need to distribute API files, try to only include the parts you are actually + * using to minimize conflicts due to API changes. + * + * .core - Miscallenous base classes and interfaces as well as some basics for tools, armor, game modes and stuff needed by biome mods. + * .fuels - Managers and classes to facilitate adding fuels to various engines and machines. + * .recipes - Managers and helpers to facilitate adding new recipes to various machines. + * .storage - Managers, events and interfaces for defining new backpacks and handling backpack behaviour. + * .mail - Anything related to handling letters and adding new mail carrier systems. + * .genetics - Shared code for all genetic subclasses. + * \ .apiculture - Bees. + * \ .arboriculture - Trees. + * \ .lepidopterology - Butterflies. + * + * Note that if Forestry is not present, all these references will be null. + */ +public class ForestryAPI { + + /** + * The main mod instance for Forestry. + */ + public static Object instance; + + /** + * A {@link ITextureManager} needed for some things in the API. + */ + @SideOnly(Side.CLIENT) + public static ITextureManager textureManager; + + /** + * The currently active {@link IGameMode}. + */ + public static IGameMode activeMode; + + /** + * Provides information on certain Forestry constants (Villager IDs, Chest gen keys, etc) + */ + public static IForestryConstants forestryConstants; + +} diff --git a/src/api/java/forestry/api/core/ForestryEvent.java b/src/api/java/forestry/api/core/ForestryEvent.java new file mode 100755 index 000000000..badeda56a --- /dev/null +++ b/src/api/java/forestry/api/core/ForestryEvent.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.entity.player.EntityPlayer; + +import cpw.mods.fml.common.eventhandler.Event; + +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; + +public abstract class ForestryEvent extends Event { + + private static abstract class BreedingEvent extends ForestryEvent { + public final ISpeciesRoot root; + public final IBreedingTracker tracker; + public final String username; + + private BreedingEvent(ISpeciesRoot root, String username, IBreedingTracker tracker) { + super(); + this.root = root; + this.username = username; + this.tracker = tracker; + } + } + + public static class SpeciesDiscovered extends BreedingEvent { + public final IAlleleSpecies species; + public SpeciesDiscovered(ISpeciesRoot root, String username, IAlleleSpecies species, IBreedingTracker tracker) { + super(root, username, tracker); + this.species = species; + } + } + + public static class MutationDiscovered extends BreedingEvent { + public final IMutation allele; + public MutationDiscovered(ISpeciesRoot root, String username, IMutation allele, IBreedingTracker tracker) { + super(root, username, tracker); + this.allele = allele; + } + } + + public static class SyncedBreedingTracker extends ForestryEvent { + public final IBreedingTracker tracker; + public final EntityPlayer player; + public SyncedBreedingTracker(IBreedingTracker tracker, EntityPlayer player) { + super(); + this.tracker = tracker; + this.player = player; + } + + } +} diff --git a/src/api/java/forestry/api/core/IArmorNaturalist.java b/src/api/java/forestry/api/core/IArmorNaturalist.java new file mode 100755 index 000000000..87400e271 --- /dev/null +++ b/src/api/java/forestry/api/core/IArmorNaturalist.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public interface IArmorNaturalist { + + /** + * Called when the naturalist's armor acts as spectacles for seeing pollinated tree leaves/flowers. + * + * @param player + * Player doing the viewing + * @param armor + * Armor item + * @param doSee + * Whether or not to actually do the side effects of viewing + * @return true if the armor actually allows the player to see pollination. + */ + public boolean canSeePollination(EntityPlayer player, ItemStack armor, boolean doSee); +} diff --git a/src/api/java/forestry/api/core/IForestryConstants.java b/src/api/java/forestry/api/core/IForestryConstants.java new file mode 100755 index 000000000..4cf876f67 --- /dev/null +++ b/src/api/java/forestry/api/core/IForestryConstants.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +public interface IForestryConstants { + + /** + * @return The villager ID for the Apiarist Villager. + */ + public int getApicultureVillagerID(); + + /** + * @return The villager ID for the Arborist Villager. + */ + public int getArboricultureVillagerID(); + + /** + * @return The ChestGenHooks key for adding items to the Forestry Villager chest. + */ + public String getVillagerChestGenKey(); +} diff --git a/src/api/java/forestry/api/core/IGameMode.java b/src/api/java/forestry/api/core/IGameMode.java new file mode 100755 index 000000000..0b2b0c55d --- /dev/null +++ b/src/api/java/forestry/api/core/IGameMode.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.item.ItemStack; + +public interface IGameMode { + + /** + * @return Human-readable identifier for the game mode. (i.e. 'EASY', 'NORMAL', 'HARD') + */ + String getIdentifier(); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, false if unknown setting. + */ + boolean getBooleanSetting(String ident); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, 0 if unknown setting. + */ + int getIntegerSetting(String ident); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, 0 if unknown setting. + */ + float getFloatSetting(String ident); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, an itemstack containing an apple if unknown setting. + */ + ItemStack getStackSetting(String ident); + +} diff --git a/src/api/java/forestry/api/core/IIconProvider.java b/src/api/java/forestry/api/core/IIconProvider.java new file mode 100755 index 000000000..308e3ce5f --- /dev/null +++ b/src/api/java/forestry/api/core/IIconProvider.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Provides icons, needed in some interfaces, most notably for bees and trees. + */ +public interface IIconProvider { + + @SideOnly(Side.CLIENT) + IIcon getIcon(short texUID); + + @SideOnly(Side.CLIENT) + void registerIcons(IIconRegister register); + +} diff --git a/src/api/java/forestry/api/core/INBTTagable.java b/src/api/java/forestry/api/core/INBTTagable.java new file mode 100755 index 000000000..1d3f85808 --- /dev/null +++ b/src/api/java/forestry/api/core/INBTTagable.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.nbt.NBTTagCompound; + +public interface INBTTagable { + void readFromNBT(NBTTagCompound nbttagcompound); + + void writeToNBT(NBTTagCompound nbttagcompound); +} diff --git a/src/api/java/forestry/api/core/IPlugin.java b/src/api/java/forestry/api/core/IPlugin.java new file mode 100755 index 000000000..4fa44cc80 --- /dev/null +++ b/src/api/java/forestry/api/core/IPlugin.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +/** + * Optional way to hook into Forestry. + * + * Plugin classes can reside in any package, their class name however has to start with 'Plugin', i.e. 'PluginMyStuff'. + * + * @author SirSengir + */ +public interface IPlugin { + + /** + * @return true if the plugin is to be loaded. + */ + public boolean isAvailable(); + + /** + * Called during Forestry's @PreInit. + */ + public void preInit(); + + /** + * Called at the start of Forestry's @PostInit. + */ + public void doInit(); + + /** + * Called at the end of Forestry's @PostInit. + */ + public void postInit(); + +} diff --git a/src/api/java/forestry/api/core/IStructureLogic.java b/src/api/java/forestry/api/core/IStructureLogic.java new file mode 100755 index 000000000..aa93d171e --- /dev/null +++ b/src/api/java/forestry/api/core/IStructureLogic.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +public interface IStructureLogic extends INBTTagable { + + /** + * @return String unique to the type of structure controlled by this structure logic. + */ + String getTypeUID(); + + /** + * Called by {@link ITileStructure}'s validateStructure(). + */ + void validateStructure(); + +} diff --git a/src/api/java/forestry/api/core/ITextureManager.java b/src/api/java/forestry/api/core/ITextureManager.java new file mode 100755 index 000000000..a259fcaea --- /dev/null +++ b/src/api/java/forestry/api/core/ITextureManager.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface ITextureManager { + + void registerIconProvider(IIconProvider provider); + + IIcon getIcon(short texUID); + + IIcon getDefault(String ident); +} diff --git a/src/api/java/forestry/api/core/ITileStructure.java b/src/api/java/forestry/api/core/ITileStructure.java new file mode 100755 index 000000000..95a7f82ef --- /dev/null +++ b/src/api/java/forestry/api/core/ITileStructure.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; + +/** + * The basis for multiblock components. + */ +public interface ITileStructure { + + /** + * @return String unique to the type of structure controlled by this structure logic. Should map to {@link IStructureLogic} + */ + String getTypeUID(); + + /** + * Should map to {@link IStructureLogic} + */ + void validateStructure(); + + /** + * Called when the structure resets. + */ + void onStructureReset(); + + /** + * @return TileEntity that is the master in this structure, null if no structure exists. + */ + ITileStructure getCentralTE(); + + /** + * Called to set the master TileEntity. Implementing TileEntity should keep track of the master's coordinates, not refer to the TE object itself. + * + * @param tile + */ + void setCentralTE(TileEntity tile); + + /** + * @return IInventory representing the TE's inventory. + */ + IInventory getInventory(); + + /** + * Only called on Forestry's own blocks. + */ + void makeMaster(); + + /** + * @return true if this TE is the master in a structure, false otherwise. + */ + boolean isMaster(); + + /** + * @return true if the TE is master or has a master. + */ + boolean isIntegratedIntoStructure(); + +} diff --git a/src/api/java/forestry/api/core/IToolScoop.java b/src/api/java/forestry/api/core/IToolScoop.java new file mode 100755 index 000000000..583b6c7ed --- /dev/null +++ b/src/api/java/forestry/api/core/IToolScoop.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +/** + * Marks a tool as a scoop. + */ +public interface IToolScoop { + +} diff --git a/src/api/java/forestry/api/core/ItemInterface.java b/src/api/java/forestry/api/core/ItemInterface.java new file mode 100755 index 000000000..32513a484 --- /dev/null +++ b/src/api/java/forestry/api/core/ItemInterface.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import java.lang.reflect.Method; + +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.FMLLog; + +/** + * This is going away someday, use FML's GameRegistry instead. + * @deprecated + */ +@Deprecated +public class ItemInterface { + + /** + * Get items here! + * + * Blocks currently not supported. + * + * @param ident + * @return ItemStack representing the item, null if not found. + */ + public static ItemStack getItem(String ident) { + ItemStack item = null; + + try { + String pack = ItemInterface.class.getPackage().getName(); + pack = pack.substring(0, pack.lastIndexOf('.')); + String itemClass = pack.substring(0, pack.lastIndexOf('.')) + ".core.config.ForestryItem"; + Object[] enums = Class.forName(itemClass).getEnumConstants(); + for (Object e : enums) { + if (e.toString().equals(ident)) { + Method m = e.getClass().getMethod("getItemStack"); + return (ItemStack) m.invoke(e); + } + } + } catch (Exception ex) { + FMLLog.warning("Could not retrieve Forestry item identified by: " + ident); + } + + return item; + } +} diff --git a/src/api/java/forestry/api/core/PluginInfo.java b/src/api/java/forestry/api/core/PluginInfo.java new file mode 100755 index 000000000..1a4d15dc7 --- /dev/null +++ b/src/api/java/forestry/api/core/PluginInfo.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Optional annotation to provide additional information on IPlugins. This information will be available via the "/forestry plugin info $pluginID" command ingame. + * + * @author SirSengir + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface PluginInfo { + + /** + * @return Unique identifier for the plugin, no spaces! + */ + String pluginID(); + + /** + * @return Nice and readable plugin name. + */ + String name(); + + /** + * @return Plugin author's name. + */ + String author() default ""; + + /** + * @return URL of plugin homepage. + */ + String url() default ""; + + /** + * @return Version of the plugin, if any. + */ + String version() default ""; + + /** + * @return Short description what the plugin does. + */ + String description() default ""; + + /** + * @return Not used (yet?). + */ + String help() default ""; + +} diff --git a/src/api/java/forestry/api/core/Tabs.java b/src/api/java/forestry/api/core/Tabs.java new file mode 100755 index 000000000..4ce85838d --- /dev/null +++ b/src/api/java/forestry/api/core/Tabs.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.creativetab.CreativeTabs; + +/** + * References to the specialised tabs added by Forestry to creative inventory. + */ +public class Tabs { + + public static CreativeTabs tabApiculture; + public static CreativeTabs tabArboriculture; + public static CreativeTabs tabLepidopterology; + +} diff --git a/src/api/java/forestry/api/core/package-info.java b/src/api/java/forestry/api/core/package-info.java new file mode 100755 index 000000000..129b7d39f --- /dev/null +++ b/src/api/java/forestry/api/core/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="Forestry", provides="ForestryAPI|core") +package forestry.api.core; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/farming/Farmables.java b/src/api/java/forestry/api/farming/Farmables.java new file mode 100755 index 000000000..bc4c159c5 --- /dev/null +++ b/src/api/java/forestry/api/farming/Farmables.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; +import java.util.HashMap; + +public class Farmables { + /** + * Can be used to add IFarmables to some of the vanilla farm logics. + * + * Identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom + */ + public static HashMap> farmables = new HashMap>(); + + public static IFarmInterface farmInterface; +} diff --git a/src/api/java/forestry/api/farming/ICrop.java b/src/api/java/forestry/api/farming/ICrop.java new file mode 100755 index 000000000..22575477d --- /dev/null +++ b/src/api/java/forestry/api/farming/ICrop.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +public interface ICrop { + + /** + * Harvests this crop. Performs the necessary manipulations to set the crop into a "harvested" state. + * + * @return Products harvested. + */ + Collection harvest(); + +} diff --git a/src/api/java/forestry/api/farming/IFarmComponent.java b/src/api/java/forestry/api/farming/IFarmComponent.java new file mode 100755 index 000000000..3387f7a34 --- /dev/null +++ b/src/api/java/forestry/api/farming/IFarmComponent.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import forestry.api.core.ITileStructure; + +public interface IFarmComponent extends ITileStructure { + + boolean hasFunction(); + + void registerListener(IFarmListener listener); + + void removeListener(IFarmListener listener); +} diff --git a/src/api/java/forestry/api/farming/IFarmHousing.java b/src/api/java/forestry/api/farming/IFarmHousing.java new file mode 100755 index 000000000..acdd982d5 --- /dev/null +++ b/src/api/java/forestry/api/farming/IFarmHousing.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public interface IFarmHousing { + + int[] getCoords(); + + int[] getArea(); + + int[] getOffset(); + + World getWorld(); + + /** + * Will run the work cycle on a master TE. Will do nothing on any other farm component. + * + * @return true if any work was done, false otherwise. + */ + boolean doWork(); + + boolean hasLiquid(FluidStack liquid); + + void removeLiquid(FluidStack liquid); + + boolean hasResources(ItemStack[] resources); + + void removeResources(ItemStack[] resources); + + /** + * Callback for {@link IFarmLogic}s to plant a sapling, seed, germling, stem. Will remove the appropriate germling from the farm's inventory. It's up to the + * logic to only call this on a valid location. + * + * @param farmable + * @param world + * @param x + * @param y + * @param z + * @return true if planting was successful, false otherwise. + */ + boolean plantGermling(IFarmable farmable, World world, int x, int y, int z); + + /* INTERACTION WITH HATCHES */ + boolean acceptsAsGermling(ItemStack itemstack); + + boolean acceptsAsResource(ItemStack itemstack); + + boolean acceptsAsFertilizer(ItemStack itemstack); + + /* LOGIC */ + /** + * Set a farm logic for the given direction. UP/DOWN/UNKNOWN are invalid! + * + * @param direction + * @param logic + */ + void setFarmLogic(ForgeDirection direction, IFarmLogic logic); + + /** + * Reset the farm logic for the given direction to default. UP/DOWN/UNKNOWN are invalid! + * + * @param direction + */ + void resetFarmLogic(ForgeDirection direction); +} diff --git a/src/api/java/forestry/api/farming/IFarmInterface.java b/src/api/java/forestry/api/farming/IFarmInterface.java new file mode 100755 index 000000000..089687476 --- /dev/null +++ b/src/api/java/forestry/api/farming/IFarmInterface.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import forestry.api.core.IStructureLogic; + +public interface IFarmInterface { + + /** + * Creates {@link IStructureLogic} for use in farm components. + * + * @param structure + * {@link IFarmComponent} to create the logic for. + * @return {@link IStructureLogic} for use in farm components + */ + IStructureLogic createFarmStructureLogic(IFarmComponent structure); +} diff --git a/src/api/java/forestry/api/farming/IFarmListener.java b/src/api/java/forestry/api/farming/IFarmListener.java new file mode 100755 index 000000000..461525ff7 --- /dev/null +++ b/src/api/java/forestry/api/farming/IFarmListener.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IFarmListener { + + /** + * Called before a crop is harvested. + * + * @param crop + * ICrop about to be harvested. + * @return true to cancel further processing of this crop. + */ + boolean beforeCropHarvest(ICrop crop); + + /** + * Called after a crop has been harvested, but before harvested items are stowed in the farms inventory. + * + * @param harvested + * Collection of harvested stacks. May be manipulated. Ensure removal of stacks with 0 or less items! + * @param crop + * Harvested {@link ICrop} + */ + void afterCropHarvest(Collection harvested, ICrop crop); + + /** + * Called after the stack of collected items has been returned by the farm logic, but before it is added to the farm's pending queue. + * + * @param collected + * Collection of collected stacks. May be manipulated. Ensure removal of stacks with 0 or less items! + * @param logic + */ + void hasCollected(Collection collected, IFarmLogic logic); + + /** + * Called after farmland has successfully been cultivated by a farm logic. + * + * @param logic + * @param x + * @param y + * @param z + * @param direction + * @param extent + */ + void hasCultivated(IFarmLogic logic, int x, int y, int z, ForgeDirection direction, int extent); + + /** + * Called after the stack of harvested crops has been returned by the farm logic, but before it is added to the farm's pending queue. + * + * @param harvested + * @param logic + * @param x + * @param y + * @param z + * @param direction + * @param extent + */ + void hasScheduledHarvest(Collection harvested, IFarmLogic logic, int x, int y, int z, ForgeDirection direction, int extent); + + /** + * Can be used to cancel farm task on a per side/{@link IFarmLogic} basis. + * + * @param logic + * @param direction + * @return true to skip any work action on the given logic and direction for this work cycle. + */ + boolean cancelTask(IFarmLogic logic, ForgeDirection direction); +} diff --git a/src/api/java/forestry/api/farming/IFarmLogic.java b/src/api/java/forestry/api/farming/IFarmLogic.java new file mode 100755 index 000000000..c21f220d6 --- /dev/null +++ b/src/api/java/forestry/api/farming/IFarmLogic.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IFarmLogic { + + int getFertilizerConsumption(); + + int getWaterConsumption(float hydrationModifier); + + boolean isAcceptedResource(ItemStack itemstack); + + boolean isAcceptedGermling(ItemStack itemstack); + + Collection collect(); + + boolean cultivate(int x, int y, int z, ForgeDirection direction, int extent); + + Collection harvest(int x, int y, int z, ForgeDirection direction, int extent); + + @SideOnly(Side.CLIENT) + IIcon getIcon(); + + ResourceLocation getSpriteSheet(); + + String getName(); +} diff --git a/src/api/java/forestry/api/farming/IFarmable.java b/src/api/java/forestry/api/farming/IFarmable.java new file mode 100755 index 000000000..42fb15395 --- /dev/null +++ b/src/api/java/forestry/api/farming/IFarmable.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +/** + * IGermling describes a crop or other harvestable object and can be used to inspect item stacks and blocks for matches. + */ +public interface IFarmable { + + /** + * @param world + * @param x + * @param y + * @param z + * @return true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop. + */ + boolean isSaplingAt(World world, int x, int y, int z); + + /** + * @param world + * @param x + * @param y + * @param z + * @return {@link ICrop} if the block at the given location is a harvestable and mature crop, null otherwise. + */ + ICrop getCropAt(World world, int x, int y, int z); + + /** + * @param itemstack + * @return true if the item is a valid germling (plantable sapling, seed, etc.) for this type. + */ + boolean isGermling(ItemStack itemstack); + + /** + * @param itemstack + * @return true if the item is something that can drop from this type without actually being harvested as a crop. (Apples or sapling from decaying leaves.) + */ + boolean isWindfall(ItemStack itemstack); + + /** + * Plants a sapling by manipulating the world. The {@link IFarmLogic} should have verified the given location as valid. Called by the {@link IFarmHousing} + * which handles resources. + * + * @param germling + * @param world + * @param x + * @param y + * @param z + * @return true on success, false otherwise. + */ + boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z); + +} diff --git a/src/api/java/forestry/api/farming/package-info.java b/src/api/java/forestry/api/farming/package-info.java new file mode 100755 index 000000000..91a4e2d9d --- /dev/null +++ b/src/api/java/forestry/api/farming/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|farming") +package forestry.api.farming; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/food/BeverageManager.java b/src/api/java/forestry/api/food/BeverageManager.java new file mode 100755 index 000000000..2b0143ab1 --- /dev/null +++ b/src/api/java/forestry/api/food/BeverageManager.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +public class BeverageManager { + public static IBeverageEffect[] effectList = new IBeverageEffect[128]; + + public static IInfuserManager infuserManager; + public static IIngredientManager ingredientManager; +} diff --git a/src/api/java/forestry/api/food/IBeverageEffect.java b/src/api/java/forestry/api/food/IBeverageEffect.java new file mode 100755 index 000000000..6a787411d --- /dev/null +++ b/src/api/java/forestry/api/food/IBeverageEffect.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public interface IBeverageEffect { + int getId(); + + void doEffect(World world, EntityPlayer player); + + String getDescription(); +} diff --git a/src/api/java/forestry/api/food/IInfuserManager.java b/src/api/java/forestry/api/food/IInfuserManager.java new file mode 100755 index 000000000..55d8ad5f3 --- /dev/null +++ b/src/api/java/forestry/api/food/IInfuserManager.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +import net.minecraft.item.ItemStack; + +public interface IInfuserManager { + + void addMixture(int meta, ItemStack ingredient, IBeverageEffect effect); + + void addMixture(int meta, ItemStack[] ingredients, IBeverageEffect effect); + + ItemStack getSeasoned(ItemStack base, ItemStack[] ingredients); + + boolean hasMixtures(ItemStack[] ingredients); + + ItemStack[] getRequired(ItemStack[] ingredients); + +} diff --git a/src/api/java/forestry/api/food/IIngredientManager.java b/src/api/java/forestry/api/food/IIngredientManager.java new file mode 100755 index 000000000..fab0e0129 --- /dev/null +++ b/src/api/java/forestry/api/food/IIngredientManager.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +import net.minecraft.item.ItemStack; + +public interface IIngredientManager { + + String getDescription(ItemStack itemstack); + + void addIngredient(ItemStack ingredient, String description); + +} diff --git a/src/api/java/forestry/api/food/package-info.java b/src/api/java/forestry/api/food/package-info.java new file mode 100755 index 000000000..33fa99e9c --- /dev/null +++ b/src/api/java/forestry/api/food/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|food") +package forestry.api.food; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/fuels/EngineBronzeFuel.java b/src/api/java/forestry/api/fuels/EngineBronzeFuel.java new file mode 100755 index 000000000..cbab0cafc --- /dev/null +++ b/src/api/java/forestry/api/fuels/EngineBronzeFuel.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraftforge.fluids.Fluid; + +public class EngineBronzeFuel { + /** + * Item that is valid fuel for a biogas engine. + */ + public final Fluid liquid; + /** + * Power produced by this fuel per work cycle of the engine. + */ + public final int powerPerCycle; + /** + * How many work cycles a single "stack" of this type lasts. + */ + public final int burnDuration; + /** + * By how much the normal heat dissipation rate of 1 is multiplied when using this fuel type. + */ + public final int dissipationMultiplier; + + public EngineBronzeFuel(Fluid liquid, int powerPerCycle, int burnDuration, int dissipationMultiplier) { + this.liquid = liquid; + this.powerPerCycle = powerPerCycle; + this.burnDuration = burnDuration; + this.dissipationMultiplier = dissipationMultiplier; + } +} diff --git a/src/api/java/forestry/api/fuels/EngineCopperFuel.java b/src/api/java/forestry/api/fuels/EngineCopperFuel.java new file mode 100755 index 000000000..af568dd41 --- /dev/null +++ b/src/api/java/forestry/api/fuels/EngineCopperFuel.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class EngineCopperFuel { + + /** + * Item that is valid fuel for a peat-fired engine. + */ + public final ItemStack fuel; + /** + * Power produced by this fuel per work cycle. + */ + public final int powerPerCycle; + /** + * Amount of work cycles this item lasts before being consumed. + */ + public final int burnDuration; + + public EngineCopperFuel(ItemStack fuel, int powerPerCycle, int burnDuration) { + this.fuel = fuel; + this.powerPerCycle = powerPerCycle; + this.burnDuration = burnDuration; + } + +} diff --git a/src/api/java/forestry/api/fuels/FermenterFuel.java b/src/api/java/forestry/api/fuels/FermenterFuel.java new file mode 100755 index 000000000..32989a803 --- /dev/null +++ b/src/api/java/forestry/api/fuels/FermenterFuel.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class FermenterFuel { + /** + * Item that is a valid fuel for the fermenter (i.e. fertilizer). + */ + public final ItemStack item; + /** + * How much is fermeted per work cycle, i.e. how much biomass is produced per cycle. + */ + public final int fermentPerCycle; + /** + * Amount of work cycles a single item of this fuel lasts before expiring. + */ + public final int burnDuration; + + public FermenterFuel(ItemStack item, int fermentPerCycle, int burnDuration) { + this.item = item; + this.fermentPerCycle = fermentPerCycle; + this.burnDuration = burnDuration; + } +} diff --git a/src/api/java/forestry/api/fuels/FuelManager.java b/src/api/java/forestry/api/fuels/FuelManager.java new file mode 100755 index 000000000..e27405813 --- /dev/null +++ b/src/api/java/forestry/api/fuels/FuelManager.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import java.util.HashMap; + + +public class FuelManager { + /** + * Add new fuels for the fermenter here (i.e. fertilizer). Will accept Items, ItemStacks and Strings (Ore Dictionary) + */ + public static HashMap fermenterFuel; + /** + * Add new resources for the moistener here (i.e. wheat) + */ + public static HashMap moistenerResource; + /** + * Add new substrates for the rainmaker here + */ + public static HashMap rainSubstrate; + /** + * Add new fuels for EngineBronze (= biogas engine) here + */ + public static HashMap bronzeEngineFuel; + /** + * Add new fuels for EngineCopper (= peat-fired engine) here + */ + public static HashMap copperEngineFuel; + + // Generator fuel list in GeneratorFuel.class +} diff --git a/src/api/java/forestry/api/fuels/GeneratorFuel.java b/src/api/java/forestry/api/fuels/GeneratorFuel.java new file mode 100755 index 000000000..9b81a4c00 --- /dev/null +++ b/src/api/java/forestry/api/fuels/GeneratorFuel.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import java.util.HashMap; + +import net.minecraftforge.fluids.FluidStack; + +public class GeneratorFuel { + + public static HashMap fuels = new HashMap(); + + /** + * LiquidStack representing the fuel type and amount consumed per triggered cycle. + */ + public final FluidStack fuelConsumed; + /** + * EU emitted per tick while this fuel is being consumed in the generator (i.e. biofuel = 32, biomass = 8). + */ + public final int eu; + /** + * Rate at which the fuel is consumed. 1 - Every tick 2 - Every second tick 3 - Every third tick etc. + */ + public final int rate; + + public GeneratorFuel(FluidStack fuelConsumed, int eu, int rate) { + this.fuelConsumed = fuelConsumed; + this.eu = eu; + this.rate = rate; + } + +} diff --git a/src/api/java/forestry/api/fuels/MoistenerFuel.java b/src/api/java/forestry/api/fuels/MoistenerFuel.java new file mode 100755 index 000000000..4c4c7a0b6 --- /dev/null +++ b/src/api/java/forestry/api/fuels/MoistenerFuel.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class MoistenerFuel { + /** + * The item to use + */ + public final ItemStack item; + /** + * The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch) + */ + public final ItemStack product; + /** + * How much this item contributes to the final product of the moistener (i.e. mycelium) + */ + public final int moistenerValue; + /** + * What stage this product represents. Resources with lower stage value will be consumed first. + */ + public final int stage; + + public MoistenerFuel(ItemStack item, ItemStack product, int stage, int moistenerValue) { + this.item = item; + this.product = product; + this.stage = stage; + this.moistenerValue = moistenerValue; + } +} diff --git a/src/api/java/forestry/api/fuels/RainSubstrate.java b/src/api/java/forestry/api/fuels/RainSubstrate.java new file mode 100755 index 000000000..ab0deb5a3 --- /dev/null +++ b/src/api/java/forestry/api/fuels/RainSubstrate.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class RainSubstrate { + /** + * Rain substrate capable of activating the rainmaker. + */ + public ItemStack item; + /** + * Duration of the rain shower triggered by this substrate in Minecraft ticks. + */ + public int duration; + /** + * Speed of activation sequence triggered. + */ + public float speed; + + public boolean reverse; + + public RainSubstrate(ItemStack item, int duration, float speed) { + this(item, duration, speed, false); + } + + public RainSubstrate(ItemStack item, float speed) { + this(item, 0, speed, true); + } + + public RainSubstrate(ItemStack item, int duration, float speed, boolean reverse) { + this.item = item; + this.duration = duration; + this.speed = speed; + this.reverse = reverse; + } +} diff --git a/src/api/java/forestry/api/fuels/package-info.java b/src/api/java/forestry/api/fuels/package-info.java new file mode 100755 index 000000000..f647c2011 --- /dev/null +++ b/src/api/java/forestry/api/fuels/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|fuels") +package forestry.api.fuels; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/genetics/AlleleManager.java b/src/api/java/forestry/api/genetics/AlleleManager.java new file mode 100755 index 000000000..8906f3c5d --- /dev/null +++ b/src/api/java/forestry/api/genetics/AlleleManager.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +/** + * Holds a static reference to the {@link IAlleleRegistry}. + */ +public class AlleleManager { + /** + * Main access point for all things related to genetics. See {@link IAlleleRegistry} for details. + */ + public static IAlleleRegistry alleleRegistry; + /** + * Translates plain leaf blocks into genetic data. Used by bees and butterflies to convert and pollinate foreign leaf blocks. + */ + public static HashMap ersatzSpecimen = new HashMap(); + /** + * Translates plain saplings into genetic data. Used by the treealyzer and the farm to convert foreign saplings. + */ + public static HashMap ersatzSaplings = new HashMap(); + /** + * Queryable instance of an {@link IClimateHelper} for easier implementation. + */ + public static IClimateHelper climateHelper; +} diff --git a/src/api/java/forestry/api/genetics/EnumTolerance.java b/src/api/java/forestry/api/genetics/EnumTolerance.java new file mode 100755 index 000000000..6ff0085eb --- /dev/null +++ b/src/api/java/forestry/api/genetics/EnumTolerance.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +public enum EnumTolerance { + NONE, + + BOTH_1, BOTH_2, BOTH_3, BOTH_4, BOTH_5, + + UP_1, UP_2, UP_3, UP_4, UP_5, + + DOWN_1, DOWN_2, DOWN_3, DOWN_4, DOWN_5 +} diff --git a/src/api/java/forestry/api/genetics/IAllele.java b/src/api/java/forestry/api/genetics/IAllele.java new file mode 100755 index 000000000..8ef6b1c86 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAllele.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * An {@link IIndividual}'s {@link IGenome} is composed of {@link IChromosome}s consisting each of a primary and secondary {@link IAllele}. + * + * {@link IAllele}s hold all information regarding an {@link IIndividual}'s traits, from species to size, temperature tolerances, etc. + * + * Should be extended for different types of alleles. ISpeciesAllele, IBiomeAllele, etc. + * + * @author SirSengir + */ +public interface IAllele { + + /** + * @return A unique string identifier for this allele. + */ + String getUID(); + + /** + * @return true if the allele is dominant, false otherwise. + */ + boolean isDominant(); + + /** + * @return Localized short, human-readable identifier used in tooltips and beealyzer. + */ + String getName(); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleArea.java b/src/api/java/forestry/api/genetics/IAlleleArea.java new file mode 100755 index 000000000..7277ff0a1 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleArea.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleArea extends IAllele { + + int[] getValue(); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleBoolean.java b/src/api/java/forestry/api/genetics/IAlleleBoolean.java new file mode 100755 index 000000000..887da3b90 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleBoolean.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleBoolean extends IAllele { + + boolean getValue(); + + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleEffect.java b/src/api/java/forestry/api/genetics/IAlleleEffect.java new file mode 100755 index 000000000..7b94e6b16 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleEffect.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Basic effect allele. + */ +public interface IAlleleEffect extends IAllele { + /** + * @return true if this effect can combine with the effect on other allele (i.e. run before or after). combination can only occur if both effects are + * combinable. + */ + boolean isCombinable(); + + /** + * Returns the passed data storage if it is valid for this effect or a new one if the passed storage object was invalid for this effect. + * + * @param storedData + * @return {@link IEffectData} for the next cycle. + */ + IEffectData validateStorage(IEffectData storedData); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleFloat.java b/src/api/java/forestry/api/genetics/IAlleleFloat.java new file mode 100755 index 000000000..6ca28776a --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleFloat.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleFloat extends IAllele { + + float getValue(); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleFlowers.java b/src/api/java/forestry/api/genetics/IAlleleFlowers.java new file mode 100755 index 000000000..0368ca41c --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleFlowers.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + + +public interface IAlleleFlowers extends IAllele { + + /** + * @return FlowerProvider + */ + IFlowerProvider getProvider(); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleHandler.java b/src/api/java/forestry/api/genetics/IAlleleHandler.java new file mode 100755 index 000000000..3d052afe4 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleHandler.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * @author Alex Binnie + * + * Handler for events that occur in IAlleleRegistry, such as registering alleles, branches etc. Useful for handling plugin specific behavior (i.e. + * creating a list of all bee species etc.) + * + */ +public interface IAlleleHandler { + + /** + * Called when an allele is registered with {@link IAlleleRegistry}. + * + * @param allele + * Allele which was registered. + */ + public void onRegisterAllele(IAllele allele); + + /** + * Called when a classification is registered with {@link IAlleleRegistry}. + * + * @param classification + * Classification which was registered. + */ + public void onRegisterClassification(IClassification classification); + + /** + * Called when a fruit family is registered with {@link IAlleleRegistry}. + * + * @param family + * Fruit family which was registered. + */ + public void onRegisterFruitFamily(IFruitFamily family); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleInteger.java b/src/api/java/forestry/api/genetics/IAlleleInteger.java new file mode 100755 index 000000000..6991efe5f --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleInteger.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing integer values. + */ +public interface IAlleleInteger extends IAllele { + + int getValue(); + +} diff --git a/src/api/java/forestry/api/genetics/IAllelePlantType.java b/src/api/java/forestry/api/genetics/IAllelePlantType.java new file mode 100755 index 000000000..211237f20 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAllelePlantType.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +public interface IAllelePlantType extends IAllele { + + public EnumSet getPlantTypes(); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleRegistry.java b/src/api/java/forestry/api/genetics/IAlleleRegistry.java new file mode 100755 index 000000000..b904a4e46 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleRegistry.java @@ -0,0 +1,227 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Collection; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import forestry.api.genetics.IClassification.EnumClassLevel; + +/** + * Manages {@link ISpeciesRoot}, {@link IAllele}s, {@link IFruitFamily}s, {@link IClassification}, the blacklist and allows creation of research notes. + * + * @author SirSengir + */ +public interface IAlleleRegistry { + + /* SPECIES ROOT CLASSES */ + /** + * Register a {@link ISpeciesRoot}. + * @param root {@link ISpeciesRoot} to register. + */ + void registerSpeciesRoot(ISpeciesRoot root); + + /** + * @return Map of all registered {@link ISpeciesRoot}. + */ + Map getSpeciesRoot(); + + /** + * Retrieve the {@link ISpeciesRoot} with the given uid. + * @param uid Unique id for the species class, i.e. "rootBees", "rootTrees", "rootButterflies". + * @return {@link ISpeciesRoot} if it exists, null otherwise. + */ + ISpeciesRoot getSpeciesRoot(String uid); + + /** + * Retrieve a matching {@link ISpeciesRoot} for the given itemstack. + * @param stack An itemstack possibly containing NBT data which can be converted by a species root. + * @return {@link ISpeciesRoot} if found, null otherwise. + */ + ISpeciesRoot getSpeciesRoot(ItemStack stack); + + /** + * Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual}-class. + * @param clz Class extending {@link IIndividual}. + * @return {@link ISpeciesRoot} if found, null otherwise. + */ + ISpeciesRoot getSpeciesRoot(Class clz); + + /* INDIVIDUAL */ + /** + * Tests the itemstack for genetic information. + * + * @param stack + * @return true if the itemstack is an individual. + */ + boolean isIndividual(ItemStack stack); + + /** + * Retrieve genetic information from an itemstack. + * + * @param stack + * Stack to retrieve genetic information for. + * @return IIndividual containing genetic information, null if none could be extracted. + */ + IIndividual getIndividual(ItemStack stack); + + /* ALLELES */ + + /** + * @return HashMap of all currently registered alleles. + */ + Map getRegisteredAlleles(); + + /** + * Registers an allele. + * + * @param allele + * IAllele to register. + */ + void registerAllele(IAllele allele); + + /** + * @return HashMap of all registered deprecated alleles and their corresponding replacements + */ + Map getDeprecatedAlleleReplacements(); + + /** + * Registers an old allele UID and the new IAllele to replace instances of it with. + * + * @param deprecatedAlleleUID + * the old allele's UID + * @param replacement + * the IAllele that the deprecated Allele will be replaced with. + */ + void registerDeprecatedAlleleReplacement(String deprecatedAlleleUID, IAllele replacement); + + /** + * Gets an allele + * + * @param uid + * String based unique identifier of the allele to retrieve. + * @return IAllele if found or a replacement is found in the Deprecated Allele map, null otherwise. + */ + IAllele getAllele(String uid); + + /* THIS SHOULD BE PHASED OUT */ + @Deprecated + void reloadMetaMap(World world); + + @Deprecated + IAllele getFromMetaMap(int meta); + + @Deprecated + int getFromUIDMap(String uid); + + /* CLASSIFICATIONS */ + /** + * @return HashMap of all currently registered classifications. + */ + Map getRegisteredClassifications(); + + /** + * Registers a classification. + * + * @param classification + * IClassification to register. + */ + void registerClassification(IClassification classification); + + /** + * Creates and returns a classification. + * + * @param level + * EnumClassLevel of the classification to create. + * @param uid + * String based unique identifier. Implementation will throw an exception if the key is already taken. + * @param scientific + * Binomial for the given classification. + * @return Created {@link IClassification} for easier chaining. + */ + IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific); + + /** + * Gets a classification. + * + * @param uid + * String based unique identifier of the classification to retrieve. + * @return {@link IClassification} if found, null otherwise. + */ + IClassification getClassification(String uid); + + /* FRUIT FAMILIES */ + /** + * Get all registered fruit families. + * + * @return A map of registered fruit families and their UIDs. + */ + Map getRegisteredFruitFamilies(); + + /** + * Registers a new fruit family. + * + * @param family + */ + void registerFruitFamily(IFruitFamily family); + + /** + * Retrieves a fruit family identified by uid. + * + * @param uid + * @return {IFruitFamily} if found, false otherwise. + */ + IFruitFamily getFruitFamily(String uid); + + /* ALLELE HANDLERS */ + /** + * Registers a new IAlleleHandler + * + * @param handler + * IAlleleHandler to register. + */ + void registerAlleleHandler(IAlleleHandler handler); + + /* BLACKLIST */ + /** + * Blacklist an allele identified by its UID from mutation. + * + * @param uid + * UID of the allele to blacklist. + */ + void blacklistAllele(String uid); + + /** + * @return Current blacklisted alleles. + */ + Collection getAlleleBlacklist(); + + /** + * @param uid + * UID of the species to vet. + * @return true if the allele is blacklisted. + */ + boolean isBlacklisted(String uid); + + /* RESEARCH */ + /** + * @param researcher Username of the player who researched this note. + * @param species {@link IAlleleSpecies} to encode on the research note. + * @return An itemstack containing a research note with the given species encoded onto it. + */ + ItemStack getSpeciesNoteStack(String researcher, IAlleleSpecies species); + + /** + * @param researcher Username of the player who researched this note. + * @param mutation {@link IMutation} to encode on the research note. + * @return An itemstack containing a research note with the given mutation encoded onto it. + */ + ItemStack getMutationNoteStack(String researcher, IMutation mutation); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleSpecies.java b/src/api/java/forestry/api/genetics/IAlleleSpecies.java new file mode 100755 index 000000000..3f02201f1 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleSpecies.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.core.IIconProvider; + +/** + * Basic species allele. + */ +public interface IAlleleSpecies extends IAllele { + + /** + * @return the {@link ISpeciesRoot} associated with this species. + */ + ISpeciesRoot getRoot(); + + /** + * @return Localized short description of this species. (May be null.) + */ + String getDescription(); + + /** + * Binomial name of the species sans genus ("Apis"). Returning "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun + * names or return null. + * + * @return flavour text (may be null) + */ + String getBinomial(); + + /** + * Authority for the binomial name, e.g. "Sengir" on species of base Forestry. + * + * @return flavour text (may be null) + */ + String getAuthority(); + + /** + * @return Branch this species is associated with. + */ + IClassification getBranch(); + + /* RESEARCH */ + /** + * Complexity determines the difficulty researching a species. The values of primary and secondary are + * added together (and rounded) to determine the amount of pairs needed for successful research. + * @return Values between 3 - 11 are useful. + */ + int getComplexity(); + + /** + * @param itemstack + * @return A float signifying the chance for the passed itemstack to yield a research success. + */ + float getResearchSuitability(ItemStack itemstack); + + /** + * @param world + * @param researcher + * @param individual + * @param bountyLevel + * @return Array of itemstacks representing the bounty for this research success. + */ + ItemStack[] getResearchBounty(World world, String researcher, IIndividual individual, int bountyLevel); + + /* CLIMATE */ + /** + * @return Preferred temperature + */ + EnumTemperature getTemperature(); + + /** + * @return Preferred humidity + */ + EnumHumidity getHumidity(); + + /* MISC */ + /** + * @return true if the species icon should have a glowing effect. + */ + boolean hasEffect(); + + /** + * @return true if the species should not be displayed in NEI or creative inventory. + */ + boolean isSecret(); + + /** + * @return true to have the species count against the species total. + */ + boolean isCounted(); + + /* APPEARANCE */ + /** + * @param renderPass Render pass to get the colour for. + * @return Colour to use for the render pass. + */ + int getIconColour(int renderPass); + + @SideOnly(Side.CLIENT) + IIconProvider getIconProvider(); + +} diff --git a/src/api/java/forestry/api/genetics/IAlleleTolerance.java b/src/api/java/forestry/api/genetics/IAlleleTolerance.java new file mode 100755 index 000000000..f5ba9e670 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IAlleleTolerance.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleTolerance extends IAllele { + + EnumTolerance getValue(); + +} diff --git a/src/api/java/forestry/api/genetics/IBreedingTracker.java b/src/api/java/forestry/api/genetics/IBreedingTracker.java new file mode 100755 index 000000000..1a37eb408 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IBreedingTracker.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +import forestry.api.apiculture.IBeekeepingMode; + +/** + * Keeps track of who bred and/or discovered which species in a world. + * + * @author SirSengir + */ +public interface IBreedingTracker { + + /** + * @return Name of the current {@link IBeekeepingMode}. + */ + String getModeName(); + + /** + * Set the current {@link IBeekeepingMode}. + */ + void setModeName(String name); + + /** + * @return Amount of species discovered. + */ + int getSpeciesBred(); + + /** + * Register the birth of an individual. Will mark it as discovered. + * + * @param individual + */ + void registerBirth(IIndividual individual); + + /** + * Register the pickup of an individual. + * + * @param individual + */ + void registerPickup(IIndividual individual); + + /** + * Marks a species as discovered. Should only be called from registerIndividual normally. + * + * @param species + */ + void registerSpecies(IAlleleSpecies species); + + /** + * Register a successful mutation. Will mark it as discovered. + */ + @Deprecated + void registerMutation(IAllele allele0, IAllele allele1); + + /** + * Register a successful mutation. Will mark it as discovered. + * + * @param mutation + */ + void registerMutation(IMutation mutation); + + /** + * Queries the tracker for discovered species. + * + * @param mutation + * Mutation to query for. + * @return true if the mutation has been discovered. + */ + boolean isDiscovered(IMutation mutation); + + /** + * Queries the tracker for discovered species. + * + * @param species + * Species to check. + * @return true if the species has been bred. + */ + boolean isDiscovered(IAlleleSpecies species); + + /** + * Synchronizes the tracker to the client side. Should be called before opening any gui needing that information. + * + * @param player + */ + void synchToPlayer(EntityPlayer player); + + /* LOADING & SAVING */ + void decodeFromNBT(NBTTagCompound nbttagcompound); + + void encodeToNBT(NBTTagCompound nbttagcompound); + +} diff --git a/src/api/java/forestry/api/genetics/IChromosome.java b/src/api/java/forestry/api/genetics/IChromosome.java new file mode 100755 index 000000000..d501efbac --- /dev/null +++ b/src/api/java/forestry/api/genetics/IChromosome.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +/** + * Implementations other than Forestry's default one are not supported! + * + * @author SirSengir + */ +public interface IChromosome extends INBTTagable { + + IAllele getPrimaryAllele(); + + IAllele getSecondaryAllele(); + + IAllele getInactiveAllele(); + + IAllele getActiveAllele(); + +} diff --git a/src/api/java/forestry/api/genetics/IChromosomeType.java b/src/api/java/forestry/api/genetics/IChromosomeType.java new file mode 100755 index 000000000..a3b1f8e0c --- /dev/null +++ b/src/api/java/forestry/api/genetics/IChromosomeType.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/* + * Interface to be implemented by the enums representing the various chromosomes + */ +public interface IChromosomeType { + + /* + * Get class which all alleles on this chromosome must interface + */ + Class getAlleleClass(); + + String getName(); + + ISpeciesRoot getSpeciesRoot(); + + int ordinal(); + +} diff --git a/src/api/java/forestry/api/genetics/IClassification.java b/src/api/java/forestry/api/genetics/IClassification.java new file mode 100755 index 000000000..f365b915c --- /dev/null +++ b/src/api/java/forestry/api/genetics/IClassification.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Biological classifications from domain down to genus. + * + * Used by the *alyzers to display hierarchies. + */ +public interface IClassification { + + public enum EnumClassLevel { + + DOMAIN(0x777fff, true), KINGDOM(0x77c3ff), PHYLUM(0x77ffb6, true), DIVISION(0x77ffb6, true), CLASS(0x7bff77), ORDER(0xbeff77), FAMILY(0xfffd77), + SUBFAMILY(0xfffd77), TRIBE(0xfffd77), GENUS(0xffba77); + + private int colour; + private boolean isDroppable; + + private EnumClassLevel(int colour) { + this(colour, false); + } + + private EnumClassLevel(int colour, boolean isDroppable) { + this.colour = colour; + this.isDroppable = isDroppable; + } + + /** + * @return Colour to use for displaying this classification. + */ + public int getColour() { + return colour; + } + + /** + * @return Indicates whether display of this classification level can be ommitted in case of space constraints. + */ + public boolean isDroppable() { + return isDroppable; + } + } + + /** + * @return Level inside the full hierarchy this particular classification is located at. + */ + EnumClassLevel getLevel(); + + /** + * @return Unique String identifier. + */ + String getUID(); + + /** + * @return Localized branch name for user display. + */ + String getName(); + + /** + * A branch approximates a "genus" in real life. Real life examples: "Micrapis", "Megapis" + * + * @return flavour text (may be null) + */ + String getScientific(); + + /** + * @return Localized description of this branch. (May be null.) + */ + String getDescription(); + + /** + * @return Member groups of this one. + */ + IClassification[] getMemberGroups(); + + /** + * Adds subgroups to this group. + */ + void addMemberGroup(IClassification group); + + /** + * @return Member species of this group. + */ + IAlleleSpecies[] getMemberSpecies(); + + /** + * Used by the allele registry to populate internal collection of branch members on the fly. + * + * @param species + */ + void addMemberSpecies(IAlleleSpecies species); + + /** + * @return Parent classification, null if this is root. + */ + IClassification getParent(); + + /** + * Only used internally by the AlleleRegistry if this classification has been added to another one. + * + * @param parent + */ + void setParent(IClassification parent); +} diff --git a/src/api/java/forestry/api/genetics/IClimateHelper.java b/src/api/java/forestry/api/genetics/IClimateHelper.java new file mode 100755 index 000000000..753b31612 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IClimateHelper.java @@ -0,0 +1,50 @@ +package forestry.api.genetics; + +import java.util.Collection; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +public interface IClimateHelper { + /** + * Determines whether the given temperature and humidity are within the given constraints. + * @param temperature The temperature to test. + * @param humidity The humidity to test. + * @param baseTemp Base temperature for the test. + * @param tolTemp Temperature tolerance to apply. + * @param baseHumid Base humidity for the test. + * @param tolHumid Humidity tolerance to apply. + * @return true if both temperature and humidity fit the given constraints. + */ + boolean isWithinLimits(EnumTemperature temperature, EnumHumidity humidity, + EnumTemperature baseTemp, EnumTolerance tolTemp, + EnumHumidity baseHumid, EnumTolerance tolHumid); + + /** + * Gets a collection of humidities which fit the given parameters. + * @param prefered Base humidity from which to measure. + * @param tolerance Tolerance to apply to the base humidity. + * @return A collection of humidities which fall within the given parameters. + */ + Collection getToleratedHumidity(EnumHumidity prefered, EnumTolerance tolerance); + /** + * Gets a collection of temperatures which fit the given parameters. + * @param prefered Base temperature from which to measure. + * @param tolerance Tolerance to apply to the base temperatures. + * @return A collection of temperatures which fall within the given parameters. + */ + Collection getToleratedTemperature(EnumTemperature prefered, EnumTolerance tolerance); + + /** + * Gets a localized, human readable string for the given temperature. + * @param temperature Temperature to generate the string for. + * @return A localized, human readable string for the given temperature. + */ + String toDisplay(EnumTemperature temperature); + /** + * Gets a localized, human readable string for the given humidity. + * @param temperature Humidity to generate the string for. + * @return A localized, human readable string for the given humidity. + */ + String toDisplay(EnumHumidity humidity); +} \ No newline at end of file diff --git a/src/api/java/forestry/api/genetics/IEffectData.java b/src/api/java/forestry/api/genetics/IEffectData.java new file mode 100755 index 000000000..909ab78df --- /dev/null +++ b/src/api/java/forestry/api/genetics/IEffectData.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +/** + * Container to hold some temporary data for bee, tree and butterfly effects. + * + * @author SirSengir + */ +public interface IEffectData extends INBTTagable { + void setInteger(int index, int val); + + void setFloat(int index, float val); + + void setBoolean(int index, boolean val); + + int getInteger(int index); + + float getFloat(int index); + + boolean getBoolean(int index); +} diff --git a/src/api/java/forestry/api/genetics/IFlowerProvider.java b/src/api/java/forestry/api/genetics/IFlowerProvider.java new file mode 100755 index 000000000..b7cbbed31 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IFlowerProvider.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IFlowerProvider { + /** + * @param world + * @param individual + * @param x + * @param y + * @param z + * @return True if the block at the passed coordinates is a valid flower for the species. + */ + boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z); + + boolean isAcceptedPollinatable(World world, IPollinatable pollinatable); + + /** + * @param world + * @param individual + * @param x + * @param y + * @param z + * @return True if a flower was planted. + */ + boolean growFlower(World world, IIndividual individual, int x, int y, int z); + + /** + * @return Short, human-readable identifier used in the beealyzer. + */ + String getDescription(); + + /** + * Allows the flower provider to affect the produce at the given location. + * @param world + * @param individual + * @param x + * @param y + * @param z + * @param products + * @return Array of itemstacks being the (modified or unmodified) produce. + */ + ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products); + + /** + * @return Array of itemstacks representing valid flowers for the flower provider. The first in the array is for use as an icon Return null or an empty + * array if the flower does not have an itemstack + */ + ItemStack[] getItemStacks(); +} diff --git a/src/api/java/forestry/api/genetics/IFruitBearer.java b/src/api/java/forestry/api/genetics/IFruitBearer.java new file mode 100755 index 000000000..5316f9ebc --- /dev/null +++ b/src/api/java/forestry/api/genetics/IFruitBearer.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +/** + * Can be implemented by tile entities which can bear fruit. + * + * @author SirSengir + */ +public interface IFruitBearer { + + /** + * @return true if the actual tile can bear fruits. + */ + boolean hasFruit(); + + /** + * @return Family of the potential fruits on this tile. + */ + IFruitFamily getFruitFamily(); + + /** + * Picks the fruits of this tile, resetting it to unripe fruits. + * + * @param tool + * Tool used in picking the fruits. May be null. + * @return Picked fruits. + */ + Collection pickFruit(ItemStack tool); + + /** + * @return float indicating the ripeness of the fruit with >= 1.0f indicating full ripeness. + */ + float getRipeness(); + + /** + * Increases the ripeness of the fruit. + * + * @param add + * Float to add to the ripeness. Will truncate to valid values. + */ + void addRipeness(float add); +} diff --git a/src/api/java/forestry/api/genetics/IFruitFamily.java b/src/api/java/forestry/api/genetics/IFruitFamily.java new file mode 100755 index 000000000..d48a4d8a1 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IFruitFamily.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +public interface IFruitFamily { + + /** + * @return Unique String identifier. + */ + String getUID(); + + /** + * @return Localized family name for user display. + */ + String getName(); + + /** + * A scientific-y name for this fruit family + * + * @return flavour text (may be null) + */ + String getScientific(); + + /** + * @return Localized description of this fruit family. (May be null.) + */ + String getDescription(); + +} diff --git a/src/api/java/forestry/api/genetics/IGenome.java b/src/api/java/forestry/api/genetics/IGenome.java new file mode 100755 index 000000000..449df4896 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IGenome.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +/** + * Holds the {@link IChromosome}s which comprise the traits of a given individual. + * + * Only the default implementation is supported. + */ +public interface IGenome extends INBTTagable { + + IAlleleSpecies getPrimary(); + + IAlleleSpecies getSecondary(); + + IChromosome[] getChromosomes(); + + IAllele getActiveAllele(int chromosome); + + IAllele getInactiveAllele(int chromosome); + + boolean isGeneticEqual(IGenome other); + + ISpeciesRoot getSpeciesRoot(); +} diff --git a/src/api/java/forestry/api/genetics/IHousing.java b/src/api/java/forestry/api/genetics/IHousing.java new file mode 100755 index 000000000..127354826 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IHousing.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +/** + * Any housing, hatchery or nest which is a fixed location in the world. + */ +public interface IHousing { + + /** + * @return String containing the login of this housing's owner. + */ + String getOwnerName(); + + World getWorld(); + + int getXCoord(); + + int getYCoord(); + + int getZCoord(); + + int getBiomeId(); + + EnumTemperature getTemperature(); + + EnumHumidity getHumidity(); + + void setErrorState(int state); + + int getErrorOrdinal(); + + /** + * Adds products to the housing's inventory. + * + * @param product + * ItemStack with the product to add. + * @param all + * @return Boolean indicating success or failure. + */ + boolean addProduct(ItemStack product, boolean all); + +} diff --git a/src/api/java/forestry/api/genetics/IIndividual.java b/src/api/java/forestry/api/genetics/IIndividual.java new file mode 100755 index 000000000..c5605120e --- /dev/null +++ b/src/api/java/forestry/api/genetics/IIndividual.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.List; + +import forestry.api.core.INBTTagable; + +/** + * An actual individual with genetic information. + * + * Only the default implementation is supported. + */ +public interface IIndividual extends INBTTagable { + + String getIdent(); + + String getDisplayName(); + + void addTooltip(List list); + + /** + * Call to mark the IIndividual as analyzed. + * @return true if the IIndividual has not been analyzed previously. + */ + boolean analyze(); + + boolean isAnalyzed(); + + boolean hasEffect(); + + boolean isSecret(); + + IGenome getGenome(); + + /** + * Check whether the genetic makeup of two IIndividuals is identical. Ignores additional data like generations, irregular mating, etc.. + * @param other + * @return true if the given other IIndividual has the amount of chromosomes and their alleles are identical. + */ + boolean isGeneticEqual(IIndividual other); + + /** + * @return A deep copy of this individual. + */ + IIndividual copy(); + + /** + * @param chromosomeOrdinal Ordinal of the chromosome to check. + * @return true if both primary and secondary allele on the given chromosome match. + */ + boolean isPureBred(int chromosomeOrdinal); + +} diff --git a/src/api/java/forestry/api/genetics/IIndividualLiving.java b/src/api/java/forestry/api/genetics/IIndividualLiving.java new file mode 100755 index 000000000..67ce0a975 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IIndividualLiving.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.world.World; + +public interface IIndividualLiving extends IIndividual { + + /** + * @return Genetic information of the mate, null if unmated. + */ + IGenome getMate(); + + /** + * @return Current health of the individual. + */ + int getHealth(); + + /** + * @return Maximum health of the individual. + */ + int getMaxHealth(); + + /** + * Age the individual. + * @param world + * @param ageModifier + */ + void age(World world, float ageModifier); + + /** + * Mate with the given individual. + * @param individual the {@link IIndividual} to mate this one with. + */ + void mate(IIndividual individual); + + /** + * @return true if the individual is among the living. + */ + boolean isAlive(); + +} diff --git a/src/api/java/forestry/api/genetics/ILegacyHandler.java b/src/api/java/forestry/api/genetics/ILegacyHandler.java new file mode 100755 index 000000000..24938e48b --- /dev/null +++ b/src/api/java/forestry/api/genetics/ILegacyHandler.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * AlleleManager.alleleRegistry can be cast to this type. + */ +public interface ILegacyHandler { + void registerLegacyMapping(int id, String uid); + + IAllele getFromLegacyMap(int id); +} diff --git a/src/api/java/forestry/api/genetics/IMutation.java b/src/api/java/forestry/api/genetics/IMutation.java new file mode 100755 index 000000000..8c15ca589 --- /dev/null +++ b/src/api/java/forestry/api/genetics/IMutation.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Collection; + +/** + * Individuals can be seeded either as hive drops or as mutation results. + * + * {@link IAlleleRegistry} manages these. + * + * @author SirSengir + */ +public interface IMutation { + + /** + * @return {@link ISpeciesRoot} this mutation is associated with. + */ + ISpeciesRoot getRoot(); + + /** + * @return first of the alleles implementing IAlleleSpecies required for this mutation. + */ + IAllele getAllele0(); + + /** + * @return second of the alleles implementing IAlleleSpecies required for this mutation. + */ + IAllele getAllele1(); + + /** + * @return Array of {@link IAllele} representing the full default genome of the mutated side. + * + * Make sure to return a proper array for the species class. Returning an allele of the wrong type will cause cast errors on runtime. + */ + IAllele[] getTemplate(); + + /** + * @return Unmodified base chance for mutation to fire. + */ + float getBaseChance(); + + /** + * @return Collection of localized, human-readable strings describing special mutation conditions, if any. + */ + Collection getSpecialConditions(); + + /** + * @param allele + * @return true if the passed allele is one of the alleles participating in this mutation. + */ + boolean isPartner(IAllele allele); + + /** + * @param allele + * @return the other allele which was not passed as argument. + */ + IAllele getPartner(IAllele allele); + + /** + * @return true if the mutation should not be displayed in the beealyzer. + */ + boolean isSecret(); + +} diff --git a/src/api/java/forestry/api/genetics/IPollinatable.java b/src/api/java/forestry/api/genetics/IPollinatable.java new file mode 100755 index 000000000..5b0694d7d --- /dev/null +++ b/src/api/java/forestry/api/genetics/IPollinatable.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +/** + * Can be implemented by tile entities, if they wish to be pollinatable. + * + * @author SirSengir + */ +public interface IPollinatable { + + /** + * @return plant types this pollinatable is classified as. (Can be used by bees to determine whether to interact or not. + */ + EnumSet getPlantType(); + + /** + * @return IIndividual containing the genetic information of this IPollinatable + */ + IIndividual getPollen(); + + /** + * Checks whether this {@link IPollinatable} can mate with the given pollen. + * + * Must be the one to check genetic equivalency. + * + * @param pollen + * IIndividual representing the pollen. + * @return true if mating is possible, false otherwise. + */ + boolean canMateWith(IIndividual pollen); + + /** + * Pollinates this entity. + * + * @param pollen + * IIndividual representing the pollen. + */ + void mateWith(IIndividual pollen); + +} diff --git a/src/api/java/forestry/api/genetics/ISpeciesRoot.java b/src/api/java/forestry/api/genetics/ISpeciesRoot.java new file mode 100755 index 000000000..66c20a3bc --- /dev/null +++ b/src/api/java/forestry/api/genetics/ISpeciesRoot.java @@ -0,0 +1,165 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Random; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/** + * Describes a class of species (i.e. bees, trees, butterflies), provides helper functions and access to common functionality. + */ +public interface ISpeciesRoot { + + /** + * @return A unique identifier for the species class. Should consist of "root" + a common name for the species class in camel-case, i.e. "rootBees", "rootTrees", "rootButterflies". + */ + String getUID(); + + /** + * @return Class of the sub-interface inheriting from {@link IIndividual}. + */ + Class getMemberClass(); + + /** + * @return Integer denoting the number of (counted) species of this type in the world. + */ + int getSpeciesCount(); + + /** + * Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class. + * @param stack itemstack to check. + * @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise. + */ + boolean isMember(ItemStack stack); + + /** + * Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class and matches the given type. + * @param stack itemstack to check. + * @param type Integer denoting the type needed to match. (i.e. butterfly vs. butterfly serum; bee queens, princesses, drones; etc.) + * @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise. + */ + boolean isMember(ItemStack stack, int type); + + /** + * Used to check whether the given {@link IIndividual} is member of this class. + * @param individual {@link IIndividual} to check. + * @return true if the individual is member of this class, false otherwise. + */ + boolean isMember(IIndividual individual); + + IIndividual getMember(ItemStack stack); + + IIndividual getMember(NBTTagCompound compound); + + ItemStack getMemberStack(IIndividual individual, int type); + + /* BREEDING TRACKER */ + IBreedingTracker getBreedingTracker(World world, String player); + + /* GENOME MANIPULATION */ + IIndividual templateAsIndividual(IAllele[] template); + + IIndividual templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); + + IChromosome[] templateAsChromosomes(IAllele[] template); + + IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive); + + IGenome templateAsGenome(IAllele[] template); + + IGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /* TEMPLATES */ + /** + * Registers a bee template using the UID of the first allele as identifier. + * + * @param template + */ + void registerTemplate(IAllele[] template); + + /** + * Registers a bee template using the passed identifier. + * + * @param template + */ + void registerTemplate(String identifier, IAllele[] template); + + /** + * Retrieves a registered template using the passed identifier. + * + * @param identifier + * @return Array of {@link IAllele} representing a genome. + */ + IAllele[] getTemplate(String identifier); + + /** + * @return Default individual template for use when stuff breaks. + */ + IAllele[] getDefaultTemplate(); + + /** + * @param rand Random to use. + * @return A random template from the pool of registered species templates. + */ + IAllele[] getRandomTemplate(Random rand); + + Map getGenomeTemplates(); + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + /** + * Use to register mutations. + * + * @param mutation + */ + void registerMutation(IMutation mutation); + + /** + * @return All registered mutations. + */ + Collection getMutations(boolean shuffle); + + /** + * @param other Allele to match mutations against. + * @return All registered mutations the given allele is part of. + */ + Collection getCombinations(IAllele other); + + /** + * @param result {@link IAllele} to search for. + * @return All registered mutations the given {@link IAllele} is the result of. + */ + Collection getPaths(IAllele result, int chromosomeOrdinal); + + /* RESEARCH */ + /** + * @return List of generic catalysts which should be accepted for research by species of this class. + */ + Map getResearchCatalysts(); + + /** + * Sets an item stack as a valid (generic) research catalyst for this class. + * @param itemstack ItemStack to set as suitable. + * @param suitability Float between 0 and 1 to indicate suitability. + */ + void setResearchSuitability(ItemStack itemstack, float suitability); + + /** + * @return Array of {@link IChromosomeType} which are in this species genome + */ + IChromosomeType[] getKaryotype(); + + /** + * @return {@link IChromosomeType} which is the "key" for this species class, usually the species chromosome. + */ + IChromosomeType getKaryotypeKey(); +} diff --git a/src/api/java/forestry/api/genetics/package-info.java b/src/api/java/forestry/api/genetics/package-info.java new file mode 100755 index 000000000..a442ecb81 --- /dev/null +++ b/src/api/java/forestry/api/genetics/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|genetics") +package forestry.api.genetics; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/lepidopterology/EnumButterflyChromosome.java b/src/api/java/forestry/api/lepidopterology/EnumButterflyChromosome.java new file mode 100755 index 000000000..9f89f7f85 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/EnumButterflyChromosome.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleArea; +import forestry.api.genetics.IAlleleBoolean; +import forestry.api.genetics.IAlleleFloat; +import forestry.api.genetics.IAlleleFlowers; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAlleleTolerance; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.ISpeciesRoot; + +public enum EnumButterflyChromosome implements IChromosomeType { + /** + * Species of the bee. Alleles here must implement {@link IAlleleButterflySpecies}. + */ + SPECIES(IAlleleButterflySpecies.class), + /** + * Physical size. + */ + SIZE(IAlleleFloat.class), + /** + * Flight speed. + */ + SPEED(IAlleleFloat.class), + /** + * How long the butterfly can last without access to matching pollinatables. + */ + LIFESPAN(IAlleleInteger.class), + /** + * Species with a higher metabolism have a higher appetite and may cause more damage to their environment. + */ + METABOLISM(IAlleleInteger.class), + /** + * Determines likelyhood of caterpillars and length of caterpillar/pupation phase. Also: Number of max caterpillars after mating? + */ + FERTILITY(IAlleleInteger.class), + /** + * Not sure yet. + */ + TEMPERATURE_TOLERANCE(IAlleleTolerance.class), + /** + * Not sure yet. + */ + HUMIDITY_TOLERANCE(IAlleleTolerance.class), + /** + * Only nocturnal butterflys/moths will fly at night. Allows daylight activity for naturally nocturnal species. + */ + NOCTURNAL(IAlleleBoolean.class), + /** + * Only tolerant flyers will fly in the rain. + */ + TOLERANT_FLYER(IAlleleBoolean.class), + /** + * Fire resistance. + */ + FIRE_RESIST(IAlleleBoolean.class), + /** + * Required flowers/leaves. + */ + FLOWER_PROVIDER(IAlleleFlowers.class), + /** + * Extra effect to surroundings. (?) + */ + EFFECT(IAlleleButterflyEffect.class), + /** + * Not used yet + */ + TERRITORY(IAlleleArea.class), + ; + + Class clss; + + EnumButterflyChromosome(Class clss) { + this.clss = clss; + } + + @Override + public Class getAlleleClass() { + return clss; + } + + @Override + public String getName() { + return this.toString().toLowerCase(); + } + + @Override + public ISpeciesRoot getSpeciesRoot() { + return AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies"); + } +} diff --git a/src/api/java/forestry/api/lepidopterology/EnumFlutterType.java b/src/api/java/forestry/api/lepidopterology/EnumFlutterType.java new file mode 100755 index 000000000..f197d7b72 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/EnumFlutterType.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +public enum EnumFlutterType { + BUTTERFLY, + SERUM, + CATERPILLAR, + NONE; + + public static final EnumFlutterType[] VALUES = values(); +} diff --git a/src/api/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java b/src/api/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java new file mode 100755 index 000000000..6457dbe89 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IAlleleEffect; +import forestry.api.genetics.IEffectData; + +public interface IAlleleButterflyEffect extends IAlleleEffect { + + /** + * Used by butterflies to trigger effects in the world. + * @param butterfly {@link IEntityButterfly} + * @param storedData + * @return {@link forestry.api.genetics.IEffectData} for the next cycle. + */ + IEffectData doEffect(IEntityButterfly butterfly, IEffectData storedData); + +} diff --git a/src/api/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java b/src/api/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java new file mode 100755 index 000000000..c1536118b --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import java.util.EnumSet; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.BiomeDictionary; + +import forestry.api.genetics.IAlleleSpecies; + +public interface IAlleleButterflySpecies extends IAlleleSpecies { + + /** + * @return the IBeeRoot + */ + IButterflyRoot getRoot(); + + /** + * @return Path of the texture to use for entity rendering. + */ + String getEntityTexture(); + + /** + * Allows butterflies to restrict random spawns beyond the restrictions set by getTemperature() and getHumidity(). + * + * @return EnumSet of biome tags this butterfly species can be spawned in. + */ + EnumSet getSpawnBiomes(); + + /** + * @return true if a prospective spawn biome must not match a biome tag outside of getSpawnBiomes. + */ + boolean strictSpawnMatch(); + + /** + * @return Float between 0 and 1 representing the rarity of the species, will affect spawn rate. + */ + float getRarity(); + + /** + * @return Float representing the distance below which this butterfly will take flight if it detects a player which is not sneaking. + */ + float getFlightDistance(); + + /** + * @return true if this species is only active at night. + */ + boolean isNocturnal(); + + Map getButterflyLoot(); + + Map getCaterpillarLoot(); +} diff --git a/src/api/java/forestry/api/lepidopterology/IButterfly.java b/src/api/java/forestry/api/lepidopterology/IButterfly.java new file mode 100755 index 000000000..c30132475 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IButterfly.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import forestry.api.genetics.IIndividualLiving; + +public interface IButterfly extends IIndividualLiving { + + IButterflyGenome getGenome(); + + /** + * @return Genetic information of the mate, null if unmated. + */ + IButterflyGenome getMate(); + + /** + * @return Physical size of the butterfly. + */ + float getSize(); + + /** + * @param world + * @param x + * @param y + * @param z + * @return true if the butterfly can naturally spawn at the given location at this time. (Used to auto-spawn butterflies from tree leaves.) + */ + boolean canSpawn(World world, double x, double y, double z); + + /** + * @param world + * @param x + * @param y + * @param z + * @return true if the butterfly can take flight at the given location at this time. (Used to auto-spawn butterflies from dropped items.) + */ + boolean canTakeFlight(World world, double x, double y, double z); + + /** + * @param world + * @param x + * @param y + * @param z + * @return true if the environment (temperature, humidity) is valid for the butterfly at the given location. + */ + boolean isAcceptedEnvironment(World world, double x, double y, double z); + + IButterfly spawnCaterpillar(IButterflyNursery nursery); + + /** + * @param entity + * @param playerKill Whether or not the butterfly was killed by a player. + * @param lootLevel Loot level according to the weapon used to kill the butterfly. + * @return Array of itemstacks to drop on death of the given entity. + */ + ItemStack[] getLootDrop(IEntityButterfly entity, boolean playerKill, int lootLevel); + + /** + * @param nursery + * @param playerKill Whether or not the nursery was broken by a player. + * @param lootLevel Fortune level. + * @return Array of itemstacks to drop on breaking of the nursery. + */ + ItemStack[] getCaterpillarDrop(IButterflyNursery nursery, boolean playerKill, int lootLevel); + + /** + * Create an exact copy of this butterfly. + */ + IButterfly copy(); + +} diff --git a/src/api/java/forestry/api/lepidopterology/IButterflyGenome.java b/src/api/java/forestry/api/lepidopterology/IButterflyGenome.java new file mode 100755 index 000000000..938166005 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IButterflyGenome.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IFlowerProvider; +import forestry.api.genetics.IGenome; + +public interface IButterflyGenome extends IGenome { + + IAlleleButterflySpecies getPrimary(); + + IAlleleButterflySpecies getSecondary(); + + float getSize(); + + int getLifespan(); + + int getMetabolism(); + + int getFertility(); + + float getSpeed(); + + EnumTolerance getToleranceTemp(); + + EnumTolerance getToleranceHumid(); + + boolean getNocturnal(); + + boolean getTolerantFlyer(); + + boolean getFireResist(); + + IFlowerProvider getFlowerProvider(); + + IAlleleButterflyEffect getEffect(); + +} diff --git a/src/api/java/forestry/api/lepidopterology/IButterflyMutation.java b/src/api/java/forestry/api/lepidopterology/IButterflyMutation.java new file mode 100755 index 000000000..027e96eb2 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IButterflyMutation.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IMutation; + +public interface IButterflyMutation extends IMutation { + float getChance(IButterflyNursery housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); +} diff --git a/src/api/java/forestry/api/lepidopterology/IButterflyNursery.java b/src/api/java/forestry/api/lepidopterology/IButterflyNursery.java new file mode 100755 index 000000000..56e42f2ec --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IButterflyNursery.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IHousing; +import forestry.api.genetics.IIndividual; + +public interface IButterflyNursery extends IHousing { + + IButterfly getCaterpillar(); + + IIndividual getNanny(); + + void setCaterpillar(IButterfly butterfly); + + boolean canNurse(IButterfly butterfly); + +} diff --git a/src/api/java/forestry/api/lepidopterology/IButterflyRoot.java b/src/api/java/forestry/api/lepidopterology/IButterflyRoot.java new file mode 100755 index 000000000..b41a7b174 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IButterflyRoot.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.ISpeciesRoot; + +public interface IButterflyRoot extends ISpeciesRoot { + + boolean isMember(ItemStack stack); + + IButterfly getMember(ItemStack stack); + + IButterfly getMember(NBTTagCompound compound); + + ItemStack getMemberStack(IIndividual butterfly, int type); + + /* GENOME CONVERSION */ + IButterfly templateAsIndividual(IAllele[] template); + + IButterfly templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); + + IButterflyGenome templateAsGenome(IAllele[] template); + + IButterflyGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /* BUTTERFLY SPECIFIC */ + ILepidopteristTracker getBreedingTracker(World world, String player); + + /** + * Spawns the given butterfly in the world. + * @param butterfly + * @return butterfly entity on success, null otherwise. + */ + EntityLiving spawnButterflyInWorld(World world, IButterfly butterfly, double x, double y, double z); + + /** + * @return true if passed item is mated. + */ + boolean isMated(ItemStack stack); + + /* TEMPLATES */ + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + Collection getMutations(boolean shuffle); + +} diff --git a/src/api/java/forestry/api/lepidopterology/IEntityButterfly.java b/src/api/java/forestry/api/lepidopterology/IEntityButterfly.java new file mode 100755 index 000000000..963c72103 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/IEntityButterfly.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.passive.IAnimals; + +import forestry.api.genetics.IIndividual; + +public interface IEntityButterfly extends IAnimals { + + void changeExhaustion(int change); + + int getExhaustion(); + + IButterfly getButterfly(); + + /** + * @return The entity as an EntityCreature to save casting. + */ + EntityCreature getEntity(); + + IIndividual getPollen(); + + void setPollen(IIndividual pollen); +} diff --git a/src/api/java/forestry/api/lepidopterology/ILepidopteristTracker.java b/src/api/java/forestry/api/lepidopterology/ILepidopteristTracker.java new file mode 100755 index 000000000..79926975f --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/ILepidopteristTracker.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IBreedingTracker; + +public interface ILepidopteristTracker extends IBreedingTracker { + + void registerCatch(IButterfly butterfly); + +} diff --git a/src/api/java/forestry/api/lepidopterology/package-info.java b/src/api/java/forestry/api/lepidopterology/package-info.java new file mode 100755 index 000000000..dc85017b3 --- /dev/null +++ b/src/api/java/forestry/api/lepidopterology/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|lepidopterology") +package forestry.api.lepidopterology; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/mail/EnumPostage.java b/src/api/java/forestry/api/mail/EnumPostage.java new file mode 100755 index 000000000..772114fb0 --- /dev/null +++ b/src/api/java/forestry/api/mail/EnumPostage.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +public enum EnumPostage { + P_0(0), P_1(1), P_2(2), P_5(5), P_10(10), P_20(20), P_50(50), P_100(100), P_200(200); + + private final int value; + + private EnumPostage(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/src/api/java/forestry/api/mail/ILetter.java b/src/api/java/forestry/api/mail/ILetter.java new file mode 100755 index 000000000..47c0cfa11 --- /dev/null +++ b/src/api/java/forestry/api/mail/ILetter.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.util.List; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import forestry.api.core.INBTTagable; + +public interface ILetter extends IInventory, INBTTagable { + + ItemStack[] getPostage(); + + void setProcessed(boolean flag); + + boolean isProcessed(); + + boolean isMailable(); + + void setSender(MailAddress address); + + MailAddress getSender(); + + boolean hasRecipient(); + + void setRecipient(MailAddress address); + + MailAddress[] getRecipients(); + + String getRecipientString(); + + void setText(String text); + + String getText(); + + @SuppressWarnings("rawtypes") + void addTooltip(List list); + + boolean isPostPaid(); + + int requiredPostage(); + + void invalidatePostage(); + + ItemStack[] getAttachments(); + + void addAttachment(ItemStack itemstack); + + void addAttachments(ItemStack[] itemstacks); + + int countAttachments(); + + void addStamps(ItemStack stamps); + +} diff --git a/src/api/java/forestry/api/mail/ILetterHandler.java b/src/api/java/forestry/api/mail/ILetterHandler.java new file mode 100755 index 000000000..dd6ddf6c4 --- /dev/null +++ b/src/api/java/forestry/api/mail/ILetterHandler.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface ILetterHandler { + IPostalState handleLetter(World world, String recipient, ItemStack letterStack, boolean doLodge); +} diff --git a/src/api/java/forestry/api/mail/IPostOffice.java b/src/api/java/forestry/api/mail/IPostOffice.java new file mode 100755 index 000000000..7975ce592 --- /dev/null +++ b/src/api/java/forestry/api/mail/IPostOffice.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IPostOffice { + + void collectPostage(ItemStack[] stamps); + + IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge); + + ItemStack getAnyStamp(int max); + + ItemStack getAnyStamp(EnumPostage postage, int max); + + ItemStack getAnyStamp(EnumPostage[] postages, int max); + + void registerTradeStation(ITradeStation trade); + + void deregisterTradeStation(ITradeStation trade); + + Map getActiveTradeStations(World world); +} diff --git a/src/api/java/forestry/api/mail/IPostRegistry.java b/src/api/java/forestry/api/mail/IPostRegistry.java new file mode 100755 index 000000000..a4e5b1f42 --- /dev/null +++ b/src/api/java/forestry/api/mail/IPostRegistry.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IPostRegistry { + + /* POST OFFICE */ + IPostOffice getPostOffice(World world); + + /* LETTERS */ + boolean isLetter(ItemStack itemstack); + + ILetter createLetter(MailAddress sender, MailAddress recipient); + + ILetter getLetter(ItemStack itemstack); + + ItemStack createLetterStack(ILetter letter); + + /* CARRIERS */ + /** + * Registers a new {@link IPostalCarrier}. See {@link IPostalCarrier} for details. + * @param carrier {@link IPostalCarrier} to register. + */ + void registerCarrier(IPostalCarrier carrier); + + IPostalCarrier getCarrier(String uid); + + Map getRegisteredCarriers(); + + /* TRADE STATIONS */ + void deleteTradeStation(World world, String moniker); + + ITradeStation getOrCreateTradeStation(World world, String owner, String moniker); + + ITradeStation getTradeStation(World world, String moniker); + + boolean isAvailableTradeMoniker(World world, String moniker); + + boolean isValidTradeMoniker(World world, String moniker); + + /* PO BOXES */ + boolean isValidPOBox(World world, String username); + +} diff --git a/src/api/java/forestry/api/mail/IPostalCarrier.java b/src/api/java/forestry/api/mail/IPostalCarrier.java new file mode 100755 index 000000000..3440f3511 --- /dev/null +++ b/src/api/java/forestry/api/mail/IPostalCarrier.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Postal Carriers are systems which can be hooked into Forestry's mail system to handle mail delivery. + * + * The two available carriers in vanilla Forestry are + * "player" - Delivers mail to individual players. + * "trader" - Handles mail addressed to trade stations. + */ +public interface IPostalCarrier { + + /** + * @return A lower-case identifier without spaces. + */ + String getUID(); + + /** + * @return A human-readable name for this carrier. + */ + String getName(); + + @SideOnly(Side.CLIENT) + IIcon getIcon(); + + /** + * Handle delivery of a letter addressed to this carrier. + * @param world The world the {@link IPostOffice} handles. + * @param office {link @IPostOffice} which received this letter and handed it to the carrier. + * @param recipient An identifier for the recipient as typed by the player into the address field. + * @param letterstack ItemStack representing the letter. See {@link IPostRegistry} for helper functions to validate and extract it. + * @param doDeliver Whether or not the letter is supposed to actually be delivered or if delivery is only to be simulated. + * @return {link IPostalState} holding information on success or failure for delivery. + */ + IPostalState deliverLetter(World world, IPostOffice office, String recipient, ItemStack letterstack, boolean doDeliver); + +} diff --git a/src/api/java/forestry/api/mail/IPostalState.java b/src/api/java/forestry/api/mail/IPostalState.java new file mode 100755 index 000000000..bc843621a --- /dev/null +++ b/src/api/java/forestry/api/mail/IPostalState.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +public interface IPostalState { + boolean isOk(); + + String getIdentifier(); + + int ordinal(); +} diff --git a/src/api/java/forestry/api/mail/IStamps.java b/src/api/java/forestry/api/mail/IStamps.java new file mode 100755 index 000000000..4332a811c --- /dev/null +++ b/src/api/java/forestry/api/mail/IStamps.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.item.ItemStack; + +public interface IStamps { + + EnumPostage getPostage(ItemStack itemstack); + +} diff --git a/src/api/java/forestry/api/mail/ITradeStation.java b/src/api/java/forestry/api/mail/ITradeStation.java new file mode 100755 index 000000000..edbfb9aff --- /dev/null +++ b/src/api/java/forestry/api/mail/ITradeStation.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.inventory.IInventory; + +public interface ITradeStation extends ILetterHandler, IInventory { + + String getMoniker(); + + boolean isValid(); + + void invalidate(); + + void setVirtual(boolean isVirtual); + + boolean isVirtual(); + + TradeStationInfo getTradeInfo(); + +} diff --git a/src/api/java/forestry/api/mail/MailAddress.java b/src/api/java/forestry/api/mail/MailAddress.java new file mode 100755 index 000000000..80fae2073 --- /dev/null +++ b/src/api/java/forestry/api/mail/MailAddress.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.nbt.NBTTagCompound; + +import forestry.api.core.INBTTagable; + +public class MailAddress implements INBTTagable { + private String type; + private String identifier; + + private MailAddress() { + } + + public MailAddress(String identifier) { + this(identifier, "player"); + } + + public MailAddress(String identifier, String type) { + this.identifier = identifier; + this.type = type; + } + + public String getType() { + return type; + } + + public String getIdentifier() { + return identifier; + } + + public boolean isPlayer() { + return "player".equals(type); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + if(nbttagcompound.hasKey("TP")) + type = nbttagcompound.getString("TP"); + else + type = nbttagcompound.getShort("TYP") == 0 ? "player" : "trader"; + identifier = nbttagcompound.getString("ID"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setString("TP", type); + nbttagcompound.setString("ID", identifier); + } + + public static MailAddress loadFromNBT(NBTTagCompound nbttagcompound) { + MailAddress address = new MailAddress(); + address.readFromNBT(nbttagcompound); + return address; + } +} diff --git a/src/api/java/forestry/api/mail/PostManager.java b/src/api/java/forestry/api/mail/PostManager.java new file mode 100755 index 000000000..c3f0e45bb --- /dev/null +++ b/src/api/java/forestry/api/mail/PostManager.java @@ -0,0 +1,11 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + + +public class PostManager { + public static IPostRegistry postRegistry; +} diff --git a/src/api/java/forestry/api/mail/TradeStationInfo.java b/src/api/java/forestry/api/mail/TradeStationInfo.java new file mode 100755 index 000000000..06da6e5ed --- /dev/null +++ b/src/api/java/forestry/api/mail/TradeStationInfo.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.item.ItemStack; + +public class TradeStationInfo { + public final String moniker; + public final String owner; + public final ItemStack tradegood; + public final ItemStack[] required; + public final IPostalState state; + + public TradeStationInfo(String moniker, String owner, ItemStack tradegood, ItemStack[] required, IPostalState state) { + this.moniker = moniker; + this.owner = owner; + this.tradegood = tradegood; + this.required = required; + this.state = state; + } +} diff --git a/src/api/java/forestry/api/mail/package-info.java b/src/api/java/forestry/api/mail/package-info.java new file mode 100755 index 000000000..7f66748ae --- /dev/null +++ b/src/api/java/forestry/api/mail/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|mail") +package forestry.api.mail; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/package-info.java b/src/api/java/forestry/api/package-info.java new file mode 100755 index 000000000..82893dc8b --- /dev/null +++ b/src/api/java/forestry/api/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="Forestry", provides="ForestryAPI|core") +package forestry.api; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/recipes/IBottlerManager.java b/src/api/java/forestry/api/recipes/IBottlerManager.java new file mode 100755 index 000000000..e21a1f5bd --- /dev/null +++ b/src/api/java/forestry/api/recipes/IBottlerManager.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the bottler. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * Note that this is untested with anything other than biofuel->fuelcan conversion. + * + * @author SirSengir + */ +public interface IBottlerManager extends ICraftingProvider { + /** + * Add a recipe to the bottler. + * The bottler will populate its recipe list dynamically from the LiquidContainerRegistry. Recipes added explicitely will take precedence. + * + * @param cyclesPerUnit + * Amount of work cycles required to run through the conversion once. + * @param input + * LiquidStack representing the input liquid. + * @param can + * ItemStack representing the cans, capsules and/or cells required + * @param bottled + * ItemStack representing the finished product + */ + @Deprecated + public void addRecipe(int cyclesPerUnit, FluidStack input, ItemStack can, ItemStack bottled); +} diff --git a/src/api/java/forestry/api/recipes/ICarpenterManager.java b/src/api/java/forestry/api/recipes/ICarpenterManager.java new file mode 100755 index 000000000..6dd880ab5 --- /dev/null +++ b/src/api/java/forestry/api/recipes/ICarpenterManager.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapedRecipes; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the carpenter. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * Only shaped recipes can be added currently. + * + * @author SirSengir + */ +public interface ICarpenterManager extends ICraftingProvider { + /** + * Add a shaped recipe to the carpenter. + * + * @param box + * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null. + * @param product + * Crafting result. + * @param materials + * Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same. + */ + public void addRecipe(ItemStack box, ItemStack product, Object materials[]); + + /** + * Add a shaped recipe to the carpenter. + * + * @param packagingTime + * Number of work cycles required to craft the recipe once. + * @param box + * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null. + * @param product + * Crafting result. + * @param materials + * Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same. + */ + public void addRecipe(int packagingTime, ItemStack box, ItemStack product, Object materials[]); + + /** + * Add a shaped recipe to the carpenter. + * + * @param packagingTime + * Number of work cycles required to craft the recipe once. + * @param liquid + * Liquid required in carpenter's tank. + * @param box + * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null. + * @param product + * Crafting result. + * @param materials + * Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same. + */ + public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object materials[]); + + public void addCrating(String toCrate, ItemStack unpack, ItemStack crated); + + public void addCrating(ItemStack itemStack); +} diff --git a/src/api/java/forestry/api/recipes/ICentrifugeManager.java b/src/api/java/forestry/api/recipes/ICentrifugeManager.java new file mode 100755 index 000000000..910bd32cf --- /dev/null +++ b/src/api/java/forestry/api/recipes/ICentrifugeManager.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +/** + * Provides an interface to the recipe manager of the centrifuge. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface ICentrifugeManager extends ICraftingProvider { + + /** + * Add a recipe to the centrifuge + * + * @param timePerItem + * Time to centrifugate one item of the given type + * @param resource + * ItemStack containing information on item id and damage. Stack size will be ignored. + * @param products + * HashMap specifying the possible products and the chances of them resulting from centrifugation. + */ + public void addRecipe(int timePerItem, ItemStack resource, HashMap products); + + /** + * Add a recipe to the centrifuge + * + * @param timePerItem + * Time to centrifugate one item of the given type + * @param resource + * ItemStack containing information on item id and damage. Stack size will be ignored. + * @param produce + * Array of ItemStacks that can be the result of this recipe. + * @param chances + * Array of integers corresponding and matching to produce providing the chance (0-100) for the ItemStack at the given index to be + * produced. + */ + public void addRecipe(int timePerItem, ItemStack resource, ItemStack[] produce, int[] chances); + + /** + * Add a recipe to the centrifuge + * + * @param timePerItem + * Time to centrifugate one item of the given type + * @param resource + * ItemStack containing information on item id and damage. Stack size will be ignored. + * @param primary + * Primary product produced by centrifugating one item. Yield 100 %. + * @param secondary + * Secondary product that may be produced when centrifugating the given item. May be null. + * @param chance + * Chance (1 - 100) for centrifugation to yield the secondary product. + */ + public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary, ItemStack secondary, int chance); + + /** + * Add a recipe to the centrifuge + * + * @param timePerItem + * Time to centrifugate one item of the given type + * @param resource + * ItemStack containing information on item id and damage. Stack size will be ignored. + * @param primary + * Primary product produced by centrifugating one item. Yield 100 %. + */ + public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary); + +} diff --git a/src/api/java/forestry/api/recipes/ICraftingProvider.java b/src/api/java/forestry/api/recipes/ICraftingProvider.java new file mode 100755 index 000000000..502dffb48 --- /dev/null +++ b/src/api/java/forestry/api/recipes/ICraftingProvider.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import java.util.Map; + +public interface ICraftingProvider { + /** + * Access to the full list of recipes contained in the crafting provider. + * + * @return List of the given format where the first array represents inputs and the second outputs. Objects can be either ItemStack or LiquidStack. + */ + public Map getRecipes(); +} diff --git a/src/api/java/forestry/api/recipes/IFabricatorManager.java b/src/api/java/forestry/api/recipes/IFabricatorManager.java new file mode 100755 index 000000000..a01f0da48 --- /dev/null +++ b/src/api/java/forestry/api/recipes/IFabricatorManager.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface IFabricatorManager extends ICraftingProvider { + + void addRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] pattern); + + void addSmelting(ItemStack resource, FluidStack molten, int meltingPoint); + +} diff --git a/src/api/java/forestry/api/recipes/IFermenterManager.java b/src/api/java/forestry/api/recipes/IFermenterManager.java new file mode 100755 index 000000000..92c903bb1 --- /dev/null +++ b/src/api/java/forestry/api/recipes/IFermenterManager.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the fermenter. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() + * cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be + * null even if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface IFermenterManager extends ICraftingProvider { + + /** + * Add a recipe to the fermenter + * + * @param resource ItemStack representing the resource. + * @param fermentationValue Value of the given resource, i.e. how much needs + * to be fermented for the output to be deposited into the product tank. + * @param modifier Modifies the amount of liquid output per work cycle. + * (water = 1.0f, honey = 1.5f) + * @param output LiquidStack representing output liquid. Amount is + * determined by fermentationValue*modifier. + * @param liquid LiquidStack representing resource liquid and amount. + * @throws NullPointerException if resource, output or liquid is null + */ + public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output, FluidStack liquid); + + /** + * Add a recipe to the fermenter. Defaults to water as input liquid. + * + * @param resource ItemStack representing the resource. + * @param modifier Modifies the amount of liquid output per work cycle. + * (water = 1.0f, honey = 1.5f) + * @param fermentationValue Value of the given resource, i.e. how much needs + * to be fermented for the output to be deposited into the product tank. + * @param output LiquidStack representing output liquid. Amount is + * determined by fermentationValue*modifier. + * @throws NullPointerException if resource, output or liquid is null + */ + public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output); +} diff --git a/src/api/java/forestry/api/recipes/IGenericCrate.java b/src/api/java/forestry/api/recipes/IGenericCrate.java new file mode 100755 index 000000000..f47571942 --- /dev/null +++ b/src/api/java/forestry/api/recipes/IGenericCrate.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +public interface IGenericCrate { + + void setContained(ItemStack crate, ItemStack contained); + + ItemStack getContained(ItemStack crate); + +} diff --git a/src/api/java/forestry/api/recipes/IMoistenerManager.java b/src/api/java/forestry/api/recipes/IMoistenerManager.java new file mode 100755 index 000000000..711264b41 --- /dev/null +++ b/src/api/java/forestry/api/recipes/IMoistenerManager.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +/** + * Provides an interface to the recipe manager of the moistener. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface IMoistenerManager extends ICraftingProvider { + + /** + * Add a recipe to the moistener + * + * @param resource + * Item required in resource stack. Will be reduced by one per produced item. + * @param product + * Item to produce per resource processed. + * @param timePerItem + * Moistener runs at 1 - 4 time ticks per ingame tick depending on light level. For mycelium this value is currently 5000. + */ + public void addRecipe(ItemStack resource, ItemStack product, int timePerItem); +} diff --git a/src/api/java/forestry/api/recipes/ISqueezerManager.java b/src/api/java/forestry/api/recipes/ISqueezerManager.java new file mode 100755 index 000000000..0a63b7314 --- /dev/null +++ b/src/api/java/forestry/api/recipes/ISqueezerManager.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the suqeezer. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface ISqueezerManager extends ICraftingProvider { + + /** + * Add a recipe to the squeezer. + * + * @param timePerItem + * Number of work cycles required to squeeze one set of resources. + * @param resources + * Array of item stacks representing the required resources for one process. Stack size will be taken into account. + * @param liquid + * {@link FluidStack} representing the output of this recipe. + * @param remnants + * Item stack representing the possible remnants from this recipe. + * @param chance + * Chance remnants will be produced by a single recipe cycle. + */ + public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid, ItemStack remnants, int chance); + + /** + * Add a recipe to the squeezer. + * + * @param timePerItem + * Number of work cycles required to squeeze one set of resources. + * @param resources + * Array of item stacks representing the required resources for one process. Stack size will be taken into account. + * @param liquid + * {@link FluidStack} representing the output of this recipe. + */ + public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid); +} diff --git a/src/api/java/forestry/api/recipes/IStillManager.java b/src/api/java/forestry/api/recipes/IStillManager.java new file mode 100755 index 000000000..47fd42159 --- /dev/null +++ b/src/api/java/forestry/api/recipes/IStillManager.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the still. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * Note that this is untested with anything other than biomass->biofuel conversion. + * + * @author SirSengir + */ +public interface IStillManager extends ICraftingProvider { + /** + * Add a recipe to the still + * + * @param cyclesPerUnit + * Amount of work cycles required to run through the conversion once. + * @param input + * ItemStack representing the input liquid. + * @param output + * ItemStack representing the output liquid + */ + public void addRecipe(int cyclesPerUnit, FluidStack input, FluidStack output); +} diff --git a/src/api/java/forestry/api/recipes/IVariableFermentable.java b/src/api/java/forestry/api/recipes/IVariableFermentable.java new file mode 100755 index 000000000..f0997f531 --- /dev/null +++ b/src/api/java/forestry/api/recipes/IVariableFermentable.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +/** + * Fermenter checks any valid fermentation item for an implementation of this interface. + * This does not supersede adding a proper recipe to the fermenter! + */ +public interface IVariableFermentable { + + /** + * @param itemstack + * @return Float representing the modification to be applied to the matching recipe's biomass output. + */ + float getFermentationModifier(ItemStack itemstack); +} diff --git a/src/api/java/forestry/api/recipes/RecipeManagers.java b/src/api/java/forestry/api/recipes/RecipeManagers.java new file mode 100755 index 000000000..bd39a4ea8 --- /dev/null +++ b/src/api/java/forestry/api/recipes/RecipeManagers.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import java.util.Collection; + +/** + * Contains all available recipe managers for Forestry machines and items. + * + * @author SirSengir + */ +public class RecipeManagers { + + public static Collection craftingProviders; + + /** + * Allows you to add recipes to the bottler. See {@link IBottlerManager} for details. + */ + public static IBottlerManager bottlerManager; + /** + * Allows you to add recipes to the carpenter. See {@link ICarpenterManager} for details. + */ + public static ICarpenterManager carpenterManager; + /** + * Allows you to add recipes to the centrifuge. See {@link ICentrifugeManager} for details. + */ + public static ICentrifugeManager centrifugeManager; + /** + * Allows you to add recipes to the fermenter. See {@link IFermenterManager} for details. + */ + public static IFermenterManager fermenterManager; + /** + * Allows you to add recipes to the moistener. See {@link IMoistenerManager} for details. + */ + public static IMoistenerManager moistenerManager; + /** + * Allows you to add recipes to the squeezer. See {@link ISqueezerManager} for details. + */ + public static ISqueezerManager squeezerManager; + /** + * Allows you to add recipes to the still. See {@link IStillManager} for details. + */ + public static IStillManager stillManager; + + public static IFabricatorManager fabricatorManager; +} diff --git a/src/api/java/forestry/api/recipes/package-info.java b/src/api/java/forestry/api/recipes/package-info.java new file mode 100755 index 000000000..336e36d2c --- /dev/null +++ b/src/api/java/forestry/api/recipes/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|recipes") +package forestry.api.recipes; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/storage/BackpackEvent.java b/src/api/java/forestry/api/storage/BackpackEvent.java new file mode 100755 index 000000000..374277881 --- /dev/null +++ b/src/api/java/forestry/api/storage/BackpackEvent.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; + +import cpw.mods.fml.common.eventhandler.Event; + + +public abstract class BackpackEvent extends Event { + + public final EntityPlayer player; + public final IBackpackDefinition backpackDefinition; + public final IInventory backpackInventory; + + public BackpackEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory) { + this.player = player; + this.backpackDefinition = backpackDefinition; + this.backpackInventory = backpackInventory; + } +} diff --git a/src/api/java/forestry/api/storage/BackpackManager.java b/src/api/java/forestry/api/storage/BackpackManager.java new file mode 100755 index 000000000..8805904d6 --- /dev/null +++ b/src/api/java/forestry/api/storage/BackpackManager.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +public class BackpackManager { + /** + * 0 - Miner's Backpack 1 - Digger's Backpack 2 - Forester's Backpack 3 - Hunter's Backpack 4 - Adventurer's Backpack + * + * Use IMC messages to achieve the same effect! + */ + public static ArrayList[] backpackItems; + + public static IBackpackInterface backpackInterface; + + /** + * Only use this if you know what you are doing. Prefer backpackInterface. + */ + public static HashMap definitions = new HashMap(); +} diff --git a/src/api/java/forestry/api/storage/BackpackResupplyEvent.java b/src/api/java/forestry/api/storage/BackpackResupplyEvent.java new file mode 100755 index 000000000..e6e5e1198 --- /dev/null +++ b/src/api/java/forestry/api/storage/BackpackResupplyEvent.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; + +import cpw.mods.fml.common.eventhandler.Cancelable; + +/** + * Use @SubscribeEvent on a method taking this event as an argument. Will fire whenever a backpack tries to resupply to a player inventory. Processing will stop + * if the event is canceled. + */ +@Cancelable +public class BackpackResupplyEvent extends BackpackEvent { + + public BackpackResupplyEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory) { + super(player, backpackDefinition, backpackInventory); + } + +} diff --git a/src/api/java/forestry/api/storage/BackpackStowEvent.java b/src/api/java/forestry/api/storage/BackpackStowEvent.java new file mode 100755 index 000000000..3afbf7a1d --- /dev/null +++ b/src/api/java/forestry/api/storage/BackpackStowEvent.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.eventhandler.Cancelable; + +/** + * Use @SubscribeEvent on a method taking this event as an argument. Will fire whenever a backpack tries to store an item. Processing will stop if the stacksize + * of stackToStow drops to 0 or less or the event is canceled. + */ +@Cancelable +public class BackpackStowEvent extends BackpackEvent { + + public final ItemStack stackToStow; + + public BackpackStowEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory, ItemStack stackToStow) { + super(player, backpackDefinition, backpackInventory); + this.stackToStow = stackToStow; + } +} diff --git a/src/api/java/forestry/api/storage/EnumBackpackType.java b/src/api/java/forestry/api/storage/EnumBackpackType.java new file mode 100755 index 000000000..a1c1538ab --- /dev/null +++ b/src/api/java/forestry/api/storage/EnumBackpackType.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +public enum EnumBackpackType { + T1, T2 +} diff --git a/src/api/java/forestry/api/storage/IBackpackDefinition.java b/src/api/java/forestry/api/storage/IBackpackDefinition.java new file mode 100755 index 000000000..804e3bfd6 --- /dev/null +++ b/src/api/java/forestry/api/storage/IBackpackDefinition.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import java.util.Collection; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public interface IBackpackDefinition { + + /** + * @return A unique string identifier + */ + String getKey(); + + /** + * @return Human-readable name of the backpack. + */ + String getName(); + + /** + * @return Primary colour for the backpack icon. + */ + int getPrimaryColour(); + + /** + * @return Secondary colour for backpack icon. + */ + int getSecondaryColour(); + + /** + * Adds an item as valid for this backpack. + * + * @param validItem + */ + void addValidItem(ItemStack validItem); + + /** + * Returns an arraylist of all items valid for this backpack type. + * + * @param player + * @return Collection of itemstack which are valid items for this backpack type. May be empty or null and does not necessarily include all valid items. + */ + Collection getValidItems(EntityPlayer player); + + /** + * Returns true if the itemstack is a valid item for this backpack type. + * + * @param player + * @param itemstack + * @return true if the given itemstack is valid for this backpack, false otherwise. + */ + boolean isValidItem(EntityPlayer player, ItemStack itemstack); + +} diff --git a/src/api/java/forestry/api/storage/IBackpackInterface.java b/src/api/java/forestry/api/storage/IBackpackInterface.java new file mode 100755 index 000000000..27a2eba56 --- /dev/null +++ b/src/api/java/forestry/api/storage/IBackpackInterface.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.item.Item; + +public interface IBackpackInterface { + + /** + * Adds a backpack with the given definition and type, returning the item. + * + * @param definition + * Definition of backpack behaviour. + * @param type + * Type of backpack. (T1 or T2 (= Woven) + * @return Created backpack item. + */ + Item addBackpack(IBackpackDefinition definition, EnumBackpackType type); +} diff --git a/src/api/java/forestry/api/storage/package-info.java b/src/api/java/forestry/api/storage/package-info.java new file mode 100755 index 000000000..139f5d8e5 --- /dev/null +++ b/src/api/java/forestry/api/storage/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|storage") +package forestry.api.storage; +import cpw.mods.fml.common.API; diff --git a/src/api/java/forestry/api/world/ITreeGenData.java b/src/api/java/forestry/api/world/ITreeGenData.java new file mode 100755 index 000000000..af42d7392 --- /dev/null +++ b/src/api/java/forestry/api/world/ITreeGenData.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.world; + +import net.minecraft.world.World; + +public interface ITreeGenData { + + int getGirth(World world, int x, int y, int z); + + float getHeightModifier(); + + boolean canGrow(World world, int x, int y, int z, int expectedGirth, int expectedHeight); + + void setLeaves(World world, String owner, int x, int y, int z); + + boolean allowsFruitBlocks(); + + boolean trySpawnFruitBlock(World world, int x, int y, int z); +} diff --git a/src/api/java/forestry/api/world/IWorldGenInterface.java b/src/api/java/forestry/api/world/IWorldGenInterface.java new file mode 100755 index 000000000..b7b5555f4 --- /dev/null +++ b/src/api/java/forestry/api/world/IWorldGenInterface.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.world; + +import net.minecraft.world.gen.feature.WorldGenerator; + +public interface IWorldGenInterface { + + /** + * Retrieves generators for trees identified by a given string. + * + * Returned generator classes take an {@link ITreeGenData} in the constructor. + * + * @param ident + * Unique identifier for tree type. Forestry's convention is 'treeSpecies', i.e. 'treeBaobab', 'treeSequoia'. + * @return All generators matching the given ident. + */ + Class[] getTreeGenerators(String ident); +} diff --git a/src/api/java/forestry/api/world/WorldGenManager.java b/src/api/java/forestry/api/world/WorldGenManager.java new file mode 100755 index 000000000..a2a5b4f84 --- /dev/null +++ b/src/api/java/forestry/api/world/WorldGenManager.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.world; + +public class WorldGenManager { + public static IWorldGenInterface worldgenInterface; +} diff --git a/src/api/java/forestry/api/world/package-info.java b/src/api/java/forestry/api/world/package-info.java new file mode 100755 index 000000000..c9656ba6d --- /dev/null +++ b/src/api/java/forestry/api/world/package-info.java @@ -0,0 +1,8 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|world") +package forestry.api.world; +import cpw.mods.fml.common.API; diff --git a/src/main/java/biomesoplenty/BiomesOPlenty.java b/src/main/java/biomesoplenty/BiomesOPlenty.java index 89dbc5665..35b023cc5 100644 --- a/src/main/java/biomesoplenty/BiomesOPlenty.java +++ b/src/main/java/biomesoplenty/BiomesOPlenty.java @@ -7,6 +7,7 @@ import biomesoplenty.common.configuration.structures.BOPConfigurationVillages; import biomesoplenty.common.core.*; import biomesoplenty.common.eventhandler.BOPEventHandlers; import biomesoplenty.common.helpers.CreativeTabsBOP; +import biomesoplenty.common.integration.BOPIntegration; import biomesoplenty.common.integration.TreecapitatorIntegration; import biomesoplenty.common.network.PacketPipeline; import biomesoplenty.common.utils.BOPModInfo; @@ -77,6 +78,8 @@ public class BiomesOPlenty @EventHandler public void postInit(FMLPostInitializationEvent event) { + BOPIntegration.postInit(); + packetPipeline.postInitialize(); BOPBiomes.worldTypeBOP = new WorldTypeBOP(); diff --git a/src/main/java/biomesoplenty/api/package-info.java b/src/main/java/biomesoplenty/api/package-info.java new file mode 100644 index 000000000..f1428548f --- /dev/null +++ b/src/main/java/biomesoplenty/api/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0.0", owner = "BiomesOPlenty", provides = "BiomesOPlentyAPI") +package biomesoplenty.api; +import cpw.mods.fml.common.API; + diff --git a/src/main/java/biomesoplenty/common/blocks/BlockAsh.java b/src/main/java/biomesoplenty/common/blocks/BlockAsh.java index 02cd7b635..2bed2ac0e 100644 --- a/src/main/java/biomesoplenty/common/blocks/BlockAsh.java +++ b/src/main/java/biomesoplenty/common/blocks/BlockAsh.java @@ -39,7 +39,7 @@ public class BlockAsh extends Block public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { float yOffset = 0.125F; - return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1 - yOffset, z + 1); + return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1 - yOffset, z + 1); } @Override diff --git a/src/main/java/biomesoplenty/common/blocks/BlockBOPGrass.java b/src/main/java/biomesoplenty/common/blocks/BlockBOPGrass.java index 8dff8e971..b45719577 100644 --- a/src/main/java/biomesoplenty/common/blocks/BlockBOPGrass.java +++ b/src/main/java/biomesoplenty/common/blocks/BlockBOPGrass.java @@ -195,7 +195,7 @@ public class BlockBOPGrass extends Block if (world.getBlockMetadata(x, y, z) == 1) { float f = 0.02F; - return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1 - f, z + 1); + return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1 - f, z + 1); } //TODO: getCollisionBoundingBoxFromPool() diff --git a/src/main/java/biomesoplenty/common/blocks/BlockBamboo.java b/src/main/java/biomesoplenty/common/blocks/BlockBamboo.java index 48bae45a9..65e9d5a2f 100644 --- a/src/main/java/biomesoplenty/common/blocks/BlockBamboo.java +++ b/src/main/java/biomesoplenty/common/blocks/BlockBamboo.java @@ -95,7 +95,7 @@ public class BlockBamboo extends Block { float pixel = 0.0625F; - return AxisAlignedBB.getAABBPool().getAABB((double)x + (1.0F - (pixel * 4)), (double)y, (double)z + (1.0F - (pixel * 4)), (double)x + (pixel * 4), (double)y + 1.0F, (double)z + (pixel * 4)); + return AxisAlignedBB.getBoundingBox((double)x + (1.0F - (pixel * 4)), (double)y, (double)z + (1.0F - (pixel * 4)), (double)x + (pixel * 4), (double)y + 1.0F, (double)z + (pixel * 4)); } @Override diff --git a/src/main/java/biomesoplenty/common/blocks/BlockFlesh.java b/src/main/java/biomesoplenty/common/blocks/BlockFlesh.java index 70e6e5c41..375107d2f 100644 --- a/src/main/java/biomesoplenty/common/blocks/BlockFlesh.java +++ b/src/main/java/biomesoplenty/common/blocks/BlockFlesh.java @@ -44,7 +44,7 @@ public class BlockFlesh extends Block public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { float var5 = 0.125F; - return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1 - var5, z + 1); + return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1 - var5, z + 1); } @Override diff --git a/src/main/java/biomesoplenty/common/blocks/BlockMud.java b/src/main/java/biomesoplenty/common/blocks/BlockMud.java index df60920ab..d50dd1905 100644 --- a/src/main/java/biomesoplenty/common/blocks/BlockMud.java +++ b/src/main/java/biomesoplenty/common/blocks/BlockMud.java @@ -72,7 +72,7 @@ public class BlockMud extends BOPBlock if (world.getBlockMetadata(x, y, z) == 0) { float var5 = 0.35F; - return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1 - var5, z + 1); + return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1 - var5, z + 1); } else return null; diff --git a/src/main/java/biomesoplenty/common/integration/BOPIntegration.java b/src/main/java/biomesoplenty/common/integration/BOPIntegration.java new file mode 100644 index 000000000..f76c46a2a --- /dev/null +++ b/src/main/java/biomesoplenty/common/integration/BOPIntegration.java @@ -0,0 +1,32 @@ +package biomesoplenty.common.integration; + +import biomesoplenty.common.utils.BOPLogger; +import cpw.mods.fml.common.Loader; + +public class BOPIntegration +{ + public static void preInit() + { + + } + + public static void init() + { + + } + + public static void postInit() + { + if (Loader.isModLoaded("Forestry")) + { + try + { + ForestryIntegration.init(); + } + catch (Exception e) + { + BOPLogger.warning("There was an error while integrating Forestry with Biomes O' Plenty", e); + } + } + } +} diff --git a/src/main/java/biomesoplenty/common/integration/ForestryIntegration.java b/src/main/java/biomesoplenty/common/integration/ForestryIntegration.java new file mode 100644 index 000000000..6116a77e7 --- /dev/null +++ b/src/main/java/biomesoplenty/common/integration/ForestryIntegration.java @@ -0,0 +1,107 @@ +package biomesoplenty.common.integration; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.oredict.OreDictionary; +import biomesoplenty.api.content.BOPCBlocks; +import biomesoplenty.api.content.BOPCItems; +import forestry.api.apiculture.FlowerManager; +import forestry.api.recipes.RecipeManagers; +import forestry.api.storage.BackpackManager; + +public class ForestryIntegration +{ + private static final String LIQUID_WATER = "water"; + + private static final String LIQUID_BIOMASS = "biomass"; + private static final String LIQUID_JUICE = "juice"; + private static final String LIQUID_HONEY = "honey"; + + private static final int MINER = 0; + private static final int DIGGER = 1; + private static final int FORESTER = 2; + + private static final Item mulch = GameRegistry.findItem("Forestry", "mulch"); + + public static void init() + { + addFermenterRecipes(); + addSqueezerRecipes(); + addFlowers(); + addBlocksToBackpack(); + } + + private static void addFermenterRecipes() + { + addFermenterRecipe(new ItemStack(BOPCBlocks.saplings, 1, OreDictionary.WILDCARD_VALUE), 250, LIQUID_BIOMASS); + addFermenterRecipe(new ItemStack(BOPCBlocks.colorizedSaplings, 1, OreDictionary.WILDCARD_VALUE), 250, LIQUID_BIOMASS); + } + + private static void addSqueezerRecipes() + { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] { new ItemStack(BOPCItems.food) }, FluidRegistry.getFluidStack(LIQUID_JUICE, 50), new ItemStack(mulch), 5); + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] { new ItemStack(BOPCItems.food, 1, 8) }, FluidRegistry.getFluidStack(LIQUID_JUICE, 200), new ItemStack(mulch), 20); + } + + private static void addFlowers() + { + FlowerManager.plainFlowers.add(new ItemStack(BOPCBlocks.flowers, 1, OreDictionary.WILDCARD_VALUE)); + FlowerManager.plainFlowers.add(new ItemStack(BOPCBlocks.flowers2, 1, OreDictionary.WILDCARD_VALUE)); + } + + private static void addBlocksToBackpack() + { + for (int i = 0; i < 16; i++) + { + if (i % 2 == 0) BackpackManager.backpackItems[MINER].add(new ItemStack(BOPCBlocks.gemOre, 1, i)); + } + + BackpackManager.backpackItems[MINER].add(new ItemStack(BOPCBlocks.driedDirt)); + BackpackManager.backpackItems[MINER].add(new ItemStack(BOPCBlocks.overgrownNetherrack)); + BackpackManager.backpackItems[MINER].add(new ItemStack(BOPCBlocks.cragRock)); + BackpackManager.backpackItems[MINER].add(new ItemStack(BOPCBlocks.ashStone)); + BackpackManager.backpackItems[MINER].add(new ItemStack(BOPCItems.gems, 1, OreDictionary.WILDCARD_VALUE)); + + BackpackManager.backpackItems[DIGGER].add(new ItemStack(BOPCBlocks.bopGrass, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[DIGGER].add(new ItemStack(BOPCBlocks.longGrass)); + BackpackManager.backpackItems[DIGGER].add(new ItemStack(BOPCBlocks.mud)); + BackpackManager.backpackItems[DIGGER].add(new ItemStack(BOPCBlocks.hardDirt)); + BackpackManager.backpackItems[DIGGER].add(new ItemStack(BOPCBlocks.hardSand)); + BackpackManager.backpackItems[DIGGER].add(new ItemStack(BOPCBlocks.originGrass)); + BackpackManager.backpackItems[DIGGER].add(new ItemStack(BOPCBlocks.ash)); + + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.logs1, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.logs2, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.logs3, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.logs4, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.colorizedSaplings, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.saplings, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.leaves1, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.leaves2, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.leaves3, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.leaves4, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.colorizedLeaves1, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.colorizedLeaves2, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.appleLeaves, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.persimmonLeaves, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.bamboo, 1, OreDictionary.WILDCARD_VALUE)); + BackpackManager.backpackItems[FORESTER].add(new ItemStack(BOPCBlocks.petals, 1, OreDictionary.WILDCARD_VALUE)); + } + + private static void addFermenterRecipe(ItemStack resource, int fermentationValue, String output) + { + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.0F, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(LIQUID_WATER, 1)); + + if (FluidRegistry.isFluidRegistered(LIQUID_JUICE)) + { + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5F, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(LIQUID_JUICE, 1)); + } + + if (FluidRegistry.isFluidRegistered(LIQUID_HONEY)) + { + RecipeManagers.fermenterManager.addRecipe(resource, fermentationValue, 1.5F, FluidRegistry.getFluidStack(output, 1), FluidRegistry.getFluidStack(LIQUID_HONEY, 1)); + } + } +}