public IGenome getGenome() { Preconditions.checkNotNull(individual, "Database Element has not been initialised."); return individual.getGenome(); }
@Nonnull @Override public Map<Object, Object> getMeta(@Nonnull IPartialContext<IIndividual> context) { IIndividual individual = context.getTarget(); Map<Object, Object> out = Maps.newHashMap(); out.put("id", individual.getIdent()); out.put("analyzed", individual.isAnalyzed()); if (individual.isAnalyzed()) { out.put("genome", context.makePartialChild(individual.getGenome()).getMeta()); Map<String, Boolean> pureBred = Maps.newHashMap(); for (IChromosomeType type : individual.getGenome().getSpeciesRoot().getKaryotype()) { pureBred.put(type.getName().toLowerCase(Locale.ENGLISH), individual.isPureBred(type)); } out.put("pureBred", pureBred); } return out; } }
@Override public boolean workCycle() { ItemStack stackToAnalyze = getStackInSlot(InventoryAnalyzer.SLOT_ANALYZE); if (stackToAnalyze.isEmpty() || specimenToAnalyze == null) { return false; } if (!specimenToAnalyze.isAnalyzed()) { FluidStack drained = resourceTank.drain(HONEY_REQUIRED, false); if (drained == null || drained.amount != HONEY_REQUIRED) { return false; } resourceTank.drain(HONEY_REQUIRED, true); specimenToAnalyze.analyze(); NBTTagCompound nbttagcompound = new NBTTagCompound(); specimenToAnalyze.writeToNBT(nbttagcompound); stackToAnalyze.setTagCompound(nbttagcompound); } boolean added = InventoryUtil.tryAddStack(invOutput, stackToAnalyze, true); if (!added) { return false; } setInventorySlotContents(InventoryAnalyzer.SLOT_ANALYZE, ItemStack.EMPTY); PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay()); NetworkUtil.sendNetworkPacket(packet, pos, world); return true; }
@Override public void registerPickup(IIndividual individual) { ISpeciesRoot speciesRoot = individual.getGenome().getPrimary().getRoot(); if (!speciesRoot.getUID().equals(speciesRootUID())) { return; } if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) { return; } if (!speciesRoot.getCombinations(individual.getGenome().getPrimary()).isEmpty()) { return; } registerSpecies(individual.getGenome().getPrimary()); }
public void addCreativeItems(NonNullList<ItemStack> itemList, boolean hideSecrets) { for (IIndividual individual : BotanyCore.getFlowerRoot().getIndividualTemplates()) { if (hideSecrets && individual.isSecret() && !Config.isDebug) { continue; } itemList.add(BotanyCore.getFlowerRoot().getMemberStack(individual.copy(), type)); } }
if (individual != null && !individual.isAnalyzed()) { final boolean requiresEnergy = ModuleHelper.isEnabled(ForestryModuleUids.APICULTURE); if (requiresEnergy) { if (individual.analyze()) { IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile()); breedingTracker.registerSpecies(individual.getGenome().getPrimary()); breedingTracker.registerSpecies(individual.getGenome().getSecondary()); individual.writeToNBT(nbttagcompound); specimen.setTagCompound(nbttagcompound);
public static ItemStack analyse(ItemStack stack, World world, GameProfile username) { if (!stack.isEmpty()) { ItemStack conv = Binnie.GENETICS.getConversionStack(stack).copy(); if (!conv.isEmpty()) { conv.setCount(stack.getCount()); stack = conv; } ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(stack); if (root != null) { final IIndividual ind = root.getMember(stack); ind.analyze(); IBreedingTracker breedingTracker = ind.getGenome().getSpeciesRoot().getBreedingTracker(world, username); breedingTracker.registerBirth(ind); final NBTTagCompound nbttagcompound = new NBTTagCompound(); ind.writeToNBT(nbttagcompound); stack.setTagCompound(nbttagcompound); return stack; } if (stack.getItem() instanceof IItemAnalysable) { return ((IItemAnalysable) stack.getItem()).analyse(stack); } } return stack; }
@Override public void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); NBTTagCompound bio = new NBTTagCompound(); contained.writeToNBT(bio); nbttagcompound.setTag("BTFLY", bio); if (pollen != null) { NBTTagCompound pln = new NBTTagCompound(); pln.setString("Root", pollen.getGenome().getSpeciesRoot().getUID()); pollen.writeToNBT(pln); nbttagcompound.setTag("PLN", pln); } nbttagcompound.setByte("STATE", (byte) getState().ordinal()); nbttagcompound.setInteger("EXH", exhaustion); nbttagcompound.setInteger("homeX", getHomePosition().getX()); nbttagcompound.setInteger("homeY", getHomePosition().getY()); nbttagcompound.setInteger("homeZ", getHomePosition().getZ()); }
IClassification classification = individual.getGenome().getPrimary().getBranch(); while (classification != null) { String binomial = individual.getGenome().getPrimary().getBinomial(); if (group != null && group.getLevel() == EnumClassLevel.GENUS) { binomial = group.getScientific().substring(0, 1) + ". " + binomial.toLowerCase(Locale.ENGLISH); textLayout.drawLine(Translator.translateToLocal("for.gui.alyzer.authority") + ": " + individual.getGenome().getPrimary().getAuthority(), 12); if (AlleleManager.alleleRegistry.isBlacklisted(individual.getIdent())) { String extinct = ">> " + Translator.translateToLocal("for.gui.alyzer.extinct").toUpperCase() + " <<"; fontRenderer.drawStringWithShadow(extinct, guiLeft + 200 - fontRenderer.getStringWidth(extinct), String description = individual.getGenome().getPrimary().getDescription(); if (StringUtils.isBlank(description) || description.startsWith("for.description.")) { textLayout.drawSplitLine(Translator.translateToLocal("for.gui.alyzer.nodescription"), 12, 200, 0x666666);
@SideOnly(Side.CLIENT) public void setIndividual(@Nullable IIndividual ind) { if (!isDatabase) { if (ind == null) { analystNone.show(); slideUpInv.hide(); } else { analystNone.hide(); slideUpInv.show(); } } if (ind != current && (ind == null || current == null || !ind.isGeneticEqual(current))) { current = ind; boolean systemChange = current != null && ind.getGenome().getSpeciesRoot() != getSystem().getSpeciesRoot(); if (systemChange) { currentSystem = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot()); } updatePages(systemChange); } }
private int getSpecimenSlot() { for (int k = ItemInventoryAlyzer.SLOT_SPECIMEN; k <= ItemInventoryAlyzer.SLOT_ANALYZE_5; k++) { ItemStack stackInSlot = itemInventory.getStackInSlot(k); if (stackInSlot.isEmpty()) { continue; } ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(stackInSlot); if (speciesRoot == null) { continue; } IIndividual individual = speciesRoot.getMember(stackInSlot); if (!individual.isAnalyzed()) { continue; } return k; } return -1; }
@Override public ItemStack getMemberStack(IIndividual tree, ISpeciesType type) { Preconditions.checkArgument(tree instanceof ITree, "individual is not a tree"); Preconditions.checkArgument(type instanceof EnumGermlingType, "type is not an EnumGermlingType"); ItemRegistryArboriculture items = ModuleArboriculture.getItems(); Item germlingItem; switch ((EnumGermlingType) type) { case SAPLING: germlingItem = items.sapling; break; case POLLEN: germlingItem = items.pollenFertile; break; default: throw new RuntimeException("Cannot instantiate a tree of type " + type); } NBTTagCompound nbttagcompound = new NBTTagCompound(); tree.writeToNBT(nbttagcompound); ItemStack treeStack = new ItemStack(germlingItem); treeStack.setTagCompound(nbttagcompound); return treeStack; }
@Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, @Nullable World world, List<String> list, ITooltipFlag flag) { if (itemstack.getTagCompound() == null) { return; } IIndividual individual = getIndividual(itemstack); if (individual != null && individual.isAnalyzed()) { if (GuiScreen.isShiftKeyDown()) { individual.addTooltip(list); } else { list.add(TextFormatting.ITALIC + "<" + Translator.translateToLocal("for.gui.tooltip.tmi") + ">"); } } else { list.add("<" + Translator.translateToLocal("for.gui.unknown") + ">"); } }
private void refreshPickup() { this.panelPickup.deleteAllChildren(); int i = 0; IBreedingSystem system = Binnie.GENETICS.getSystem(this.root); for (ISpeciesType type : system.getActiveTypes()) { IIndividual ind = this.root.templateAsIndividual(this.template); ind.analyze(); ItemStack stack = this.root.getMemberStack(ind, type); ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18); display.setItemStack(stack); display.setTooltip(); display.addEventHandler(EventMouse.Down.class, EventHandlerOrigin.SELF, display, event -> { NBTTagCompound nbt = new NBTTagCompound(); stack.writeToNBT(nbt); Window.get(event.getOrigin()).sendClientAction(ACTION_GENESIS, nbt); }); ++i; } }
public void addCreativeItems(NonNullList<ItemStack> subItems, boolean hideSecrets) { for (IIndividual individual : TreeManager.treeRoot.getIndividualTemplates()) { // Don't show secrets unless ordered to. if (hideSecrets && individual.isSecret() && !Config.isDebug) { continue; } subItems.add(TreeManager.treeRoot.getMemberStack(individual, type)); } }
public GuiNaturalistInventory(ISpeciesRoot speciesRoot, EntityPlayer player, Container container, int page, int maxPages) { super(Constants.TEXTURE_PATH_GUI + "/apiaristinventory.png", container); this.speciesRoot = speciesRoot; this.pageCurrent = page; this.pageMax = maxPages; xSize = 196; ySize = 202; for (IIndividual individual : speciesRoot.getIndividualTemplates()) { iconStacks.put(individual.getIdent(), speciesRoot.getMemberStack(individual, speciesRoot.getIconType())); } breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile()); }
@Override public NonNullList<ItemStack> getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { ItemStack serum = getRoot().getMemberStack(individual.copy(), EnumFlutterType.SERUM); NonNullList<ItemStack> bounty = NonNullList.create(); bounty.add(serum); return bounty; }
if (individual != null && !individual.isAnalyzed()) { final boolean requiresEnergy = ModuleHelper.isEnabled(ForestryModuleUids.APICULTURE); ItemStack energyStack = alyzerInventory.getStackInSlot(InventoryDatabaseAnalyzer.SLOT_ENERGY); if (individual.analyze()) { IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.world, player.getGameProfile()); breedingTracker.registerSpecies(individual.getGenome().getPrimary()); breedingTracker.registerSpecies(individual.getGenome().getSecondary()); individual.writeToNBT(nbttagcompound); specimen = specimen.copy(); specimen.setTagCompound(nbttagcompound);
public static boolean isAnalysed(final ItemStack stack) { if (stack.isEmpty()) { return false; } final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(stack); if (ind != null) { return ind.isAnalyzed(); } return stack.getItem() instanceof IItemAnalysable && ((IItemAnalysable) stack.getItem()).isAnalysed(stack); }
@Override public ItemStack getMemberStack(IIndividual butterfly, ISpeciesType type) { Preconditions.checkArgument(type instanceof EnumFlutterType); ItemRegistryLepidopterology items = ModuleLepidopterology.getItems(); Preconditions.checkNotNull(items); Item butterflyItem; switch ((EnumFlutterType) type) { case SERUM: butterflyItem = items.serumGE; break; case CATERPILLAR: butterflyItem = items.caterpillarGE; break; case COCOON: butterflyItem = items.cocoonGE; break; case BUTTERFLY: default: butterflyItem = items.butterflyGE; break; } NBTTagCompound nbttagcompound = new NBTTagCompound(); butterfly.writeToNBT(nbttagcompound); ItemStack stack = new ItemStack(butterflyItem); stack.setTagCompound(nbttagcompound); if (type == EnumFlutterType.CATERPILLAR) { ItemButterflyGE.setAge(stack, 0); } return stack; }