Split "api" into one api module for every module

This commit is contained in:
mezz committed 2017-08-12 21:16:54 -07:00
1 parent 8600dc9e66
commit ef90f2228b
87 files changed
+44 -18

No files matched your search

@@ -0,0 +1,22 @@
package binnie.botany.api;
import binnie.botany.api.gardening.IGardeningManager;
import binnie.botany.api.genetics.IFlowerFactory;
import binnie.botany.api.genetics.IFlowerRoot;
public class BotanyAPI {
/**
* Convenient access to AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers")
*/
public static IFlowerRoot flowerRoot;
/**
* Used to create new flowers.
*/
public static IFlowerFactory flowerFactory;
/**
* Used to manager soil.
*/
public static IGardeningManager gardening;
}
@@ -0,0 +1,43 @@
package binnie.botany.api.gardening;
import javax.annotation.Nullable;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
public enum EnumAcidity implements IStringSerializable {
ACID(TextFormatting.RED),
NEUTRAL(null),
ALKALINE(TextFormatting.AQUA);
@Nullable
TextFormatting color;
EnumAcidity(@Nullable TextFormatting color) {
this.color = color;
}
@Override
public String getName() {
return name().toLowerCase();
}
public String getLocalisedName(boolean withColor) {
String localisedName = I18n.translateToLocal("botany.ph." + getName());
if (withColor && color != null) {
localisedName = color + localisedName;
}
return localisedName;
}
public static EnumAcidity getFromValue(float rawAcidity) {
if(rawAcidity <= -1.0f){
return EnumAcidity.ACID;
}else if(rawAcidity >= 1.0f){
return EnumAcidity.ALKALINE;
}else{
return EnumAcidity.NEUTRAL;
}
}
}
@@ -0,0 +1,5 @@
package binnie.botany.api.gardening;
public enum EnumFertiliserType {
ACID, ALKALINE, NUTRIENT
}
@@ -0,0 +1,44 @@
package binnie.botany.api.gardening;
import javax.annotation.Nullable;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
public enum EnumMoisture implements IStringSerializable {
DRY(TextFormatting.YELLOW),
NORMAL(null),
DAMP(TextFormatting.DARK_BLUE);
@Nullable
final TextFormatting color;
EnumMoisture(@Nullable TextFormatting color) {
this.color = color;
}
@Override
public String getName() {
return name().toLowerCase();
}
public String getLocalisedName(boolean withColor) {
String localisedName = I18n.translateToLocal("botany.moisture." + getName());
if (withColor && color != null) {
localisedName = color + localisedName + TextFormatting.GRAY;
}
return localisedName;
}
public static EnumMoisture getFromValue(float rawMoisture) {
if(rawMoisture <= -1.0f){
return EnumMoisture.DRY;
}else if(rawMoisture >= 1.0f){
return EnumMoisture.DAMP;
}else{
return EnumMoisture.NORMAL;
}
}
}
@@ -0,0 +1,29 @@
package binnie.botany.api.gardening;
import java.util.Locale;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
public enum EnumSoilType implements IStringSerializable {
SOIL(TextFormatting.DARK_GRAY),
LOAM(TextFormatting.GOLD),
FLOWERBED(TextFormatting.LIGHT_PURPLE);
private final TextFormatting color;
EnumSoilType(TextFormatting color) {
this.color = color;
}
@Override
public String getName() {
return name().toLowerCase(Locale.ENGLISH);
}
public String getTranslated() {
return color + I18n.translateToLocal("botany.soil." + getName());
}
}
@@ -0,0 +1,22 @@
package binnie.botany.api.gardening;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface IBlockSoil {
EnumAcidity getPH(World world, BlockPos pos);
EnumMoisture getMoisture(World world, BlockPos pos);
EnumSoilType getType(World world, BlockPos pos);
boolean fertilise(World world, BlockPos pos, EnumSoilType soilType);
boolean degrade(World world, BlockPos pos, EnumSoilType soilType);
boolean setPH(World world, BlockPos pos, EnumAcidity acidity);
boolean setMoisture(World world, BlockPos pos, EnumMoisture moisture);
boolean resistsWeeds(World world, BlockPos pos);
}
@@ -0,0 +1,67 @@
package binnie.botany.api.gardening;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.core.EnumTemperature;
import binnie.botany.api.genetics.IFlower;
public interface IGardeningManager {
default boolean isSoil(Block block) {
return block instanceof IBlockSoil;
}
boolean isSoil(Item item);
boolean isSoil(ItemStack item);
EnumMoisture getNaturalMoisture(World world, BlockPos pos);
EnumAcidity getNaturalPH(World world, BlockPos pos);
float getBiomeMoisture(World world, BlockPos pos);
float getBiomePH(World world, BlockPos pos);
IBlockState getSoil(EnumSoilType soil, boolean weedKill, EnumMoisture moisture, EnumAcidity acidity);
void plantSoil(World world, BlockPos pos, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity);
Collection<ItemStack> getFertilisers(EnumFertiliserType type);
Map<EnumFertiliserType, Map<ItemStack, Integer>> getFertilisers();
void registerFertiliser(EnumFertiliserType type, ItemStack stack, int strength);
boolean isFertiliser(EnumFertiliserType type, ItemStack stack);
int getFertiliserStrength(ItemStack stack);
boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos);
EnumSoilType getSoilType(World world, BlockPos pos);
default Block getSoilBlock(EnumSoilType type) {
return getSoilBlock(type, false);
}
Block getSoilBlock(EnumSoilType type, boolean weedKill);
boolean canTolerate(IFlower flower, EnumAcidity acidity, EnumMoisture moisture, EnumTemperature temperature);
boolean isWeedkiller(ItemStack heldItem);
boolean addWeedKiller(World world, BlockPos pos);
boolean onFertiliseSoil(ItemStack heldItem, IBlockSoil soil, World world, BlockPos pos, EntityPlayer player);
}
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.botany.api.gardening;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,48 @@
package binnie.botany.api.genetics;
import java.util.Locale;
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.IAlleleTolerance;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot;
public enum EnumFlowerChromosome implements IChromosomeType {
SPECIES(IAlleleFlowerSpecies.class),
PRIMARY(IAlleleInteger.class),
SECONDARY(IAlleleInteger.class),
FERTILITY(IAlleleInteger.class),
TERRITORY(IAlleleArea.class),
EFFECT(IAlleleFlowerEffect.class),
LIFESPAN(IAlleleInteger.class),
TEMPERATURE_TOLERANCE(IAlleleTolerance.class),
HUMIDITY_TOLERANCE(IAlleleTolerance.class),
PH_TOLERANCE(IAlleleTolerance.class),
SAPPINESS(IAlleleFloat.class),
STEM(IAlleleInteger.class);
private Class<? extends IAllele> cls;
EnumFlowerChromosome(Class<? extends IAllele> cls) {
this.cls = cls;
}
@Override
public Class<? extends IAllele> getAlleleClass() {
return cls;
}
@Override
public String getName() {
return toString().toLowerCase(Locale.ENGLISH);
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
}
}
@@ -0,0 +1,130 @@
package binnie.botany.api.genetics;
import java.awt.Color;
import binnie.botany.api.BotanyAPI;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.translation.I18n;
public enum EnumFlowerColor implements IStringSerializable {
Aquamarine("aquamarine", new Color(8388564)),
Black("black", new Color(2631720)),
Blue("blue", new Color(255)),
Brown("brown", new Color(10824234)),
CadetBlue("cadetBlue", new Color(6266528)),
Chocolate("chocolate", new Color(13789470)),
Coral("coral", new Color(16744272)),
Crimson("crimson", new Color(14423100)),
Cyan("cyan", new Color(65535)),
DarkGoldenrod("darkGoldenrod", new Color(12092939)),
DarkGray("darkGray", new Color(11119017)),
DarkGreen("darkGreen", new Color(25600)),
DarkKhaki("darkKhaki", new Color(12433259)),
DarkOliveGreen("darkOliveGreen", new Color(5597999)),
DarkOrange("darkOrange", new Color(16747520)),
DarkSalmon("darkSalmon", new Color(15308410)),
DarkSeaGreen("darkSeaGreen", new Color(9419915)),
DarkSlateBlue("darkSlateBlue", new Color(4734347)),
DarkSlateGray("darkSlateGray", new Color(3100495)),
DarkTurquoise("darkTurquoise", new Color(52945)),
DarkViolet("darkViolet", new Color(9699539)),
DeepPink("deepPink", new Color(16716947)),
DeepSkyBlue("deepSkyBlue", new Color(49151)),
DimGray("dimGray", new Color(6908265)),
DodgerBlue("dodgerBlue", new Color(2003199)),
Gold("gold", new Color(16766720)),
Goldenrod("goldenrod", new Color(14329120)),
Gray("gray", new Color(8421504)),
Green("green", new Color(32768)),
HotPink("hotPink", new Color(16738740)),
IndianRed("indianRed", new Color(13458524)),
Indigo("indigo", new Color(4915330)),
Khaki("khaki", new Color(15787660)),
Lavender("lavender", new Color(15132410)),
LemonChiffon("lemonChiffon", new Color(16775885)),
LightGray("lightGray", new Color(13882323)),
LightSeaGreen("lightSeaGreen", new Color(2142890)),
LightSteelBlue("lightSteelBlue", new Color(11584734)),
Lime("lime", new Color(65280)),
LimeGreen("limeGreen", new Color(3329330)),
Magenta("magenta", new Color(16711935)),
Maroon("maroon", new Color(8388608)),
MediumAquamarine("mediumAquamarine", new Color(6737322)),
MediumOrchid("mediumOrchid", new Color(12211667)),
MediumPurple("mediumPurple", new Color(9662683)),
MediumSeaGreen("mediumSeaGreen", new Color(3978097)),
MediumVioletRed("mediumVioletRed", new Color(13047173)),
MistyRose("mistyRose", new Color(16770273)),
Navy("navy", new Color(128)),
Olive("olive", new Color(8421376)),
OliveDrab("oliveDrab", new Color(7048739)),
Orange("orange", new Color(16753920)),
PaleGreen("paleGreen", new Color(10025880)),
PaleTurquoise("paleTurquoise", new Color(11529966)),
PaleVioletRed("paleVioletRed", new Color(14381203)),
Peru("peru", new Color(13468991)),
Pink("pink", new Color(16761035)),
Plum("plum", new Color(14524637)),
Purple("purple", new Color(8388736)),
Red("red", new Color(16711680)),
RosyBrown("rosyBrown", new Color(12357519)),
RoyalBlue("royalBlue", new Color(4286945)),
Salmon("salmon", new Color(16416882)),
SandyBrown("sandyBrown", new Color(16032864)),
SeaGreen("seaGreen", new Color(3050327)),
Sienna("sienna", new Color(10506797)),
SkyBlue("skyBlue", new Color(8900331)),
SlateBlue("slateBlue", new Color(6970061)),
SlateGray("slateGray", new Color(7372944)),
SpringGreen("springGreen", new Color(65407)),
SteelBlue("steelBlue", new Color(4620980)),
Tan("tan", new Color(13808780)),
Teal("teal", new Color(32896)),
Thistle("thistle", new Color(14204888)),
Turquoise("turquoise", new Color(4251856)),
Violet("violet", new Color(15631086)),
Wheat("wheat", new Color(16113331)),
White("white", new Color(16777215)),
Yellow("yellow", new Color(16776960)),
YellowGreen("yellowGreen", new Color(10145074));
public static final EnumFlowerColor[] VALUES = values();
private final String ident;
private final IAlleleFlowerColor allele;
EnumFlowerColor(String ident, Color color) {
this.ident = ident;
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
r = (int) (0.45 * (r + 214));
g = (int) (0.45 * (g + 174));
b = (int) (0.45 * (b + 131));
Color colorWilted = new Color(r, g, b);
String uid = "botany.color" + name();
allele = BotanyAPI.flowerFactory.createFlowerColorAllele(uid, ordinal(), color, colorWilted, name().toLowerCase(), uid, true);
}
public String getIdent() {
return ident;
}
public static EnumFlowerColor get(int i) {
return values()[Math.max(0, i) % values().length];
}
public String getDisplayName() {
return I18n.translateToLocal("botany.color." + getName());
}
@Override
public String getName() {
return name().toLowerCase();
}
public IAlleleFlowerColor getFlowerColorAllele() {
return allele;
}
}
@@ -0,0 +1,29 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.ISpeciesType;
public enum EnumFlowerStage implements ISpeciesType {
FLOWER("Flower"),
SEED("Seed"),
POLLEN("Pollen");
public static final EnumFlowerStage[] VALUES = values();
String name;
EnumFlowerStage(String name) {
this.name = name;
}
public static EnumFlowerStage getStage(IFlower flower) {
return getStage(flower.getAge());
}
public static EnumFlowerStage getStage(int age) {
return age == 0 ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
}
public String getName() {
return name;
}
}
@@ -0,0 +1,6 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.IAlleleInteger;
public interface IAlleleFlowerColor extends IFlowerColor, IAlleleInteger {
}
@@ -0,0 +1,10 @@
package binnie.botany.api.genetics;
import net.minecraft.world.World;
import forestry.api.genetics.IAlleleEffect;
import forestry.api.genetics.IEffectData;
public interface IAlleleFlowerEffect extends IAlleleEffect {
IEffectData doEffect(IFlowerGenome genome, IEffectData effect, World world, int x, int y, int z);
}
@@ -0,0 +1,31 @@
package binnie.botany.api.genetics;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
import forestry.api.genetics.IAlleleProperty;
import forestry.api.genetics.IAlleleSpecies;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
public interface IAlleleFlowerSpecies extends IAlleleSpecies, IAlleleProperty<IAlleleFlowerSpecies> {
IFlowerType getType();
EnumAcidity getPH();
EnumMoisture getMoisture();
@SideOnly(Side.CLIENT)
int getFlowerColor(EnumFlowerStage type, int renderPass);
@SideOnly(Side.CLIENT)
ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered);
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager, EnumFlowerStage type);
}
@@ -0,0 +1,15 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.IAlleleSpeciesBuilder;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
public interface IAlleleFlowerSpeciesBuilder extends IAlleleSpeciesBuilder {
@Override
IAlleleFlowerSpecies build();
IAlleleFlowerSpeciesBuilder setPH(EnumAcidity acidity);
IAlleleFlowerSpeciesBuilder setMoisture(EnumMoisture moisture);
}
@@ -0,0 +1,6 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.IBreedingTracker;
public interface IBotanistTracker extends IBreedingTracker {
}
@@ -0,0 +1,13 @@
package binnie.botany.api.genetics;
public interface IColorMix {
IFlowerColor getColorFirst();
IFlowerColor getColorSecond();
boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond);
int getChance();
IFlowerColor getResult();
}
@@ -0,0 +1,76 @@
package binnie.botany.api.genetics;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IIndividual;
public interface IFlower extends IIndividual {
/**
* @return Flowers's genetic information.
*/
@Override
IFlowerGenome getGenome();
/**
* @return Genetic information of the flower's mate, null if unmated.
*/
@Nullable
IFlowerGenome getMate();
/**
* Mate with the given flower.
*
* @param flower the {@link IFlower} to mate this one with.
*/
void mate(IFlower flower);
/**
* Remove the mate of the flower.
*/
void removeMate();
IFlower getOffspring(World world, BlockPos pos);
/**
* @return The current age of the flower.
*/
int getAge();
/**
* Set the current age of the flower.
*/
void setAge(int age);
/**
* Age the flower.
*/
void age();
/**
* @return Maximum age of the flower.
*/
int getMaxAge();
/**
* @return true if the flower is wilted.
*/
boolean isWilted();
/**
* Set that the flower is wilted.
*/
void setWilted(boolean wilted);
/**
* @return true if the flower has flowered.
*/
boolean hasFlowered();
/**
* Set that the flower has flowered.
*/
void setFlowered(boolean flowered);
}
@@ -0,0 +1,13 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.IAlleleInteger;
public interface IFlowerColor {
int getColor(boolean dis);
IAlleleInteger getAllele();
int getID();
String getColorName();
}
@@ -0,0 +1,15 @@
package binnie.botany.api.genetics;
import net.minecraft.item.ItemStack;
import forestry.core.genetics.IGeneticDefinition;
public interface IFlowerDefinition extends IGeneticDefinition {
@Override
IFlowerGenome getGenome();
@Override
IFlower getIndividual();
ItemStack getMemberStack(EnumFlowerStage flowerStage);
}
@@ -0,0 +1,14 @@
package binnie.botany.api.genetics;
import java.awt.Color;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
public interface IFlowerFactory {
IAlleleFlowerSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean isDominant, IClassification branch, String binomial, IFlowerType flowerType);
IFlowerMutationBuilder createMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] result, int chance);
IAlleleFlowerColor createFlowerColorAllele(String uid, int id, Color color, Color colorWilted, String name, String unlocalizedName, boolean isDominant);
}
@@ -0,0 +1,44 @@
package binnie.botany.api.genetics;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IGenome;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
public interface IFlowerGenome extends IGenome {
@Override
IAlleleFlowerSpecies getPrimary();
@Override
IAlleleFlowerSpecies getSecondary();
IFlowerColor getPrimaryColor();
IFlowerColor getSecondaryColor();
IFlowerColor getStemColor();
int getFertility();
int getLifespan();
IFlowerType getType();
EnumTolerance getToleranceTemperature();
EnumTolerance getToleranceMoisture();
EnumTolerance getTolerancePH();
float getAgeChance();
float getSappiness();
boolean canTolerate(EnumAcidity acidity);
boolean canTolerate(EnumMoisture moisture);
boolean canTolerate(EnumTemperature temperature);
}
@@ -0,0 +1,13 @@
package binnie.botany.api.genetics;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IMutation;
public interface IFlowerMutation extends IMutation {
@Override
IFlowerRoot getRoot();
float getChance(World world, BlockPos pos, IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IFlowerGenome genome0, IFlowerGenome genome1);
}
@@ -0,0 +1,6 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.IMutationBuilder;
public interface IFlowerMutationBuilder extends IMutationBuilder {
}
@@ -0,0 +1,59 @@
package binnie.botany.api.genetics;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
public interface IFlowerRoot extends ISpeciesRoot {
@Override
@Nullable
IFlower getMember(ItemStack memberStack);
@Override
IFlower templateAsIndividual(IAllele[] template);
@Override
IFlower templateAsIndividual(IAllele[] templateFirst, IAllele[] templateSecond);
@Override
IFlowerGenome templateAsGenome(IAllele[] template);
@Override
IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
@Override
IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile profile);
@Override
List<? extends IFlowerMutation> getMutations(boolean shuffle);
@Override
@Nullable
EnumFlowerStage getType(ItemStack itemStack);
IFlower getFlower(IFlowerGenome genome);
void addConversion(ItemStack memberStack, IAllele[] template);
@Nullable
IFlower getConversion(ItemStack memberStack);
Collection<IColorMix> getColorMixes(boolean shuffle);
void registerColourMix(IColorMix colorMix);
boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner);
void tryGrowSection(World world, BlockPos pos);
void onGrowFromSeed(World world, BlockPos pos);
}
@@ -0,0 +1,23 @@
package binnie.botany.api.genetics;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IModelManager;
public interface IFlowerType<I extends IFlowerType<I>> extends Comparable<I> {
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager, EnumFlowerStage type);
@SideOnly(Side.CLIENT)
ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered);
String getName();
int getSections();
int ordinal();
}
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.botany.api.genetics;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.botany.api;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;