Search in sources :

Example 1 with BOPTrees

use of biomesoplenty.api.enums.BOPTrees in project BiomesOPlenty by Glitchfiend.

the class BlockBOPLeaves method dropApple.

// TODO: different fruits for different trees?
@Override
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) {
    // chance will initially be related to fortune as follows:  0 => 200, 1 => 180, 2 => 160, 3 => 120, 4+ => 40
    ItemStack fruit = null;
    BOPTrees tree = ((BOPTrees) state.getValue(this.variantProperty));
    switch(tree) {
        case FLOWERING:
        case JACARANDA:
        case MAHOGANY:
            if (worldIn.rand.nextInt(chance) == 0) {
                fruit = new ItemStack(BOPItems.peach, 1, 0);
            }
            break;
        case MANGROVE:
        case WILLOW:
            if (worldIn.rand.nextInt(chance) == 0) {
                fruit = new ItemStack(BOPItems.pear, 1, 0);
            }
            break;
        case YELLOW_AUTUMN:
        case ORANGE_AUTUMN:
        case MAPLE:
        case DEAD:
            if (worldIn.rand.nextInt(chance) == 0) {
                fruit = new ItemStack(BOPItems.persimmon, 1, 0);
            }
            break;
        case ORIGIN:
            if (worldIn.rand.nextInt(chance) == 0) {
                fruit = new ItemStack(Items.APPLE, 1, 0);
            }
            break;
        case FIR:
        case REDWOOD:
        case PINE:
            if (worldIn.rand.nextInt(chance) == 0) {
                fruit = new ItemStack(BOPItems.pinecone, 1, 0);
            }
            break;
        default:
            break;
    }
    if (fruit != null) {
        spawnAsEntity(worldIn, pos, fruit);
    }
}
Also used : BOPTrees(biomesoplenty.api.enums.BOPTrees) ItemStack(net.minecraft.item.ItemStack)

Example 2 with BOPTrees

use of biomesoplenty.api.enums.BOPTrees in project BiomesOPlenty by Glitchfiend.

the class BlockBOPLeaves method getMetaFromState.

@Override
public int getMetaFromState(IBlockState state) {
    BOPTrees tree = (BOPTrees) state.getValue(this.variantProperty);
    int meta = paging.getIndex(tree);
    if (!state.getValue(DECAYABLE).booleanValue()) {
        meta |= 4;
    }
    if (state.getValue(CHECK_DECAY).booleanValue()) {
        meta |= 8;
    }
    return meta;
}
Also used : BOPTrees(biomesoplenty.api.enums.BOPTrees)

Example 3 with BOPTrees

use of biomesoplenty.api.enums.BOPTrees in project BiomesOPlenty by Glitchfiend.

the class BlockBOPLeaves method onSheared.

@Override
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
    List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() == this) {
        // get default state corresponding to this tree (IE discard CHECK_DECAY and DECAYABLE bits for item meta)
        BOPTrees tree = (BOPTrees) state.getValue(this.variantProperty);
        int meta = this.getMetaFromState(this.getDefaultState().withProperty(this.variantProperty, tree));
        ret.add(new ItemStack(this, 1, meta));
    }
    return ret;
}
Also used : BOPTrees(biomesoplenty.api.enums.BOPTrees) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack)

Example 4 with BOPTrees

use of biomesoplenty.api.enums.BOPTrees in project BiomesOPlenty by Glitchfiend.

the class BlockBOPSapling method generateTree.

// try to generate a tree at the specified location, return true on success and false on failure
public boolean generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) {
        return false;
    }
    BOPTrees treeType = ((BOPTrees) state.getValue(this.variantProperty));
    WorldGenerator smallTreeGenerator = this.getSmallTreeGenerator(treeType);
    WorldGenerator bigTreeGenerator = this.getBigTreeGenerator(treeType);
    WorldGenerator megaTreeGenerator = this.getMegaTreeGenerator(treeType);
    if (megaTreeGenerator != null) {
        // if we have 4 saplings in a square, then try to grow a mega tree
        int i;
        int j;
        for (i = 0; i >= -1; --i) {
            for (j = 0; j >= -1; --j) {
                if (this.thisSaplingHere(worldIn, pos.add(i, 0, j)) && this.thisSaplingHere(worldIn, pos.add(i + 1, 0, j)) && this.thisSaplingHere(worldIn, pos.add(i, 0, j + 1)) && this.thisSaplingHere(worldIn, pos.add(i + 1, 0, j + 1))) {
                    if (this.generateMegaTree(worldIn, pos.add(i, 0, j), state, rand, megaTreeGenerator)) {
                        return true;
                    }
                }
            }
        }
    }
    if (bigTreeGenerator != null) {
        // with a one in 10 chance, try to grow a big tree
        if (rand.nextInt(10) == 0) {
            if (this.generateSmallOrBigTree(worldIn, pos, state, rand, bigTreeGenerator)) {
                return true;
            }
        }
    }
    // otherwise, try to grow a small tree
    if (smallTreeGenerator != null) {
        return this.generateSmallOrBigTree(worldIn, pos, state, rand, smallTreeGenerator);
    }
    return false;
}
Also used : BOPTrees(biomesoplenty.api.enums.BOPTrees) WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator)

Aggregations

BOPTrees (biomesoplenty.api.enums.BOPTrees)4 ItemStack (net.minecraft.item.ItemStack)2 IBlockState (net.minecraft.block.state.IBlockState)1 WorldGenerator (net.minecraft.world.gen.feature.WorldGenerator)1