Tidy villager bee registration

This commit is contained in:
mezz committed 2016-03-04 01:50:01 -08:00
1 parent ec53b6d882
commit 039af049aa
3 files changed
+29 -19

No files matched your search

@@ -5,8 +5,10 @@
******************************************************************************/
package forestry.api.apiculture;
import java.util.ArrayList;
import javax.annotation.Nonnull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
@@ -19,14 +21,19 @@ import net.minecraft.item.ItemStack;
public class BeeManager {
/**
* 0 - Common Village Bees 1 - Uncommon Village Bees (20 % of spawns)
* Common Village Bees
*/
public static ArrayList<IBeeGenome>[] villageBees;
public static List<IBeeGenome> commonVillageBees;
/**
* Uncommon Village Bees (20 % of spawns)
*/
public static List<IBeeGenome> uncommonVillageBees;
/**
* List of items that can induce swarming. Integer denotes x in 1000 chance.
*/
public static HashMap<ItemStack, Integer> inducers = new HashMap<>();
@Nonnull
public static final Map<ItemStack, Integer> inducers = new HashMap<>();
/**
* Convenient access to AlleleManager.alleleRegistry.getSpeciesRoot("rootBees")
@@ -151,7 +151,8 @@ public class PluginApiculture extends BlankForestryPlugin {
FlowerManager.flowerRegistry = new FlowerRegistry();
BeeManager.villageBees = new ArrayList[]{new ArrayList<>(), new ArrayList<>()};
BeeManager.commonVillageBees = new ArrayList<>();
BeeManager.uncommonVillageBees = new ArrayList<>();
BeeManager.beeFactory = new BeeFactory();
BeeManager.beeMutationFactory = new BeeMutationFactory();
@@ -287,16 +288,16 @@ public class PluginApiculture extends BlankForestryPlugin {
EntityUtil.registerEntity(EntityMinecartBeehouse.class, "cart.beehouse", 1, 0x000000, 0xffffff, 256, 3, true);
EntityUtil.registerEntity(EntityMinecartApiary.class, "cart.apiary", 2, 0x000000, 0xffffff, 256, 3, true);
BeeManager.villageBees[0].add(BeeDefinition.FOREST.getGenome());
BeeManager.villageBees[0].add(BeeDefinition.MEADOWS.getGenome());
BeeManager.villageBees[0].add(BeeDefinition.MODEST.getGenome());
BeeManager.villageBees[0].add(BeeDefinition.MARSHY.getGenome());
BeeManager.villageBees[0].add(BeeDefinition.WINTRY.getGenome());
BeeManager.villageBees[0].add(BeeDefinition.TROPICAL.getGenome());
BeeManager.commonVillageBees.add(BeeDefinition.FOREST.getGenome());
BeeManager.commonVillageBees.add(BeeDefinition.MEADOWS.getGenome());
BeeManager.commonVillageBees.add(BeeDefinition.MODEST.getGenome());
BeeManager.commonVillageBees.add(BeeDefinition.MARSHY.getGenome());
BeeManager.commonVillageBees.add(BeeDefinition.WINTRY.getGenome());
BeeManager.commonVillageBees.add(BeeDefinition.TROPICAL.getGenome());
BeeManager.villageBees[1].add(BeeDefinition.FOREST.getRainResist().getGenome());
BeeManager.villageBees[1].add(BeeDefinition.COMMON.getGenome());
BeeManager.villageBees[1].add(BeeDefinition.VALIANT.getGenome());
BeeManager.uncommonVillageBees.add(BeeDefinition.FOREST.getRainResist().getGenome());
BeeManager.uncommonVillageBees.add(BeeDefinition.COMMON.getGenome());
BeeManager.uncommonVillageBees.add(BeeDefinition.VALIANT.getGenome());
/*if (Config.enableVillagers) {
// Register villager stuff
@@ -342,11 +342,11 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
// Get current biome
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
ArrayList<IBeeGenome> candidates;
if (BeeManager.villageBees[1] != null && BeeManager.villageBees[1].size() > 0 && world.rand.nextDouble() < 0.2) {
candidates = BeeManager.villageBees[1];
List<IBeeGenome> candidates;
if (BeeManager.uncommonVillageBees != null && !BeeManager.uncommonVillageBees.isEmpty() && world.rand.nextDouble() < 0.2) {
candidates = BeeManager.uncommonVillageBees;
} else {
candidates = BeeManager.villageBees[0];
candidates = BeeManager.commonVillageBees;
}
EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, pos);
@@ -362,7 +362,9 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
// No valid ones found, return any of the common ones.
if (valid.isEmpty()) {
return BeeManager.beeRoot.getBee(world, BeeManager.villageBees[0].get(world.rand.nextInt(BeeManager.villageBees[0].size())));
int index = world.rand.nextInt(BeeManager.commonVillageBees.size());
IBeeGenome genome = BeeManager.commonVillageBees.get(index);
return BeeManager.beeRoot.getBee(world, genome);
}
return BeeManager.beeRoot.getBee(world, valid.get(world.rand.nextInt(valid.size())));