Add sorting block (Genetic Filter)

This commit is contained in:
Nedelosk committed 2018-01-15 19:03:48 +01:00
1 parent 1fc56c3b20
commit 8b0d54f3ec
85 files changed
+2795 -35

No files matched your search

@@ -5,9 +5,10 @@
******************************************************************************/
package forestry.api.arboriculture;
import forestry.api.genetics.IGenome;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IGenome;
public interface ITreeGenome extends IGenome {
@Override
@@ -37,6 +38,8 @@ public interface ITreeGenome extends IGenome {
int getGirth();
boolean getFireproof();
IAlleleLeafEffect getEffect();
/**
@@ -23,4 +23,9 @@ public class AlleleManager {
* Creates Forestry alleles.
*/
public static IAlleleFactory alleleFactory;
/**
* @since 5.8
*/
public static IFilterRegistry filterRegistry;
}
@@ -5,10 +5,14 @@
******************************************************************************/
package forestry.api.genetics;
import forestry.api.apiculture.IBeekeepingMode;
import java.util.Collection;
import java.util.Collections;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.apiculture.IBeekeepingMode;
/**
* Keeps track of who bred, discovered, and researched which species in a world.
*
@@ -67,6 +71,13 @@ public interface IBreedingTracker {
*/
boolean isDiscovered(IAlleleSpecies species);
/**
* @return A collection that contains the {@link IAllele#getUID()}s of all discovered species.
*/
default Collection<String> getDiscoveredSpecies(){
return Collections.emptyList();
}
/**
* Register a successfully researched mutation.
* Mutations are normally researched in the Escritoire.
@@ -0,0 +1,27 @@
package forestry.api.genetics;
public interface IFilterData {
/**
* If the root is present, returns the root,
* otherwise throws {@code NoSuchElementException}.
*/
ISpeciesRoot getRoot();
/**
* If the individual is present, returns the individual,
* otherwise throws {@code NoSuchElementException}.
*/
IIndividual getIndividual();
/**
* If the type is present, returns the type,
* otherwise throws {@code NoSuchElementException}.
*/
ISpeciesType getType();
/**
* @return True if this data contains a root, individual and type.
*/
boolean isPresent();
}
@@ -0,0 +1,17 @@
package forestry.api.genetics;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
public interface IFilterLogic {
boolean isValid(ItemStack itemStack, IFilterData data);
/**
* If a root with this uid is registered, the filter will only get stack with individuals from this root.
*/
@Nullable
default String getRootUID() {
return null;
}
}
@@ -0,0 +1,36 @@
package forestry.api.genetics;
import javax.annotation.Nullable;
import java.util.Collection;
/**
* @since 5.8
*/
public interface IFilterRegistry {
/**
* Registers a filter rule.
*/
void registerFilter(IFilterRule rule);
Collection<IFilterRule> getRules();
IFilterRule getDefaultRule();
@Nullable
IFilterRule getRule(String uid);
@Nullable
IFilterRule getRule(int id);
int getId(IFilterRule rule);
default IFilterRule getRuleOrDefault(String uid){
IFilterRule rule = getRule(uid);
return rule != null ? rule : getDefaultRule();
}
default IFilterRule getRuleOrDefault(int id){
IFilterRule rule = getRule(id);
return rule != null ? rule : getDefaultRule();
}
}
@@ -0,0 +1,25 @@
package forestry.api.genetics;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/**
* @since 5.8
*/
public interface IFilterRule extends IFilterLogic {
void addLogic(IFilterLogic logic);
/**
* @return A unique identifier for the rule.
*/
String getUID();
@SideOnly(Side.CLIENT)
TextureAtlasSprite getSprite();
@SideOnly(Side.CLIENT)
ResourceLocation getTextureMap();
}