use of forestry.api.apiculture.IBeekeepingMode in project ForestryMC by ForestryMC.
the class ModuleApiculture method doInit.
// TODO: Buildcraft for 1.9
// @Override
// public void registerTriggers() {
// ApicultureTriggers.initialize();
// }
@Override
public void doInit() {
File configFile = new File(Forestry.instance.getConfigFolder(), CONFIG_CATEGORY + ".cfg");
LocalizedConfiguration config = new LocalizedConfiguration(configFile, "3.0.0");
if (!Objects.equals(config.getLoadedConfigVersion(), config.getDefinedConfigVersion())) {
boolean deleted = configFile.delete();
if (deleted) {
config = new LocalizedConfiguration(configFile, "3.0.0");
}
}
initFlowerRegistry();
List<IBeekeepingMode> beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
String[] validBeekeepingModeNames = new String[beekeepingModes.size()];
for (int i = 0; i < beekeepingModes.size(); i++) {
validBeekeepingModeNames[i] = beekeepingModes.get(i).getName();
}
beekeepingMode = config.getStringLocalized("beekeeping", "mode", "NORMAL", validBeekeepingModeNames);
Log.debug("Beekeeping mode read from config: " + beekeepingMode);
secondPrincessChance = config.getFloatLocalized("beekeeping", "second.princess", secondPrincessChance, 0.0f, 100.0f);
maxFlowersSpawnedPerHive = config.getIntLocalized("beekeeping", "flowers.spawn", 20, 0, 1000);
String[] blacklist = config.getStringListLocalized("species", "blacklist", Constants.EMPTY_STRINGS);
parseBeeBlacklist(blacklist);
ticksPerBeeWorkCycle = config.getIntLocalized("beekeeping", "ticks.work", 550, 250, 850);
hivesDamageOnPeaceful = config.getBooleanLocalized("beekeeping", "hivedamage.peaceful", false);
doSelfPollination = config.getBooleanLocalized("beekeeping", "self.pollination", false);
config.save();
// Genetics
createAlleles();
BeeDefinition.initBees();
// Hives
createHives();
registerBeehiveDrops();
ItemRegistryApiculture items = getItems();
BlockRegistryApiculture blocks = getBlocks();
// Inducers for swarmer
BeeManager.inducers.put(items.royalJelly.getItemStack(), 10);
GameRegistry.registerTileEntity(TileAlvearyPlain.class, "forestry.Alveary");
GameRegistry.registerTileEntity(TileHive.class, "forestry.Swarm");
GameRegistry.registerTileEntity(TileAlvearySwarmer.class, "forestry.AlvearySwarmer");
GameRegistry.registerTileEntity(TileAlvearyHeater.class, "forestry.AlvearyHeater");
GameRegistry.registerTileEntity(TileAlvearyFan.class, "forestry.AlvearyFan");
GameRegistry.registerTileEntity(TileAlvearyHygroregulator.class, "forestry.AlvearyHygro");
GameRegistry.registerTileEntity(TileAlvearyStabiliser.class, "forestry.AlvearyStabiliser");
GameRegistry.registerTileEntity(TileAlvearySieve.class, "forestry.AlvearySieve");
GameRegistry.registerTileEntity(TileCandle.class, "forestry.Candle");
ResourceLocation beeHouseCartResource = new ResourceLocation(Constants.MOD_ID, "cart.beehouse");
EntityUtil.registerEntity(beeHouseCartResource, EntityMinecartBeehouse.class, "cart.beehouse", 1, 0x000000, 0xffffff, 256, 3, true);
ResourceLocation apiaryCartResource = new ResourceLocation(Constants.MOD_ID, "cart.apiary");
EntityUtil.registerEntity(apiaryCartResource, EntityMinecartApiary.class, "cart.apiary", 2, 0x000000, 0xffffff, 256, 3, true);
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.uncommonVillageBees.add(BeeDefinition.FOREST.getRainResist().getGenome());
BeeManager.uncommonVillageBees.add(BeeDefinition.COMMON.getGenome());
BeeManager.uncommonVillageBees.add(BeeDefinition.VALIANT.getGenome());
if (Config.enableVillagers) {
// Register villager stuff
VillageCreationApiculture villageHandler = new VillageCreationApiculture();
VillagerRegistry villagerRegistry = VillagerRegistry.instance();
villagerRegistry.registerVillageCreationHandler(villageHandler);
villagerApiarist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_APIARIST, Constants.TEXTURE_SKIN_BEEKPEEPER, Constants.TEXTURE_SKIN_ZOMBIE_BEEKPEEPER);
IForgeRegistry<VillagerRegistry.VillagerProfession> villagerProfessions = ForgeRegistries.VILLAGER_PROFESSIONS;
villagerProfessions.register(villagerApiarist);
ItemStack wildcardPrincess = new ItemStack(items.beePrincessGE, 1);
ItemStack wildcardDrone = new ItemStack(items.beeDroneGE, 1);
ItemStack apiary = new ItemStack(blocks.apiary);
ItemStack provenFrames = items.frameProven.getItemStack();
ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE);
ItemStack endDrone = BeeDefinition.ENDED.getMemberStack(EnumBeeType.DRONE);
ItemStack propolis = new ItemStack(items.propolis, 1);
VillagerRegistry.VillagerCareer apiaristCareer = new VillagerRegistry.VillagerCareer(villagerApiarist, "apiarist");
apiaristCareer.addTrade(1, new VillagerApiaristTrades.GiveRandomCombsForItems(items.beeComb, new ItemStack(Items.WHEAT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)), new VillagerApiaristTrades.GiveRandomCombsForItems(items.beeComb, new ItemStack(Items.CARROT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)), new VillagerApiaristTrades.GiveRandomCombsForItems(items.beeComb, new ItemStack(Items.POTATO), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)));
apiaristCareer.addTrade(2, new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 4), new ItemStack(items.smoker), null), new VillagerTradeLists.GiveItemForLogsAndEmeralds(apiary, new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(16, 32), new EntityVillager.PriceInfo(1, 2)), new VillagerApiaristTrades.GiveRandomHiveDroneForItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4)));
apiaristCareer.addTrade(3, new VillagerTradeLists.GiveEmeraldForItems(wildcardPrincess, null), new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6)));
apiaristCareer.addTrade(4, new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null), new VillagerTradeLists.GiveItemForTwoItems(wildcardPrincess, null, new ItemStack(Items.ENDER_EYE), new EntityVillager.PriceInfo(12, 16), endDrone, null));
}
blocks.apiary.init();
blocks.beeHouse.init();
blocks.beeChest.init();
}
use of forestry.api.apiculture.IBeekeepingMode in project ForestryMC by ForestryMC.
the class Bee method produceStacks.
@Override
public NonNullList<ItemStack> produceStacks(IBeeHousing housing) {
World world = housing.getWorldObj();
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
NonNullList<ItemStack> products = NonNullList.create();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
IBeeModifier beeModeModifier = mode.getBeeModifier();
// Bee genetic speed * beehousing * beekeeping mode
float speed = genome.getSpeed() * beeHousingModifier.getProductionModifier(genome, 1f) * beeModeModifier.getProductionModifier(genome, 1f);
// / Primary Products
for (Map.Entry<ItemStack, Float> entry : primary.getProductChances().entrySet()) {
if (world.rand.nextFloat() < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
// / Secondary Products
for (Map.Entry<ItemStack, Float> entry : secondary.getProductChances().entrySet()) {
if (world.rand.nextFloat() < Math.round(entry.getValue() / 2) * speed) {
products.add(entry.getKey().copy());
}
}
// / Specialty products
if (primary.isJubilant(genome, housing) && secondary.isJubilant(genome, housing)) {
for (Map.Entry<ItemStack, Float> entry : primary.getSpecialtyChances().entrySet()) {
if (world.rand.nextFloat() < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
}
BlockPos housingCoordinates = housing.getCoordinates();
return genome.getFlowerProvider().affectProducts(world, this, housingCoordinates, products);
}
Aggregations