mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Change the plugin system to a module system and slit up modules
-Moved the woodpile from the arboriculture module to the charcoal module -Moved the backpacks from the storage module to the backpacks module -Moved the crates from the storage module to the creates module -Added the database module with a new storage for individuals -Added a gui element system to improve the alyzer api -Added a species plugin interface to handle the database gui -Added some alyzer methods to the species plugin to move the alyzer integration later to it
This commit is contained in:
1 parent
ee272de168
commit
88fd031fb4
277 files changed
+7361
-1930
No files matched your search
@@ -19,6 +19,4 @@ public interface IAlleleFruit extends IAlleleProperty<IAlleleFruit> {
|
||||
@Nullable
|
||||
String getModelName();
|
||||
|
||||
String getModID();
|
||||
|
||||
}
|
||||
@@ -7,15 +7,18 @@ package forestry.api.arboriculture;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.IAlleleProperty;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IAlleleTreeSpecies extends IAlleleSpecies, IAlleleProperty<IAlleleTreeSpecies> {
|
||||
|
||||
@@ -36,11 +39,6 @@ public interface IAlleleTreeSpecies extends IAlleleSpecies, IAlleleProperty<IAll
|
||||
* @return Tree generator for this species.
|
||||
*/
|
||||
ITreeGenerator getGenerator();
|
||||
|
||||
/**
|
||||
* @return The modid from the mod of the species.
|
||||
*/
|
||||
String getModID();
|
||||
|
||||
/**
|
||||
* @return Float between 0 and 1 representing the rarity of the species, will affect spawn rate. If it's 0, it will not spawn.
|
||||
|
||||
@@ -14,7 +14,10 @@ public interface ICharcoalPileWall {
|
||||
int getCharcoalAmount();
|
||||
|
||||
boolean matches(IBlockState state);
|
||||
|
||||
|
||||
@Deprecated
|
||||
NonNullList<ItemStack> getDisplyItems();
|
||||
|
||||
NonNullList<ItemStack> getDisplayItems();
|
||||
|
||||
}
|
||||
@@ -5,13 +5,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import forestry.api.core.ITextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ITextureManager;
|
||||
|
||||
public interface IWoodProvider {
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerSprites(Item item, ITextureManager manager);
|
||||
@@ -29,11 +31,15 @@ public interface IWoodProvider {
|
||||
|
||||
/**
|
||||
* The amount of charcoal dropped from a charcoal pile of this wood.
|
||||
* @deprecated Will be removed in 1.13
|
||||
*/
|
||||
@Deprecated
|
||||
int getCarbonization();
|
||||
|
||||
/**
|
||||
* The chance that a pile has to drop a extra charcoal
|
||||
* @deprecated Will be removed in 1.13
|
||||
*/
|
||||
@Deprecated
|
||||
float getCharcoalChance(int numberOfCharcoal);
|
||||
}
|
||||
@@ -5,10 +5,11 @@
|
||||
******************************************************************************/
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@API(apiVersion = "4.2.1", owner = "ForestryAPI|core", provides = "ForestryAPI|arboriculture")
|
||||
@API(apiVersion = "4.3.0", owner = "ForestryAPI|core", provides = "ForestryAPI|arboriculture")
|
||||
package forestry.api.arboriculture;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -7,14 +7,17 @@ package forestry.api.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.climate.IClimateStates;
|
||||
import forestry.greenhouse.api.climate.IClimateFactory;
|
||||
import forestry.api.climate.IClimateManager;
|
||||
import forestry.api.climate.IClimateStates;
|
||||
import forestry.api.farming.IFarmRegistry;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.api.farming.ISimpleFarmLogic;
|
||||
import forestry.greenhouse.api.climate.IClimateFactory;
|
||||
|
||||
/**
|
||||
* Forestry's API is divided into several subcategories to make it easier to understand.
|
||||
@@ -58,10 +61,13 @@ public class ForestryAPI {
|
||||
*/
|
||||
public static IClimateFactory climateFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static IClimateStates states;
|
||||
|
||||
/**
|
||||
* A registry for register fertilizers, {@link IFarmabeles}s and {@link ISimpleFarmLogic}s
|
||||
* A registry for register fertilizers, {@link IFarmable}s and {@link ISimpleFarmLogic}s
|
||||
*/
|
||||
public static IFarmRegistry farmRegistry;
|
||||
|
||||
@@ -76,10 +82,20 @@ public class ForestryAPI {
|
||||
public static IForestryConstants forestryConstants;
|
||||
|
||||
/**
|
||||
* The currently enabled Forestry plugins.
|
||||
* The currently enabled Forestry modules.
|
||||
* Can be used to check if certain features are available, for example:
|
||||
* ForestryAPI.enabledPlugins.contains("APICULTURE")
|
||||
* ForestryAPI.enabledModules.contains(new ResourceLocation("forestry", "apiculture"))
|
||||
*/
|
||||
public static Set<ResourceLocation> enabledModules;
|
||||
|
||||
/**
|
||||
* The currently enabled Forestry modules.
|
||||
* Can be used to check if certain features are available, for example:
|
||||
* ForestryAPI.enabledPlugins.contains("forestry.apiculture")
|
||||
*
|
||||
* @deprecated Use {@link #enabledModules}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Set<String> enabledPlugins;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package forestry.api.core;
|
||||
|
||||
/**
|
||||
* The alignment of the text in a text gui element.
|
||||
*/
|
||||
public enum GuiElementAlignment {
|
||||
LEFT, CENTER, RIGHT;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IGuiElement {
|
||||
int getX();
|
||||
|
||||
int getY();
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
void setXOffset(int xOffset);
|
||||
|
||||
void setYOffset(int yOffset);
|
||||
|
||||
@Nullable
|
||||
IGuiElement getParent();
|
||||
|
||||
void setParent(@Nullable IGuiElement parent);
|
||||
|
||||
void draw(int startX, int startY);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
default List<String> getToolTip(int mouseX, int mouseY){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
boolean isMouseOver(int mouseX, int mouseY);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
/**
|
||||
* A helper interface to create gui elements.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IGuiElementFactory {
|
||||
|
||||
IGuiElementHelper createHelper(IGuiElementLayout element);
|
||||
|
||||
/* GENETIC*/
|
||||
/**
|
||||
* @param dominant True if you want the dominant color and false if you want the recessive color.
|
||||
*
|
||||
* @return The color code that forestry uses to show if a allele is dominant (true) or recessive (false).
|
||||
*/
|
||||
int getColorCoding(boolean dominant);
|
||||
|
||||
/**
|
||||
* @return Null if the mutation is secret and undiscovered. {@link IMutation#isSecret()}
|
||||
*/
|
||||
IGuiElement createMutation(int x, int y, int width, int height, IMutation mutation, IAllele species, IBreedingTracker breedingTracker);
|
||||
|
||||
/**
|
||||
* @return Null if the mutation is secret and undiscovered. {@link IMutation#isSecret()}
|
||||
*/
|
||||
IGuiElement createMutationResultant(int x, int y, int width, int height, IMutation mutation, IBreedingTracker breedingTracker);
|
||||
|
||||
IGuiElement createFertilityInfo(IAlleleInteger fertilityAllele, int x, int texOffset);
|
||||
|
||||
IGuiElement createToleranceInfo(IAlleleTolerance toleranceAllele, IAlleleSpecies species, String text);
|
||||
|
||||
/* LAYOUTS */
|
||||
IGuiElementLayout createHorizontal(int xPos, int yPos, int height);
|
||||
|
||||
IGuiElementLayout createVertical(int xPos, int yPos, int width);
|
||||
|
||||
IGuiElementLayout createPanel(int xPos, int yPos, int width, int height);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IGuiElementLayoutHelper.LayoutFactory;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
/**
|
||||
* A helper interface to add gui elements.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IGuiElementHelper {
|
||||
/**
|
||||
* Adds a {@link IGuiElement} to the parent of this.
|
||||
*/
|
||||
void add(IGuiElement element);
|
||||
|
||||
/**
|
||||
* Centers a element to the center of the x axis of the parent element.
|
||||
*
|
||||
* @return the element
|
||||
*/
|
||||
IGuiElement centerElement(IGuiElement element);
|
||||
|
||||
/**
|
||||
* Creates and adds an item gui element.
|
||||
*/
|
||||
void addItem(int x, ItemStack itemStack);
|
||||
|
||||
IGuiElementLayoutHelper layoutHelper(LayoutFactory layoutFactory, int width, int height);
|
||||
|
||||
/**
|
||||
* Adds the chromosomeName and the name of the active/not active allele, of the chromosome, with {@link #addText}.
|
||||
*/
|
||||
void addAllele(String chromosomeName, IIndividual individual, IChromosomeType chromosome, boolean active);
|
||||
|
||||
/**
|
||||
* Adds the chromosomeName and the result of toString with {@link #addText}.
|
||||
*/
|
||||
<A extends IAllele> void addAllele(String chromosomeName, Function<A, String> toString, IIndividual individual, IChromosomeType chromosome, boolean active);
|
||||
|
||||
void addFertilityInfo(IAlleleInteger fertilityAllele, int x, int texOffset);
|
||||
|
||||
void addToleranceInfo(IAlleleTolerance toleranceAllele, IAlleleSpecies species, String text);
|
||||
|
||||
void addMutation(int x, int y, int width, int height, IMutation mutation, IAllele species, IBreedingTracker breedingTracker);
|
||||
|
||||
void addMutationResultant(int x, int y, int width, int height, IMutation mutation, IBreedingTracker breedingTracker);
|
||||
|
||||
/**
|
||||
* Adds a text element with the default color,the align {@link GuiElementAlignment#LEFT} and the height 12.
|
||||
*/
|
||||
void addText(String text);
|
||||
|
||||
/**
|
||||
* Adds a text element with the align {@link GuiElementAlignment#LEFT} and the height 12.
|
||||
*/
|
||||
void addText(String text, int color);
|
||||
|
||||
/**
|
||||
* Adds a text element with the default color and the height 12.
|
||||
*/
|
||||
void addText(String text, GuiElementAlignment align);
|
||||
|
||||
/**
|
||||
* Adds a text element with the height 12.
|
||||
*/
|
||||
void addText(String text,GuiElementAlignment align, int color);
|
||||
|
||||
/**
|
||||
* Adds a text element.
|
||||
*/
|
||||
void addText(int x, int height, String text, GuiElementAlignment align, int color);
|
||||
|
||||
/**
|
||||
* @return The element to which all elements are added.
|
||||
*/
|
||||
IGuiElement getParent();
|
||||
|
||||
IGuiElementFactory factory();
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IGuiElementLayout extends IGuiElement {
|
||||
/**
|
||||
* Adds a element to this layout.
|
||||
*/
|
||||
IGuiElementLayout addElement(IGuiElement element);
|
||||
|
||||
/**
|
||||
* Removes a element from this layout.
|
||||
*/
|
||||
IGuiElementLayout removeElement(IGuiElement element);
|
||||
|
||||
default IGuiElementLayout addElements(IGuiElement... elements){
|
||||
for(IGuiElement element : elements){
|
||||
addElement(element);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
default IGuiElementLayout removeElements(IGuiElement... elements){
|
||||
for(IGuiElement element : elements){
|
||||
removeElement(element);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
default IGuiElementLayout addElements(Collection<IGuiElement> elements){
|
||||
elements.forEach(element -> addElement(element));
|
||||
return this;
|
||||
}
|
||||
|
||||
default IGuiElementLayout removeElements(Collection<IGuiElement> elements){
|
||||
elements.forEach(element -> removeElement(element));
|
||||
return this;
|
||||
}
|
||||
|
||||
List<IGuiElement> getElements();
|
||||
|
||||
IGuiElementLayout setDistance(int distance);
|
||||
|
||||
void addTooltip(String line);
|
||||
|
||||
/**
|
||||
* @return The tooltip that is displayed if the mouse is over this element and no element of this layout is under it.
|
||||
*/
|
||||
List<String> getTooltip();
|
||||
|
||||
/**
|
||||
* @return The distance between the different elements of this layout.
|
||||
*/
|
||||
int getDistance();
|
||||
|
||||
int getSize();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package forestry.api.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IGuiElementLayoutHelper {
|
||||
/**
|
||||
* @return Only false if the helper has no space to add this element.
|
||||
*/
|
||||
boolean add(IGuiElement element);
|
||||
|
||||
/**
|
||||
* Removes all layouts and resets all variables of this helper.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Adds the layouts to the parent of the {@link IGuiElementHelper}. And calls {@link #clear()}
|
||||
*/
|
||||
void finish();
|
||||
|
||||
/**
|
||||
* @return All layouts that were created with the help of this helper since the last {@link #clear()} or {@link #finish()}.
|
||||
*/
|
||||
Collection<IGuiElementLayout> layouts();
|
||||
|
||||
interface LayoutFactory {
|
||||
/**
|
||||
* A factory method to create new layouts if the last layout is full.
|
||||
*/
|
||||
IGuiElementLayout createLayout(int xOffset, int yOffset);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
******************************************************************************/
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@API(apiVersion = "5.2.0", owner = "Forestry", provides = "ForestryAPI|core")
|
||||
@API(apiVersion = "5.3.0", owner = "Forestry", provides = "ForestryAPI|core")
|
||||
package forestry.api.core;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package forestry.api.genetics;
|
||||
|
||||
/**
|
||||
* Every instance of this enum represents a tab in the database.
|
||||
*/
|
||||
public enum EnumDatabaseTab {
|
||||
//Used to display information about the active species of the individual.
|
||||
ACTIVE_SPECIES,
|
||||
//Used to display information about the inactive species of the individual.
|
||||
INACTIVE_SPECIES,
|
||||
//Used to display information about the products of the active species of the individual.
|
||||
PRODUCTS,
|
||||
//Used to display information about the mutations of the active species of the individual.
|
||||
MUTATIONS;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package forestry.api.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IGuiElementHelper;
|
||||
|
||||
/**
|
||||
* A tab of the database screen that shows some information about a {@link IIndividual}.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IDatabaseTab<I extends IIndividual> {
|
||||
/**
|
||||
* Creates the gui elements that are displayed if this tab is selected in the database.
|
||||
*
|
||||
* @param individual The individual that is currently in the database selected.
|
||||
* @param elementHelper A helper to create the gui elements.
|
||||
*/
|
||||
void createElements(IGuiElementHelper elementHelper, I individual, ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* @return The slot of this tab.
|
||||
*/
|
||||
EnumDatabaseTab getTab();
|
||||
|
||||
/**
|
||||
* Can be used to give the tab a custom tooltip.
|
||||
*/
|
||||
@Nullable
|
||||
default String getTooltip(I individual){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -14,17 +14,38 @@ import forestry.api.core.INbtWritable;
|
||||
*/
|
||||
public interface IGenome extends INbtWritable {
|
||||
|
||||
/**
|
||||
* @return The active species of this genome.
|
||||
*/
|
||||
IAlleleSpecies getPrimary();
|
||||
|
||||
/**
|
||||
* @return The inactive species of this genome.
|
||||
*/
|
||||
IAlleleSpecies getSecondary();
|
||||
|
||||
/**
|
||||
* @return A array with all chromosomes of this genome.
|
||||
*/
|
||||
IChromosome[] getChromosomes();
|
||||
|
||||
/**
|
||||
* @return The active allele of this chromosome type.
|
||||
*/
|
||||
IAllele getActiveAllele(IChromosomeType chromosomeType);
|
||||
|
||||
/**
|
||||
* @return The inactive allele of this chromosome type.
|
||||
*/
|
||||
IAllele getInactiveAllele(IChromosomeType chromosomeType);
|
||||
|
||||
/**
|
||||
* @return true if the given other IGenome has the amount of chromosomes and their alleles are identical.
|
||||
*/
|
||||
boolean isGeneticEqual(IGenome other);
|
||||
|
||||
/**
|
||||
* @return The root of this species and describes the class of species of this genome.
|
||||
*/
|
||||
ISpeciesRoot getSpeciesRoot();
|
||||
}
|
||||
@@ -12,6 +12,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
*/
|
||||
public interface IHousing {
|
||||
|
||||
/**
|
||||
* The coordinates of the housing.
|
||||
*/
|
||||
BlockPos getCoordinates();
|
||||
|
||||
}
|
||||
@@ -16,10 +16,19 @@ import forestry.api.core.INbtWritable;
|
||||
*/
|
||||
public interface IIndividual extends INbtWritable {
|
||||
|
||||
/**
|
||||
* @return The uid of the active species of this individual.
|
||||
*/
|
||||
String getIdent();
|
||||
|
||||
/**
|
||||
* @return The display name of the active species of this individual.
|
||||
*/
|
||||
String getDisplayName();
|
||||
|
||||
/**
|
||||
* Adds some information about the individual to the list.
|
||||
*/
|
||||
void addTooltip(List<String> list);
|
||||
|
||||
/**
|
||||
@@ -29,12 +38,24 @@ public interface IIndividual extends INbtWritable {
|
||||
*/
|
||||
boolean analyze();
|
||||
|
||||
/**
|
||||
* @return true if the IIndividual has been analyzed previously.
|
||||
*/
|
||||
boolean isAnalyzed();
|
||||
|
||||
/**
|
||||
* @return true if the active species of this individual has a effect.
|
||||
*/
|
||||
boolean hasEffect();
|
||||
|
||||
/**
|
||||
* @return true if the active species of this individual is secret.
|
||||
*/
|
||||
boolean isSecret();
|
||||
|
||||
/**
|
||||
* @return The genetic data of this individual.
|
||||
*/
|
||||
IGenome getGenome();
|
||||
|
||||
/**
|
||||
@@ -49,6 +70,9 @@ public interface IIndividual extends INbtWritable {
|
||||
*/
|
||||
IIndividual copy();
|
||||
|
||||
/**
|
||||
* @return true if this individual has the same active and inactive species.
|
||||
*/
|
||||
boolean isPureBred(IChromosomeType chromosomeType);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package forestry.api.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IGuiElementHelper;
|
||||
|
||||
/**
|
||||
* An ISpeciesPlugin provides methods that are used in the alyzer and database to display information about an
|
||||
* individual.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ISpeciesPlugin<I extends IIndividual> {
|
||||
|
||||
/**
|
||||
* A map that contains a {@link ItemStack} for every possible {@link IAlleleSpecies}.
|
||||
* This item stack represents the species in the database and alyzer gui.
|
||||
*
|
||||
* The key of the map is the uid of the species.
|
||||
*/
|
||||
Map<String, ItemStack> getIndividualStacks();
|
||||
|
||||
|
||||
/* ALYZER */
|
||||
/**
|
||||
* Creates the first page of the alyzer.
|
||||
*
|
||||
* @param gui A instance of the alyzer gui.
|
||||
* @param elementHelper A helper to create the gui elements.
|
||||
* @param individual The individual that is currently in the alyzer slot.
|
||||
*/
|
||||
default void createFirstPage(GuiScreen gui, IGuiElementHelper elementHelper, I individual){
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the second page of the alyzer.
|
||||
*
|
||||
* @param gui A instance of the alyzer gui.
|
||||
* @param elementHelper A helper to create the gui elements.
|
||||
* @param individual The individual that is currently in the alyzer slot.
|
||||
*/
|
||||
default void createSecondPage(GuiScreen gui, IGuiElementHelper elementHelper, I individual){
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the third page of the alyzer. This page is usually used to display the products of the individual.
|
||||
*
|
||||
* @param gui A instance of the alyzer gui.
|
||||
* @param elementHelper A helper to create the gui elements.
|
||||
* @param individual The individual that is currently in the alyzer slot.
|
||||
*/
|
||||
default void createThirdPage(GuiScreen gui, IGuiElementHelper elementHelper, I individual){
|
||||
}
|
||||
|
||||
/**
|
||||
* The hints that will be shown in the alyzer gui.
|
||||
*/
|
||||
List<String> getHints();
|
||||
|
||||
/* DATABASE */
|
||||
/**
|
||||
* Provides a instance of a {@link IDatabaseTab} that is used to display information about the species of a individual in the
|
||||
* database.
|
||||
*
|
||||
* @param active True if this tab is used to display the active species of the individual.
|
||||
*
|
||||
* @return null if this plugin does not support the database.
|
||||
*/
|
||||
default IDatabaseTab<I> getSpeciesTab(boolean active){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to provide a custom products tab for the database.
|
||||
* If this is Null forestry uses the default mutation tab to display the products.
|
||||
*/
|
||||
@Nullable
|
||||
default IDatabaseTab<I> getProductsTab(){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to provide a custom mutation tab for the database.
|
||||
* If this is Null forestry uses the default mutation tab to display the mutations.
|
||||
*/
|
||||
@Nullable
|
||||
default IDatabaseTab<I> getMutationTab(){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A item stack that represents the database tab in the database gui.
|
||||
*/
|
||||
ItemStack getTabDatabaseIconItem(EnumDatabaseTab tab);
|
||||
}
|
||||
@@ -11,12 +11,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Describes a class of species (i.e. bees, trees, butterflies), provides helper functions and access to common functionality.
|
||||
*/
|
||||
@@ -72,6 +75,9 @@ public interface ISpeciesRoot {
|
||||
@Nullable
|
||||
<O extends Object, I extends IIndividual> IIndividualTranslator<I, O> getTranslator(Object translatorKey);
|
||||
|
||||
@Nullable
|
||||
<O extends Object, I extends IIndividual> I translateMember(O objectToTranslator);
|
||||
|
||||
@Nullable
|
||||
ISpeciesType getType(ItemStack itemStack);
|
||||
|
||||
@@ -160,6 +166,12 @@ public interface ISpeciesRoot {
|
||||
*/
|
||||
List<? extends IMutation> getCombinations(IAllele other);
|
||||
|
||||
/**
|
||||
* @param other Allele to match mutations against.
|
||||
* @return All registered mutations the give allele is resolute of.
|
||||
*/
|
||||
List<? extends IMutation> getResultantMutations(IAllele other);
|
||||
|
||||
/**
|
||||
* @return all possible mutations that result from breeding two species
|
||||
* @since Forestry 3.7
|
||||
@@ -197,4 +209,19 @@ public interface ISpeciesRoot {
|
||||
* Plugin to add information for the handheld genetic analyzer.
|
||||
*/
|
||||
IAlyzerPlugin getAlyzerPlugin();
|
||||
|
||||
/**
|
||||
* A array with the size of 4. With the database tabs of this {@link IIndividual}.
|
||||
*/
|
||||
//IDatabaseTab[] getDatabaseTabs();
|
||||
|
||||
/**
|
||||
* Plugin to add information for the handheld genetic analyzer and the database.
|
||||
* @since 5.7
|
||||
*/
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
default ISpeciesPlugin getSpeciesPlugin(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,11 @@
|
||||
******************************************************************************/
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@API(apiVersion = "4.7.1", owner = "ForestryAPI|core", provides = "ForestryAPI|genetics")
|
||||
@API(apiVersion = "5.7.0", owner = "ForestryAPI|core", provides = "ForestryAPI|genetics")
|
||||
package forestry.api.genetics;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
@@ -8,16 +8,19 @@ package forestry.api.lepidopterology;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public interface IAlleleButterflySpecies extends IAlleleSpecies {
|
||||
|
||||
/**
|
||||
* @return the IBeeRoot
|
||||
* @return the IButterflyRoot
|
||||
*/
|
||||
@Override
|
||||
IButterflyRoot getRoot();
|
||||
@@ -59,15 +62,16 @@ public interface IAlleleButterflySpecies extends IAlleleSpecies {
|
||||
*/
|
||||
boolean isNocturnal();
|
||||
|
||||
/**
|
||||
* @return The loot that drops if you kill a butterfly.
|
||||
*/
|
||||
Map<ItemStack, Float> getButterflyLoot();
|
||||
|
||||
/**
|
||||
* @return The loot that drops if you destroy a leaf that contains a caterpillar.
|
||||
*/
|
||||
Map<ItemStack, Float> getCaterpillarLoot();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerSprites();
|
||||
|
||||
/**
|
||||
* @return The modid from the mod of the species.
|
||||
*/
|
||||
String getModID();
|
||||
}
|
||||
Reference in new issue
Block a user