mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-19 03:49:13 +00:00
Adding Hiveacynth, with several configuration options.
This commit is contained in:
1 parent
55840ac08e
commit
a65c593c9a
9 files changed
+193
-6
No files matched your search
@@ -219,7 +219,7 @@ public class Allele implements IAllele
|
||||
|
||||
public static IAlleleBeeSpecies getExtraSpecies(String name)
|
||||
{
|
||||
return (IAlleleBeeSpecies)AlleleManager.alleleRegistry.getAllele((new StringBuilder()).append("extrabees.species.").append(name).toString());
|
||||
return (IAlleleBeeSpecies)AlleleManager.alleleRegistry.getAllele((new StringBuilder()).append("extrabees.species.").append(name.toLowerCase()).toString());
|
||||
}
|
||||
|
||||
public static IAllele getBaseAllele(String name)
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
package magicbees.bees;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import magicbees.block.types.HiveType;
|
||||
import magicbees.item.types.DropType;
|
||||
import magicbees.main.Config;
|
||||
import magicbees.main.utils.Tuple;
|
||||
import magicbees.main.utils.compat.ExtraBeesHelper;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
|
||||
public class BeeManager
|
||||
{
|
||||
public static IBeeRoot beeRoot;
|
||||
|
||||
private static List<Tuple<IAlleleBeeSpecies, Double>> worldgenSpeciesWeights = new ArrayList<Tuple<IAlleleBeeSpecies, Double>>();
|
||||
private static double worldgenSpeciesWeightsTotal = 0;
|
||||
|
||||
public static void ititializeBees()
|
||||
{
|
||||
@@ -23,4 +34,51 @@ public class BeeManager
|
||||
|
||||
beeRoot.setResearchSuitability(Config.drops.getStackForType(DropType.INTELLECT), 0.5f);
|
||||
}
|
||||
|
||||
public static IAlleleBeeSpecies getRandomWorldgenSpecies(Random r) {
|
||||
Collections.shuffle(worldgenSpeciesWeights);
|
||||
double value = r.nextDouble() * worldgenSpeciesWeightsTotal;
|
||||
IAlleleBeeSpecies species = Allele.getBaseSpecies("Forest");
|
||||
|
||||
for (Tuple<IAlleleBeeSpecies, Double> t : worldgenSpeciesWeights) {
|
||||
value -= t.right.doubleValue();
|
||||
if (value <= 0.0) {
|
||||
species = t.left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return species;
|
||||
}
|
||||
|
||||
public static void addWorldgenSpeciesWeight(IAlleleBeeSpecies species, double d) {
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(species, d));
|
||||
worldgenSpeciesWeightsTotal += d;
|
||||
}
|
||||
|
||||
public static void populateSpeciesListRarity() {
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getBaseSpecies("Forest"), 20.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getBaseSpecies("Meadows"), 20.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getBaseSpecies("Tropical"), 10.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getBaseSpecies("Modest"), 16.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getBaseSpecies("Wintry"), 10.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getBaseSpecies("Ended"), 0.5));
|
||||
|
||||
if (ExtraBeesHelper.isActive()) {
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getExtraSpecies("Water"), 12.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getExtraSpecies("Rocky"), 16.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(Allele.getExtraSpecies("Embittered"), 10.0));
|
||||
}
|
||||
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(BeeSpecies.MYSTICAL, 20.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(BeeSpecies.UNUSUAL, 20.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(BeeSpecies.SORCEROUS, 13.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(BeeSpecies.ATTUNED, 6.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(BeeSpecies.INFERNAL, 10.0));
|
||||
worldgenSpeciesWeights.add(new Tuple<IAlleleBeeSpecies, Double>(BeeSpecies.OBLIVION, 1.0));
|
||||
|
||||
for (Tuple<IAlleleBeeSpecies, Double> t : worldgenSpeciesWeights) {
|
||||
worldgenSpeciesWeightsTotal += t.right.doubleValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package magicbees.main;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.block.BlockEffectJar;
|
||||
import magicbees.block.BlockHive;
|
||||
@@ -32,6 +34,7 @@ import magicbees.item.types.ResourceType;
|
||||
import magicbees.item.types.WaxType;
|
||||
import magicbees.main.utils.LocalizationManager;
|
||||
import magicbees.main.utils.LogHelper;
|
||||
import magicbees.main.utils.Tuple;
|
||||
import magicbees.main.utils.VersionInfo;
|
||||
import magicbees.main.utils.compat.BotaniaHelper;
|
||||
import magicbees.main.utils.compat.ThaumcraftHelper;
|
||||
@@ -55,6 +58,7 @@ import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.storage.BackpackManager;
|
||||
import forestry.api.storage.EnumBackpackType;
|
||||
|
||||
@@ -222,6 +226,7 @@ public class Config
|
||||
|
||||
public static Item botManaResource;
|
||||
|
||||
|
||||
//----- Config State info ----------------------------------
|
||||
public static Configuration configuration;
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package magicbees.main.utils;
|
||||
|
||||
public class Tuple<X, Y> {
|
||||
|
||||
public final X left;
|
||||
public final Y right;
|
||||
|
||||
public Tuple(X x, Y y) {
|
||||
left = x;
|
||||
right = y;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package magicbees.main.utils.compat;
|
||||
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.Config;
|
||||
import magicbees.main.utils.BlockInterface;
|
||||
import magicbees.main.utils.ItemInterface;
|
||||
import magicbees.main.utils.compat.botania.BotaniaSignature;
|
||||
import magicbees.main.utils.compat.botania.SubTileBeegonia;
|
||||
import magicbees.main.utils.compat.botania.SubTileHiveacynth;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
@@ -43,6 +45,9 @@ public class BotaniaHelper {
|
||||
public static final String Name = "Botania";
|
||||
|
||||
public static double beegoniaManaMultiplier;
|
||||
public static double hiveacynthManaMultiplier;
|
||||
public static double hiveacynthRainResistRate;
|
||||
public static double hiveacynthPrincessSpawnRate;
|
||||
|
||||
public static boolean isActive() {
|
||||
return isBotaniaActive;
|
||||
@@ -68,6 +73,12 @@ public class BotaniaHelper {
|
||||
BotaniaAPI.registerSubTile(SubTileBeegonia.NAME, SubTileBeegonia.class);
|
||||
BotaniaAPI.registerSubTileSignature(SubTileBeegonia.class, new BotaniaSignature(SubTileBeegonia.NAME));
|
||||
BotaniaAPI.addSubTileToCreativeMenu(SubTileBeegonia.NAME);
|
||||
|
||||
// Hiveacynth would appreciate it if this list existed.
|
||||
BeeManager.populateSpeciesListRarity();
|
||||
BotaniaAPI.registerSubTile(SubTileHiveacynth.NAME, SubTileHiveacynth.class);
|
||||
BotaniaAPI.registerSubTileSignature(SubTileHiveacynth.class, new BotaniaSignature(SubTileHiveacynth.NAME));
|
||||
BotaniaAPI.addSubTileToCreativeMenu(SubTileHiveacynth.NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +99,20 @@ public class BotaniaHelper {
|
||||
Property p;
|
||||
String section = "botaniaPlugin";
|
||||
|
||||
p = configuration.get(section, "beegoniaManaMultiplier", 1);
|
||||
p.comment = "Multiplyer for the Beegonia's mana generation. Default: 1.0 (Affects duration, not throughput)";
|
||||
p = configuration.get(section, "beegoniaManaMultiplier", 1.0);
|
||||
p.comment = "Multiplier for the Beegonia's mana generation. Default: 1.0 (Affects duration, not throughput)";
|
||||
beegoniaManaMultiplier = p.getDouble();
|
||||
|
||||
p = configuration.get(section, "hiveacynthManaMultiplier", 1.0);
|
||||
p.comment = "Multiplier for the Hiveacynth's mana consumption. Default: 1.0";
|
||||
hiveacynthManaMultiplier = p.getDouble();
|
||||
|
||||
p = configuration.get(section, "hiveacynthRainResistRate", 0.1);
|
||||
p.comment = "Rate at which the hiveacynth applies rain resist to spawned bees. Default: 0.1 Setting to 0 will disable.";
|
||||
hiveacynthRainResistRate = p.getDouble();
|
||||
|
||||
p = configuration.get(section, "hiveacynthPrincessSpawnRate", 0.09);
|
||||
p.comment = "Rate at which the Hiveacynth will spawn a Princess instead of a Drone. Default: 0.09. Setting to 0 will disable.";
|
||||
hiveacynthPrincessSpawnRate = p.getDouble();
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class SubTileBeegonia extends SubTileGenerating {
|
||||
}
|
||||
}
|
||||
|
||||
public int getSpeciesScaledComplexity(IAlleleBeeSpecies species) {
|
||||
private int getSpeciesScaledComplexity(IAlleleBeeSpecies species) {
|
||||
if (species == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package magicbees.main.utils.compat.botania;
|
||||
|
||||
import magicbees.bees.BeeGenomeManager;
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.utils.compat.BotaniaHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.subtile.SubTileFunctional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
public class SubTileHiveacynth extends SubTileFunctional {
|
||||
|
||||
public static final String NAME = "hiveacynth";
|
||||
private static final int COST = 15000;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (supertile.getWorldObj().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (readyToProduceProduct()) {
|
||||
EnumBeeType beeType = EnumBeeType.DRONE;
|
||||
|
||||
if (supertile.getWorldObj().rand.nextDouble() < BotaniaHelper.hiveacynthPrincessSpawnRate) {
|
||||
beeType = EnumBeeType.PRINCESS;
|
||||
}
|
||||
|
||||
ItemStack stack = BeeManager.beeRoot.getMemberStack(getRandomBee(), beeType.ordinal());
|
||||
|
||||
EntityItem entity = new EntityItem(supertile.getWorldObj(), supertile.xCoord, supertile.yCoord, supertile.zCoord, stack);
|
||||
supertile.getWorldObj().spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
private IBee getRandomBee() {
|
||||
IAlleleBeeSpecies dropSpecies = BeeManager.getRandomWorldgenSpecies(supertile.getWorldObj().rand);
|
||||
IAllele[] speciesTemplate = BeeManager.beeRoot.getTemplate(dropSpecies.getUID());
|
||||
|
||||
if (supertile.getWorldObj().rand.nextDouble() < BotaniaHelper.hiveacynthRainResistRate) {
|
||||
speciesTemplate = BeeGenomeManager.addRainResist(speciesTemplate);
|
||||
}
|
||||
|
||||
IBeeGenome genome = BeeManager.beeRoot.templateAsGenome(speciesTemplate);
|
||||
return BeeManager.beeRoot.getBee(supertile.getWorldObj(), genome);
|
||||
}
|
||||
|
||||
private boolean readyToProduceProduct() {
|
||||
return redstoneSignal == 0 && ticksExisted % 20==0;//0 == 0 && mana >= getFinalCost();
|
||||
}
|
||||
|
||||
private int getFinalCost() {
|
||||
return (int)(COST * BotaniaHelper.hiveacynthManaMultiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
return BotaniaAPI.getSignatureForName(NAME).getIconForStack(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0x0071C6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMana() {
|
||||
return getFinalCost();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user