Farmerly & Agrarian bees. Buzz buzz

This commit is contained in:
MysteriousAges committed 2014-12-04 01:13:29 -08:00
1 parent d132a0ae62
commit 8ff72af9d2
5 files changed
+93 -5

No files matched your search

@@ -0,0 +1,59 @@
package forestry.apiculture.genetics;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
public class AlleleEffectFertile extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 5;
public AlleleEffectFertile(String uid) {
super(uid, "fertile", false, 6, true, false);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing)) {
return storedData;
}
World world = housing.getWorld();
int territorySize[] = genome.getTerritory();
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
int blockMaxY = housing.getYCoord() + territorySize[1] / 2 + 1;
int blockMinY = housing.getYCoord() - (territorySize[1] / 2) - 1;
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
if (tryTickColumn(world, blockX, blockZ, blockMaxY, blockMinY)) {
break;
}
blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
}
return storedData;
}
private int getRandomOffset(Random random, int centrePos, int offset) {
return centrePos + random.nextInt(offset) - (offset / 2);
}
private boolean tryTickColumn(World world, int x, int z, int maxY, int minY) {
for (int y = maxY; y >= minY; --y) {
if (!world.isAirBlock(x, y, z)) {
Block block = world.getBlock(x, y, z);
world.scheduleBlockUpdate(x, y, z, block, 5);
return true;
}
}
return false;
}
}
@@ -548,6 +548,24 @@ public class BeeTemplates {
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesRural;
return alleles;
}
public static IAllele[] getFarmerlyTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFarmerly;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
return alleles;
}
public static IAllele[] getAgrarianTemplate() {
IAllele[] alleles = getAgrarianBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesArgrarian;
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectFertile;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
return alleles;
}
// / BOGGY BRANCH
public static IAllele[] getBoggyBranchTemplate() {
@@ -118,8 +118,8 @@ public class Allele implements IAllele {
// Agrarian branch
public static AlleleSpecies speciesRural;
// 41 Farmerly
// 42 Agrarian
public static AlleleSpecies speciesFarmerly;
public static AlleleSpecies speciesArgrarian;
// Boggy branch
public static AlleleSpecies speciesMarshy;
@@ -391,6 +391,7 @@ public class Allele implements IAllele {
public static Allele effectReanimation;
public static Allele effectResurrection;
public static Allele effectRepulsion;
public static Allele effectFertile;
// / TREES // EFFECTS
public static Allele leavesNone;
@@ -82,6 +82,7 @@ import forestry.apiculture.genetics.AlleleEffectRadioactive;
import forestry.apiculture.genetics.AlleleEffectRepulsion;
import forestry.apiculture.genetics.AlleleEffectResurrection;
import forestry.apiculture.genetics.AlleleEffectSnowing;
import forestry.apiculture.genetics.AlleleEffectFertile;
import forestry.apiculture.genetics.AlleleFlowers;
import forestry.apiculture.genetics.Bee;
import forestry.apiculture.genetics.BeeHelper;
@@ -1028,8 +1029,10 @@ public class PluginApiculture extends ForestryPlugin {
// Agrarian branch
Allele.speciesRural = new AlleleBeeSpecies("speciesRural", false, "bees.species.rural", agrarian, "rustico", 0xfeff8f, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 14), 20).setIsSecret();
// 41 Farmerly
// 42 Agrarian
Allele.speciesFarmerly = new AlleleBeeSpecies("speciesFarmerly", true, "bees.species.farmerly", agrarian, "arator", 0xD39728, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 14), 27).setIsSecret();
Allele.speciesArgrarian = new AlleleBeeSpecies("speciesArgrarian", true, "bees.species.agrarian", agrarian, "arator", 0xFFCA75, 0xFFE047).addProduct(
ForestryItem.beeComb.getItemStack(1, 14), 35).setIsSecret().setHasEffect();
// Boggy branch
Allele.speciesMarshy = new AlleleBeeSpecies("speciesMarshy", true, "bees.species.marshy", boggy, "adorasti", 0x546626, 0xffdc16).addProduct(
@@ -1075,6 +1078,7 @@ public class PluginApiculture extends ForestryPlugin {
Allele.effectReanimation = new AlleleEffectResurrection("effectReanimation", "reanimation", AlleleEffectResurrection.getReanimationList());
Allele.effectResurrection = new AlleleEffectResurrection("effectResurrection", "resurrection", AlleleEffectResurrection.getResurrectionList());
Allele.effectRepulsion = new AlleleEffectRepulsion("effectRepulsion");
Allele.effectFertile = new AlleleEffectFertile("effectFertile");
}
@@ -1160,6 +1164,10 @@ public class PluginApiculture extends ForestryPlugin {
// Agrarian branch
BeeTemplates.ruralA = new BeeMutation(Allele.speciesMeadows, Allele.speciesDiligent, BeeTemplates.getRuralTemplate(), 12)
.restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck();
new BeeMutation(Allele.speciesRural, Allele.speciesUnweary, BeeTemplates.getFarmerlyTemplate(), 10)
.restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck();
new BeeMutation(Allele.speciesFarmerly, Allele.speciesIndustrious, BeeTemplates.getAgrarianBranchTemplate(), 6)
.restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck();
// Monastic branch
BeeTemplates.secludedA = new BeeMutation(Allele.speciesMonastic, Allele.speciesAustere, BeeTemplates.getSecludedTemplate(), 12);
@@ -1210,6 +1218,8 @@ public class PluginApiculture extends ForestryPlugin {
beeInterface.registerTemplate(BeeTemplates.getReddenedTemplate());
beeInterface.registerTemplate(BeeTemplates.getOmegaTemplate());
beeInterface.registerTemplate(BeeTemplates.getRuralTemplate());
beeInterface.registerTemplate(BeeTemplates.getFarmerlyTemplate());
beeInterface.registerTemplate(BeeTemplates.getAgrarianTemplate());
beeInterface.registerTemplate(BeeTemplates.getLeporineTemplate());
beeInterface.registerTemplate(BeeTemplates.getMerryTemplate());
beeInterface.registerTemplate(BeeTemplates.getTipsyTemplate());