use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class Bee method retrievePollen.
/* FLOWERS */
@Override
@Nullable
public IIndividual retrievePollen(IBeeHousing housing) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
World world = housing.getWorldObj();
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance) {
return null;
}
Vec3i area = getArea(genome, beeModifier);
Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
BlockPos housingPos = housing.getCoordinates();
IIndividual pollen = null;
for (int i = 0; i < 20; i++) {
BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area);
BlockPos blockPos = VectUtil.add(housingPos, randomPos, offset);
ICheckPollinatable pitcher = TileUtil.getTile(world, blockPos, ICheckPollinatable.class);
if (pitcher != null) {
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) {
pollen = pitcher.getPollen();
}
} else {
pollen = GeneticsUtil.getPollen(world, blockPos);
}
if (pollen != null) {
return pollen;
}
}
return null;
}
use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class FlowerRegistry method getAreaIterator.
@Override
public Iterator<BlockPos.MutableBlockPos> getAreaIterator(IBeeHousing beeHousing, IBee bee) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
Vec3i area = getArea(bee.getGenome(), beeModifier);
BlockPos minPos = beeHousing.getCoordinates().add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2);
BlockPos maxPos = minPos.add(area);
World world = beeHousing.getWorldObj();
return VectUtil.getAllInBoxFromCenterMutable(world, minPos, beeHousing.getCoordinates(), maxPos);
}
use of forestry.api.apiculture.IBeeModifier 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);
}
use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class AlleleEffect method getBounding.
public static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1.0f);
Vec3i area = VectUtil.scale(genome.getTerritory(), territoryModifier);
Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
BlockPos min = housing.getCoordinates().add(offset);
BlockPos max = min.add(area);
return new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ());
}
use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class EntityMinecartApiary method getBeeModifiers.
@Override
public Collection<IBeeModifier> getBeeModifiers() {
List<IBeeModifier> beeModifiers = new ArrayList<>();
beeModifiers.add(beeModifier);
for (Tuple<IHiveFrame, ItemStack> frame : inventory.getFrames()) {
IHiveFrame hiveFrame = frame.getFirst();
ItemStack stack = frame.getSecond();
IBeeModifier beeModifier = hiveFrame.getBeeModifier(stack);
beeModifiers.add(beeModifier);
}
return beeModifiers;
}
Aggregations