Updated Forestry API
This commit is contained in:
parent
573868c94a
commit
0033a3b4c3
101 changed files with 1388 additions and 740 deletions
|
@ -9,8 +9,6 @@ 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.
|
||||
|
@ -19,21 +17,6 @@ import forestry.api.genetics.IMutation;
|
|||
*/
|
||||
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)
|
||||
*/
|
||||
|
@ -43,4 +26,24 @@ public class BeeManager {
|
|||
* List of items that can induce swarming. Integer denotes x in 1000 chance.
|
||||
*/
|
||||
public static HashMap<ItemStack, Integer> inducers = new HashMap<ItemStack, Integer>();
|
||||
|
||||
/**
|
||||
* Convenient access to AlleleManager.alleleRegistry.getSpeciesRoot("rootBees")
|
||||
*/
|
||||
public static IBeeRoot beeRoot;
|
||||
|
||||
/**
|
||||
* Used to create new bees.
|
||||
*/
|
||||
public static IBeeFactory beeFactory;
|
||||
|
||||
/**
|
||||
* Used to create new bee mutations.
|
||||
*/
|
||||
public static IBeeMutationFactory beeMutationFactory;
|
||||
|
||||
/**
|
||||
* Used to get Forestry's jubilance implementations.
|
||||
*/
|
||||
public static IJubilanceFactory jubilanceFactory;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleArea;
|
||||
import forestry.api.genetics.IAlleleBoolean;
|
||||
|
@ -98,6 +97,6 @@ public enum EnumBeeChromosome implements IChromosomeType {
|
|||
|
||||
@Override
|
||||
public ISpeciesRoot getSpeciesRoot() {
|
||||
return AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
|
||||
return BeeManager.beeRoot;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public enum EnumBeeType {
|
|||
String name;
|
||||
|
||||
private EnumBeeType() {
|
||||
this.name = "bees." + this.toString().toLowerCase(Locale.ENGLISH);
|
||||
this.name = this.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
|
@ -10,10 +10,30 @@ import java.util.ArrayList;
|
|||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
|
||||
public class FlowerManager {
|
||||
/**
|
||||
* ItemStacks representing simple flower blocks. Meta-sensitive, processed by the basic {@link IFlowerProvider}.
|
||||
*
|
||||
* @deprecated since Forestry 3.4. Use {@link #IFlowerRegistry.registerPlantableFlower(ItemStack flower, double weight, String... flowerTypes)} instead.
|
||||
* <blockquote><pre>e.g. FlowerManager.flowerRegister.registerPlantableFlower(new ItemStack(Blocks.red_flower), 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);</pre></blockquote>
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<ItemStack> plainFlowers = new ArrayList<ItemStack>();
|
||||
|
||||
/**
|
||||
* <blockquote><pre>e.g. FlowerManager.flowerRegister.registerPlantableFlower(new ItemStack(Blocks.red_flower), 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);</pre></blockquote>
|
||||
*/
|
||||
public static IFlowerRegistry flowerRegistry;
|
||||
|
||||
public static final String FlowerTypeVanilla = "flowersVanilla";
|
||||
public static final String FlowerTypeNether = "flowersNether";
|
||||
public static final String FlowerTypeCacti = "flowersCacti";
|
||||
public static final String FlowerTypeMushrooms = "flowersMushrooms";
|
||||
public static final String FlowerTypeEnd = "flowersEnd";
|
||||
public static final String FlowerTypeJungle = "flowersJungle";
|
||||
public static final String FlowerTypeSnow = "flowersSnow";
|
||||
public static final String FlowerTypeWheat = "flowersWheat";
|
||||
public static final String FlowerTypeGourd = "flowersGourd";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
@ -26,16 +26,16 @@ public interface IAlleleBeeSpecies extends IAlleleSpecies {
|
|||
* @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)
|
||||
* @return Map of possible products with the chance for drop each bee cycle. (0 - 1]
|
||||
*/
|
||||
Map<ItemStack, Integer> getSpecialty();
|
||||
Map<ItemStack, Float> getProductChances();
|
||||
|
||||
/**
|
||||
* @return Map of possible specialities with the chance for drop each bee cycle. (0 - 1]
|
||||
*/
|
||||
Map<ItemStack, Float> getSpecialtyChances();
|
||||
|
||||
/**
|
||||
* Only jubilant bees produce specialities.
|
||||
|
@ -47,7 +47,23 @@ public interface IAlleleBeeSpecies extends IAlleleSpecies {
|
|||
IIcon getIcon(EnumBeeType type, int renderPass);
|
||||
|
||||
/**
|
||||
* @deprecated since Forestry 3.6.
|
||||
* @return Path of the texture to use for entity rendering.
|
||||
*/
|
||||
@Deprecated
|
||||
String getEntityTexture();
|
||||
|
||||
/**
|
||||
* @deprecated Since Forestry 3.6 use getProductChances()
|
||||
* @return Map of possible products with the chance for drop each bee cycle. (0 - 100)
|
||||
*/
|
||||
@Deprecated
|
||||
Map<ItemStack, Integer> getProducts();
|
||||
|
||||
/**
|
||||
* @deprecated Since Forestry 3.6 use getSpecialtyChances()
|
||||
* @return Map of possible specialities with the chance for drop each bee cycle. (0 - 100)
|
||||
*/
|
||||
@Deprecated
|
||||
Map<ItemStack, Integer> getSpecialty();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpeciesCustom;
|
||||
|
||||
public interface IAlleleBeeSpeciesCustom extends IAlleleBeeSpecies, IAlleleSpeciesCustom {
|
||||
|
||||
/**
|
||||
* Add a product for this bee species.
|
||||
* Chance is between 0 and 1.
|
||||
*/
|
||||
IAlleleBeeSpeciesCustom addProduct(ItemStack product, Float chance);
|
||||
|
||||
/**
|
||||
* Add a specialty product for this bee species.
|
||||
* Bees only produce their specialty when they are Jubilant (see IJubilanceProvider)
|
||||
* Chance is between 0 and 1.
|
||||
*/
|
||||
IAlleleBeeSpeciesCustom addSpecialty(ItemStack specialty, Float chance);
|
||||
|
||||
/**
|
||||
* Set the Jubilance Provider for this bee species.
|
||||
* Bees only produce their specialty when they are Jubilant (see IJubilanceProvider)
|
||||
*/
|
||||
IAlleleBeeSpeciesCustom setJubilanceProvider(IJubilanceProvider provider);
|
||||
|
||||
/**
|
||||
* Make this species only active at night.
|
||||
*/
|
||||
IAlleleBeeSpeciesCustom setNocturnal();
|
||||
|
||||
/** Use this if you have custom icons for bees. */
|
||||
IAlleleBeeSpeciesCustom setCustomBeeIconProvider(IBeeIconProvider beeIconProvider);
|
||||
}
|
|
@ -6,9 +6,12 @@
|
|||
package forestry.api.apiculture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IIndividualLiving;
|
||||
|
@ -46,11 +49,6 @@ public interface IBee extends IIndividualLiving {
|
|||
*/
|
||||
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);
|
||||
|
@ -62,15 +60,14 @@ public interface IBee extends IIndividualLiving {
|
|||
|
||||
/**
|
||||
* 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
|
||||
* @return an empty set if the queen can work, a set of error states if the queen can not work
|
||||
*/
|
||||
int isWorking(IBeeHousing housing);
|
||||
Set<IErrorState> getCanWork(IBeeHousing housing);
|
||||
|
||||
boolean hasFlower(IBeeHousing housing);
|
||||
|
||||
ArrayList<Integer> getSuitableBiomeIds();
|
||||
ArrayList<BiomeGenBase> getSuitableBiomes();
|
||||
|
||||
ItemStack[] getProduceList();
|
||||
|
||||
|
@ -88,4 +85,14 @@ public interface IBee extends IIndividualLiving {
|
|||
|
||||
boolean pollinateRandom(IBeeHousing housing, IIndividual pollen);
|
||||
|
||||
/**
|
||||
* Determines whether the queen can work.
|
||||
*
|
||||
* @param housing the {@link IBeeHousing} the bee currently resides in.
|
||||
* @return the error code encountered.
|
||||
* @deprecated since Forestry 3.6. Use getCanWork
|
||||
*/
|
||||
@Deprecated
|
||||
IErrorState canWork(IBeeHousing housing);
|
||||
|
||||
}
|
||||
|
|
39
src/api/java/forestry/api/apiculture/IBeeFactory.java
Normal file
39
src/api/java/forestry/api/apiculture/IBeeFactory.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
public interface IBeeFactory {
|
||||
|
||||
/**
|
||||
* Creates a new bee species.
|
||||
* Automatically registered with AlleleManager.alleleRegistry.registerAllele()
|
||||
* See IAlleleBeeSpeciesCustom and IAlleleSpeciesCustom for adding additional properties to the returned species.
|
||||
*
|
||||
* @param uid Unique Identifier for this species
|
||||
* @param dominant Whether this species is genetically dominant (false means it is recessive)
|
||||
* @param authority Authority for the binomial name, e.g. "Sengir" on species of base Forestry.
|
||||
* @param unlocalizedName Unlocalized name for this species
|
||||
* @param unlocalizedDescription Unlocalized description for this species
|
||||
* @param branch Classification of this species
|
||||
* @param binomial Binomial name of the species sans genus ("Apis"). "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun names or null.
|
||||
* @param primaryColor The outline color of this species
|
||||
* @param secondaryColor The body color of this species
|
||||
* @return a new bee species allele.
|
||||
*/
|
||||
IAlleleBeeSpeciesCustom createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor);
|
||||
|
||||
/**
|
||||
* Creates a new bee branch.
|
||||
* Must be registered with AlleleManager.alleleRegistry.getClassification("family.apidae").addMemberGroup();
|
||||
*
|
||||
* @param uid Unique Identifier for this branch
|
||||
* @param scientific approximates a "genus" in real life. Real life examples: "Micrapis", "Megapis"
|
||||
* @return a new bee branch
|
||||
*/
|
||||
IClassification createBranch(String uid, String scientific);
|
||||
}
|
14
src/api/java/forestry/api/apiculture/IBeeIconProvider.java
Normal file
14
src/api/java/forestry/api/apiculture/IBeeIconProvider.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public interface IBeeIconProvider {
|
||||
void registerIcons(IIconRegister register);
|
||||
IIcon getIcon(EnumBeeType type, int renderPass);
|
||||
}
|
|
@ -20,6 +20,10 @@ public interface IBeeMutation extends IMutation {
|
|||
* @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!
|
||||
* @deprecated since Forestry 3.6, use the IAlleleBeeSpecies / IBeeGenome version
|
||||
*/
|
||||
@Deprecated
|
||||
float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
|
||||
|
||||
float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1);
|
||||
}
|
||||
|
|
12
src/api/java/forestry/api/recipes/IGenericCrate.java → src/api/java/forestry/api/apiculture/IBeeMutationCustom.java
Executable file → Normal file
12
src/api/java/forestry/api/recipes/IGenericCrate.java → src/api/java/forestry/api/apiculture/IBeeMutationCustom.java
Executable file → Normal file
|
@ -1,16 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.recipes;
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.genetics.IMutationCustom;
|
||||
|
||||
public interface IGenericCrate {
|
||||
|
||||
void setContained(ItemStack crate, ItemStack contained);
|
||||
|
||||
ItemStack getContained(ItemStack crate);
|
||||
public interface IBeeMutationCustom extends IBeeMutation, IMutationCustom {
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
public interface IBeeMutationFactory {
|
||||
/**
|
||||
* Creates a new bee mutation.
|
||||
* Automatically registered with BeeManager.beeRoot.registerMutation()
|
||||
* See IBeeMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
|
||||
*
|
||||
* @param parentBee0 A parent bee for this mutation
|
||||
* @param parentBee1 A parent bee for this mutation
|
||||
* @param result The resulting alleles for this mutation
|
||||
* @param chance The chance that breeding the two parent bees will result in this mutation
|
||||
* @return a new bee mutation.
|
||||
*/
|
||||
IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance);
|
||||
}
|
|
@ -12,31 +12,40 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
boolean isMember(ItemStack stack);
|
||||
|
||||
|
||||
/**
|
||||
* @return {@link IBee} pattern parsed from the passed stack's nbt data.
|
||||
*/
|
||||
@Override
|
||||
IBee getMember(ItemStack stack);
|
||||
|
||||
@Override
|
||||
IBee getMember(NBTTagCompound compound);
|
||||
|
||||
/* GENOME CONVERSION */
|
||||
@Override
|
||||
IBee templateAsIndividual(IAllele[] template);
|
||||
|
||||
|
||||
@Override
|
||||
IBee templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
|
||||
@Override
|
||||
IBeeGenome templateAsGenome(IAllele[] template);
|
||||
|
||||
@Override
|
||||
IBeeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
/* BREEDING TRACKER */
|
||||
|
@ -44,14 +53,14 @@ public interface IBeeRoot extends ISpeciesRoot {
|
|||
* @param world
|
||||
* @return {@link IApiaristTracker} associated with the passed world.
|
||||
*/
|
||||
IApiaristTracker getBreedingTracker(World world, String player);
|
||||
IApiaristTracker getBreedingTracker(World world, GameProfile 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
|
||||
*/
|
||||
|
@ -79,16 +88,18 @@ public interface IBeeRoot extends ISpeciesRoot {
|
|||
* @return Mated {@link IBee} from the passed genomes.
|
||||
*/
|
||||
IBee getBee(World world, IBeeGenome genome, IBee mate);
|
||||
|
||||
|
||||
/* TEMPLATES */
|
||||
@Override
|
||||
ArrayList<IBee> getIndividualTemplates();
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<IBeeMutation> getMutations(boolean shuffle);
|
||||
|
||||
/* GAME MODE */
|
||||
void resetBeekeepingMode();
|
||||
|
||||
|
||||
ArrayList<IBeekeepingMode> getBeekeepingModes();
|
||||
|
||||
IBeekeepingMode getBeekeepingMode(World world);
|
||||
|
|
|
@ -21,7 +21,21 @@ public interface IBeekeepingLogic extends INBTTagable {
|
|||
|
||||
IEffectData[] getEffectData();
|
||||
|
||||
/* UPDATING */
|
||||
/**
|
||||
* Checks that the bees can work, setting error conditions on the housing where needed
|
||||
* @return true if no errors are present and doWork should be called
|
||||
*/
|
||||
boolean canWork();
|
||||
|
||||
/**
|
||||
* Performs actual work, breeding, production, etc.
|
||||
*/
|
||||
void doWork();
|
||||
|
||||
/**
|
||||
* @deprecated since Forestry 3.6. use canWork() and doWork() instead
|
||||
*/
|
||||
@Deprecated
|
||||
void update();
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.world.World;
|
|||
/**
|
||||
* Bees can be seeded either as hive drops or as mutation results.
|
||||
*
|
||||
* Add IHiveDrops to BeeManager.hiveDrops
|
||||
* Add IHiveDrops with HiveManager.get___Hive.addDrop
|
||||
*
|
||||
* @author SirSengir
|
||||
*/
|
||||
|
|
16
src/api/java/forestry/api/apiculture/IJubilanceFactory.java
Normal file
16
src/api/java/forestry/api/apiculture/IJubilanceFactory.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public interface IJubilanceFactory {
|
||||
/** The default Jubilance Provider is satisfied when the humidity and temperature are ideal for the bee. */
|
||||
IJubilanceProvider getDefault();
|
||||
|
||||
/** The Requires Resource Jubilance Provider is satisfied when a specific block is under the hive. */
|
||||
IJubilanceProvider getRequiresResource(Block block, int meta);
|
||||
}
|
15
src/api/java/forestry/api/arboriculture/TreeManager.java → src/api/java/forestry/api/apiculture/IJubilanceProvider.java
Executable file → Normal file
15
src/api/java/forestry/api/arboriculture/TreeManager.java → src/api/java/forestry/api/apiculture/IJubilanceProvider.java
Executable file → Normal file
|
@ -1,16 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
package forestry.api.apiculture;
|
||||
|
||||
public interface IJubilanceProvider {
|
||||
|
||||
public class TreeManager {
|
||||
public static int treeSpeciesCount = 0;
|
||||
|
||||
/**
|
||||
* Get your own reference to this via AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees") and save it somewhere.
|
||||
* Returns true when conditions are right to make this species Jubilant.
|
||||
* Jubilant bees can produce their Specialty products.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ITreeRoot treeInterface;
|
||||
boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing);
|
||||
}
|
13
src/api/java/forestry/api/apiculture/hives/HiveManager.java
Normal file
13
src/api/java/forestry/api/apiculture/hives/HiveManager.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture.hives;
|
||||
|
||||
public class HiveManager {
|
||||
|
||||
public static IHiveRegistry hiveRegistry;
|
||||
public static IHiveGenHelper genHelper;
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture.hives;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
|
||||
public interface IHiveDescription {
|
||||
|
||||
/**
|
||||
* The hive generator for this hive.
|
||||
*/
|
||||
IHiveGen getHiveGen();
|
||||
|
||||
/**
|
||||
* The hive block to be placed in the world.
|
||||
*/
|
||||
Block getBlock();
|
||||
int getMeta();
|
||||
|
||||
/**
|
||||
* returns true if the hive can be generated in these conditions.
|
||||
* Used as a fast early-elimination check for hives that have no hope of spawning in the area.
|
||||
*/
|
||||
boolean isGoodBiome(BiomeGenBase biome);
|
||||
boolean isGoodHumidity(EnumHumidity humidity);
|
||||
boolean isGoodTemperature(EnumTemperature temperature);
|
||||
|
||||
/**
|
||||
* float representing the relative chance a hive will generate in a chunk.
|
||||
* Default is 1.0, higher numbers result in more hives, smaller will result in fewer.
|
||||
* Tree hives want around 3.0 to 4.0 since there are less locations to generate on.
|
||||
*/
|
||||
float getGenChance();
|
||||
|
||||
/**
|
||||
* Called after successful hive generation.
|
||||
* world, x, y, z give the location of the new hive.
|
||||
**/
|
||||
void postGen(World world, int x, int y, int z);
|
||||
}
|
29
src/api/java/forestry/api/apiculture/hives/IHiveGen.java
Normal file
29
src/api/java/forestry/api/apiculture/hives/IHiveGen.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture.hives;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IHiveGen {
|
||||
|
||||
/**
|
||||
* return a Y value that the hive should try to generate at.
|
||||
* returns negative if the hive can't be placed anywhere.
|
||||
*/
|
||||
int getYForHive(World world, int x, int z);
|
||||
|
||||
/**
|
||||
* returns true if the hive can be generated at this location.
|
||||
* Used for advanced conditions, like checking that the ground below the hive is a certain type.
|
||||
*/
|
||||
boolean isValidLocation(World world, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* returns true if the hive can safely replace the block at this location.
|
||||
*/
|
||||
boolean canReplace(World world, int x, int y, int z);
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture.hives;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public interface IHiveGenHelper {
|
||||
|
||||
/**
|
||||
* Returns a hiveGen for a hive that spawns on the ground.
|
||||
* validGroundBlocks specifies which block materials it can spawn on.
|
||||
*/
|
||||
IHiveGen ground(Block... validGroundBlocks);
|
||||
|
||||
/**
|
||||
* Returns a hiveGen for a hive that spawns in trees.
|
||||
*/
|
||||
IHiveGen tree();
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture.hives;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.apiculture.IHiveDrop;
|
||||
|
||||
public interface IHiveRegistry {
|
||||
|
||||
/* Forestry Hive Names */
|
||||
public static final String forest = "Forestry:forest";
|
||||
public static final String meadows = "Forestry:meadows";
|
||||
public static final String desert = "Forestry:desert";
|
||||
public static final String jungle = "Forestry:jungle";
|
||||
public static final String end = "Forestry:end";
|
||||
public static final String snow = "Forestry:snow";
|
||||
public static final String swamp = "Forestry:swamp";
|
||||
|
||||
/**
|
||||
* Adds a new hive to be generated in the world.
|
||||
*/
|
||||
void registerHive(String hiveName, IHiveDescription hiveDescription);
|
||||
|
||||
/**
|
||||
* Add drops to a registered hive.
|
||||
*/
|
||||
void addDrops(String hiveName, IHiveDrop... drops);
|
||||
void addDrops(String hiveName, List<IHiveDrop> drop);
|
||||
}
|
6
src/api/java/forestry/api/package-info.java → src/api/java/forestry/api/apiculture/hives/package-info.java
Executable file → Normal file
6
src/api/java/forestry/api/package-info.java → src/api/java/forestry/api/apiculture/hives/package-info.java
Executable file → Normal file
|
@ -1,8 +1,8 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="Forestry", provides="ForestryAPI|core")
|
||||
package forestry.api;
|
||||
@API(apiVersion="4.1.0", owner="ForestryAPI|apiculture", provides="ForestryAPI|hives")
|
||||
package forestry.api.apiculture.hives;
|
||||
import cpw.mods.fml.common.API;
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|apiculture")
|
||||
@API(apiVersion="3.5.0", owner="ForestryAPI|core", provides="ForestryAPI|apiculture")
|
||||
package forestry.api.apiculture;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
package forestry.api.arboriculture;
|
||||
|
||||
public enum EnumGermlingType {
|
||||
SAPLING("Sapling"), BLOSSOM("Blossom"), POLLEN("Pollen"), GERMLING("Germling"), NONE("None");
|
||||
SAPLING("sapling"), BLOSSOM("blossom"), POLLEN("pollen"), GERMLING("germling"), NONE("none");
|
||||
|
||||
public static final EnumGermlingType[] VALUES = values();
|
||||
|
||||
String name;
|
||||
private final String name;
|
||||
|
||||
private EnumGermlingType(String name) {
|
||||
this.name = name;
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
******************************************************************************/
|
||||
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.IAlleleBoolean;
|
||||
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;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public enum EnumTreeChromosome implements IChromosomeType {
|
||||
|
||||
|
@ -66,6 +66,10 @@ public enum EnumTreeChromosome implements IChromosomeType {
|
|||
MATURATION(IAlleleInteger.class),
|
||||
|
||||
GIRTH(IAlleleInteger.class),
|
||||
/**
|
||||
* Determines if the tree can burn.
|
||||
*/
|
||||
FIREPROOF(IAlleleBoolean.class),
|
||||
;
|
||||
|
||||
Class<? extends IAllele> clss;
|
||||
|
|
|
@ -34,12 +34,6 @@ public interface IAlleleTreeSpecies extends IAlleleSpecies {
|
|||
*/
|
||||
Collection<IFruitFamily> getSuitableFruit();
|
||||
|
||||
/**
|
||||
* @return Trunk girth. 1 = 1x1, 2 = 2x2, etc.
|
||||
*/
|
||||
@Deprecated
|
||||
int getGirth();
|
||||
|
||||
/**
|
||||
* @param tree
|
||||
* @param world
|
||||
|
|
|
@ -15,8 +15,9 @@ import net.minecraftforge.common.EnumPlantType;
|
|||
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.world.ITreeGenData;
|
||||
|
||||
public interface ITree extends IIndividual {
|
||||
public interface ITree extends IIndividual, ITreeGenData {
|
||||
|
||||
void mate(ITree other);
|
||||
|
||||
|
|
|
@ -12,28 +12,42 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
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 {
|
||||
|
||||
|
||||
@Override
|
||||
boolean isMember(ItemStack itemstack);
|
||||
|
||||
@Override
|
||||
ITree getMember(ItemStack itemstack);
|
||||
|
||||
@Override
|
||||
ITree getMember(NBTTagCompound compound);
|
||||
|
||||
@Override
|
||||
ITree templateAsIndividual(IAllele[] template);
|
||||
|
||||
@Override
|
||||
ITree templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
@Override
|
||||
ITreeGenome templateAsGenome(IAllele[] template);
|
||||
|
||||
@Override
|
||||
ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @return {@link IArboristTracker} associated with the passed world.
|
||||
*/
|
||||
IArboristTracker getBreedingTracker(World world, String player);
|
||||
@Override
|
||||
IArboristTracker getBreedingTracker(World world, GameProfile player);
|
||||
|
||||
/* TREE SPECIFIC */
|
||||
/**
|
||||
|
@ -41,9 +55,9 @@ public interface ITreeRoot extends ISpeciesRoot {
|
|||
* @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.
|
||||
*/
|
||||
|
@ -53,12 +67,26 @@ public interface ITreeRoot extends ISpeciesRoot {
|
|||
|
||||
ITree getTree(World world, ITreeGenome genome);
|
||||
|
||||
boolean plantSapling(World world, ITree tree, String owner, int x, int y, int z);
|
||||
boolean plantSapling(World world, ITree tree, GameProfile owner, int x, int y, int z);
|
||||
|
||||
boolean setLeaves(World world, IIndividual tree, String owner, int x, int y, int z);
|
||||
/**
|
||||
* @deprecated since Forestry 3.5.0. Use ITreeGenData setLeavesDecorative.
|
||||
*/
|
||||
@Deprecated
|
||||
// decorative=true for creative and player-placed leaves. No decay, pollination, or drops.
|
||||
boolean setLeaves(World world, IIndividual tree, GameProfile owner, int x, int y, int z, boolean decorative);
|
||||
|
||||
/**
|
||||
* @deprecated since Forestry 3.5.0. Use ITreeGenData setLeaves.
|
||||
*/
|
||||
@Deprecated
|
||||
// set normal leaves created as worldgen
|
||||
boolean setLeaves(World world, IIndividual tree, GameProfile owner, int x, int y, int z);
|
||||
|
||||
@Override
|
||||
IChromosome[] templateAsChromosomes(IAllele[] template);
|
||||
|
||||
@Override
|
||||
IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, short[] indices, int x, int y, int z);
|
||||
|
@ -73,11 +101,13 @@ public interface ITreeRoot extends ISpeciesRoot {
|
|||
void registerTreekeepingMode(ITreekeepingMode mode);
|
||||
|
||||
void setTreekeepingMode(World world, String name);
|
||||
|
||||
|
||||
/* TEMPLATES */
|
||||
@Override
|
||||
ArrayList<ITree> getIndividualTemplates();
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<ITreeMutation> getMutations(boolean shuffle);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|arboriculture")
|
||||
@API(apiVersion="2.3.0", owner="ForestryAPI|core", provides="ForestryAPI|arboriculture")
|
||||
package forestry.api.arboriculture;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.circuits;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -13,7 +13,7 @@ import net.minecraft.world.World;
|
|||
public interface ICircuitRegistry {
|
||||
|
||||
/* CIRCUITS */
|
||||
HashMap<String, ICircuit> getRegisteredCircuits();
|
||||
Map<String, ICircuit> getRegisteredCircuits();
|
||||
|
||||
void registerCircuit(ICircuit circuit);
|
||||
|
||||
|
@ -21,22 +21,17 @@ public interface ICircuitRegistry {
|
|||
|
||||
ICircuitLibrary getCircuitLibrary(World world, String playername);
|
||||
|
||||
void registerLegacyMapping(int id, String uid);
|
||||
|
||||
ICircuit getFromLegacyMap(int id);
|
||||
|
||||
/* LAYOUTS */
|
||||
HashMap<String, ICircuitLayout> getRegisteredLayouts();
|
||||
Map<String, ICircuitLayout> getRegisteredLayouts();
|
||||
|
||||
void registerLayout(ICircuitLayout layout);
|
||||
|
||||
ICircuitLayout getLayout(String uid);
|
||||
|
||||
ICircuitLayout getDefaultLayout();
|
||||
|
||||
|
||||
|
||||
ICircuitBoard getCircuitboard(ItemStack itemstack);
|
||||
|
||||
|
||||
boolean isChipset(ItemStack itemstack);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|circuits")
|
||||
@API(apiVersion="2.0.0", owner="ForestryAPI|core", provides="ForestryAPI|circuits")
|
||||
package forestry.api.circuits;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
36
src/api/java/forestry/api/core/BiomeHelper.java
Normal file
36
src/api/java/forestry/api/core/BiomeHelper.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package forestry.api.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
public class BiomeHelper {
|
||||
|
||||
private static final Map<BiomeGenBase, Boolean> isBiomeHellishCache = new HashMap<BiomeGenBase, Boolean>();
|
||||
|
||||
/**
|
||||
* Determines if it can rain or snow in the given biome.
|
||||
*/
|
||||
public static boolean canRainOrSnow(BiomeGenBase biomeGenBase) {
|
||||
return biomeGenBase.getEnableSnow() || biomeGenBase.canSpawnLightningBolt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a given BiomeGenBase is of HELLISH temperature, since it is treated separately from actual temperature values.
|
||||
* Uses the BiomeDictionary.
|
||||
* @param biomeGen BiomeGenBase of the biome in question
|
||||
* @return true, if the BiomeGenBase is a Nether-type biome; false otherwise.
|
||||
*/
|
||||
public static boolean isBiomeHellish(BiomeGenBase biomeGen) {
|
||||
if (isBiomeHellishCache.containsKey(biomeGen)) {
|
||||
return isBiomeHellishCache.get(biomeGen);
|
||||
}
|
||||
|
||||
boolean isBiomeHellish = BiomeDictionary.isBiomeOfType(biomeGen, BiomeDictionary.Type.NETHER);
|
||||
isBiomeHellishCache.put(biomeGen, isBiomeHellish);
|
||||
return isBiomeHellish;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
public class BlockInterface {
|
||||
/**
|
||||
* Rather limited function to retrieve block ids.
|
||||
*
|
||||
* @param ident
|
||||
* @return ItemStack representing the block.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ItemStack getBlock(String ident) {
|
||||
ItemStack item = null;
|
||||
|
||||
try {
|
||||
String pack = ItemInterface.class.getPackage().getName();
|
||||
pack = pack.substring(0, pack.lastIndexOf('.'));
|
||||
String itemClass = pack.substring(0, pack.lastIndexOf('.')) + ".core.config.ForestryBlock";
|
||||
Object obj = Class.forName(itemClass).getField(ident).get(null);
|
||||
if (obj instanceof Block)
|
||||
item = new ItemStack((Block) obj);
|
||||
else if (obj instanceof ItemStack)
|
||||
item = (ItemStack) obj;
|
||||
} catch (Exception ex) {
|
||||
FMLLog.warning("Could not retrieve Forestry block identified by: " + ident);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,8 +5,6 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Many things Forestry use temperature and humidity of a biome to determine whether they can or how they can work or spawn at a given location.
|
||||
*
|
||||
|
@ -15,25 +13,6 @@ import java.util.ArrayList;
|
|||
public enum EnumHumidity {
|
||||
ARID("Arid"), NORMAL("Normal"), DAMP("Damp");
|
||||
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional arid biomes here. (ex. desert)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> aridBiomeIds = new ArrayList<Integer>();
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional damp biomes here. (ex. jungle)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> dampBiomeIds = new ArrayList<Integer>();
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional normal biomes here.
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> normalBiomeIds = new ArrayList<Integer>();
|
||||
|
||||
public final String name;
|
||||
|
||||
private EnumHumidity(String name) {
|
||||
|
@ -44,34 +23,21 @@ public enum EnumHumidity {
|
|||
return this.name;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> getBiomeIds(EnumHumidity humidity) {
|
||||
switch (humidity) {
|
||||
case ARID:
|
||||
return aridBiomeIds;
|
||||
case DAMP:
|
||||
return dampBiomeIds;
|
||||
case NORMAL:
|
||||
default:
|
||||
return normalBiomeIds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the EnumHumidity given a floating point representation of Minecraft Rainfall
|
||||
* Determines the EnumHumidity given a floating point representation of Minecraft Rainfall.
|
||||
* To check if rainfall is possible in a biome, use BiomeHelper.canRainOrSnow().
|
||||
* @param rawHumidity raw rainfall value
|
||||
* @return EnumHumidity corresponding to rainfall value
|
||||
*/
|
||||
public static EnumHumidity getFromValue(float rawHumidity) {
|
||||
EnumHumidity value = EnumHumidity.ARID;
|
||||
|
||||
if (rawHumidity >= 0.9f) {
|
||||
value = EnumHumidity.DAMP;
|
||||
if (rawHumidity > 0.85f) { // matches BiomeGenBase.isHighHumidity()
|
||||
return DAMP;
|
||||
}
|
||||
else if (rawHumidity >= 0.3f) {
|
||||
value = EnumHumidity.NORMAL;
|
||||
return NORMAL;
|
||||
}
|
||||
else {
|
||||
return ARID;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,12 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
/**
|
||||
* Many things Forestry use temperature and humidity of a biome to determine whether they can or how they can work or spawn at a given location.
|
||||
*
|
||||
|
@ -24,43 +20,6 @@ public enum EnumTemperature {
|
|||
NONE("None", "habitats/ocean"), ICY("Icy", "habitats/snow"), COLD("Cold", "habitats/taiga"),
|
||||
NORMAL("Normal", "habitats/plains"), WARM("Warm", "habitats/jungle"), HOT("Hot", "habitats/desert"), HELLISH("Hellish", "habitats/nether");
|
||||
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional icy/snow biomes here. (ex. snow plains)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> icyBiomeIds = new ArrayList<Integer>();
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional cold biomes here. (ex. taiga)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> coldBiomeIds = new ArrayList<Integer>();
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional normal biomes here. (ex. forest, plains)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> normalBiomeIds = new ArrayList<Integer>();
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional warm biomes here. (ex. jungle)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> warmBiomeIds = new ArrayList<Integer>();
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional hot biomes here. (ex. desert)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> hotBiomeIds = new ArrayList<Integer>();
|
||||
/**
|
||||
* Populated by Forestry with vanilla biomes. Add additional hellish biomes here. (ex. nether)
|
||||
* @deprecated Biomes will be checked live rather than relying on cached values, so you don't have to register them.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> hellishBiomeIds = new ArrayList<Integer>();
|
||||
|
||||
public final String name;
|
||||
public final String iconIndex;
|
||||
|
||||
|
@ -77,74 +36,44 @@ public enum EnumTemperature {
|
|||
public IIcon getIcon() {
|
||||
return ForestryAPI.textureManager.getDefault(iconIndex);
|
||||
}
|
||||
/**
|
||||
* @deprecated Switching most internals to use getFromValue to not rely on cached values.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ArrayList<Integer> getBiomeIds(EnumTemperature temperature) {
|
||||
|
||||
switch (temperature) {
|
||||
case ICY:
|
||||
return icyBiomeIds;
|
||||
case COLD:
|
||||
return coldBiomeIds;
|
||||
case WARM:
|
||||
return warmBiomeIds;
|
||||
case HOT:
|
||||
return hotBiomeIds;
|
||||
case HELLISH:
|
||||
return hellishBiomeIds;
|
||||
case NORMAL:
|
||||
default:
|
||||
return normalBiomeIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a given BiomeGenBase is of HELLISH temperature, since it is treated seperatly from actual temperature values.
|
||||
* Uses the BiomeDictionary.
|
||||
* @param biomeGen BiomeGenBase of the biome in question
|
||||
* @return true, if the BiomeGenBase is a Nether-type biome; false otherwise.
|
||||
*/
|
||||
public static boolean isBiomeHellish(BiomeGenBase biomeGen) {
|
||||
return BiomeDictionary.isBiomeOfType(biomeGen, BiomeDictionary.Type.NETHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a given biomeID is of HELLISH temperature, since it is treated seperatly from actual temperature values.
|
||||
* Uses the BiomeDictionary.
|
||||
* @param biomeID ID of the BiomeGenBase in question
|
||||
* @return true, if the biomeID is a Nether-type biome; false otherwise.
|
||||
*/
|
||||
public static boolean isBiomeHellish(int biomeID) {
|
||||
return BiomeDictionary.isBiomeRegistered(biomeID) && BiomeDictionary.isBiomeOfType(BiomeGenBase.getBiome(biomeID), BiomeDictionary.Type.NETHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the EnumTemperature given a floating point representation of
|
||||
* Minecraft temperature. Hellish biomes are handled based on their biome
|
||||
* type - check isBiomeHellish.
|
||||
* type - check BiomeHelper.isBiomeHellish.
|
||||
* @param rawTemp raw temperature value
|
||||
* @return EnumTemperature corresponding to value of rawTemp
|
||||
*/
|
||||
public static EnumTemperature getFromValue(float rawTemp) {
|
||||
EnumTemperature value = EnumTemperature.ICY;
|
||||
|
||||
if (rawTemp >= 2.0f) {
|
||||
value = EnumTemperature.HOT;
|
||||
if (rawTemp > 1.00f) {
|
||||
return HOT;
|
||||
}
|
||||
else if (rawTemp >= 0.95f) {
|
||||
value = EnumTemperature.WARM;
|
||||
else if (rawTemp > 0.85f) {
|
||||
return WARM;
|
||||
}
|
||||
else if (rawTemp >= 0.2f) {
|
||||
value = EnumTemperature.NORMAL;
|
||||
else if (rawTemp > 0.35f) {
|
||||
return NORMAL;
|
||||
}
|
||||
else if (rawTemp >= 0.05f) {
|
||||
value = EnumTemperature.COLD;
|
||||
else if (rawTemp > 0.0f) {
|
||||
return COLD;
|
||||
}
|
||||
else {
|
||||
return ICY;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static EnumTemperature getFromBiome(BiomeGenBase biomeGenBase) {
|
||||
if (BiomeHelper.isBiomeHellish(biomeGenBase)) {
|
||||
return HELLISH;
|
||||
}
|
||||
return getFromValue(biomeGenBase.temperature);
|
||||
}
|
||||
|
||||
public static EnumTemperature getFromBiome(BiomeGenBase biomeGenBase, int x, int y, int z) {
|
||||
if (BiomeHelper.isBiomeHellish(biomeGenBase)) {
|
||||
return HELLISH;
|
||||
}
|
||||
float temperature = biomeGenBase.getFloatTemperature(x, y, z);
|
||||
return getFromValue(temperature);
|
||||
}
|
||||
}
|
||||
|
|
77
src/api/java/forestry/api/core/ErrorStateRegistry.java
Normal file
77
src/api/java/forestry/api/core/ErrorStateRegistry.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
*******************************************************************************
|
||||
*/
|
||||
package forestry.api.core;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CovertJaguar <http://www.railcraft.info/>
|
||||
*/
|
||||
public class ErrorStateRegistry {
|
||||
|
||||
private static final BiMap<Short, IErrorState> states = HashBiMap.create();
|
||||
private static final Map<String, IErrorState> stateNames = new HashMap<String, IErrorState>();
|
||||
private static final Set<IErrorState> stateView = Collections.unmodifiableSet(states.inverse().keySet());
|
||||
|
||||
public static void registerErrorState(IErrorState state) {
|
||||
if (states.containsKey(state.getID()))
|
||||
throw new RuntimeException("Forestry Error State does not possess a unique id.");
|
||||
states.put(state.getID(), state);
|
||||
addStateName(state, state.getUniqueName());
|
||||
}
|
||||
|
||||
public static void addAlias(IErrorState state, String name) {
|
||||
if (!states.values().contains(state))
|
||||
throw new RuntimeException("Forestry Error State did not exist while trying to register alias.");
|
||||
addStateName(state, name);
|
||||
}
|
||||
|
||||
private static void addStateName(IErrorState state, String name) {
|
||||
if (!name.contains(":"))
|
||||
throw new RuntimeException("Forestry Error State name must be in the format <modid>:<name>.");
|
||||
if (stateNames.containsKey(name))
|
||||
throw new RuntimeException("Forestry Error State does not possess a unique name.");
|
||||
stateNames.put(name, state);
|
||||
}
|
||||
|
||||
public static IErrorState getErrorState(short id) {
|
||||
return states.get(id);
|
||||
}
|
||||
|
||||
public static IErrorState getErrorState(String name) {
|
||||
return stateNames.get(name);
|
||||
}
|
||||
|
||||
public static Set<IErrorState> getErrorStates() {
|
||||
return stateView;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void initIcons(IIconRegister register) {
|
||||
for (IErrorState code : states.values()) {
|
||||
code.registerIcons(register);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -48,5 +50,11 @@ public class ForestryAPI {
|
|||
* Provides information on certain Forestry constants (Villager IDs, Chest gen keys, etc)
|
||||
*/
|
||||
public static IForestryConstants forestryConstants;
|
||||
|
||||
|
||||
/**
|
||||
* The currently enabled Forestry plugins.
|
||||
* Can be used to check if certain features are available, for example:
|
||||
* ForestryAPI.enabledPlugins.contains("APICULTURE")
|
||||
*/
|
||||
public static Set<String> enabledPlugins;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ package forestry.api.core;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
@ -15,36 +17,36 @@ import forestry.api.genetics.IMutation;
|
|||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public abstract class ForestryEvent extends Event {
|
||||
|
||||
|
||||
private static abstract class BreedingEvent extends ForestryEvent {
|
||||
public final ISpeciesRoot root;
|
||||
public final IBreedingTracker tracker;
|
||||
public final String username;
|
||||
|
||||
private BreedingEvent(ISpeciesRoot root, String username, IBreedingTracker tracker) {
|
||||
public final GameProfile username;
|
||||
|
||||
private BreedingEvent(ISpeciesRoot root, GameProfile username, IBreedingTracker tracker) {
|
||||
super();
|
||||
this.root = root;
|
||||
this.username = username;
|
||||
this.tracker = tracker;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SpeciesDiscovered extends BreedingEvent {
|
||||
public final IAlleleSpecies species;
|
||||
public SpeciesDiscovered(ISpeciesRoot root, String username, IAlleleSpecies species, IBreedingTracker tracker) {
|
||||
public SpeciesDiscovered(ISpeciesRoot root, GameProfile username, IAlleleSpecies species, IBreedingTracker tracker) {
|
||||
super(root, username, tracker);
|
||||
this.species = species;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MutationDiscovered extends BreedingEvent {
|
||||
public final IMutation allele;
|
||||
public MutationDiscovered(ISpeciesRoot root, String username, IMutation allele, IBreedingTracker tracker) {
|
||||
public MutationDiscovered(ISpeciesRoot root, GameProfile username, IMutation allele, IBreedingTracker tracker) {
|
||||
super(root, username, tracker);
|
||||
this.allele = allele;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SyncedBreedingTracker extends ForestryEvent {
|
||||
public final IBreedingTracker tracker;
|
||||
public final EntityPlayer player;
|
||||
|
@ -53,6 +55,6 @@ public abstract class ForestryEvent extends Event {
|
|||
this.tracker = tracker;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
41
src/api/java/forestry/api/core/IErrorState.java
Normal file
41
src/api/java/forestry/api/core/IErrorState.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
*******************************************************************************
|
||||
*/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CovertJaguar <http://www.railcraft.info/>
|
||||
*/
|
||||
public interface IErrorState {
|
||||
|
||||
short getID();
|
||||
|
||||
String getUniqueName();
|
||||
|
||||
String getDescription();
|
||||
|
||||
String getHelp();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerIcons(IIconRegister register);
|
||||
|
||||
@SideOnly(value = Side.CLIENT)
|
||||
IIcon getIcon();
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
/**
|
||||
* Optional way to hook into Forestry.
|
||||
*
|
||||
* Plugin classes can reside in any package, their class name however has to start with 'Plugin', i.e. 'PluginMyStuff'.
|
||||
*
|
||||
* @author SirSengir
|
||||
*/
|
||||
public interface IPlugin {
|
||||
|
||||
/**
|
||||
* @return true if the plugin is to be loaded.
|
||||
*/
|
||||
public boolean isAvailable();
|
||||
|
||||
/**
|
||||
* Called during Forestry's @PreInit.
|
||||
*/
|
||||
public void preInit();
|
||||
|
||||
/**
|
||||
* Called at the start of Forestry's @PostInit.
|
||||
*/
|
||||
public void doInit();
|
||||
|
||||
/**
|
||||
* Called at the end of Forestry's @PostInit.
|
||||
*/
|
||||
public void postInit();
|
||||
|
||||
}
|
52
src/api/java/forestry/api/core/ISpecialInventory.java
Normal file
52
src/api/java/forestry/api/core/ISpecialInventory.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Taken from BuildCraft 5.0.x
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ISpecialInventory extends IInventory {
|
||||
|
||||
/**
|
||||
* Offers an ItemStack for addition to the inventory.
|
||||
*
|
||||
* @param stack
|
||||
* ItemStack offered for addition. Do not manipulate this!
|
||||
* @param doAdd
|
||||
* If false no actual addition should take place. Implementors should simulate.
|
||||
* @param from
|
||||
* Orientation the ItemStack is offered from.
|
||||
* @return Amount of items used from the passed stack.
|
||||
*/
|
||||
@Deprecated
|
||||
int addItem(ItemStack stack, boolean doAdd, ForgeDirection from);
|
||||
|
||||
/**
|
||||
* Requests items to be extracted from the inventory
|
||||
*
|
||||
* @param doRemove
|
||||
* If false no actual extraction may occur. Implementors should simulate.
|
||||
* Can be used to "peek" at what the result would be
|
||||
* @param from
|
||||
* Orientation the ItemStack is requested from.
|
||||
* @param maxItemCount
|
||||
* Maximum amount of items to extract (spread over all returned item stacks)
|
||||
* @return Array of item stacks that were/would be extracted from the inventory
|
||||
*/
|
||||
@Deprecated
|
||||
ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount);
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
|
@ -41,9 +41,9 @@ public interface ITileStructure {
|
|||
void setCentralTE(TileEntity tile);
|
||||
|
||||
/**
|
||||
* @return IInventory representing the TE's inventory.
|
||||
* @return ISidedInventory representing the inventory accessed from this block.
|
||||
*/
|
||||
IInventory getInventory();
|
||||
ISidedInventory getStructureInventory();
|
||||
|
||||
/**
|
||||
* Only called on Forestry's own blocks.
|
||||
|
|
54
src/api/java/forestry/api/core/IToolPipette.java
Normal file
54
src/api/java/forestry/api/core/IToolPipette.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
/**
|
||||
* Taken from BuildCraft 5.0.x
|
||||
*/
|
||||
public interface IToolPipette {
|
||||
|
||||
/**
|
||||
* @param pipette
|
||||
* ItemStack of the pipette.
|
||||
* @return Capacity of the pipette.
|
||||
*/
|
||||
int getCapacity(ItemStack pipette);
|
||||
|
||||
/**
|
||||
* @param pipette
|
||||
* @return true if the pipette can pipette.
|
||||
*/
|
||||
boolean canPipette(ItemStack pipette);
|
||||
|
||||
/**
|
||||
* Fills the pipette with the given liquid stack.
|
||||
*
|
||||
* @param pipette
|
||||
* @param liquid
|
||||
* @param doFill
|
||||
* @return Amount of liquid used in filling the pipette.
|
||||
*/
|
||||
int fill(ItemStack pipette, FluidStack liquid, boolean doFill);
|
||||
|
||||
/**
|
||||
* Drains liquid from the pipette
|
||||
*
|
||||
* @param pipette
|
||||
* @param maxDrain
|
||||
* @param doDrain
|
||||
* @return Fluid stack representing the liquid and amount drained from the pipette.
|
||||
*/
|
||||
FluidStack drain(ItemStack pipette, int maxDrain, boolean doDrain);
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
/**
|
||||
* This is going away someday, use FML's GameRegistry instead.
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public class ItemInterface {
|
||||
|
||||
/**
|
||||
* Get items here!
|
||||
*
|
||||
* Blocks currently not supported.
|
||||
*
|
||||
* @param ident
|
||||
* @return ItemStack representing the item, null if not found.
|
||||
*/
|
||||
public static ItemStack getItem(String ident) {
|
||||
ItemStack item = null;
|
||||
|
||||
try {
|
||||
String pack = ItemInterface.class.getPackage().getName();
|
||||
pack = pack.substring(0, pack.lastIndexOf('.'));
|
||||
String itemClass = pack.substring(0, pack.lastIndexOf('.')) + ".core.config.ForestryItem";
|
||||
Object[] enums = Class.forName(itemClass).getEnumConstants();
|
||||
for (Object e : enums) {
|
||||
if (e.toString().equals(ident)) {
|
||||
Method m = e.getClass().getMethod("getItemStack");
|
||||
return (ItemStack) m.invoke(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
FMLLog.warning("Could not retrieve Forestry item identified by: " + ident);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Optional annotation to provide additional information on IPlugins. This information will be available via the "/forestry plugin info $pluginID" command ingame.
|
||||
*
|
||||
* @author SirSengir
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PluginInfo {
|
||||
|
||||
/**
|
||||
* @return Unique identifier for the plugin, no spaces!
|
||||
*/
|
||||
String pluginID();
|
||||
|
||||
/**
|
||||
* @return Nice and readable plugin name.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* @return Plugin author's name.
|
||||
*/
|
||||
String author() default "";
|
||||
|
||||
/**
|
||||
* @return URL of plugin homepage.
|
||||
*/
|
||||
String url() default "";
|
||||
|
||||
/**
|
||||
* @return Version of the plugin, if any.
|
||||
*/
|
||||
String version() default "";
|
||||
|
||||
/**
|
||||
* @return Short description what the plugin does.
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* @return Not used (yet?).
|
||||
*/
|
||||
String help() default "";
|
||||
|
||||
}
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="Forestry", provides="ForestryAPI|core")
|
||||
@API(apiVersion="3.2.0", owner="Forestry", provides="ForestryAPI|core")
|
||||
package forestry.api.core;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -32,6 +32,8 @@ public interface IFarmLogic {
|
|||
|
||||
Collection<ICrop> harvest(int x, int y, int z, ForgeDirection direction, int extent);
|
||||
|
||||
IFarmLogic setManual(boolean manual);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon getIcon();
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.farming;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -54,6 +55,6 @@ public interface IFarmable {
|
|||
* @param z
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
boolean plantSaplingAt(ItemStack germling, World world, int x, int y, int z);
|
||||
boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, int x, int y, int z);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|farming")
|
||||
@API(apiVersion="1.1.0", owner="ForestryAPI|core", provides="ForestryAPI|farming")
|
||||
package forestry.api.farming;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -17,6 +17,8 @@ public interface IInfuserManager {
|
|||
|
||||
boolean hasMixtures(ItemStack[] ingredients);
|
||||
|
||||
boolean isIngredient(ItemStack itemstack);
|
||||
|
||||
ItemStack[] getRequired(ItemStack[] ingredients);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|food")
|
||||
@API(apiVersion="1.1.0", owner="ForestryAPI|core", provides="ForestryAPI|food")
|
||||
package forestry.api.food;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -5,30 +5,36 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.fuels;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class FuelManager {
|
||||
/**
|
||||
* Add new fuels for the fermenter here (i.e. fertilizer). Will accept Items, ItemStacks and Strings (Ore Dictionary)
|
||||
* Add new fuels for the fermenter here (i.e. fertilizer).
|
||||
*/
|
||||
public static HashMap<Object, FermenterFuel> fermenterFuel;
|
||||
public static HashMap<ItemStack, FermenterFuel> fermenterFuel;
|
||||
/**
|
||||
* Add new resources for the moistener here (i.e. wheat)
|
||||
*/
|
||||
public static HashMap<Object, MoistenerFuel> moistenerResource;
|
||||
public static HashMap<ItemStack, MoistenerFuel> moistenerResource;
|
||||
/**
|
||||
* Add new substrates for the rainmaker here
|
||||
*/
|
||||
public static HashMap<Object, RainSubstrate> rainSubstrate;
|
||||
public static HashMap<ItemStack, RainSubstrate> rainSubstrate;
|
||||
/**
|
||||
* Add new fuels for EngineBronze (= biogas engine) here
|
||||
*/
|
||||
public static HashMap<Object, EngineBronzeFuel> bronzeEngineFuel;
|
||||
public static HashMap<Fluid, EngineBronzeFuel> bronzeEngineFuel;
|
||||
/**
|
||||
* Add new fuels for EngineCopper (= peat-fired engine) here
|
||||
*/
|
||||
public static HashMap<Object, EngineCopperFuel> copperEngineFuel;
|
||||
public static HashMap<ItemStack, EngineCopperFuel> copperEngineFuel;
|
||||
/**
|
||||
* Add new fuels for Generator here
|
||||
*/
|
||||
public static HashMap<Fluid, GeneratorFuel> generatorFuel;
|
||||
|
||||
// Generator fuel list in GeneratorFuel.class
|
||||
}
|
||||
|
|
|
@ -5,14 +5,10 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.fuels;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class GeneratorFuel {
|
||||
|
||||
public static HashMap<Integer, GeneratorFuel> fuels = new HashMap<Integer, GeneratorFuel>();
|
||||
|
||||
/**
|
||||
* LiquidStack representing the fuel type and amount consumed per triggered cycle.
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|fuels")
|
||||
@API(apiVersion="2.0.1", owner="ForestryAPI|core", provides="ForestryAPI|fuels")
|
||||
package forestry.api.fuels;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -29,4 +29,8 @@ public class AlleleManager {
|
|||
* Queryable instance of an {@link IClimateHelper} for easier implementation.
|
||||
*/
|
||||
public static IClimateHelper climateHelper;
|
||||
/**
|
||||
* Creates Forestry alleles.
|
||||
*/
|
||||
public static IAlleleFactory alleleFactory;
|
||||
}
|
||||
|
|
|
@ -30,5 +30,10 @@ public interface IAllele {
|
|||
* @return Localized short, human-readable identifier used in tooltips and beealyzer.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
|
||||
/**
|
||||
* @return The unlocalized identifier
|
||||
*/
|
||||
String getUnlocalizedName();
|
||||
|
||||
}
|
||||
|
|
80
src/api/java/forestry/api/genetics/IAlleleFactory.java
Normal file
80
src/api/java/forestry/api/genetics/IAlleleFactory.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
package forestry.api.genetics;
|
||||
|
||||
/**
|
||||
* Creates new alleles with smart localization.
|
||||
*
|
||||
*
|
||||
* UID is created like this:
|
||||
* modId + '.' + category + WordUtils.capitalize(valueName);
|
||||
* For Example:
|
||||
* modId:forestry, category:height, valueName:smallest => forestry.heightSmallest
|
||||
* This is mainly for legacy compatibility and may change in future major versions.
|
||||
*
|
||||
*
|
||||
* The default localization uses:
|
||||
* [modId].allele.[valueName]
|
||||
*
|
||||
* Languages that need category-specific names can override it by defining:
|
||||
* [modId].allele.[category].[valueName]
|
||||
*
|
||||
* For example:
|
||||
* en_US
|
||||
* forestry.allele.smallest=Smallest
|
||||
* ru_RU
|
||||
* forestry.allele.smallest=????? ?????????
|
||||
* forestry.allele.height.smallest=????? ??????
|
||||
*/
|
||||
public interface IAlleleFactory {
|
||||
/**
|
||||
* @param modId mod prefix for uid and localization (i.e. "forestry")
|
||||
* @param category allele category for uid and localization (i.e. "height")
|
||||
* @param valueName allele value name for uid and localization (i.e. "smallest")
|
||||
* @param value allele float value
|
||||
* @param isDominant allele dominance
|
||||
* @return a new IAlleleFloat
|
||||
*/
|
||||
IAlleleFloat createFloat(String modId, String category, String valueName, float value, boolean isDominant);
|
||||
|
||||
/**
|
||||
* @param modId mod prefix for uid and localization (i.e. "forestry")
|
||||
* @param category allele category for uid and localization (i.e. "territory")
|
||||
* @param valueName allele value name for uid and localization (i.e. "large")
|
||||
* @param xDimValue allele area X Size
|
||||
* @param yDimValue allele area Y Size
|
||||
* @param zDimValue allele area Z Size
|
||||
* @param isDominant allele dominance
|
||||
* @return a new IAlleleArea
|
||||
*/
|
||||
IAlleleArea createArea(String modId, String category, String valueName, int xDimValue, int yDimValue, int zDimValue, boolean isDominant);
|
||||
|
||||
/**
|
||||
* @param modId mod prefix for uid and localization (i.e. "forestry")
|
||||
* @param category allele category for uid and localization (i.e. "fertility")
|
||||
* @param valueName allele value name for uid and localization (i.e. "low")
|
||||
* @param value allele int value
|
||||
* @param isDominant allele dominance
|
||||
* @return a new IAlleleInteger
|
||||
*/
|
||||
IAlleleInteger createInteger(String modId, String category, String valueName, int value, boolean isDominant);
|
||||
|
||||
/**
|
||||
* @param modId mod prefix for uid and localization (i.e. "forestry")
|
||||
* @param category allele category for uid and localization (i.e. "fireproof")
|
||||
* @param value allele boolean value
|
||||
* @param isDominant allele dominance
|
||||
* @return a new IAlleleBoolean
|
||||
* Note that valueName will always be "true" or "false"
|
||||
*/
|
||||
IAlleleBoolean createBoolean(String modId, String category, boolean value, boolean isDominant);
|
||||
|
||||
/**
|
||||
* @param modId mod prefix for uid (i.e. "forestry")
|
||||
* @param category allele category for uid (i.e. "flowers")
|
||||
* @param valueName allele value name for uid (i.e. "vanilla")
|
||||
* @param value allele IFlowerProvider value
|
||||
* @param isDominant allele dominance
|
||||
* @return a new IAlleleFlowers
|
||||
* IAlleleFlowers localization is handled by the IFlowerProvider.getDescription(), unlike the other alleles.
|
||||
*/
|
||||
IAlleleFlowers createFlowers(String modId, String category, String valueName, IFlowerProvider value, boolean isDominant);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
@ -9,7 +9,8 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IClassification.EnumClassLevel;
|
||||
|
||||
|
@ -38,21 +39,21 @@ public interface IAlleleRegistry {
|
|||
* @return {@link ISpeciesRoot} if it exists, null otherwise.
|
||||
*/
|
||||
ISpeciesRoot getSpeciesRoot(String uid);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a matching {@link ISpeciesRoot} for the given itemstack.
|
||||
* @param stack An itemstack possibly containing NBT data which can be converted by a species root.
|
||||
* @return {@link ISpeciesRoot} if found, null otherwise.
|
||||
*/
|
||||
ISpeciesRoot getSpeciesRoot(ItemStack stack);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual}-class.
|
||||
* @param clz Class extending {@link IIndividual}.
|
||||
* @return {@link ISpeciesRoot} if found, null otherwise.
|
||||
*/
|
||||
ISpeciesRoot getSpeciesRoot(Class<? extends IIndividual> clz);
|
||||
|
||||
|
||||
/* INDIVIDUAL */
|
||||
/**
|
||||
* Tests the itemstack for genetic information.
|
||||
|
@ -85,7 +86,7 @@ public interface IAlleleRegistry {
|
|||
* IAllele to register.
|
||||
*/
|
||||
void registerAllele(IAllele allele);
|
||||
|
||||
|
||||
/**
|
||||
* @return HashMap of all registered deprecated alleles and their corresponding replacements
|
||||
*/
|
||||
|
@ -110,16 +111,6 @@ public interface IAlleleRegistry {
|
|||
*/
|
||||
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.
|
||||
|
@ -215,13 +206,13 @@ public interface IAlleleRegistry {
|
|||
* @param species {@link IAlleleSpecies} to encode on the research note.
|
||||
* @return An itemstack containing a research note with the given species encoded onto it.
|
||||
*/
|
||||
ItemStack getSpeciesNoteStack(String researcher, IAlleleSpecies species);
|
||||
|
||||
ItemStack getSpeciesNoteStack(GameProfile researcher, IAlleleSpecies species);
|
||||
|
||||
/**
|
||||
* @param researcher Username of the player who researched this note.
|
||||
* @param mutation {@link IMutation} to encode on the research note.
|
||||
* @return An itemstack containing a research note with the given mutation encoded onto it.
|
||||
*/
|
||||
ItemStack getMutationNoteStack(String researcher, IMutation mutation);
|
||||
ItemStack getMutationNoteStack(GameProfile researcher, IMutation mutation);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ package forestry.api.genetics;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -16,10 +18,10 @@ import forestry.api.core.EnumTemperature;
|
|||
import forestry.api.core.IIconProvider;
|
||||
|
||||
/**
|
||||
* Basic species allele.
|
||||
* Basic species allele.
|
||||
*/
|
||||
public interface IAlleleSpecies extends IAllele {
|
||||
|
||||
|
||||
/**
|
||||
* @return the {@link ISpeciesRoot} associated with this species.
|
||||
*/
|
||||
|
@ -57,22 +59,22 @@ public interface IAlleleSpecies extends IAllele {
|
|||
* @return Values between 3 - 11 are useful.
|
||||
*/
|
||||
int getComplexity();
|
||||
|
||||
|
||||
/**
|
||||
* @param itemstack
|
||||
* @return A float signifying the chance for the passed itemstack to yield a research success.
|
||||
*/
|
||||
float getResearchSuitability(ItemStack itemstack);
|
||||
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param researcher
|
||||
* @param gameProfile
|
||||
* @param individual
|
||||
* @param bountyLevel
|
||||
* @return Array of itemstacks representing the bounty for this research success.
|
||||
*/
|
||||
ItemStack[] getResearchBounty(World world, String researcher, IIndividual individual, int bountyLevel);
|
||||
|
||||
ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual individual, int bountyLevel);
|
||||
|
||||
/* CLIMATE */
|
||||
/**
|
||||
* @return Preferred temperature
|
||||
|
|
23
src/api/java/forestry/api/genetics/IAlleleSpeciesCustom.java
Normal file
23
src/api/java/forestry/api/genetics/IAlleleSpeciesCustom.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
|
||||
public interface IAlleleSpeciesCustom extends IAlleleSpecies {
|
||||
|
||||
IAlleleSpeciesCustom setTemperature(EnumTemperature temperature);
|
||||
IAlleleSpeciesCustom setHumidity(EnumHumidity humidity);
|
||||
|
||||
IAlleleSpeciesCustom setHasEffect();
|
||||
|
||||
/** Secret species are not shown in creative mode. */
|
||||
IAlleleSpeciesCustom setIsSecret();
|
||||
|
||||
/** Uncounted species do not count toward total species discovered. */
|
||||
IAlleleSpeciesCustom setIsNotCounted();
|
||||
}
|
|
@ -53,12 +53,6 @@ public interface IBreedingTracker {
|
|||
*/
|
||||
void registerSpecies(IAlleleSpecies species);
|
||||
|
||||
/**
|
||||
* Register a successful mutation. Will mark it as discovered.
|
||||
*/
|
||||
@Deprecated
|
||||
void registerMutation(IAllele allele0, IAllele allele1);
|
||||
|
||||
/**
|
||||
* Register a successful mutation. Will mark it as discovered.
|
||||
*
|
||||
|
|
|
@ -19,6 +19,9 @@ public interface IClimateHelper {
|
|||
boolean isWithinLimits(EnumTemperature temperature, EnumHumidity humidity,
|
||||
EnumTemperature baseTemp, EnumTolerance tolTemp,
|
||||
EnumHumidity baseHumid, EnumTolerance tolHumid);
|
||||
|
||||
boolean isWithinLimits(EnumTemperature temperature, EnumTemperature baseTemp, EnumTolerance tolTemp);
|
||||
boolean isWithinLimits(EnumHumidity humidity, EnumHumidity baseHumid, EnumTolerance tolHumid);
|
||||
|
||||
/**
|
||||
* Gets a collection of humidities which fit the given parameters.
|
||||
|
@ -43,7 +46,7 @@ public interface IClimateHelper {
|
|||
String toDisplay(EnumTemperature temperature);
|
||||
/**
|
||||
* Gets a localized, human readable string for the given humidity.
|
||||
* @param temperature Humidity to generate the string for.
|
||||
* @param humidity Humidity to generate the string for.
|
||||
* @return A localized, human readable string for the given humidity.
|
||||
*/
|
||||
String toDisplay(EnumHumidity humidity);
|
||||
|
|
19
src/api/java/forestry/api/genetics/ILegacyHandler.java → src/api/java/forestry/api/genetics/IFlower.java
Executable file → Normal file
19
src/api/java/forestry/api/genetics/ILegacyHandler.java → src/api/java/forestry/api/genetics/IFlower.java
Executable file → Normal file
|
@ -1,15 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
/**
|
||||
* AlleleManager.alleleRegistry can be cast to this type.
|
||||
*/
|
||||
public interface ILegacyHandler {
|
||||
void registerLegacyMapping(int id, String uid);
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public interface IFlower extends Comparable<IFlower> {
|
||||
|
||||
Block getBlock();
|
||||
int getMeta();
|
||||
|
||||
double getWeight();
|
||||
void setWeight(double weight);
|
||||
|
||||
boolean isPlantable();
|
||||
|
||||
IAllele getFromLegacyMap(int id);
|
||||
}
|
15
src/api/java/forestry/api/genetics/IFlowerGrowthRule.java
Normal file
15
src/api/java/forestry/api/genetics/IFlowerGrowthRule.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Basic condition for flower growing
|
||||
*/
|
||||
public interface IFlowerGrowthRule {
|
||||
boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z);
|
||||
}
|
|
@ -5,16 +5,13 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IFlowerProvider {
|
||||
/**
|
||||
* @param world
|
||||
* @param individual
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return True if the block at the passed coordinates is a valid flower for the species.
|
||||
*/
|
||||
boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z);
|
||||
|
@ -22,11 +19,6 @@ public interface IFlowerProvider {
|
|||
boolean isAcceptedPollinatable(World world, IPollinatable pollinatable);
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param individual
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return True if a flower was planted.
|
||||
*/
|
||||
boolean growFlower(World world, IIndividual individual, int x, int y, int z);
|
||||
|
@ -38,19 +30,14 @@ public interface IFlowerProvider {
|
|||
|
||||
/**
|
||||
* Allows the flower provider to affect the produce at the given location.
|
||||
* @param world
|
||||
* @param individual
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param products
|
||||
*
|
||||
* @return Array of itemstacks being the (modified or unmodified) produce.
|
||||
*/
|
||||
ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products);
|
||||
|
||||
/**
|
||||
* @return Array of itemstacks representing valid flowers for the flower provider. The first in the array is for use as an icon Return null or an empty
|
||||
* array if the flower does not have an itemstack
|
||||
* @return List of valid flowers for the flower provider. The first in the array is for use as an icon.
|
||||
* Returns an empty list if the flower provider does not have any valid flowers.
|
||||
*/
|
||||
ItemStack[] getItemStacks();
|
||||
List<IFlower> getFlowers();
|
||||
}
|
||||
|
|
43
src/api/java/forestry/api/genetics/IFlowerRegistry.java
Normal file
43
src/api/java/forestry/api/genetics/IFlowerRegistry.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IFlowerRegistry {
|
||||
|
||||
List<IFlower> getAcceptableFlowers(String flowerType);
|
||||
|
||||
boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z);
|
||||
|
||||
boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Registers a non-plantable flower, but bees accept them.
|
||||
*
|
||||
* @param flowerTypes See {@link forestry.api.apiculture.FlowerManager}.FlowerTypeXXX
|
||||
*/
|
||||
void registerAcceptableFlower(Block flowerBlock, String... flowerTypes);
|
||||
void registerAcceptableFlower(Block flowerBlock, int flowerMeta, String... flowerTypes);
|
||||
|
||||
void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes);
|
||||
|
||||
/**
|
||||
* Registers a plantable flower.
|
||||
* The distribution is based on its own weight and the total number of plants for this flowerType.
|
||||
*
|
||||
* @param weight Weight for the Flower (Vanilla = 1.0, Modded flowers < 1.0)
|
||||
* @param flowerTypes See {@link forestry.api.apiculture.FlowerManager}.FlowerTypeXXX
|
||||
*/
|
||||
void registerPlantableFlower(Block flowerBlock, int flowerMeta, double weight, String... flowerTypes);
|
||||
|
||||
IFlower getRandomPlantableFlower(String flowerType, Random rand);
|
||||
|
||||
}
|
|
@ -20,9 +20,9 @@ public interface IGenome extends INBTTagable {
|
|||
|
||||
IChromosome[] getChromosomes();
|
||||
|
||||
IAllele getActiveAllele(int chromosome);
|
||||
IAllele getActiveAllele(IChromosomeType chromosomeType);
|
||||
|
||||
IAllele getInactiveAllele(int chromosome);
|
||||
IAllele getInactiveAllele(IChromosomeType chromosomeType);
|
||||
|
||||
boolean isGeneticEqual(IGenome other);
|
||||
|
||||
|
|
|
@ -5,21 +5,27 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorState;
|
||||
|
||||
/**
|
||||
* Any housing, hatchery or nest which is a fixed location in the world.
|
||||
* Any housing, hatchery or nest which is a fixed location in the world.
|
||||
*/
|
||||
public interface IHousing {
|
||||
|
||||
/**
|
||||
* @return String containing the login of this housing's owner.
|
||||
*/
|
||||
String getOwnerName();
|
||||
GameProfile getOwnerName();
|
||||
|
||||
World getWorld();
|
||||
|
||||
|
@ -29,15 +35,22 @@ public interface IHousing {
|
|||
|
||||
int getZCoord();
|
||||
|
||||
int getBiomeId();
|
||||
BiomeGenBase getBiome();
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
EnumHumidity getHumidity();
|
||||
|
||||
void setErrorState(int state);
|
||||
/**
|
||||
* Sets the errorState when condition is true, and unsets it when condition is false.
|
||||
* @return condition
|
||||
*/
|
||||
boolean setErrorCondition(boolean condition, IErrorState errorState);
|
||||
|
||||
int getErrorOrdinal();
|
||||
/**
|
||||
* @return the error states for this housing. An empty Set indicates no errors.
|
||||
*/
|
||||
Set<IErrorState> getErrorStates();
|
||||
|
||||
/**
|
||||
* Adds products to the housing's inventory.
|
||||
|
@ -45,8 +58,21 @@ public interface IHousing {
|
|||
* @param product
|
||||
* ItemStack with the product to add.
|
||||
* @param all
|
||||
* if true, success requires that all products are added
|
||||
* @return Boolean indicating success or failure.
|
||||
*/
|
||||
boolean addProduct(ItemStack product, boolean all);
|
||||
|
||||
/**
|
||||
* @deprecated since Forestry 3.6. use setErrorCondition()
|
||||
*/
|
||||
@Deprecated
|
||||
void setErrorState(IErrorState state);
|
||||
|
||||
/**
|
||||
* @deprecated since Forestry 3.6. use getErrorStates()
|
||||
*/
|
||||
@Deprecated
|
||||
IErrorState getErrorState();
|
||||
|
||||
}
|
||||
|
|
|
@ -47,11 +47,7 @@ public interface IIndividual extends INBTTagable {
|
|||
* @return A deep copy of this individual.
|
||||
*/
|
||||
IIndividual copy();
|
||||
|
||||
/**
|
||||
* @param chromosomeOrdinal Ordinal of the chromosome to check.
|
||||
* @return true if both primary and secondary allele on the given chromosome match.
|
||||
*/
|
||||
boolean isPureBred(int chromosomeOrdinal);
|
||||
|
||||
boolean isPureBred(IChromosomeType chromosomeType);
|
||||
|
||||
}
|
||||
|
|
23
src/api/java/forestry/api/genetics/IMutationCondition.java
Normal file
23
src/api/java/forestry/api/genetics/IMutationCondition.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMutationCondition {
|
||||
|
||||
/**
|
||||
* Returns a float from 0 to 1 representing the chance for mutation to occur.
|
||||
* Most will return 1 if the condition is met and 0 otherwise,
|
||||
* but the float offers flexibility for more advanced conditions.
|
||||
*/
|
||||
float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
|
||||
|
||||
/**
|
||||
* A localized description of the mutation condition. (i.e. "A temperature of HOT is required.")
|
||||
*/
|
||||
String getDescription();
|
||||
}
|
47
src/api/java/forestry/api/genetics/IMutationCustom.java
Normal file
47
src/api/java/forestry/api/genetics/IMutationCustom.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.genetics;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
|
||||
/** Set custom mutation requirements */
|
||||
public interface IMutationCustom extends IMutation {
|
||||
|
||||
/** Prevent this mutation from being shown in the analyzers */
|
||||
IMutationCustom setIsSecret();
|
||||
|
||||
/** Require a specific temperature for this mutation to occur */
|
||||
IMutationCustom restrictTemperature(EnumTemperature temperature);
|
||||
IMutationCustom restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
|
||||
|
||||
/** Require a specific humidity for this mutation to occur */
|
||||
IMutationCustom restrictHumidity(EnumHumidity humidity);
|
||||
IMutationCustom restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
|
||||
|
||||
/**
|
||||
* Restrict this mutation to certain types of biomes.
|
||||
* @param types The types of biomes this mutation can occur.
|
||||
*/
|
||||
IMutationCustom restrictBiomeType(BiomeDictionary.Type... types);
|
||||
|
||||
/** Restrict the days of the year that this mutation can occur */
|
||||
IMutationCustom restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
|
||||
|
||||
/** Restrict the time of day that this mutation can occur */
|
||||
IMutationCustom requireDay();
|
||||
IMutationCustom requireNight();
|
||||
|
||||
/** Require a specific resource to be under the location of the mutation */
|
||||
IMutationCustom requireResource(Block block, int meta);
|
||||
|
||||
/** Require some other custom mutation condition */
|
||||
IMutationCustom addMutationCondition(IMutationCondition mutationCondition);
|
||||
}
|
|
@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
/**
|
||||
* Describes a class of species (i.e. bees, trees, butterflies), provides helper functions and access to common functionality.
|
||||
*/
|
||||
|
@ -63,7 +65,7 @@ public interface ISpeciesRoot {
|
|||
ItemStack getMemberStack(IIndividual individual, int type);
|
||||
|
||||
/* BREEDING TRACKER */
|
||||
IBreedingTracker getBreedingTracker(World world, String player);
|
||||
IBreedingTracker getBreedingTracker(World world, GameProfile player);
|
||||
|
||||
/* GENOME MANIPULATION */
|
||||
IIndividual templateAsIndividual(IAllele[] template);
|
||||
|
@ -134,11 +136,7 @@ public interface ISpeciesRoot {
|
|||
*/
|
||||
Collection<? extends IMutation> getCombinations(IAllele other);
|
||||
|
||||
/**
|
||||
* @param result {@link IAllele} to search for.
|
||||
* @return All registered mutations the given {@link IAllele} is the result of.
|
||||
*/
|
||||
Collection<? extends IMutation> getPaths(IAllele result, int chromosomeOrdinal);
|
||||
Collection<? extends IMutation> getPaths(IAllele result, IChromosomeType chromosomeType);
|
||||
|
||||
/* RESEARCH */
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|genetics")
|
||||
@API(apiVersion="3.3.0", owner="ForestryAPI|core", provides="ForestryAPI|genetics")
|
||||
package forestry.api.genetics;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -13,31 +13,41 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface IButterflyRoot extends ISpeciesRoot {
|
||||
|
||||
@Override
|
||||
boolean isMember(ItemStack stack);
|
||||
|
||||
@Override
|
||||
IButterfly getMember(ItemStack stack);
|
||||
|
||||
@Override
|
||||
IButterfly getMember(NBTTagCompound compound);
|
||||
|
||||
|
||||
@Override
|
||||
ItemStack getMemberStack(IIndividual butterfly, int type);
|
||||
|
||||
/* GENOME CONVERSION */
|
||||
@Override
|
||||
IButterfly templateAsIndividual(IAllele[] template);
|
||||
|
||||
|
||||
@Override
|
||||
IButterfly templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
|
||||
@Override
|
||||
IButterflyGenome templateAsGenome(IAllele[] template);
|
||||
|
||||
@Override
|
||||
IButterflyGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
|
||||
|
||||
/* BUTTERFLY SPECIFIC */
|
||||
ILepidopteristTracker getBreedingTracker(World world, String player);
|
||||
ILepidopteristTracker getBreedingTracker(World world, GameProfile player);
|
||||
|
||||
/**
|
||||
* Spawns the given butterfly in the world.
|
||||
|
@ -52,9 +62,13 @@ public interface IButterflyRoot extends ISpeciesRoot {
|
|||
boolean isMated(ItemStack stack);
|
||||
|
||||
/* TEMPLATES */
|
||||
@Override
|
||||
ArrayList<IButterfly> getIndividualTemplates();
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<IButterflyMutation> getMutations(boolean shuffle);
|
||||
|
||||
EnumFlutterType getType(ItemStack stack);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|lepidopterology")
|
||||
@API(apiVersion="1.1", owner="ForestryAPI|core", provides="ForestryAPI|lepidopterology")
|
||||
package forestry.api.lepidopterology;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
26
src/api/java/forestry/api/mail/EnumAddressee.java
Normal file
26
src/api/java/forestry/api/mail/EnumAddressee.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.mail;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumAddressee {
|
||||
PLAYER, TRADER;
|
||||
|
||||
public static EnumAddressee fromString(String ident) {
|
||||
ident = ident.toLowerCase(Locale.ENGLISH);
|
||||
for(EnumAddressee addr : values()) {
|
||||
if(addr.toString().equals(ident))
|
||||
return addr;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
|
@ -22,15 +22,15 @@ public interface ILetter extends IInventory, INBTTagable {
|
|||
|
||||
boolean isMailable();
|
||||
|
||||
void setSender(MailAddress address);
|
||||
void setSender(IMailAddress address);
|
||||
|
||||
MailAddress getSender();
|
||||
IMailAddress getSender();
|
||||
|
||||
boolean hasRecipient();
|
||||
|
||||
void setRecipient(MailAddress address);
|
||||
void setRecipient(IMailAddress address);
|
||||
|
||||
MailAddress[] getRecipients();
|
||||
IMailAddress[] getRecipients();
|
||||
|
||||
String getRecipientString();
|
||||
|
||||
|
@ -38,8 +38,7 @@ public interface ILetter extends IInventory, INBTTagable {
|
|||
|
||||
String getText();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
void addTooltip(List list);
|
||||
void addTooltip(List<String> list);
|
||||
|
||||
boolean isPostPaid();
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
public interface ILetterHandler {
|
||||
IPostalState handleLetter(World world, String recipient, ItemStack letterStack, boolean doLodge);
|
||||
IPostalState handleLetter(World world, IMailAddress recipient, ItemStack letterStack, boolean doLodge);
|
||||
}
|
||||
|
|
23
src/api/java/forestry/api/mail/IMailAddress.java
Normal file
23
src/api/java/forestry/api/mail/IMailAddress.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.mail;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public interface IMailAddress extends INBTTagable {
|
||||
|
||||
EnumAddressee getType();
|
||||
String getName();
|
||||
|
||||
boolean isValid();
|
||||
|
||||
boolean isPlayer();
|
||||
boolean isTrader();
|
||||
|
||||
GameProfile getPlayerProfile();
|
||||
}
|
|
@ -26,5 +26,5 @@ public interface IPostOffice {
|
|||
|
||||
void deregisterTradeStation(ITradeStation trade);
|
||||
|
||||
Map<String, ITradeStation> getActiveTradeStations(World world);
|
||||
Map<IMailAddress, ITradeStation> getActiveTradeStations(World world);
|
||||
}
|
||||
|
|
|
@ -10,43 +10,49 @@ import java.util.Map;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public interface IPostRegistry {
|
||||
|
||||
|
||||
/* POST OFFICE */
|
||||
IPostOffice getPostOffice(World world);
|
||||
|
||||
/* MAIL ADDRESSES */
|
||||
IMailAddress getMailAddress(GameProfile gameProfile);
|
||||
IMailAddress getMailAddress(String traderName);
|
||||
|
||||
/* LETTERS */
|
||||
boolean isLetter(ItemStack itemstack);
|
||||
|
||||
ILetter createLetter(MailAddress sender, MailAddress recipient);
|
||||
|
||||
ILetter createLetter(IMailAddress sender, IMailAddress recipient);
|
||||
|
||||
ILetter getLetter(ItemStack itemstack);
|
||||
|
||||
|
||||
ItemStack createLetterStack(ILetter letter);
|
||||
|
||||
|
||||
/* CARRIERS */
|
||||
/**
|
||||
* Registers a new {@link IPostalCarrier}. See {@link IPostalCarrier} for details.
|
||||
* @param carrier {@link IPostalCarrier} to register.
|
||||
*/
|
||||
void registerCarrier(IPostalCarrier carrier);
|
||||
|
||||
IPostalCarrier getCarrier(String uid);
|
||||
|
||||
Map<String, IPostalCarrier> getRegisteredCarriers();
|
||||
IPostalCarrier getCarrier(EnumAddressee uid);
|
||||
|
||||
Map<EnumAddressee, IPostalCarrier> getRegisteredCarriers();
|
||||
|
||||
/* TRADE STATIONS */
|
||||
void deleteTradeStation(World world, String moniker);
|
||||
void deleteTradeStation(World world, IMailAddress address);
|
||||
|
||||
ITradeStation getOrCreateTradeStation(World world, String owner, String moniker);
|
||||
ITradeStation getOrCreateTradeStation(World world, GameProfile owner, IMailAddress address);
|
||||
|
||||
ITradeStation getTradeStation(World world, String moniker);
|
||||
ITradeStation getTradeStation(World world, IMailAddress address);
|
||||
|
||||
boolean isAvailableTradeMoniker(World world, String moniker);
|
||||
boolean isAvailableTradeAddress(World world, IMailAddress address);
|
||||
|
||||
boolean isValidTradeMoniker(World world, String moniker);
|
||||
boolean isValidTradeAddress(World world, IMailAddress address);
|
||||
|
||||
/* PO BOXES */
|
||||
boolean isValidPOBox(World world, String username);
|
||||
boolean isValidPOBox(World world, IMailAddress address);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
/**
|
||||
* Postal Carriers are systems which can be hooked into Forestry's mail system to handle mail delivery.
|
||||
*
|
||||
*
|
||||
* The two available carriers in vanilla Forestry are
|
||||
* "player" - Delivers mail to individual players.
|
||||
* "trader" - Handles mail addressed to trade stations.
|
||||
|
@ -22,27 +22,27 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
public interface IPostalCarrier {
|
||||
|
||||
/**
|
||||
* @return A lower-case identifier without spaces.
|
||||
* @return An EnumAddressee identifying the type of carrier
|
||||
*/
|
||||
String getUID();
|
||||
|
||||
EnumAddressee getType();
|
||||
|
||||
/**
|
||||
* @return A human-readable name for this carrier.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon getIcon();
|
||||
|
||||
/**
|
||||
* Handle delivery of a letter addressed to this carrier.
|
||||
* Handle delivery of a letter addressed to this carrier.
|
||||
* @param world The world the {@link IPostOffice} handles.
|
||||
* @param office {link @IPostOffice} which received this letter and handed it to the carrier.
|
||||
* @param office {link @IPostOffice} which received this letter and handed it to the carrier.
|
||||
* @param recipient An identifier for the recipient as typed by the player into the address field.
|
||||
* @param letterstack ItemStack representing the letter. See {@link IPostRegistry} for helper functions to validate and extract it.
|
||||
* @param doDeliver Whether or not the letter is supposed to actually be delivered or if delivery is only to be simulated.
|
||||
* @return {link IPostalState} holding information on success or failure for delivery.
|
||||
*/
|
||||
IPostalState deliverLetter(World world, IPostOffice office, String recipient, ItemStack letterstack, boolean doDeliver);
|
||||
IPostalState deliverLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doDeliver);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.inventory.IInventory;
|
|||
|
||||
public interface ITradeStation extends ILetterHandler, IInventory {
|
||||
|
||||
String getMoniker();
|
||||
IMailAddress getAddress();
|
||||
|
||||
boolean isValid();
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.mail;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.core.INBTTagable;
|
||||
|
||||
public class MailAddress implements INBTTagable {
|
||||
private String type;
|
||||
private String identifier;
|
||||
|
||||
private MailAddress() {
|
||||
}
|
||||
|
||||
public MailAddress(String identifier) {
|
||||
this(identifier, "player");
|
||||
}
|
||||
|
||||
public MailAddress(String identifier, String type) {
|
||||
this.identifier = identifier;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public boolean isPlayer() {
|
||||
return "player".equals(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
if(nbttagcompound.hasKey("TP"))
|
||||
type = nbttagcompound.getString("TP");
|
||||
else
|
||||
type = nbttagcompound.getShort("TYP") == 0 ? "player" : "trader";
|
||||
identifier = nbttagcompound.getString("ID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("TP", type);
|
||||
nbttagcompound.setString("ID", identifier);
|
||||
}
|
||||
|
||||
public static MailAddress loadFromNBT(NBTTagCompound nbttagcompound) {
|
||||
MailAddress address = new MailAddress();
|
||||
address.readFromNBT(nbttagcompound);
|
||||
return address;
|
||||
}
|
||||
}
|
|
@ -5,17 +5,22 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.mail;
|
||||
|
||||
import java.lang.IllegalArgumentException;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class TradeStationInfo {
|
||||
public final String moniker;
|
||||
public final String owner;
|
||||
public final IMailAddress address;
|
||||
public final GameProfile owner;
|
||||
public final ItemStack tradegood;
|
||||
public final ItemStack[] required;
|
||||
public final IPostalState state;
|
||||
|
||||
public TradeStationInfo(String moniker, String owner, ItemStack tradegood, ItemStack[] required, IPostalState state) {
|
||||
this.moniker = moniker;
|
||||
public TradeStationInfo(IMailAddress address, GameProfile owner, ItemStack tradegood, ItemStack[] required, IPostalState state) {
|
||||
if (!address.isTrader()) {
|
||||
throw new IllegalArgumentException("TradeStation address must be a trader");
|
||||
}
|
||||
this.address = address;
|
||||
this.owner = owner;
|
||||
this.tradegood = tradegood;
|
||||
this.required = required;
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|mail")
|
||||
@API(apiVersion="3.0.0", owner="ForestryAPI|core", provides="ForestryAPI|mail")
|
||||
package forestry.api.mail;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
/**
|
||||
* Provides an interface to the recipe manager of the bottler.
|
||||
*
|
||||
* The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even
|
||||
* if your mod loads before Forestry.
|
||||
*
|
||||
* Accessible via {@link RecipeManagers}
|
||||
*
|
||||
* Note that this is untested with anything other than biofuel->fuelcan conversion.
|
||||
*
|
||||
* @author SirSengir
|
||||
*/
|
||||
public interface IBottlerManager extends ICraftingProvider {
|
||||
/**
|
||||
* Add a recipe to the bottler.
|
||||
* The bottler will populate its recipe list dynamically from the LiquidContainerRegistry. Recipes added explicitely will take precedence.
|
||||
*
|
||||
* @param cyclesPerUnit
|
||||
* Amount of work cycles required to run through the conversion once.
|
||||
* @param input
|
||||
* LiquidStack representing the input liquid.
|
||||
* @param can
|
||||
* ItemStack representing the cans, capsules and/or cells required
|
||||
* @param bottled
|
||||
* ItemStack representing the finished product
|
||||
*/
|
||||
@Deprecated
|
||||
public void addRecipe(int cyclesPerUnit, FluidStack input, ItemStack can, ItemStack bottled);
|
||||
}
|
|
@ -33,7 +33,7 @@ public interface ICarpenterManager extends ICraftingProvider {
|
|||
* @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[]);
|
||||
public void addRecipe(ItemStack box, ItemStack product, Object... materials);
|
||||
|
||||
/**
|
||||
* Add a shaped recipe to the carpenter.
|
||||
|
@ -47,7 +47,7 @@ public interface ICarpenterManager extends ICraftingProvider {
|
|||
* @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[]);
|
||||
public void addRecipe(int packagingTime, ItemStack box, ItemStack product, Object... materials);
|
||||
|
||||
/**
|
||||
* Add a shaped recipe to the carpenter.
|
||||
|
@ -63,9 +63,5 @@ public interface ICarpenterManager extends ICraftingProvider {
|
|||
* @param materials
|
||||
* Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same.
|
||||
*/
|
||||
public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object materials[]);
|
||||
|
||||
public void addCrating(String toCrate, ItemStack unpack, ItemStack crated);
|
||||
|
||||
public void addCrating(ItemStack itemStack);
|
||||
public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object... materials);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package forestry.api.recipes;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -21,59 +22,67 @@ import net.minecraft.item.ItemStack;
|
|||
*/
|
||||
public interface ICentrifugeManager extends ICraftingProvider {
|
||||
|
||||
/**
|
||||
* Add a recipe to the centrifuge.
|
||||
* Gives fine-grained control over the outputs.
|
||||
*/
|
||||
void addRecipe(ICentrifugeRecipe recipe);
|
||||
|
||||
/**
|
||||
* Add a recipe to the centrifuge
|
||||
*
|
||||
* @param timePerItem Time to centrifugate one item of the given type. Default is 20.
|
||||
* @param input ItemStack containing information on item id and damage. Stack size will be ignored.
|
||||
* @param products Specifies the possible products and the chances of them resulting from centrifuging.
|
||||
* Chances are from (0.0 to 1.0]
|
||||
*/
|
||||
void addRecipe(int timePerItem, ItemStack input, Map<ItemStack, Float> 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 products
|
||||
* HashMap<ItemStack, Integer> specifying the possible products and the chances of them resulting from centrifugation.
|
||||
* @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<ItemStack, Integer> specifying the possible products and the chances of them resulting from centrifugation.
|
||||
* @deprecated since Forestry 3.6. Use the Float version
|
||||
*/
|
||||
@Deprecated
|
||||
public void addRecipe(int timePerItem, ItemStack resource, HashMap<ItemStack, Integer> products);
|
||||
|
||||
/**
|
||||
* Add a recipe to the centrifuge
|
||||
*
|
||||
* @param timePerItem
|
||||
* Time to centrifugate one item of the given type
|
||||
* @param resource
|
||||
* ItemStack containing information on item id and damage. Stack size will be ignored.
|
||||
* @param produce
|
||||
* Array of ItemStacks that can be the result of this recipe.
|
||||
* @param chances
|
||||
* Array of integers corresponding and matching to produce providing the chance (0-100) for the ItemStack at the given index to be
|
||||
* produced.
|
||||
* @param timePerItem Time to centrifugate one item of the given type
|
||||
* @param resource ItemStack containing information on item id and damage. Stack size will be ignored.
|
||||
* @param produce Array of ItemStacks that can be the result of this recipe.
|
||||
* @param chances Array of integers corresponding and matching to produce providing the chance (0-100) for the ItemStack at the given index to be produced.
|
||||
* @deprecated since Forestry 3.6. Use the Map<ItemStack, Float> version
|
||||
*/
|
||||
@Deprecated
|
||||
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.
|
||||
* @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.
|
||||
* @deprecated since Forestry 3.6. Use the Map<ItemStack, Float> version
|
||||
*/
|
||||
@Deprecated
|
||||
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 %.
|
||||
* @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 %.
|
||||
* @deprecated since Forestry 3.6. Use the Map<ItemStack, Float> version
|
||||
*/
|
||||
@Deprecated
|
||||
public void addRecipe(int timePerItem, ItemStack resource, ItemStack primary);
|
||||
|
||||
}
|
||||
|
|
30
src/api/java/forestry/api/recipes/ICentrifugeRecipe.java
Normal file
30
src/api/java/forestry/api/recipes/ICentrifugeRecipe.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.recipes;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ICentrifugeRecipe {
|
||||
|
||||
/** The item for this recipe to match against. **/
|
||||
ItemStack getInput();
|
||||
|
||||
/** The time it takes to process one item. Default is 20. **/
|
||||
int getProcessingTime();
|
||||
|
||||
/** Returns the randomized products from processing one input item. **/
|
||||
Collection<ItemStack> getProducts(Random random);
|
||||
|
||||
/**
|
||||
* Returns a list of all possible products and their estimated probabilities (0.0 to 1.0],
|
||||
* to help mods that display recipes
|
||||
**/
|
||||
Map<ItemStack, Float> getAllProducts();
|
||||
}
|
|
@ -16,10 +16,6 @@ public class RecipeManagers {
|
|||
|
||||
public static Collection<ICraftingProvider> craftingProviders;
|
||||
|
||||
/**
|
||||
* Allows you to add recipes to the bottler. See {@link IBottlerManager} for details.
|
||||
*/
|
||||
public static IBottlerManager bottlerManager;
|
||||
/**
|
||||
* Allows you to add recipes to the carpenter. See {@link ICarpenterManager} for details.
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|recipes")
|
||||
@API(apiVersion="3.1.0", owner="ForestryAPI|core", provides="ForestryAPI|recipes")
|
||||
package forestry.api.recipes;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
package forestry.api.storage;
|
||||
|
||||
public enum EnumBackpackType {
|
||||
T1, T2
|
||||
APIARIST, T1, T2
|
||||
}
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
******************************************************************************/
|
||||
package forestry.api.storage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IBackpackDefinition {
|
||||
|
@ -20,7 +19,7 @@ public interface IBackpackDefinition {
|
|||
/**
|
||||
* @return Human-readable name of the backpack.
|
||||
*/
|
||||
String getName();
|
||||
String getName(ItemStack backpack);
|
||||
|
||||
/**
|
||||
* @return Primary colour for the backpack icon.
|
||||
|
@ -38,22 +37,11 @@ public interface IBackpackDefinition {
|
|||
* @param validItem
|
||||
*/
|
||||
void addValidItem(ItemStack validItem);
|
||||
|
||||
/**
|
||||
* Returns an arraylist of all items valid for this backpack type.
|
||||
*
|
||||
* @param player
|
||||
* @return Collection of itemstack which are valid items for this backpack type. May be empty or null and does not necessarily include all valid items.
|
||||
*/
|
||||
Collection<ItemStack> getValidItems(EntityPlayer player);
|
||||
void addValidItems(List<ItemStack> validItems);
|
||||
|
||||
/**
|
||||
* Returns true if the itemstack is a valid item for this backpack type.
|
||||
*
|
||||
* @param player
|
||||
* @param itemstack
|
||||
* @return true if the given itemstack is valid for this backpack, false otherwise.
|
||||
*/
|
||||
boolean isValidItem(EntityPlayer player, ItemStack itemstack);
|
||||
boolean isValidItem(ItemStack itemstack);
|
||||
|
||||
}
|
||||
|
|
32
src/api/java/forestry/api/storage/ICrateRegistry.java
Normal file
32
src/api/java/forestry/api/storage/ICrateRegistry.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.storage;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ICrateRegistry {
|
||||
|
||||
/**
|
||||
* Makes a new crate, registers it with the game registry with uid,
|
||||
* and creates crating and uncrating recipes for the Carpenter.
|
||||
* The icon is rendered automatically from the contained item.
|
||||
*
|
||||
* Can only be called during the Init stage.
|
||||
*/
|
||||
void registerCrate(Item item, String uid);
|
||||
void registerCrate(Block block, String uid);
|
||||
void registerCrate(ItemStack stack, String uid);
|
||||
|
||||
/**
|
||||
* Same as the above, but uses the ore dictionary for the Carpenter crating recipe.
|
||||
*/
|
||||
void registerCrateUsingOreDict(Item item, String uid);
|
||||
void registerCrateUsingOreDict(Block block, String uid);
|
||||
void registerCrateUsingOreDict(ItemStack stack, String uid);
|
||||
|
||||
}
|
12
src/api/java/forestry/api/storage/StorageManager.java
Normal file
12
src/api/java/forestry/api/storage/StorageManager.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.storage;
|
||||
|
||||
public class StorageManager {
|
||||
|
||||
public static ICrateRegistry crateRegistry;
|
||||
|
||||
}
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|storage")
|
||||
@API(apiVersion="3.0.0", owner="ForestryAPI|core", provides="ForestryAPI|storage")
|
||||
package forestry.api.storage;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
|
@ -7,6 +7,10 @@ package forestry.api.world;
|
|||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
|
||||
public interface ITreeGenData {
|
||||
|
||||
int getGirth(World world, int x, int y, int z);
|
||||
|
@ -15,9 +19,12 @@ public interface ITreeGenData {
|
|||
|
||||
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);
|
||||
void setLeaves(World world, GameProfile owner, int x, int y, int z);
|
||||
void setLeavesDecorative(World world, GameProfile owner, int x, int y, int z);
|
||||
|
||||
boolean allowsFruitBlocks();
|
||||
|
||||
boolean trySpawnFruitBlock(World world, int x, int y, int z);
|
||||
|
||||
ITreeGenome getGenome();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|world")
|
||||
@API(apiVersion="1.1.0", owner="ForestryAPI|core", provides="ForestryAPI|world")
|
||||
package forestry.api.world;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue