Search in sources :

Example 1 with IBeeHousing

use of forestry.api.apiculture.IBeeHousing in project ForestryMC by ForestryMC.

the class MutationConditionRequiresResource method getChance.

@Override
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate) {
    TileEntity tile;
    do {
        pos = pos.down();
        tile = TileUtil.getTile(world, pos);
    } while (tile instanceof IBeeHousing);
    IBlockState blockState = world.getBlockState(pos);
    return this.acceptedBlockStates.contains(blockState) ? 1 : 0;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) IBeeHousing(forestry.api.apiculture.IBeeHousing)

Example 2 with IBeeHousing

use of forestry.api.apiculture.IBeeHousing in project ForestryMC by ForestryMC.

the class JubilanceRequiresResource method isJubilant.

@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
    World world = housing.getWorldObj();
    BlockPos pos = housing.getCoordinates();
    TileEntity tile;
    do {
        pos = pos.down();
        tile = TileUtil.getTile(world, pos);
    } while (tile instanceof IBeeHousing && pos.getY() > 0);
    IBlockState blockState = world.getBlockState(pos);
    return this.acceptedBlockStates.contains(blockState);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) IBeeHousing(forestry.api.apiculture.IBeeHousing) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 3 with IBeeHousing

use of forestry.api.apiculture.IBeeHousing 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 4 with IBeeHousing

use of forestry.api.apiculture.IBeeHousing in project Binnie by ForestryMC.

the class AlvearyLogicHatchery method updateServer.

@Override
public void updateServer(TileEntityExtraBeesAlvearyPart tile) {
    if (tile.getWorldObj().rand.nextInt(2400) == 0) {
        final IBeeHousing house = tile.getMultiblockLogic().getController();
        if (!house.getErrorLogic().hasErrors()) {
            final ItemStack queenStack = house.getBeeInventory().getQueen();
            IBeeRoot beeRoot = Utils.getBeeRoot();
            final IBee queen = (queenStack.isEmpty()) ? null : beeRoot.getMember(queenStack);
            if (queen != null) {
                ItemStack larvae = beeRoot.getMemberStack(beeRoot.getBee(queen.getGenome()), EnumBeeType.LARVAE);
                for (int i = 0; i < 5; i++) {
                    if (inv.insertItem(i, larvae, false).isEmpty()) {
                        return;
                    }
                }
            }
        }
    }
}
Also used : IBeeHousing(forestry.api.apiculture.IBeeHousing) IBeeRoot(forestry.api.apiculture.IBeeRoot) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IBeeHousing (forestry.api.apiculture.IBeeHousing)4 IBlockState (net.minecraft.block.state.IBlockState)3 TileEntity (net.minecraft.tileentity.TileEntity)3 BlockPos (net.minecraft.util.math.BlockPos)2 World (net.minecraft.world.World)2 IBee (forestry.api.apiculture.IBee)1 IBeeRoot (forestry.api.apiculture.IBeeRoot)1 BlockAlveary (forestry.apiculture.blocks.BlockAlveary)1 Random (java.util.Random)1 Block (net.minecraft.block.Block)1 ItemStack (net.minecraft.item.ItemStack)1 Vec3i (net.minecraft.util.math.Vec3i)1