use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class FilterLogic method isValid.
public boolean isValid(EnumFacing facing, ItemStack itemStack, IFilterData filterData) {
IFilterRuleType rule = getRule(facing);
if (rule == DefaultFilterRuleType.CLOSED) {
return false;
}
if (rule == DefaultFilterRuleType.ITEM && !filterData.isPresent()) {
return true;
}
String requiredRoot = rule.getRootUID();
if (requiredRoot != null && (!filterData.isPresent() || !filterData.getRoot().getUID().equals(requiredRoot))) {
return false;
}
if (rule == DefaultFilterRuleType.ANYTHING || rule.isValid(itemStack, filterData)) {
if (filterData.isPresent()) {
IIndividual ind = filterData.getIndividual();
IGenome genome = ind.getGenome();
IAllele active = genome.getPrimary();
IAllele inactive = genome.getSecondary();
if (!isValidAllelePair(facing, active.getUID(), inactive.getUID())) {
return false;
}
}
return true;
}
return false;
}
use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class EscritoireGameBoard method initialize.
public boolean initialize(ItemStack specimen) {
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(specimen);
if (individual == null) {
return false;
}
IGenome genome = individual.getGenome();
ISpeciesRoot root = genome.getPrimary().getRoot();
tokenCount = getTokenCount(genome);
for (int i = 0; i < tokenCount / 2; i++) {
IAllele[] randomTemplate = root.getRandomTemplate(rand);
String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID();
gameTokens.add(new EscritoireGameToken(speciesUid));
gameTokens.add(new EscritoireGameToken(speciesUid));
}
Collections.shuffle(gameTokens);
return true;
}
use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class TileEscritoire method processTurnResult.
private void processTurnResult(GameProfile gameProfile) {
if (getGame().getStatus() != EscritoireGame.Status.SUCCESS) {
return;
}
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getStackInSlot(InventoryEscritoire.SLOT_ANALYZE));
if (individual == null) {
return;
}
IAlleleSpecies species = individual.getGenome().getPrimary();
for (ItemStack itemstack : species.getResearchBounty(world, gameProfile, individual, game.getBountyLevel())) {
InventoryUtil.addStack(getInternalInventory(), itemstack, InventoryEscritoire.SLOT_RESULTS_1, InventoryEscritoire.SLOTS_RESULTS_COUNT, true);
}
}
use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class ModuleArboriculture method registerErsatzGenomes.
private static void registerErsatzGenomes() {
TreeManager.treeRoot.registerTranslator(Blocks.LEAVES, new IBlockTranslator<ITree>() {
@Nullable
@Override
public ITree getIndividualFromObject(IBlockState blockState) {
if (!blockState.getValue(BlockLeaves.DECAYABLE)) {
return null;
}
switch(blockState.getValue(BlockOldLeaf.VARIANT)) {
case OAK:
return TreeDefinition.Oak.getIndividual();
case SPRUCE:
return TreeDefinition.Spruce.getIndividual();
case BIRCH:
return TreeDefinition.Birch.getIndividual();
case JUNGLE:
return TreeDefinition.Jungle.getIndividual();
}
return null;
}
});
TreeManager.treeRoot.registerTranslator(Blocks.LEAVES2, new IBlockTranslator<ITree>() {
@Nullable
@Override
public ITree getIndividualFromObject(IBlockState blockState) {
if (!blockState.getValue(BlockLeaves.DECAYABLE)) {
return null;
}
switch(blockState.getValue(BlockNewLeaf.VARIANT)) {
case ACACIA:
return TreeDefinition.AcaciaVanilla.getIndividual();
case DARK_OAK:
return TreeDefinition.DarkOak.getIndividual();
}
return null;
}
});
TreeManager.treeRoot.registerTranslator(Item.getItemFromBlock(Blocks.SAPLING), new IItemTranslator<ITree>() {
@Nullable
@Override
public ITree getIndividualFromObject(ItemStack itemStack) {
switch(itemStack.getMetadata()) {
case 0:
return TreeDefinition.Oak.getIndividual();
case 1:
return TreeDefinition.Spruce.getIndividual();
case 2:
return TreeDefinition.Birch.getIndividual();
case 3:
return TreeDefinition.Jungle.getIndividual();
case 4:
return TreeDefinition.AcaciaVanilla.getIndividual();
case 5:
return TreeDefinition.DarkOak.getIndividual();
}
return null;
}
});
for (BlockDefaultLeaves leaves : getBlocks().leavesDefault) {
TreeManager.treeRoot.registerTranslator(leaves, (IBlockTranslator<IIndividual>) blockState -> {
TreeDefinition treeDefinition = leaves.getTreeDefinition(blockState);
if (treeDefinition != null) {
return treeDefinition.getIndividual();
} else {
return null;
}
});
}
}
use of forestry.api.genetics.IIndividual in project ForestryMC by ForestryMC.
the class GuiAlyzer method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
widgetManager.clear();
int specimenSlot = getSpecimenSlot();
if (specimenSlot < ItemInventoryAlyzer.SLOT_ANALYZE_1) {
drawAnalyticsOverview();
return;
}
ItemStack stackInSlot = itemInventory.getStackInSlot(specimenSlot);
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot);
if (speciesRoot == null) {
return;
}
switch(specimenSlot) {
case ItemInventoryAlyzer.SLOT_ANALYZE_1:
{
speciesRoot.getAlyzerPlugin().drawAnalyticsPage1(this, stackInSlot);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_2:
{
speciesRoot.getAlyzerPlugin().drawAnalyticsPage2(this, stackInSlot);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_3:
{
speciesRoot.getAlyzerPlugin().drawAnalyticsPage3(this, stackInSlot);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_4:
{
IIndividual individual = speciesRoot.getMember(stackInSlot);
drawAnalyticsPageMutations(individual);
break;
}
case ItemInventoryAlyzer.SLOT_ANALYZE_5:
{
IIndividual individual = speciesRoot.getMember(stackInSlot);
drawAnalyticsPageClassification(individual);
break;
}
default:
drawAnalyticsOverview();
}
}
Aggregations