Search in sources :

Example 1 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class GuiBeealyzer method drawAnalyticsPage1.

private void drawAnalyticsPage1(IBee bee, EnumBeeType type) {
    startPage(COLUMN_0, COLUMN_1, COLUMN_2);
    drawLine(StringUtil.localize("gui.active"), COLUMN_1);
    drawLine(StringUtil.localize("gui.inactive"), COLUMN_2);
    newLine();
    newLine();
    {
        String customPrimaryBeeKey = "bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", "");
        String customSecondaryBeeKey = "bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getSecondary().getUnlocalizedName().replace("bees.species.", "");
        drawSpeciesRow(StringUtil.localize("gui.species"), bee, EnumBeeChromosome.SPECIES, checkCustomName(customPrimaryBeeKey), checkCustomName(customSecondaryBeeKey));
    }
    drawChromosomeRow(StringUtil.localize("gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN);
    drawChromosomeRow(StringUtil.localize("gui.speed"), bee, EnumBeeChromosome.SPEED);
    drawChromosomeRow(StringUtil.localize("gui.pollination"), bee, EnumBeeChromosome.FLOWERING);
    drawChromosomeRow(StringUtil.localize("gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER);
    drawLine(StringUtil.localize("gui.fertility"), COLUMN_0);
    IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY);
    IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY);
    drawFertilityInfo(primaryFertility.getValue(), COLUMN_1, getColorCoding(primaryFertility.isDominant()), 0);
    drawFertilityInfo(secondaryFertility.getValue(), COLUMN_2, getColorCoding(secondaryFertility.isDominant()), 0);
    newLine();
    IAlleleArea activeTerritory = (IAlleleArea) bee.getGenome().getActiveAllele(EnumBeeChromosome.TERRITORY);
    IAlleleArea inactiveTerritory = (IAlleleArea) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY);
    drawRow(StringUtil.localize("gui.area"), new Vect(activeTerritory.getValue()).toString(), new Vect(inactiveTerritory.getValue()).toString(), bee, EnumBeeChromosome.TERRITORY);
    drawChromosomeRow(StringUtil.localize("gui.effect"), bee, EnumBeeChromosome.EFFECT);
    newLine();
    endPage();
}
Also used : IAlleleInteger(forestry.api.genetics.IAlleleInteger) Vect(forestry.core.vect.Vect) IAlleleArea(forestry.api.genetics.IAlleleArea)

Example 2 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class AlleleEffectSnowing method doEffect.

@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    World world = housing.getWorld();
    if (isHalted(storedData, housing)) {
        return storedData;
    }
    EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
    switch(temp) {
        case HELLISH:
        case HOT:
        case WARM:
            return storedData;
        default:
    }
    int[] areaAr = genome.getTerritory();
    Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]);
    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
    for (int i = 0; i < 1; i++) {
        Vect randomPos = new Vect(world.rand.nextInt(area.x), world.rand.nextInt(area.y), world.rand.nextInt(area.z));
        Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
        posBlock = posBlock.add(offset);
        // Put snow on the ground
        if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) {
            continue;
        }
        if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
            continue;
        }
        Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.snow_layer);
    }
    return storedData;
}
Also used : Vect(forestry.core.vect.Vect) World(net.minecraft.world.World) EnumTemperature(forestry.api.core.EnumTemperature)

Example 3 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class Bee method plantFlowerRandom.

@Override
public void plantFlowerRandom(IBeeHousing housing) {
    int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
    World world = housing.getWorld();
    Random random = world.rand;
    // Correct speed
    if (random.nextInt(100) >= chance) {
        return;
    }
    // Gather required info
    IFlowerProvider provider = genome.getFlowerProvider();
    Vect area = getArea(genome, housing);
    Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
    Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
    for (int i = 0; i < 10; i++) {
        Vect randomPos = Vect.getRandomPositionInArea(random, area);
        Vect posBlock = Vect.add(housingPos, randomPos, offset);
        if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) {
            break;
        }
    }
}
Also used : IFlowerProvider(forestry.api.genetics.IFlowerProvider) Random(java.util.Random) Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect) World(net.minecraft.world.World)

Example 4 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class Bee method getArea.

private static Vect getArea(IBeeGenome genome, IBeeHousing housing) {
    int[] genomeTerritory = genome.getTerritory();
    float housingModifier = housing.getTerritoryModifier(genome, 1f);
    return new Vect(genomeTerritory).multiply(housingModifier * 3.0f);
}
Also used : Vect(forestry.core.vect.Vect) MutableVect(forestry.core.vect.MutableVect)

Example 5 with Vect

use of forestry.core.vect.Vect in project ForestryMC by ForestryMC.

the class AlleleEffectGlacial method doEffect.

@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    World world = housing.getWorld();
    if (isHalted(storedData, housing)) {
        return storedData;
    }
    EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
    switch(temp) {
        case HELLISH:
        case HOT:
        case WARM:
            return storedData;
        default:
    }
    int[] areaAr = genome.getTerritory();
    Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]);
    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
    for (int i = 0; i < 10; i++) {
        Vect randomPos = new Vect(world.rand.nextInt(area.x), world.rand.nextInt(area.y), world.rand.nextInt(area.z));
        Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
        posBlock = posBlock.add(offset);
        // Freeze water
        Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
        if (block != Blocks.water) {
            continue;
        }
        if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) {
            continue;
        }
        Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.ice);
    }
    return storedData;
}
Also used : Vect(forestry.core.vect.Vect) Block(net.minecraft.block.Block) World(net.minecraft.world.World) EnumTemperature(forestry.api.core.EnumTemperature)

Aggregations

Vect (forestry.core.vect.Vect)59 World (net.minecraft.world.World)28 ItemStack (net.minecraft.item.ItemStack)19 ICrop (forestry.api.farming.ICrop)18 MutableVect (forestry.core.vect.MutableVect)15 Block (net.minecraft.block.Block)15 Stack (java.util.Stack)11 ArrayList (java.util.ArrayList)10 TileEntity (net.minecraft.tileentity.TileEntity)9 IFarmable (forestry.api.farming.IFarmable)7 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)7 ITileStructure (forestry.api.core.ITileStructure)4 HashSet (java.util.HashSet)4 Random (java.util.Random)4 IFarmComponent (forestry.api.farming.IFarmComponent)3 EnumStructureBlock (forestry.core.utils.Schemata.EnumStructureBlock)3 IVect (forestry.core.vect.IVect)3 List (java.util.List)3 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)3 EnumTemperature (forestry.api.core.EnumTemperature)2