@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 @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 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; }
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 boolean canSlotAccept(int slotIndex, ItemStack itemStack) { if (slotIndex == SLOT_ENERGY) { return isAlyzingFuel(itemStack); } // only allow one slot to be used at a time if (hasSpecimen() && getStackInSlot(slotIndex).isEmpty()) { return false; } itemStack = GeneticsUtil.convertToGeneticEquivalent(itemStack); ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(itemStack); if (speciesRoot == null) { return false; } if (slotIndex == SLOT_SPECIMEN) { return true; } IIndividual individual = speciesRoot.getMember(itemStack); return individual != null && individual.isAnalyzed(); }
@Override public boolean hasWork() { moveSpecimenToAnalyzeSlot(); ItemStack specimen = getStackInSlot(InventoryAnalyzer.SLOT_ANALYZE); boolean hasSpecimen = !specimen.isEmpty(); boolean hasResource = true; boolean hasSpace = true; if (hasSpecimen) { hasSpace = InventoryUtil.tryAddStack(invOutput, specimen, true, false); if (specimenToAnalyze != null && !specimenToAnalyze.isAnalyzed()) { FluidStack drained = resourceTank.drain(HONEY_REQUIRED, false); hasResource = drained != null && drained.amount == HONEY_REQUIRED; } } getErrorLogic().setCondition(!hasSpecimen, EnumErrorCode.NO_SPECIMEN); getErrorLogic().setCondition(!hasResource, EnumErrorCode.NO_RESOURCE_LIQUID); getErrorLogic().setCondition(!hasSpace, EnumErrorCode.NO_SPACE_INVENTORY); return hasSpecimen && hasResource && hasSpace; }
@Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { super.drawGuiContainerBackgroundLayer(f, i, j); String header = Translator.translateToLocal("for.gui.page") + " " + (pageCurrent + 1) + "/" + pageMax; fontRenderer.drawString(header, guiLeft + 95 + textLayout.getCenteredOffset(header, 98), guiTop + 10, ColourProperties.INSTANCE.get("gui.title")); IIndividual individual = getIndividualAtPosition(i, j); if (individual == null) { displayBreedingStatistics(10); } if (individual != null) { RenderHelper.enableGUIStandardItemLighting(); textLayout.startPage(); displaySpeciesInformation(true, individual.getGenome().getPrimary(), iconStacks.get(individual.getIdent()), 10); if (!individual.isPureBred(EnumTreeChromosome.SPECIES)) { displaySpeciesInformation(individual.isAnalyzed(), individual.getGenome().getSecondary(), iconStacks.get(individual.getGenome().getSecondary().getUID()), 10); } textLayout.endPage(); } }
@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; }
if (original.isAnalyzed()) { individual.analyze();
invInput.setInventorySlotContents(slotIndex, ItemStack.EMPTY); if (specimenToAnalyze.isAnalyzed()) { setTicksPerWorkCycle(1); setEnergyPerWorkCycle(0);
if (individual != null && !individual.isAnalyzed()) { final boolean requiresEnergy = ModuleHelper.isEnabled(ForestryModuleUids.APICULTURE); if (requiresEnergy) {
if (individual != null && !individual.isAnalyzed()) { final boolean requiresEnergy = ModuleHelper.isEnabled(ForestryModuleUids.APICULTURE); ItemStack energyStack = alyzerInventory.getStackInSlot(InventoryDatabaseAnalyzer.SLOT_ENERGY);
IIndividual individual = root.getMember(stack); if (individual != null) { if (individual.isAnalyzed()) { tabs.setPlugin(databasePlugin); IDatabaseTab tab = tabs.getSelected();