Search in sources :

Example 1 with IHiveDrop

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

the class BlockBeeHives method getDrops.

@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    Random random = world instanceof World ? ((World) world).rand : RANDOM;
    List<IHiveDrop> hiveDrops = getDropsForHive(getMetaFromState(state));
    Collections.shuffle(hiveDrops);
    // Grab a princess
    int tries = 0;
    boolean hasPrincess = false;
    while (tries <= 10 && !hasPrincess) {
        tries++;
        for (IHiveDrop drop : hiveDrops) {
            if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
                IBee bee = drop.getBeeType(world, pos);
                if (random.nextFloat() < drop.getIgnobleChance(world, pos, fortune)) {
                    bee.setIsNatural(false);
                }
                ItemStack princess = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.PRINCESS);
                drops.add(princess);
                hasPrincess = true;
                break;
            }
        }
    }
    // Grab drones
    for (IHiveDrop drop : hiveDrops) {
        if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
            IBee bee = drop.getBeeType(world, pos);
            ItemStack drone = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
            drops.add(drone);
            break;
        }
    }
    // Grab anything else on offer
    for (IHiveDrop drop : hiveDrops) {
        if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
            drops.addAll(drop.getExtraItems(world, pos, fortune));
            break;
        }
    }
}
Also used : Random(java.util.Random) IHiveDrop(forestry.api.apiculture.IHiveDrop) IBee(forestry.api.apiculture.IBee) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IHiveDrop

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

the class BlockExtraBeeHives method getDrops.

@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    Random random = world instanceof World ? ((World) world).rand : RANDOM;
    List<IHiveDrop> hiveDrops = getDropsForHive(getMetaFromState(state));
    Collections.shuffle(hiveDrops);
    // Grab a princess
    int tries = 0;
    boolean hasPrincess = false;
    while (tries <= 10 && !hasPrincess) {
        tries++;
        for (IHiveDrop drop : hiveDrops) {
            if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
                IBee bee = drop.getBeeType(world, pos);
                if (random.nextFloat() < drop.getIgnobleChance(world, pos, fortune)) {
                    bee.setIsNatural(false);
                }
                ItemStack princess = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.PRINCESS);
                drops.add(princess);
                hasPrincess = true;
                break;
            }
        }
    }
    // Grab drones
    for (IHiveDrop drop : hiveDrops) {
        if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
            IBee bee = drop.getBeeType(world, pos);
            ItemStack drone = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
            drops.add(drone);
            break;
        }
    }
    // Grab anything else on offer
    for (IHiveDrop drop : hiveDrops) {
        if (random.nextDouble() < drop.getChance(world, pos, fortune)) {
            drops.addAll(drop.getExtraItems(world, pos, fortune));
            break;
        }
    }
}
Also used : Random(java.util.Random) IHiveDrop(forestry.api.apiculture.IHiveDrop) IBee(forestry.api.apiculture.IBee) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IBee (forestry.api.apiculture.IBee)2 IHiveDrop (forestry.api.apiculture.IHiveDrop)2 Random (java.util.Random)2 ItemStack (net.minecraft.item.ItemStack)2 World (net.minecraft.world.World)2