Update buildscript & spotlessApply

This commit is contained in:
DianeXD committed 2022-07-03 12:17:51 +08:00
1 parent e4329e2b8f
commit 8683a345c3
818 files changed
+51123 -49403

No files matched your search

@@ -18,124 +18,125 @@ import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.alleles.EnumAllele;
import java.util.TreeSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.TreeSet;
class BeeBreedingSystem extends BreedingSystem {
public BeeBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee");
}
public BeeBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee");
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
return ((IBeeMutation) mutation).getChance(
new VirtualBeeHousing(player),
(IAlleleBeeSpecies) species1,
(IAlleleBeeSpecies) species2,
(IBeeGenome) getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(species1.getUID())),
(IBeeGenome) getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(species2.getUID()))
);
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
return ((IBeeMutation) mutation)
.getChance(
new VirtualBeeHousing(player),
(IAlleleBeeSpecies) species1,
(IAlleleBeeSpecies) species2,
(IBeeGenome) getSpeciesRoot()
.templateAsGenome(getSpeciesRoot().getTemplate(species1.getUID())),
(IBeeGenome) getSpeciesRoot()
.templateAsGenome(getSpeciesRoot().getTemplate(species2.getUID())));
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getBeeRoot();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getBeeRoot();
}
@Override
public int getColor() {
return 0xffd900;
}
@Override
public int getColor() {
return 0xffd900;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return IApiaristTracker.class;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return IApiaristTracker.class;
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumBeeChromosome.FERTILITY) {
if (allele.getUID().contains("Low")) {
return I18N.localise("binniecore.allele.fertility.low");
}
if (allele.getUID().contains("Normal")) {
return I18N.localise("binniecore.allele.fertility.normal");
}
if (allele.getUID().contains("High")) {
return I18N.localise("binniecore.allele.fertility.high");
}
if (allele.getUID().contains("Maximum")) {
return I18N.localise("binniecore.allele.fertility.maximum");
}
}
return super.getAlleleName(chromosome, allele);
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumBeeChromosome.FERTILITY) {
if (allele.getUID().contains("Low")) {
return I18N.localise("binniecore.allele.fertility.low");
}
if (allele.getUID().contains("Normal")) {
return I18N.localise("binniecore.allele.fertility.normal");
}
if (allele.getUID().contains("High")) {
return I18N.localise("binniecore.allele.fertility.high");
}
if (allele.getUID().contains("Maximum")) {
return I18N.localise("binniecore.allele.fertility.maximum");
}
}
return super.getAlleleName(chromosome, allele);
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((IBeeRoot) getSpeciesRoot()).getType(member) == EnumBeeType.LARVAE;
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((IBeeRoot) getSpeciesRoot()).getType(member) == EnumBeeType.LARVAE;
}
@Override
public int[] getActiveTypes() {
return new int[] {
EnumBeeType.DRONE.ordinal(),
EnumBeeType.PRINCESS.ordinal(),
EnumBeeType.QUEEN.ordinal(),
EnumBeeType.LARVAE.ordinal()
};
}
@Override
public int[] getActiveTypes() {
return new int[] {
EnumBeeType.DRONE.ordinal(),
EnumBeeType.PRINCESS.ordinal(),
EnumBeeType.QUEEN.ordinal(),
EnumBeeType.LARVAE.ordinal()
};
}
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumBeeChromosome) chromosome) {
case FERTILITY:
for (EnumAllele.Fertility fertility : EnumAllele.Fertility.values()) {
alleles.add(AlleleHelper.getAllele(fertility));
}
break;
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumBeeChromosome) chromosome) {
case FERTILITY:
for (EnumAllele.Fertility fertility : EnumAllele.Fertility.values()) {
alleles.add(AlleleHelper.getAllele(fertility));
}
break;
case FLOWERING:
for (EnumAllele.Flowering flowering : EnumAllele.Flowering.values()) {
alleles.add(AlleleHelper.getAllele(flowering));
}
break;
case FLOWERING:
for (EnumAllele.Flowering flowering : EnumAllele.Flowering.values()) {
alleles.add(AlleleHelper.getAllele(flowering));
}
break;
case HUMIDITY_TOLERANCE:
case TEMPERATURE_TOLERANCE:
for (EnumTolerance tolerance : EnumTolerance.values()) {
alleles.add(AlleleHelper.getAllele(tolerance));
}
break;
case HUMIDITY_TOLERANCE:
case TEMPERATURE_TOLERANCE:
for (EnumTolerance tolerance : EnumTolerance.values()) {
alleles.add(AlleleHelper.getAllele(tolerance));
}
break;
case LIFESPAN:
for (EnumAllele.Lifespan lifespan : EnumAllele.Lifespan.values()) {
alleles.add(AlleleHelper.getAllele(lifespan));
}
break;
case LIFESPAN:
for (EnumAllele.Lifespan lifespan : EnumAllele.Lifespan.values()) {
alleles.add(AlleleHelper.getAllele(lifespan));
}
break;
case SPEED:
for (EnumAllele.Speed speed : EnumAllele.Speed.values()) {
alleles.add(AlleleHelper.getAllele(speed));
}
break;
case SPEED:
for (EnumAllele.Speed speed : EnumAllele.Speed.values()) {
alleles.add(AlleleHelper.getAllele(speed));
}
break;
case TERRITORY:
for (EnumAllele.Territory territory : EnumAllele.Territory.values()) {
alleles.add(AlleleHelper.getAllele(territory));
}
break;
case TERRITORY:
for (EnumAllele.Territory territory : EnumAllele.Territory.values()) {
alleles.add(AlleleHelper.getAllele(territory));
}
break;
case NOCTURNAL:
case CAVE_DWELLING:
case TOLERANT_FLYER:
for (ForestryAllele.Bool bool : ForestryAllele.Bool.values()) {
alleles.add(bool.getAllele());
}
break;
}
}
case NOCTURNAL:
case CAVE_DWELLING:
case TOLERANT_FLYER:
for (ForestryAllele.Bool bool : ForestryAllele.Bool.values()) {
alleles.add(bool.getAllele());
}
break;
}
}
}
@@ -6,44 +6,44 @@ import java.util.List;
import java.util.Map;
public class BeeModifierLogic {
private Map<EnumBeeModifier, Float[]> modifiers;
private List<EnumBeeBooleanModifier> booleanModifiers;
private Map<EnumBeeModifier, Float[]> modifiers;
private List<EnumBeeBooleanModifier> booleanModifiers;
public BeeModifierLogic() {
modifiers = new HashMap<>();
booleanModifiers = new ArrayList<>();
}
public BeeModifierLogic() {
modifiers = new HashMap<>();
booleanModifiers = new ArrayList<>();
}
public float getModifier(EnumBeeModifier modifier, float currentModifier) {
if (!modifiers.containsKey(modifier)) {
return 1.0f;
}
public float getModifier(EnumBeeModifier modifier, float currentModifier) {
if (!modifiers.containsKey(modifier)) {
return 1.0f;
}
Float[] values = modifiers.get(modifier);
float mult = values[0];
float max = values[1];
if (max >= 1.0f) {
if (max <= currentModifier) {
return 1.0f;
}
return Math.min(max / currentModifier, mult);
}
Float[] values = modifiers.get(modifier);
float mult = values[0];
float max = values[1];
if (max >= 1.0f) {
if (max <= currentModifier) {
return 1.0f;
}
return Math.min(max / currentModifier, mult);
}
if (max >= currentModifier) {
return 1.0f;
}
return Math.max(max / currentModifier, mult);
}
if (max >= currentModifier) {
return 1.0f;
}
return Math.max(max / currentModifier, mult);
}
public boolean getModifier(EnumBeeBooleanModifier modifier) {
return booleanModifiers.contains(modifier);
}
public boolean getModifier(EnumBeeBooleanModifier modifier) {
return booleanModifiers.contains(modifier);
}
public void setModifier(EnumBeeBooleanModifier modifier) {
booleanModifiers.add(modifier);
}
public void setModifier(EnumBeeBooleanModifier modifier) {
booleanModifiers.add(modifier);
}
public void setModifier(EnumBeeModifier modifier, float mult, float max) {
modifiers.put(modifier, new Float[] { mult, max });
}
public void setModifier(EnumBeeModifier modifier, float mult, float max) {
modifiers.put(modifier, new Float[] {mult, max});
}
}
@@ -18,12 +18,6 @@ import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -32,406 +26,414 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
public abstract class BreedingSystem implements IItemStackRepresentative {
public float discoveredSpeciesPercentage;
public int totalSpeciesCount;
public int discoveredSpeciesCount;
public int totalSecretCount;
public int discoveredSecretCount;
public float discoveredBranchPercentage;
public int totalBranchCount;
public int discoveredBranchCount;
public float discoveredSpeciesPercentage;
public int totalSpeciesCount;
public int discoveredSpeciesCount;
public int totalSecretCount;
public int discoveredSecretCount;
public float discoveredBranchPercentage;
public int totalBranchCount;
public int discoveredBranchCount;
protected BinnieIcon iconUndiscovered;
protected BinnieIcon iconDiscovered;
protected List<IAlleleSpecies> allActiveSpecies = new ArrayList<>();
protected BinnieIcon iconUndiscovered;
protected BinnieIcon iconDiscovered;
protected List<IAlleleSpecies> allActiveSpecies = new ArrayList<>();
private List<IClassification> allBranches = new ArrayList<>();
private List<IMutation> allMutations = new ArrayList<>();
private Map<IAlleleSpecies, List<IMutation>> resultantMutations = new HashMap<>();
private Map<IAlleleSpecies, List<IMutation>> furtherMutations = new HashMap<>();
private List<IClassification> allBranches = new ArrayList<>();
private List<IMutation> allMutations = new ArrayList<>();
private Map<IAlleleSpecies, List<IMutation>> resultantMutations = new HashMap<>();
private Map<IAlleleSpecies, List<IMutation>> furtherMutations = new HashMap<>();
public BreedingSystem() {
Binnie.Genetics.registerBreedingSystem(this);
MinecraftForge.EVENT_BUS.register(this);
}
public BreedingSystem() {
Binnie.Genetics.registerBreedingSystem(this);
MinecraftForge.EVENT_BUS.register(this);
}
public String getChromosomeName(IChromosomeType chromo) {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".chromosome." + chromo.getName());
}
public String getChromosomeName(IChromosomeType chromo) {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".chromosome." + chromo.getName());
}
public String getChromosomeShortName(IChromosomeType chromo) {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".chromosome." + chromo.getName() + ".short");
}
public String getChromosomeShortName(IChromosomeType chromo) {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".chromosome." + chromo.getName() + ".short");
}
public String getEpitome(float discoveredPercentage) {
int i = 0;
if (discoveredPercentage == 1.0f) {
i = 6;
} else if (discoveredPercentage < 0.1f) {
i = 0;
} else if (discoveredPercentage < 0.3f) {
i = 1;
} else if (discoveredPercentage < 0.5f) {
i = 2;
} else if (discoveredPercentage < 0.7f) {
i = 3;
} else if (discoveredPercentage < 0.9f) {
i = 4;
} else if (discoveredPercentage < 1.0f) {
i = 5;
}
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".epitome." + i);
}
public String getEpitome(float discoveredPercentage) {
int i = 0;
if (discoveredPercentage == 1.0f) {
i = 6;
} else if (discoveredPercentage < 0.1f) {
i = 0;
} else if (discoveredPercentage < 0.3f) {
i = 1;
} else if (discoveredPercentage < 0.5f) {
i = 2;
} else if (discoveredPercentage < 0.7f) {
i = 3;
} else if (discoveredPercentage < 0.9f) {
i = 4;
} else if (discoveredPercentage < 1.0f) {
i = 5;
}
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".epitome." + i);
}
public abstract ISpeciesRoot getSpeciesRoot();
public abstract ISpeciesRoot getSpeciesRoot();
public List<IClassification> getAllBranches() {
return allBranches;
}
public List<IClassification> getAllBranches() {
return allBranches;
}
public Collection<IAlleleSpecies> getAllSpecies() {
return allActiveSpecies;
}
public Collection<IAlleleSpecies> getAllSpecies() {
return allActiveSpecies;
}
public Collection<IMutation> getAllMutations() {
return allMutations;
}
public Collection<IMutation> getAllMutations() {
return allMutations;
}
public void calculateArrays() {
Collection<IAllele> allAlleles = AlleleManager.alleleRegistry.getRegisteredAlleles().values();
resultantMutations = new HashMap<>();
furtherMutations = new HashMap<>();
allActiveSpecies = new ArrayList<>();
public void calculateArrays() {
Collection<IAllele> allAlleles =
AlleleManager.alleleRegistry.getRegisteredAlleles().values();
resultantMutations = new HashMap<>();
furtherMutations = new HashMap<>();
allActiveSpecies = new ArrayList<>();
for (IAllele species : allAlleles) {
if (getSpeciesRoot().getTemplate(species.getUID()) != null) {
resultantMutations.put((IAlleleSpecies) species, new ArrayList<>());
furtherMutations.put((IAlleleSpecies) species, new ArrayList<>());
for (IAllele species : allAlleles) {
if (getSpeciesRoot().getTemplate(species.getUID()) != null) {
resultantMutations.put((IAlleleSpecies) species, new ArrayList<>());
furtherMutations.put((IAlleleSpecies) species, new ArrayList<>());
if (isBlacklisted(species) || species.getUID().contains("speciesBotAlfheim")) {
continue;
}
allActiveSpecies.add((IAlleleSpecies) species);
}
}
if (isBlacklisted(species) || species.getUID().contains("speciesBotAlfheim")) {
continue;
}
allActiveSpecies.add((IAlleleSpecies) species);
}
}
allMutations = new ArrayList<>();
Collection<IClassification> allRegBranches = AlleleManager.alleleRegistry.getRegisteredClassifications().values();
allBranches = new ArrayList<>();
for (IClassification branch : allRegBranches) {
if (branch.getMemberSpecies().length > 0 && getSpeciesRoot().getTemplate(branch.getMemberSpecies()[0].getUID()) != null) {
boolean possible = false;
for (IAlleleSpecies species2 : branch.getMemberSpecies()) {
if (allActiveSpecies.contains(species2)) {
possible = true;
}
}
if (!possible) {
continue;
}
allBranches.add(branch);
}
}
allMutations = new ArrayList<>();
Collection<IClassification> allRegBranches =
AlleleManager.alleleRegistry.getRegisteredClassifications().values();
allBranches = new ArrayList<>();
for (IClassification branch : allRegBranches) {
if (branch.getMemberSpecies().length > 0
&& getSpeciesRoot().getTemplate(branch.getMemberSpecies()[0].getUID()) != null) {
boolean possible = false;
for (IAlleleSpecies species2 : branch.getMemberSpecies()) {
if (allActiveSpecies.contains(species2)) {
possible = true;
}
}
if (!possible) {
continue;
}
allBranches.add(branch);
}
}
if (getSpeciesRoot().getMutations(false) != null) {
Set<IMutation> mutations = new LinkedHashSet<>();
mutations.addAll(getSpeciesRoot().getMutations(false));
// TODO Why is this necessary?
if (this == Binnie.Genetics.beeBreedingSystem) {
mutations.addAll(ExtraBeeMutation.mutations);
}
if (getSpeciesRoot().getMutations(false) != null) {
Set<IMutation> mutations = new LinkedHashSet<>();
mutations.addAll(getSpeciesRoot().getMutations(false));
// TODO Why is this necessary?
if (this == Binnie.Genetics.beeBreedingSystem) {
mutations.addAll(ExtraBeeMutation.mutations);
}
for (IMutation mutation : mutations) {
allMutations.add(mutation);
Set<IAlleleSpecies> participatingSpecies = new LinkedHashSet<>();
if (mutation.getAllele0() != null) {
participatingSpecies.add(mutation.getAllele0());
}
if (mutation.getAllele1() != null) {
participatingSpecies.add(mutation.getAllele1());
}
for (IMutation mutation : mutations) {
allMutations.add(mutation);
Set<IAlleleSpecies> participatingSpecies = new LinkedHashSet<>();
if (mutation.getAllele0() != null) {
participatingSpecies.add(mutation.getAllele0());
}
if (mutation.getAllele1() != null) {
participatingSpecies.add(mutation.getAllele1());
}
for (IAlleleSpecies species3 : participatingSpecies) {
if (allActiveSpecies.contains(species3)) {
furtherMutations.get(species3).add(mutation);
}
}
if (resultantMutations.containsKey(mutation.getTemplate()[0])) {
resultantMutations.get(mutation.getTemplate()[0]).add(mutation);
}
}
}
}
for (IAlleleSpecies species3 : participatingSpecies) {
if (allActiveSpecies.contains(species3)) {
furtherMutations.get(species3).add(mutation);
}
}
if (resultantMutations.containsKey(mutation.getTemplate()[0])) {
resultantMutations.get(mutation.getTemplate()[0]).add(mutation);
}
}
}
}
public boolean isBlacklisted(IAllele allele) {
return AlleleManager.alleleRegistry.isBlacklisted(allele.getUID());
}
public boolean isBlacklisted(IAllele allele) {
return AlleleManager.alleleRegistry.isBlacklisted(allele.getUID());
}
public List<IMutation> getResultantMutations(IAlleleSpecies species) {
if (resultantMutations.isEmpty()) {
calculateArrays();
}
return resultantMutations.get(species);
}
public List<IMutation> getResultantMutations(IAlleleSpecies species) {
if (resultantMutations.isEmpty()) {
calculateArrays();
}
return resultantMutations.get(species);
}
public List<IMutation> getFurtherMutations(IAlleleSpecies species) {
if (furtherMutations.isEmpty()) {
calculateArrays();
}
return furtherMutations.get(species);
}
public List<IMutation> getFurtherMutations(IAlleleSpecies species) {
if (furtherMutations.isEmpty()) {
calculateArrays();
}
return furtherMutations.get(species);
}
public boolean isMutationDiscovered(IMutation mutation, World world, GameProfile name) {
return isMutationDiscovered(mutation, getSpeciesRoot().getBreedingTracker(world, name));
}
public boolean isMutationDiscovered(IMutation mutation, World world, GameProfile name) {
return isMutationDiscovered(mutation, getSpeciesRoot().getBreedingTracker(world, name));
}
public boolean isMutationDiscovered(IMutation mutation, IBreedingTracker tracker) {
return tracker == null || tracker.isDiscovered(mutation);
}
public boolean isMutationDiscovered(IMutation mutation, IBreedingTracker tracker) {
return tracker == null || tracker.isDiscovered(mutation);
}
public boolean isSpeciesDiscovered(IAlleleSpecies species, World world, GameProfile name) {
return isSpeciesDiscovered(species, getSpeciesRoot().getBreedingTracker(world, name));
}
public boolean isSpeciesDiscovered(IAlleleSpecies species, World world, GameProfile name) {
return isSpeciesDiscovered(species, getSpeciesRoot().getBreedingTracker(world, name));
}
public boolean isSpeciesDiscovered(IAlleleSpecies species, IBreedingTracker tracker) {
return tracker == null || tracker.isDiscovered(species);
}
public boolean isSpeciesDiscovered(IAlleleSpecies species, IBreedingTracker tracker) {
return tracker == null || tracker.isDiscovered(species);
}
public boolean isSecret(IAlleleSpecies species) {
return !species.isCounted();
}
public boolean isSecret(IAlleleSpecies species) {
return !species.isCounted();
}
public boolean isSecret(IClassification branch) {
for (IAlleleSpecies species : branch.getMemberSpecies()) {
if (!isSecret(species)) {
return false;
}
}
return true;
}
public boolean isSecret(IClassification branch) {
for (IAlleleSpecies species : branch.getMemberSpecies()) {
if (!isSecret(species)) {
return false;
}
}
return true;
}
public Collection<IClassification> getDiscoveredBranches(World world, GameProfile player) {
List<IClassification> branches = new ArrayList<>();
for (IClassification branch : getAllBranches()) {
boolean discovered = false;
for (IAlleleSpecies species : branch.getMemberSpecies()) {
if (isSpeciesDiscovered(species, world, player)) {
discovered = true;
}
}
public Collection<IClassification> getDiscoveredBranches(World world, GameProfile player) {
List<IClassification> branches = new ArrayList<>();
for (IClassification branch : getAllBranches()) {
boolean discovered = false;
for (IAlleleSpecies species : branch.getMemberSpecies()) {
if (isSpeciesDiscovered(species, world, player)) {
discovered = true;
}
}
if (discovered) {
branches.add(branch);
}
}
return branches;
}
if (discovered) {
branches.add(branch);
}
}
return branches;
}
public Collection<IClassification> getDiscoveredBranches(IBreedingTracker tracker) {
List<IClassification> branches = new ArrayList<>();
for (IClassification branch : getAllBranches()) {
boolean discovered = false;
for (IAlleleSpecies species : branch.getMemberSpecies()) {
if (isSpeciesDiscovered(species, tracker)) {
discovered = true;
}
}
public Collection<IClassification> getDiscoveredBranches(IBreedingTracker tracker) {
List<IClassification> branches = new ArrayList<>();
for (IClassification branch : getAllBranches()) {
boolean discovered = false;
for (IAlleleSpecies species : branch.getMemberSpecies()) {
if (isSpeciesDiscovered(species, tracker)) {
discovered = true;
}
}
if (discovered) {
branches.add(branch);
}
}
return branches;
}
if (discovered) {
branches.add(branch);
}
}
return branches;
}
public Collection<IAlleleSpecies> getDiscoveredSpecies(World world, GameProfile player) {
List<IAlleleSpecies> speciesList = new ArrayList<>();
for (IAlleleSpecies species : getAllSpecies()) {
if (isSpeciesDiscovered(species, world, player)) {
speciesList.add(species);
}
}
return speciesList;
}
public Collection<IAlleleSpecies> getDiscoveredSpecies(World world, GameProfile player) {
List<IAlleleSpecies> speciesList = new ArrayList<>();
for (IAlleleSpecies species : getAllSpecies()) {
if (isSpeciesDiscovered(species, world, player)) {
speciesList.add(species);
}
}
return speciesList;
}
public Collection<IAlleleSpecies> getDiscoveredSpecies(IBreedingTracker tracker) {
List<IAlleleSpecies> speciesList = new ArrayList<>();
for (IAlleleSpecies species : getAllSpecies()) {
if (isSpeciesDiscovered(species, tracker)) {
speciesList.add(species);
}
}
return speciesList;
}
public Collection<IAlleleSpecies> getDiscoveredSpecies(IBreedingTracker tracker) {
List<IAlleleSpecies> speciesList = new ArrayList<>();
for (IAlleleSpecies species : getAllSpecies()) {
if (isSpeciesDiscovered(species, tracker)) {
speciesList.add(species);
}
}
return speciesList;
}
public List<IMutation> getDiscoveredMutations(World world, GameProfile player) {
List<IMutation> speciesList = new ArrayList<>();
for (IMutation species : getAllMutations()) {
if (isMutationDiscovered(species, world, player)) {
speciesList.add(species);
}
}
return speciesList;
}
public List<IMutation> getDiscoveredMutations(World world, GameProfile player) {
List<IMutation> speciesList = new ArrayList<>();
for (IMutation species : getAllMutations()) {
if (isMutationDiscovered(species, world, player)) {
speciesList.add(species);
}
}
return speciesList;
}
public IIcon getUndiscoveredIcon() {
return iconUndiscovered.getIcon();
}
public IIcon getUndiscoveredIcon() {
return iconUndiscovered.getIcon();
}
public IIcon getDiscoveredIcon() {
return iconDiscovered.getIcon();
}
public IIcon getDiscoveredIcon() {
return iconDiscovered.getIcon();
}
public abstract float getChance(IMutation mutation, EntityPlayer player, IAllele allele1, IAllele allele2);
public abstract float getChance(IMutation mutation, EntityPlayer player, IAllele allele1, IAllele allele2);
public abstract Class<? extends IBreedingTracker> getTrackerClass();
public abstract Class<? extends IBreedingTracker> getTrackerClass();
@SubscribeEvent
public void onSyncBreedingTracker(ForestryEvent.SyncedBreedingTracker event) {
IBreedingTracker tracker = event.tracker;
if (!getTrackerClass().isInstance(tracker)) {
return;
}
syncTracker(tracker);
}
@SubscribeEvent
public void onSyncBreedingTracker(ForestryEvent.SyncedBreedingTracker event) {
IBreedingTracker tracker = event.tracker;
if (!getTrackerClass().isInstance(tracker)) {
return;
}
syncTracker(tracker);
}
public void syncTracker(IBreedingTracker tracker) {
discoveredSpeciesPercentage = 0.0f;
totalSpeciesCount = 0;
discoveredSpeciesCount = 0;
totalSecretCount = 0;
discoveredSecretCount = 0;
Collection<IAlleleSpecies> allSpecies = getAllSpecies();
public void syncTracker(IBreedingTracker tracker) {
discoveredSpeciesPercentage = 0.0f;
totalSpeciesCount = 0;
discoveredSpeciesCount = 0;
totalSecretCount = 0;
discoveredSecretCount = 0;
Collection<IAlleleSpecies> allSpecies = getAllSpecies();
for (IAlleleSpecies species : allSpecies) {
if (!isSecret(species)) {
totalSpeciesCount++;
if (!isSpeciesDiscovered(species, tracker)) {
continue;
}
discoveredSpeciesCount++;
} else {
totalSecretCount++;
if (!isSpeciesDiscovered(species, tracker)) {
continue;
}
discoveredSecretCount++;
}
}
for (IAlleleSpecies species : allSpecies) {
if (!isSecret(species)) {
totalSpeciesCount++;
if (!isSpeciesDiscovered(species, tracker)) {
continue;
}
discoveredSpeciesCount++;
} else {
totalSecretCount++;
if (!isSpeciesDiscovered(species, tracker)) {
continue;
}
discoveredSecretCount++;
}
}
discoveredBranchPercentage = 0.0f;
totalBranchCount = 0;
discoveredBranchCount = 0;
Collection<IClassification> discoveredBranches = getDiscoveredBranches(tracker);
Collection<IClassification> allBranches = getAllBranches();
discoveredBranchPercentage = 0.0f;
totalBranchCount = 0;
discoveredBranchCount = 0;
Collection<IClassification> discoveredBranches = getDiscoveredBranches(tracker);
Collection<IClassification> allBranches = getAllBranches();
for (IClassification branch : allBranches) {
if (!isSecret(branch)) {
totalBranchCount++;
if (!discoveredBranches.contains(branch)) {
continue;
}
discoveredBranchCount++;
}
}
for (IClassification branch : allBranches) {
if (!isSecret(branch)) {
totalBranchCount++;
if (!discoveredBranches.contains(branch)) {
continue;
}
discoveredBranchCount++;
}
}
discoveredSpeciesPercentage = discoveredSpeciesCount / totalSpeciesCount;
discoveredBranchPercentage = discoveredBranchCount / totalBranchCount;
onSyncBreedingTracker(tracker);
}
discoveredSpeciesPercentage = discoveredSpeciesCount / totalSpeciesCount;
discoveredBranchPercentage = discoveredBranchCount / totalBranchCount;
onSyncBreedingTracker(tracker);
}
public void onSyncBreedingTracker(IBreedingTracker tracker) {
// ignored
}
public void onSyncBreedingTracker(IBreedingTracker tracker) {
// ignored
}
public String getEpitome() {
return getEpitome(discoveredSpeciesPercentage);
}
public String getEpitome() {
return getEpitome(discoveredSpeciesPercentage);
}
public String getDescriptor() {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".descriptor");
}
public String getDescriptor() {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".descriptor");
}
public String getIdent() {
return getSpeciesRoot().getUID();
}
public String getIdent() {
return getSpeciesRoot().getUID();
}
public IChromosomeType getChromosome(int i) {
for (IChromosomeType chromosome : getSpeciesRoot().getKaryotype()) {
if (i == chromosome.ordinal()) {
return chromosome;
}
}
return null;
}
public IChromosomeType getChromosome(int i) {
for (IChromosomeType chromosome : getSpeciesRoot().getKaryotype()) {
if (i == chromosome.ordinal()) {
return chromosome;
}
}
return null;
}
public abstract int getColor();
public abstract int getColor();
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (allele instanceof IAlleleBoolean) {
return ((IAlleleBoolean) allele).getValue() ?
I18N.localise("binniecore.allele.true") :
I18N.localise("binniecore.allele.false");
}
if (allele.getName().equals("for.gui.maximum")) {
return I18N.localise("binniecore.allele.fertility.maximum");
}
return allele.getName();
}
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (allele instanceof IAlleleBoolean) {
return ((IAlleleBoolean) allele).getValue()
? I18N.localise("binniecore.allele.true")
: I18N.localise("binniecore.allele.false");
}
if (allele.getName().equals("for.gui.maximum")) {
return I18N.localise("binniecore.allele.fertility.maximum");
}
return allele.getName();
}
public String getName() {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".shortName");
}
public String getName() {
return I18N.localise("binniecore." + getSpeciesRoot().getUID() + ".shortName");
}
@Override
public ItemStack getItemStackRepresentative() {
ISpeciesRoot speciesRoot = getSpeciesRoot();
IIndividual first = speciesRoot.getIndividualTemplates().get(0);
return speciesRoot.getMemberStack(first, getDefaultType());
}
@Override
public ItemStack getItemStackRepresentative() {
ISpeciesRoot speciesRoot = getSpeciesRoot();
IIndividual first = speciesRoot.getIndividualTemplates().get(0);
return speciesRoot.getMemberStack(first, getDefaultType());
}
@Override
public String toString() {
return getName();
}
@Override
public String toString() {
return getName();
}
public abstract boolean isDNAManipulable(ItemStack member);
public abstract boolean isDNAManipulable(ItemStack member);
public IIndividual getConversion(ItemStack stack) {
return null;
}
public IIndividual getConversion(ItemStack stack) {
return null;
}
public IIndividual getDefaultIndividual() {
return getSpeciesRoot().templateAsIndividual(getSpeciesRoot().getDefaultTemplate());
}
public IIndividual getDefaultIndividual() {
return getSpeciesRoot().templateAsIndividual(getSpeciesRoot().getDefaultTemplate());
}
public int getDefaultType() {
return getActiveTypes()[0];
}
public int getDefaultType() {
return getActiveTypes()[0];
}
public abstract int[] getActiveTypes();
public abstract int[] getActiveTypes();
public abstract void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles);
public abstract void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles);
public ItemStack getConversionStack(ItemStack stack) {
return getSpeciesRoot().getMemberStack(getConversion(stack), getDefaultType());
}
public ItemStack getConversionStack(ItemStack stack) {
return getSpeciesRoot().getMemberStack(getConversion(stack), getDefaultType());
}
public Collection<IChromosomeType> getActiveKaryotype() {
return Binnie.Genetics.getActiveChromosomes(getSpeciesRoot());
}
public Collection<IChromosomeType> getActiveKaryotype() {
return Binnie.Genetics.getActiveChromosomes(getSpeciesRoot());
}
public ItemStack getDefaultMember(String uid) {
return getSpeciesRoot().getMemberStack(getIndividual(uid), getDefaultType());
}
public ItemStack getDefaultMember(String uid) {
return getSpeciesRoot().getMemberStack(getIndividual(uid), getDefaultType());
}
public IIndividual getIndividual(String uid) {
return getSpeciesRoot().templateAsIndividual(getSpeciesRoot().getTemplate(uid));
}
public IIndividual getIndividual(String uid) {
return getSpeciesRoot().templateAsIndividual(getSpeciesRoot().getTemplate(uid));
}
public IGenome getGenome(String uid) {
return getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(uid));
}
public IGenome getGenome(String uid) {
return getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(uid));
}
}
@@ -1,8 +1,8 @@
package binnie.core.genetics;
public enum EnumBeeBooleanModifier {
SEALED,
SELF_LIGHTED,
SUNLIGHT_STIMULATED,
HELLISH
SEALED,
SELF_LIGHTED,
SUNLIGHT_STIMULATED,
HELLISH
}
@@ -3,14 +3,14 @@ package binnie.core.genetics;
import binnie.core.util.I18N;
public enum EnumBeeModifier {
TERRITORY,
MUTATION,
LIFESPAN,
PRODUCTION,
FLOWERING,
GENETIC_DECAY;
TERRITORY,
MUTATION,
LIFESPAN,
PRODUCTION,
FLOWERING,
GENETIC_DECAY;
public String getName() {
return I18N.localise("binniecore.beemodifier." + name().toLowerCase());
}
public String getName() {
return I18N.localise("binniecore.beemodifier." + name().toLowerCase());
}
}
@@ -19,117 +19,114 @@ import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.alleles.EnumAllele;
import java.util.TreeSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.TreeSet;
class FlowerBreedingSystem extends BreedingSystem {
public FlowerBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee");
}
public FlowerBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/undiscoveredBee");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraBees.instance, "icon/discoveredBee");
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
return mutation.getBaseChance();
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
return mutation.getBaseChance();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getFlowerRoot();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getFlowerRoot();
}
@Override
public int getColor() {
return 0xde3737;
}
@Override
public int getColor() {
return 0xde3737;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return IBotanistTracker.class;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return IBotanistTracker.class;
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumFlowerChromosome.FERTILITY) {
if (allele.getUID().contains("Low")) {
return I18N.localise("binniecore.allele.fertility.low");
}
if (allele.getUID().contains("Normal")) {
return I18N.localise("binniecore.allele.fertility.normal");
}
if (allele.getUID().contains("High")) {
return I18N.localise("binniecore.allele.fertility.high");
}
if (allele.getUID().contains("Maximum")) {
return I18N.localise("binniecore.allele.fertility.maximum");
}
}
return super.getAlleleName(chromosome, allele);
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumFlowerChromosome.FERTILITY) {
if (allele.getUID().contains("Low")) {
return I18N.localise("binniecore.allele.fertility.low");
}
if (allele.getUID().contains("Normal")) {
return I18N.localise("binniecore.allele.fertility.normal");
}
if (allele.getUID().contains("High")) {
return I18N.localise("binniecore.allele.fertility.high");
}
if (allele.getUID().contains("Maximum")) {
return I18N.localise("binniecore.allele.fertility.maximum");
}
}
return super.getAlleleName(chromosome, allele);
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((IFlowerRoot) getSpeciesRoot()).getStageType(member) == EnumFlowerStage.POLLEN;
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((IFlowerRoot) getSpeciesRoot()).getStageType(member) == EnumFlowerStage.POLLEN;
}
@Override
public IIndividual getConversion(ItemStack stack) {
return BotanyCore.getFlowerRoot().getConversion(stack);
}
@Override
public IIndividual getConversion(ItemStack stack) {
return BotanyCore.getFlowerRoot().getConversion(stack);
}
@Override
public int[] getActiveTypes() {
return new int[]{
EnumFlowerStage.FLOWER.ordinal(),
EnumFlowerStage.POLLEN.ordinal(),
EnumFlowerStage.SEED.ordinal()
};
}
@Override
public int[] getActiveTypes() {
return new int[] {
EnumFlowerStage.FLOWER.ordinal(), EnumFlowerStage.POLLEN.ordinal(), EnumFlowerStage.SEED.ordinal()
};
}
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumFlowerChromosome) chromosome) {
case FERTILITY:
for (EnumAllele.Fertility fertility : EnumAllele.Fertility.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(fertility)));
}
break;
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumFlowerChromosome) chromosome) {
case FERTILITY:
for (EnumAllele.Fertility fertility : EnumAllele.Fertility.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(fertility)));
}
break;
case LIFESPAN:
for (EnumAllele.Lifespan lifespan : EnumAllele.Lifespan.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(lifespan)));
}
break;
case LIFESPAN:
for (EnumAllele.Lifespan lifespan : EnumAllele.Lifespan.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(lifespan)));
}
break;
case HUMIDITY_TOLERANCE:
case PH_TOLERANCE:
case TEMPERATURE_TOLERANCE:
for (EnumTolerance a3 : EnumTolerance.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(a3)));
}
break;
case HUMIDITY_TOLERANCE:
case PH_TOLERANCE:
case TEMPERATURE_TOLERANCE:
for (EnumTolerance a3 : EnumTolerance.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(a3)));
}
break;
case PRIMARY:
case SECONDARY:
case STEM:
for (EnumFlowerColor color : EnumFlowerColor.values()) {
alleles.add(color.getAllele());
}
break;
case PRIMARY:
case SECONDARY:
case STEM:
for (EnumFlowerColor color : EnumFlowerColor.values()) {
alleles.add(color.getAllele());
}
break;
case SAPPINESS:
for (EnumAllele.Sappiness sappiness : EnumAllele.Sappiness.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(sappiness)));
}
break;
case SAPPINESS:
for (EnumAllele.Sappiness sappiness : EnumAllele.Sappiness.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(sappiness)));
}
break;
case TERRITORY:
for (EnumAllele.Territory territory : EnumAllele.Territory.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(territory)));
}
break;
}
}
case TERRITORY:
for (EnumAllele.Territory territory : EnumAllele.Territory.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(territory)));
}
break;
}
}
}
@@ -4,99 +4,99 @@ import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
public class ForestryAllele {
public enum Lifespan {
Shortest,
Shorter,
Short,
Shortened,
Normal,
Elongated,
Long,
Longer,
Longest;
public enum Lifespan {
Shortest,
Shorter,
Short,
Shortened,
Normal,
Elongated,
Long,
Longer,
Longest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.lifespan" + toString());
}
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.lifespan" + toString());
}
}
public enum Speed {
Slowest,
Slower,
Slow,
Norm,
Fast,
Faster,
Fastest;
public enum Speed {
Slowest,
Slower,
Slow,
Norm,
Fast,
Faster,
Fastest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.speed" + toString());
}
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.speed" + toString());
}
}
public enum Fertility {
Low,
Normal,
High,
Maximum;
public enum Fertility {
Low,
Normal,
High,
Maximum;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.fertility" + toString());
}
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.fertility" + toString());
}
}
public enum Territory {
Default,
Large,
Larger,
Largest;
public enum Territory {
Default,
Large,
Larger,
Largest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.territory" + toString());
}
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.territory" + toString());
}
}
public enum Size {
Smallest,
Smaller,
Small,
Average,
Large,
Larger,
Largest;
public enum Size {
Smallest,
Smaller,
Small,
Average,
Large,
Larger,
Largest;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.size" + toString());
}
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.size" + toString());
}
}
public enum Bool {
True,
False;
public enum Bool {
True,
False;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.bool" + toString());
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.bool" + toString());
}
public static IAllele get(boolean bool) {
return (bool ? Bool.True : Bool.False).getAllele();
}
}
public static IAllele get(boolean bool) {
return (bool ? Bool.True : Bool.False).getAllele();
}
}
public enum Int {
Int1,
Int2,
Int3,
Int4,
Int5,
Int6,
Int7,
Int8,
Int9,
Int10;
public enum Int {
Int1,
Int2,
Int3,
Int4,
Int5,
Int6,
Int7,
Int8,
Int9,
Int10;
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.i" + (ordinal() + 1) + "d");
}
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele("forestry.i" + (ordinal() + 1) + "d");
}
}
}
+80 -80
View File
@@ -10,102 +10,102 @@ import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.nbt.NBTTagCompound;
public class Gene implements INBTTagable, IGene {
private IAllele allele;
private IChromosomeType chromosome;
private ISpeciesRoot root;
private IAllele allele;
private IChromosomeType chromosome;
private ISpeciesRoot root;
@Override
public ISpeciesRoot getSpeciesRoot() {
return root;
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return root;
}
@Override
public String toString() {
return getAlleleName();
}
@Override
public String toString() {
return getAlleleName();
}
public Gene(IAllele allele, IChromosomeType chromosome, ISpeciesRoot root) {
this.allele = allele;
this.chromosome = chromosome;
this.root = root;
}
public Gene(IAllele allele, IChromosomeType chromosome, ISpeciesRoot root) {
this.allele = allele;
this.chromosome = chromosome;
this.root = root;
}
public Gene(NBTTagCompound nbt) {
readFromNBT(nbt);
}
public Gene(NBTTagCompound nbt) {
readFromNBT(nbt);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
allele = AlleleManager.alleleRegistry.getAllele(nbt.getString("allele"));
root = AlleleManager.alleleRegistry.getSpeciesRoot(nbt.getString("root"));
int chromoID = nbt.getByte("chromo");
if (root != null && chromoID >= 0 && chromoID < root.getKaryotype().length) {
chromosome = root.getKaryotype()[chromoID];
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
allele = AlleleManager.alleleRegistry.getAllele(nbt.getString("allele"));
root = AlleleManager.alleleRegistry.getSpeciesRoot(nbt.getString("root"));
int chromoID = nbt.getByte("chromo");
if (root != null && chromoID >= 0 && chromoID < root.getKaryotype().length) {
chromosome = root.getKaryotype()[chromoID];
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
nbt.setString("allele", allele.getUID());
nbt.setString("root", root.getUID());
nbt.setByte("chromo", (byte) chromosome.ordinal());
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
nbt.setString("allele", allele.getUID());
nbt.setString("root", root.getUID());
nbt.setByte("chromo", (byte) chromosome.ordinal());
}
public boolean isCorrupted() {
return allele == null || chromosome == null || root == null;
}
public boolean isCorrupted() {
return allele == null || chromosome == null || root == null;
}
public static Gene create(NBTTagCompound nbt) {
Gene gene = new Gene(nbt);
return gene.isCorrupted() ? null : gene;
}
public static Gene create(NBTTagCompound nbt) {
Gene gene = new Gene(nbt);
return gene.isCorrupted() ? null : gene;
}
public static Gene create(IAllele allele, IChromosomeType chromosome, ISpeciesRoot root) {
Gene gene = new Gene(allele, chromosome, root);
return gene.isCorrupted() ? null : gene;
}
public static Gene create(IAllele allele, IChromosomeType chromosome, ISpeciesRoot root) {
Gene gene = new Gene(allele, chromosome, root);
return gene.isCorrupted() ? null : gene;
}
@Override
public NBTTagCompound getNBTTagCompound() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return nbt;
}
@Override
public NBTTagCompound getNBTTagCompound() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return nbt;
}
@Override
public String getName() {
return Binnie.Genetics.getSystem(root).getAlleleName(chromosome, allele);
}
@Override
public String getName() {
return Binnie.Genetics.getSystem(root).getAlleleName(chromosome, allele);
}
public BreedingSystem getSystem() {
return Binnie.Genetics.getSystem(root);
}
public BreedingSystem getSystem() {
return Binnie.Genetics.getSystem(root);
}
@Override
public IChromosomeType getChromosome() {
return chromosome;
}
@Override
public IChromosomeType getChromosome() {
return chromosome;
}
@Override
public IAllele getAllele() {
return allele;
}
@Override
public IAllele getAllele() {
return allele;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Gene)) {
return false;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Gene)) {
return false;
}
Gene g = (Gene) obj;
return allele == g.allele && chromosome.ordinal() == g.chromosome.ordinal() && root == g.root;
}
Gene g = (Gene) obj;
return allele == g.allele && chromosome.ordinal() == g.chromosome.ordinal() && root == g.root;
}
public String getAlleleName() {
return getSystem().getAlleleName(chromosome, allele);
}
public String getAlleleName() {
return getSystem().getAlleleName(chromosome, allele);
}
public String getShortChromosomeName() {
return getSystem().getChromosomeShortName(chromosome);
}
public String getShortChromosomeName() {
return getSystem().getChromosomeShortName(chromosome);
}
}
@@ -3,5 +3,5 @@ package binnie.core.genetics;
import net.minecraft.item.ItemStack;
public interface IItemStackRepresentative {
ItemStack getItemStackRepresentative();
ItemStack getItemStackRepresentative();
}
@@ -19,9 +19,6 @@ import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.lepidopterology.IButterflyRoot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.world.WorldEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
@@ -29,193 +26,195 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.world.WorldEvent;
public class ManagerGenetics extends ManagerBase {
public BreedingSystem beeBreedingSystem;
public BreedingSystem treeBreedingSystem;
public BreedingSystem mothBreedingSystem;
public BreedingSystem flowerBreedingSystem;
private Map<ISpeciesRoot, BreedingSystem> breedingSystems;
private List<IChromosomeType> invalidChromosomeTypes;
private Map<ISpeciesRoot, Map<IChromosomeType, List<IAllele>>> chromosomeArray;
public BreedingSystem beeBreedingSystem;
public BreedingSystem treeBreedingSystem;
public BreedingSystem mothBreedingSystem;
public BreedingSystem flowerBreedingSystem;
private Map<ISpeciesRoot, BreedingSystem> breedingSystems;
private List<IChromosomeType> invalidChromosomeTypes;
private Map<ISpeciesRoot, Map<IChromosomeType, List<IAllele>>> chromosomeArray;
public ManagerGenetics() {
breedingSystems = new LinkedHashMap<>();
invalidChromosomeTypes = new ArrayList<>();
chromosomeArray = new LinkedHashMap<>();
}
public ManagerGenetics() {
breedingSystems = new LinkedHashMap<>();
invalidChromosomeTypes = new ArrayList<>();
chromosomeArray = new LinkedHashMap<>();
}
@Override
public void init() {
if (BinnieCore.isApicultureActive()) {
beeBreedingSystem = new BeeBreedingSystem();
}
if (BinnieCore.isArboricultureActive()) {
treeBreedingSystem = new TreeBreedingSystem();
}
if (BinnieCore.isLepidopteryActive()) {
mothBreedingSystem = new MothBreedingSystem();
}
if (BinnieCore.isBotanyActive()) {
flowerBreedingSystem = new FlowerBreedingSystem();
}
}
@Override
public void init() {
if (BinnieCore.isApicultureActive()) {
beeBreedingSystem = new BeeBreedingSystem();
}
if (BinnieCore.isArboricultureActive()) {
treeBreedingSystem = new TreeBreedingSystem();
}
if (BinnieCore.isLepidopteryActive()) {
mothBreedingSystem = new MothBreedingSystem();
}
if (BinnieCore.isBotanyActive()) {
flowerBreedingSystem = new FlowerBreedingSystem();
}
}
@Override
public void postInit() {
refreshData();
}
@Override
public void postInit() {
refreshData();
}
public ITreeRoot getTreeRoot() {
return (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees");
}
public ITreeRoot getTreeRoot() {
return (ITreeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees");
}
public IBeeRoot getBeeRoot() {
return (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
}
public IBeeRoot getBeeRoot() {
return (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
}
public IButterflyRoot getButterflyRoot() {
return (IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies");
}
public IButterflyRoot getButterflyRoot() {
return (IButterflyRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies");
}
public IFlowerRoot getFlowerRoot() {
return (IFlowerRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
}
public IFlowerRoot getFlowerRoot() {
return (IFlowerRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers");
}
public BreedingSystem getSystem(String string) {
for (BreedingSystem system : breedingSystems.values()) {
if (system.getIdent().equals(string)) {
return system;
}
}
return null;
}
public BreedingSystem getSystem(String string) {
for (BreedingSystem system : breedingSystems.values()) {
if (system.getIdent().equals(string)) {
return system;
}
}
return null;
}
public BreedingSystem getSystem(ISpeciesRoot root) {
// Fix NPE
if (root == null) {
return null;
}
return getSystem(root.getUID());
}
public BreedingSystem getSystem(ISpeciesRoot root) {
// Fix NPE
if (root == null) {
return null;
}
return getSystem(root.getUID());
}
public ISpeciesRoot getSpeciesRoot(IAlleleSpecies species) {
for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
if (root.getKaryotype()[0].getAlleleClass().isInstance(species)) {
return root;
}
}
return null;
}
public ISpeciesRoot getSpeciesRoot(IAlleleSpecies species) {
for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
if (root.getKaryotype()[0].getAlleleClass().isInstance(species)) {
return root;
}
}
return null;
}
public int[] getTolerance(EnumTolerance tol) {
return Tolerance.values()[tol.ordinal()].getBounds();
}
public int[] getTolerance(EnumTolerance tol) {
return Tolerance.values()[tol.ordinal()].getBounds();
}
public Collection<BreedingSystem> getActiveSystems() {
return breedingSystems.values();
}
public Collection<BreedingSystem> getActiveSystems() {
return breedingSystems.values();
}
public void registerBreedingSystem(BreedingSystem system) {
breedingSystems.put(system.getSpeciesRoot(), system);
}
public void registerBreedingSystem(BreedingSystem system) {
breedingSystems.put(system.getSpeciesRoot(), system);
}
public BreedingSystem getConversionSystem(ItemStack stack) {
for (BreedingSystem system : getActiveSystems()) {
if (system.getConversion(stack) != null) {
return system;
}
}
return null;
}
public BreedingSystem getConversionSystem(ItemStack stack) {
for (BreedingSystem system : getActiveSystems()) {
if (system.getConversion(stack) != null) {
return system;
}
}
return null;
}
public ItemStack getConversionStack(ItemStack stack) {
BreedingSystem system = getConversionSystem(stack);
return (system == null) ? null : system.getConversionStack(stack);
}
public ItemStack getConversionStack(ItemStack stack) {
BreedingSystem system = getConversionSystem(stack);
return (system == null) ? null : system.getConversionStack(stack);
}
public IIndividual getConversion(ItemStack stack) {
BreedingSystem system = getConversionSystem(stack);
return (system == null) ? null : system.getConversion(stack);
}
public IIndividual getConversion(ItemStack stack) {
BreedingSystem system = getConversionSystem(stack);
return (system == null) ? null : system.getConversion(stack);
}
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
refreshData();
}
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
refreshData();
}
private void refreshData() {
loadAlleles();
for (BreedingSystem system : Binnie.Genetics.getActiveSystems()) {
system.calculateArrays();
}
}
private void refreshData() {
loadAlleles();
for (BreedingSystem system : Binnie.Genetics.getActiveSystems()) {
system.calculateArrays();
}
}
private void loadAlleles() {
invalidChromosomeTypes.clear();
for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
BreedingSystem system = getSystem(root);
Map<IChromosomeType, List<IAllele>> chromosomeMap = new LinkedHashMap<>();
for (IChromosomeType chromosome : root.getKaryotype()) {
TreeSet<IAllele> alleles = new TreeSet<>(new ComparatorAllele());
for (IIndividual individual : root.getIndividualTemplates()) {
IGenome genome = individual.getGenome();
try {
IAllele a1 = genome.getActiveAllele(chromosome);
IAllele a2 = genome.getInactiveAllele(chromosome);
if (chromosome.getAlleleClass().isInstance(a1)) {
alleles.add(a1);
}
if (!chromosome.getAlleleClass().isInstance(a2)) {
continue;
}
alleles.add(a2);
} catch (Exception ex) {
// ignored
}
}
private void loadAlleles() {
invalidChromosomeTypes.clear();
for (ISpeciesRoot root : AlleleManager.alleleRegistry.getSpeciesRoot().values()) {
BreedingSystem system = getSystem(root);
Map<IChromosomeType, List<IAllele>> chromosomeMap = new LinkedHashMap<>();
for (IChromosomeType chromosome : root.getKaryotype()) {
TreeSet<IAllele> alleles = new TreeSet<>(new ComparatorAllele());
for (IIndividual individual : root.getIndividualTemplates()) {
IGenome genome = individual.getGenome();
try {
IAllele a1 = genome.getActiveAllele(chromosome);
IAllele a2 = genome.getInactiveAllele(chromosome);
if (chromosome.getAlleleClass().isInstance(a1)) {
alleles.add(a1);
}
if (!chromosome.getAlleleClass().isInstance(a2)) {
continue;
}
alleles.add(a2);
} catch (Exception ex) {
// ignored
}
}
system.addExtraAlleles(chromosome, alleles);
if (alleles.size() == 0) {
invalidChromosomeTypes.add(chromosome);
} else {
List<IAllele> alleleList = new ArrayList<>();
alleleList.addAll(alleles);
chromosomeMap.put(chromosome, alleleList);
}
}
chromosomeArray.put(root, chromosomeMap);
}
}
system.addExtraAlleles(chromosome, alleles);
if (alleles.size() == 0) {
invalidChromosomeTypes.add(chromosome);
} else {
List<IAllele> alleleList = new ArrayList<>();
alleleList.addAll(alleles);
chromosomeMap.put(chromosome, alleleList);
}
}
chromosomeArray.put(root, chromosomeMap);
}
}
public Map<IChromosomeType, List<IAllele>> getChromosomeMap(ISpeciesRoot root) {
return chromosomeArray.get(root);
}
public Map<IChromosomeType, List<IAllele>> getChromosomeMap(ISpeciesRoot root) {
return chromosomeArray.get(root);
}
public Collection<IChromosomeType> getActiveChromosomes(ISpeciesRoot root) {
return getChromosomeMap(root).keySet();
}
public Collection<IChromosomeType> getActiveChromosomes(ISpeciesRoot root) {
return getChromosomeMap(root).keySet();
}
public boolean isInvalidChromosome(IChromosomeType type) {
return invalidChromosomeTypes.contains(type);
}
public boolean isInvalidChromosome(IChromosomeType type) {
return invalidChromosomeTypes.contains(type);
}
static class ComparatorAllele implements Comparator<IAllele> {
@Override
public int compare(IAllele o1, IAllele o2) {
if (o1 == null || o2 == null) {
throw new NullPointerException("Allele is null!");
}
if (o1 instanceof IAlleleFloat && o2 instanceof IAlleleFloat) {
return Float.valueOf(((IAlleleFloat) o1).getValue()).compareTo(((IAlleleFloat) o2).getValue());
}
if (o1 instanceof IAlleleInteger && o2 instanceof IAlleleInteger && !(o1 instanceof AlleleColor)) {
return Integer.valueOf(((IAlleleInteger) o1).getValue()).compareTo(((IAlleleInteger) o2).getValue());
}
if (o1.getName() != null && o2.getName() != null) {
return o1.getName().compareTo(o2.getName());
}
return o1.getUID().compareTo(o2.getUID());
}
}
static class ComparatorAllele implements Comparator<IAllele> {
@Override
public int compare(IAllele o1, IAllele o2) {
if (o1 == null || o2 == null) {
throw new NullPointerException("Allele is null!");
}
if (o1 instanceof IAlleleFloat && o2 instanceof IAlleleFloat) {
return Float.valueOf(((IAlleleFloat) o1).getValue()).compareTo(((IAlleleFloat) o2).getValue());
}
if (o1 instanceof IAlleleInteger && o2 instanceof IAlleleInteger && !(o1 instanceof AlleleColor)) {
return Integer.valueOf(((IAlleleInteger) o1).getValue()).compareTo(((IAlleleInteger) o2).getValue());
}
if (o1.getName() != null && o2.getName() != null) {
return o1.getName().compareTo(o2.getName());
}
return o1.getUID().compareTo(o2.getUID());
}
}
}
@@ -13,128 +13,125 @@ import forestry.api.lepidopterology.EnumButterflyChromosome;
import forestry.api.lepidopterology.EnumFlutterType;
import forestry.api.lepidopterology.IButterflyRoot;
import forestry.api.lepidopterology.ILepidopteristTracker;
import java.util.TreeSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.TreeSet;
class MothBreedingSystem extends BreedingSystem {
public MothBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/undiscoveredMoth");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/discoveredMoth");
}
public MothBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/undiscoveredMoth");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/discoveredMoth");
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
return 0.0f;
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
return 0.0f;
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getButterflyRoot();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getButterflyRoot();
}
@Override
public int getColor() {
return 0x00f2f2;
}
@Override
public int getColor() {
return 0x00f2f2;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return ILepidopteristTracker.class;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return ILepidopteristTracker.class;
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumButterflyChromosome.METABOLISM) {
int metabolism = ((IAlleleInteger) allele).getValue();
if (metabolism >= 19) {
return I18N.localise("binniecore.allele.metabolism.highest");
}
if (metabolism >= 16) {
return I18N.localise("binniecore.allele.metabolism.higher");
}
if (metabolism >= 13) {
return I18N.localise("binniecore.allele.metabolism.high");
}
if (metabolism >= 10) {
return I18N.localise("binniecore.allele.metabolism.average");
}
if (metabolism >= 7) {
return I18N.localise("binniecore.allele.metabolism.slow");
}
if (metabolism >= 4) {
return I18N.localise("binniecore.allele.metabolism.slower");
}
return I18N.localise("binniecore.allele.metabolism.slowest");
}
if (chromosome == EnumButterflyChromosome.FERTILITY) {
return ((IAlleleInteger) allele).getValue() + "x";
}
return super.getAlleleName(chromosome, allele);
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumButterflyChromosome.METABOLISM) {
int metabolism = ((IAlleleInteger) allele).getValue();
if (metabolism >= 19) {
return I18N.localise("binniecore.allele.metabolism.highest");
}
if (metabolism >= 16) {
return I18N.localise("binniecore.allele.metabolism.higher");
}
if (metabolism >= 13) {
return I18N.localise("binniecore.allele.metabolism.high");
}
if (metabolism >= 10) {
return I18N.localise("binniecore.allele.metabolism.average");
}
if (metabolism >= 7) {
return I18N.localise("binniecore.allele.metabolism.slow");
}
if (metabolism >= 4) {
return I18N.localise("binniecore.allele.metabolism.slower");
}
return I18N.localise("binniecore.allele.metabolism.slowest");
}
if (chromosome == EnumButterflyChromosome.FERTILITY) {
return ((IAlleleInteger) allele).getValue() + "x";
}
return super.getAlleleName(chromosome, allele);
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((IButterflyRoot) getSpeciesRoot()).getType(member) == EnumFlutterType.SERUM;
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((IButterflyRoot) getSpeciesRoot()).getType(member) == EnumFlutterType.SERUM;
}
@Override
public int[] getActiveTypes() {
return new int[]{
EnumFlutterType.BUTTERFLY.ordinal(),
EnumFlutterType.CATERPILLAR.ordinal(),
EnumFlutterType.SERUM.ordinal()
};
}
@Override
public int[] getActiveTypes() {
return new int[] {
EnumFlutterType.BUTTERFLY.ordinal(), EnumFlutterType.CATERPILLAR.ordinal(), EnumFlutterType.SERUM.ordinal()
};
}
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumButterflyChromosome) chromosome) {
case FERTILITY:
for (ForestryAllele.Int a : ForestryAllele.Int.values()) {
alleles.add(a.getAllele());
}
break;
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumButterflyChromosome) chromosome) {
case FERTILITY:
for (ForestryAllele.Int a : ForestryAllele.Int.values()) {
alleles.add(a.getAllele());
}
break;
case LIFESPAN:
for (ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) {
alleles.add(a2.getAllele());
}
break;
case LIFESPAN:
for (ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) {
alleles.add(a2.getAllele());
}
break;
case METABOLISM:
for (ForestryAllele.Int a : ForestryAllele.Int.values()) {
alleles.add(a.getAllele());
}
break;
case METABOLISM:
for (ForestryAllele.Int a : ForestryAllele.Int.values()) {
alleles.add(a.getAllele());
}
break;
case TOLERANT_FLYER:
case FIRE_RESIST:
case NOCTURNAL:
for (ForestryAllele.Bool a3 : ForestryAllele.Bool.values()) {
alleles.add(a3.getAllele());
}
break;
case TOLERANT_FLYER:
case FIRE_RESIST:
case NOCTURNAL:
for (ForestryAllele.Bool a3 : ForestryAllele.Bool.values()) {
alleles.add(a3.getAllele());
}
break;
case SIZE:
for (ForestryAllele.Size a4 : ForestryAllele.Size.values()) {
alleles.add(a4.getAllele());
}
break;
case SIZE:
for (ForestryAllele.Size a4 : ForestryAllele.Size.values()) {
alleles.add(a4.getAllele());
}
break;
case SPEED:
for (ForestryAllele.Speed a5 : ForestryAllele.Speed.values()) {
alleles.add(a5.getAllele());
}
break;
case SPEED:
for (ForestryAllele.Speed a5 : ForestryAllele.Speed.values()) {
alleles.add(a5.getAllele());
}
break;
case HUMIDITY_TOLERANCE:
case TEMPERATURE_TOLERANCE:
for (Tolerance a6 : Tolerance.values()) {
alleles.add(a6.getAllele());
}
break;
}
}
case HUMIDITY_TOLERANCE:
case TEMPERATURE_TOLERANCE:
for (Tolerance a6 : Tolerance.values()) {
alleles.add(a6.getAllele());
}
break;
}
}
}
@@ -5,51 +5,50 @@ import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
public enum Tolerance {
None(0, 0),
Both1(-1, 1),
Both2(-2, 2),
Both3(-3, 3),
Both4(-4, 4),
Both5(-5, 5),
Up1(0, 1),
Up2(0, 2),
Up3(0, 3),
Up4(0, 4),
Up5(0, 5),
Down1(-1, 0),
Down2(-2, 0),
Down3(-3, 0),
Down4(-4, 0),
Down5(-5, 0);
None(0, 0),
Both1(-1, 1),
Both2(-2, 2),
Both3(-3, 3),
Both4(-4, 4),
Both5(-5, 5),
Up1(0, 1),
Up2(0, 2),
Up3(0, 3),
Up4(0, 4),
Up5(0, 5),
Down1(-1, 0),
Down2(-2, 0),
Down3(-3, 0),
Down4(-4, 0),
Down5(-5, 0);
private int[] bounds;
private int[] bounds;
Tolerance(int a, int b) {
bounds = new int[]{a, b};
}
Tolerance(int a, int b) {
bounds = new int[] {a, b};
}
public String getUID() {
return "forestry.tolerance" + toString();
}
public String getUID() {
return "forestry.tolerance" + toString();
}
public int[] getBounds() {
return bounds;
}
public int[] getBounds() {
return bounds;
}
public static Tolerance get(EnumTolerance tol) {
return values()[tol.ordinal()];
}
public static Tolerance get(EnumTolerance tol) {
return values()[tol.ordinal()];
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele(getUID());
}
public IAllele getAllele() {
return AlleleManager.alleleRegistry.getAllele(getUID());
}
public <T extends Enum<T>> boolean canTolerate(T base, T test) {
return test.ordinal() <= base.ordinal() + bounds[1]
&& test.ordinal() >= base.ordinal() + bounds[0];
}
public <T extends Enum<T>> boolean canTolerate(T base, T test) {
return test.ordinal() <= base.ordinal() + bounds[1] && test.ordinal() >= base.ordinal() + bounds[0];
}
public static <T extends Enum<T>> boolean canTolerate(T base, T test, EnumTolerance tol) {
return get(tol).canTolerate(base, test);
}
public static <T extends Enum<T>> boolean canTolerate(T base, T test, EnumTolerance tol) {
return get(tol).canTolerate(base, test);
}
}
@@ -30,12 +30,6 @@ import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.alleles.EnumAllele;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -45,279 +39,298 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.util.ForgeDirection;
public class TreeBreedingSystem extends BreedingSystem {
public UniqueItemStackSet allFruits = new UniqueItemStackSet();
public UniqueItemStackSet allWoods = new UniqueItemStackSet();
private UniqueItemStackSet discoveredFruits = new UniqueItemStackSet();
private UniqueItemStackSet discoveredWoods = new UniqueItemStackSet();
public UniqueItemStackSet allFruits = new UniqueItemStackSet();
public UniqueItemStackSet allWoods = new UniqueItemStackSet();
private UniqueItemStackSet discoveredFruits = new UniqueItemStackSet();
private UniqueItemStackSet discoveredWoods = new UniqueItemStackSet();
public TreeBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/undiscoveredTree");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/discoveredTree");
}
public TreeBreedingSystem() {
iconUndiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/undiscoveredTree");
iconDiscovered = Binnie.Resource.getItemIcon(ExtraTrees.instance, "icon/discoveredTree");
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
ISpeciesRoot speciesRoot = getSpeciesRoot();
ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species1.getUID()));
ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species2.getUID()));
return ((ITreeMutation) mutation).getChance(player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ, (IAlleleTreeSpecies) species1, (IAlleleTreeSpecies) species2, genome0, genome2);
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAllele species1, IAllele species2) {
ISpeciesRoot speciesRoot = getSpeciesRoot();
ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species1.getUID()));
ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species2.getUID()));
return ((ITreeMutation) mutation)
.getChance(
player.worldObj,
(int) player.posX,
(int) player.posY,
(int) player.posZ,
(IAlleleTreeSpecies) species1,
(IAlleleTreeSpecies) species2,
genome0,
genome2);
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getTreeRoot();
}
@Override
public ISpeciesRoot getSpeciesRoot() {
return Binnie.Genetics.getTreeRoot();
}
@Override
public int getColor() {
return 0x00cf0e;
}
@Override
public int getColor() {
return 0x00cf0e;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return IArboristTracker.class;
}
@Override
public Class<? extends IBreedingTracker> getTrackerClass() {
return IArboristTracker.class;
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumTreeChromosome.GIRTH) {
return ((IAlleleInteger) allele).getValue() + "x" + ((IAlleleInteger) allele).getValue();
}
@Override
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
if (chromosome == EnumTreeChromosome.GIRTH) {
return ((IAlleleInteger) allele).getValue() + "x" + ((IAlleleInteger) allele).getValue();
}
if (chromosome == EnumTreeChromosome.PLANT) {
EnumSet<EnumPlantType> types = ((IAllelePlantType) allele).getPlantTypes();
return types.isEmpty()
? I18N.localise("binniecore.allele.none")
: types.iterator().next().toString();
}
if (chromosome == EnumTreeChromosome.PLANT) {
EnumSet<EnumPlantType> types = ((IAllelePlantType) allele).getPlantTypes();
return types.isEmpty()
? I18N.localise("binniecore.allele.none")
: types.iterator().next().toString();
}
if (chromosome == EnumTreeChromosome.FRUITS && allele.getUID().contains(".")) {
IFruitProvider provider = ((IAlleleFruit) allele).getProvider();
return (provider.getProducts().length == 0)
? I18N.localise("binniecore.allele.none")
: provider.getProducts()[0].getDisplayName();
}
if (chromosome == EnumTreeChromosome.FRUITS && allele.getUID().contains(".")) {
IFruitProvider provider = ((IAlleleFruit) allele).getProvider();
return (provider.getProducts().length == 0)
? I18N.localise("binniecore.allele.none")
: provider.getProducts()[0].getDisplayName();
}
if (chromosome == EnumTreeChromosome.GROWTH) {
if (allele.getUID().contains("Tropical")) {
return I18N.localise("binniecore.allele.growth.tropical");
}
if (allele.getUID().contains("Lightlevel")) {
return I18N.localise("binniecore.allele.growth.lightlevel");
}
}
return super.getAlleleName(chromosome, allele);
}
if (chromosome == EnumTreeChromosome.GROWTH) {
if (allele.getUID().contains("Tropical")) {
return I18N.localise("binniecore.allele.growth.tropical");
}
if (allele.getUID().contains("Lightlevel")) {
return I18N.localise("binniecore.allele.growth.lightlevel");
}
}
return super.getAlleleName(chromosome, allele);
}
@Override
public void onSyncBreedingTracker(IBreedingTracker tracker) {
discoveredFruits.clear();
discoveredWoods.clear();
for (IAlleleSpecies species : getDiscoveredSpecies(tracker)) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ISpeciesRoot speciesRoot = getSpeciesRoot();
ITreeGenome genome = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(tSpecies.getUID()));
@Override
public void onSyncBreedingTracker(IBreedingTracker tracker) {
discoveredFruits.clear();
discoveredWoods.clear();
for (IAlleleSpecies species : getDiscoveredSpecies(tracker)) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ISpeciesRoot speciesRoot = getSpeciesRoot();
ITreeGenome genome = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(tSpecies.getUID()));
FakeWorld world = FakeWorld.instance;
genome.getPrimary().getGenerator().setLogBlock(genome, world, 0, 0, 0, ForgeDirection.UP);
ItemStack wood = world.getWooLog();
if (wood != null) {
discoveredWoods.add(wood);
}
FakeWorld world = FakeWorld.instance;
genome.getPrimary().getGenerator().setLogBlock(genome, world, 0, 0, 0, ForgeDirection.UP);
ItemStack wood = world.getWooLog();
if (wood != null) {
discoveredWoods.add(wood);
}
// TODO ???
// for (ItemStack wood :
// tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList())
// {
// this.discoveredWoods.add(wood);
// }
discoveredFruits.addAll(Arrays.asList(genome.getFruitProvider().getProducts()));
for (ItemStack wood2 : discoveredWoods) {
}
}
}
// TODO ???
// for (ItemStack wood :
// tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList())
// {
// this.discoveredWoods.add(wood);
// }
discoveredFruits.addAll(Arrays.asList(genome.getFruitProvider().getProducts()));
for (ItemStack wood2 : discoveredWoods) {}
}
}
@Override
public void calculateArrays() {
super.calculateArrays();
for (IAlleleSpecies species : allActiveSpecies) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = (ITreeGenome) getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(tSpecies.getUID()));
@Override
public void calculateArrays() {
super.calculateArrays();
for (IAlleleSpecies species : allActiveSpecies) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = (ITreeGenome)
getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(tSpecies.getUID()));
FakeWorld world = FakeWorld.instance;
genome.getPrimary().getGenerator().setLogBlock(genome, world, 0, 0, 0, ForgeDirection.UP);
ItemStack wood = world.getWooLog();
if (wood != null) {
allWoods.add(wood);
}
FakeWorld world = FakeWorld.instance;
genome.getPrimary().getGenerator().setLogBlock(genome, world, 0, 0, 0, ForgeDirection.UP);
ItemStack wood = world.getWooLog();
if (wood != null) {
allWoods.add(wood);
}
// TODO ???
// for (ItemStack wood :
// tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList())
// {
// this.allWoods.add(wood);
// }
allFruits.addAll(Arrays.asList(genome.getFruitProvider().getProducts()));
}
}
// TODO ???
// for (ItemStack wood :
// tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList())
// {
// this.allWoods.add(wood);
// }
allFruits.addAll(Arrays.asList(genome.getFruitProvider().getProducts()));
}
}
public Collection<IAlleleSpecies> getTreesThatBearFruit(ItemStack fruit, boolean nei, World world, GameProfile player) {
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = (ITreeGenome) getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(tSpecies.getUID()));
for (ItemStack fruit2 : genome.getFruitProvider().getProducts()) {
if (fruit2.isItemEqual(fruit)) {
found.add(species);
}
}
}
return found;
}
public Collection<IAlleleSpecies> getTreesThatBearFruit(
ItemStack fruit, boolean nei, World world, GameProfile player) {
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = (ITreeGenome)
getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(tSpecies.getUID()));
for (ItemStack fruit2 : genome.getFruitProvider().getProducts()) {
if (fruit2.isItemEqual(fruit)) {
found.add(species);
}
}
}
return found;
}
public Collection<IAlleleSpecies> getTreesThatCanBearFruit(ItemStack fruit, boolean nei, World world, GameProfile player) {
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
Set<IFruitFamily> providers = new HashSet<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = (ITreeGenome) getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(tSpecies.getUID()));
for (ItemStack fruit2 : genome.getFruitProvider().getProducts()) {
if (fruit2.isItemEqual(fruit)) {
providers.add(genome.getFruitProvider().getFamily());
}
}
}
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
for (IFruitFamily family : providers) {
if (tSpecies.getSuitableFruit().contains(family)) {
found.add(species);
break;
}
}
}
return found;
}
public Collection<IAlleleSpecies> getTreesThatCanBearFruit(
ItemStack fruit, boolean nei, World world, GameProfile player) {
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
Set<IFruitFamily> providers = new HashSet<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = (ITreeGenome)
getSpeciesRoot().templateAsGenome(getSpeciesRoot().getTemplate(tSpecies.getUID()));
for (ItemStack fruit2 : genome.getFruitProvider().getProducts()) {
if (fruit2.isItemEqual(fruit)) {
providers.add(genome.getFruitProvider().getFamily());
}
}
}
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
for (IFruitFamily family : providers) {
if (tSpecies.getSuitableFruit().contains(family)) {
found.add(species);
break;
}
}
}
return found;
}
public Collection<IAlleleSpecies> getTreesThatHaveWood(ItemStack fruit, boolean nei, World world, GameProfile player) {
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
// for (ItemStack fruit2 :
// tSpecies.getRoot().getMember(fruit).getProduceList()){
tSpecies.getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
ItemStack fruit2 = FakeWorld.instance.getWooLog();
if (fruit2.isItemEqual(fruit)) {
found.add(species);
// }
}
}
return found;
}
public Collection<IAlleleSpecies> getTreesThatHaveWood(
ItemStack fruit, boolean nei, World world, GameProfile player) {
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome =
TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
// for (ItemStack fruit2 :
// tSpecies.getRoot().getMember(fruit).getProduceList()){
tSpecies.getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
ItemStack fruit2 = FakeWorld.instance.getWooLog();
if (fruit2.isItemEqual(fruit)) {
found.add(species);
// }
}
}
return found;
}
public Collection<IAlleleSpecies> getTreesThatMakePlanks(ItemStack fruit, boolean nei, World world, GameProfile player) {
if (fruit == null) {
return new ArrayList<>();
}
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
tSpecies.getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
ItemStack fruit2 = FakeWorld.instance.getWooLog();
// for (ItemStack fruit2 :
// tSpecies.getRoot().getMember(fruit).getProduceList()) {
if (Lumbermill.getPlankProduct(fruit2) != null && fruit.isItemEqual(Lumbermill.getPlankProduct(fruit2))) {
found.add(species);
}
// }
}
return found;
}
public Collection<IAlleleSpecies> getTreesThatMakePlanks(
ItemStack fruit, boolean nei, World world, GameProfile player) {
if (fruit == null) {
return new ArrayList<>();
}
Collection<IAlleleSpecies> set = nei ? getAllSpecies() : getDiscoveredSpecies(world, player);
List<IAlleleSpecies> found = new ArrayList<>();
for (IAlleleSpecies species : set) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome =
TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
tSpecies.getGenerator().setLogBlock(genome, FakeWorld.instance, 0, 0, 0, ForgeDirection.UP);
ItemStack fruit2 = FakeWorld.instance.getWooLog();
// for (ItemStack fruit2 :
// tSpecies.getRoot().getMember(fruit).getProduceList()) {
if (Lumbermill.getPlankProduct(fruit2) != null && fruit.isItemEqual(Lumbermill.getPlankProduct(fruit2))) {
found.add(species);
}
// }
}
return found;
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((ITreeRoot) getSpeciesRoot()).getType(member) == EnumGermlingType.POLLEN;
}
@Override
public boolean isDNAManipulable(ItemStack member) {
return ((ITreeRoot) getSpeciesRoot()).getType(member) == EnumGermlingType.POLLEN;
}
@Override
public IIndividual getConversion(ItemStack stack) {
if (stack == null) {
return null;
}
for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSaplings.entrySet()) {
if (ItemStack.areItemStacksEqual(stack, entry.getKey())) {
return entry.getValue();
}
}
return null;
}
@Override
public IIndividual getConversion(ItemStack stack) {
if (stack == null) {
return null;
}
for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSaplings.entrySet()) {
if (ItemStack.areItemStacksEqual(stack, entry.getKey())) {
return entry.getValue();
}
}
return null;
}
@Override
public int[] getActiveTypes() {
return new int[]{
EnumGermlingType.SAPLING.ordinal(),
EnumGermlingType.POLLEN.ordinal()
};
}
@Override
public int[] getActiveTypes() {
return new int[] {EnumGermlingType.SAPLING.ordinal(), EnumGermlingType.POLLEN.ordinal()};
}
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumTreeChromosome) chromosome) {
case FERTILITY:
for (EnumAllele.Saplings saplings : EnumAllele.Saplings.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(saplings)));
}
break;
@Override
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
switch ((EnumTreeChromosome) chromosome) {
case FERTILITY:
for (EnumAllele.Saplings saplings : EnumAllele.Saplings.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(saplings)));
}
break;
case GIRTH:
for (ForestryAllele.Int a2 : ForestryAllele.Int.values()) {
alleles.add(a2.getAllele());
}
break;
case GIRTH:
for (ForestryAllele.Int a2 : ForestryAllele.Int.values()) {
alleles.add(a2.getAllele());
}
break;
case HEIGHT:
for (EnumAllele.Height height : EnumAllele.Height.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(height)));
}
break;
case HEIGHT:
for (EnumAllele.Height height : EnumAllele.Height.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(height)));
}
break;
case MATURATION:
for (EnumAllele.Maturation maturation : EnumAllele.Maturation.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(maturation)));
}
break;
case MATURATION:
for (EnumAllele.Maturation maturation : EnumAllele.Maturation.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(maturation)));
}
break;
case SAPPINESS:
for (EnumAllele.Sappiness sappiness : EnumAllele.Sappiness.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(sappiness)));
}
break;
case SAPPINESS:
for (EnumAllele.Sappiness sappiness : EnumAllele.Sappiness.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(sappiness)));
}
break;
case TERRITORY:
for (EnumAllele.Territory territory : EnumAllele.Territory.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(territory)));
}
break;
case TERRITORY:
for (EnumAllele.Territory territory : EnumAllele.Territory.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(territory)));
}
break;
case YIELD:
for (EnumAllele.Yield yield : EnumAllele.Yield.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(yield)));
}
break;
case YIELD:
for (EnumAllele.Yield yield : EnumAllele.Yield.values()) {
alleles.add(AlleleManager.alleleRegistry.getAllele(AlleleHelper.getUid(yield)));
}
break;
case FIREPROOF:
for (ForestryAllele.Bool bool : ForestryAllele.Bool.values()) {
alleles.add(bool.getAllele());
}
break;
}
}
case FIREPROOF:
for (ForestryAllele.Bool bool : ForestryAllele.Bool.values()) {
alleles.add(bool.getAllele());
}
break;
}
}
}
@@ -12,162 +12,156 @@ import forestry.api.core.IErrorLogic;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.InventoryBeeHousing;
import forestry.core.access.FakeAccessHandler;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
import net.minecraft.world.biome.BiomeGenBase;
import java.util.ArrayList;
public class VirtualBeeHousing extends VirtualHousing implements IBeeHousing, IBeeModifier {
ArrayList<IBeeModifier> beeModifier = new ArrayList<>();
private InventoryBeeHousing beeInventory;
ArrayList<IBeeModifier> beeModifier = new ArrayList<>();
private InventoryBeeHousing beeInventory;
public VirtualBeeHousing(EntityPlayer player) {
super(player);
beeModifier.add(this);
beeInventory = new InventoryBeeHousing(12, FakeAccessHandler.getInstance());
}
public VirtualBeeHousing(EntityPlayer player) {
super(player);
beeModifier.add(this);
beeInventory = new InventoryBeeHousing(12, FakeAccessHandler.getInstance());
}
@Override
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
@Override
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
@Override
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
return 1.0f;
}
@Override
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
return 1.0f;
}
@Override
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
return 1.0f;
}
@Override
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
return 1.0f;
}
@Override
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
@Override
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
public ItemStack getQueen() {
return null;
}
public ItemStack getQueen() {
return null;
}
public ItemStack getDrone() {
return null;
}
public ItemStack getDrone() {
return null;
}
public void setQueen(ItemStack itemStack) {
// ignored
}
public void setQueen(ItemStack itemStack) {
// ignored
}
public void setDrone(ItemStack itemStack) {
}
public void setDrone(ItemStack itemStack) {}
public boolean canBreed() {
return true;
}
public boolean canBreed() {
return true;
}
@Override
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
@Override
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
public void wearOutEquipment(int amount) {
}
public void wearOutEquipment(int amount) {}
public void onQueenChange(ItemStack queen) {
}
public void onQueenChange(ItemStack queen) {}
@Override
public boolean isSealed() {
return false;
}
@Override
public boolean isSealed() {
return false;
}
@Override
public boolean isSelfLighted() {
return false;
}
@Override
public boolean isSelfLighted() {
return false;
}
@Override
public boolean isSunlightSimulated() {
return false;
}
@Override
public boolean isSunlightSimulated() {
return false;
}
@Override
public boolean isHellish() {
return getBiomeId() == BiomeGenBase.hell.biomeID;
}
@Override
public boolean isHellish() {
return getBiomeId() == BiomeGenBase.hell.biomeID;
}
@Override
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
@Override
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
public void onQueenDeath(IBee queen) {
}
public void onQueenDeath(IBee queen) {}
public void onPostQueenDeath(IBee queen) {
}
public void onPostQueenDeath(IBee queen) {}
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
return false;
}
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
return false;
}
public boolean onEggLaid(IBee queen) {
return false;
}
public boolean onEggLaid(IBee queen) {
return false;
}
@Override
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
@Override
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
return 1.0f;
}
@Override
public IErrorLogic getErrorLogic() {
return null;
}
@Override
public IErrorLogic getErrorLogic() {
return null;
}
// TODO ??
@Override
public boolean canBlockSeeTheSky() {
return true;
}
// TODO ??
@Override
public boolean canBlockSeeTheSky() {
return true;
}
// TODO ??
@Override
public Vec3 getBeeFXCoordinates() {
return Vec3.createVectorHelper(0, -100000, 0);
}
// TODO ??
@Override
public Vec3 getBeeFXCoordinates() {
return Vec3.createVectorHelper(0, -100000, 0);
}
@Override
public IBeeHousingInventory getBeeInventory() {
return beeInventory;
}
@Override
public IBeeHousingInventory getBeeInventory() {
return beeInventory;
}
// TODO ??
@Override
public Iterable<IBeeListener> getBeeListeners() {
return null;
}
// TODO ??
@Override
public Iterable<IBeeListener> getBeeListeners() {
return null;
}
@Override
public Iterable<IBeeModifier> getBeeModifiers() {
return beeModifier;
}
@Override
public Iterable<IBeeModifier> getBeeModifiers() {
return beeModifier;
}
@Override
public IBeekeepingLogic getBeekeepingLogic() {
return null;
}
@Override
public IBeekeepingLogic getBeekeepingLogic() {
return null;
}
@Override
public int getBlockLightValue() {
return 0;
}
@Override
public int getBlockLightValue() {
return 0;
}
@Override
public GameProfile getOwner() {
return getOwnerName();
}
@Override
public GameProfile getOwner() {
return getOwnerName();
}
}
@@ -5,86 +5,84 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IHousing;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import java.util.Set;
class VirtualHousing implements IHousing {
private EntityPlayer player;
private EntityPlayer player;
public VirtualHousing(EntityPlayer player) {
this.player = player;
}
public VirtualHousing(EntityPlayer player) {
this.player = player;
}
public int getX() {
return (int) player.posX;
}
public int getX() {
return (int) player.posX;
}
public int getY() {
return (int) player.posY;
}
public int getY() {
return (int) player.posY;
}
public int getZ() {
return (int) player.posZ;
}
public int getZ() {
return (int) player.posZ;
}
public int getBiomeId() {
return player.worldObj.getBiomeGenForCoords(getX(), getY()).biomeID;
}
public int getBiomeId() {
return player.worldObj.getBiomeGenForCoords(getX(), getY()).biomeID;
}
public EnumTemperature getTemperature() {
return EnumTemperature.getFromValue(getBiome().temperature);
}
public EnumTemperature getTemperature() {
return EnumTemperature.getFromValue(getBiome().temperature);
}
public EnumHumidity getHumidity() {
return EnumHumidity.getFromValue(getBiome().rainfall);
}
public EnumHumidity getHumidity() {
return EnumHumidity.getFromValue(getBiome().rainfall);
}
public World getWorld() {
return player.worldObj;
}
public World getWorld() {
return player.worldObj;
}
public void setErrorState(int state) {
// ignored
}
public void setErrorState(int state) {
// ignored
}
public int getErrorOrdinal() {
return 0;
}
public int getErrorOrdinal() {
return 0;
}
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
public boolean addProduct(ItemStack product, boolean all) {
return false;
}
public GameProfile getOwnerName() {
return player.getGameProfile();
}
public GameProfile getOwnerName() {
return player.getGameProfile();
}
public BiomeGenBase getBiome() {
return player.worldObj.getBiomeGenForCoords(getX(), getZ());
}
public BiomeGenBase getBiome() {
return player.worldObj.getBiomeGenForCoords(getX(), getZ());
}
// public EnumErrorCode getErrorState() {
// return null;
// }
// public EnumErrorCode getErrorState() {
// return null;
// }
public void setErrorState(IErrorState state) {
}
public void setErrorState(IErrorState state) {}
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
return false;
}
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
return false;
}
public Set<IErrorState> getErrorStates() {
return null;
}
public Set<IErrorState> getErrorStates() {
return null;
}
@Override
public ChunkCoordinates getCoordinates() {
return new ChunkCoordinates(getX(), getY(), getZ());
}
@Override
public ChunkCoordinates getCoordinates() {
return new ChunkCoordinates(getX(), getY(), getZ());
}
}