use of forestry.api.genetics.IBreedingTracker in project ForestryMC by ForestryMC.
the class BreedingTracker method synchToPlayer.
@Override
public void synchToPlayer(EntityPlayer player) {
if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) {
IBreedingTracker breedingTracker = getBreedingTracker(player);
String modeName = breedingTracker.getModeName();
setModeName(modeName);
NBTTagCompound nbttagcompound = new NBTTagCompound();
encodeToNBT(nbttagcompound);
PacketGenomeTrackerSync packet = new PacketGenomeTrackerSync(nbttagcompound);
NetworkUtil.sendToPlayer(packet, player);
}
}
use of forestry.api.genetics.IBreedingTracker in project ForestryMC by ForestryMC.
the class AlleleSpecies method getResearchBounty.
@Override
public NonNullList<ItemStack> getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
if (world.rand.nextFloat() < bountyLevel / 16.0f) {
List<? extends IMutation> allMutations = getRoot().getCombinations(this);
if (!allMutations.isEmpty()) {
List<IMutation> unresearchedMutations = new ArrayList<>();
IBreedingTracker tracker = individual.getGenome().getSpeciesRoot().getBreedingTracker(world, researcher);
for (IMutation mutation : allMutations) {
if (!tracker.isResearched(mutation)) {
unresearchedMutations.add(mutation);
}
}
IMutation chosenMutation;
if (!unresearchedMutations.isEmpty()) {
chosenMutation = unresearchedMutations.get(world.rand.nextInt(unresearchedMutations.size()));
} else {
chosenMutation = allMutations.get(world.rand.nextInt(allMutations.size()));
}
ItemStack researchNote = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, chosenMutation);
NonNullList<ItemStack> bounty = NonNullList.create();
bounty.add(researchNote);
return bounty;
}
}
return NonNullList.create();
}
use of forestry.api.genetics.IBreedingTracker in project ForestryMC by ForestryMC.
the class PickupHandlerCore method onItemPickup.
@Override
public boolean onItemPickup(EntityPlayer entityPlayer, EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
if (itemstack.isEmpty()) {
return false;
}
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(itemstack);
if (root != null) {
IIndividual individual = root.getMember(itemstack);
if (individual != null) {
IBreedingTracker tracker = root.getBreedingTracker(entityitem.world, entityPlayer.getGameProfile());
tracker.registerPickup(individual);
}
}
return false;
}
use of forestry.api.genetics.IBreedingTracker in project Binnie by ForestryMC.
the class WindowAnalyst method initialiseServer.
@Override
public void initialiseServer() {
for (IBreedingSystem system : Binnie.GENETICS.getActiveSystems()) {
ISpeciesRoot root = system.getSpeciesRoot();
if (root != null) {
IBreedingTracker tracker = root.getBreedingTracker(getWorld(), getUsername());
if (tracker != null) {
tracker.synchToPlayer(getPlayer());
}
}
}
// create slots
getWindowInventory().createSlot(0);
getWindowInventory().createSlot(1);
setupValidators();
}
use of forestry.api.genetics.IBreedingTracker in project ForestryMC by ForestryMC.
the class TileSapling method tryGrow.
public void tryGrow(Random random, boolean bonemealed) {
ITree tree = getTree();
if (tree == null) {
return;
}
int maturity = getRequiredMaturity(world, tree);
if (timesTicked < maturity) {
if (bonemealed) {
timesTicked = maturity;
}
return;
}
WorldGenerator generator = tree.getTreeGenerator(world, getPos(), bonemealed);
final boolean generated;
if (generator instanceof WorldGenBase) {
generated = ((WorldGenBase) generator).generate(world, random, getPos(), false);
} else {
generated = generator.generate(world, random, getPos());
}
if (generated) {
IBreedingTracker breedingTracker = TreeManager.treeRoot.getBreedingTracker(world, getOwnerHandler().getOwner());
breedingTracker.registerBirth(tree);
}
}
Aggregations