@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 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; }
@Override public ItemStack getMemberStack(IIndividual flower, ISpeciesType type) { if (!isMember(flower)) { return ItemStack.EMPTY; } Item flowerItem = ModuleFlowers.flowerItem; if (type == EnumFlowerStage.SEED) { flowerItem = ModuleFlowers.seed; } else if (type == EnumFlowerStage.POLLEN) { flowerItem = ModuleFlowers.pollen; } if (flowerItem != ModuleFlowers.flowerItem) { ((IFlower) flower).setAge(0); } NBTTagCompound nbttagcompound = new NBTTagCompound(); flower.writeToNBT(nbttagcompound); ItemStack flowerStack = new ItemStack(flowerItem); flowerStack.setTagCompound(nbttagcompound); return flowerStack; }
@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; }
individual.writeToNBT(nbt); if (mate != null) { nbt.setTag("Mate", mate);
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()); }
individual.writeToNBT(nbttagcompound); specimen.setTagCompound(nbttagcompound);
individual.writeToNBT(nbttagcompound); specimen = specimen.copy(); specimen.setTagCompound(nbttagcompound);