mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
165 lines
4.9 KiB
Java
Executable File
165 lines
4.9 KiB
Java
Executable File
/*******************************************************************************
|
|
* Copyright (c) 2011-2014 SirSengir.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the GNU Lesser Public License v3
|
|
* which accompanies this distribution, and is available at
|
|
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
*
|
|
* Various Contributors including, but not limited to:
|
|
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
|
******************************************************************************/
|
|
package forestry.apiculture.genetics;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
import forestry.api.apiculture.BeeManager;
|
|
import forestry.api.apiculture.EnumBeeChromosome;
|
|
import forestry.api.apiculture.IAlleleBeeEffect;
|
|
import forestry.api.apiculture.IAlleleBeeSpecies;
|
|
import forestry.api.apiculture.IBeeGenome;
|
|
import forestry.api.genetics.AlleleManager;
|
|
import forestry.api.genetics.EnumTolerance;
|
|
import forestry.api.genetics.IAllele;
|
|
import forestry.api.genetics.IAlleleFloat;
|
|
import forestry.api.genetics.IAlleleFlowers;
|
|
import forestry.api.genetics.IAlleleInteger;
|
|
import forestry.api.genetics.IAlleleSpecies;
|
|
import forestry.api.genetics.IChromosome;
|
|
import forestry.api.genetics.IFlowerProvider;
|
|
import forestry.api.genetics.ISpeciesRoot;
|
|
import forestry.core.genetics.Chromosome;
|
|
import forestry.core.genetics.Genome;
|
|
import forestry.core.genetics.alleles.AlleleArea;
|
|
import forestry.core.genetics.alleles.AlleleBoolean;
|
|
import forestry.core.genetics.alleles.AlleleTolerance;
|
|
import forestry.core.vect.Vect;
|
|
|
|
public class BeeGenome extends Genome implements IBeeGenome {
|
|
/**
|
|
* 0 - Species (determines product)
|
|
*
|
|
* 1 - Speed
|
|
*
|
|
* 2 - Lifespan
|
|
*
|
|
* 3 - Fertility (Maximum number of offspring)
|
|
*
|
|
* 4 - Preferred temperature Icy: Snow biomes Cold: Tundra/Steppe, Extreme Mountains/Hills? Normal: Plains, Forests, Mountains Hot: Desert Hellish: Nether
|
|
*
|
|
* 5 - Temperature tolerance (Range +/-)
|
|
*
|
|
* 6 - Nocturnal
|
|
*
|
|
* 7 - Preferred humidity (Arid - Normal - Damp)
|
|
*
|
|
* 8 - Humidity tolerance (Range +/-)
|
|
*
|
|
* 9 - Flight interference tolerance (stuff falling from the sky/other hindrances -> tolerates dampness + flight interference tolerance => rain resistance)
|
|
*
|
|
* 10 - Cave dwelling
|
|
*
|
|
* 11 - Required flowers
|
|
*
|
|
* 12 - Flower plant chance
|
|
*
|
|
* 13 - Territory
|
|
*/
|
|
/* CONSTRUCTOR */
|
|
public BeeGenome(NBTTagCompound nbttagcompound) {
|
|
super(nbttagcompound);
|
|
}
|
|
|
|
public BeeGenome(IChromosome[] chromosomes) {
|
|
super(chromosomes);
|
|
}
|
|
|
|
// NBT RETRIEVAL
|
|
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
|
|
IAlleleSpecies species = getSpeciesDirectly(itemStack);
|
|
if (species instanceof IAlleleBeeSpecies) {
|
|
return (IAlleleBeeSpecies) species;
|
|
}
|
|
|
|
return (IAlleleBeeSpecies) getActiveAllele(itemStack, EnumBeeChromosome.SPECIES, BeeManager.beeRoot);
|
|
}
|
|
|
|
// / INFORMATION RETRIEVAL
|
|
@Override
|
|
public IAlleleBeeSpecies getPrimary() {
|
|
return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES);
|
|
}
|
|
|
|
@Override
|
|
public IAlleleBeeSpecies getSecondary() {
|
|
return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES);
|
|
}
|
|
|
|
@Override
|
|
public float getSpeed() {
|
|
return ((IAlleleFloat) getActiveAllele(EnumBeeChromosome.SPEED)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public int getLifespan() {
|
|
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.LIFESPAN)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public int getFertility() {
|
|
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FERTILITY)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public EnumTolerance getToleranceTemp() {
|
|
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public boolean getNocturnal() {
|
|
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public EnumTolerance getToleranceHumid() {
|
|
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public boolean getTolerantFlyer() {
|
|
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.TOLERANT_FLYER)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public boolean getCaveDwelling() {
|
|
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public IFlowerProvider getFlowerProvider() {
|
|
return ((IAlleleFlowers) getActiveAllele(EnumBeeChromosome.FLOWER_PROVIDER)).getProvider();
|
|
}
|
|
|
|
@Override
|
|
public int getFlowering() {
|
|
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FLOWERING)).getValue();
|
|
}
|
|
|
|
@Override
|
|
public int[] getTerritory() {
|
|
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea();
|
|
return new int[]{area.x, area.y, area.z};
|
|
}
|
|
|
|
@Override
|
|
public IAlleleBeeEffect getEffect() {
|
|
return (IAlleleBeeEffect) getActiveAllele(EnumBeeChromosome.EFFECT);
|
|
}
|
|
|
|
@Override
|
|
public ISpeciesRoot getSpeciesRoot() {
|
|
return BeeManager.beeRoot;
|
|
}
|
|
}
|