Java Code Examples for net.minecraft.init.Blocks#SAPLING

The following examples show how to use net.minecraft.init.Blocks#SAPLING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockGrass.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
	IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	if(plant.getBlock() == Blocks.SAPLING)
		return false;//This may break some cross mod compatability but for now its needed to prevent vanilla and some pam trees from generating

	if(plantType == EnumPlantType.Plains)
		return true;

	if(plant.getBlock() == TFCBlocks.VegDesert)
		return true;
	return false;
}
 
Example 2
Source File: ItemSupply.java    From minecraft-roguelike with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemStack getLootItem(Random rand, int level) {
	
	if(rand.nextInt(20) == 0) return new ItemStack(Items.CARROT, 1);
	if(rand.nextInt(20) == 0) return new ItemStack(Items.POTATO, 1);

	switch(rand.nextInt(8)){
	case 0: return new ItemStack(Items.WHEAT_SEEDS, rand.nextInt(8) + 1);
	case 1: return new ItemStack(Items.PUMPKIN_SEEDS, rand.nextInt(8) + 1);
	case 2: return new ItemStack(Items.MELON_SEEDS, rand.nextInt(8) + 1);		
	case 3: return new ItemStack(Items.WHEAT, rand.nextInt(8) + 1);
	case 4: return new ItemStack(Blocks.TORCH, 10 + rand.nextInt(10));
	case 5: return new ItemStack(Items.PAPER, rand.nextInt(8) + 1);
	case 6:	return new ItemStack(Items.BOOK, rand.nextInt(4) + 1);
	case 7:	return new ItemStack(Blocks.SAPLING, rand.nextInt(4) + 1, rand.nextInt(4));
	default: return new ItemStack(Items.STICK, 1);
	}
}
 
Example 3
Source File: TileEntityEnderFurnace.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't fuel
 * @param stack
 * @return
 */
private static int getItemBurnTime(ItemStack stack)
{
    if (stack.isEmpty())
    {
        return 0;
    }

    int burnTime = ForgeEventFactory.getItemBurnTime(stack) * COOKTIME_DEFAULT * 3 / 400;

    if (burnTime >= 0)
    {
        return burnTime;
    }

    Item item = stack.getItem();

    if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR)
    {
        Block block = Block.getBlockFromItem(item);
        if (block.getDefaultState().getMaterial() == Material.WOOD) { return COOKTIME_DEFAULT * 225 / 100; }
        if (block == Blocks.COAL_BLOCK) { return COOKTIME_DEFAULT * 120; }
        if (block == Blocks.WOODEN_SLAB) { return COOKTIME_DEFAULT * 45 / 40; }
        if (block == Blocks.SAPLING) return COOKTIME_DEFAULT * 3 / 4;
    }
    else
    {
        if (item == Items.COAL) return COOKTIME_DEFAULT * 12;
        if (item == Items.BLAZE_ROD) return COOKTIME_DEFAULT * 18;

        if (item == Items.LAVA_BUCKET) return COOKTIME_DEFAULT * 150;
        if (item == Items.STICK) return COOKTIME_DEFAULT * 3 / 4;
        if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;

        // Ender Furnace custom fuels
        if (item == Items.BLAZE_POWDER) return COOKTIME_DEFAULT * 9;
        if (item == Items.ENDER_PEARL) { return COOKTIME_DEFAULT * 8; }
        if (item == Items.ENDER_EYE) { return COOKTIME_DEFAULT * 17; }
    }

    return 0;
}