本文整理汇总了Java中forestry.api.genetics.ISpeciesRoot类的典型用法代码示例。如果您正苦于以下问题:Java ISpeciesRoot类的具体用法?Java ISpeciesRoot怎么用?Java ISpeciesRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISpeciesRoot类属于forestry.api.genetics包,在下文中一共展示了ISpeciesRoot类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: same
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
@Override
protected boolean same(ItemStack stack1, ItemStack stack2) {
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack1);
if (root == null || !root.isMember(stack2)) {
return false;
}
if (type == PrecisionModes.Type.MATCH) {
if (root.getType(stack1) != root.getType(stack2)) {
return false;
}
}
IIndividual individual1 = root.getMember(stack1);
IIndividual individual2 = root.getMember(stack2);
try {
return same(individual1, individual2);
} catch (NullPointerException e) {
return false;
}
}
示例2: getBeeParents
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get possible mutations that results in given bee")
public List<Map<String, Object>> getBeeParents(IBeeHousing housing, @Arg(name = "childType", description = "The type of bee you want the parents for") String childType) {
ISpeciesRoot beeRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
if (beeRoot == null) return null;
List<Map<String, Object>> result = Lists.newArrayList();
childType = childType.toLowerCase(Locale.ENGLISH);
for (IMutation mutation : beeRoot.getMutations(false)) {
if (mutation.isSecret() && !Config.showHiddenMutations) continue;
final IAlleleSpecies species = getOffspringSpecies(mutation);
if (alleleNameMatches(species, childType)) {
result.add(serializeMutation(mutation, false));
}
}
return result;
}
示例3: getBeeChildren
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get possible mutations that can be created with given bee")
public List<Map<String, Object>> getBeeChildren(IBeeHousing housing, @Arg(name = "parentYpe", description = "The type of bee you want the children for") String childType) {
ISpeciesRoot beeRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
if (beeRoot == null) return null;
List<Map<String, Object>> result = Lists.newArrayList();
childType = childType.toLowerCase(Locale.ENGLISH);
for (IMutation mutation : beeRoot.getMutations(false)) {
if (mutation.isSecret() && !Config.showHiddenMutations) continue;
if (alleleNameMatches(mutation.getAllele0(), childType) || alleleNameMatches(mutation.getAllele1(), childType)) {
result.add(serializeMutation(mutation, true));
}
}
return result;
}
示例4: callMethod
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
if (!Config.enableAnalyzers)
throw new LuaException("Analyzers have been disabled");
switch (method) {
case 0:
ISpeciesRoot root = getRoot();
ItemStack stack = getStackInSlot(0);
if (stack == null || !root.isMember(stack))
return new Object[] {false};
IIndividual individual = root.getMember(stack);
if (!individual.isAnalyzed())
return new Object[] {null};
HashMap<String, Object> ret = new HashMap<String, Object>();
addGenome(stack, individual.getGenome(), ret);
return new Object[] {ret};
case 1:
ItemStack specimen = getStackInSlot(0);
if (specimen == null || !getRoot().isMember(specimen))
return new Object[] {false};
return new Object[] {true};
}
return new Object[]{};
}
示例5: setItem
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
@Nonnull
private ItemStack setItem(int slot, @Nonnull ItemStack itemStack) {
if (slot < 0 || slot >= items.size()) {
return ItemStack.EMPTY;
}
ItemStack prevStack = items.get(slot);
if (!prevStack.isEmpty()) {
this.primarySpeciesUids[slot] = null;
this.secondarySpeciesUids[slot] = null;
}
items.set(slot, itemStack);
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack);
if (speciesRoot != null) {
IIndividual member = speciesRoot.getMember(itemStack);
if (member != null) {
IGenome genome = member.getGenome();
primarySpeciesUids[slot] = genome.getPrimary().getUID();
secondarySpeciesUids[slot] = genome.getSecondary().getUID();
}
}
return prevStack;
}
示例6: getBeeBreedingData
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
@Asynchronous
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get the full breeding list thingy. Experimental!")
public List<Map<String, Object>> getBeeBreedingData(IBeeHousing housing) {
ISpeciesRoot beeRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
if (beeRoot == null) return null;
List<Map<String, Object>> result = Lists.newArrayList();
for (IMutation mutation : beeRoot.getMutations(false)) {
if (mutation.isSecret() && !Config.showHiddenMutations) continue;
final Map<String, Object> mutationMap = Maps.newHashMap();
try {
IAlleleSpecies allele1 = mutation.getAllele0();
if (allele1 != null) mutationMap.put(ALLELE_1, allele1.getName());
IAlleleSpecies allele2 = mutation.getAllele1();
if (allele2 != null) mutationMap.put(ALLELE_2, allele2.getName());
final IAlleleSpecies offspringSpecies = getOffspringSpecies(mutation);
mutationMap.put(MUTATION_RESULT, offspringSpecies.getName());
mutationMap.put(MUTATION_CHANCE, mutation.getBaseChance());
mutationMap.put(MUTATION_CONDITIONS, mutation.getSpecialConditions());
result.add(mutationMap);
} catch (Exception e) {
throw new RuntimeException(String.format("Failed to get bee breeding information from %s, collected data: %s", mutation, mutationMap), e);
}
}
return result;
}
示例7: listAllSpecies
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get all known bees species")
public List<Map<String, String>> listAllSpecies(IBeeHousing housing) {
ISpeciesRoot beeRoot = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
if (beeRoot == null) return null;
final Set<IAlleleSpecies> allSpecies = Sets.newTreeSet(alleleCompatator);
// approach 1: parents and children of all mutations
for (IMutation mutation : beeRoot.getMutations(false)) {
allSpecies.add(mutation.getAllele0());
allSpecies.add(mutation.getAllele1());
allSpecies.add(getOffspringSpecies(mutation));
}
// approach 2: template bees
for (IIndividual individual : beeRoot.getIndividualTemplates()) {
final IGenome genome = individual.getGenome();
allSpecies.add(genome.getPrimary()); // secondary is same as primary
}
// TODO approach 3
// beeRoot.getRegisteredAlleles(EnumBeeChromosome.SPECIES) (Forestry 4.2 API)
final List<Map<String, String>> result = Lists.newArrayList();
for (IAlleleSpecies allele : allSpecies)
if (!allele.isSecret() || Config.showHiddenBees) result.add(serializeAllele(allele));
return result;
}
示例8: BreedingEvent
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
private BreedingEvent(ISpeciesRoot root, GameProfile username, IBreedingTracker tracker) {
super();
this.root = root;
this.username = username;
this.tracker = tracker;
}
示例9: SpeciesDiscovered
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
public SpeciesDiscovered(ISpeciesRoot root, GameProfile username, IAlleleSpecies species, IBreedingTracker tracker) {
super(root, username, tracker);
this.species = species;
}
示例10: MutationDiscovered
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
public MutationDiscovered(ISpeciesRoot root, GameProfile username, IMutation allele, IBreedingTracker tracker) {
super(root, username, tracker);
this.allele = allele;
}
示例11: getRoot
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
protected ISpeciesRoot getRoot() {
return AlleleManager.alleleRegistry.getSpeciesRoot(getRootType());
}
示例12: itemMatched
import forestry.api.genetics.ISpeciesRoot; //导入依赖的package包/类
private boolean itemMatched(@Nonnull ItemStack item) {
if (Prep.isInvalid(item)) {
return false;
}
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(item);
if (speciesRoot == null) {
return false;
}
IIndividual member = speciesRoot.getMember(item);
if (member == null) {
return false;
}
IGenome genome = member.getGenome();
String primarySpeciesUid = genome.getPrimary().getUID();
String secondarySpeciesUid = genome.getSecondary().getUID();
for (int slot = 0; slot < items.size(); slot++) {
ItemStack slotItem = items.get(slot);
if (slotItem.getItem() == item.getItem()) {
switch (speciesMode) {
case BOTH:
if (primarySpeciesUids[slot].equals(primarySpeciesUid) && secondarySpeciesUids[slot].equals(secondarySpeciesUid)) {
return true;
}
break;
case PRIMARY:
if (primarySpeciesUids[slot].equals(primarySpeciesUid)) {
return true;
}
break;
case SECONDARY:
if (secondarySpeciesUids[slot].equals(secondarySpeciesUid)) {
return true;
}
break;
}
}
}
return false;
}