Welcoming Miry and Boggy bees! Marshy bees are no longer in a branch all on their lonesome.

This commit is contained in:
MysteriousAges committed 2014-12-08 21:42:22 -08:00
1 parent 99f09b4037
commit e281cb4591
5 files changed
+188 -30

No files matched your search

@@ -0,0 +1,129 @@
package forestry.apiculture.genetics;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
public class AlleleEffectFungification extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 10;
public static final int ENTITY_THROTTLE = 6;
public AlleleEffectFungification(String uid) {
super(uid, "mycophilic", true, 10, false, false);
}
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (storedData instanceof EffectData && ((EffectData) storedData).getIntSize() == 2) {
return storedData;
}
return new EffectData(2, 0);
}
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing)) {
return storedData;
}
doBlockEffect(genome, housing);
int entityThrottle = storedData.getInteger(1);
if (entityThrottle >= ENTITY_THROTTLE) {
doEntityEffect(genome, housing);
entityThrottle = 0;
} else {
++entityThrottle;
}
storedData.setInteger(1, entityThrottle);
return storedData;
}
private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorld();
int territorySize[] = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
int blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
Block block = world.getBlock(blockX, blockY, blockZ);
if (isSuitableForMycelium(world, block, blockX, blockY, blockZ)) {
world.setBlock(blockX, blockY, blockZ, Blocks.mycelium);
break;
} else if (isSuitableForGrowth(block)) {
doMushroomGrowth(block, world, blockX, blockY, blockZ);
break;
}
blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
}
}
private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
AxisAlignedBB aabb = this.getBounding(genome, housing, 1f);
World world = housing.getWorld();
@SuppressWarnings("unchecked") // Quiets warnings. Eventually returns a list of entities.
List<Entity> entities = (List<Entity>)world.getEntitiesWithinAABB(EntityCow.class, aabb);
for (Entity entity : entities) {
if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) {
convertCowToMooshroom((EntityCow)entity);
break;
}
}
}
private int getRandomOffset(Random random, int centrePos, int offset) {
return centrePos + random.nextInt(offset) - (offset / 2);
}
private boolean isSuitableForMycelium(World world, Block block, int blockX, int blockY, int blockZ) {
return block == Blocks.grass || (block == Blocks.dirt && world.canBlockSeeTheSky(blockX, blockY, blockZ));
}
private boolean isSuitableForGrowth(Block block) {
return block == Blocks.red_mushroom || block == Blocks.brown_mushroom;
}
private static void convertCowToMooshroom(EntityCow cow) {
World worldObj = cow.worldObj;
cow.setDead();
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double)(cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
}
private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) {
WorldGenBigMushroom giantMushroomGenerator = null;
if (block == Blocks.brown_mushroom) {
giantMushroomGenerator = new WorldGenBigMushroom(0);
} else {
giantMushroomGenerator = new WorldGenBigMushroom(1);
}
world.setBlockToAir(blockX, blockY, blockZ);
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
}
}
@@ -582,6 +582,25 @@ public class BeeTemplates {
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMarshy;
return alleles;
}
public static IAllele[] getMiryTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMiry;
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
return alleles;
}
public static IAllele[] getBoggyTemplate() {
IAllele[] alleles = getBoggyBranchTemplate();
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesBoggy;
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger;
return alleles;
}
/* MONASTIC BRANCH */
public static IAllele[] getMonasticBranchTemplate() {
@@ -123,8 +123,8 @@ public class Allele implements IAllele {
// Boggy branch
public static AlleleSpecies speciesMarshy;
// 44 speciesMiry
// 45 speciesBoggy
public static AlleleSpecies speciesMiry;
public static AlleleSpecies speciesBoggy;
// Monastic branch
public static AlleleSpecies speciesMonastic;
@@ -392,6 +392,7 @@ public class Allele implements IAllele {
public static Allele effectResurrection;
public static Allele effectRepulsion;
public static Allele effectFertile;
public static Allele effectMycophilic;
// / TREES // EFFECTS
public static Allele leavesNone;
@@ -10,6 +10,26 @@
******************************************************************************/
package forestry.plugins;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.util.IIcon;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
@@ -37,7 +57,6 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IClassification.EnumClassLevel;
import forestry.api.recipes.RecipeManagers;
import forestry.apiculture.commands.CommandBeekeeping;
import forestry.apiculture.FlowerProviderCacti;
import forestry.apiculture.FlowerProviderEnd;
import forestry.apiculture.FlowerProviderGourd;
@@ -50,6 +69,7 @@ import forestry.apiculture.GuiHandlerApiculture;
import forestry.apiculture.PacketHandlerApiculture;
import forestry.apiculture.SaveEventHandlerApiculture;
import forestry.apiculture.VillageHandlerApiculture;
import forestry.apiculture.commands.CommandBeekeeping;
import forestry.apiculture.gadgets.BlockAlveary;
import forestry.apiculture.gadgets.BlockBeehives;
import forestry.apiculture.gadgets.BlockCandle;
@@ -71,6 +91,8 @@ import forestry.apiculture.genetics.AlleleBeeSpecies;
import forestry.apiculture.genetics.AlleleEffectAggressive;
import forestry.apiculture.genetics.AlleleEffectCreeper;
import forestry.apiculture.genetics.AlleleEffectExploration;
import forestry.apiculture.genetics.AlleleEffectFertile;
import forestry.apiculture.genetics.AlleleEffectFungification;
import forestry.apiculture.genetics.AlleleEffectGlacial;
import forestry.apiculture.genetics.AlleleEffectHeroic;
import forestry.apiculture.genetics.AlleleEffectIgnition;
@@ -82,7 +104,6 @@ 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;
@@ -105,7 +126,6 @@ import forestry.apiculture.items.ItemImprinter;
import forestry.apiculture.items.ItemWaxCast;
import forestry.apiculture.proxy.ProxyApiculture;
import forestry.apiculture.trigger.ApicultureTriggers;
import forestry.apiculture.trigger.TriggerNoFrames;
import forestry.apiculture.worldgen.HiveDecorator;
import forestry.apiculture.worldgen.HiveEnd;
import forestry.apiculture.worldgen.HiveForest;
@@ -136,30 +156,8 @@ import forestry.core.items.ItemOverlay.OverlayInfo;
import forestry.core.items.ItemScoop;
import forestry.core.proxy.Proxies;
import forestry.core.render.EntitySnowFX;
import forestry.core.triggers.Trigger;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.ShapedRecipeCustom;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.command.ICommand;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.util.IIcon;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
@Plugin(pluginID = "Apiculture", name = "Apiculture", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.apiculture.description")
public class PluginApiculture extends ForestryPlugin {
@@ -1037,8 +1035,10 @@ public class PluginApiculture extends ForestryPlugin {
// Boggy branch
Allele.speciesMarshy = new AlleleBeeSpecies("speciesMarshy", true, "bees.species.marshy", boggy, "adorasti", 0x546626, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 15), 30).setHumidity(EnumHumidity.DAMP);
// 44 speciesMiry
// 45 speciesBoggy
Allele.speciesMiry = new AlleleBeeSpecies("speciesMiry", true, "bees.species.miry", boggy, "humidium", 0x92AF42, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 15), 36).setHumidity(EnumHumidity.DAMP).setIsSecret();
Allele.speciesBoggy = new AlleleBeeSpecies("speciesBoggy", true, "bees.species.boggy", boggy, "paluster", 0x698948, 0xffdc16).addProduct(
ForestryItem.beeComb.getItemStack(1, 15), 39).addSpecialty(ForestryItem.peat.getItemStack(1), 8).setHumidity(EnumHumidity.DAMP).setIsSecret();
// Monastic branch
Allele.speciesMonastic = new AlleleBeeSpecies("speciesMonastic", false, "bees.species.monastic", monastic, "monachus", 0x42371c, 0xfff7b6)
@@ -1079,6 +1079,7 @@ public class PluginApiculture extends ForestryPlugin {
Allele.effectResurrection = new AlleleEffectResurrection("effectResurrection", "resurrection", AlleleEffectResurrection.getResurrectionList());
Allele.effectRepulsion = new AlleleEffectRepulsion("effectRepulsion");
Allele.effectFertile = new AlleleEffectFertile("effectFertile");
Allele.effectMycophilic = new AlleleEffectFungification("effectMycophilic");
}
@@ -1168,6 +1169,12 @@ public class PluginApiculture extends ForestryPlugin {
.restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck();
new BeeMutation(Allele.speciesFarmerly, Allele.speciesIndustrious, BeeTemplates.getAgrarianTemplate(), 6)
.restrictBiomeType(BiomeDictionary.Type.PLAINS).enableStrictBiomeCheck();
// Boggy branch
new BeeMutation(Allele.speciesMarshy, Allele.speciesNoble, BeeTemplates.getMiryTemplate(), 15)
.setTemperatureRainfall(0.75f, 0.94f, 0.75f, 2.0f);
new BeeMutation(Allele.speciesMarshy, Allele.speciesMiry, BeeTemplates.getBoggyTemplate(), 9)
.setTemperatureRainfall(0.75f, 0.94f, 0.75f, 2.0f);
// Monastic branch
BeeTemplates.secludedA = new BeeMutation(Allele.speciesMonastic, Allele.speciesAustere, BeeTemplates.getSecludedTemplate(), 12);
@@ -1225,6 +1232,8 @@ public class PluginApiculture extends ForestryPlugin {
beeInterface.registerTemplate(BeeTemplates.getTipsyTemplate());
beeInterface.registerTemplate(BeeTemplates.getTrickyTemplate());
beeInterface.registerTemplate(BeeTemplates.getMarshyTemplate());
beeInterface.registerTemplate(BeeTemplates.getMiryTemplate());
beeInterface.registerTemplate(BeeTemplates.getBoggyTemplate());
beeInterface.registerTemplate(BeeTemplates.getMonasticTemplate());
beeInterface.registerTemplate(BeeTemplates.getSecludedTemplate());
beeInterface.registerTemplate(BeeTemplates.getHermiticTemplate());