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,18 @@
package forestry.api.arboriculture;
public enum EnumGermlingType {
SAPLING("Sapling"), BLOSSOM("Blossom"), POLLEN("Pollen"), GERMLING("Germling"), NONE("None");
public static final EnumGermlingType[] VALUES = values();
String name;
private EnumGermlingType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

View file

@ -0,0 +1,5 @@
package forestry.api.arboriculture;
public enum EnumGrowthConditions {
HOSTILE, PALTRY, NORMAL, GOOD, EXCELLENT
}

View file

@ -0,0 +1,86 @@
package forestry.api.arboriculture;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleArea;
import forestry.api.genetics.IAlleleFloat;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IAllelePlantType;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IFruitFamily;
import forestry.api.genetics.ISpeciesRoot;
public enum EnumTreeChromosome implements IChromosomeType {
/**
* Determines the following: - WorldGen, including the used wood blocks - {@link IFruitFamily}s supported. Limits which {@link IFruitProvider}
* will actually yield fruit with this species. - Native {@link EnumPlantType} for this tree. Combines with the PLANT chromosome.
*/
SPECIES(IAlleleTreeSpecies.class),
/**
* {@link IGrowthProvider}, determines conditions required by the tree to grow.
*/
GROWTH(IAlleleGrowth.class),
/**
* A float modifying the height of the tree. Taken into account at worldgen.
*/
HEIGHT(IAlleleFloat.class),
/**
* Chance for saplings.
*/
FERTILITY(IAlleleFloat.class),
/**
* {@link IFruitProvider}, determines if and what fruits are grown on the tree. Limited by the {@link IFruitFamily}s the species supports.
*/
FRUITS(IAlleleFruit.class),
/**
* Chance for fruit leaves and/or drops.
*/
YIELD(IAlleleFloat.class),
/**
* May add additional tolerances for {@link EnumPlantTypes}.
*/
PLANT(IAllelePlantType.class),
/**
* Determines the speed at which fruit will ripen on this tree.
*/
SAPPINESS(IAlleleFloat.class),
/**
* Territory for leaf effects. Unused.
*/
TERRITORY(IAlleleArea.class),
/**
* Leaf effect. Unused.
*/
EFFECT(IAlleleLeafEffect.class),
/**
* Amount of random ticks which need to elapse before a sapling will grow into a tree.
*/
MATURATION(IAlleleInteger.class),
GIRTH(IAlleleInteger.class),
;
Class<? extends IAllele> clss;
EnumTreeChromosome(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("rootTrees");
}
}

View file

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

View file

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

View file

@ -0,0 +1,14 @@
package forestry.api.arboriculture;
import net.minecraft.world.World;
import forestry.api.genetics.IAlleleEffect;
import forestry.api.genetics.IEffectData;
/**
* Simple allele encapsulating a leaf effect. (Not implemented)
*/
public interface IAlleleLeafEffect extends IAlleleEffect {
IEffectData doEffect(ITreeGenome genome, IEffectData storedData, World world, int x, int y, int z);
}

View file

@ -0,0 +1,67 @@
package forestry.api.arboriculture;
import java.util.Collection;
import net.minecraft.item.ItemStack;
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 {
ITreeRoot getRoot();
/**
* @return Native plant type of this species.
*/
EnumPlantType getPlantType();
/**
* @return List of all {@link IFruitFamily}s which can grow on leaves generated by this species.
*/
Collection<IFruitFamily> 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<? extends WorldGenerator>[] getGeneratorClasses();
/* TEXTURES AND OVERRIDES */
int getLeafColour(ITree tree);
short getLeafIconIndex(ITree tree, boolean fancy);
@SideOnly(Side.CLIENT)
Icon getGermlingIcon(EnumGermlingType type, int renderPass);
@SideOnly(Side.CLIENT)
int getGermlingColour(EnumGermlingType type, int renderPass);
/**
*
* @return Array of ItemStacks representing logs that these tree produces, the first one being the primary one
*/
ItemStack[] getLogStacks();
}

View file

@ -0,0 +1,7 @@
package forestry.api.arboriculture;
import forestry.api.genetics.IBreedingTracker;
public interface IArboristTracker extends IBreedingTracker {
}

View file

@ -0,0 +1,67 @@
package forestry.api.arboriculture;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
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);
@SideOnly(Side.CLIENT)
void registerIcons(IconRegister register);
}

View file

@ -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 Genome of the tree this is called for.
* @param world Minecraft world the tree will inhabit.
* @param xPos x-Coordinate to attempt growth at.
* @param yPos y-Coordinate to attempt growth at.
* @param zPos z-Coordinate to attempt growth at.
* @param expectedGirth Trunk size of the tree to generate.
* @param expectedHeight Height of the tree to generate.
* @return true if the tree can grow at the given coordinates, false otherwise.
*/
boolean canGrow(ITreeGenome genome, World world, int xPos, int yPos, int zPos, int expectedGirth, int expectedHeight);
EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, int xPos, int yPos, int zPos);
/**
* @return Short, human-readable identifier used in the treealyzer.
*/
String getDescription();
/**
* @return Detailed description of growth behaviour used in the treealyzer.
*/
String[] getInfo();
}

View file

@ -0,0 +1,7 @@
package forestry.api.arboriculture;
import net.minecraft.world.World;
public interface ILeafTickHandler {
boolean onRandomLeafTick(ITree tree, World world, int biomeId, int x, int y, int z, boolean isDestroyed);
}

View file

@ -0,0 +1,19 @@
package forestry.api.arboriculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IToolGrafter {
/**
* Called by leaves to determine the increase in sapling droprate.
*
* @param stack ItemStack containing the grafter.
* @param world Minecraft world the player and the target block inhabit.
* @param x x-Coordinate of the broken leaf block.
* @param y y-Coordinate of the broken leaf block.
* @param z z-Coordinate of the broken leaf block.
* @return Float representing the factor the usual drop chance is to be multiplied by.
*/
float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, int x, int y, int z);
}

View file

@ -0,0 +1,92 @@
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<EnumPlantType> getPlantTypes();
ITree[] getSaplings(World world, int x, int y, int z, float modifier);
ItemStack[] getProduceList();
ItemStack[] getSpecialtyList();
ItemStack[] produceStacks(World world, int x, int y, int z, int ripeningTime);
/**
*
* @param world
* @param x
* @param y
* @param z
* @return Boolean indicating whether a sapling can stay planted at the given position.
*/
boolean canStay(World world, int x, int y, int z);
/**
*
* @param world
* @param x
* @param y
* @param z
* @return Boolean indicating whether a sapling at the given position can grow into a tree.
*/
boolean canGrow(World world, int x, int y, int z, int expectedGirth, int expectedHeight);
/**
* @return Integer denoting the maturity (block ticks) required for a sapling to attempt to grow into a tree.
*/
int getRequiredMaturity();
/**
* @return Integer denoting how resilient leaf blocks are against adverse influences (i.e. caterpillars).
*/
int getResilience();
/**
* @param world
* @param x
* @param y
* @param z
* @return Integer denoting the size of the tree trunk.
*/
int getGirth(World world, int x, int y, int z);
/**
*
* @param world
* @param x
* @param y
* @param z
* @return Growth conditions at the given position.
*/
EnumGrowthConditions getGrowthCondition(World world, int x, int y, int z);
WorldGenerator getTreeGenerator(World world, int x, int y, int z, boolean wasBonemealed);
ITree copy();
boolean isPureBred(EnumTreeChromosome chromosome);
boolean canBearFruit();
}

View file

@ -0,0 +1,40 @@
package forestry.api.arboriculture;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.IGenome;
public interface ITreeGenome extends IGenome {
IAlleleTreeSpecies getPrimary();
IAlleleTreeSpecies getSecondary();
IFruitProvider getFruitProvider();
IGrowthProvider getGrowthProvider();
float getHeight();
float getFertility();
/**
* @return Determines either a) how many fruit leaves there are or b) the chance for any fruit leave to drop a sapling. Exact usage determined by the
* IFruitProvider
*/
float getYield();
float getSappiness();
EnumSet<EnumPlantType> getPlantTypes();
/**
* @return Amount of random block ticks required for a sapling to mature into a fully grown tree.
*/
int getMaturationTime();
int getGirth();
IAlleleLeafEffect getEffect();
}

View file

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

View file

@ -0,0 +1,28 @@
package forestry.api.arboriculture;
import net.minecraft.world.World;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
public interface ITreeMutation extends IMutation {
/**
* @return {@link ISpeciesRoot} this mutation is associated with.
*/
ITreeRoot getRoot();
/**
* @param world
* @param x
* @param y
* @param z
* @param allele0
* @param allele1
* @param genome0
* @param genome1
* @return float representing the chance for mutation to occur. note that this is 0 - 100 based, since it was an integer previously!
*/
float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
}

View file

@ -0,0 +1,77 @@
package forestry.api.arboriculture;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
public interface ITreeRoot extends ISpeciesRoot {
boolean isMember(ItemStack itemstack);
ITree getMember(ItemStack itemstack);
ITree getMember(NBTTagCompound compound);
ITreeGenome templateAsGenome(IAllele[] template);
ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
/**
* @param world
* @return {@link IArboristTracker} associated with the passed world.
*/
IArboristTracker getBreedingTracker(World world, String player);
/* TREE SPECIFIC */
/**
* Register a leaf tick handler.
* @param handler the {@link ILeafTickHandler} to register.
*/
void registerLeafTickHandler(ILeafTickHandler handler);
Collection<ILeafTickHandler> getLeafTickHandlers();
/**
* @return type of tree encoded on the itemstack. EnumBeeType.NONE if it isn't a tree.
*/
EnumGermlingType getType(ItemStack stack);
ITree getTree(World world, int x, int y, int z);
ITree getTree(World world, ITreeGenome genome);
boolean plantSapling(World world, ITree tree, String owner, int x, int y, int z);
boolean setLeaves(World world, IIndividual tree, String owner, int x, int y, int z);
IChromosome[] templateAsChromosomes(IAllele[] template);
IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive);
boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, short[] indices, int x, int y, int z);
/* GAME MODE */
ArrayList<ITreekeepingMode> getTreekeepingModes();
ITreekeepingMode getTreekeepingMode(World world);
ITreekeepingMode getTreekeepingMode(String name);
void registerTreekeepingMode(ITreekeepingMode mode);
void setTreekeepingMode(World world, String name);
/* TEMPLATES */
ArrayList<ITree> getIndividualTemplates();
/* MUTATIONS */
Collection<ITreeMutation> getMutations(boolean shuffle);
}

View file

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

View file

@ -0,0 +1,11 @@
package forestry.api.arboriculture;
public class TreeManager {
public static int treeSpeciesCount = 0;
/**
* Get your own reference to this via AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees") and save it somewhere.
*/
@Deprecated
public static ITreeRoot treeInterface;
}

View file

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