Search in sources :

Example 51 with Vec3i

use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.

the class AlleleEffectFungification method doBlockEffect.

private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
    World world = housing.getWorldObj();
    BlockPos housingCoordinates = housing.getCoordinates();
    Vec3i area = getModifiedArea(genome, housing);
    Vec3i halfArea = new Vec3i(area.getX() / 2, area.getY() / 2, area.getZ() / 2);
    for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
        BlockPos pos = VectUtil.getRandomPositionInArea(world.rand, area).subtract(halfArea).add(housingCoordinates);
        if (world.isBlockLoaded(pos)) {
            IBlockState blockState = world.getBlockState(pos);
            if (convertToMycelium(world, blockState, pos)) {
                return;
            } else if (growGiantMushroom(world, blockState, pos)) {
                return;
            }
        }
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 52 with Vec3i

use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.

the class AlleleEffectRadioactive method destroyEnvironment.

private static IEffectData destroyEnvironment(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    World world = housing.getWorldObj();
    Random rand = world.rand;
    Vec3i area = VectUtil.scale(genome.getTerritory(), 2);
    Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
    BlockPos posHousing = housing.getCoordinates();
    for (int i = 0; i < 20; i++) {
        BlockPos randomPos = VectUtil.getRandomPositionInArea(rand, area);
        BlockPos posBlock = randomPos.add(posHousing);
        posBlock = posBlock.add(offset);
        if (posBlock.getY() <= 1 || posBlock.getY() >= world.getActualHeight()) {
            continue;
        }
        // Don't destroy ourselves or blocks below us.
        if (posBlock.getX() == posHousing.getX() && posBlock.getZ() == posHousing.getZ() && posBlock.getY() <= posHousing.getY()) {
            continue;
        }
        if (!world.isBlockLoaded(posBlock) || world.isAirBlock(posBlock)) {
            continue;
        }
        IBlockState blockState = world.getBlockState(posBlock);
        Block block = blockState.getBlock();
        if (block instanceof BlockAlveary) {
            continue;
        }
        TileEntity tile = TileUtil.getTile(world, posBlock);
        if (tile instanceof IBeeHousing) {
            continue;
        }
        if (blockState.getBlockHardness(world, posBlock) < 0) {
            continue;
        }
        BlockUtil.setBlockToAirWithSound(world, posBlock, blockState);
        break;
    }
    return storedData;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Vec3i(net.minecraft.util.math.Vec3i) BlockAlveary(forestry.apiculture.blocks.BlockAlveary) IBlockState(net.minecraft.block.state.IBlockState) Random(java.util.Random) Block(net.minecraft.block.Block) IBeeHousing(forestry.api.apiculture.IBeeHousing) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 53 with Vec3i

use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.

the class AlleleEffectSnowing method doEffectThrottled.

@Override
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    World world = housing.getWorldObj();
    EnumTemperature temp = housing.getTemperature();
    switch(temp) {
        case HELLISH:
        case HOT:
        case WARM:
            return storedData;
        default:
    }
    Vec3i area = getModifiedArea(genome, housing);
    Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
    for (int i = 0; i < 1; i++) {
        BlockPos randomPos = VectUtil.getRandomPositionInArea(world.rand, area);
        BlockPos posBlock = randomPos.add(housing.getCoordinates()).add(offset);
        // Put snow on the ground
        if (world.isBlockLoaded(posBlock) && world.isSideSolid(posBlock.down(), EnumFacing.UP, false)) {
            IBlockState state = world.getBlockState(posBlock);
            Block block = state.getBlock();
            if (block == Blocks.SNOW_LAYER) {
                Integer layers = state.getValue(BlockSnow.LAYERS);
                if (layers < 7) {
                    IBlockState moreSnow = state.withProperty(BlockSnow.LAYERS, layers + 1);
                    world.setBlockState(posBlock, moreSnow);
                } else {
                    world.setBlockState(posBlock, Blocks.SNOW.getDefaultState());
                }
            } else if (block.isReplaceable(world, posBlock)) {
                world.setBlockState(posBlock, Blocks.SNOW_LAYER.getDefaultState());
            }
        }
    }
    return storedData;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EnumTemperature(forestry.api.core.EnumTemperature)

Example 54 with Vec3i

use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.

the class AlleleEffectSnowing method doFX.

@Override
@SideOnly(Side.CLIENT)
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    if (housing.getWorldObj().rand.nextInt(3) == 0) {
        Vec3i area = getModifiedArea(genome, housing);
        Vec3i offset = VectUtil.scale(area, -0.5F);
        BlockPos coordinates = housing.getCoordinates();
        World world = housing.getWorldObj();
        BlockPos spawn = VectUtil.getRandomPositionInArea(world.rand, area).add(coordinates).add(offset);
        ParticleRender.addEntitySnowFX(world, spawn.getX(), spawn.getY(), spawn.getZ());
        return storedData;
    } else {
        return super.doFX(genome, storedData, housing);
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 55 with Vec3i

use of net.minecraft.util.math.Vec3i in project ForestryMC by ForestryMC.

the class TilePlanter method getArea.

@Override
public Vec3i getArea() {
    if (area == null) {
        int basisArea = 5;
        if (Config.ringFarms) {
            basisArea = basisArea + 1 + Config.ringSize * 2;
        }
        area = new Vec3i(basisArea + Config.planterExtend, 13, basisArea + Config.planterExtend);
    }
    return area;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)65 BlockPos (net.minecraft.util.math.BlockPos)35 IBlockState (net.minecraft.block.state.IBlockState)15 World (net.minecraft.world.World)12 EnumFacing (net.minecraft.util.EnumFacing)7 IBeeModifier (forestry.api.apiculture.IBeeModifier)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Tessellator (net.minecraft.client.renderer.Tessellator)4 Vec3d (net.minecraft.util.math.Vec3d)4 Random (java.util.Random)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 EnumTemperature (forestry.api.core.EnumTemperature)2 ICheckPollinatable (forestry.api.genetics.ICheckPollinatable)2 EffectLightning (hellfirepvp.fracture.client.effect.fx.EffectLightning)2 EntityFXFacingParticle (hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)2 FissureData (hellfirepvp.fracture.common.fissure.FissureData)2 Vector3 (hellfirepvp.fracture.common.util.Vector3)2 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)2 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)2 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)2