mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Fix #439 Some Drones have GEN tag
This commit is contained in:
1 parent
d536d5cf46
commit
960b322e86
5 files changed
+53
-61
No files matched your search
@@ -58,6 +58,9 @@ import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
protected int generation;
|
||||
protected boolean isNatural = true;
|
||||
|
||||
public IBeeGenome genome;
|
||||
public IBeeGenome mate;
|
||||
|
||||
@@ -66,28 +69,20 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
public Bee(World world, IBeeGenome genome, IBee mate) {
|
||||
this(world, genome);
|
||||
public Bee(IBeeGenome genome, IBee mate) {
|
||||
this(genome);
|
||||
this.mate = mate.getGenome();
|
||||
this.isIrregularMating = mate.isNatural() != this.isNatural;
|
||||
}
|
||||
|
||||
public Bee(World world, IBeeGenome genome) {
|
||||
this(world, genome, true, 0);
|
||||
}
|
||||
|
||||
public Bee(IBeeGenome genome) {
|
||||
this(genome, true, 0);
|
||||
}
|
||||
|
||||
public Bee(World world, IBeeGenome genome, boolean isNatural, int generation) {
|
||||
super(genome.getLifespan(), isNatural, generation);
|
||||
this.genome = genome;
|
||||
}
|
||||
|
||||
public Bee(IBeeGenome genome, boolean isNatural, int generation) {
|
||||
super(genome.getLifespan(), isNatural, generation);
|
||||
super(genome.getLifespan());
|
||||
this.genome = genome;
|
||||
this.isNatural = isNatural;
|
||||
this.generation = generation;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@@ -101,15 +96,51 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (nbttagcompound.hasKey("NA"))
|
||||
isNatural = nbttagcompound.getBoolean("NA");
|
||||
|
||||
if (nbttagcompound.hasKey("GEN"))
|
||||
generation = nbttagcompound.getInteger("GEN");
|
||||
|
||||
if (nbttagcompound.hasKey("Genome"))
|
||||
genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome"));
|
||||
else
|
||||
genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
|
||||
|
||||
if (nbttagcompound.hasKey("Mate"))
|
||||
mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (!isNatural)
|
||||
nbttagcompound.setBoolean("NA", false);
|
||||
|
||||
if (generation > 0)
|
||||
nbttagcompound.setInteger("GEN", generation);
|
||||
}
|
||||
|
||||
public void setIsNatural(boolean flag) {
|
||||
this.isNatural = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIrregularMating() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNatural() {
|
||||
return this.isNatural;
|
||||
}
|
||||
|
||||
public int getGeneration() {
|
||||
return generation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mate(IIndividual individual) {
|
||||
if(!(individual instanceof IBee))
|
||||
@@ -117,7 +148,6 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
IBee drone = (IBee)individual;
|
||||
mate = drone.getGenome();
|
||||
this.isIrregularMating = drone.isNatural() != this.isNatural;
|
||||
}
|
||||
|
||||
/* EFFECTS */
|
||||
@@ -470,7 +500,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
toCreate = 1;
|
||||
|
||||
for (int i = 0; i < toCreate; i++) {
|
||||
IBee offspring = createOffspring(housing, -1);
|
||||
IBee offspring = createOffspring(housing, 0);
|
||||
if (offspring != null) {
|
||||
offspring.setIsNatural(true);
|
||||
bees.add(offspring);
|
||||
@@ -505,7 +535,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
|
||||
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
|
||||
IBee offspring = new Bee(world, new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
|
||||
IBee offspring = new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
|
||||
|
||||
/* Disabling the mutation rate nerf
|
||||
// All mutation and no play makes queen a dull girl.
|
||||
|
||||
@@ -156,8 +156,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public IBee getMember(ItemStack stack) {
|
||||
if (!ForestryItem.beeQueenGE.isItemEqual(stack) && !ForestryItem.beePrincessGE.isItemEqual(stack)
|
||||
&& !ForestryItem.beeDroneGE.isItemEqual(stack) && !ForestryItem.beeLarvaeGE.isItemEqual(stack))
|
||||
if (!isMember(stack))
|
||||
return null;
|
||||
|
||||
return new Bee(stack.getTagCompound());
|
||||
@@ -170,12 +169,12 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public IBee getBee(World world, IBeeGenome genome) {
|
||||
return new Bee(world, genome);
|
||||
return new Bee(genome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBee getBee(World world, IBeeGenome genome, IBee mate) {
|
||||
return new Bee(world, genome, mate);
|
||||
return new Bee(genome, mate);
|
||||
}
|
||||
|
||||
/* GENOME CONVERSIONS */
|
||||
|
||||
@@ -17,19 +17,13 @@ import net.minecraft.world.World;
|
||||
|
||||
public abstract class IndividualLiving extends Individual implements IIndividualLiving {
|
||||
|
||||
protected int generation;
|
||||
protected boolean isNatural;
|
||||
protected boolean isIrregularMating;
|
||||
|
||||
protected int health;
|
||||
protected int maxHealth;
|
||||
|
||||
public IndividualLiving() {}
|
||||
|
||||
public IndividualLiving(int newHealth, boolean isNatural, int generation) {
|
||||
public IndividualLiving(int newHealth) {
|
||||
health = maxHealth = newHealth;
|
||||
this.isNatural = isNatural;
|
||||
this.generation = generation;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@@ -38,13 +32,6 @@ public abstract class IndividualLiving extends Individual implements IIndividual
|
||||
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (nbttagcompound.hasKey("NA"))
|
||||
isNatural = nbttagcompound.getBoolean("NA");
|
||||
else
|
||||
isNatural = true;
|
||||
isIrregularMating = nbttagcompound.getBoolean("IM");
|
||||
generation = nbttagcompound.getInteger("GEN");
|
||||
|
||||
health = nbttagcompound.getInteger("Health");
|
||||
maxHealth = nbttagcompound.getInteger("MaxH");
|
||||
|
||||
@@ -55,10 +42,6 @@ public abstract class IndividualLiving extends Individual implements IIndividual
|
||||
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setBoolean("NA", isNatural);
|
||||
nbttagcompound.setBoolean("IM", isIrregularMating);
|
||||
nbttagcompound.setInteger("GEN", generation);
|
||||
|
||||
nbttagcompound.setInteger("Health", health);
|
||||
nbttagcompound.setInteger("MaxH", maxHealth);
|
||||
|
||||
@@ -77,22 +60,6 @@ public abstract class IndividualLiving extends Individual implements IIndividual
|
||||
|
||||
/* GENERATION */
|
||||
public abstract IGenome getMate();
|
||||
|
||||
public void setIsNatural(boolean flag) {
|
||||
this.isNatural = flag;
|
||||
}
|
||||
|
||||
public boolean isIrregularMating() {
|
||||
return this.isIrregularMating;
|
||||
}
|
||||
|
||||
public boolean isNatural() {
|
||||
return this.isNatural;
|
||||
}
|
||||
|
||||
public int getGeneration() {
|
||||
return generation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
|
||||
@@ -54,11 +54,7 @@ public class Butterfly extends IndividualLiving implements IButterfly {
|
||||
}
|
||||
|
||||
public Butterfly(IButterflyGenome genome) {
|
||||
this(genome, true, 0);
|
||||
}
|
||||
|
||||
public Butterfly(IButterflyGenome genome, boolean isNatural, int generation) {
|
||||
super(genome.getLifespan(), isNatural, generation);
|
||||
super(genome.getLifespan());
|
||||
this.genome = genome;
|
||||
}
|
||||
|
||||
@@ -201,7 +197,7 @@ public class Butterfly extends IndividualLiving implements IButterfly {
|
||||
if (parent1[i] != null && parent2[i] != null)
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
|
||||
|
||||
return new Butterfly(new ButterflyGenome(chromosomes), true, generation);
|
||||
return new Butterfly(new ButterflyGenome(chromosomes));
|
||||
}
|
||||
|
||||
private IChromosome[] mutateSpecies(IButterflyNursery nursery, IGenome genomeOne, IGenome genomeTwo) {
|
||||
|
||||
Reference in new issue
Block a user