Test with stuff + Forestry potential support

This commit is contained in:
WayofTime 2014-01-25 20:36:28 -05:00
parent 5b05cf651b
commit bd26e441cb
174 changed files with 5602 additions and 0 deletions

View file

@ -0,0 +1,40 @@
package forestry.api.apiculture;
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IMutation;
/**
*
* Some miscellaneous lists and settings for bees.
*
* @author SirSengir
*/
public class BeeManager {
/**
* Get your own reference to this via AlleleManager.alleleRegistry.getSpeciesRoot("rootBees") and save it somewhere.
*/
@Deprecated
public static IBeeRoot beeInterface;
/**
* Species templates for bees that can drop from hives.
*
* 0 - Forest 1 - Meadows 2 - Desert 3 - Jungle 4 - End 5 - Snow 6 - Swamp
*
* see {@link IMutation} for template format
*/
public static ArrayList<IHiveDrop>[] hiveDrops;
/**
* 0 - Common Village Bees 1 - Uncommon Village Bees (20 % of spawns)
*/
public static ArrayList<IBeeGenome>[] villageBees;
/**
* List of items that can induce swarming. Integer denotes x in 1000 chance.
*/
public static HashMap<ItemStack, Integer> inducers = new HashMap<ItemStack, Integer>();
}

View file

@ -0,0 +1,98 @@
package forestry.api.apiculture;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleArea;
import forestry.api.genetics.IAlleleBoolean;
import forestry.api.genetics.IAlleleFloat;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot;
/**
* Enum representing the order of chromosomes in a bee's genome and what they control.
*
* @author SirSengir
*/
public enum EnumBeeChromosome implements IChromosomeType {
/**
* Species of the bee. Alleles here must implement {@link IAlleleBeeSpecies}.
*/
SPECIES(IAlleleBeeSpecies.class),
/**
* (Production) Speed of the bee.
*/
SPEED(IAlleleFloat.class),
/**
* Lifespan of the bee.
*/
LIFESPAN(IAlleleInteger.class),
/**
* Fertility of the bee. Determines number of offspring.
*/
FERTILITY(IAlleleInteger.class),
/**
* Temperature difference to its native supported one the bee can tolerate.
*/
TEMPERATURE_TOLERANCE(IAlleleTolerance.class),
/**
* Slightly incorrectly named. If true, a naturally dirunal bee can work during the night. If true, a naturally nocturnal bee can work during the day.
*/
NOCTURNAL(IAlleleBoolean.class),
/**
* Not used / superseded by fixed values for the species. Probably going to be replaced with a boolean for FIRE_RESIST.
*/
@Deprecated
HUMIDITY(IAllele.class),
/**
* Humidity difference to its native supported one the bee can tolerate.
*/
HUMIDITY_TOLERANCE(IAlleleTolerance.class),
/**
* If true the bee can work during rain.
*/
TOLERANT_FLYER(IAlleleBoolean.class),
/**
* If true, the bee can work without a clear view of the sky.
*/
CAVE_DWELLING(IAlleleBoolean.class),
/**
* Contains the supported flower provider.
*/
FLOWER_PROVIDER(IAlleleFlowers.class),
/**
* Determines pollination speed.
*/
FLOWERING(IAlleleInteger.class),
/**
* Determines the size of the bee's territory.
*/
TERRITORY(IAlleleArea.class),
/**
* Determines the bee's effect.
*/
EFFECT(IAlleleBeeEffect.class);
Class<? extends IAllele> clss;
EnumBeeChromosome(Class<? extends IAllele> clss) {
this.clss = clss;
}
@Override
public Class<? extends IAllele> getAlleleClass() {
return clss;
}
@Override
public String getName() {
return this.toString().toLowerCase();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
}
}

View file

@ -0,0 +1,19 @@
package forestry.api.apiculture;
import java.util.Locale;
public enum EnumBeeType {
DRONE, PRINCESS, QUEEN, LARVAE, NONE;
public static final EnumBeeType[] VALUES = values();
String name;
private EnumBeeType() {
this.name = "bees." + this.toString().toLowerCase(Locale.ENGLISH);
}
public String getName() {
return name;
}
}

View file

@ -0,0 +1,14 @@
package forestry.api.apiculture;
import java.util.ArrayList;
import forestry.api.genetics.IFlowerProvider;
import net.minecraft.item.ItemStack;
public class FlowerManager {
/**
* ItemStacks representing simple flower blocks. Meta-sensitive, processed by the basic {@link IFlowerProvider}.
*/
public static ArrayList<ItemStack> plainFlowers = new ArrayList<ItemStack>();
}

View file

@ -0,0 +1,31 @@
package forestry.api.apiculture;
import forestry.api.genetics.IAlleleEffect;
import forestry.api.genetics.IEffectData;
public interface IAlleleBeeEffect extends IAlleleEffect {
/**
* Called by apiaries to cause an effect in the world.
*
* @param genome
* Genome of the bee queen causing this effect
* @param storedData
* Object containing the stored effect data for the apiary/hive the bee is in.
* @param housing {@link IBeeHousing} the bee currently resides in.
* @return storedData, may have been manipulated.
*/
IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing);
/**
* Is called to produce bee effects.
*
* @param genome
* @param storedData
* Object containing the stored effect data for the apiary/hive the bee is in.
* @param housing {@link IBeeHousing} the bee currently resides in.
* @return storedData, may have been manipulated.
*/
IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing);
}

View file

@ -0,0 +1,46 @@
package forestry.api.apiculture;
import java.util.Map;
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 {
/**
* @return the IBeeRoot
*/
IBeeRoot getRoot();
/**
* @return true if this species is only active at night.
*/
boolean isNocturnal();
/**
* @return Map of possible products with the chance for drop each bee cycle. (0 - 100)
*/
Map<ItemStack, Integer> getProducts();
/**
* @return Map of possible specialities with the chance for drop each bee cycle. (0 - 100)
*/
Map<ItemStack, Integer> getSpecialty();
/**
* Only jubilant bees produce specialities.
* @return true if the bee is jubilant, false otherwise.
*/
boolean isJubilant(IBeeGenome genome, IBeeHousing housing);
@SideOnly(Side.CLIENT)
Icon getIcon(EnumBeeType type, int renderPass);
/**
* @return Path of the texture to use for entity rendering.
*/
String getEntityTexture();
}

View file

@ -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();
}

View file

@ -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 forestry.api.genetics.ISpeciesRoot} for retrieval functions.
*
* @author SirSengir
*/
public interface IApiaristTracker extends IBreedingTracker {
/**
* Register the birth of a queen. Will mark species as discovered.
*
* @param queen
* Created queen.
*/
void registerQueen(IIndividual queen);
/**
* @return Amount of queens bred with this tracker.
*/
int getQueenCount();
/**
* Register the birth of a princess. Will mark species as discovered.
*
* @param princess
* Created princess.
*/
void registerPrincess(IIndividual princess);
/**
* @return Amount of princesses bred with this tracker.
*/
int getPrincessCount();
/**
* Register the birth of a drone. Will mark species as discovered.
*
* @param drone
* Created drone.
*/
void registerDrone(IIndividual drone);
/**
* @return Amount of drones bred with this tracker.
*/
int getDroneCount();
}

View file

@ -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);
}

View file

@ -0,0 +1,85 @@
package forestry.api.apiculture;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IIndividualLiving;
/**
* Other implementations than Forestry's default one are not supported.
*
* @author SirSengir
*/
public interface IBee extends IIndividualLiving {
/**
* @return Bee's genetic information.
*/
IBeeGenome getGenome();
/**
* @return Genetic information of the bee's mate, null if unmated.
*/
IBeeGenome getMate();
/**
* @return true if the individual is originally of natural origin.
*/
boolean isNatural();
/**
* @return generation this individual is removed from the original individual.
*/
int getGeneration();
/**
* Set the natural flag on this bee.
* @param flag
*/
void setIsNatural(boolean flag);
/**
* @return true if the bee is mated with another whose isNatural() doesn't match.
*/
boolean isIrregularMating();
IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing);
IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing);
/**
* @return true if the bee may spawn offspring
*/
boolean canSpawn();
/**
* Determines whether the queen can work.
*
* @param housing the {@link IBeeHousing} the bee currently resides in.
* @return Ordinal of the error code encountered. 0 - EnumErrorCode.OK
*/
int isWorking(IBeeHousing housing);
boolean hasFlower(IBeeHousing housing);
ArrayList<Integer> getSuitableBiomeIds();
ItemStack[] getProduceList();
ItemStack[] getSpecialtyList();
ItemStack[] produceStacks(IBeeHousing housing);
IBee spawnPrincess(IBeeHousing housing);
IBee[] spawnDrones(IBeeHousing housing);
void plantFlowerRandom(IBeeHousing housing);
IIndividual retrievePollen(IBeeHousing housing);
boolean pollinateRandom(IBeeHousing housing, IIndividual pollen);
}

View file

@ -0,0 +1,43 @@
package forestry.api.apiculture;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
/**
* Only the default implementation is supported.
*
* @author SirSengir
*
*/
public interface IBeeGenome extends IGenome {
IAlleleBeeSpecies getPrimary();
IAlleleBeeSpecies getSecondary();
float getSpeed();
int getLifespan();
int getFertility();
EnumTolerance getToleranceTemp();
EnumTolerance getToleranceHumid();
boolean getNocturnal();
boolean getTolerantFlyer();
boolean getCaveDwelling();
IFlowerProvider getFlowerProvider();
int getFlowering();
int[] getTerritory();
IAlleleBeeEffect getEffect();
}

View file

@ -0,0 +1,21 @@
package forestry.api.apiculture;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IHousing;
public interface IBeeHousing extends IBeeModifier, IBeeListener, IHousing {
ItemStack getQueen();
ItemStack getDrone();
void setQueen(ItemStack itemstack);
void setDrone(ItemStack itemstack);
/**
* @return true if princesses and drones can (currently) mate in this housing to generate queens.
*/
boolean canBreed();
}

View file

@ -0,0 +1,40 @@
package forestry.api.apiculture;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IIndividual;
public interface IBeeListener {
/**
* Called on queen update.
*
* @param queen
*/
void onQueenChange(ItemStack queen);
/**
* Called when the bees wear out the housing's equipment.
*
* @param amount
* Integer indicating the amount worn out.
*/
void wearOutEquipment(int amount);
/**
* Called just before the children are generated, and the queen removed.
*
* @param queen
*/
void onQueenDeath(IBee queen);
/**
* Called after the children have been spawned, but before the queen appears
*
* @param queen
*/
void onPostQueenDeath(IBee queen);
boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled);
boolean onEggLaid(IBee queen);
}

View file

@ -0,0 +1,66 @@
package forestry.api.apiculture;
public interface IBeeModifier {
/**
* @param genome Genome of the bee this modifier is called for.
* @param currentModifier Current modifier.
* @return Float used to modify the base territory.
*/
float getTerritoryModifier(IBeeGenome genome, float currentModifier);
/**
* @param genome Genome of the bee this modifier is called for.
* @param mate
* @param currentModifier Current modifier.
* @return Float used to modify the base mutation chance.
*/
float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier);
/**
* @param genome Genome of the bee this modifier is called for.
* @param currentModifier Current modifier.
* @return Float used to modify the life span of queens.
*/
float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier);
/**
* @param genome Genome of the bee this modifier is called for.
* @param currentModifier Current modifier.
* @return Float modifying the production speed of queens.
*/
float getProductionModifier(IBeeGenome genome, float currentModifier);
/**
* @param genome Genome of the bee this modifier is called for.
* @return Float modifying the flowering of queens.
*/
float getFloweringModifier(IBeeGenome genome, float currentModifier);
/**
* @param genome Genome of the bee this modifier is called for.
* @return Float modifying the chance for a swarmer queen to die off.
*/
float getGeneticDecay(IBeeGenome genome, float currentModifier);
/**
* @return Boolean indicating if housing can ignore rain
*/
boolean isSealed();
/**
* @return Boolean indicating if housing can ignore darkness/night
*/
boolean isSelfLighted();
/**
* @return Boolean indicating if housing can ignore not seeing the sky
*/
boolean isSunlightSimulated();
/**
* @return Boolean indicating whether this housing simulates the nether
*/
boolean isHellish();
}

View file

@ -0,0 +1,20 @@
package forestry.api.apiculture;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation;
public interface IBeeMutation extends IMutation {
IBeeRoot getRoot();
/**
* @param housing
* @param allele0
* @param allele1
* @param genome0
* @param genome1
* @return float representing the chance for mutation to occur. note that this is 0 - 100 based, since it was an integer previously!
*/
float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
}

View file

@ -0,0 +1,111 @@
package forestry.api.apiculture;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.core.IStructureLogic;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
public interface IBeeRoot extends ISpeciesRoot {
/**
* @return true if passed item is a Forestry bee. Equal to getType(ItemStack stack) != EnumBeeType.NONE
*/
boolean isMember(ItemStack stack);
/**
* @return {@link IBee} pattern parsed from the passed stack's nbt data.
*/
IBee getMember(ItemStack stack);
IBee getMember(NBTTagCompound compound);
/* GENOME CONVERSION */
IBee templateAsIndividual(IAllele[] template);
IBee templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
IBeeGenome templateAsGenome(IAllele[] template);
IBeeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
/* BREEDING TRACKER */
/**
* @param world
* @return {@link IApiaristTracker} associated with the passed world.
*/
IApiaristTracker getBreedingTracker(World world, String player);
/* BEE SPECIFIC */
/**
* @return type of bee encoded on the itemstack. EnumBeeType.NONE if it isn't a bee.
*/
EnumBeeType getType(ItemStack stack);
/**
* @return true if passed item is a drone. Equal to getType(ItemStack stack) == EnumBeeType.DRONE
*/
boolean isDrone(ItemStack stack);
/**
* @return true if passed item is mated (i.e. a queen)
*/
boolean isMated(ItemStack stack);
/**
* @param genome
* Valid {@link IBeeGenome}
* @return {@link IBee} from the passed genome
*/
IBee getBee(World world, IBeeGenome genome);
/**
* Creates an IBee suitable for a queen containing the necessary second genome for the mate.
*
* @param genome
* Valid {@link IBeeGenome}
* @param mate
* Valid {@link IBee} representing the mate.
* @return Mated {@link IBee} from the passed genomes.
*/
IBee getBee(World world, IBeeGenome genome, IBee mate);
/* TEMPLATES */
ArrayList<IBee> getIndividualTemplates();
/* MUTATIONS */
Collection<IBeeMutation> getMutations(boolean shuffle);
/* GAME MODE */
void resetBeekeepingMode();
ArrayList<IBeekeepingMode> getBeekeepingModes();
IBeekeepingMode getBeekeepingMode(World world);
IBeekeepingMode getBeekeepingMode(String name);
void registerBeekeepingMode(IBeekeepingMode mode);
void setBeekeepingMode(World world, String name);
/* MISC */
/**
* @param housing
* Object implementing IBeeHousing.
* @return IBeekeepingLogic
*/
IBeekeepingLogic createBeekeepingLogic(IBeeHousing housing);
/**
* TileEntities wanting to function as alveary components need to implement structure logic for validation.
*
* @return IStructureLogic for alvearies.
*/
IStructureLogic createAlvearyStructureLogic(IAlvearyComponent structure);
}

View file

@ -0,0 +1,22 @@
package forestry.api.apiculture;
import forestry.api.core.INBTTagable;
import forestry.api.genetics.IEffectData;
public interface IBeekeepingLogic extends INBTTagable {
/* STATE INFORMATION */
int getBreedingTime();
int getTotalBreedingTime();
IBee getQueen();
IBeeHousing getHousing();
IEffectData[] getEffectData();
/* UPDATING */
void update();
}

View file

@ -0,0 +1,65 @@
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<String> getDescription();
/**
* @return Float used to modify the wear on comb frames.
*/
float getWearModifier();
/**
* @param queen
* @return fertility taking into account the birthing queen and surroundings.
*/
int getFinalFertility(IBee queen, World world, int x, int y, int z);
/**
* @param queen
* @return true if the queen is genetically "fatigued" and should not be reproduced anymore.
*/
boolean isFatigued(IBee queen, IBeeHousing housing);
/**
* @param queen
* @param housing
* @return true if the queen is being overworked in the bee housing (with chance). will trigger a negative effect.
*/
boolean isOverworked(IBee queen, IBeeHousing housing);
/**
*
* @param queen
* @param offspring
* @param housing
* @return true if the genetic structure of the queen is breaking down during spawning of the offspring (with chance). will trigger a negative effect.
*/
boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing);
/**
* @param queen
* @return true if an offspring of this queen is considered a natural
*/
boolean isNaturalOffspring(IBee queen);
/**
* @param queen
* @return true if this mode allows the passed queen or princess to be multiplied
*/
boolean mayMultiplyPrincess(IBee queen);
}

View file

@ -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<ItemStack> getDrones(World world, int x, int y, int z, int fortune);
Collection<ItemStack> getAdditional(World world, int x, int y, int z, int fortune);
/**
* Chance to drop. Default drops have 80 (= 80 %).
*
* @param world Minecraft world this is called for.
* @param x x-Coordinate of the broken hive.
* @param y y-Coordinate of the broken hive.
* @param z z-Coordinate of the broken hive.
* @return Chance for drop as an integer of 0 - 100.
*/
int getChance(World world, int x, int y, int z);
}

View file

@ -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. The wear modifier of the current beekeeping mode has already been taken into account.
* @return ItemStack containing the actual frame with adjusted damage.
*/
ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear);
}

View file

@ -0,0 +1,3 @@
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|apiculture")
package forestry.api.apiculture;
import cpw.mods.fml.common.API;