diff --git a/src/minecraft/forestry/api/apiculture/BeeManager.java b/src/minecraft/forestry/api/apiculture/BeeManager.java new file mode 100644 index 000000000..ebcf96d28 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/BeeManager.java @@ -0,0 +1,39 @@ +package forestry.api.apiculture; + +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.item.ItemStack; +import forestry.api.genetics.IMutation; + +public class BeeManager { + + /** + * See {@link IBeeInterface} for details + */ + public static IBeeInterface 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; + + /** + * Access to Forestry's breeding manager for breeding information. + */ + public static IBreedingManager breedingManager; + + /** + * List of items that can induce swarming. Integer denotes x in 1000 chance. + */ + public static HashMap inducers = new HashMap(); +} diff --git a/src/minecraft/forestry/api/apiculture/EnumBeeChromosome.java b/src/minecraft/forestry/api/apiculture/EnumBeeChromosome.java new file mode 100644 index 000000000..0321d6590 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/EnumBeeChromosome.java @@ -0,0 +1,6 @@ +package forestry.api.apiculture; + +public enum EnumBeeChromosome { + SPECIES, SPEED, LIFESPAN, FERTILITY, TEMPERATURE_TOLERANCE, NOCTURNAL, @Deprecated + HUMIDITY, HUMIDITY_TOLERANCE, TOLERANT_FLYER, CAVE_DWELLING, FLOWER_PROVIDER, FLOWERING, TERRITORY, EFFECT +} diff --git a/src/minecraft/forestry/api/apiculture/EnumBeeType.java b/src/minecraft/forestry/api/apiculture/EnumBeeType.java new file mode 100644 index 000000000..7fdd52cb4 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/EnumBeeType.java @@ -0,0 +1,17 @@ +package forestry.api.apiculture; + +import java.util.Locale; + +public enum EnumBeeType { + NONE, PRINCESS, QUEEN, DRONE; + + String name; + + private EnumBeeType() { + this.name = "bees." + this.toString().toLowerCase(Locale.ENGLISH); + } + + public String getName() { + return name; + } +} diff --git a/src/minecraft/forestry/api/apiculture/FlowerManager.java b/src/minecraft/forestry/api/apiculture/FlowerManager.java new file mode 100644 index 000000000..3f2f40693 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/FlowerManager.java @@ -0,0 +1,12 @@ +package forestry.api.apiculture; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +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/minecraft/forestry/api/apiculture/IAlleleBeeEffect.java b/src/minecraft/forestry/api/apiculture/IAlleleBeeEffect.java new file mode 100644 index 000000000..6738c3199 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IAlleleBeeEffect.java @@ -0,0 +1,47 @@ +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 world + * @param biomeid + * @param x + * @param y + * @param z + * @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 world + * @param biomeid + * @param x + * @param y + * @param z + * @return storedData, may have been manipulated. + */ + IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing); + + /** + * @return A texture file containing an icon representing the effect + */ + String getIconTextureFile(); + + /** + * @return Icon index of the effect's icon, return -1 if there isn't one + */ + int getIconIndex(); +} diff --git a/src/minecraft/forestry/api/apiculture/IAlleleBeeSpecies.java b/src/minecraft/forestry/api/apiculture/IAlleleBeeSpecies.java new file mode 100644 index 000000000..2acf3906b --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IAlleleBeeSpecies.java @@ -0,0 +1,26 @@ +package forestry.api.apiculture; + +import java.util.HashMap; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.genetics.IAlleleSpecies; + +public interface IAlleleBeeSpecies extends IAlleleSpecies { + + // / Products, Chance + HashMap getProducts(); + + // / Specialty, Chance + HashMap getSpecialty(); + + // / Only jubilant bees give their specialty product + boolean isJubilant(IBeeGenome genome, IBeeHousing housing); + + int getIconColour(int renderPass); + + @SideOnly(Side.CLIENT) + Icon getIcon(EnumBeeType type, int renderPass); +} diff --git a/src/minecraft/forestry/api/apiculture/IAlleleFlowers.java b/src/minecraft/forestry/api/apiculture/IAlleleFlowers.java new file mode 100644 index 000000000..e95ad9411 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IAlleleFlowers.java @@ -0,0 +1,12 @@ +package forestry.api.apiculture; + +import forestry.api.genetics.IAllele; + +public interface IAlleleFlowers extends IAllele { + + /** + * @return FlowerProvider + */ + IFlowerProvider getProvider(); + +} diff --git a/src/minecraft/forestry/api/apiculture/IAlvearyComponent.java b/src/minecraft/forestry/api/apiculture/IAlvearyComponent.java new file mode 100644 index 000000000..2e6df0a06 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IAlvearyComponent.java @@ -0,0 +1,27 @@ +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/minecraft/forestry/api/apiculture/IApiaristTracker.java b/src/minecraft/forestry/api/apiculture/IApiaristTracker.java new file mode 100644 index 000000000..aae3bd563 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IApiaristTracker.java @@ -0,0 +1,52 @@ +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 IBreedingManager} + * + * @author SirSengir + */ +public interface IApiaristTracker extends IBreedingTracker { + + /** + * Register the birth of a queen. Will mark species as discovered. + * + * @param bee + * 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 bee + * 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 bee + * Created drone. + */ + void registerDrone(IIndividual drone); + + /** + * @return Amount of drones bred with this tracker. + */ + int getDroneCount(); + +} diff --git a/src/minecraft/forestry/api/apiculture/IArmorApiarist.java b/src/minecraft/forestry/api/apiculture/IArmorApiarist.java new file mode 100644 index 000000000..b2e5518dc --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IArmorApiarist.java @@ -0,0 +1,24 @@ +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/minecraft/forestry/api/apiculture/IBee.java b/src/minecraft/forestry/api/apiculture/IBee.java new file mode 100644 index 000000000..4c45bcfe2 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBee.java @@ -0,0 +1,93 @@ +package forestry.api.apiculture; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IEffectData; +import forestry.api.genetics.IIndividual; + +/** + * Other implementations than Forestry's default one are not supported. + * + * @author SirSengir + */ +public interface IBee extends IIndividual { + + /** + * @return true if the individual is originally of natural origin. + */ + boolean isNatural(); + + /** + * @return generation this individual is removed from the original individual. + */ + int getGeneration(); + + IBee setNatural(boolean flag); + + boolean isIrregularMating(); + + void age(World world, float ageModifier); + + void mate(IBee drone); + + void setIsNatural(boolean flag); + + IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing); + + IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing); + + boolean isAlive(); + + boolean isPureBred(EnumBeeChromosome chromosome); + + /** + * @return true if the bee may spawn offspring + */ + boolean canSpawn(); + + /** + * Determines whether the queen can work. + * + * @param world + * @param isAlveary + * @param biomeid + * @param temperature + * @param humidity + * @param x + * @param y + * @param z + * @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); + + int getHealth(); + + int getMaxHealth(); + + IBeeGenome getGenome(); + + IBeeGenome getMate(); + + IIndividual retrievePollen(IBeeHousing housing); + + boolean pollinateRandom(IBeeHousing housing, IIndividual pollen); + +} diff --git a/src/minecraft/forestry/api/apiculture/IBeeGenome.java b/src/minecraft/forestry/api/apiculture/IBeeGenome.java new file mode 100644 index 000000000..bd5f55850 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeeGenome.java @@ -0,0 +1,42 @@ +package forestry.api.apiculture; + +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IGenome; + +/** + * Only the default implementation is supported. + * + * @author SirSengir + * + */ +public interface IBeeGenome extends IGenome { + + IAlleleBeeSpecies getPrimaryAsBee(); + + IAlleleBeeSpecies getSecondaryAsBee(); + + float getSpeed(); + + int getLifespan(); + + int getFertility(); + + boolean getNocturnal(); + + boolean getTolerantFlyer(); + + boolean getCaveDwelling(); + + IFlowerProvider getFlowerProvider(); + + int getFlowering(); + + int[] getTerritory(); + + IAlleleBeeEffect getEffect(); + + EnumTolerance getToleranceTemp(); + + EnumTolerance getToleranceHumid(); + +} diff --git a/src/minecraft/forestry/api/apiculture/IBeeHousing.java b/src/minecraft/forestry/api/apiculture/IBeeHousing.java new file mode 100644 index 000000000..fb880765b --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeeHousing.java @@ -0,0 +1,56 @@ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +public interface IBeeHousing extends IBeeModifier, IBeeListener { + + int getXCoord(); + + int getYCoord(); + + int getZCoord(); + + ItemStack getQueen(); + + ItemStack getDrone(); + + void setQueen(ItemStack itemstack); + + void setDrone(ItemStack itemstack); + + int getBiomeId(); + + EnumTemperature getTemperature(); + + EnumHumidity getHumidity(); + + World getWorld(); + + /** + * @return String containing the login of this housing's owner. + */ + String getOwnerName(); + + void setErrorState(int state); + + int getErrorOrdinal(); + + /** + * @return true if princesses and drones can (currently) mate in this housing to generate queens. + */ + boolean canBreed(); + + /** + * Called by IBeekeepingLogic to add 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/minecraft/forestry/api/apiculture/IBeeInterface.java b/src/minecraft/forestry/api/apiculture/IBeeInterface.java new file mode 100644 index 000000000..7ef2ec523 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeeInterface.java @@ -0,0 +1,69 @@ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IChromosome; + +public interface IBeeInterface { + + /** + * @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 Forestry bee. Equal to getType(ItemStack stack) != EnumBeeType.NONE + */ + boolean isBee(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); + + /** + * @return {@link IBee} pattern parsed from the passed stack's nbt data. + */ + IBee getBee(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); + + /** + * @param bee + * Bee object to use in creating the itemstack. If a queen is to be created, make sure the mate genome is set. + * @param type + * {@link EnumBeeType} according to whether a princess, drone or queen is wanted. + * @return ItemStack representing a Forestry bee. + */ + ItemStack getBeeStack(IBee bee, EnumBeeType type); + + IChromosome[] templateAsChromosomes(IAllele[] template); + + IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive); + + IBeeGenome templateAsGenome(IAllele[] template); + + IBeeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); +} diff --git a/src/minecraft/forestry/api/apiculture/IBeeListener.java b/src/minecraft/forestry/api/apiculture/IBeeListener.java new file mode 100644 index 000000000..93938ef31 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeeListener.java @@ -0,0 +1,36 @@ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; + +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); + +} diff --git a/src/minecraft/forestry/api/apiculture/IBeeModifier.java b/src/minecraft/forestry/api/apiculture/IBeeModifier.java new file mode 100644 index 000000000..cce63accb --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeeModifier.java @@ -0,0 +1,60 @@ +package forestry.api.apiculture; + +public interface IBeeModifier { + + /** + * + * @param genome + * @return Float used to modify the base territory. + */ + float getTerritoryModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome + * @param mate + * @return Float used to modify the base mutation chance. + */ + float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier); + + /** + * @param genome + * @param mate + * @return Float used to modify the life span of queens. + */ + float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier); + + /** + * @param genome + * @param mate + * @return Fload modifying the production speed of queens. + */ + float getProductionModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome + * @param mate + * @return Fload modifying the flowering of queens. + */ + float getFloweringModifier(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/minecraft/forestry/api/apiculture/IBeeMutation.java b/src/minecraft/forestry/api/apiculture/IBeeMutation.java new file mode 100644 index 000000000..970aeda73 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeeMutation.java @@ -0,0 +1,9 @@ +package forestry.api.apiculture; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IMutation; + +public interface IBeeMutation extends IMutation { + int getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); +} diff --git a/src/minecraft/forestry/api/apiculture/IBeekeepingLogic.java b/src/minecraft/forestry/api/apiculture/IBeekeepingLogic.java new file mode 100644 index 000000000..cb8327a0f --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeekeepingLogic.java @@ -0,0 +1,20 @@ +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(); + + IEffectData[] getEffectData(); + + // / UPDATING + void update(); + +} diff --git a/src/minecraft/forestry/api/apiculture/IBeekeepingMode.java b/src/minecraft/forestry/api/apiculture/IBeekeepingMode.java new file mode 100644 index 000000000..b3c86293e --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBeekeepingMode.java @@ -0,0 +1,48 @@ +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); + + /** + * @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/minecraft/forestry/api/apiculture/IBreedingManager.java b/src/minecraft/forestry/api/apiculture/IBreedingManager.java new file mode 100644 index 000000000..25fb9a20b --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IBreedingManager.java @@ -0,0 +1,103 @@ +package forestry.api.apiculture; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.world.World; +import forestry.api.core.IStructureLogic; +import forestry.api.genetics.IAllele; + +public interface IBreedingManager { + + ArrayList getBeekeepingModes(); + + IBeekeepingMode getBeekeepingMode(World world); + + IBeekeepingMode getBeekeepingMode(String name); + + void registerBeekeepingMode(IBeekeepingMode mode); + + void setBeekeepingMode(World world, String name); + + /** + * @return Integer denoting the number of (counted) bee species in the world. + */ + int getBeeSpeciesCount(); + + /** + * Moved to IAlleleRegistry + */ + @Deprecated + void blacklistBeeSpecies(String uid); + + /** + * Moved to IAlleleRegistry + */ + @Deprecated + ArrayList getBeeSpeciesBlacklist(); + + /** + * Moved to IAlleleRegistry + */ + @Deprecated + boolean isBlacklisted(String uid); + + /** + * @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); + + /** + * Registers a bee template using the UID of the first allele as identifier. + * + * @param template + */ + void registerBeeTemplate(IAllele[] template); + + /** + * Registers a bee template using the passed identifier. + * + * @param template + */ + void registerBeeTemplate(String identifier, IAllele[] template); + + /** + * Retrieves a registered template using the passed identifier. + * + * @param identifier + * @return + */ + IAllele[] getBeeTemplate(String identifier); + + /** + * @return Default bee template for use in emergencies. + */ + IAllele[] getDefaultBeeTemplate(); + + /** + * @param world + * @return {@link IApiaristTracker} associated with the passed world. + */ + IApiaristTracker getApiaristTracker(World world, String player); + + /** + * Use to register bee mutations. + * + * @param mutation + */ + void registerBeeMutation(IBeeMutation mutation); + + /** + * @return All registered mutations. + */ + Collection getMutations(boolean shuffle); +} diff --git a/src/minecraft/forestry/api/apiculture/IFlowerProvider.java b/src/minecraft/forestry/api/apiculture/IFlowerProvider.java new file mode 100644 index 000000000..6b50aa0a6 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IFlowerProvider.java @@ -0,0 +1,44 @@ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IPollinatable; + +public interface IFlowerProvider { + /** + * @param world + * @param species + * Integer representing a species' ordinal matching {@EnumBeeBreed} + * @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, IBeeGenome genome, int x, int y, int z); + + boolean isAcceptedPollinatable(World world, IPollinatable pollinatable); + + /** + * @param world + * @param species + * Integer representing a species' ordinal matching {@EnumBeeBreed} + * @param x + * @param y + * @param z + * @return True if a flower was planted. + */ + boolean growFlower(World world, IBeeGenome genome, int x, int y, int z); + + /** + * @return Short, human-readable identifier used in the beealyzer. + */ + String getDescription(); + + ItemStack[] affectProducts(World world, IBeeGenome genome, 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/minecraft/forestry/api/apiculture/IHiveDrop.java b/src/minecraft/forestry/api/apiculture/IHiveDrop.java new file mode 100644 index 000000000..924d4fe02 --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IHiveDrop.java @@ -0,0 +1,33 @@ +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 + * @param x + * @param y + * @param z + * @return + */ + int getChance(World world, int x, int y, int z); +} diff --git a/src/minecraft/forestry/api/apiculture/IHiveFrame.java b/src/minecraft/forestry/api/apiculture/IHiveFrame.java new file mode 100644 index 000000000..4ab97c3eb --- /dev/null +++ b/src/minecraft/forestry/api/apiculture/IHiveFrame.java @@ -0,0 +1,22 @@ +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. {@link IBeekeepingMode.getWearModifier()} 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/minecraft/forestry/api/arboriculture/EnumGermlingType.java b/src/minecraft/forestry/api/arboriculture/EnumGermlingType.java new file mode 100644 index 000000000..d16d9deb9 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/EnumGermlingType.java @@ -0,0 +1,16 @@ +package forestry.api.arboriculture; + +public enum EnumGermlingType { + SAPLING("Sapling"), BLOSSOM("Blossom"), POLLEN("Pollen"), GERMLING("Germling"); + + String name; + + private EnumGermlingType(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/src/minecraft/forestry/api/arboriculture/EnumGrowthConditions.java b/src/minecraft/forestry/api/arboriculture/EnumGrowthConditions.java new file mode 100644 index 000000000..99e117b40 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/EnumGrowthConditions.java @@ -0,0 +1,5 @@ +package forestry.api.arboriculture; + +public enum EnumGrowthConditions { + HOSTILE, PALTRY, NORMAL, GOOD, EXCELLENT +} diff --git a/src/minecraft/forestry/api/arboriculture/EnumTreeChromosome.java b/src/minecraft/forestry/api/arboriculture/EnumTreeChromosome.java new file mode 100644 index 000000000..b45875220 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/EnumTreeChromosome.java @@ -0,0 +1,56 @@ +package forestry.api.arboriculture; + +import net.minecraftforge.common.EnumPlantType; +import forestry.api.genetics.IFruitFamily; + +public enum EnumTreeChromosome { + + /** + * Determines the following: - WorldGen, including the used wood blocks - {@link IFruitFamily}s supported. Limits which {@IFruitProvider} + * will actually yield fruit with this species. - Native {@link EnumPlantType} for this tree. Combines with the PLANT chromosome. + */ + SPECIES, + /** + * {@link IGrowthProvider}, determines conditions required by the tree to grow. + */ + GROWTH, + /** + * A float modifying the height of the tree. Taken into account at worldgen. + */ + HEIGHT, + /** + * Chance for saplings. + */ + FERTILITY, + /** + * {@link IFruitProvider}, determines if and what fruits are grown on the tree. Limited by the {@link IFruitFamily}s the species supports. + */ + FRUITS, + /** + * Chance for fruit leaves and/or drops. + */ + YIELD, + /** + * May add additional tolerances for {@link EnumPlantTypes}. + */ + PLANT, + /** + * Determines the speed at which fruit will ripen on this tree. + */ + SAPPINESS, + /** + * Territory for leaf effects. Unused. + */ + TERRITORY, + /** + * Leaf effect. Unused. + */ + EFFECT, + /** + * Amount of random ticks that need to elapse before a sapling will grow into a tree. + */ + MATURATION, + + GIRTH + +} diff --git a/src/minecraft/forestry/api/arboriculture/IAlleleFruit.java b/src/minecraft/forestry/api/arboriculture/IAlleleFruit.java new file mode 100644 index 000000000..f468af08c --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IAlleleFruit.java @@ -0,0 +1,12 @@ +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/minecraft/forestry/api/arboriculture/IAlleleGrowth.java b/src/minecraft/forestry/api/arboriculture/IAlleleGrowth.java new file mode 100644 index 000000000..60b34a631 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IAlleleGrowth.java @@ -0,0 +1,12 @@ +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/minecraft/forestry/api/arboriculture/IAlleleLeafEffect.java b/src/minecraft/forestry/api/arboriculture/IAlleleLeafEffect.java new file mode 100644 index 000000000..1a3e640ef --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IAlleleLeafEffect.java @@ -0,0 +1,10 @@ +package forestry.api.arboriculture; + +import forestry.api.genetics.IAlleleEffect; + +/** + * Simple allele encapsulating a leaf effect. (Not implemented) + */ +public interface IAlleleLeafEffect extends IAlleleEffect { + +} diff --git a/src/minecraft/forestry/api/arboriculture/IAlleleTreeSpecies.java b/src/minecraft/forestry/api/arboriculture/IAlleleTreeSpecies.java new file mode 100644 index 000000000..5a3ccf1c7 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IAlleleTreeSpecies.java @@ -0,0 +1,57 @@ +package forestry.api.arboriculture; + +import java.util.Collection; + +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.EnumPlantType; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IFruitFamily; + +public interface IAlleleTreeSpecies extends IAlleleSpecies { + + /** + * @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); + + int getGermlingIconColour(int renderPass); + + @SideOnly(Side.CLIENT) + Icon getGermlingIcon(EnumGermlingType type, int renderPass); + +} diff --git a/src/minecraft/forestry/api/arboriculture/IArboristTracker.java b/src/minecraft/forestry/api/arboriculture/IArboristTracker.java new file mode 100644 index 000000000..8e7ce8a95 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IArboristTracker.java @@ -0,0 +1,7 @@ +package forestry.api.arboriculture; + +import forestry.api.genetics.IBreedingTracker; + +public interface IArboristTracker extends IBreedingTracker { + +} diff --git a/src/minecraft/forestry/api/arboriculture/IFruitProvider.java b/src/minecraft/forestry/api/arboriculture/IFruitProvider.java new file mode 100644 index 000000000..bf839d89a --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IFruitProvider.java @@ -0,0 +1,63 @@ +package forestry.api.arboriculture; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +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 Icon 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); + + void registerIcons(); +} diff --git a/src/minecraft/forestry/api/arboriculture/IGrowthProvider.java b/src/minecraft/forestry/api/arboriculture/IGrowthProvider.java new file mode 100644 index 000000000..91db285d3 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IGrowthProvider.java @@ -0,0 +1,33 @@ +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 + * @param world + * @param xPos + * @param yPos + * @param zPos + * @param expectedGirth + * @param expectedHeight + * @return + */ + 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/minecraft/forestry/api/arboriculture/IToolGrafter.java b/src/minecraft/forestry/api/arboriculture/IToolGrafter.java new file mode 100644 index 000000000..d5840a99d --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/IToolGrafter.java @@ -0,0 +1,18 @@ +package forestry.api.arboriculture; + +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 + * @param world + * @param x + * @param y + * @param z + * @return + */ + float getSaplingModifier(ItemStack stack, World world, int x, int y, int z); +} diff --git a/src/minecraft/forestry/api/arboriculture/ITree.java b/src/minecraft/forestry/api/arboriculture/ITree.java new file mode 100644 index 000000000..9e66112c9 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/ITree.java @@ -0,0 +1,78 @@ +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(); + + 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/minecraft/forestry/api/arboriculture/ITreeBreedingManager.java b/src/minecraft/forestry/api/arboriculture/ITreeBreedingManager.java new file mode 100644 index 000000000..af9e86552 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/ITreeBreedingManager.java @@ -0,0 +1,37 @@ +package forestry.api.arboriculture; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.world.World; +import forestry.api.genetics.IAllele; + +public interface ITreeBreedingManager { + + void registerTreeTemplate(IAllele[] template); + + void registerTreeTemplate(String identifier, IAllele[] template); + + IAllele[] getTreeTemplate(String identifier); + + IAllele[] getDefaultTreeTemplate(); + + /** + * @param world + * @return {@link IArboristTracker} associated with the passed world. + */ + IArboristTracker getArboristTracker(World world, String player); + + ArrayList getTreekeepingModes(); + + ITreekeepingMode getTreekeepingMode(World world); + + ITreekeepingMode getTreekeepingMode(String name); + + void registerTreekeepingMode(ITreekeepingMode mode); + + void setTreekeepingMode(World world, String name); + + IAllele[] getRandomTreeTemplate(Random rand); + +} diff --git a/src/minecraft/forestry/api/arboriculture/ITreeGenome.java b/src/minecraft/forestry/api/arboriculture/ITreeGenome.java new file mode 100644 index 000000000..b4f33ec30 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/ITreeGenome.java @@ -0,0 +1,38 @@ +package forestry.api.arboriculture; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; +import forestry.api.genetics.IGenome; + +public interface ITreeGenome extends IGenome { + + IAlleleTreeSpecies getPrimaryAsTree(); + + IAlleleTreeSpecies getSecondaryAsTree(); + + 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(); +} diff --git a/src/minecraft/forestry/api/arboriculture/ITreeInterface.java b/src/minecraft/forestry/api/arboriculture/ITreeInterface.java new file mode 100644 index 000000000..a4c3c7478 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/ITreeInterface.java @@ -0,0 +1,38 @@ +package forestry.api.arboriculture; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IChromosome; +import forestry.api.genetics.IIndividual; + +public interface ITreeInterface { + boolean isGermling(ItemStack itemstack); + + boolean isPollen(ItemStack itemstack); + + boolean isPollinated(ItemStack itemstack); + + ITree getTree(World world, int x, int y, int z); + + ITree getTree(ItemStack itemstack); + + ITree getTree(World world, ITreeGenome genome); + + ItemStack getGermlingStack(ITree tree, EnumGermlingType type); + + 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); + + ITreeGenome templateAsGenome(IAllele[] template); + + ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, short[] indices, int x, int y, int z); + +} diff --git a/src/minecraft/forestry/api/arboriculture/ITreeModifier.java b/src/minecraft/forestry/api/arboriculture/ITreeModifier.java new file mode 100644 index 000000000..18a12a54a --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/ITreeModifier.java @@ -0,0 +1,40 @@ +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/minecraft/forestry/api/arboriculture/ITreeMutation.java b/src/minecraft/forestry/api/arboriculture/ITreeMutation.java new file mode 100644 index 000000000..efc46a814 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/ITreeMutation.java @@ -0,0 +1,10 @@ +package forestry.api.arboriculture; + +import net.minecraft.world.World; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IMutation; + +public interface ITreeMutation extends IMutation { + int getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); +} diff --git a/src/minecraft/forestry/api/arboriculture/ITreekeepingMode.java b/src/minecraft/forestry/api/arboriculture/ITreekeepingMode.java new file mode 100644 index 000000000..92e65cc3b --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/ITreekeepingMode.java @@ -0,0 +1,17 @@ +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/minecraft/forestry/api/arboriculture/TreeManager.java b/src/minecraft/forestry/api/arboriculture/TreeManager.java new file mode 100644 index 000000000..e6f9faee3 --- /dev/null +++ b/src/minecraft/forestry/api/arboriculture/TreeManager.java @@ -0,0 +1,15 @@ +package forestry.api.arboriculture; + +import java.util.ArrayList; + +public class TreeManager { + public static int treeSpeciesCount = 0; + public static ITreeInterface treeInterface; + public static ITreeBreedingManager breedingManager; + + /** + * List of possible mutations on fruit alleles. + */ + public static ArrayList treeMutations = new ArrayList(); + +} diff --git a/src/minecraft/forestry/api/circuits/ChipsetManager.java b/src/minecraft/forestry/api/circuits/ChipsetManager.java new file mode 100644 index 000000000..8baa4c95a --- /dev/null +++ b/src/minecraft/forestry/api/circuits/ChipsetManager.java @@ -0,0 +1,8 @@ +package forestry.api.circuits; + +public class ChipsetManager { + + public static ISolderManager solderManager; + public static ICircuitRegistry circuitRegistry; + +} diff --git a/src/minecraft/forestry/api/circuits/ICircuit.java b/src/minecraft/forestry/api/circuits/ICircuit.java new file mode 100644 index 000000000..1607036de --- /dev/null +++ b/src/minecraft/forestry/api/circuits/ICircuit.java @@ -0,0 +1,27 @@ +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/minecraft/forestry/api/circuits/ICircuitBoard.java b/src/minecraft/forestry/api/circuits/ICircuitBoard.java new file mode 100644 index 000000000..81a013d7a --- /dev/null +++ b/src/minecraft/forestry/api/circuits/ICircuitBoard.java @@ -0,0 +1,24 @@ +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); + +} diff --git a/src/minecraft/forestry/api/circuits/ICircuitLayout.java b/src/minecraft/forestry/api/circuits/ICircuitLayout.java new file mode 100644 index 000000000..5dc731875 --- /dev/null +++ b/src/minecraft/forestry/api/circuits/ICircuitLayout.java @@ -0,0 +1,11 @@ +package forestry.api.circuits; + +public interface ICircuitLayout { + + String getUID(); + + String getName(); + + String getUsage(); + +} diff --git a/src/minecraft/forestry/api/circuits/ICircuitLibrary.java b/src/minecraft/forestry/api/circuits/ICircuitLibrary.java new file mode 100644 index 000000000..1f38d6cce --- /dev/null +++ b/src/minecraft/forestry/api/circuits/ICircuitLibrary.java @@ -0,0 +1,5 @@ +package forestry.api.circuits; + +public interface ICircuitLibrary { + +} diff --git a/src/minecraft/forestry/api/circuits/ICircuitRegistry.java b/src/minecraft/forestry/api/circuits/ICircuitRegistry.java new file mode 100644 index 000000000..c412f53d9 --- /dev/null +++ b/src/minecraft/forestry/api/circuits/ICircuitRegistry.java @@ -0,0 +1,31 @@ +package forestry.api.circuits; + +import java.util.HashMap; + +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(); + +} diff --git a/src/minecraft/forestry/api/circuits/ISolderManager.java b/src/minecraft/forestry/api/circuits/ISolderManager.java new file mode 100644 index 000000000..e9420ffbb --- /dev/null +++ b/src/minecraft/forestry/api/circuits/ISolderManager.java @@ -0,0 +1,9 @@ +package forestry.api.circuits; + +import net.minecraft.item.ItemStack; + +public interface ISolderManager { + + void addRecipe(ICircuitLayout layout, ItemStack resource, ICircuit circuit); + +} diff --git a/src/minecraft/forestry/api/core/BlockInterface.java b/src/minecraft/forestry/api/core/BlockInterface.java new file mode 100644 index 000000000..4bec3cdc8 --- /dev/null +++ b/src/minecraft/forestry/api/core/BlockInterface.java @@ -0,0 +1,33 @@ +package forestry.api.core; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.FMLLog; + +public class BlockInterface { + /** + * Get yer blocks here! + * + * @param ident + * @return + */ + 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/minecraft/forestry/api/core/EnumHumidity.java b/src/minecraft/forestry/api/core/EnumHumidity.java new file mode 100644 index 000000000..50cf3d668 --- /dev/null +++ b/src/minecraft/forestry/api/core/EnumHumidity.java @@ -0,0 +1,48 @@ +package forestry.api.core; + +import java.util.ArrayList; + +public enum EnumHumidity { + ARID("Arid", 2), NORMAL("Normal", 1), DAMP("Damp", 4); + + /** + * Populated by Forestry with vanilla biomes. Add additional arid biomes here. (ex. desert) + */ + public static ArrayList aridBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional damp biomes here. (ex. jungle) + */ + public static ArrayList dampBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional normal biomes here. + */ + public static ArrayList normalBiomeIds = new ArrayList(); + + public final String name; + public final int iconIndex; + + private EnumHumidity(String name, int iconIndex) { + this.name = name; + this.iconIndex = iconIndex; + } + + public String getName() { + return this.name; + } + + public int getIconIndex() { + return this.iconIndex; + } + + public static ArrayList getBiomeIds(EnumHumidity humidity) { + switch (humidity) { + case ARID: + return aridBiomeIds; + case DAMP: + return dampBiomeIds; + case NORMAL: + default: + return normalBiomeIds; + } + } +} diff --git a/src/minecraft/forestry/api/core/EnumTemperature.java b/src/minecraft/forestry/api/core/EnumTemperature.java new file mode 100644 index 000000000..8722cb044 --- /dev/null +++ b/src/minecraft/forestry/api/core/EnumTemperature.java @@ -0,0 +1,70 @@ +package forestry.api.core; + +import java.util.ArrayList; + +import net.minecraft.util.Icon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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) + */ + public static ArrayList icyBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional cold biomes here. (ex. taiga) + */ + public static ArrayList coldBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional normal biomes here. (ex. forest, plains) + */ + public static ArrayList normalBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional warm biomes here. (ex. jungle) + */ + public static ArrayList warmBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional hot biomes here. (ex. desert) + */ + public static ArrayList hotBiomeIds = new ArrayList(); + /** + * Populated by Forestry with vanilla biomes. Add additional hellish biomes here. (ex. nether) + */ + 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; + } + + 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; + } + + } +} diff --git a/src/minecraft/forestry/api/core/ForestryAPI.java b/src/minecraft/forestry/api/core/ForestryAPI.java new file mode 100644 index 000000000..d673ac6e6 --- /dev/null +++ b/src/minecraft/forestry/api/core/ForestryAPI.java @@ -0,0 +1,12 @@ +package forestry.api.core; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ForestryAPI { + + public static Object instance; + + @SideOnly(Side.CLIENT) + public static ITextureManager textureManager; +} diff --git a/src/minecraft/forestry/api/core/GlobalManager.java b/src/minecraft/forestry/api/core/GlobalManager.java new file mode 100644 index 000000000..71e2b0f75 --- /dev/null +++ b/src/minecraft/forestry/api/core/GlobalManager.java @@ -0,0 +1,12 @@ +package forestry.api.core; + +import java.util.ArrayList; + +public class GlobalManager { + + public static ArrayList dirtBlockIds = new ArrayList(); + public static ArrayList sandBlockIds = new ArrayList(); + public static ArrayList leafBlockIds = new ArrayList(); + public static ArrayList snowBlockIds = new ArrayList(); + +} diff --git a/src/minecraft/forestry/api/core/IIconProvider.java b/src/minecraft/forestry/api/core/IIconProvider.java new file mode 100644 index 000000000..297c8281e --- /dev/null +++ b/src/minecraft/forestry/api/core/IIconProvider.java @@ -0,0 +1,18 @@ +package forestry.api.core; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.util.Icon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface IIconProvider { + + @SideOnly(Side.CLIENT) + Icon getIcon(short texUID); + + @SideOnly(Side.CLIENT) + void registerItemIcons(IconRegister itemMap); + @SideOnly(Side.CLIENT) + void registerTerrainIcons(IconRegister terrainMap); + +} diff --git a/src/minecraft/forestry/api/core/INBTTagable.java b/src/minecraft/forestry/api/core/INBTTagable.java new file mode 100644 index 000000000..c2e71ec5e --- /dev/null +++ b/src/minecraft/forestry/api/core/INBTTagable.java @@ -0,0 +1,9 @@ +package forestry.api.core; + +import net.minecraft.nbt.NBTTagCompound; + +public interface INBTTagable { + void readFromNBT(NBTTagCompound nbttagcompound); + + void writeToNBT(NBTTagCompound nbttagcompound); +} diff --git a/src/minecraft/forestry/api/core/IPlugin.java b/src/minecraft/forestry/api/core/IPlugin.java new file mode 100644 index 000000000..af659849a --- /dev/null +++ b/src/minecraft/forestry/api/core/IPlugin.java @@ -0,0 +1,17 @@ +package forestry.api.core; + +/** + * Plugins get loaded at the beginning of Forestry's ModsLoaded() if isAvailable() returns true. + * + * @author SirSengir + */ +public interface IPlugin { + public boolean isAvailable(); + + public void preInit(); + + public void doInit(); + + public void postInit(); + +} diff --git a/src/minecraft/forestry/api/core/IStructureLogic.java b/src/minecraft/forestry/api/core/IStructureLogic.java new file mode 100644 index 000000000..500613a9b --- /dev/null +++ b/src/minecraft/forestry/api/core/IStructureLogic.java @@ -0,0 +1,15 @@ +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/minecraft/forestry/api/core/ITextureManager.java b/src/minecraft/forestry/api/core/ITextureManager.java new file mode 100644 index 000000000..7fc324e7c --- /dev/null +++ b/src/minecraft/forestry/api/core/ITextureManager.java @@ -0,0 +1,14 @@ +package forestry.api.core; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.Icon; + +@SideOnly(Side.CLIENT) +public interface ITextureManager { + + void registerIconProvider(IIconProvider provider); + + Icon getIcon(short texUID); + +} diff --git a/src/minecraft/forestry/api/core/ITileStructure.java b/src/minecraft/forestry/api/core/ITileStructure.java new file mode 100644 index 000000000..69c149fe2 --- /dev/null +++ b/src/minecraft/forestry/api/core/ITileStructure.java @@ -0,0 +1,55 @@ +package forestry.api.core; + +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; + +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/minecraft/forestry/api/core/ItemInterface.java b/src/minecraft/forestry/api/core/ItemInterface.java new file mode 100644 index 000000000..fd17e1252 --- /dev/null +++ b/src/minecraft/forestry/api/core/ItemInterface.java @@ -0,0 +1,117 @@ +package forestry.api.core; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.FMLLog; + +public class ItemInterface { + + /** + * Get yer items here! + * + * Blocks currently not supported. + * + * @param ident + * @return + */ + 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 obj = Class.forName(itemClass).getField(ident).get(null); + if (obj instanceof Item) + item = new ItemStack((Item) obj); + else if (obj instanceof ItemStack) + item = (ItemStack) obj; + } catch (Exception ex) { + FMLLog.warning("Could not retrieve Forestry item identified by: " + ident); + } + + return item; + } + + /* + * public static Item fertilizerBio; public static Item fertilizerCompound; public static Item apatite; + * + * // Ingots public static ItemStack ingotCopper; public static ItemStack ingotTin; public static ItemStack ingotBronze; + * + * public static Item wrench; public static Item bucketBiomass; public static Item vialEmpty; public static Item vialCatalyst; public static Item + * liquidBiomass; public static Item liquidBiofuel; public static Item bucketBiofuel; public static Item liquidMilk; + * + * // Crafting public static Item sturdyMachine; public static Item hardenedMachine; public static Item craftingMaterial; + * + * // Rainmaker public static Item iodineCapsule; + * + * // Gears public static Item gearBronze; public static Item gearCopper; public static Item gearTin; + * + * // Carpenter public static Item oakStick; public static Item woodPulp; public static Item carton; public static Item crate; + * + * // Tools public static Item bronzePickaxe; public static Item brokenBronzePickaxe; public static Item kitPickaxe; public static Item bronzeShovel; public + * static Item brokenBronzeShovel; public static Item kitShovel; + * + * // Do not touch - contagious! public static Item tent; + * + * // Moistener public static Item mouldyWheat; public static Item decayingWheat; public static Item mulch; + * + * // Peat public static Item peat; public static Item bituminousPeat; public static Item ash; + * + * // Bees public static Item beeQueen; public static Item beeDrone; public static Item beePrincess; public static Item beeQueenGE; public static Item + * beeDroneGE; public static Item beePrincessGE; + * + * public static Item beealyzer; + * + * public static Item honeyDrop; public static Item scoop; public static Item beeswax; public static Item pollen; public static Item propolis; public static + * Item honeydew; public static Item royalJelly; public static Item honeyedSlice; public static Item shortMead; public static Item ambrosia; public static + * Item honeyPot; public static Item phosphor; public static Item refractoryWax; + * + * // Apiarist's Armor public static Item apiaristHat; public static Item apiaristChest; public static Item apiaristLegs; public static Item apiaristBoots; + * + * // Combs public static Item beeComb; + * + * public static Item honeyComb; public static Item cocoaComb; public static Item simmeringComb; public static Item stringyComb; public static Item + * frozenComb; public static Item drippingComb; + * + * // Backpacks public static Item apiaristBackpack; public static Item minerBackpack; public static Item diggerBackpack; public static Item + * foresterBackpack; public static Item hunterBackpack; public static Item masonBackpack; // unused/null public static Item dyerBackpack; // unused/null + * public static Item railroaderBackpack; // unused/null public static Item tinkererBackpack; // unused/null public static Item adventurerBackpack; // T2 + * public static Item minerBackpackT2; public static Item diggerBackpackT2; public static Item foresterBackpackT2; public static Item hunterBackpackT2; + * public static Item masonBackpackT2; // unused/null public static Item dyerBackpackT2; // unused/null public static Item railroaderBackpackT2; // + * unused/null public static Item tinkererBackpackT2; // unused/null public static Item adventurerBackpackT2; + * + * // Liquids public static Item liquidSeedOil; public static Item liquidJuice; public static Item liquidHoney; + * + * // Capsules public static Item waxCapsule; public static Item waxCapsuleWater; public static Item waxCapsuleBiomass; public static Item + * waxCapsuleBiofuel; public static Item waxCapsuleOil; public static Item waxCapsuleFuel; public static Item waxCapsuleSeedOil; public static Item + * waxCapsuleHoney; public static Item waxCapsuleJuice; + * + * // Refractory Capsules public static Item refractoryEmpty; public static Item refractoryWater; public static Item refractoryBiomass; public static Item + * refractoryBiofuel; public static Item refractoryOil; public static Item refractoryFuel; public static Item refractoryLava; public static Item + * refractorySeedOil; public static Item refractoryHoney; public static Item refractoryJuice; + * + * // Cans public static Item canWater; public static Item canEmpty; public static Item canBiomass; public static Item canBiofuel; public static Item + * canOil; public static Item canFuel; public static Item canLava; public static Item canSeedOil; public static Item canHoney; public static Item canJuice; + * + * // Crating public static ItemGenericCrate cratedWood; public static ItemGenericCrate cratedCobblestone; public static ItemGenericCrate cratedDirt; public + * static ItemGenericCrate cratedStone; public static ItemGenericCrate cratedBrick; public static ItemGenericCrate cratedCacti; public static + * ItemGenericCrate cratedSand; public static ItemGenericCrate cratedObsidian; public static ItemGenericCrate cratedNetherrack; public static + * ItemGenericCrate cratedSoulsand; public static ItemGenericCrate cratedSandstone; public static ItemGenericCrate cratedBogearth; public static + * ItemGenericCrate cratedHumus; public static ItemGenericCrate cratedNetherbrick; public static ItemGenericCrate cratedPeat; public static ItemGenericCrate + * cratedApatite; public static ItemGenericCrate cratedFertilizer; public static ItemGenericCrate cratedTin; public static ItemGenericCrate cratedCopper; + * public static ItemGenericCrate cratedBronze; public static ItemGenericCrate cratedWheat; public static ItemGenericCrate cratedMycelium; public static + * ItemGenericCrate cratedMulch; public static ItemGenericCrate cratedSilver; public static ItemGenericCrate cratedBrass; public static ItemGenericCrate + * cratedNikolite; public static ItemGenericCrate cratedCookies; public static ItemGenericCrate cratedHoneycombs; public static ItemGenericCrate + * cratedBeeswax; public static ItemGenericCrate cratedPollen; public static ItemGenericCrate cratedPropolis; public static ItemGenericCrate cratedHoneydew; + * public static ItemGenericCrate cratedRoyalJelly; public static ItemGenericCrate cratedCocoaComb; public static ItemGenericCrate cratedRedstone; public + * static ItemGenericCrate cratedLapis; public static ItemGenericCrate cratedReeds; public static ItemGenericCrate cratedClay; public static + * ItemGenericCrate cratedGlowstone; public static ItemGenericCrate cratedApples; public static ItemGenericCrate cratedNetherwart; public static + * ItemGenericCrate cratedResin; public static ItemGenericCrate cratedRubber; public static ItemGenericCrate cratedScrap; public static ItemGenericCrate + * cratedUUM; public static ItemGenericCrate cratedSimmeringCombs; public static ItemGenericCrate cratedStringyCombs; public static ItemGenericCrate + * cratedFrozenCombs; public static ItemGenericCrate cratedDrippingCombs; public static ItemGenericCrate cratedRefractoryWax; public static ItemGenericCrate + * cratedPhosphor; public static ItemGenericCrate cratedAsh; public static ItemGenericCrate cratedCharcoal; public static ItemGenericCrate cratedGravel; + * public static ItemGenericCrate cratedCoal; public static ItemGenericCrate cratedSeeds; public static ItemGenericCrate cratedSaplings; + */ + +} diff --git a/src/minecraft/forestry/api/core/PluginInfo.java b/src/minecraft/forestry/api/core/PluginInfo.java new file mode 100644 index 000000000..627d55472 --- /dev/null +++ b/src/minecraft/forestry/api/core/PluginInfo.java @@ -0,0 +1,49 @@ +package forestry.api.core; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * 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/minecraft/forestry/api/core/Tabs.java b/src/minecraft/forestry/api/core/Tabs.java new file mode 100644 index 000000000..985fafbdc --- /dev/null +++ b/src/minecraft/forestry/api/core/Tabs.java @@ -0,0 +1,10 @@ +package forestry.api.core; + +import net.minecraft.creativetab.CreativeTabs; + +public class Tabs { + + public static CreativeTabs tabApiculture; + public static CreativeTabs tabArboriculture; + +} diff --git a/src/minecraft/forestry/api/farming/Farmables.java b/src/minecraft/forestry/api/farming/Farmables.java new file mode 100644 index 000000000..b307c3780 --- /dev/null +++ b/src/minecraft/forestry/api/farming/Farmables.java @@ -0,0 +1,15 @@ +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/minecraft/forestry/api/farming/ICrop.java b/src/minecraft/forestry/api/farming/ICrop.java new file mode 100644 index 000000000..bad171ae2 --- /dev/null +++ b/src/minecraft/forestry/api/farming/ICrop.java @@ -0,0 +1,16 @@ +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/minecraft/forestry/api/farming/IFarmComponent.java b/src/minecraft/forestry/api/farming/IFarmComponent.java new file mode 100644 index 000000000..bf30de490 --- /dev/null +++ b/src/minecraft/forestry/api/farming/IFarmComponent.java @@ -0,0 +1,12 @@ +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/minecraft/forestry/api/farming/IFarmHousing.java b/src/minecraft/forestry/api/farming/IFarmHousing.java new file mode 100644 index 000000000..8ba6d227f --- /dev/null +++ b/src/minecraft/forestry/api/farming/IFarmHousing.java @@ -0,0 +1,68 @@ +package forestry.api.farming; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.liquids.LiquidStack; + +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(LiquidStack liquid); + + void removeLiquid(LiquidStack 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/minecraft/forestry/api/farming/IFarmInterface.java b/src/minecraft/forestry/api/farming/IFarmInterface.java new file mode 100644 index 000000000..d784876f8 --- /dev/null +++ b/src/minecraft/forestry/api/farming/IFarmInterface.java @@ -0,0 +1,15 @@ +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/minecraft/forestry/api/farming/IFarmListener.java b/src/minecraft/forestry/api/farming/IFarmListener.java new file mode 100644 index 000000000..f3c1069bb --- /dev/null +++ b/src/minecraft/forestry/api/farming/IFarmListener.java @@ -0,0 +1,71 @@ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.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/minecraft/forestry/api/farming/IFarmLogic.java b/src/minecraft/forestry/api/farming/IFarmLogic.java new file mode 100644 index 000000000..f8c2b00d4 --- /dev/null +++ b/src/minecraft/forestry/api/farming/IFarmLogic.java @@ -0,0 +1,31 @@ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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) + Icon getIcon(); + + String getName(); +} diff --git a/src/minecraft/forestry/api/farming/IFarmable.java b/src/minecraft/forestry/api/farming/IFarmable.java new file mode 100644 index 000000000..e3110ca4c --- /dev/null +++ b/src/minecraft/forestry/api/farming/IFarmable.java @@ -0,0 +1,54 @@ +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/minecraft/forestry/api/food/BeverageManager.java b/src/minecraft/forestry/api/food/BeverageManager.java new file mode 100644 index 000000000..35efb5d60 --- /dev/null +++ b/src/minecraft/forestry/api/food/BeverageManager.java @@ -0,0 +1,8 @@ +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/minecraft/forestry/api/food/IBeverageEffect.java b/src/minecraft/forestry/api/food/IBeverageEffect.java new file mode 100644 index 000000000..14b91b130 --- /dev/null +++ b/src/minecraft/forestry/api/food/IBeverageEffect.java @@ -0,0 +1,12 @@ +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/minecraft/forestry/api/food/IInfuserManager.java b/src/minecraft/forestry/api/food/IInfuserManager.java new file mode 100644 index 000000000..87527731e --- /dev/null +++ b/src/minecraft/forestry/api/food/IInfuserManager.java @@ -0,0 +1,17 @@ +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/minecraft/forestry/api/food/IIngredientManager.java b/src/minecraft/forestry/api/food/IIngredientManager.java new file mode 100644 index 000000000..a7851c973 --- /dev/null +++ b/src/minecraft/forestry/api/food/IIngredientManager.java @@ -0,0 +1,11 @@ +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/minecraft/forestry/api/fuels/EngineBronzeFuel.java b/src/minecraft/forestry/api/fuels/EngineBronzeFuel.java new file mode 100644 index 000000000..b65857776 --- /dev/null +++ b/src/minecraft/forestry/api/fuels/EngineBronzeFuel.java @@ -0,0 +1,29 @@ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class EngineBronzeFuel { + /** + * Item that is valid fuel for a biogas engine. + */ + public final ItemStack 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(ItemStack liquid, int powerPerCycle, int burnDuration, int dissipationMultiplier) { + this.liquid = liquid; + this.powerPerCycle = powerPerCycle; + this.burnDuration = burnDuration; + this.dissipationMultiplier = dissipationMultiplier; + } +} diff --git a/src/minecraft/forestry/api/fuels/EngineCopperFuel.java b/src/minecraft/forestry/api/fuels/EngineCopperFuel.java new file mode 100644 index 000000000..bb2d817b1 --- /dev/null +++ b/src/minecraft/forestry/api/fuels/EngineCopperFuel.java @@ -0,0 +1,26 @@ +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/minecraft/forestry/api/fuels/FermenterFuel.java b/src/minecraft/forestry/api/fuels/FermenterFuel.java new file mode 100644 index 000000000..6d7cf379b --- /dev/null +++ b/src/minecraft/forestry/api/fuels/FermenterFuel.java @@ -0,0 +1,24 @@ +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/minecraft/forestry/api/fuels/FuelManager.java b/src/minecraft/forestry/api/fuels/FuelManager.java new file mode 100644 index 000000000..c1125e5f5 --- /dev/null +++ b/src/minecraft/forestry/api/fuels/FuelManager.java @@ -0,0 +1,30 @@ +package forestry.api.fuels; + +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +public class FuelManager { + /** + * Add new fuels for the fermenter here (i.e. fertilizer) + */ + public static HashMap fermenterFuel = new ItemStackMap(); + /** + * Add new resources for the moistener here (i.e. wheat) + */ + public static HashMap moistenerResource = new ItemStackMap(); + /** + * Add new substrates for the rainmaker here + */ + public static HashMap rainSubstrate = new ItemStackMap(); + /** + * Add new fuels for EngineBronze (= biogas engine) here + */ + public static HashMap bronzeEngineFuel = new ItemStackMap(); + /** + * Add new fuels for EngineCopper (= peat-fired engine) here + */ + public static HashMap copperEngineFuel = new ItemStackMap(); + + // Generator fuel list in GeneratorFuel.class +} diff --git a/src/minecraft/forestry/api/fuels/GeneratorFuel.java b/src/minecraft/forestry/api/fuels/GeneratorFuel.java new file mode 100644 index 000000000..20c1b67d2 --- /dev/null +++ b/src/minecraft/forestry/api/fuels/GeneratorFuel.java @@ -0,0 +1,30 @@ +package forestry.api.fuels; + +import java.util.HashMap; + +import net.minecraftforge.liquids.LiquidStack; + +public class GeneratorFuel { + + public static HashMap fuels = new HashMap(); + + /** + * LiquidStack representing the fuel type and amount consumed per triggered cycle. + */ + public final LiquidStack 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(LiquidStack fuelConsumed, int eu, int rate) { + this.fuelConsumed = fuelConsumed; + this.eu = eu; + this.rate = rate; + } + +} diff --git a/src/minecraft/forestry/api/fuels/ItemStackMap.java b/src/minecraft/forestry/api/fuels/ItemStackMap.java new file mode 100644 index 000000000..f85181b18 --- /dev/null +++ b/src/minecraft/forestry/api/fuels/ItemStackMap.java @@ -0,0 +1,57 @@ +package forestry.api.fuels; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.liquids.LiquidStack; + +public class ItemStackMap extends HashMap { + + private static final long serialVersionUID = 5383477742290646466L; + + @Override + public boolean containsKey(Object key) { + for (Map.Entry entry : this.entrySet()) + if (areItemStacksEqual(entry.getKey(), key)) + return true; + return super.containsKey(key); + } + + @Override + public T remove(Object key) { + Iterator> iterator = this.entrySet().iterator(); + ; + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + if (areItemStacksEqual(entry.getKey(), key)) + iterator.remove(); + } + return super.remove(key); + } + + @Override + public T get(Object key) { + for (Map.Entry entry : this.entrySet()) + if (areItemStacksEqual(entry.getKey(), key)) + return entry.getValue(); + return super.get(key); + } + + private boolean areItemStacksEqual(ItemStack a, Object b) { + if (a == null || b == null) + return false; + if (b instanceof ItemStack) + return ItemStack.areItemStackTagsEqual(a, (ItemStack) b) && a.isItemEqual((ItemStack) b); + else if (b instanceof LiquidStack) + return ItemStack.areItemStackTagsEqual(a, ((LiquidStack) b).asItemStack()) && a.isItemEqual(((LiquidStack) b).asItemStack()); + else if (b instanceof Integer) + return ((Integer) b).equals(a.itemID); + else if (b instanceof Item) + return ((Item) b).itemID == a.itemID; + return false; + } + +} diff --git a/src/minecraft/forestry/api/fuels/MoistenerFuel.java b/src/minecraft/forestry/api/fuels/MoistenerFuel.java new file mode 100644 index 000000000..15bbb1b88 --- /dev/null +++ b/src/minecraft/forestry/api/fuels/MoistenerFuel.java @@ -0,0 +1,29 @@ +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/minecraft/forestry/api/fuels/RainSubstrate.java b/src/minecraft/forestry/api/fuels/RainSubstrate.java new file mode 100644 index 000000000..7aac5bce7 --- /dev/null +++ b/src/minecraft/forestry/api/fuels/RainSubstrate.java @@ -0,0 +1,35 @@ +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/minecraft/forestry/api/genetics/AlleleManager.java b/src/minecraft/forestry/api/genetics/AlleleManager.java new file mode 100644 index 000000000..7ae88448a --- /dev/null +++ b/src/minecraft/forestry/api/genetics/AlleleManager.java @@ -0,0 +1,42 @@ +package forestry.api.genetics; + +import java.util.HashMap; + +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.FMLLog; + +public class AlleleManager { + + public static IAlleleRegistry alleleRegistry; + + /** + * Translates plain leaf blocks into genetic data. Used by bees 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(); + + /** + * @deprecated Use IAlleleRegistry.getAllele instead! + */ + @Deprecated + public static IAllele getAllele(String ident) { + IAllele allele = null; + + try { + + String alleleClass = "forestry.core.genetics.Allele"; + + Object obj = Class.forName(alleleClass).getField(ident).get(null); + if (obj instanceof IAllele) + allele = (IAllele) obj; + } catch (Exception ex) { + FMLLog.warning("Could not retrieve bee allele identified by: " + ident); + } + + return allele; + } + +} diff --git a/src/minecraft/forestry/api/genetics/EnumTolerance.java b/src/minecraft/forestry/api/genetics/EnumTolerance.java new file mode 100644 index 000000000..a30f64f23 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/EnumTolerance.java @@ -0,0 +1,11 @@ +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/minecraft/forestry/api/genetics/IAllele.java b/src/minecraft/forestry/api/genetics/IAllele.java new file mode 100644 index 000000000..67921dc5c --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IAllele.java @@ -0,0 +1,17 @@ +package forestry.api.genetics; + +/** + * Should be extended for different types of alleles. ISpeciesAllele, IBiomeAllele, etc. + */ +public interface IAllele { + + /** + * @return A unique string identifier for this allele. + */ + String getUID(); + + /** + * @return true if the allele is dominant, false otherwise. + */ + boolean isDominant(); +} diff --git a/src/minecraft/forestry/api/genetics/IAlleleEffect.java b/src/minecraft/forestry/api/genetics/IAlleleEffect.java new file mode 100644 index 000000000..2e08148c7 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IAlleleEffect.java @@ -0,0 +1,23 @@ +package forestry.api.genetics; + +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 + */ + IEffectData validateStorage(IEffectData storedData); + + /** + * @return Short, human-readable identifier used in the beealyzer. + */ + String getIdentifier(); + +} diff --git a/src/minecraft/forestry/api/genetics/IAlleleFloat.java b/src/minecraft/forestry/api/genetics/IAlleleFloat.java new file mode 100644 index 000000000..2ace6d1d5 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IAlleleFloat.java @@ -0,0 +1,10 @@ +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/minecraft/forestry/api/genetics/IAlleleHandler.java b/src/minecraft/forestry/api/genetics/IAlleleHandler.java new file mode 100644 index 000000000..593351b2e --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IAlleleHandler.java @@ -0,0 +1,36 @@ +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/minecraft/forestry/api/genetics/IAlleleInteger.java b/src/minecraft/forestry/api/genetics/IAlleleInteger.java new file mode 100644 index 000000000..61e089e35 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IAlleleInteger.java @@ -0,0 +1,10 @@ +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/minecraft/forestry/api/genetics/IAlleleRegistry.java b/src/minecraft/forestry/api/genetics/IAlleleRegistry.java new file mode 100644 index 000000000..77e35845a --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IAlleleRegistry.java @@ -0,0 +1,154 @@ +package forestry.api.genetics; + +import java.util.ArrayList; +import java.util.LinkedHashMap; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import forestry.api.genetics.IClassification.EnumClassLevel; + +public interface IAlleleRegistry { + + /* 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. + */ + LinkedHashMap getRegisteredAlleles(); + + /** + * Registers an allele. + * + * @param allele + * IAllele to register. + */ + void registerAllele(IAllele allele); + + /** + * Gets an allele + * + * @param uid + * String based unique identifier of the allele to retrieve. + * @return IAllele if found, 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. + */ + LinkedHashMap 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 + */ + IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific); + + /** + * Gets a classification. + * + * @param uid + * String based unique identifier of the classification to retrieve. + * @return Classification if found, null otherwise. + */ + IClassification getClassification(String uid); + + /* FRUIT FAMILIES */ + /** + * Get all registered fruit families. + * + * @return + */ + LinkedHashMap getRegisteredFruitFamilies(); + + /** + * Registers a new fruit family. + * + * @param family + */ + void registerFruitFamily(IFruitFamily family); + + /** + * Retrieves a fruit family identified by uid. + * + * @param uid + * @return + */ + 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. + */ + ArrayList getAlleleBlacklist(); + + /** + * @param uid + * UID of the species to vet. + * @return true if the allele is blacklisted. + */ + boolean isBlacklisted(String uid); + +} diff --git a/src/minecraft/forestry/api/genetics/IAlleleSpecies.java b/src/minecraft/forestry/api/genetics/IAlleleSpecies.java new file mode 100644 index 000000000..1b8546fe9 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IAlleleSpecies.java @@ -0,0 +1,68 @@ +package forestry.api.genetics; + +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; + +public interface IAlleleSpecies extends IAllele { + /** + * @return Localized short, human-readable identifier used in tooltips and beealyzer. + */ + String getName(); + + /** + * @return Localized short description of this species. (May be null.) + */ + String getDescription(); + + /** + * @return Preferred temperature + */ + EnumTemperature getTemperature(); + + /** + * @return Preferred humidity + */ + EnumHumidity getHumidity(); + + /** + * @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(); + + /** + * 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(); + + @SideOnly(Side.CLIENT) + IIconProvider getIconProvider(); + +} diff --git a/src/minecraft/forestry/api/genetics/IBreedingTracker.java b/src/minecraft/forestry/api/genetics/IBreedingTracker.java new file mode 100644 index 000000000..76f251439 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IBreedingTracker.java @@ -0,0 +1,75 @@ +package forestry.api.genetics; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import forestry.api.apiculture.IBeekeepingMode; + +public interface IBreedingTracker { + + void decodeFromNBT(NBTTagCompound nbttagcompound); + + void encodeToNBT(NBTTagCompound nbttagcompound); + + /** + * @return Name of the current {@link IBeekeepingMode}. + */ + String getModeName(); + + /** + * @return 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 registerIndividual(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. + * + * @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 world + * @param player + */ + void synchToPlayer(EntityPlayer player); + +} diff --git a/src/minecraft/forestry/api/genetics/IChromosome.java b/src/minecraft/forestry/api/genetics/IChromosome.java new file mode 100644 index 000000000..1a6668a1a --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IChromosome.java @@ -0,0 +1,20 @@ +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/minecraft/forestry/api/genetics/IClassification.java b/src/minecraft/forestry/api/genetics/IClassification.java new file mode 100644 index 000000000..bf9ae2359 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IClassification.java @@ -0,0 +1,97 @@ +package forestry.api.genetics; + +/** + * 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), 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; + } + } + + 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/minecraft/forestry/api/genetics/IEffectData.java b/src/minecraft/forestry/api/genetics/IEffectData.java new file mode 100644 index 000000000..2ac557d68 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IEffectData.java @@ -0,0 +1,17 @@ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +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/minecraft/forestry/api/genetics/IFruitBearer.java b/src/minecraft/forestry/api/genetics/IFruitBearer.java new file mode 100644 index 000000000..13478b764 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IFruitBearer.java @@ -0,0 +1,40 @@ +package forestry.api.genetics; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +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/minecraft/forestry/api/genetics/IFruitFamily.java b/src/minecraft/forestry/api/genetics/IFruitFamily.java new file mode 100644 index 000000000..10393b724 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IFruitFamily.java @@ -0,0 +1,27 @@ +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/minecraft/forestry/api/genetics/IGenome.java b/src/minecraft/forestry/api/genetics/IGenome.java new file mode 100644 index 000000000..955ff214a --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IGenome.java @@ -0,0 +1,21 @@ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +/** + * Implementations other than Forestry's default one are not supported! + */ +public interface IGenome extends INBTTagable { + + IAlleleSpecies getPrimary(); + + IAlleleSpecies getSecondary(); + + IChromosome[] getChromosomes(); + + IAllele getActiveAllele(int chromosome); + + IAllele getInactiveAllele(int chromosome); + + boolean isGeneticEqual(IGenome other); +} diff --git a/src/minecraft/forestry/api/genetics/IIndividual.java b/src/minecraft/forestry/api/genetics/IIndividual.java new file mode 100644 index 000000000..9a8654253 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IIndividual.java @@ -0,0 +1,41 @@ +package forestry.api.genetics; + +import java.util.List; + +import forestry.api.core.INBTTagable; + +/** + * Implementations other than Forestry's default one are not 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); + + IIndividual copy(); + +} diff --git a/src/minecraft/forestry/api/genetics/ILegacyHandler.java b/src/minecraft/forestry/api/genetics/ILegacyHandler.java new file mode 100644 index 000000000..18412e85b --- /dev/null +++ b/src/minecraft/forestry/api/genetics/ILegacyHandler.java @@ -0,0 +1,10 @@ +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/minecraft/forestry/api/genetics/IMutation.java b/src/minecraft/forestry/api/genetics/IMutation.java new file mode 100644 index 000000000..d6d6c7068 --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IMutation.java @@ -0,0 +1,62 @@ +package forestry.api.genetics; + +/** + * Bees can be seeded either as hive drops or as mutation results. + * + * Add mutations to BeeManager.beeMutations + * + * @author SirSengir + */ +public interface IMutation { + + /** + * @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. The array _must_ implement this format: + * + * Chromosome Must implement Customizable Note ----------- --------------- ------------- ------------ 0 : SPECIES IAlleleSpecies X 1 : SPEED + * AlleleFloat 2 : LIFESPAN AlleleInteger 3 : FERTILITY AlleleInteger 4 : TEMPERATURE_TOLERANCE AlleleTolerance 5 : NOCTURNAL AlleleBoolean 6 : + * (HUMIDITY) (AlleleHumidity) Not used. Anything passed into here will be nulled. 7 : HUMIDITY_TOLERANCE AlleleTolerance 8 : TOLERANT_FLYER + * AlleleBoolean 9 : CAVE_DWELLING AlleleBoolean 10: FLOWER_PROVIDER IAlleleFlowers X 11: FLOWERING AlleleInteger 12: TERRITORY AlleleArea 13: + * EFFECT IAlleleEffect X + * + * Make sure to return a proper array. Returning an allele of the wrong type will cause cast errors on runtime. + * + * Alleles marked as customizable can be populated with your own custom alleles. Make sure to register them correctly in alleleList! + * + * Other alleles must be populated with any matching pre-defined allele. Retrieve those via BeeManager.getAllele + * + */ + IAllele[] getTemplate(); + + /** + * @return Unmodified base chance for mutation to fire. + */ + int getBaseChance(); + + /** + * @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/minecraft/forestry/api/genetics/IPollinatable.java b/src/minecraft/forestry/api/genetics/IPollinatable.java new file mode 100644 index 000000000..6bdec1eaa --- /dev/null +++ b/src/minecraft/forestry/api/genetics/IPollinatable.java @@ -0,0 +1,38 @@ +package forestry.api.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +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 {@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/minecraft/forestry/api/recipes/IBottlerManager.java b/src/minecraft/forestry/api/recipes/IBottlerManager.java new file mode 100644 index 000000000..2bfc43a70 --- /dev/null +++ b/src/minecraft/forestry/api/recipes/IBottlerManager.java @@ -0,0 +1,34 @@ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.liquids.LiquidStack; + +/** + * 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.bottlerManager} + * + * 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 + * + * @param cyclesPerUnit + * Amount of work cycles required to run through the conversion once. + * @param input + * ItemStack representing the input liquid. + * @param inputAmount + * Amount of liquid required for a single conversion. + * @param can + * ItemStack representing the cans, capsules and/or cells required + * @param bottled + * ItemStack representing the finished product + */ + public void addRecipe(int cyclesPerUnit, LiquidStack input, ItemStack can, ItemStack bottled); +} diff --git a/src/minecraft/forestry/api/recipes/ICarpenterManager.java b/src/minecraft/forestry/api/recipes/ICarpenterManager.java new file mode 100644 index 000000000..b8d3ba15d --- /dev/null +++ b/src/minecraft/forestry/api/recipes/ICarpenterManager.java @@ -0,0 +1,67 @@ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraftforge.liquids.LiquidStack; + +/** + * 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.carpenterManager} + * + * 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 liquidId + * Id of liquid required in tank. Anything other than Block.waterStill.blockId is untested! + * @param liquidAmount + * Amount of liquid required to craft the recipe once. One bucket of water = one unit on the carpenter's tank = 1000. + * @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, LiquidStack 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/minecraft/forestry/api/recipes/ICentrifugeManager.java b/src/minecraft/forestry/api/recipes/ICentrifugeManager.java new file mode 100644 index 000000000..76a3948f5 --- /dev/null +++ b/src/minecraft/forestry/api/recipes/ICentrifugeManager.java @@ -0,0 +1,74 @@ +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.centrifugeManager} + * + * @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 {@link 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/minecraft/forestry/api/recipes/ICraftingProvider.java b/src/minecraft/forestry/api/recipes/ICraftingProvider.java new file mode 100644 index 000000000..e80ef69af --- /dev/null +++ b/src/minecraft/forestry/api/recipes/ICraftingProvider.java @@ -0,0 +1,19 @@ +package forestry.api.recipes; + +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +public interface ICraftingProvider { + /** + * DOES NOT WORK FOR MANY MACHINES, DON'T USE IT! + * + * 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. Input and output liquids are returned as itemstacks as + * well, representing itemID and damage. + */ + @Deprecated + public List> getRecipes(); +} diff --git a/src/minecraft/forestry/api/recipes/IFabricatorManager.java b/src/minecraft/forestry/api/recipes/IFabricatorManager.java new file mode 100644 index 000000000..3ff32afdd --- /dev/null +++ b/src/minecraft/forestry/api/recipes/IFabricatorManager.java @@ -0,0 +1,12 @@ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.liquids.LiquidStack; + +public interface IFabricatorManager extends ICraftingProvider { + + void addRecipe(ItemStack plan, LiquidStack molten, ItemStack result, Object[] pattern); + + void addSmelting(ItemStack resource, LiquidStack molten, int meltingPoint); + +} diff --git a/src/minecraft/forestry/api/recipes/IFermenterManager.java b/src/minecraft/forestry/api/recipes/IFermenterManager.java new file mode 100644 index 000000000..b311da4b9 --- /dev/null +++ b/src/minecraft/forestry/api/recipes/IFermenterManager.java @@ -0,0 +1,48 @@ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.liquids.LiquidStack; + +/** + * 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.fermenterManager} + * + * @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. + */ + public void addRecipe(ItemStack resource, int fermentationValue, float modifier, LiquidStack output, LiquidStack 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. + */ + public void addRecipe(ItemStack resource, int fermentationValue, float modifier, LiquidStack output); + +} diff --git a/src/minecraft/forestry/api/recipes/IGenericCrate.java b/src/minecraft/forestry/api/recipes/IGenericCrate.java new file mode 100644 index 000000000..814cb83aa --- /dev/null +++ b/src/minecraft/forestry/api/recipes/IGenericCrate.java @@ -0,0 +1,11 @@ +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/minecraft/forestry/api/recipes/IMoistenerManager.java b/src/minecraft/forestry/api/recipes/IMoistenerManager.java new file mode 100644 index 000000000..fe991f2e0 --- /dev/null +++ b/src/minecraft/forestry/api/recipes/IMoistenerManager.java @@ -0,0 +1,28 @@ +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.moistenerManager} + * + * @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/minecraft/forestry/api/recipes/ISqueezerManager.java b/src/minecraft/forestry/api/recipes/ISqueezerManager.java new file mode 100644 index 000000000..6d118025b --- /dev/null +++ b/src/minecraft/forestry/api/recipes/ISqueezerManager.java @@ -0,0 +1,45 @@ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.liquids.LiquidStack; + +/** + * 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.squeezerManager} + * + * @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 LiquidStack} 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, LiquidStack 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 LiquidStack} representing the output of this recipe. + */ + public void addRecipe(int timePerItem, ItemStack[] resources, LiquidStack liquid); +} diff --git a/src/minecraft/forestry/api/recipes/IStillManager.java b/src/minecraft/forestry/api/recipes/IStillManager.java new file mode 100644 index 000000000..60640499e --- /dev/null +++ b/src/minecraft/forestry/api/recipes/IStillManager.java @@ -0,0 +1,29 @@ +package forestry.api.recipes; + +import net.minecraftforge.liquids.LiquidStack; + +/** + * 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.stillManager} + * + * 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, LiquidStack input, LiquidStack output); +} diff --git a/src/minecraft/forestry/api/recipes/IVariableFermentable.java b/src/minecraft/forestry/api/recipes/IVariableFermentable.java new file mode 100644 index 000000000..ce51b1f6c --- /dev/null +++ b/src/minecraft/forestry/api/recipes/IVariableFermentable.java @@ -0,0 +1,16 @@ +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/minecraft/forestry/api/recipes/RecipeManagers.java b/src/minecraft/forestry/api/recipes/RecipeManagers.java new file mode 100644 index 000000000..5f5cbda62 --- /dev/null +++ b/src/minecraft/forestry/api/recipes/RecipeManagers.java @@ -0,0 +1,40 @@ +package forestry.api.recipes; + +/** + * Contains all available recipe managers for Forestry machines and items. + * + * @author SirSengir + */ +public class RecipeManagers { + + /** + * 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/minecraft/forestry/api/storage/BackpackEvent.java b/src/minecraft/forestry/api/storage/BackpackEvent.java new file mode 100644 index 000000000..83d06e705 --- /dev/null +++ b/src/minecraft/forestry/api/storage/BackpackEvent.java @@ -0,0 +1,18 @@ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraftforge.event.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/minecraft/forestry/api/storage/BackpackManager.java b/src/minecraft/forestry/api/storage/BackpackManager.java new file mode 100644 index 000000000..64af8cd01 --- /dev/null +++ b/src/minecraft/forestry/api/storage/BackpackManager.java @@ -0,0 +1,22 @@ +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/minecraft/forestry/api/storage/BackpackResupplyEvent.java b/src/minecraft/forestry/api/storage/BackpackResupplyEvent.java new file mode 100644 index 000000000..caa74377f --- /dev/null +++ b/src/minecraft/forestry/api/storage/BackpackResupplyEvent.java @@ -0,0 +1,18 @@ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraftforge.event.Cancelable; + +/** + * Use @ForgeSubscribe 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/minecraft/forestry/api/storage/BackpackStowEvent.java b/src/minecraft/forestry/api/storage/BackpackStowEvent.java new file mode 100644 index 000000000..94c837a31 --- /dev/null +++ b/src/minecraft/forestry/api/storage/BackpackStowEvent.java @@ -0,0 +1,21 @@ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.Cancelable; + +/** + * Use @ForgeSubscribe 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/minecraft/forestry/api/storage/EnumBackpackType.java b/src/minecraft/forestry/api/storage/EnumBackpackType.java new file mode 100644 index 000000000..13faf87b6 --- /dev/null +++ b/src/minecraft/forestry/api/storage/EnumBackpackType.java @@ -0,0 +1,5 @@ +package forestry.api.storage; + +public enum EnumBackpackType { + T1, T2 +} diff --git a/src/minecraft/forestry/api/storage/IBackpackDefinition.java b/src/minecraft/forestry/api/storage/IBackpackDefinition.java new file mode 100644 index 000000000..002bc0209 --- /dev/null +++ b/src/minecraft/forestry/api/storage/IBackpackDefinition.java @@ -0,0 +1,54 @@ +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 getValidItems(EntityPlayer player); + + /** + * Returns true if the itemstack is a valid item for this backpack type. + * + * @param player + * @param itemstack + * @return + */ + boolean isValidItem(EntityPlayer player, ItemStack itemstack); + +} \ No newline at end of file diff --git a/src/minecraft/forestry/api/storage/IBackpackInterface.java b/src/minecraft/forestry/api/storage/IBackpackInterface.java new file mode 100644 index 000000000..0012fab11 --- /dev/null +++ b/src/minecraft/forestry/api/storage/IBackpackInterface.java @@ -0,0 +1,19 @@ +package forestry.api.storage; + +import net.minecraft.item.Item; + +public interface IBackpackInterface { + + /** + * Adds a backpack with the given id, definition and type, returning the item. + * + * @param itemID + * Item id to use. + * @param definition + * Definition of backpack behaviour. + * @param type + * Type of backpack. (T1 or T2 (= Woven) + * @return Created backpack item. + */ + Item addBackpack(int itemID, IBackpackDefinition definition, EnumBackpackType type); +} diff --git a/src/minecraft/forestry/api/world/ITreeGenData.java b/src/minecraft/forestry/api/world/ITreeGenData.java new file mode 100644 index 000000000..c43d8bb87 --- /dev/null +++ b/src/minecraft/forestry/api/world/ITreeGenData.java @@ -0,0 +1,18 @@ +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/minecraft/forestry/api/world/IWorldGenInterface.java b/src/minecraft/forestry/api/world/IWorldGenInterface.java new file mode 100644 index 000000000..bff246648 --- /dev/null +++ b/src/minecraft/forestry/api/world/IWorldGenInterface.java @@ -0,0 +1,17 @@ +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/minecraft/forestry/api/world/WorldGenManager.java b/src/minecraft/forestry/api/world/WorldGenManager.java new file mode 100644 index 000000000..b2147a647 --- /dev/null +++ b/src/minecraft/forestry/api/world/WorldGenManager.java @@ -0,0 +1,5 @@ +package forestry.api.world; + +public class WorldGenManager { + public static IWorldGenInterface worldgenInterface; +} diff --git a/src/minecraft/tdwp_ftw/biomesop/declarations/BOPBiomes.java b/src/minecraft/tdwp_ftw/biomesop/declarations/BOPBiomes.java index 7d5d422a3..60a426837 100644 --- a/src/minecraft/tdwp_ftw/biomesop/declarations/BOPBiomes.java +++ b/src/minecraft/tdwp_ftw/biomesop/declarations/BOPBiomes.java @@ -88,6 +88,8 @@ import tdwp_ftw.biomesop.worldtype.WTBiomesOP; import com.google.common.base.Optional; import cpw.mods.fml.common.registry.GameRegistry; +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; public class BOPBiomes { @@ -442,7 +444,173 @@ public class BOPBiomes { addStrongholdBiome(Biomes.taigaNew); addStrongholdBiome(Biomes.swamplandNew); addStrongholdBiome(Biomes.jungleNew); - + + //Hottest to Coldest + EnumTemperature.hellishBiomeIds.add(BOPConfiguration.deadlandsID); + EnumTemperature.hellishBiomeIds.add(BOPConfiguration.volcanoID); + + EnumHumidity.aridBiomeIds.add(BOPConfiguration.deadlandsID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.volcanoID); + + //Hot - Arid + EnumTemperature.hotBiomeIds.add(BOPConfiguration.badlandsID); + EnumTemperature.hotBiomeIds.add(BOPConfiguration.dunesID); + EnumTemperature.hotBiomeIds.add(BOPConfiguration.mesaID); + EnumTemperature.hotBiomeIds.add(BOPConfiguration.wastelandID); + + EnumHumidity.aridBiomeIds.add(BOPConfiguration.badlandsID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.dunesID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.mesaID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.wastelandID); + + //Hot - Damp + EnumTemperature.hotBiomeIds.add(BOPConfiguration.lushDesertID); + EnumTemperature.hotBiomeIds.add(BOPConfiguration.oasisID); + + EnumHumidity.dampBiomeIds.add(BOPConfiguration.lushDesertID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.oasisID); + + //Warm - Damp + EnumTemperature.warmBiomeIds.add(BOPConfiguration.bambooForestID); + EnumTemperature.warmBiomeIds.add(BOPConfiguration.rainforestID); + EnumTemperature.warmBiomeIds.add(BOPConfiguration.sacredSpringsID); + EnumTemperature.warmBiomeIds.add(BOPConfiguration.temperateRainforestID); + EnumTemperature.warmBiomeIds.add(BOPConfiguration.tropicalRainforestID); + EnumTemperature.warmBiomeIds.add(BOPConfiguration.tropicsID); + + EnumHumidity.dampBiomeIds.add(BOPConfiguration.bambooForestID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.rainforestID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.sacredSpringsID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.temperateRainforestID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.tropicalRainforestID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.tropicsID); + + //Normal - Damp + EnumTemperature.normalBiomeIds.add(BOPConfiguration.bayouID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.bogID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.deadSwampID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.fenID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.fungiForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.lushSwampID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.moorID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.ominousWoodsID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.quagmireID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.shieldID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.swampwoodsID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.wetlandID); + + EnumHumidity.dampBiomeIds.add(BOPConfiguration.bayouID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.bogID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.deadSwampID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.fenID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.fungiForestID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.lushSwampID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.moorID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.ominousWoodsID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.quagmireID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.shieldID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.swampwoodsID); + EnumHumidity.dampBiomeIds.add(BOPConfiguration.wetlandID); + + //Normal + EnumTemperature.normalBiomeIds.add(BOPConfiguration.birchForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.borealForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.chaparralID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.cherryBlossomGroveID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.coniferousForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.deciduousForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.fieldID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.gardenID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.grasslandID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.groveID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.highlandID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.jadeCliffsID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.mapleWoodsID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.meadowID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.mountainID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.mysticGroveID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.orchardID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.prairieID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.redwoodForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.seasonalForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.spruceWoodsID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.thicketID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.woodlandID); + + EnumHumidity.normalBiomeIds.add(BOPConfiguration.birchForestID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.borealForestID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.chaparralID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.cherryBlossomGroveID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.coniferousForestID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.deciduousForestID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.fieldID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.gardenID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.grasslandID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.groveID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.highlandID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.jadeCliffsID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.mapleWoodsID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.meadowID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.mountainID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.mysticGroveID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.orchardID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.prairieID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.redwoodForestID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.seasonalForestID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.spruceWoodsID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.thicketID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.woodlandID); + + //Normal - Arid + EnumTemperature.normalBiomeIds.add(BOPConfiguration.canyonID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.cragID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.deadForestID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.drylandsID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.heathlandID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.outbackID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.pastureID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.savannaID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.scrublandID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.shrublandID); + EnumTemperature.normalBiomeIds.add(BOPConfiguration.steppeID); + + EnumHumidity.aridBiomeIds.add(BOPConfiguration.canyonID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.cragID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.deadForestID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.drylandsID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.heathlandID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.outbackID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.pastureID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.savannaID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.scrublandID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.shrublandID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.steppeID); + + //Cold + EnumTemperature.coldBiomeIds.add(BOPConfiguration.tundraID); + EnumTemperature.coldBiomeIds.add(BOPConfiguration.snowyWoodsID); + + EnumHumidity.normalBiomeIds.add(BOPConfiguration.tundraID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.snowyWoodsID); + + //Icy + EnumTemperature.icyBiomeIds.add(BOPConfiguration.alpsID); + EnumTemperature.icyBiomeIds.add(BOPConfiguration.arcticID); + EnumTemperature.icyBiomeIds.add(BOPConfiguration.frostForestID); + + EnumHumidity.normalBiomeIds.add(BOPConfiguration.alpsID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.arcticID); + EnumHumidity.normalBiomeIds.add(BOPConfiguration.frostForestID); + + //Icy - Arid + EnumTemperature.icyBiomeIds.add(BOPConfiguration.glacierID); + EnumTemperature.icyBiomeIds.add(BOPConfiguration.iceSheetID); + EnumTemperature.icyBiomeIds.add(BOPConfiguration.icyHillsID); + + EnumHumidity.aridBiomeIds.add(BOPConfiguration.glacierID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.iceSheetID); + EnumHumidity.aridBiomeIds.add(BOPConfiguration.icyHillsID); + if (BOPConfiguration.addToDefault == true) { if (BOPConfiguration.alpsGen == true) diff --git a/src/minecraft/tdwp_ftw/biomesop/items/projectiles/EntityMudball.java b/src/minecraft/tdwp_ftw/biomesop/items/projectiles/EntityMudball.java index 2c83d5850..4f4c5168e 100644 --- a/src/minecraft/tdwp_ftw/biomesop/items/projectiles/EntityMudball.java +++ b/src/minecraft/tdwp_ftw/biomesop/items/projectiles/EntityMudball.java @@ -7,10 +7,13 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; +import tdwp_ftw.biomesop.ClientProxy; import tdwp_ftw.biomesop.mod_BiomesOPlenty; public class EntityMudball extends EntityThrowable { + boolean isClient = mod_BiomesOPlenty.proxy instanceof ClientProxy; + public EntityMudball(World par1World) { super(par1World); @@ -36,9 +39,12 @@ public class EntityMudball extends EntityThrowable ((EntityLiving)par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 300)); } - for (int i = 0; i < 16; ++i) + if (isClient) { - mod_BiomesOPlenty.proxy.spawnMud(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + for (int i = 0; i < 16; ++i) + { + mod_BiomesOPlenty.proxy.spawnMud(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + } } if (!this.worldObj.isRemote) diff --git a/src/minecraft/tdwp_ftw/biomesop/worldtype/WorldTypeBase.java b/src/minecraft/tdwp_ftw/biomesop/worldtype/WorldTypeBase.java index e58dfeb52..8ba9b2302 100644 --- a/src/minecraft/tdwp_ftw/biomesop/worldtype/WorldTypeBase.java +++ b/src/minecraft/tdwp_ftw/biomesop/worldtype/WorldTypeBase.java @@ -4,7 +4,6 @@ import net.minecraft.world.World; import net.minecraft.world.WorldType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.WorldChunkManager; -import net.minecraft.world.chunk.IChunkProvider; public class WorldTypeBase extends WorldType {